Author: chatellier Date: 2011-01-10 14:42:03 +0000 (Mon, 10 Jan 2011) New Revision: 489 Log: Gestion des zones / sous zones (indicateurs) Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/WebService.java Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/WebService.java =================================================================== --- trunk/coser-business/src/main/java/fr/ifremer/coser/services/WebService.java 2011-01-10 14:33:20 UTC (rev 488) +++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/WebService.java 2011-01-10 14:42:03 UTC (rev 489) @@ -531,7 +531,7 @@ * Retourne les indicateurs calculés avec leurs traductions scientifique * pour la zone et l'especes souhaitées. * - * @param zone zone + * @param zone zone (zoneid-surveyname) * @param species especes * @param locale locale ({@code fr} ou {@code en}) * @return la liste des indicateurs @@ -540,32 +540,47 @@ public Map<String, String> getIndicators(String zone, String species, String locale) throws CoserBusinessException { Map<String, String> indicators = new TreeMap<String, String>(); + String zoneId = zone.substring(0, zone.indexOf('-')); + String survey = zone.substring(zone.indexOf('-') + 1); + // parcours des resultats disponibles File projectsDirectory = config.getWebProjectsDirectory(); File[] projectFiles = projectsDirectory.listFiles(); if (projectFiles != null) { for (File projectFile : projectFiles) { if (projectFile.isDirectory()) { - Project project = projectService.openProject(projectFile.getName(), projectsDirectory); + File selectionsDirectory = new File(projectFile, CoserConstants.STORAGE_SELECTION_DIRECTORY); + File[] selectionFiles = selectionsDirectory.listFiles(); - for (Selection selection : project.getSelections().values()) { - boolean resultFound = false; + // selection iteration + if (selectionFiles != null) { + for (File selectionFile : selectionFiles) { + if (selectionFile.isDirectory()) { + File resultsDirectory = new File(selectionFile, CoserConstants.STORAGE_RESULTS_DIRECTORY); + File[] resultFiles = resultsDirectory.listFiles(); + + // result iteration + if (resultFiles != null) { + for (File resultFile : resultFiles) { + if (resultFile.isDirectory()) { + RSufiResult rsufiResult = projectService.getRSufiResult(resultFile); - for (RSufiResult rsufiResult : selection.getRsufiResults()) { - - // extraction des especes pour le résultat demandé - if (rsufiResult.getZone() != null && rsufiResult.getZone().equals(zone)) { - // data loading not necessary here - Map<String, String> resultIndicators = getRsufiResultIndicators(project, selection, rsufiResult, species, locale); - indicators.putAll(resultIndicators); - resultFound = true; - break; + // extraction des especes pour le résultat demandé + if (rsufiResult.getZone() != null && rsufiResult.getZone().equals(zoneId)) { + + // get survey name (other condition) + String surveyName = projectService.getProjectSurveyName(resultFile, rsufiResult); + + // data loading not necessary here + Map<String, String> resultIndicators = getRsufiResultIndicators(resultFile, rsufiResult, species, locale); + indicators.putAll(resultIndicators); + break; + } + } + } + } } } - - if (resultFound) { - break; - } } } } @@ -578,29 +593,19 @@ * Recupere la liste de toutes les especes nom sci et nom off à partir * d'un resultat. * - * @param project project - * @param selection selection + * @param resultDirectory rsufi result directory * @param rsufiResult result * @param species to get indicator * @param locale locale ({@code fr} ou {@code en}) * @return indicator for species * @throws CoserBusinessException */ - protected Map<String, String> getRsufiResultIndicators(Project project, - Selection selection, RSufiResult rsufiResult, String species, String locale) throws CoserBusinessException { + protected Map<String, String> getRsufiResultIndicators(File resultDirectory, RSufiResult rsufiResult, String species, String locale) throws CoserBusinessException { MultiKeyMap defaultIndicators = getIndicatorsMap(); Map<String, String> result = new HashMap<String, String>(); - // on peu lours mais reconstruit le path jusqu'au fichier estcomind - File projectsDirectory = config.getWebProjectsDirectory(); - File projectDirectory = new File(projectsDirectory, project.getName()); - File selectionsDirectory = new File(projectDirectory, CoserConstants.STORAGE_SELECTION_DIRECTORY); - File selectionDirectory = new File(selectionsDirectory, selection.getName()); - File resultsDirectory = new File(selectionDirectory, CoserConstants.STORAGE_RESULTS_DIRECTORY); - File resultDirectory = new File(resultsDirectory, rsufiResult.getName()); - // le fichier estcomind File estPopIndFile = new File(resultDirectory, rsufiResult.getEstPopIndName());