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;
  }
Exemplo n.º 2
0
  /*
   * (non-Javadoc)
   * @see au.org.aurin.wif.svc.report.ReportService#getAllocationAnalysisReport(
   * au.org.aurin.wif.model.allocation.AllocationScenario)
   */
  public AllocationAnalysisReport getAllocationAnalysisReport(
      final AllocationScenario allocationScenario)
      throws WifInvalidInputException, WifInvalidConfigException, ParsingException {
    LOGGER.info("getAllocationAnalysisReport for: {}", allocationScenario.getLabel());
    final AllocationAnalysisReport allocationAnalysisReport = new AllocationAnalysisReport();

    final WifProject project = allocationScenario.getWifProject();
    final AllocationConfig allocationConfig = project.getAllocationConfig();
    final String projectId = allocationScenario.getProjectId();
    allocationAnalysisReport.setReportType(allocationScenario.getDocType());
    allocationAnalysisReport.setLabel(project.getName());
    allocationAnalysisReport.setScenarioLabel(allocationScenario.getDocType());
    allocationAnalysisReport.setProjectId(allocationScenario.getProjectId());

    // Getting land use information
    LOGGER.info("Getting land use information: {}");
    final DemandConfig demandConfig = demandConfigService.getDemandConfig(projectId);
    LOGGER.info("Associated demandConfigId: {}", demandConfig.getId());
    final TreeSet<Projection> projections = new TreeSet<Projection>(new YearComparator());
    projections.addAll(demandConfig.getProjections());
    final Projection current = projections.first();
    LOGGER.info("current year projection: {}", current.getLabel());
    // setting up taking into account current projection year is not a
    // projection by itself,per se,
    final NavigableSet<Projection> projectedSet = projections.tailSet(projections.first(), false);
    final Set<AllocationLU> allocationLandUses = project.getAllocationLandUses();
    for (final AllocationLU allocationLU : allocationLandUses) {
      if (allocationLU.getLabel() == null) {
        LOGGER.warn("Not performing analysis for null label for LU: {}", allocationLU.getId());
        continue;
      }
      for (final Projection projection : projectedSet) {
        LOGGER.info("getAreaByLU for: {}, id {}", allocationLU.getLabel(), allocationLU.getId());
        final String allocationFFName =
            allocationConfig.getAllocationColumnsMap().get(projection.getLabel());

        final Double areaByLU =
            geodataFinder.getAreaByLU(
                project.getSuitabilityConfig().getUnifiedAreaZone(),
                project.getAreaLabel(),
                project.getExistingLUAttributeName(),
                allocationLU.getFeatureFieldName(),
                allocationFFName,
                allocationLU.getAllocationFeatureFieldName());
        final AreaRequirement ar = new AreaRequirement();
        ar.setAllocationLU(allocationLU);
        ar.setRequiredArea(areaByLU);
        ar.setProjection(projection);
        allocationAnalysisReport.getLandUseInformation().add(ar);
      }
    }
    // Getting population and employment information
    LOGGER.info("Getting population and employment information: {}");
    final DemographicTrend demographicTrend =
        demandConfig.getTrendByLabel(
            allocationScenario.getDemandScenario().getDemographicTrendLabel());
    final Set<DemographicData> demographicData = demographicTrend.getDemographicData();
    for (final DemographicData data : demographicData) {
      if (data instanceof ResidentialDemographicData) {
        allocationAnalysisReport.getPopulationInformation().add((ResidentialDemographicData) data);
      } else if (data instanceof EmploymentDemographicData) {
        allocationAnalysisReport.getEmploymentInformation().add((EmploymentDemographicData) data);
      }
    }
    LOGGER.info(
        "Finished allocationAnalysisReport for: {}", allocationAnalysisReport.getProjectId());
    return allocationAnalysisReport;
  }