Coser-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
July 2012
- 1 participants
- 23 discussions
r1027 - in trunk/coser-business/src: main/java/fr/ifremer/coser/services main/resources/i18n test/java/fr/ifremer/coser/services test/resources
by echatellier@users.forge.codelutin.com 19 Jul '12
by echatellier@users.forge.codelutin.com 19 Jul '12
19 Jul '12
Author: echatellier
Date: 2012-07-19 16:07:21 +0200 (Thu, 19 Jul 2012)
New Revision: 1027
Url: http://forge.codelutin.com/repositories/revision/coser/1027
Log:
refs #1321: Control sur valeurs aberrantes utilisant l'?\195?\169cart type mais n'?\195?\169tant pas tout ?\195?\160 fait satisfaisant.
Modified:
trunk/coser-business/src/main/java/fr/ifremer/coser/services/ControlService.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
trunk/coser-business/src/test/java/fr/ifremer/coser/services/ControlServiceTest.java
trunk/coser-business/src/test/resources/log4j.properties
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/ControlService.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/services/ControlService.java 2012-07-19 09:41:56 UTC (rev 1026)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ControlService.java 2012-07-19 14:07:21 UTC (rev 1027)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2010 - 2011 Ifremer, Codelutin, Chatellier Eric
+ * Copyright (C) 2010 - 2012 Ifremer, Codelutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
@@ -203,13 +203,15 @@
*
* @param project project
* @param control control a valider
- * @param progress progress monitor
+ * @param progress progress monitor (can be null)
* @return les erreurs de validation
*/
public List<ControlError> validateData(Project project, Control control, ProgressMonitor progress) {
- progress.setStepCount(10);
- progress.setStep(0);
+ if (progress != null) {
+ progress.setStepCount(11);
+ progress.setStep(0);
+ }
// valide chaque category
List<ControlError> validationErrors = new ArrayList<ControlError>();
@@ -220,27 +222,35 @@
if (categoryErrors != null) {
validationErrors.addAll(categoryErrors);
}
- progress.nextStep();
+ if (progress != null) {
+ progress.nextStep();
+ }
// validation specifique de la category
List<ControlError> specificErrors = validateCategorySpecific(control, category, progress);
if (specificErrors != null) {
validationErrors.addAll(specificErrors);
}
- progress.nextStep();
+ if (progress != null) {
+ progress.nextStep();
+ }
}
}
// validation entre catch et length (specific)
List<? extends ControlError> diffCatchLengthErrors = validateDiffCatchLength(control, progress);
- progress.nextStep();
+ if (progress != null) {
+ progress.nextStep();
+ }
if (diffCatchLengthErrors != null) {
validationErrors.addAll(diffCatchLengthErrors);
}
// validation par croisement de fichiers
List<ControlError> crossFileErrors = validationCrossFiles(project, control, progress);
- progress.nextStep();
+ if (progress != null) {
+ progress.nextStep();
+ }
if (crossFileErrors != null) {
validationErrors.addAll(crossFileErrors);
}
@@ -261,7 +271,7 @@
*
* @param control control a valider
* @param category category a valider
- * @param progress progress monitor
+ * @param progress progress monitor (can be null)
* @return les erreurs de validation
*/
public List<ControlError> validateCategory(Control control, Category category, ProgressMonitor progress) {
@@ -282,7 +292,7 @@
*
* @param control control a valider
* @param category category a valider
- * @param progress progress monitor
+ * @param progress progress monitor (can be null)
* @return les erreurs de validation (not null)
*/
public List<ControlError> validateCategoryXWork(Control control, Category category, ProgressMonitor progress) {
@@ -485,7 +495,7 @@
* Alerte si Somme(CAPTURES$Nombre par CAPTURES$Annee|Strate|Espece) < nobsmin.
*
* @param control control
- * @param progress progress monitor
+ * @param progress progress monitor (can be null)
* @return error list
*/
protected List<ControlError> validateCategorySpecificCatch(
@@ -579,7 +589,7 @@
* et les nombres dans taille.
*
* @param control data container
- * @param progress progress
+ * @param progress progress (can be null)
*
* @see PublicationService#getCompareCatchLengthGraph(Project, AbstractDataContainer, Collection) for details
* @see CoserBusinessConfig#getControlDiffCatchLength() for option
@@ -753,8 +763,16 @@
/**
* Alerte si Somme(TAILLES$Nombre par TAILLES$Annee|Strate|Espece) < nobsmin
*
+ * Warning sur les tailles aberrantes par espèce:
+ * <ul>
+ * <li>premiere passe pour calculer l'écart type et la moyenne par espèce
+ * <li>seconde passe pour détecter les valeurs abérentes (> ecart type)
+ * </ul>
+ *
+ * L'ecarty étant : racine( somme (x - moyenne)^2 / n)
+ *
* @param control control
- * @param progress progress
+ * @param progress progress (can be null)
* @return error list
*/
protected List<ControlError> validateCategorySpecificLength(
@@ -772,6 +790,10 @@
Map<String, Double> nombreForKey = new HashMap<String, Double>();
Map<String, String> firstLineForKey = new HashMap<String, String>();
+ // Standard deviation
+ Map<String, Double> lengthSumForSpecies = new HashMap<String, Double>();
+ Map<String, Double> lengthCountForSpecies = new HashMap<String, Double>();
+
// parcours des elements
Iterator<String[]> itTuple = control.getLength().iterator(true);
int lineIndex = 1; // skip header
@@ -813,20 +835,45 @@
}
}
catch (NumberFormatException ex) {
- // par trop grave, normalement les données deviennet
+ // par trop grave, normalement les données deviennent
// valide au fil de la validation
if (log.isWarnEnabled()) {
log.warn("Can't parse " + nombreValue + " as double");
}
}
+
+ // store lenght for Standard deviation
+ String lengthValue = tuple[Length.INDEX_LENGTH];
+ try {
+ Double nombre = Double.valueOf(lengthValue);
+ String key = tuple[Length.INDEX_SPECIES];
+ if (lengthSumForSpecies.containsKey(key)) {
+ Double oldValue = lengthSumForSpecies.get(key);
+ Double newValue = oldValue + nombre;
+ lengthSumForSpecies.put(key, newValue);
+ Double count = lengthCountForSpecies.get(key);
+ lengthCountForSpecies.put(key, count + 1);
+ }
+ else {
+ lengthSumForSpecies.put(key, nombre);
+ lengthCountForSpecies.put(key, 1d);
+ }
+ }
+ catch (NumberFormatException ex) {
+ // par trop grave, normalement les données deviennent
+ // valide au fil de la validation
+ if (log.isWarnEnabled()) {
+ log.warn("Can't parse " + lengthValue + " as double");
+ }
+ }
}
- // now look for invalid data
+ // now look for invalid data (observations)
for (Map.Entry<String, Double> sumObservation : nombreForKey.entrySet()) {
String key = sumObservation.getKey();
Double value = sumObservation.getValue();
if (value < config.getControlNobsmin()) {
-
+
String lineNumber = firstLineForKey.get(key);
ControlError error = new ControlError();
@@ -839,6 +886,114 @@
}
}
+ // recherche des valeurs abérrantes
+ if (progress != null) {
+ progress.nextStep();
+ progress.setTotal(total * 2);
+ }
+
+ // Standard deviation : calcul de la moyenne
+ Map<String, Double> avgForSpecies = new HashMap<String, Double>();
+ for (Map.Entry<String, Double> entry : lengthSumForSpecies.entrySet()) {
+ double avg = entry.getValue() / lengthCountForSpecies.get(entry.getKey());
+ avgForSpecies.put(entry.getKey(), avg);
+ }
+
+ // Standard deviation : somme des variances au carré
+ Map<String, Double> varianceSumForSpecies = new HashMap<String, Double>();
+ itTuple = control.getLength().iterator(true);
+ lineIndex = 1; // skip header
+ while (itTuple.hasNext()) {
+
+ // update progress
+ if (progress != null) {
+ int progressPercent = (int)((double)lineIndex / (double)total * 50.0);
+ progress.setText(_("coser.business.control.step.lengthdeviation", _(Category.LENGTH.getTranslationKey()), progressPercent));
+ progress.setCurrent(lineIndex);
+ ++lineIndex;
+ }
+
+ String[] tuple = itTuple.next();
+ // store lenght for Standard deviation
+ String lengthValue = tuple[Length.INDEX_LENGTH];
+ try {
+ String key = tuple[Length.INDEX_SPECIES];
+ Double nombre = Double.valueOf(lengthValue);
+ Double value = Math.pow(nombre - avgForSpecies.get(key), 2);
+
+ if (varianceSumForSpecies.containsKey(key)) {
+ Double oldValue = varianceSumForSpecies.get(key);
+ Double newValue = oldValue + value;
+ varianceSumForSpecies.put(key, newValue);
+ }
+ else {
+ varianceSumForSpecies.put(key, value);
+ }
+ }
+ catch (NumberFormatException ex) {
+ // par trop grave, normalement les données deviennent
+ // valide au fil de la validation
+ if (log.isWarnEnabled()) {
+ log.warn("Can't parse " + lengthValue + " as double");
+ }
+ }
+ }
+
+ // Standard deviation : calcul de l'ecart type par espèce
+ // racine( somme (x - moyenne)^2 / n)
+ Map<String, Double> deviationForSpecies = new HashMap<String, Double>();
+ for (Map.Entry<String, Double> entry : varianceSumForSpecies.entrySet()) {
+ double avg = Math.sqrt(entry.getValue() / lengthCountForSpecies.get(entry.getKey()));
+ deviationForSpecies.put(entry.getKey(), avg);
+ }
+
+ // Standard deviation : recherche des valeurs aberantes : 3 fois l'écart type
+ itTuple = control.getLength().iterator(true);
+ lineIndex = 1; // skip header
+ while (itTuple.hasNext()) {
+
+ // update progress
+ if (progress != null) {
+ int progressPercent = (int)((double)lineIndex / (double)total * 50.0 + 50.0);
+ progress.setText(_("coser.business.control.step.lengthoutliers", _(Category.LENGTH.getTranslationKey()), progressPercent));
+ progress.setCurrent(total + lineIndex);
+ ++lineIndex;
+ }
+
+ String[] tuple = itTuple.next();
+ // store lenght for Standard deviation
+ String lengthValue = tuple[Length.INDEX_LENGTH];
+ try {
+ String species = tuple[Length.INDEX_SPECIES];
+ Double nombre = Double.valueOf(lengthValue);
+ Double avg = avgForSpecies.get(species);
+ Double deviation = deviationForSpecies.get(species);
+
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("Species %s, avg=%f, deviation=%f, value=%f", species, avg, deviation, nombre));
+ }
+
+ if (Math.abs(nombre - avg) > deviation * 3) {
+ String lineNumber = tuple[AbstractDataEntity.INDEX_LINE];
+
+ ControlError error = new ControlError();
+ error.setCategory(Category.LENGTH);
+ error.setLevel(ValidationLevel.WARNING);
+ error.addLineNumber(lineNumber);
+ error.setMessage(_("coser.business.control.error.lengthOutliers", avg, deviation));
+ error.setDetailMessage(_("coser.business.control.error.lengthOutliersDetail", species, avg, deviation, lengthValue));
+ validationErrors.add(error);
+ }
+ }
+ catch (NumberFormatException ex) {
+ // par trop grave, normalement les données deviennent
+ // valide au fil de la validation
+ if (log.isWarnEnabled()) {
+ log.warn("Can't parse " + lengthValue + " as double");
+ }
+ }
+ }
+
return validationErrors;
}
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-07-19 09:41:56 UTC (rev 1026)
+++ trunk/coser-business/src/main/resources/i18n/coser-business_en_GB.properties 2012-07-19 14:07:21 UTC (rev 1027)
@@ -49,6 +49,8 @@
coser.business.control.error.invalidLengthLengthStep=Invalid length step (authorized centimeters and half-centimeters)
coser.business.control.error.invalidLengthLengthStepDetail=Invalid length step %s for species %s
coser.business.control.error.invalidLengthLengthStepTip=Length field must be in centimeters.
+coser.business.control.error.lengthOutliers=Aberrants lengths
+coser.business.control.error.lengthOutliersDetail=Species %s \: length %4$s aberrant (average\: %2$.2f, deviation\: %3$.2f)
coser.business.control.error.minObservationCount=Minimum number of observation not reached
coser.business.control.error.minObservationCountDetail=Minimum number of observation not reached (%s) \: %.2f
coser.business.control.error.missingCatchHaulFromHaul=Missing haul file hauls in catch file
@@ -92,6 +94,8 @@
coser.business.control.noerrorfound=No error found
coser.business.control.step.crossFileChech=Cross file checks (%d%%)
coser.business.control.step.diffCatchLength=Check diff catch/length (%d%%)
+coser.business.control.step.lengthdeviation=Comptuting standard deviation \: %s (%d%%)
+coser.business.control.step.lengthoutliers=Searching for aberrants lengths \: %s (%d%%)
coser.business.control.step.observation=Checking observation number \: %s (%d%%)
coser.business.control.step.xworks=Line checks \: %s (%d%%)
coser.business.extract.creationdate=Creation date \:
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-07-19 09:41:56 UTC (rev 1026)
+++ trunk/coser-business/src/main/resources/i18n/coser-business_fr_FR.properties 2012-07-19 14:07:21 UTC (rev 1027)
@@ -49,6 +49,8 @@
coser.business.control.error.invalidLengthLengthStep=Le pas de longueur est invalide (autorisé centimètre et demi-centimètre)
coser.business.control.error.invalidLengthLengthStepDetail=Le pas longueur %s est invalide pour l'espèce %s
coser.business.control.error.invalidLengthLengthStepTip=Le champs de longueur doit être en centimètre (ou demi centimètre)
+coser.business.control.error.lengthOutliers=Longueurs aberrantes
+coser.business.control.error.lengthOutliersDetail=Espèce %s \: longueur %4$s aberrantes (moyenne\: %2$.2f, écart\: %3$.2f)
coser.business.control.error.minObservationCount=Nombre minimal d'observation non atteint
coser.business.control.error.minObservationCountDetail=Nombre minimal d'observation non atteint (%s) \: %.2f
coser.business.control.error.missingCatchHaulFromHaul=Traits du fichier traits absents dans le fichier captures
@@ -92,6 +94,8 @@
coser.business.control.noerrorfound=Aucune erreur détectée
coser.business.control.step.crossFileChech=Vérification par croisement de fichiers (%d%%)
coser.business.control.step.diffCatchLength=Vérification des différences captures/taille (%d%%)
+coser.business.control.step.lengthdeviation=Calcul de l'écart type \: %s (%d%%)
+coser.business.control.step.lengthoutliers=Recherche des longueurs abérrantes \: %s (%d%%)
coser.business.control.step.observation=Vérification du nombre d'observation \: %s (%d%%)
coser.business.control.step.xworks=Validation par lignes \: %s (%d%%)
coser.business.extract.creationdate=Date de création \:
Modified: trunk/coser-business/src/test/java/fr/ifremer/coser/services/ControlServiceTest.java
===================================================================
--- trunk/coser-business/src/test/java/fr/ifremer/coser/services/ControlServiceTest.java 2012-07-19 09:41:56 UTC (rev 1026)
+++ trunk/coser-business/src/test/java/fr/ifremer/coser/services/ControlServiceTest.java 2012-07-19 14:07:21 UTC (rev 1027)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric
+ * Copyright (C) 2010 - 2012 Ifremer, Codelutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
@@ -32,8 +32,10 @@
import org.junit.Assert;
import org.junit.Test;
+import fr.ifremer.coser.CoserBusinessException;
import fr.ifremer.coser.CoserConstants.Category;
import fr.ifremer.coser.bean.Control;
+import fr.ifremer.coser.bean.Project;
import fr.ifremer.coser.control.ControlError;
import fr.ifremer.coser.data.Catch;
import fr.ifremer.coser.data.Haul;
@@ -42,7 +44,7 @@
import fr.ifremer.coser.storage.MemoryDataStorage;
/**
- * Test abour validation.
+ * Test about control service (validation...).
*
* @author chatellier
* @version $Revision$
@@ -55,6 +57,7 @@
private static final Log log = LogFactory.getLog(ControlServiceTest.class);
protected ControlService controlService = new ControlService(config);
+ protected ProjectService projectService = new ProjectService(config);
/**
* Test les validations sur les champs vide.
@@ -164,4 +167,33 @@
Assert.assertFalse(controlService.isValidFishLength("1.3"));
Assert.assertFalse(controlService.isValidFishLength("1.001"));
}
+
+ /**
+ * Test que la validation globales fonctionne.
+ * Méthode valid data qui passe tout les contôles.
+ *
+ * @throws CoserBusinessException
+ */
+ @Test
+ public void testValidData() throws CoserBusinessException {
+ Project project = createTestProject(projectService, false);
+ List<ControlError> errors = controlService.validateData(project, project.getControl(), null);
+
+ // 18 : xxx must contain at least x decimals
+ // 1 : Duplicated line for key : COSER_TEST|2010|TRAIT1|COSER_SPECIES2|i|NA|19.60|
+ // 8 : Differences between length and catch for species XXX
+ // 15 : Missing XXX tuple in catch
+ // 4 : Missing strata xxx in haul file
+ // 3 : Missing haul xxx in length file
+ // Total : 49
+ if (log.isInfoEnabled()) {
+ for (ControlError error : errors) {
+ log.info(error.getLevel() + " " + error.getDetailMessage());
+ }
+ }
+
+ // il y a beaucoup d'erreurs car les jeux d'essai ne sont
+ // pas forcements cohérents
+ Assert.assertEquals(49, errors.size());
+ }
}
Modified: trunk/coser-business/src/test/resources/log4j.properties
===================================================================
--- trunk/coser-business/src/test/resources/log4j.properties 2012-07-19 09:41:56 UTC (rev 1026)
+++ trunk/coser-business/src/test/resources/log4j.properties 2012-07-19 14:07:21 UTC (rev 1027)
@@ -5,7 +5,7 @@
# $Id$
# $HeadURL$
# %%
-# Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric
+# Copyright (C) 2010 - 2012 Ifremer, Codelutin, Chatellier Eric
# %%
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
@@ -33,4 +33,3 @@
# Categories
#log4j.category.fr.ifremer.coser=DEBUG
-#log4j.category.com.opensymphony.xwork2=DEBUG
1
0
r1026 - trunk/coser-business/src/main/java/fr/ifremer/coser/services
by echatellier@users.forge.codelutin.com 19 Jul '12
by echatellier@users.forge.codelutin.com 19 Jul '12
19 Jul '12
Author: echatellier
Date: 2012-07-19 11:41:56 +0200 (Thu, 19 Jul 2012)
New Revision: 1026
Url: http://forge.codelutin.com/repositories/revision/coser/1026
Log:
Erreur, comment?\195?\169 juste pour tests.
Modified:
trunk/coser-business/src/main/java/fr/ifremer/coser/services/ControlService.java
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/ControlService.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/services/ControlService.java 2012-07-19 09:36:52 UTC (rev 1025)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ControlService.java 2012-07-19 09:41:56 UTC (rev 1026)
@@ -213,7 +213,7 @@
// valide chaque category
List<ControlError> validationErrors = new ArrayList<ControlError>();
- /*for (Category category : Category.values()) {
+ for (Category category : Category.values()) {
if (category.isDataCategory()) {
// validation de la category seule (generique)
List<ControlError> categoryErrors = validateCategoryXWork(control, category, progress);
@@ -229,7 +229,7 @@
}
progress.nextStep();
}
- }*/
+ }
// validation entre catch et length (specific)
List<? extends ControlError> diffCatchLengthErrors = validateDiffCatchLength(control, progress);
1
0
r1025 - in trunk: . coser-business/src/main/java/fr/ifremer/coser/control coser-business/src/main/java/fr/ifremer/coser/services coser-ui/src/main/java/fr/ifremer/coser/ui/control coser-ui/src/main/resources/i18n
by echatellier@users.forge.codelutin.com 19 Jul '12
by echatellier@users.forge.codelutin.com 19 Jul '12
19 Jul '12
Author: echatellier
Date: 2012-07-19 11:36:52 +0200 (Thu, 19 Jul 2012)
New Revision: 1025
Url: http://forge.codelutin.com/repositories/revision/coser/1025
Log:
fixes #1320: Regrouper les warning capture/taille par esp?\195?\168ce
Added:
trunk/coser-business/src/main/java/fr/ifremer/coser/control/SpeciesControlError.java
Modified:
trunk/coser-business/src/main/java/fr/ifremer/coser/control/DiffCatchLengthControlError.java
trunk/coser-business/src/main/java/fr/ifremer/coser/services/ControlService.java
trunk/coser-business/src/main/java/fr/ifremer/coser/services/PublicationService.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlErrorTreeRenderer.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/GlobalControlErrorModel.java
trunk/coser-ui/src/main/resources/i18n/coser-ui_en_GB.properties
trunk/coser-ui/src/main/resources/i18n/coser-ui_fr_FR.properties
trunk/pom.xml
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/control/DiffCatchLengthControlError.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/control/DiffCatchLengthControlError.java 2012-07-18 10:24:01 UTC (rev 1024)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/control/DiffCatchLengthControlError.java 2012-07-19 09:36:52 UTC (rev 1025)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2010 - 2011 Ifremer, Codelutin, Chatellier Eric
+ * Copyright (C) 2010 - 2012 Ifremer, Codelutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
@@ -36,27 +36,9 @@
* Last update : $Date$
* By : $Author$
*/
-public class DiffCatchLengthControlError extends ControlError implements Comparable<DiffCatchLengthControlError> {
+public class DiffCatchLengthControlError extends SpeciesControlError {
- /** serialVersionUID. */
- private static final long serialVersionUID = -3254763296138201677L;
+ /** serialVersionUID */
+ private static final long serialVersionUID = 6646855823928956144L;
- protected String species;
-
- public String getSpecies() {
- return species;
- }
-
- public void setSpecies(String species) {
- this.species = species;
- }
-
- @Override
- public int compareTo(DiffCatchLengthControlError o) {
- int result = -1;
- if (species != null) {
- result = species.compareTo(o.species);
- }
- return result;
- }
}
Added: trunk/coser-business/src/main/java/fr/ifremer/coser/control/SpeciesControlError.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/control/SpeciesControlError.java (rev 0)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/control/SpeciesControlError.java 2012-07-19 09:36:52 UTC (rev 1025)
@@ -0,0 +1,63 @@
+/*
+ * #%L
+ *
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.coser.control;
+
+/**
+ * Erreur de controle specifique pour les différences des nombres entre
+ * les captures et les tailles pour utilisation typée de cette erreur
+ * (export html) et information supplémentaires (especes).
+ *
+ * @author chatellier
+ * @version $Revision$
+ * @since 1.3
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class SpeciesControlError extends ControlError implements Comparable<SpeciesControlError> {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = -3254763296138201677L;
+
+ protected String species;
+
+ public String getSpecies() {
+ return species;
+ }
+
+ public void setSpecies(String species) {
+ this.species = species;
+ }
+
+ @Override
+ public int compareTo(SpeciesControlError o) {
+ int result = -1;
+ if (species != null) {
+ result = species.compareTo(o.species);
+ }
+ return result;
+ }
+}
Property changes on: trunk/coser-business/src/main/java/fr/ifremer/coser/control/SpeciesControlError.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/ControlService.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/services/ControlService.java 2012-07-18 10:24:01 UTC (rev 1024)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ControlService.java 2012-07-19 09:36:52 UTC (rev 1025)
@@ -66,6 +66,7 @@
import fr.ifremer.coser.bean.Project;
import fr.ifremer.coser.control.ControlError;
import fr.ifremer.coser.control.DiffCatchLengthControlError;
+import fr.ifremer.coser.control.SpeciesControlError;
import fr.ifremer.coser.data.AbstractDataEntity;
import fr.ifremer.coser.data.Catch;
import fr.ifremer.coser.data.Haul;
@@ -212,7 +213,7 @@
// valide chaque category
List<ControlError> validationErrors = new ArrayList<ControlError>();
- for (Category category : Category.values()) {
+ /*for (Category category : Category.values()) {
if (category.isDataCategory()) {
// validation de la category seule (generique)
List<ControlError> categoryErrors = validateCategoryXWork(control, category, progress);
@@ -228,7 +229,7 @@
}
progress.nextStep();
}
- }
+ }*/
// validation entre catch et length (specific)
List<? extends ControlError> diffCatchLengthErrors = validateDiffCatchLength(control, progress);
@@ -593,7 +594,7 @@
progress.setTotal(total);
}
- List<DiffCatchLengthControlError> validationErrors = new ArrayList<DiffCatchLengthControlError>();
+ List<SpeciesControlError> validationErrors = new ArrayList<SpeciesControlError>();
// data necessary for compute
SortedSet<String> setYear = new TreeSet<String>();
@@ -715,15 +716,14 @@
// warning si taille = 0 et captures différent de 0
// nomespece, année(s) avec absence de taille
if (lengthNumber == 0 && catchNumber > 0 && !missingYearLengthSpecies.contains(species)) {
- DiffCatchLengthControlError error = new DiffCatchLengthControlError();
+ SpeciesControlError error = new SpeciesControlError();
error.setSpecies(species);
error.setLevel(ValidationLevel.WARNING);
error.setMessage(_("coser.business.control.error.diffCatchLengthMissingYear"));
error.setDetailMessage(_("coser.business.control.error.diffCatchLengthMissingYearDetail", species));
validationErrors.add(error);
missingYearLengthSpecies.add(species);
- }
- else {
+ } else {
// diff entre 4 et 5 = (5-4) * 100 / 5
double min = Math.min(catchNumber, lengthNumber);
// si c'est 0, ou absence de catures, ce n'est pas une erreur
@@ -1216,7 +1216,7 @@
// especes de tailles doivent etre dans especes de captures (fatal)
Collection<String> missingCatchSpeciesNames = CollectionUtils.subtract(lengthSpeciesNames, catchSpeciesNames);
for (String missingCatchSpeciesName : missingCatchSpeciesNames) {
- DiffCatchLengthControlError error = new DiffCatchLengthControlError();
+ SpeciesControlError error = new SpeciesControlError();
error.setLevel(ValidationLevel.FATAL);
error.setSpecies(missingCatchSpeciesName);
error.setMessage(_("coser.business.control.error.missingCatchSpeciesFromLength"));
@@ -1230,7 +1230,7 @@
// especes de captures doivent etre dans especes de tailles (warning)
Collection<String> missingLengthSpeciesNames = CollectionUtils.subtract(catchSpeciesNames, lengthSpeciesNames);
for (String missingLengthSpeciesName : missingLengthSpeciesNames) {
- DiffCatchLengthControlError error = new DiffCatchLengthControlError();
+ SpeciesControlError error = new SpeciesControlError();
error.setLevel(ValidationLevel.WARNING);
error.setSpecies(missingLengthSpeciesName);
error.setMessage(_("coser.business.control.error.missingLengthSpeciesFromCatch"));
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/PublicationService.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/services/PublicationService.java 2012-07-18 10:24:01 UTC (rev 1024)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/PublicationService.java 2012-07-19 09:36:52 UTC (rev 1025)
@@ -92,11 +92,11 @@
import fr.ifremer.coser.control.ControlError;
import fr.ifremer.coser.control.ControlErrorGroup;
import fr.ifremer.coser.control.DiffCatchLengthControlError;
+import fr.ifremer.coser.control.SpeciesControlError;
import fr.ifremer.coser.data.Catch;
import fr.ifremer.coser.data.Length;
import fr.ifremer.coser.storage.DataStorage;
import fr.ifremer.coser.storage.MemoryDataStorage;
-import freemarker.template.TemplateException;
/**
* Publication service (charts, reports, export, pdf...)
@@ -347,8 +347,8 @@
errorGroup.add(group);
}
- if (validationError instanceof DiffCatchLengthControlError) {
- DiffCatchLengthControlError diffError = (DiffCatchLengthControlError)validationError;
+ if (validationError instanceof SpeciesControlError) {
+ SpeciesControlError diffError = (SpeciesControlError)validationError;
speciesGraph.add(diffError.getSpecies());
}
childErrors.add(validationError);
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlErrorTreeRenderer.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlErrorTreeRenderer.java 2012-07-18 10:24:01 UTC (rev 1024)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlErrorTreeRenderer.java 2012-07-19 09:36:52 UTC (rev 1025)
@@ -33,10 +33,13 @@
import javax.swing.tree.DefaultTreeCellRenderer;
import jaxx.runtime.validator.swing.SwingValidatorUtil;
+
+import org.jdesktop.swingx.treetable.TreeTableNode;
+
import fr.ifremer.coser.CoserConstants.Category;
import fr.ifremer.coser.CoserConstants.ValidationLevel;
+import fr.ifremer.coser.control.ControlError;
import fr.ifremer.coser.control.ControlErrorGroup;
-import fr.ifremer.coser.control.ControlError;
/**
* Renderer pour le table des erreurs globales.
@@ -73,18 +76,19 @@
GlobalControlErrorModel model = (GlobalControlErrorModel)tree.getModel();
JLabel component = (JLabel)super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
+ Object userObject = ((TreeTableNode)value).getUserObject();
ImageIcon icon = null;
String text = null;
String tooltipText = null;
- if (value instanceof String) {
- text = _((String)value) + " (" + model.getChildCount(value) + ")";
+ if (userObject instanceof String) {
+ text = _((String)userObject) + " (" + model.getChildCount(value) + ")";
}
- else if (value instanceof Category) {
- text = _(((Category)value).getTranslationKey()) + " (" + model.getChildCount(value) + ")";
+ else if (userObject instanceof Category) {
+ text = _(((Category)userObject).getTranslationKey()) + " (" + model.getChildCount(value) + ")";
}
- else if (value instanceof ControlErrorGroup) {
- ControlErrorGroup validationErrorGroup = (ControlErrorGroup)value;
+ else if (userObject instanceof ControlErrorGroup) {
+ ControlErrorGroup validationErrorGroup = (ControlErrorGroup)userObject;
ValidationLevel level = validationErrorGroup.getValidationLevel();
switch (level) {
case FATAL:
@@ -104,8 +108,8 @@
String message = validationErrorGroup.getMessage();
text = _(message) + " (" + model.getChildCount(value) + ")";
}
- else if (value instanceof ControlError) {
- ControlError validationError = (ControlError)value;
+ else if (userObject instanceof ControlError) {
+ ControlError validationError = (ControlError)userObject;
ValidationLevel level = validationError.getLevel();
switch (level) {
case FATAL:
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java 2012-07-18 10:24:01 UTC (rev 1024)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java 2012-07-19 09:36:52 UTC (rev 1025)
@@ -24,6 +24,7 @@
package fr.ifremer.coser.ui.control;
import static org.nuiton.i18n.I18n._;
+import static org.nuiton.i18n.I18n.n_;
import java.awt.BorderLayout;
import java.awt.GridBagConstraints;
@@ -36,6 +37,7 @@
import java.beans.Introspector;
import java.io.File;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -67,6 +69,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTreeTable;
+import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode;
+import org.jdesktop.swingx.treetable.DefaultTreeTableModel;
+import org.jdesktop.swingx.treetable.TreeTableNode;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.nuiton.widget.SwingSession;
@@ -81,6 +86,7 @@
import fr.ifremer.coser.control.ControlError;
import fr.ifremer.coser.control.ControlErrorGroup;
import fr.ifremer.coser.control.DiffCatchLengthControlError;
+import fr.ifremer.coser.control.SpeciesControlError;
import fr.ifremer.coser.data.AbstractDataEntity;
import fr.ifremer.coser.data.Catch;
import fr.ifremer.coser.data.Haul;
@@ -452,10 +458,12 @@
throw new CoserException("Can't validate data", ex);
}
}
+
+
};
task.execute();
}
-
+
/**
* Called when selection change to display selected bean
* in edition panel.
@@ -514,18 +522,19 @@
*/
public void showSelectedError(ControlView view, TreeSelectionEvent event) {
TreePath selectedError = view.getGlobalControlErrorTable().getTreeSelectionModel().getSelectionPath();
- if (selectedError != null) {
- Object[] pathWay = selectedError.getPath();
+ if (selectedError != null && selectedError.getPathCount() >= 3) {
+ TreeTableNode cateNode = (TreeTableNode)selectedError.getPathComponent(1);
+ Object cateObject = cateNode.getUserObject();
+ TreeTableNode lastNode = (TreeTableNode)selectedError.getLastPathComponent();
+ Object userObject = lastNode.getUserObject();
- // 2 = validation group (middle level)
- // 3 = validation error (last level)
- if (pathWay.length == 4 && pathWay[1] instanceof Category) {
- Category category = (Category)pathWay[1];
+ if (cateObject instanceof Category && userObject instanceof ControlError) {
+ Category category = (Category)cateObject;
// swap category
view.getCategoryComboBoxModel().setSelectedItem(category);
-
- ControlError error = (ControlError)pathWay[3];
+
+ ControlError error = (ControlError)userObject;
List<String> errorLineNumbers = error.getLineNumbers();
// peut être vide, si l'erreur ne porte pas sur un bean en particulier
if (errorLineNumbers != null) {
@@ -555,11 +564,11 @@
/**
* Affiche le menu contextuel de l'arbre qui contient les erreurs de
* validation globales ou les graphes de comparaison captures/taille
- * dans le cas d'un double clic sur une {@link DiffCatchLengthControlError}.
+ * dans le cas d'un double clic sur une {@link SpeciesControlError}.
*
* @param controlView view
* @param event mouse event
- * @see DiffCatchLengthControlError
+ * @see SpeciesControlError
*/
public void globalErrorTableMouseClicked(final ControlView controlView, MouseEvent event) {
@@ -573,20 +582,22 @@
JPopupMenu popupMenu = new JPopupMenu();
// plusieurs lignes selectionnées et pas la premiere colonne (Line index)
- if (selectedError != null) {
- Object[] pathWay = selectedError.getPath();
+ if (selectedError != null && selectedError.getPathCount() >= 3) {
- // 2 = validation group (middle level)
- if (pathWay.length == 3) {
- if (pathWay[1] instanceof Category) {
- final Category category = (Category)pathWay[1];
- final ControlErrorGroup validationGroup = (ControlErrorGroup)pathWay[2];
-
+ TreeTableNode cateNode = (TreeTableNode)selectedError.getPathComponent(1);
+ Object cateObject = cateNode.getUserObject();
+
+ if (cateObject instanceof Category) { // ca peut être 'tout' en String
+ final Category category = (Category)cateObject;
+ final TreeTableNode lastNode = (TreeTableNode)selectedError.getLastPathComponent();
+
+ // selectall n'a d'interet que pour les groupes d'erreurs
+ if (lastNode.getChildCount() > 0) {
JMenuItem replaceMenu = new JMenuItem(_("coser.ui.control.globalErrorMenuSelectAll"));
replaceMenu.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
- selectAllErrorGroupLines(controlView, category, validationGroup);
+ selectAllErrorGroupLines(controlView, category, lastNode);
}
});
popupMenu.add(replaceMenu);
@@ -617,10 +628,10 @@
// si la selection est une instance de DiffCatchLengthControlError
// affiche le graphe avec l'espece correspondante
if (selectedError != null) {
- Object[] pathWay = selectedError.getPath();
- Object lastComponent = pathWay[pathWay.length - 1];
- if (lastComponent instanceof DiffCatchLengthControlError) {
- DiffCatchLengthControlError error = (DiffCatchLengthControlError)lastComponent;
+ TreeTableNode lastComponent = (TreeTableNode)selectedError.getLastPathComponent();
+ Object userObject = lastComponent.getUserObject();
+ if (userObject instanceof SpeciesControlError) {
+ SpeciesControlError error = (SpeciesControlError)userObject;
String species = error.getSpecies();
displayCompareNumberCatchGraph(controlView, species);
}
@@ -632,38 +643,64 @@
* Selectionne toutes les lignes associés au erreur d'un groupe d'erreur.
*
* @param controlView controlView
- * @param validationGroup validationGroup
+ * @param category la categorie pour switcher les tables
+ * @param lastNode validationGroup
*/
- protected void selectAllErrorGroupLines(ControlView controlView, Category category, ControlErrorGroup validationGroup) {
+ protected void selectAllErrorGroupLines(ControlView controlView, Category category, TreeTableNode lastNode) {
// swap category
controlView.getCategoryComboBoxModel().setSelectedItem(category);
// select all lines
+ JTable displayedTable = getControlDataTable(controlView);
+ ListSelectionModel selectionModel = displayedTable.getSelectionModel();
+ selectionModel.clearSelection();
+ selectAllErrorGroupLines(controlView, lastNode, true);
+ }
+
+ /**
+ * Methode recursive qui selection toutes les lignes correspondant à un
+ * groupe d'erreurs.
+ *
+ * @param controlView
+ * @param lastNode
+ * @param scrollToVisible allow to scroll to visible
+ */
+ protected void selectAllErrorGroupLines(ControlView controlView, TreeTableNode lastNode, boolean scrollToVisible) {
GlobalControlErrorModel model = controlView.getGlobalControlErrorModel();
JTable displayedTable = getControlDataTable(controlView);
ControlTableModel tableModel = (ControlTableModel)displayedTable.getModel();
ListSelectionModel selectionModel = displayedTable.getSelectionModel();
- selectionModel.clearSelection();
- boolean first = true;
- int childCount = model.getChildCount(validationGroup);
+
+ boolean first = scrollToVisible;
+ int childCount = model.getChildCount(lastNode);
for (int indexChild = 0 ; indexChild < childCount ; ++indexChild) {
- ControlError validationError = (ControlError)model.getChild(validationGroup, indexChild);
- List<String> errorLineNumbers = validationError.getLineNumbers();
+ TreeTableNode childNode = (TreeTableNode)model.getChild(lastNode, indexChild);
+ Object userObject = childNode.getUserObject();
- for (String errorLineNumber : errorLineNumbers) {
- int errorLineIndex = tableModel.getRealIndexOfLine(errorLineNumber);
+ if (userObject instanceof ControlErrorGroup) { // recursive
+ selectAllErrorGroupLines(controlView, childNode, first);
+ first = false;
+ } else if (userObject instanceof ControlError) {
+ ControlError validationError = (ControlError)userObject;
+ List<String> errorLineNumbers = validationError.getLineNumbers();
+
+ for (String errorLineNumber : errorLineNumbers) {
+ int errorLineIndex = tableModel.getRealIndexOfLine(errorLineNumber);
- // ca peut arriver si la ligne a été supprimée
- if (errorLineIndex >= 0) {
- selectionModel.addSelectionInterval(errorLineIndex, errorLineIndex);
- if (first) {
- scrollToVisible(displayedTable, errorLineIndex, 0);
- first = false;
+ // ca peut arriver si la ligne a été supprimée
+ if (errorLineIndex >= 0) {
+ selectionModel.addSelectionInterval(errorLineIndex, errorLineIndex);
+ if (first) {
+ scrollToVisible(displayedTable, errorLineIndex, 0);
+ first = false;
+ }
}
}
}
}
}
+
+
/**
* Scroll le viewport de la table à la ligne demandée.
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/GlobalControlErrorModel.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/GlobalControlErrorModel.java 2012-07-18 10:24:01 UTC (rev 1024)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/GlobalControlErrorModel.java 2012-07-19 09:36:52 UTC (rev 1025)
@@ -3,7 +3,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric
+ * Copyright (C) 2010 - 2012 Ifremer, Codelutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -26,21 +26,19 @@
import static org.nuiton.i18n.I18n._;
import static org.nuiton.i18n.I18n.n_;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import org.jdesktop.swingx.treetable.AbstractTreeTableModel;
+import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode;
+import org.jdesktop.swingx.treetable.DefaultTreeTableModel;
-import fr.ifremer.coser.CoserConstants.Category;
import fr.ifremer.coser.CoserConstants.ValidationLevel;
-import fr.ifremer.coser.control.ControlErrorGroup;
import fr.ifremer.coser.control.ControlError;
+import fr.ifremer.coser.control.ControlErrorGroup;
+import fr.ifremer.coser.control.DiffCatchLengthControlError;
/**
* Global validation table model.
@@ -51,23 +49,19 @@
* Last update : $Date$
* By : $Author$
*/
-public class GlobalControlErrorModel extends AbstractTreeTableModel {
+public class GlobalControlErrorModel extends DefaultTreeTableModel {
protected List<ControlError> controlErrors;
- protected List<Object> controlErrorCategory;
- protected Map<Object, List<ControlErrorGroup>> controlCategoryChild;
- protected Map<ControlErrorGroup, List<ControlError>> controlErrorsChilds;
protected Set<Object> checkedControlErrors;
public GlobalControlErrorModel() {
- super(1);
+ super(null);
}
public void setControlErrors(List<ControlError> controlErrors) {
this.controlErrors = controlErrors;
- getValidationErrorAsMaps(controlErrors);
- modelSupport.fireNewRoot();
-
+ buildGlobalControlErrorTreeModel(controlErrors);
+ checkedControlErrors = new HashSet<Object>();
}
public List<ControlError> getControlErrors() {
@@ -75,60 +69,61 @@
}
/**
- * Convert error list to tree structure.
+ * Utilise une simple liste d'erreur issue du contôle pour en faire
+ * une représentation sous forme d'arbre pour l'utilisateur.
*
- * @param validationErrors list to convert
+ * @param errors errors list to render
*/
- protected void getValidationErrorAsMaps(List<ControlError> validationErrors) {
+ protected void buildGlobalControlErrorTreeModel(List<ControlError> validationErrors) {
- controlCategoryChild = new HashMap<Object, List<ControlErrorGroup>>();
- controlErrorsChilds = new HashMap<ControlErrorGroup, List<ControlError>>();
+ Map<Object, DefaultMutableTreeTableNode> nodeCache = new HashMap<Object, DefaultMutableTreeTableNode>();
+ DefaultMutableTreeTableNode root = new DefaultMutableTreeTableNode(null);
for (ControlError validationError : validationErrors) {
-
Object category = validationError.getCategory() == null ?
n_("coser.ui.control.error.allCategories") : validationError.getCategory();
- List<ControlErrorGroup> errorGroup = controlCategoryChild.get(category);
- if (errorGroup == null) {
- errorGroup = new ArrayList<ControlErrorGroup>();
- controlCategoryChild.put(category, errorGroup);
+
+ // definition du noeud categorie
+ DefaultMutableTreeTableNode categoryNode = nodeCache.get(category);
+ if (categoryNode == null) {
+ categoryNode = new DefaultMutableTreeTableNode(category);
+ root.add(categoryNode);
+ nodeCache.put(category, categoryNode);
}
- ControlErrorGroup group = new ControlErrorGroup(validationError.getCategory(), validationError.getLevel(), validationError.getMessage());
-
- List<ControlError> childErrors = controlErrorsChilds.get(group);
- if (childErrors == null) {
- childErrors = new ArrayList<ControlError>();
- controlErrorsChilds.put(group, childErrors);
- errorGroup.add(group);
+ // definition du noeud de regroupement
+ // des erreurs de categories communes
+ DefaultMutableTreeTableNode parentNode = nodeCache.get(validationError.getMessage());
+ if (parentNode == null) {
+ ControlErrorGroup group = new ControlErrorGroup(validationError.getCategory(), validationError.getLevel(), validationError.getMessage());
+ parentNode = new DefaultMutableTreeTableNode(group);
+ categoryNode.add(parentNode);
+ nodeCache.put(validationError.getMessage(), parentNode);
}
-
- childErrors.add(validationError);
- }
-
- controlErrorCategory = new ArrayList<Object>(controlCategoryChild.keySet());
- Collections.sort(controlErrorCategory, new Comparator<Object>() {
- @Override
- public int compare(Object o1, Object o2) {
- int result = -1;
- if (o1 instanceof String) {
- if (o2 instanceof String) {
- result = ((String)o1).compareTo((String)o2);
- }
+
+ // cas special pour les erreurs DiffCatchLengthControlError
+ // regroupement supplémentaire par espèce
+ if (validationError instanceof DiffCatchLengthControlError) {
+ DiffCatchLengthControlError diffCatchError = (DiffCatchLengthControlError)validationError;
+ String species = diffCatchError.getSpecies();
+ String speciesCategory = _("coser.ui.control.error.diffcatchlenghtspecies", species);
+
+ ControlErrorGroup group = new ControlErrorGroup(validationError.getCategory(), validationError.getLevel(), speciesCategory);
+ DefaultMutableTreeTableNode newParent = nodeCache.get(speciesCategory);
+ if (newParent == null) {
+ newParent = new DefaultMutableTreeTableNode(group);
+ parentNode.add(newParent);
+ nodeCache.put(speciesCategory, newParent);
}
- else if (o1 instanceof Category) {
- if (o2 instanceof Category) {
- result = ((Category)o1).compareTo((Category)o2);
- }
- }
- return result;
+ parentNode = newParent;
}
-
- });
- for (List<ControlErrorGroup> groups : controlCategoryChild.values()) {
- Collections.sort(groups);
+
+ // ajout de l'erreur dans sa categories
+ DefaultMutableTreeTableNode node = new DefaultMutableTreeTableNode(validationError);
+ parentNode.add(node);
}
- checkedControlErrors = new HashSet<Object>();
+
+ setRoot(root);
}
/*
@@ -188,73 +183,7 @@
return result;
}
- /*
- * @see javax.swing.tree.TreeModel#getChild(java.lang.Object, int)
- */
@Override
- public Object getChild(Object parent, int index) {
-
- Object result = null;
-
- if (parent == getRoot()) {
- result = controlErrorCategory.get(index);
- }
- else if (parent instanceof String || parent instanceof Category) {
- result = controlCategoryChild.get(parent).get(index);
- }
- else if (parent instanceof ControlErrorGroup) {
- List<ControlError> childError = controlErrorsChilds.get(parent);
- result = childError.get(index);
- }
-
- return result;
- }
-
- /*
- * @see javax.swing.tree.TreeModel#getChildCount(java.lang.Object)
- */
- @Override
- public int getChildCount(Object parent) {
- int result = 0;
-
- if (parent == getRoot()) {
- if (controlErrorCategory != null) {
- result = controlErrorCategory.size();
- }
- }
- else if (parent instanceof String || parent instanceof Category) {
- result = controlCategoryChild.get(parent).size();
- }
- else if (parent instanceof ControlErrorGroup) {
- List<ControlError> childError = controlErrorsChilds.get(parent);
- result = childError.size();
- }
-
- return result;
- }
-
- /*
- * @see javax.swing.tree.TreeModel#getIndexOfChild(java.lang.Object, java.lang.Object)
- */
- @Override
- public int getIndexOfChild(Object parent, Object child) {
- int result = -1;
-
- if (parent == getRoot()) {
- result = controlErrorCategory.indexOf(child);
- }
- else if (parent instanceof String || parent instanceof Category) {
- result = controlCategoryChild.get(parent).indexOf(child);
- }
- else if (parent instanceof ControlErrorGroup) {
- List<ControlError> childError = controlErrorsChilds.get(parent);
- result = childError.indexOf(child);
- }
-
- return result;
- }
-
- @Override
public boolean isCellEditable(Object node, int column) {
boolean result = false;
if (column == 1) {
@@ -275,12 +204,10 @@
}
// recursive check of sub errors
- if (node instanceof String || node instanceof Category || node instanceof ControlErrorGroup) {
- int childCount = getChildCount(node);
- for (int i = 0 ; i < childCount; ++i) {
- Object child = getChild(node, i);
- setValueAt(value, child, column);
- }
+ int childCount = getChildCount(node);
+ for (int i = 0 ; i < childCount; ++i) {
+ Object child = getChild(node, i);
+ setValueAt(value, child, column);
}
}
}
Modified: trunk/coser-ui/src/main/resources/i18n/coser-ui_en_GB.properties
===================================================================
--- trunk/coser-ui/src/main/resources/i18n/coser-ui_en_GB.properties 2012-07-18 10:24:01 UTC (rev 1024)
+++ trunk/coser-ui/src/main/resources/i18n/coser-ui_en_GB.properties 2012-07-19 09:36:52 UTC (rev 1025)
@@ -35,6 +35,7 @@
coser.ui.control.dataMenuReplaceAll=Replace in %s in all data
coser.ui.control.deleteLine=Delete line
coser.ui.control.error.allCategories=All categories
+coser.ui.control.error.diffcatchlenghtspecies=Differences between length and catch for %s
coser.ui.control.global.message=Message
coser.ui.control.globalErrorMenuGenerateHTML=Control report
coser.ui.control.globalErrorMenuSelectAll=Select all lines
Modified: trunk/coser-ui/src/main/resources/i18n/coser-ui_fr_FR.properties
===================================================================
--- trunk/coser-ui/src/main/resources/i18n/coser-ui_fr_FR.properties 2012-07-18 10:24:01 UTC (rev 1024)
+++ trunk/coser-ui/src/main/resources/i18n/coser-ui_fr_FR.properties 2012-07-19 09:36:52 UTC (rev 1025)
@@ -35,6 +35,7 @@
coser.ui.control.dataMenuReplaceAll=Remplacer dans %s pour toutes les lignes
coser.ui.control.deleteLine=Supprimer la ligne
coser.ui.control.error.allCategories=Toutes les catégories
+coser.ui.control.error.diffcatchlenghtspecies=Différence entre les captures et taille pour %s
coser.ui.control.global.message=Message
coser.ui.control.globalErrorMenuGenerateHTML=Rapport de contrôle
coser.ui.control.globalErrorMenuSelectAll=Sélectionner toutes les lignes
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-07-18 10:24:01 UTC (rev 1024)
+++ trunk/pom.xml 2012-07-19 09:36:52 UTC (rev 1025)
@@ -316,7 +316,7 @@
<roles>
<role>Développeur</role>
</roles>
- <timezone>+2</timezone>
+ <timezone>Europe/Paris</timezone>
</developer>
<developer>
<id>tchemit</id>
@@ -326,7 +326,7 @@
<roles>
<role>Développeur</role>
</roles>
- <timezone>+2</timezone>
+ <timezone>Europe/Paris</timezone>
</developer>
</developers>
1
0
r1024 - in trunk/src/site: . en/rst en/rst/devel rst/devel
by echatellier@users.forge.codelutin.com 18 Jul '12
by echatellier@users.forge.codelutin.com 18 Jul '12
18 Jul '12
Author: echatellier
Date: 2012-07-18 12:24:01 +0200 (Wed, 18 Jul 2012)
New Revision: 1024
Url: http://forge.codelutin.com/repositories/revision/coser/1024
Log:
refs #1334
Added:
trunk/src/site/en/rst/devel/
trunk/src/site/en/rst/devel/textupdate.rst
trunk/src/site/rst/devel/textupdate.rst
Modified:
trunk/src/site/site_en.xml
trunk/src/site/site_fr.xml
Added: trunk/src/site/en/rst/devel/textupdate.rst
===================================================================
--- trunk/src/site/en/rst/devel/textupdate.rst (rev 0)
+++ trunk/src/site/en/rst/devel/textupdate.rst 2012-07-18 10:24:01 UTC (rev 1024)
@@ -0,0 +1,25 @@
+.. -
+.. * #%L
+.. * Coser
+.. *
+.. * $Id$
+.. * $HeadURL$
+.. * %%
+.. * Copyright (C) 2012 Ifremer, Codelutin, Chatellier Eric
+.. * %%
+.. * This program is free software: you can redistribute it and/or modify
+.. * it under the terms of the GNU Lesser General Public License as
+.. * published by the Free Software Foundation, either version 3 of the
+.. * License, or (at your option) any later version.
+.. *
+.. * This program is distributed in the hope that it will be useful,
+.. * but WITHOUT ANY WARRANTY; without even the implied warranty of
+.. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+.. * GNU General Lesser Public License for more details.
+.. *
+.. * You should have received a copy of the GNU General Lesser Public
+.. * License along with this program. If not, see
+.. * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+.. * #L%
+.. -
+
Added: trunk/src/site/rst/devel/textupdate.rst
===================================================================
--- trunk/src/site/rst/devel/textupdate.rst (rev 0)
+++ trunk/src/site/rst/devel/textupdate.rst 2012-07-18 10:24:01 UTC (rev 1024)
@@ -0,0 +1,82 @@
+.. -
+.. * #%L
+.. * Coser
+.. *
+.. * $Id$
+.. * $HeadURL$
+.. * %%
+.. * Copyright (C) 2012 Ifremer, Codelutin, Chatellier Eric
+.. * %%
+.. * This program is free software: you can redistribute it and/or modify
+.. * it under the terms of the GNU Lesser General Public License as
+.. * published by the Free Software Foundation, either version 3 of the
+.. * License, or (at your option) any later version.
+.. *
+.. * This program is distributed in the hope that it will be useful,
+.. * but WITHOUT ANY WARRANTY; without even the implied warranty of
+.. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+.. * GNU General Lesser Public License for more details.
+.. *
+.. * You should have received a copy of the GNU General Lesser Public
+.. * License along with this program. If not, see
+.. * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+.. * #L%
+.. -
+
+Mise à jour des textes du site
+==============================
+
+Cette documentation détaille comment mettre à jour le contenu textuel du site:
+http://www.ifremer.fr/SIH-indices-campagnes/.
+
+Source
+------
+Pour pouvoir modifier n'importe quel contenu, il faut être développeur autorisé
+à commiter sur le dépôt de source de coser.
+
+Ensuite, il est possible de récupérer les sources via un client subversion:
+ * Windows : http://tortoisesvn.net/
+ * Linux : commande console ``svn``
+
+L'adresse du dépôt à renseigner est : http://svn.forge.codelutin.com/svn/coser/trunk
+
+
+Organisation des dossiers
+-------------------------
+Le répertoire racine est constitué de 3 modules maven:
+
+ * *coser-business* : contenant le code métier (tout le code utilisé par les deux
+ autre modules)
+ * *coser-ui* : client swing
+ * *coser-web* : site internet
+
+Dans le cas de la modification du contenu text du site, le module *coser-web*
+devra être utilisé.
+
+
+Source du modules coser-web
+---------------------------
+Dans le module coser-web, deux groupes de fichiers concerne la modification
+du contenu textuel:
+
+ * ``src/main/webapp/WEB-INF/content`` : qui contient les pages html
+ * ``src/main/resources/fr/ifremer/coser/web`` : qui contient les traductions de
+ texte à inclure dans les pages html
+
+En effet, dans les pages html, on trouve ce genre d'instruction::
+
+ <head>
+ <title><s:text name="message.index.title" /></title>
+ </head>
+
+Cette code défini un titre de page html, contenant la traduction de le clé
+`message.layout.title`.
+
+Et dans les fichiers ``package_en.properties`` et ``package_fr.properties``, on trouve
+respectivement::
+
+ message.index.title=Home
+
+et::
+
+ message.index.title=Accueil
\ No newline at end of file
Modified: trunk/src/site/site_en.xml
===================================================================
--- trunk/src/site/site_en.xml 2012-07-18 10:22:09 UTC (rev 1023)
+++ trunk/src/site/site_en.xml 2012-07-18 10:24:01 UTC (rev 1024)
@@ -78,9 +78,9 @@
<item name="Controls list" href="user/guide_listcontrols.html" />
<item name="Controls modification" href="user/controls.html" />
</item>
- <!-- <item name="Developer" href="developer.html">
- <item name="Coser Project layout" href="devel/directory.html" />
- </item> -->
+ <item name="Developer" href="developer.html">
+ <item name="Update website texts" href="devel/textupdate.html" />
+ </item>
</menu>
<menu ref="modules"/>
Modified: trunk/src/site/site_fr.xml
===================================================================
--- trunk/src/site/site_fr.xml 2012-07-18 10:22:09 UTC (rev 1023)
+++ trunk/src/site/site_fr.xml 2012-07-18 10:24:01 UTC (rev 1024)
@@ -77,10 +77,11 @@
<item name="Avancé" href="user/guide_listcontrols.html">
<item name="Liste des contrôles" href="user/guide_listcontrols.html" />
<item name="Modification des contrôles" href="user/controls.html" />
+
</item>
- <!-- <item name="Développeur" href="developer.html">
- <item name="Coser Project layout" href="devel/directory.html" />
- </item> -->
+ <item name="Développeur" href="developer.html">
+ <item name="Mise à jour des textes du site" href="devel/textupdate.html" />
+ </item>
</menu>
<menu ref="modules"/>
1
0
Author: echatellier
Date: 2012-07-18 12:22:09 +0200 (Wed, 18 Jul 2012)
New Revision: 1023
Url: http://forge.codelutin.com/repositories/revision/coser/1023
Log:
Use released version
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-07-18 09:59:42 UTC (rev 1022)
+++ trunk/pom.xml 2012-07-18 10:22:09 UTC (rev 1023)
@@ -346,7 +346,7 @@
<license.organizationName>Ifremer, Codelutin</license.organizationName>
<!-- Versions -->
- <jaxx.version>2.5.2-SNAPSHOT</jaxx.version>
+ <jaxx.version>2.5.2</jaxx.version>
<i18n.version>2.4.1</i18n.version>
<!-- 2.3.1.1 fails to validate fields in jnlp -->
<struts.version>2.3.4</struts.version>
1
0
r1022 - trunk/coser-web/src/main/webapp/WEB-INF/decorators
by echatellier@users.forge.codelutin.com 18 Jul '12
by echatellier@users.forge.codelutin.com 18 Jul '12
18 Jul '12
Author: echatellier
Date: 2012-07-18 11:59:42 +0200 (Wed, 18 Jul 2012)
New Revision: 1022
Url: http://forge.codelutin.com/repositories/revision/coser/1022
Log:
Remove comments
Modified:
trunk/coser-web/src/main/webapp/WEB-INF/decorators/layout.jsp
trunk/coser-web/src/main/webapp/WEB-INF/decorators/sublayout.jsp
Modified: trunk/coser-web/src/main/webapp/WEB-INF/decorators/layout.jsp
===================================================================
--- trunk/coser-web/src/main/webapp/WEB-INF/decorators/layout.jsp 2012-07-18 09:53:12 UTC (rev 1021)
+++ trunk/coser-web/src/main/webapp/WEB-INF/decorators/layout.jsp 2012-07-18 09:59:42 UTC (rev 1022)
@@ -55,8 +55,7 @@
<div id="conteneur">
<div id="head" class="clearfix">
<a href="http://www.ifremer.fr/sih/" class="logoSIH" target="_blank">Système d'Information Halieutique</a>
- <h1><!-- Indices de populations et de communauté <br/>
- issus des campagnes de <span class="jaune">surveillance halieutique</span> de <span class="jaune">l'Ifremer </span> -->
+ <h1>
<s:text name="message.layout.title" />
</h1>
<a href="http://www.ifremer.fr/" class="logoIfremer" target="_blank">L'Ifremer</a>
Modified: trunk/coser-web/src/main/webapp/WEB-INF/decorators/sublayout.jsp
===================================================================
--- trunk/coser-web/src/main/webapp/WEB-INF/decorators/sublayout.jsp 2012-07-18 09:53:12 UTC (rev 1021)
+++ trunk/coser-web/src/main/webapp/WEB-INF/decorators/sublayout.jsp 2012-07-18 09:59:42 UTC (rev 1022)
@@ -55,8 +55,7 @@
<div id="conteneur_int">
<div id="head" class="clearfix">
<a href="http://www.ifremer.fr/sih/" class="logoSIH" target="_blank">Système d'Information Halieutique</a>
- <h1><!-- Indices de populations et de communauté <br/>
- issus des campagnes de <span class="jaune">surveillance halieutique</span> de <span class="jaune">l'Ifremer </span> -->
+ <h1>
<s:text name="message.layout.title" />
</h1>
<a href="http://www.ifremer.fr/" class="logoIfremer" target="_blank">L'Ifremer</a>
1
0
r1021 - trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control
by echatellier@users.forge.codelutin.com 18 Jul '12
by echatellier@users.forge.codelutin.com 18 Jul '12
18 Jul '12
Author: echatellier
Date: 2012-07-18 11:53:12 +0200 (Wed, 18 Jul 2012)
New Revision: 1021
Url: http://forge.codelutin.com/repositories/revision/coser/1021
Log:
Misc fix
Modified:
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlView.jaxx
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java 2012-07-18 08:29:15 UTC (rev 1020)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java 2012-07-18 09:53:12 UTC (rev 1021)
@@ -3,7 +3,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric
+ * Copyright (C) 2010 - 2012 Ifremer, Codelutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -390,7 +390,6 @@
final ControlService validationService = view.getContextValue(ControlService.class);
final Project project = view.getContextValue(Project.class);
- //final Category category = (Category)view.getCategoryComboBox().getSelectedItem();
final CoserProgressBar progressBar = view.getCheckProgressBar();
SwingWorker<List<ControlError>, Void> task = new SwingWorker<List<ControlError>, Void>() {
@@ -420,7 +419,7 @@
view.setContextValue(charts, "CompareCatchLengthGraph");
view.getCompareNumberCatchLengthButton().setEnabled(true);
- // hack parce que impossible de faire un faire
+ // hack parce que impossible à faire
// sans que les colonnes soit redimentionnées
view.getGlobalControlErrorTable().setAutoCreateColumnsFromModel(false);
@@ -562,7 +561,7 @@
* @param event mouse event
* @see DiffCatchLengthControlError
*/
- public void globalErrorTableMouseCLicked(final ControlView controlView, MouseEvent event) {
+ public void globalErrorTableMouseClicked(final ControlView controlView, MouseEvent event) {
int eventButton = event.getButton();
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlView.jaxx
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlView.jaxx 2012-07-18 08:29:15 UTC (rev 1020)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlView.jaxx 2012-07-18 09:53:12 UTC (rev 1021)
@@ -163,7 +163,7 @@
<JXTreeTable id='globalControlErrorTable' treeTableModel="{globalControlErrorModel}"
rootVisible="false" showsRootHandles="true"
treeCellRenderer="{new ControlErrorTreeRenderer()}"
- onMouseClicked="getHandler().globalErrorTableMouseCLicked(this, event)"
+ onMouseClicked="getHandler().globalErrorTableMouseClicked(this, event)"
selectionMode="{ListSelectionModel.SINGLE_SELECTION}" />
<javax.swing.tree.TreeSelectionModel id="globalControlErrorSelectionModel"
javaBean="globalControlErrorTable.getTreeSelectionModel()"
1
0
r1020 - trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/project
by echatellier@users.forge.codelutin.com 18 Jul '12
by echatellier@users.forge.codelutin.com 18 Jul '12
18 Jul '12
Author: echatellier
Date: 2012-07-18 10:29:15 +0200 (Wed, 18 Jul 2012)
New Revision: 1020
Url: http://forge.codelutin.com/repositories/revision/coser/1020
Log:
Fix button enabled
Modified:
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectOpenView.jaxx
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectOpenView.jaxx
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectOpenView.jaxx 2012-07-17 16:25:55 UTC (rev 1019)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectOpenView.jaxx 2012-07-18 08:29:15 UTC (rev 1020)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric
+ Copyright (C) 2010 - 2012 Ifremer, Codelutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -45,7 +45,7 @@
<row>
<cell weightx="1" anchor="east" columns="3">
<JButton text="coser.ui.project.openProject"
- enabled="{projectsList.getSelectedIndex() > 0}"
+ enabled="{projectsList.getSelectedIndex() >= 0}"
onActionPerformed="getHandler().loadProject(this)" />
</cell>
</row>
1
0
r1019 - in trunk/coser-ui/src/main/java/fr/ifremer/coser/ui: control project selection
by echatellier@users.forge.codelutin.com 17 Jul '12
by echatellier@users.forge.codelutin.com 17 Jul '12
17 Jul '12
Author: echatellier
Date: 2012-07-17 18:25:55 +0200 (Tue, 17 Jul 2012)
New Revision: 1019
Url: http://forge.codelutin.com/repositories/revision/coser/1019
Log:
Misc improvements
Modified:
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlView.jaxx
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectHandler.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectOpenView.jaxx
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionDetailsView.jaxx
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionListsView.jaxx
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlView.jaxx
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlView.jaxx 2012-07-17 15:28:11 UTC (rev 1018)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlView.jaxx 2012-07-17 16:25:55 UTC (rev 1019)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric
+ Copyright (C) 2010 - 2012 Ifremer, Codelutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -48,9 +48,6 @@
<row>
<cell fill="horizontal" insets="0" anchor="west" columns="2">
<JToolBar floatable="false">
- <JButton icon="disk.png" text="coser.ui.control.save"
- onActionPerformed="getHandler().saveControl(this)" />
- <JToolBar.Separator />
<JLabel text="coser.ui.control.categorylabel" />
<fr.ifremer.coser.ui.control.ControlCategoryListModel id="categoryComboBoxModel" />
<JComboBox id="categoryComboBox" model="{categoryComboBoxModel}"
@@ -67,11 +64,12 @@
<JToolBar.Separator />
<JButton icon="report.png" onActionPerformed="getHandler().displayLogReport(this)"
text="coser.ui.control.controlreport" />
- <JToolBar.Separator />
+ <Component initializer="javax.swing.Box.createHorizontalGlue()" />
+ <JButton icon="disk.png" text="coser.ui.control.save"
+ onActionPerformed="getHandler().saveControl(this)" />
<JButton icon="accept.png" onActionPerformed="getHandler().validControl(this)"
text="coser.ui.control.validcontrol" toolTipText="coser.ui.control.validcontroltip"
enabled="{isCanValidControl()}"/>
-
</JToolBar>
</cell>
</row>
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectHandler.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectHandler.java 2012-07-17 15:28:11 UTC (rev 1018)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectHandler.java 2012-07-17 16:25:55 UTC (rev 1019)
@@ -33,6 +33,7 @@
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
+import javax.swing.ListSelectionModel;
import javax.swing.SwingWorker;
import javax.swing.filechooser.FileFilter;
@@ -309,7 +310,8 @@
*/
public void loadProject(final ProjectOpenView projectView) {
- final String projectName = (String)projectView.getProjectsComboBox().getSelectedItem();
+ int selectedIndex = projectView.getProjectsList().getSelectedIndex();
+ String projectName = (String)projectView.getProjectsList().getModel().getElementAt(selectedIndex);
ProjectService projectService = projectView.getContextValue(ProjectService.class);
CoserFrame parent = projectView.getContextValue(CoserFrame.class, JAXXUtil.PARENT);
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectOpenView.jaxx
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectOpenView.jaxx 2012-07-17 15:28:11 UTC (rev 1018)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectOpenView.jaxx 2012-07-17 16:25:55 UTC (rev 1019)
@@ -29,20 +29,23 @@
<cell weightx="1" fill="horizontal">
<Table border='{BorderFactory.createTitledBorder(_("coser.ui.project.openProjectTitle"))}'>
<row>
- <cell anchor="west">
+ <cell anchor="north">
<JLabel text="coser.ui.project.project" />
</cell>
- <cell>
+ <cell anchor="north">
<JLabel text='{getContextValue(fr.ifremer.coser.CoserConfig.class).getProjectsDirectory().getAbsolutePath() + java.io.File.separator}' />
</cell>
- <cell anchor="west" weightx="1">
- <JComboBox id="projectsComboBox" model="{new fr.ifremer.coser.ui.project.ProjectNamesListModel(this)}" />
+ <cell fill="both" weightx="1">
+ <JScrollPane>
+ <JList id="projectsList" selectionMode="{javax.swing.ListSelectionModel.SINGLE_SELECTION}"
+ model="{new fr.ifremer.coser.ui.project.ProjectNamesListModel(this)}" />
+ </JScrollPane>
</cell>
</row>
<row>
<cell weightx="1" anchor="east" columns="3">
<JButton text="coser.ui.project.openProject"
- enabled="{projectsComboBox.getSelectedItem() != null}"
+ enabled="{projectsList.getSelectedIndex() > 0}"
onActionPerformed="getHandler().loadProject(this)" />
</cell>
</row>
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionDetailsView.jaxx
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionDetailsView.jaxx 2012-07-17 15:28:11 UTC (rev 1018)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionDetailsView.jaxx 2012-07-17 16:25:55 UTC (rev 1019)
@@ -63,15 +63,16 @@
</BeanValidator>
<row>
- <cell weightx="1" fill="horizontal">
+ <cell weightx="1" insets="0" fill="horizontal" >
<JToolBar floatable="false">
- <JButton id="saveSelectionButton" text="coser.ui.selection.details.saveSelection"
- icon="disk.png" onActionPerformed="getHandler().saveSelection(this)" />
<JButton icon="report.png" onActionPerformed="getHandler().displayLogReport(this)"
text="coser.ui.selection.selectionreport" />
<JToolBar.Separator />
<JButton icon="arrow_rotate_clockwise.png" onActionPerformed="getHandler().reloadControlData(this)"
text="coser.ui.selection.reloadcontroldata" />
+ <Component initializer="javax.swing.Box.createHorizontalGlue()" />
+ <JButton id="saveSelectionButton" text="coser.ui.selection.details.saveSelection"
+ icon="disk.png" onActionPerformed="getHandler().saveSelection(this)" />
</JToolBar>
</cell>
</row>
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java 2012-07-17 15:28:11 UTC (rev 1018)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java 2012-07-17 16:25:55 UTC (rev 1019)
@@ -766,20 +766,6 @@
}
/**
- * Sauvegarde la sélection (partie listes de selection)
- * et affiche un message utilisateur.
- *
- * @param view parent view
- */
- public void saveSelection(SelectionListsView view) {
- boolean saved = saveProjectSelection(view);
- if (saved) {
- JOptionPane.showMessageDialog(view, _("coser.ui.selection.selectionSaved"),
- _("coser.ui.selection.selectionTitle"), JOptionPane.INFORMATION_MESSAGE);
- }
- }
-
- /**
* Sauvegarde la sélection (partie listes de selection).
*
* @param view parent view
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionListsView.jaxx
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionListsView.jaxx 2012-07-17 15:28:11 UTC (rev 1018)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionListsView.jaxx 2012-07-17 16:25:55 UTC (rev 1019)
@@ -55,8 +55,7 @@
<row>
<cell columns="8" weightx="1" fill="horizontal">
<JToolBar floatable="false">
- <JButton id="saveSelectionButton" text="coser.ui.selection.details.saveSelection"
- icon="disk.png" onActionPerformed="getHandler().saveSelection(this)" />
+ <Component initializer="javax.swing.Box.createHorizontalGlue()" />
<JButton id="validSelectionButton" text="coser.ui.selection.details.validSelection"
icon="accept.png" onActionPerformed="getHandler().validSelection(this)" />
</JToolBar>
1
0
r1018 - in trunk: coser-business/src/main/java/fr/ifremer/coser/services coser-business/src/main/resources/i18n coser-business/src/test/java/fr/ifremer/coser/services coser-ui/src/main/java/fr/ifremer/coser/ui/control coser-ui/src/main/java/fr/ifremer/coser/ui/selection
by echatellier@users.forge.codelutin.com 17 Jul '12
by echatellier@users.forge.codelutin.com 17 Jul '12
17 Jul '12
Author: echatellier
Date: 2012-07-17 17:28:11 +0200 (Tue, 17 Jul 2012)
New Revision: 1018
Url: http://forge.codelutin.com/repositories/revision/coser/1018
Log:
fixes #1329 : Sauvegarder les rapports contr?\195?\180le et s?\195?\169lection en PDF
Modified:
trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java
trunk/coser-business/src/main/java/fr/ifremer/coser/services/PublicationService.java
trunk/coser-business/src/main/resources/i18n/coser-business_fr_FR.properties
trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java 2012-07-17 14:03:22 UTC (rev 1017)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java 2012-07-17 15:28:11 UTC (rev 1018)
@@ -825,14 +825,50 @@
* Genère également les PDF des rapports de contrôle.
*
* @param project project to save
- * @throws CoserBusinessException
+ * @throws CoserBusinessException
+ * @since 1.3
*/
public void validControl(Project project) throws CoserBusinessException {
-
- project.getControl().setValidated(true);
+ Control control = project.getControl();
+ control.setValidated(true);
+
+ // sauvegarde
+ saveProjectControl(project);
+
+ // generate control file as pdf
+ File projectsDirectory = config.getProjectsDirectory();
+ File projectDirectory = new File(projectsDirectory, project.getName());
+ File controlDirectory = new File(projectDirectory, CoserConstants.STORAGE_CONTROL_DIRECTORY);
+ File controlReportPdf = new File(controlDirectory, "control.pdf");
+ publicationService.extractControlLogAsPDF(project, control, controlReportPdf);
}
+
+ /**
+ * Marque la selection comme validée et sauve le projet.
+ *
+ * Genère également les PDF des rapports de selection.
+ *
+ * @param project project to save
+ * @throws CoserBusinessException
+ * @since 1.3
+ */
+ public void validSelection(Project project, Selection selection) throws CoserBusinessException {
+ selection.setValidated(true);
+
+ // sauvegarde
+ saveProjectSelection(project, selection);
+
+ // generate control file as pdf
+ File projectsDirectory = config.getProjectsDirectory();
+ File projectDirectory = new File(projectsDirectory, project.getName());
+ File selectionsDirectory = new File(projectDirectory, CoserConstants.STORAGE_SELECTION_DIRECTORY);
+ File selectionDirectory = new File(selectionsDirectory, selection.getName());
+ File selectionReportPdf = new File(selectionDirectory, "selection.pdf");
+ publicationService.extractSelectionLogAsPDF(project, selection, selectionReportPdf);
+ }
+
/**
* Creer une instance de selection "non sauvegardee" avec les données
* de control (validée) du projet.
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/PublicationService.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/services/PublicationService.java 2012-07-17 14:03:22 UTC (rev 1017)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/PublicationService.java 2012-07-17 15:28:11 UTC (rev 1018)
@@ -30,8 +30,13 @@
import java.awt.Color;
import java.awt.Shape;
import java.io.File;
+import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
import java.io.PrintStream;
+import java.io.StringWriter;
+import java.io.Writer;
import java.text.DateFormat;
import java.text.NumberFormat;
import java.util.ArrayList;
@@ -67,11 +72,16 @@
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.data.statistics.DefaultStatisticalCategoryDataset;
import org.jfree.util.ShapeUtilities;
+import org.w3c.dom.Document;
+import org.xhtmlrenderer.pdf.ITextRenderer;
+import com.lowagie.text.DocumentException;
+
import fr.ifremer.coser.CoserBusinessConfig;
import fr.ifremer.coser.CoserBusinessException;
import fr.ifremer.coser.CoserConstants;
import fr.ifremer.coser.CoserConstants.Category;
+import fr.ifremer.coser.CoserUtils;
import fr.ifremer.coser.bean.AbstractDataContainer;
import fr.ifremer.coser.bean.Control;
import fr.ifremer.coser.bean.Project;
@@ -86,6 +96,7 @@
import fr.ifremer.coser.data.Length;
import fr.ifremer.coser.storage.DataStorage;
import fr.ifremer.coser.storage.MemoryDataStorage;
+import freemarker.template.TemplateException;
/**
* Publication service (charts, reports, export, pdf...)
@@ -421,11 +432,9 @@
out.println("</ul>");
out.println("</body></html>");
- }
- catch (IOException ex) {
+ } catch (IOException ex) {
throw new CoserBusinessException("Can't export errors", ex);
- }
- finally {
+ } finally {
IOUtils.closeQuietly(out);
}
return exportHtmlFile;
@@ -443,40 +452,93 @@
*/
public File extractControlLogAsHTML(Project project, Control control) throws CoserBusinessException {
File exportHtmlFile = null;
- PrintStream out = null;
+ Writer out = null;
try {
exportHtmlFile = File.createTempFile("log-", ".html");
if (log.isInfoEnabled()) {
log.info("Generating HTML report to " + exportHtmlFile.getAbsolutePath());
}
- out = new PrintStream(exportHtmlFile, "utf-8");
+ out = new OutputStreamWriter(new FileOutputStream(exportHtmlFile), "utf-8");
+ extractControlLogAsHTML(project, control, out);
+ } catch (IOException ex) {
+ throw new CoserBusinessException("Can't export logs", ex);
+ } finally {
+ IOUtils.closeQuietly(out);
+ }
+ return exportHtmlFile;
+ }
- out.println("<html><head>");
- out.println("<title>" + _("coser.business.publication.controllogexporttitle", project.getName())+ "</title>");
- out.println("<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>");
- out.println("</head><body>");
+ /**
+ * Extrait les logs des modifications faites sur un control au format html
+ * dans un flux donné.
+ *
+ * @param project project
+ * @param control data container
+ * @param out output stream
+ * @throws CoserBusinessException
+ * @throws IOException
+ */
+ protected void extractControlLogAsHTML(Project project, Control control, Writer out) throws CoserBusinessException, IOException {
+ out.write("<html><head>");
+ out.write("<title>" + _("coser.business.publication.controllogexporttitle", project.getName())+ "</title>");
+ out.write("<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>");
+ out.write("</head><body>");
- // header
- out.println("<h1 style='text-align:center'>" + _("coser.business.publication.controllogexporttitle", project.getName()) + "</h1>");
+ // header
+ out.write("<h1 style='text-align:center'>" + _("coser.business.publication.controllogexporttitle", project.getName()) + "</h1>");
- // partie detail
- extractProjectReport(project, out);
+ // partie detail
+ extractProjectReport(project, out);
- // partie specific : commandes
- extractHistoryCommandReport(project, control, out);
+ // partie specific : commandes
+ extractHistoryCommandReport(project, control, out);
- out.println("</body></html>");
+ out.write("</body></html>");
+ }
+
+ /**
+ * Extrait les logs des modifications faites sur un control au format pdf.
+ *
+ * @param project project
+ * @param control data container
+ * @param pdfFile output pdf file
+ * @return extractedFile
+ * @throws CoserBusinessException
+ * @sincee 1.3
+ *
+ * @see AbstractDataContainer#getHistoryCommands()
+ */
+ public void extractControlLogAsPDF(Project project, Control control, File pdfFile) throws CoserBusinessException {
+
+ OutputStream os = null;
+ try {
+
+ Writer out = new StringWriter();
+ extractControlLogAsHTML(project, control, out);
+ out.flush();
+
+ // get content as w3c document
+ Document document = CoserUtils.parseDocument(out.toString());
+
+ // render template output as pdf
+ os = new FileOutputStream(pdfFile);
+
+ ITextRenderer renderer = new ITextRenderer();
+ renderer.setDocument(document, null);
+ renderer.layout();
+ renderer.createPDF(os);
+
+ os.close();
+ } catch (IOException ex) {
+ throw new CoserBusinessException("Can't generate log pdf", ex);
+ } catch (DocumentException ex) {
+ throw new CoserBusinessException("Can't generate log pdf", ex);
+ } finally {
+ IOUtils.closeQuietly(os);
}
- catch (IOException ex) {
- throw new CoserBusinessException("Can't export logs", ex);
- }
- finally {
- IOUtils.closeQuietly(out);
- }
- return exportHtmlFile;
}
-
+
/**
* Extrait les logs des modifications faites sur une selection au format html.
*
@@ -489,46 +551,61 @@
*/
public File extractSelectionLogAsHTML(Project project, Selection selection) throws CoserBusinessException {
File exportHtmlFile = null;
- PrintStream out = null;
+ Writer out = null;
try {
exportHtmlFile = File.createTempFile("log-", ".html");
if (log.isInfoEnabled()) {
log.info("Generating HTML report to " + exportHtmlFile.getAbsolutePath());
}
- out = new PrintStream(exportHtmlFile, "utf-8");
+ out = new OutputStreamWriter(new FileOutputStream(exportHtmlFile), "utf-8");
+ extractSelectionLogAsHTML(project, selection, out);
+
+ } catch (IOException ex) {
+ throw new CoserBusinessException("Can't export logs", ex);
+ } finally {
+ IOUtils.closeQuietly(out);
+ }
+ return exportHtmlFile;
+ }
- out.println("<html><head>");
- out.println("<title>" + _("coser.business.publication.selectionlogexporttitle", selection.getName(), project.getName())+ "</title>");
- out.println("<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>");
- out.println("</head><body>");
+ /**
+ * Extrait les logs des modifications faites sur une selection au format html
+ * dans le flux donné.
+ *
+ * @param project project
+ * @param selection data container
+ * @param out output stream
+ * @return extractedFile
+ * @throws IOException
+ * @throws CoserBusinessException
+ *
+ * @see AbstractDataContainer#getHistoryCommands()
+ */
+ protected void extractSelectionLogAsHTML(Project project, Selection selection, Writer out) throws IOException, CoserBusinessException {
+ out.write("<html><head>");
+ out.write("<title>" + _("coser.business.publication.selectionlogexporttitle", selection.getName(), project.getName())+ "</title>");
+ out.write("<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>");
+ out.write("</head><body>");
- // header
- out.println("<h1 style='text-align:center'>" + _("coser.business.publication.selectionlogexporttitle", selection.getName(), project.getName()) + "</h1>");
+ // header
+ out.write("<h1 style='text-align:center'>" + _("coser.business.publication.selectionlogexporttitle", selection.getName(), project.getName()) + "</h1>");
- // partie detail
- extractProjectReport(project, out);
+ // partie detail
+ extractProjectReport(project, out);
- // partie resumé de selection
- out.println("<h2>" + _("coser.business.publication.selectionchoices") + "</h2>");
- out.println("<ul>");
- out.println("<li>" + _("coser.business.common.years") + " : " + StringUtils.join(selection.getSelectedYears(), ", ") + "</li>");
- out.println("<li>" + _("coser.business.common.strata") + " : " + StringUtils.join(selection.getSelectedStrata(), ", ") + "</li>");
- out.println("<li>" + _("coser.business.common.species") + " : " + StringUtils.join(selection.getSelectedSpecies(), ", ") + "</li>");
- out.println("</ul>");
+ // partie resumé de selection
+ out.write("<h2>" + _("coser.business.publication.selectionchoices") + "</h2>");
+ out.write("<ul>");
+ out.write("<li>" + _("coser.business.common.years") + " : " + StringUtils.join(selection.getSelectedYears(), ", ") + "</li>");
+ out.write("<li>" + _("coser.business.common.strata") + " : " + StringUtils.join(selection.getSelectedStrata(), ", ") + "</li>");
+ out.write("<li>" + _("coser.business.common.species") + " : " + StringUtils.join(selection.getSelectedSpecies(), ", ") + "</li>");
+ out.write("</ul>");
- // partie specific : commandes
- extractHistoryCommandReport(project, selection, out);
+ // partie specific : commandes
+ extractHistoryCommandReport(project, selection, out);
- out.println("</body></html>");
- }
- catch (IOException ex) {
- throw new CoserBusinessException("Can't export logs", ex);
- }
- finally {
- IOUtils.closeQuietly(out);
- }
- return exportHtmlFile;
+ out.write("</body></html>");
}
/**
@@ -536,32 +613,74 @@
*
* @param project project
* @param out stream
+ * @throws IOException
*/
- protected void extractProjectReport(Project project, PrintStream out) {
+ protected void extractProjectReport(Project project, Writer out) throws IOException {
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT, config.getLocale());
// date du rapport
- out.println("<div style='text-align:right;font-style:italic'>" +
+ out.write("<div style='text-align:right;font-style:italic'>" +
_("coser.business.publication.date") +" : " +
dateFormat.format(new Date()) + "</div>");
// partie projet
- out.println("<h2>" + _("coser.business.publication.projectdetails") + "</h2>");
- out.println("<ul>");
- out.println("<li>" + _("coser.business.publication.creationdate") + " : " + dateFormat.format(project.getCreationDate()));
- out.println("<li>" + _("coser.business.publication.author") + " : " + project.getAuthor() + "</li>");
- out.println("<li>" + _("coser.business.publication.catchfilename") + " : " + commonService.getDataStorageFileName(project, Category.CATCH, null) + "</li>");
- out.println("<li>" + _("coser.business.publication.lengthfilename") + " : " + commonService.getDataStorageFileName(project, Category.LENGTH, null) + "</li>");
- out.println("<li>" + _("coser.business.publication.haulfilename") + " : " + commonService.getDataStorageFileName(project, Category.HAUL, null) + "</li>");
- out.println("<li>" + _("coser.business.publication.stratafilename") + " : " + commonService.getDataStorageFileName(project, Category.STRATA, null) + "</li>");
+ out.write("<h2>" + _("coser.business.publication.projectdetails") + "</h2>");
+ out.write("<ul>");
+ out.write("<li>" + _("coser.business.publication.creationdate") + " : " + dateFormat.format(project.getCreationDate()) + "</li>");
+ out.write("<li>" + _("coser.business.publication.author") + " : " + project.getAuthor() + "</li>");
+ out.write("<li>" + _("coser.business.publication.catchfilename") + " : " + commonService.getDataStorageFileName(project, Category.CATCH, null) + "</li>");
+ out.write("<li>" + _("coser.business.publication.lengthfilename") + " : " + commonService.getDataStorageFileName(project, Category.LENGTH, null) + "</li>");
+ out.write("<li>" + _("coser.business.publication.haulfilename") + " : " + commonService.getDataStorageFileName(project, Category.HAUL, null) + "</li>");
+ out.write("<li>" + _("coser.business.publication.stratafilename") + " : " + commonService.getDataStorageFileName(project, Category.STRATA, null) + "</li>");
if (StringUtils.isNotEmpty(project.getComment())) {
- out.println("<li>" + _("coser.business.publication.comment") + " : " + project.getComment() + "</li>");
+ out.write("<li>" + _("coser.business.publication.comment") + " : " + project.getComment() + "</li>");
}
- out.println("</ul>");
+ out.write("</ul>");
}
/**
+ * Extrait les logs des modifications faites sur une selection au format pdf.
+ *
+ * @param project project
+ * @param selection data container
+ * @return extractedFile
+ * @throws CoserBusinessException
+ * @since 1.3
+ *
+ * @see AbstractDataContainer#getHistoryCommands()
+ */
+ public void extractSelectionLogAsPDF(Project project, Selection selection, File pdfFile) throws CoserBusinessException {
+
+ OutputStream os = null;
+ try {
+
+ Writer out = new StringWriter();
+ extractSelectionLogAsHTML(project, selection, out);
+ out.flush();
+
+ // get content as w3c document
+ Document document = CoserUtils.parseDocument(out.toString());
+
+ // render template output as pdf
+ os = new FileOutputStream(pdfFile);
+
+ ITextRenderer renderer = new ITextRenderer();
+ renderer.setDocument(document, null);
+ renderer.layout();
+ renderer.createPDF(os);
+
+ os.close();
+ } catch (IOException ex) {
+ throw new CoserBusinessException("Can't generate log pdf", ex);
+ } catch (DocumentException ex) {
+ throw new CoserBusinessException("Can't generate log pdf", ex);
+ } finally {
+ IOUtils.closeQuietly(os);
+ }
+ }
+
+ /**
* Partie commune aux export qui effectue en 2 passe la recuperation
* des lignes d'erreur, la recuperation des données correspondant à
* ces lignes dans les fichiers originaux et la sortie des erreurs.
@@ -570,8 +689,9 @@
* @param container data container
* @param out output stream
* @throws CoserBusinessException
+ * @throws IOException
*/
- protected void extractHistoryCommandReport(Project project, AbstractDataContainer container, PrintStream out) throws CoserBusinessException {
+ protected void extractHistoryCommandReport(Project project, AbstractDataContainer container, Writer out) throws CoserBusinessException, IOException {
// first get lines index to get content
Set<String> catchLines = new HashSet<String>();
@@ -611,8 +731,8 @@
Map<String, String[]> strataContent = commonService.getOriginalContent(project, Category.STRATA, strataLines);
// third, generate html report
- out.println("<h2>" + _("coser.business.publication.datamodification") + "</h2>");
- out.println("<ol>");
+ out.write("<h2>" + _("coser.business.publication.datamodification") + "</h2>");
+ out.write("<ol>");
for (Command command : container.getHistoryCommands()) {
Category category = null;
String line = null;
@@ -636,14 +756,14 @@
data = strataContent.get(line);
break;
}
- out.println("<li>" + command.getLogString(container) + "<br/>");
- out.println("<tt style='color:#5F5A59'>" + StringUtils.join(data, ", ") + "</tt><br /></li>");
+ out.write("<li>" + command.getLogString(container) + "<br/>");
+ out.write("<tt style='color:#5F5A59'>" + StringUtils.join(data, ", ") + "</tt><br /></li>");
}
else {
- out.println("<li>" + command.getLogString(container) + "</li>");
+ out.write("<li>" + command.getLogString(container) + "</li>");
}
}
- out.println("</ol>");
+ out.write("</ol>");
}
/**
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-07-17 14:03:22 UTC (rev 1017)
+++ trunk/coser-business/src/main/resources/i18n/coser-business_fr_FR.properties 2012-07-17 15:28:11 UTC (rev 1018)
@@ -111,7 +111,7 @@
coser.business.publication.catchfilename=Nom du fichier captures
coser.business.publication.comment=Commentaire
coser.business.publication.controllogexporttitle=Rapport des modifications (projet %s)
-coser.business.publication.creationdate=Date de créaction
+coser.business.publication.creationdate=Date de création
coser.business.publication.datamodification=Modifications sur les données
coser.business.publication.date=Le
coser.business.publication.errorexportlines=Lignes
Modified: trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java
===================================================================
--- trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java 2012-07-17 14:03:22 UTC (rev 1017)
+++ trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java 2012-07-17 15:28:11 UTC (rev 1018)
@@ -154,11 +154,47 @@
}
/**
+ * Test que la validation du controle fonctionne et produit bien le pdf
+ * de rapport.
+ *
+ * @throws CoserBusinessException
+ */
+ @Test
+ public void testValidControl() throws CoserBusinessException {
+ Project project = createTestProject(projectService, false);
+ projectService.validControl(project);
+
+ Assert.assertTrue(project.getControl().isValidated());
+ Assert.assertTrue(new File(config.getProjectsDirectory(),
+ project.getName() + File.separator + "control" + File.separator + "control.pdf").exists());
+ }
+
+ /**
* Test que les selections sont bien creer.
*
* @throws CoserBusinessException
*/
@Test
+ public void testValidSelection() throws CoserBusinessException {
+ Project project = createTestProject(projectService, true);
+ Selection selection = projectService.initProjectSelection(project);
+ selection.setName("titi");
+
+ projectService.createProjectSelection(project, selection);
+ projectService.validSelection(project, selection);
+
+ Assert.assertTrue(selection.isValidated());
+ Assert.assertTrue(new File(config.getProjectsDirectory(),
+ project.getName() + File.separator + "selections" + File.separator +
+ "titi" + File.separator + "selection.pdf").exists());
+ }
+
+ /**
+ * Test que les selections sont bien creer.
+ *
+ * @throws CoserBusinessException
+ */
+ @Test
public void testCreateSelection() throws CoserBusinessException {
Project project = createTestProject(projectService, true);
Selection selection = projectService.initProjectSelection(project);
@@ -259,8 +295,6 @@
// doit recharger les données pour être correct
strata = projectService.filterDataYearsAndGetStrata(project, selection, years3);
Assert.assertEquals(3, strata.size());
-
-
}
/**
@@ -317,7 +351,6 @@
projectService.filterDataStrata(project, selection, Collections.singletonList("STR6"));
species = projectService.getProjectSpecies(project, selection, allPpeciesType);
Assert.assertEquals(4, species.size());
-
}
/**
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java 2012-07-17 14:03:22 UTC (rev 1017)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java 2012-07-17 15:28:11 UTC (rev 1018)
@@ -1073,7 +1073,6 @@
try {
service.validControl(project);
- saveProjectControl(view);
JOptionPane.showMessageDialog(view, _("coser.ui.control.controlValidated"),
_("coser.ui.control.controlTitle"), JOptionPane.INFORMATION_MESSAGE);
} catch (CoserBusinessException ex) {
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java 2012-07-17 14:03:22 UTC (rev 1017)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java 2012-07-17 15:28:11 UTC (rev 1018)
@@ -854,14 +854,20 @@
*/
public void validSelection(SelectionListsView view) {
Selection selection = view.getContextValue(Selection.class);
+ Project project = view.getContextValue(Project.class);
+ ProjectService service = view.getContextValue(ProjectService.class);
saveSelectionLists(view, selection);
boolean canBeValidated = checkSelectionListComments(view, selection);
if (canBeValidated) {
- selection.setValidated(true);
- boolean saved = saveProjectSelection(view);
- if (saved) {
+ try {
+ service.validSelection(project, selection);
JOptionPane.showMessageDialog(view, _("coser.ui.selection.selectionValidated"),
- _("coser.ui.selection.selectionTitle"), JOptionPane.INFORMATION_MESSAGE);
+ _("coser.ui.selection.selectionTitle"), JOptionPane.INFORMATION_MESSAGE);
+ } catch (CoserBusinessException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't save selection", ex);
+ }
+ JOptionPane.showMessageDialog(view, ex.getMessage(), _("coser.ui.selection.saveError"), JOptionPane.ERROR_MESSAGE);
}
}
}
1
0