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();
    }
  }
 public synchronized DunningConfig getDunningConfig(
     DunningConfigID dunningConfigID,
     String[] fetchGroups,
     int maxFetchDepth,
     ProgressMonitor monitor) {
   monitor.beginTask("Loading dunningConfig " + dunningConfigID.dunningConfigID, 1);
   DunningConfig dunningConfig =
       getJDOObject(
           null, dunningConfigID, fetchGroups, maxFetchDepth, new SubProgressMonitor(monitor, 1));
   monitor.done();
   return dunningConfig;
 }
 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);
   }
 }
  /**
   * 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();
    }
  }
Exemplo n.º 7
0
  /**
   * Prints the given report (registryItemID) with the given parameters. The {@link ReportUseCase}
   * for the given report will be searched and used for printing.
   *
   * @param registryItemID The id of the report to print.
   * @param params The parameters to use to render the report.
   * @param monitor The monitor to report progress to.
   * @throws PrinterException If an error occurs while printing.
   */
  public void printWithParams(
      ReportRegistryItemID registryItemID, Map<String, Object> params, ProgressMonitor monitor)
      throws PrinterException {
    monitor.beginTask(
        Messages.getString(
            "org.nightlabs.jfire.reporting.ui.layout.action.print.AbstractPrintReportLayoutAction.task.printingReportLayout"),
        6); //$NON-NLS-1$
    String useCaseID = getReportUseCaseID(registryItemID, params);
    if (useCaseID == null) {
      // Try to lookup the UseCase by the reportLayoutType
      ReportUseCase useCase =
          ReportUseCaseRegistry.sharedInstance()
              .getReportUseCaseByLayoutType(registryItemID.reportRegistryItemType);
      if (useCase != null) useCaseID = useCase.getId();
    }
    if (useCaseID == null) {
      // if no usecase found till now, try to find the default/fallback one
      ReportUseCase useCase =
          ReportUseCaseRegistry.sharedInstance()
              .getReportUseCase(ReportingPlugin.DEFAULT_REPORT_USE_CASE_ID);
      if (useCase == null) {
        throw new PrinterException(
            "No useCaseID could be found. A usecase for the type "
                + registryItemID.reportRegistryItemType
                + " could not be found and also the default/fallback usecase seems not to be registered."); //$NON-NLS-1$ //$NON-NLS-2$
      }
      useCaseID = useCase.getId();
    }

    RenderReportRequest renderRequest = new RenderReportRequest();
    renderRequest.setReportRegistryItemID(registryItemID);
    renderRequest.setParameters(params);
    Locale requestLocale =
        getRenderRequestLocale(registryItemID, params, new SubProgressMonitor(monitor, 1));
    if (requestLocale != null) {
      renderRequest.setLocale(requestLocale);
    } else {
      renderRequest.setLocale(Locale.getDefault());
    }
    PrintReportLayoutUtil.printReportLayoutWithDefaultFormat(
        renderRequest, useCaseID, new SubProgressMonitor(monitor, 5));
    monitor.done();
  }
Exemplo n.º 8
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();
    }
  }
  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();
    }
  }