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();
    }
  }
  /**
   * Get the {@link Region}s of the specified {@link Country} or all regions, if <code>countryID
   * </code> is <code>null</code>.
   *
   * @param countryID the object-id of the country containing the requested regions or <code>null
   *     </code> to obtain all regions.
   * @param fetchGroups the fetch-groups or <code>null</code>.
   * @param maxFetchDepth the maximum fetch-depth (i.e. the maximum depth of the returned object
   *     graph). Use {@link NLJDOHelper#MAX_FETCH_DEPTH_NO_LIMIT} for unlimited graph depth.
   * @param monitor the monitor for progress feedback.
   * @return the regions.
   */
  public synchronized List<Region> getRegions(
      CountryID countryID, String[] fetchGroups, int maxFetchDepth, ProgressMonitor monitor) {
    monitor.beginTask("Getting regions", 100);
    try {
      geographyManager = getEjbProvider().getRemoteBean(GeographyManagerRemote.class);
      monitor.worked(10);

      Collection<RegionID> regionIDs = geographyManager.getRegionIDs(countryID);
      monitor.worked(40);

      return getJDOObjects(
          null, regionIDs, fetchGroups, maxFetchDepth, new SubProgressMonitor(monitor, 50));
    } catch (Exception x) {
      throw new RuntimeException(x);
    } finally {
      geographyManager = null;
      monitor.done();
    }
  }
  @Override
  protected Collection<Region> retrieveJDOObjects(
      Set<RegionID> objectIDs, String[] fetchGroups, int maxFetchDepth, ProgressMonitor monitor)
      throws Exception {
    monitor.beginTask("Loading Regions", 100);
    try {
      GeographyManagerRemote gm = geographyManager;
      if (gm == null) gm = getEjbProvider().getRemoteBean(GeographyManagerRemote.class);

      monitor.worked(50);
      Collection<Region> regions = gm.getRegions(objectIDs, fetchGroups, maxFetchDepth);
      monitor.worked(50);
      return regions;
    } catch (Exception x) {
      throw new RuntimeException(x);
    } finally {
      monitor.done();
    }
  }
  public synchronized Region importRegion(
      RegionID regionID,
      boolean get,
      String[] fetchGroups,
      int maxFetchDepth,
      ProgressMonitor monitor) {
    monitor.beginTask("Importing region", 100);
    try {
      GeographyManagerRemote gm = getEjbProvider().getRemoteBean(GeographyManagerRemote.class);
      monitor.worked(10);

      Region region = gm.importRegion(regionID, get, fetchGroups, maxFetchDepth);
      if (region != null) getCache().put(null, region, fetchGroups, maxFetchDepth);

      monitor.worked(90);

      return region;
    } catch (Exception e) {
      throw new RuntimeException(e);
    } finally {
      monitor.done();
    }
  }
예제 #6
0
  public void assignNewPriceConfig(
      IInnerPriceConfig innerPC, final boolean inherited, final ProgressMonitor monitor) {
    monitor.beginTask(
        Messages.getString(
            "org.nightlabs.jfire.trade.admin.ui.gridpriceconfig.PriceConfigComposite.job.assignPriceConfig.name"),
        100); //$NON-NLS-1$
    try {
      if (innerPC != null) {
        PriceConfigID innerPCID = (PriceConfigID) JDOHelper.getObjectId(innerPC);
        if (innerPCID != null) innerPC = retrieveInnerPriceConfigForEditing(innerPCID);
      }
      monitor.worked(80);

      final IInnerPriceConfig finalInnerPC = innerPC;

      Display.getDefault()
          .syncExec(
              new Runnable() {
                public void run() {
                  if (isDisposed()) return;

                  packageProductType.setInnerPriceConfig(finalInnerPC);
                  packageProductType
                      .getFieldMetaData(ProductType.FieldName.innerPriceConfig)
                      .setValueInherited(inherited);
                  if (packageProductType.getInnerPriceConfig() != null) {
                    GridPriceConfig packagePriceConfig =
                        (GridPriceConfig) packageProductType.getPackagePriceConfig();
                    if (packagePriceConfig != null)
                      packagePriceConfig.adoptParameters(
                          packageProductType.getInnerPriceConfig(), false);
                  }

                  _setPackageProductType(packageProductType);
                  dirtyStateManager.markDirty();
                  monitor.worked(20);
                }
              });
    } finally {
      monitor.done();
    }
  }