public synchronized DunningConfig storeDunningConfig(
      DunningConfig dunningConfig,
      boolean get,
      String[] fetchGroups,
      int maxFetchDepth,
      ProgressMonitor monitor) {
    if (dunningConfig == null)
      throw new NullPointerException("DunningConfig to save must not be null");
    monitor.beginTask("Storing dunningConfig: " + dunningConfig.getDunningConfigID(), 3);
    try {
      DunningManagerRemote im =
          JFireEjb3Factory.getRemoteBean(
              DunningManagerRemote.class,
              GlobalSecurityReflector.sharedInstance().getInitialContextProperties());
      monitor.worked(1);

      DunningConfig result = im.storeDunningConfig(dunningConfig, get, fetchGroups, maxFetchDepth);
      if (result != null) getCache().put(null, result, fetchGroups, maxFetchDepth);

      monitor.worked(1);
      monitor.done();
      return result;
    } catch (Exception e) {
      monitor.done();
      throw new RuntimeException(e);
    }
  }
  @Override
  /** {@inheritDoc} */
  protected synchronized Collection<DunningConfig> retrieveJDOObjects(
      Set<DunningConfigID> dunningConfigIDs,
      String[] fetchGroups,
      int maxFetchDepth,
      ProgressMonitor monitor)
      throws Exception {

    monitor.beginTask("Loading DunningConfigs", 1);
    try {
      DunningManagerRemote im =
          JFireEjb3Factory.getRemoteBean(
              DunningManagerRemote.class,
              GlobalSecurityReflector.sharedInstance().getInitialContextProperties());
      return im.getDunningConfigs(dunningConfigIDs, fetchGroups, maxFetchDepth);
    } catch (Exception e) {
      monitor.setCanceled(true);
      throw e;

    } finally {
      monitor.worked(1);
      monitor.done();
    }
  }
Ejemplo n.º 3
0
 /** Returns a new ReportParameterManager bean. */
 @Deprecated
 public static ReportParameterManagerRemote getReportParameterManager() {
   try {
     return JFireEjb3Factory.getRemoteBean(
         ReportParameterManagerRemote.class, Login.getLogin().getInitialContextProperties());
   } catch (Exception e) {
     throw new RuntimeException(e);
   }
 }
 public synchronized Collection<DunningConfig> getDunningConfigs(
     String[] fetchGroups, int maxFetchDepth, ProgressMonitor monitor) {
   monitor.beginTask("Loading dunningConfigs", 1);
   try {
     DunningManagerRemote im =
         JFireEjb3Factory.getRemoteBean(
             DunningManagerRemote.class,
             GlobalSecurityReflector.sharedInstance().getInitialContextProperties());
     Set<DunningConfigID> is = im.getDunningConfigIDs();
     monitor.done();
     return getJDOObjects(null, is, fetchGroups, maxFetchDepth, monitor);
   } catch (Exception e) {
     throw new RuntimeException(e);
   }
 }
Ejemplo n.º 5
0
  public static ArticleContainerEditorInput createEditorInput() {
    TradeManagerRemote tm;
    try {
      try {
        Login.getLogin();

        TradeConfigModule tradeConfigModule =
            ConfigUtil.getUserCfMod(
                TradeConfigModule.class,
                new String[] {
                  FetchPlan.DEFAULT, TradeConfigModule.FETCH_GROUP_CURRENCY,
                },
                NLJDOHelper.MAX_FETCH_DEPTH_NO_LIMIT,
                new NullProgressMonitor()); // TODO async!

        tm =
            JFireEjb3Factory.getRemoteBean(
                TradeManagerRemote.class, Login.getLogin().getInitialContextProperties());
        // by default get the customerID of the anonymous customer
        AnchorID customerID =
            (AnchorID)
                JDOHelper.getObjectId(
                    LegalEntityDAO.sharedInstance()
                        .getAnonymousLegalEntity(new NullProgressMonitor()));
        //			 FIXME IDPREFIX (next line) should be asked from user if necessary!
        OrderID orderID =
            tm.createQuickSaleWorkOrder(
                customerID,
                null,
                tradeConfigModule.getCurrencyID(),
                new SegmentTypeID[] {null}); // null here is a shortcut for default segment type
        return new ArticleContainerEditorInput(orderID);
      } catch (LoginException le) {
        return null;
      }
    } catch (Throwable t) {
      throw new RuntimeException(t);
    }
  }
  /* (non-Javadoc)
   * @see org.nightlabs.jfire.geography.GeographyTemplateDataManagerRemote#initialiseJDOLifecycleListeners()
   */
  @TransactionAttribute(TransactionAttributeType.REQUIRED)
  @RolesAllowed("_System_")
  public void initialiseJDOLifecycleListeners() throws Exception {
    final String subscriberOrganisationID = getOrganisationID();
    final String rootOrganisationID = getRootOrganisationID();
    if (subscriberOrganisationID.equals(
        rootOrganisationID)) // only register in the root organisation, if that's not the local
                             // organisation
    return;

    final PersistenceManager pm = createPersistenceManager();
    try {
      pm.getExtent(GeographyTemplateDataNotificationReceiver.class);

      final NotificationReceiverID notificationReceiverID =
          NotificationReceiverID.create(
              rootOrganisationID,
              SubscriptionUtil.SUBSCRIBER_TYPE_ORGANISATION,
              subscriberOrganisationID,
              GeographyTemplateDataNotificationFilter.class.getName());
      try {
        pm.getObjectById(notificationReceiverID);
        logger.info(
            "initialiseJDOLifecycleListeners: NotificationReceiver for CSV changes in the root organisation has already been registered. Skipping!");
        return; // it exists already => doing nothing
      } catch (final JDOObjectNotFoundException x) {
        // it doesn't exist => register the persistent lifecycle listener
      }

      // check if the root-organisation is already registered
      try {
        pm.getObjectById(OrganisationID.create(rootOrganisationID));
      } catch (final JDOObjectNotFoundException x) {
        logger.info(
            "initialiseJDOLifecycleListeners: NotificationReceiver does not yet exist, but I cannot register the JDO lifecycle listener in the root organisation, because the root organisation is not yet registered.");
        return;
      }
      logger.info(
          "initialiseJDOLifecycleListeners: NotificationReceiver does not yet exist. Will register persistent JDO lifecycle listener in root organisation and persist NotificationReceiver now.");

      final GeographyTemplateDataNotificationFilter notificationFilter =
          new GeographyTemplateDataNotificationFilter(
              rootOrganisationID,
              SubscriptionUtil.SUBSCRIBER_TYPE_ORGANISATION,
              subscriberOrganisationID,
              GeographyTemplateDataNotificationFilter.class.getName());
      PersistentNotificationEJBRemote persistentNotificationEJB;

      try {
        persistentNotificationEJB =
            JFireEjb3Factory.getRemoteBean(
                PersistentNotificationEJBRemote.class,
                getInitialContextProperties(rootOrganisationID));
      } catch (final JDOObjectNotFoundException x) {
        logger.warn(
            "Creating JDO lifecycle listeners for CSV instances in the root organisation failed. Reason: Root organisation "
                + rootOrganisationID
                + " does not exist.");
        return;
      }

      persistentNotificationEJB.storeNotificationFilter(notificationFilter, false, null, 1);

      final GeographyTemplateDataNotificationReceiver notificationReceiver =
          new GeographyTemplateDataNotificationReceiver(notificationFilter);
      pm.makePersistent(notificationReceiver);

      logger.info(
          "initialiseJDOLifecycleListeners: NotificationReceiver for changes of CSV instances in the root organisation has been successfully created.");
    } finally {
      pm.close();
    }
  }