コード例 #1
0
  public DemandOutcome createDemandOutcome(
      final List<AreaRequirement> outcome, final String projectId)
      throws WifInvalidInputException, WifInvalidConfigException {
    final DemandOutcome newDemandOutcome = new DemandOutcome();
    newDemandOutcome.setLabel("automated-manualdemand");
    LOGGER.debug("creating a new ManualDemandScenario={}", newDemandOutcome.getLabel());
    final WifProject project = projectService.getProject(projectId);
    newDemandOutcome.setProjectId(project.getId());
    for (final AreaRequirement areaRequirement : outcome) {
      // final ManualAreaRequirement manualAreaRequirement = new
      // ManualAreaRequirement();
      // manualAreaRequirement.setAllocationLU(areaRequirement.getAllocationLU());
      // manualAreaRequirement.setRequiredArea(areaRequirement.getRequiredArea());
      // manualAreaRequirement.setProjection(areaRequirement.getProjection());

      areaRequirement.setProjectionLabel(areaRequirement.getProjection().getLabel());

      newDemandOutcome.addAreaRequirenment(areaRequirement);
      LOGGER.info(
          "recreating manually required area for land use  {} in projection "
              + areaRequirement.getProjection().getLabel()
              + " is : {}",
          areaRequirement.getAllocationLU().getLabel(),
          areaRequirement.getRequiredArea());
    }

    final DemandOutcome savedDemandOutcome =
        demandOutcomeDao.persistDemandOutcome(newDemandOutcome);
    LOGGER.debug("returning the ManualDemandScenario with id={}", savedDemandOutcome.getId());
    return savedDemandOutcome;
  }
コード例 #2
0
  /*
   * (non-Javadoc)
   * @see au.org.aurin.wif.svc.suitability.ManualDemandScenarioService#
   * createManualDemandScenario
   * (au.org.aurin.wif.model.suitability.ManualDemandScenario, java.lang.String)
   */
  public DemandOutcome createDemandOutcomeNew(
      final DemandOutcome demandOutcome, final String projectId)
      throws WifInvalidInputException, WifInvalidConfigException, ParsingException,
          IncompleteDemandOutcomeException {
    if (demandOutcome == null) {
      LOGGER.error("createManualDemandScenario failed: ManualDemandScenario is null or invalid");
      throw new WifInvalidInputException(
          "createManualDemandScenario failed: ManualDemandScenario is null or invalid");
    }
    final WifProject project = projectService.getProject(projectId);
    // final ManualDemandConfig manualdemandConfig = manualdemandConfigService
    // .getManualDemandConfig(projectId);
    final DemandConfig demandConfig = demandConfigService.getDemandConfig(projectId);
    project.setDemandConfig(demandConfig);
    // project.setManualDemandConfig(manualdemandConfig);
    try {
      // ManualDemandScenario = ManualDemandScenarioParser.parse(
      // ManualDemandScenario, manualdemandConfig, project);
    } catch (final Exception e) {
      LOGGER.error("Parsing new scenario failed", e);
      throw new IncompleteDemandOutcomeException("Parsing new scenario failed", e);
    }
    LOGGER.debug("persisting the DemandOutcome={}", demandOutcome.getLabel());
    demandOutcome.setProjectId(projectId);
    final DemandOutcome savedDemandOutcome = demandOutcomeDao.persistDemandOutcome(demandOutcome);
    LOGGER.debug("returning the ManualDemandScenario with id={}", savedDemandOutcome.getId());
    project.getDemandOutcomesMap().put(savedDemandOutcome.getId(), savedDemandOutcome.getLabel());
    wifProjectDao.updateProject(project);

    return savedDemandOutcome;
  }