/* * (non-Javadoc) * @see * au.org.aurin.wif.svc.ManualDemandScenarioService#updateManualDemandScenario * (au.org.aurin.wif.model.allocation.ManualDemandScenario, java.lang.String) */ public void updateDemandOutcome(final DemandOutcome demandOutcome, final String projectId) throws WifInvalidInputException, WifInvalidConfigException, ParsingException { LOGGER.info( "updating ManualDemandScenario: {}, with id: {}", demandOutcome.getLabel(), demandOutcome.getId()); try { if (demandOutcome.getProjectId().equals(projectId)) { demandOutcome.setRevision( demandOutcomeDao.findDemandOutcomeById(demandOutcome.getId()).getRevision()); demandOutcomeDao.updateDemandOutcome(demandOutcome); } else { LOGGER.error( "illegal argument, the ManualDemandScenario supplied doesn't belong to project: " + projectId); throw new WifInvalidInputException( "illegal argument, the ManualDemandScenario supplied doesn't belong to project: " + projectId); } } catch (final IllegalArgumentException e) { LOGGER.error("illegal argument, the ManualDemandScenario supplied is invalid "); throw new WifInvalidInputException( "illegal argument, the ManualDemandScenario supplied is invalid ", e); } }
/** * Gets the suitability scenario. * * @param id the id * @return the suitability scenario * @throws WifInvalidInputException the wif invalid input exception * @throws WifInvalidConfigException the wif invalid config exception * @throws ParsingException the parsing exception */ public DemandOutcome getDemandOutcome(final String id) throws WifInvalidInputException, WifInvalidConfigException, ParsingException { LOGGER.debug("getting the ManualDemandScenario with ID={}", id); try { final DemandOutcome demandOutcome = demandOutcomeDao.findDemandOutcomeById(id); if (demandOutcome == null) { LOGGER.error( "illegal argument, the ManualDemandScenario with the ID " + id + " supplied was not found "); throw new InvalidEntityIdException( "illegal argument, the ManualDemandScenario with the ID " + id + " supplied was not found "); } // final String projectId = demandOutcome.getProjectId(); // final WifProject project = projectService.getProject(projectId); // final ManualDemandConfig manualdemandConfig = manualdemandConfigService // .getManualDemandConfig(projectId); // project.setManualDemandConfig(manualdemandConfig); // ManualDemandScenario = ManualDemandScenarioParser.parse( // ManualDemandScenario, manualdemandConfig, project); // ManualDemandScenario.setManualDemandConfig(manualdemandConfig); // ManualDemandScenario = ManualDemandScenarioParser // .parseAreaRequirements(ManualDemandScenario); // demandOutcome.setWifProject(project); return demandOutcome; } catch (final IllegalArgumentException e) { LOGGER.error( "illegal argument, the ID " + id + " supplied doesn't identify a valid ManualDemandScenario "); throw new WifInvalidInputException( "illegal argument, the ID " + id + " supplied doesn't identify a valid ManualDemandScenario ", e); } }
/* * (non-Javadoc) * @see * au.org.aurin.wif.svc.ManualDemandScenarioService#deleteManualDemandScenario * (java.lang.String, java.lang.String) */ public void deleteDemandOutcome(final String id, final String projectId) throws WifInvalidInputException, WifInvalidConfigException, ParsingException { LOGGER.info("deleting the ManualDemandScenario with ID={}", id); final DemandOutcome demandOutcome = demandOutcomeDao.findDemandOutcomeById(id); if (demandOutcome.getProjectId().equals(projectId)) { // Deleting associated area requirements final List<AreaRequirement> requirements = areaRequirementDao.getAreaRequirements(demandOutcome.getId()); for (final AreaRequirement areaRequirement : requirements) { areaRequirementDao.deleteAreaRequirement(areaRequirement); } demandOutcomeDao.deleteDemandOutcome(demandOutcome); final WifProject project = projectService.getProject(projectId); project.getDemandOutcomesMap().remove(id); wifProjectDao.updateProject(project); } else { LOGGER.error( "illegal argument, the ManualDemandScenario supplied doesn't belong to project: " + projectId); throw new WifInvalidInputException( "illegal argument, the ManualDemandScenario supplied doesn't belong to project: " + projectId); } }