r1065 - in trunk/coser-business/src/main: java/fr/ifremer/coser/services resources/i18n
Author: echatellier Date: 2012-08-24 13:52:37 +0200 (Fri, 24 Aug 2012) New Revision: 1065 Url: http://forge.codelutin.com/repositories/revision/coser/1065 Log: Fix update process and generated mail content Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/WebService.java trunk/coser-business/src/main/resources/i18n/coser-business_en_GB.properties trunk/coser-business/src/main/resources/i18n/coser-business_fr_FR.properties 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 2012-08-21 10:06:08 UTC (rev 1064) +++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/WebService.java 2012-08-24 11:52:37 UTC (rev 1065) @@ -707,15 +707,21 @@ File projectsDirectory = config.getWebIndicatorsProjectsDirectory(); File mapsDirectory = config.getWebMapsProjectsDirectory(); + // recuperer les resultats actuels pour le mail de mise à jour + Map<String, String> indicatorResults = getZonesIds(projectsDirectory, true, null, null); + Map<String, String> mapsResults = getZonesIds(mapsDirectory, null, true, null); + Map<String, String> dataResults = getZonesIds(projectsDirectory, null, null, true); + // suppression des resultats qui ont été envoyé mais // ne sont ni maps result, ni indicator result - Map<String, String> noIndicatorsResultZoneIds = getZonesIds(tempDirectory, false, null); + Map<String, String> noIndicatorsResultZoneIds = getZonesIds(tempDirectory, false, null, null); cleanCurrentProjectDirectory(projectsDirectory, noIndicatorsResultZoneIds.keySet()); - Map<String, String> noMapsResultZoneIds = getZonesIds(tempDirectory, null, false); + Map<String, String> noMapsResultZoneIds = getZonesIds(tempDirectory, null, false, null); cleanCurrentProjectDirectory(mapsDirectory, noMapsResultZoneIds.keySet()); + Map<String, String> noDataResultZoneIds = getZonesIds(tempDirectory, null, null, false); // recuperation des noms zone des nouveau fichiers - Map<String, String> indicatorsResultZoneIds = getZonesIds(tempDirectory, true, false); + Map<String, String> indicatorsResultZoneIds = getZonesIds(tempDirectory, true, null, null); // suppression dans l'ancien répertoire des resultat deja present // dans le nouveau (pour les conflits) cleanCurrentProjectDirectory(projectsDirectory, indicatorsResultZoneIds.keySet()); @@ -725,7 +731,7 @@ customCopyDirectory(tempDirectory, projectsDirectory, indicatorsFileFilter); // recuperation des noms zone des nouveau fichiers - Map<String, String> mapsResultZoneIds = getZonesIds(tempDirectory, false, true); + Map<String, String> mapsResultZoneIds = getZonesIds(tempDirectory, null, true, null); // suppression dans l'ancien répertoire des resultat deja present // dans le nouveau (pour les conflits) cleanCurrentProjectDirectory(mapsDirectory, mapsResultZoneIds.keySet()); @@ -734,6 +740,9 @@ // copie (avec ecrasement) des nouveaux fichiers dans l'ancien répertoire customCopyDirectory(tempDirectory, mapsDirectory, mapsFileFilter); + // recuperation des nom de resultat data + Map<String, String> dataResultZoneIds = getZonesIds(tempDirectory, null, null, true); + FileUtils.deleteDirectory(tempDirectory); if (log.isInfoEnabled()) { @@ -741,40 +750,69 @@ } // generate email content - StringBuffer content = new StringBuffer(); - if (!noMapsResultZoneIds.isEmpty() || !mapsResultZoneIds.isEmpty()) { - content.append(_("coser.business.notificationmail.mapsresults") + "\n"); - for (Map.Entry<String, String> noMapsResultZoneId : noMapsResultZoneIds.entrySet()) { + StringBuilder content = new StringBuilder(); + + int count = 0; + content.append(_("coser.business.notificationmail.mapsresults") + "\n"); + for (Map.Entry<String, String> noMapsResultZoneId : noMapsResultZoneIds.entrySet()) { + if (mapsResults.containsValue(noMapsResultZoneId.getValue())) { content.append(" - " + _("coser.business.notificationmail.deleted", - getZoneFullName(noMapsResultZoneId.getKey()), - noMapsResultZoneId.getValue()) + "\n"); + getZoneFullName(noMapsResultZoneId.getKey()), + noMapsResultZoneId.getValue()) + "\n"); + count++; } - for (Map.Entry<String, String> mapsResultZoneId : mapsResultZoneIds.entrySet()) { + } + for (Map.Entry<String, String> mapsResultZoneId : mapsResultZoneIds.entrySet()) { + if (!mapsResults.containsValue(mapsResultZoneId.getValue())) { content.append(" - " + _("coser.business.notificationmail.added", - getZoneFullName(mapsResultZoneId.getKey()), - mapsResultZoneId.getValue()) + "\n"); + getZoneFullName(mapsResultZoneId.getKey()), + mapsResultZoneId.getValue()) + "\n"); + count++; } - content.append("\n"); } - - if (!noIndicatorsResultZoneIds.isEmpty() || !indicatorsResultZoneIds.isEmpty()) { - content.append(_("coser.business.notificationmail.indicatorsresults") + "\n"); - for (Map.Entry<String, String> noIndicatorsResultZoneId : noIndicatorsResultZoneIds.entrySet()) { + content.append("\n"); + + content.append(_("coser.business.notificationmail.indicatorsresults") + "\n"); + for (Map.Entry<String, String> noIndicatorsResultZoneId : noIndicatorsResultZoneIds.entrySet()) { + if (indicatorResults.containsValue(noIndicatorsResultZoneId.getValue())) { content.append(" - " + _("coser.business.notificationmail.deleted", - getZoneFullName(noIndicatorsResultZoneId.getKey()), - noIndicatorsResultZoneId.getValue()) + "\n"); + getZoneFullName(noIndicatorsResultZoneId.getKey()), + noIndicatorsResultZoneId.getValue()) + "\n"); + count++; } - for (Map.Entry<String, String> indicatorsResultZoneId : indicatorsResultZoneIds.entrySet()) { + + } + for (Map.Entry<String, String> indicatorsResultZoneId : indicatorsResultZoneIds.entrySet()) { + if (!indicatorResults.containsValue(indicatorsResultZoneId.getValue())) { content.append(" - " + _("coser.business.notificationmail.added", - getZoneFullName(indicatorsResultZoneId.getKey()), - indicatorsResultZoneId.getValue()) + "\n"); + getZoneFullName(indicatorsResultZoneId.getKey()), + indicatorsResultZoneId.getValue()) + "\n"); + count++; } - content.append("\n"); } + content.append("\n"); + content.append(_("coser.business.notificationmail.dataresults") + "\n"); + for (Map.Entry<String, String> noDataResultZoneId : noDataResultZoneIds.entrySet()) { + if (dataResults.containsValue(noDataResultZoneId.getValue())) { + content.append(" - " + _("coser.business.notificationmail.deleted", + getZoneFullName(noDataResultZoneId.getKey()), + noDataResultZoneId.getValue()) + "\n"); + count++; + } + + } + for (Map.Entry<String, String> dataResultZoneId : dataResultZoneIds.entrySet()) { + if (!dataResults.containsValue(dataResultZoneId.getValue())) { + content.append(" - " + _("coser.business.notificationmail.added", + getZoneFullName(dataResultZoneId.getKey()), + dataResultZoneId.getValue()) + "\n"); + count++; + } + } + content.append("\n"); + // send notification mails - int count = noMapsResultZoneIds.size() + mapsResultZoneIds.size() + - noIndicatorsResultZoneIds.size() + indicatorsResultZoneIds.size(); sendNewResultNotifications(login, count, content.toString()); // update data date @@ -892,10 +930,12 @@ * @param scanDirectory le repertoire a scanner * @param indicatorResults if true get indicator results * @param mapResults if true get map results + * @param dataResults if true get data allowed result * @return une map de resultid/nom visuel des projets * @throws CoserBusinessException */ - protected Map<String, String> getZonesIds(File scanDirectory, Boolean indicatorResults, Boolean mapResults) throws CoserBusinessException { + protected Map<String, String> getZonesIds(File scanDirectory, Boolean indicatorResults, + Boolean mapResults, Boolean dataResults) throws CoserBusinessException { Map<String, String> resultIds = new HashMap<String, String>(); File[] projectFiles = scanDirectory.listFiles(); @@ -918,8 +958,10 @@ // return result depending on result type if ( ( indicatorResults == null || rsufiResult.isIndicatorsResult() == indicatorResults ) - || - ( mapResults == null || rsufiResult.isMapsResult() == mapResults ) ) { + && + ( mapResults == null || rsufiResult.isMapsResult() == mapResults ) + && + ( dataResults == null || rsufiResult.isDataAllowed() == dataResults)) { String resultResultId = rsufiResult.getZone(); if (StringUtils.isNotBlank(resultResultId)) { String resultPath = projectFile.getName() + "/" + Modified: trunk/coser-business/src/main/resources/i18n/coser-business_en_GB.properties =================================================================== --- trunk/coser-business/src/main/resources/i18n/coser-business_en_GB.properties 2012-08-21 10:06:08 UTC (rev 1064) +++ trunk/coser-business/src/main/resources/i18n/coser-business_en_GB.properties 2012-08-24 11:52:37 UTC (rev 1065) @@ -114,6 +114,7 @@ coser.business.matrix.samplingeffort=Sampling effort coser.business.notificationmail.added=added \: %s (%s) coser.business.notificationmail.body=Data has been updated on website by %s.\n\n%s--\nCoser. +coser.business.notificationmail.dataresults=Data results \: coser.business.notificationmail.deleted=deleted \: %s (%s) coser.business.notificationmail.indicatorsresults=Indicator results \: coser.business.notificationmail.mapsresults=Map results \: Modified: trunk/coser-business/src/main/resources/i18n/coser-business_fr_FR.properties =================================================================== --- trunk/coser-business/src/main/resources/i18n/coser-business_fr_FR.properties 2012-08-21 10:06:08 UTC (rev 1064) +++ trunk/coser-business/src/main/resources/i18n/coser-business_fr_FR.properties 2012-08-24 11:52:37 UTC (rev 1065) @@ -114,6 +114,7 @@ coser.business.matrix.samplingeffort=Effort d'échantillonnage coser.business.notificationmail.added=ajouté \: %s (%s) coser.business.notificationmail.body=Les données du site internet viennent d'être mises à jour par %s.\n\n%s--\nCoser. +coser.business.notificationmail.dataresults=Résultat de donnnées \: coser.business.notificationmail.deleted=supprimé \: %s (%s) coser.business.notificationmail.indicatorsresults=Résultats d'indicateur \: coser.business.notificationmail.mapsresults=Résultat de carte \:
participants (1)
-
echatellier@users.forge.codelutin.com