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
- 1259 discussions
Author: chatellier
Date: 2010-11-18 08:47:18 +0000 (Thu, 18 Nov 2010)
New Revision: 224
Log:
Update dependencies
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-11-17 17:36:33 UTC (rev 223)
+++ trunk/pom.xml 2010-11-18 08:47:18 UTC (rev 224)
@@ -90,7 +90,7 @@
<dependency>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-utils</artifactId>
- <version>1.5.1-SNAPSHOT</version>
+ <version>1.5.1</version>
<scope>compile</scope>
</dependency>
@@ -153,18 +153,8 @@
<dependency>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-widgets</artifactId>
- <version>1.0.4-SNAPSHOT</version>
+ <version>1.1-SNAPSHOT</version>
<scope>compile</scope>
- <exclusions>
- <exclusion>
- <groupId>jgoodies</groupId>
- <artifactId>looks</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.nuiton.thirdparty</groupId>
- <artifactId>l2fprod-common</artifactId>
- </exclusion>
- </exclusions>
</dependency>
<dependency>
1
0
r223 - in trunk: coser-business/src/main/java/fr/ifremer/coser/services coser-business/src/main/resources/fr/ifremer/coser/data coser-business/src/main/resources/i18n coser-ui/src/main/java/fr/ifremer/coser/ui/control coser-ui/src/main/resources/i18n
by chatellier@users.labs.libre-entreprise.org 17 Nov '10
by chatellier@users.labs.libre-entreprise.org 17 Nov '10
17 Nov '10
Author: chatellier
Date: 2010-11-17 17:36:33 +0000 (Wed, 17 Nov 2010)
New Revision: 223
Log:
Add cross files control
Modified:
trunk/coser-business/src/main/java/fr/ifremer/coser/services/ValidationService.java
trunk/coser-business/src/main/resources/fr/ifremer/coser/data/Haul-error-validation.xml
trunk/coser-business/src/main/resources/fr/ifremer/coser/data/Length-error-validation.xml
trunk/coser-business/src/main/resources/fr/ifremer/coser/data/Strata-error-validation.xml
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-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.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
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/ValidationService.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/services/ValidationService.java 2010-11-17 15:03:14 UTC (rev 222)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ValidationService.java 2010-11-17 17:36:33 UTC (rev 223)
@@ -57,6 +57,7 @@
import fr.ifremer.coser.CoserConstants.Category;
import fr.ifremer.coser.CoserConstants.ValidationLevel;
import fr.ifremer.coser.bean.Control;
+import fr.ifremer.coser.bean.Project;
import fr.ifremer.coser.control.ProgressMonitor;
import fr.ifremer.coser.control.ValidationError;
import fr.ifremer.coser.data.AbstractDataEntity;
@@ -187,11 +188,12 @@
/**
* Valide toutes les données du projet.
*
+ * @param project project
* @param control control a valider
* @param progress progress monitor
* @return les erreurs de validation
*/
- public List<ValidationError> validateData(Control control, ProgressMonitor progress) {
+ public List<ValidationError> validateData(Project project, Control control, ProgressMonitor progress) {
// compte le nombre de category a valider
int categoryCount = 0;
@@ -214,11 +216,17 @@
// validation specifique de la category
List<ValidationError> specificErrors = validateCategorySpecific(control, category, progress);
if (specificErrors != null) {
- categoryErrors.addAll(specificErrors);
+ validationErrors.addAll(specificErrors);
}
}
}
+ // validation par croisement de fichiers
+ List<ValidationError> crossFileErrors = validationCrossFiles(project, control, progress);
+ if (crossFileErrors != null) {
+ validationErrors.addAll(crossFileErrors);
+ }
+
// cas particulier, s'il n'y a aucune erreur, on ajout une erreur de
// type info pour dire qu'il n'y a pas d'erreur
if (validationErrors.isEmpty()) {
@@ -229,7 +237,7 @@
}
return validationErrors;
}
-
+
/**
* Valide une category entière d'un project.
*
@@ -644,4 +652,182 @@
Control control, ProgressMonitor progress) {
return null;
}
+
+ /**
+ * @param control
+ * @param progress
+ * @return
+ */
+ protected List<ValidationError> validationCrossFiles(Project project, Control control,
+ ProgressMonitor progress) {
+
+ if (progress != null) {
+ progress.setText(_("coser.business.control.step.crossFileChech", 0));
+ progress.setTotal(100);
+ progress.setCurrent(0);
+ }
+
+ List<ValidationError> crossFilesErrors = new ArrayList<ValidationError>();
+
+ // get all iterators
+ Iterator<String[]> itReftax = project.getRefTaxSpecies().iterator();
+ itReftax.next(); // skip header
+ Iterator<String[]> itCatch = control.getCatch().iterator();
+ itCatch.next(); // skip header
+ Iterator<String[]> itLength = control.getLength().iterator();
+ itLength.next(); // skip header
+ Iterator<String[]> itStrata = control.getStrata().iterator();
+ itStrata.next(); // skip header
+ Iterator<String[]> itHaul = control.getHaul().iterator();
+ itHaul.next(); // skip header
+
+ // declare all necessary data
+ Set<String> refTaxSpecies = new HashSet<String>();
+ Set<String> catchYear = new HashSet<String>();
+ Set<String> lengthYear = new HashSet<String>();
+ Set<String> haulYear = new HashSet<String>();
+ Set<String> campagneNames = new HashSet<String>();
+ Set<String> lengthYearHaulSpecies = new HashSet<String>();
+ Set<String> catchYearHaulSpecies = new HashSet<String>();
+ Set<String> haulYearHaul = new HashSet<String>();
+ Set<String> lengthYearHaul = new HashSet<String>();
+ Set<String> catchYearHaul = new HashSet<String>();
+
+ // parcourt de toutes les données
+ while (itReftax.hasNext() ) {
+ String[] tuple = itReftax.next();
+ // "C_Perm","NumSys","NivSys","C_VALIDE","L_VALIDE","AA_VALIDE","C_TxP\u00E8re","Taxa"
+ refTaxSpecies.add(tuple[3]);
+ }
+
+ while (itCatch.hasNext()) {
+ String[] catchData = itCatch.next();
+ campagneNames.add(catchData[Catch.INDEX_SURVEY]);
+ catchYear.add(catchData[Catch.INDEX_YEAR]);
+ catchYearHaulSpecies.add(catchData[Catch.INDEX_YEAR] + ";" + catchData[Catch.INDEX_HAUL] + ";" + catchData[Catch.INDEX_SPECIES]);
+ catchYearHaul.add(catchData[Catch.INDEX_YEAR] + ";" + catchData[Catch.INDEX_HAUL]);
+
+ // Contrôle des noms d'espèces dans fichiers CAPTURES et TAILLES qui
+ // doivent être dans le référentiel "reftax": CAPTURES$Espece et
+ // TAILLES$Espece doivent exister dans REFTAX$ C_VALIDE
+ if (!refTaxSpecies.contains(catchData[Catch.INDEX_SPECIES])) {
+ ValidationError error = new ValidationError();
+ error.setCategory(Category.CATCH);
+ error.setLineNumber(catchData[Catch.INDEX_LINE]);
+ error.setLevel(ValidationLevel.ERROR);
+ error.setMessage(_("coser.business.control.error.nonExistantSpecies"));
+ error.setDetailMessage(_("coser.business.control.error.nonExistantSpeciesDetail", catchData[Catch.INDEX_SPECIES]));
+ crossFilesErrors.add(error);
+ }
+ }
+
+ if (progress != null) {
+ progress.setText(_("coser.business.control.step.crossFileChech", 25));
+ progress.setCurrent(25);
+ }
+
+ while (itLength.hasNext()) {
+ String[] lengthData = itLength.next();
+ campagneNames.add(lengthData[Length.INDEX_SURVEY]);
+ lengthYear.add(lengthData[Length.INDEX_YEAR]);
+ lengthYearHaulSpecies.add(lengthData[Length.INDEX_YEAR] + ";" +
+ lengthData[Length.INDEX_HAUL] + ";" + lengthData[Length.INDEX_SPECIES]);
+ lengthYearHaul.add(lengthData[Length.INDEX_YEAR] + ";" + lengthData[Length.INDEX_HAUL]);
+
+ // Contrôle des noms d'espèces dans fichiers CAPTURES et TAILLES qui
+ // doivent être dans le référentiel "reftax": CAPTURES$Espece et
+ // TAILLES$Espece doivent exister dans REFTAX$ C_VALIDE
+ if (!refTaxSpecies.contains(lengthData[Length.INDEX_SPECIES])) {
+ ValidationError error = new ValidationError();
+ error.setCategory(Category.CATCH);
+ error.setLineNumber(lengthData[Length.INDEX_LINE]);
+ error.setLevel(ValidationLevel.ERROR);
+ error.setMessage(_("coser.business.control.error.nonExistantSpecies"));
+ error.setDetailMessage(_("coser.business.control.error.nonExistantSpeciesDetail", lengthData[Length.INDEX_SPECIES]));
+ crossFilesErrors.add(error);
+ }
+ }
+
+ if (progress != null) {
+ progress.setText(_("coser.business.control.step.crossFileChech", 50));
+ progress.setCurrent(50);
+ }
+
+ /*while (itStrata.hasNext()) {
+ String[] strataData = itStrata.next();
+ campagneNames.add(strataData[Strata.INDEX_SURVEY]);
+ catchYear.add(strataData[Strata.INDEX_YEAR]);
+ }*/
+
+ if (progress != null) {
+ progress.setText(_("coser.business.control.step.crossFileChech", 75));
+ progress.setCurrent(75);
+ }
+
+ while (itHaul.hasNext()) {
+ String[] haulData = itHaul.next();
+ campagneNames.add(haulData[Haul.INDEX_SURVEY]);
+ haulYear.add(haulData[Haul.INDEX_YEAR]);
+ haulYearHaul.add(haulData[Haul.INDEX_YEAR] + ";" + haulData[Haul.INDEX_HAUL]);
+ }
+
+ // Vérifier que les mêmes années sont présentes dans fichiers captures
+ // traits et tailles: CAPTURES$Annee, TRAITS$Annee, TAILLES$Annee.
+ if (!catchYear.equals(lengthYear) || !haulYear.equals(lengthYear)) {
+ ValidationError error = new ValidationError();
+ error.setLevel(ValidationLevel.FATAL);
+ error.setMessage(_("coser.business.control.error.yearsNotEquals"));
+ error.setDetailMessage(_("coser.business.control.error.yearsNotEquals"));
+ crossFilesErrors.add(error);
+ }
+
+ // Vérifier que le nom de la campagne est le même dans tous les fichiers *$Campagne.
+ if (campagneNames.size() != 1) {
+ ValidationError error = new ValidationError();
+ error.setLevel(ValidationLevel.FATAL);
+ error.setMessage(_("coser.business.control.error.surveyNotEquals"));
+ error.setDetailMessage(_("coser.business.control.error.surveyNotEquals"));
+ crossFilesErrors.add(error);
+ }
+
+ // Vérifier que pour chaque espèce présent dans un trait d'une année
+ // dans le fichier tailles (noté Annee|Trait|Espece) il y a une donnée
+ // dans le fichier captures (le contraire n'est pas vraie)
+ if (!catchYearHaulSpecies.contains(lengthYearHaulSpecies)) {
+ ValidationError error = new ValidationError();
+ error.setLevel(ValidationLevel.FATAL);
+ error.setMessage(_("coser.business.control.error.incompleteHaulSpeciesData"));
+ error.setDetailMessage(_("coser.business.control.error.incompleteHaulSpeciesData"));
+ crossFilesErrors.add(error);
+ }
+
+ // Vérifier que pour chaque trait présent une année (noté Annee|Trait)
+ // dans les fichiers tailles et capt il y a une donnée dans le fichier
+ // traits
+ if (!lengthYearHaul.containsAll(haulYearHaul)) {
+ ValidationError error = new ValidationError();
+ error.setLevel(ValidationLevel.FATAL);
+ error.setMessage(_("coser.business.control.error.incompleteHaulDataLength"));
+ error.setDetailMessage(_("coser.business.control.error.incompleteHaulDataLength"));
+ crossFilesErrors.add(error);
+ }
+
+ // Vérifier que pour chaque trait présent une année (noté Annee|Trait)
+ // dans les fichiers tailles et capt il y a une donnée dans le fichier
+ // traits
+ if (!catchYearHaul.containsAll(haulYearHaul)) {
+ ValidationError error = new ValidationError();
+ error.setLevel(ValidationLevel.FATAL);
+ error.setMessage(_("coser.business.control.error.incompleteHaulDataCatch"));
+ error.setDetailMessage(_("coser.business.control.error.incompleteHaulDataCatch"));
+ crossFilesErrors.add(error);
+ }
+
+ if (progress != null) {
+ progress.setText(_("coser.business.control.step.crossFileChech", 100));
+ progress.setCurrent(100);
+ }
+
+ return crossFilesErrors;
+ }
}
Modified: trunk/coser-business/src/main/resources/fr/ifremer/coser/data/Haul-error-validation.xml
===================================================================
--- trunk/coser-business/src/main/resources/fr/ifremer/coser/data/Haul-error-validation.xml 2010-11-17 15:03:14 UTC (rev 222)
+++ trunk/coser-business/src/main/resources/fr/ifremer/coser/data/Haul-error-validation.xml 2010-11-17 17:36:33 UTC (rev 223)
@@ -52,23 +52,27 @@
<message>You must enter a stratum name.</message>
</field-validator>
</field>
- <field name="sweptSurface">
- <field-validator type="checkDouble" short-circuit="true">
+ <field name="sweptSurfaceAsString">
+ <field-validator type="checkDouble">
+ <param name="notAvailable">NA</param>
<message>sweptSurface attribute is not a valid double</message>
</field-validator>
</field>
- <field name="lat">
- <field-validator type="checkDouble" short-circuit="true">
+ <field name="latAsString">
+ <field-validator type="checkDouble">
+ <param name="notAvailable">NA</param>
<message>lat attribute is not a valid double</message>
</field-validator>
</field>
- <field name="long">
- <field-validator type="checkDouble" short-circuit="true">
+ <field name="longAsString">
+ <field-validator type="checkDouble">
+ <param name="notAvailable">NA</param>
<message>long attribute is not a valid double</message>
</field-validator>
</field>
- <field name="depth">
- <field-validator type="checkDouble" short-circuit="true">
+ <field name="depthAsString">
+ <field-validator type="checkDouble">
+ <param name="notAvailable">NA</param>
<message>Depth attribute is not a valid double</message>
</field-validator>
</field>
Modified: trunk/coser-business/src/main/resources/fr/ifremer/coser/data/Length-error-validation.xml
===================================================================
--- trunk/coser-business/src/main/resources/fr/ifremer/coser/data/Length-error-validation.xml 2010-11-17 15:03:14 UTC (rev 222)
+++ trunk/coser-business/src/main/resources/fr/ifremer/coser/data/Length-error-validation.xml 2010-11-17 17:36:33 UTC (rev 223)
@@ -60,18 +60,18 @@
<message>Maturity attribute is required</message>
</field-validator>
</field>
- <field name="length">
+ <field name="lengthAsString">
<field-validator type="checkDouble">
<message>length attribute is not a valid double</message>
</field-validator>
</field>
- <field name="number">
+ <field name="numberAsString">
<field-validator type="checkDouble">
<param name="notAvailable">NA</param>
<message>number attribute is not a valid double</message>
</field-validator>
</field>
- <field name="weight">
+ <field name="weightAsString">
<field-validator type="checkDouble">
<param name="notAvailable">NA</param>
<message>Weight attribute is not a valid double</message>
Modified: trunk/coser-business/src/main/resources/fr/ifremer/coser/data/Strata-error-validation.xml
===================================================================
--- trunk/coser-business/src/main/resources/fr/ifremer/coser/data/Strata-error-validation.xml 2010-11-17 15:03:14 UTC (rev 222)
+++ trunk/coser-business/src/main/resources/fr/ifremer/coser/data/Strata-error-validation.xml 2010-11-17 17:36:33 UTC (rev 223)
@@ -38,7 +38,7 @@
<message>You must enter a strata name.</message>
</field-validator>
</field>
- <field name="surface">
+ <field name="surfaceAsString">
<field-validator type="requiredstring">
<param name="trim">true</param>
<message>You must enter a trait name.</message>
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 2010-11-17 15:03:14 UTC (rev 222)
+++ trunk/coser-business/src/main/resources/i18n/coser-business-en_GB.properties 2010-11-17 17:36:33 UTC (rev 223)
@@ -35,10 +35,17 @@
coser.business.common.number=
coser.business.common.year=
coser.business.control.error.duplicatedLine=
+coser.business.control.error.incompleteHaulDataCatch=
+coser.business.control.error.incompleteHaulDataLength=
+coser.business.control.error.incompleteHaulSpeciesData=
coser.business.control.error.minObservationCount=
coser.business.control.error.minObservationCountDetail=
-coser.business.control.error.noCatchNumberWithWeight=
+coser.business.control.error.nonExistantSpecies=
+coser.business.control.error.nonExistantSpeciesDetail=
+coser.business.control.error.surveyNotEquals=
+coser.business.control.error.yearsNotEquals=
coser.business.control.noerrorfound=No error found
+coser.business.control.step.crossFileChech=
coser.business.control.step.observation=
coser.business.control.step.xworks=
coser.business.line=Line
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 2010-11-17 15:03:14 UTC (rev 222)
+++ trunk/coser-business/src/main/resources/i18n/coser-business-fr_FR.properties 2010-11-17 17:36:33 UTC (rev 223)
@@ -35,10 +35,17 @@
coser.business.common.number=Nombre
coser.business.common.year=Ann\u00E9e
coser.business.control.error.duplicatedLine=Ligne en doublon
+coser.business.control.error.incompleteHaulDataCatch=Certains couples Annee|Trait ne sont pas pr\u00E9sents dans les captures
+coser.business.control.error.incompleteHaulDataLength=Certains couples Annee|Trait ne sont pas pr\u00E9sents dans les tailles
+coser.business.control.error.incompleteHaulSpeciesData=Certains couples Annee|Trait|Espece ne sont pas pr\u00E9sents dans les captures
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.noCatchNumberWithWeight=Poids sp\u00E9cifi\u00E9 sans captures
+coser.business.control.error.nonExistantSpecies=Esp\u00E8ces non existantes dans le reftax
+coser.business.control.error.nonExistantSpeciesDetail=Esp\u00E8ce %s non existante dans le reftax
+coser.business.control.error.surveyNotEquals=Les noms de campagnes de sont pas \u00E9gaux
+coser.business.control.error.yearsNotEquals=Les ann\u00E9es ne sont pas identiques
coser.business.control.noerrorfound=Aucune erreur d\u00E9tect\u00E9e
+coser.business.control.step.crossFileChech=V\u00E9rification par croisement de fichiers (%d%%)
coser.business.control.step.observation=V\u00E9rification du nombre d'observation (%d%%)
coser.business.control.step.xworks=Validation par lignes (%d%%)
coser.business.line=Ligne
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 2010-11-17 15:03:14 UTC (rev 222)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java 2010-11-17 17:36:33 UTC (rev 223)
@@ -319,7 +319,7 @@
@Override
public List<ValidationError> doInBackground() {
- List<ValidationError> validationErrors = validationService.validateData(project.getControl(), progressBar);
+ List<ValidationError> validationErrors = validationService.validateData(project, project.getControl(), progressBar);
return validationErrors;
}
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 2010-11-17 15:03:14 UTC (rev 222)
+++ trunk/coser-ui/src/main/resources/i18n/coser-ui-en_GB.properties 2010-11-17 17:36:33 UTC (rev 223)
@@ -17,9 +17,6 @@
coser.ui.common.valid=Valid
coser.ui.config.title=Configuration
coser.ui.control.categorylabel=
-coser.ui.control.check.containsError=
-coser.ui.control.check.containsUncheckedWarning=
-coser.ui.control.check.title=
coser.ui.control.comment=
coser.ui.control.confirmDeletionMessage=Are you sure you want to delete this data ?
coser.ui.control.confirmDeletionTitle=Confirm delete
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 2010-11-17 15:03:14 UTC (rev 222)
+++ trunk/coser-ui/src/main/resources/i18n/coser-ui-fr_FR.properties 2010-11-17 17:36:33 UTC (rev 223)
@@ -17,9 +17,6 @@
coser.ui.common.valid=Valider
coser.ui.config.title=Configuration
coser.ui.control.categorylabel=Donn\u00E9es affich\u00E9es \:
-coser.ui.control.check.containsError=Les donn\u00E9es contiennent encore des erreurs non corrig\u00E9es\npouvant fausser la cr\u00E9ation de la s\u00E9lection.\nVoulez vous poursuivre la cr\u00E9ation de la s\u00E9lection ?
-coser.ui.control.check.containsUncheckedWarning=Les donn\u00E9es contiennent encore %d avertissements non coch\uFFFDs pouvant fausser la cr\u00E9ation de la selection.\nVoulez vous poursuivre la cr\u00E9ation de la s\u00E9lection ?
-coser.ui.control.check.title=V\u00E9rification des erreurs
coser.ui.control.comment=Commentaire \:
coser.ui.control.confirmDeletionMessage=\u00CAtes vous s\u00FBr de vouloir supprimer cette donn\u00E9e ?
coser.ui.control.confirmDeletionTitle=Confirmation de suppression
1
0
r222 - in trunk: coser-business/src/main/java/fr/ifremer/coser/control coser-business/src/main/java/fr/ifremer/coser/services coser-business/src/main/resources/fr/ifremer/coser/data 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/resources/i18n
by chatellier@users.labs.libre-entreprise.org 17 Nov '10
by chatellier@users.labs.libre-entreprise.org 17 Nov '10
17 Nov '10
Author: chatellier
Date: 2010-11-17 15:03:14 +0000 (Wed, 17 Nov 2010)
New Revision: 222
Log:
Validation de toutes les categories en meme tps.
Presentation des erreurs par categories.
Modified:
trunk/coser-business/src/main/java/fr/ifremer/coser/control/ValidationError.java
trunk/coser-business/src/main/java/fr/ifremer/coser/services/ValidationService.java
trunk/coser-business/src/main/resources/fr/ifremer/coser/data/Catch-error-validation.xml
trunk/coser-business/src/main/resources/fr/ifremer/coser/data/Haul-fatal-validation.xml
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/ValidationServiceTest.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/ControlValidationRenderer.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/GlobalValidationGroup.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/GlobalValidationModel.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
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/control/ValidationError.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/control/ValidationError.java 2010-11-17 15:00:58 UTC (rev 221)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/control/ValidationError.java 2010-11-17 15:03:14 UTC (rev 222)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2010 Codelutin, Chatellier Eric
+ * Copyright (C) 2010 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
@@ -27,6 +27,7 @@
import java.io.Serializable;
+import fr.ifremer.coser.CoserConstants.Category;
import fr.ifremer.coser.CoserConstants.ValidationLevel;
/**
@@ -45,6 +46,9 @@
/** serialVersionUID. */
private static final long serialVersionUID = -1806823191454701123L;
+ /** Category de l'erreur. */
+ protected Category category;
+
/** Niveau de l'erreur (fatal, error, warning, info). */
protected ValidationLevel level;
@@ -66,6 +70,26 @@
}
/**
+ * Category de l'erreur.
+ *
+ * Peut etre null si l'erreur n'est pas associées à une category en particulier.
+ *
+ * @return category de l'erreur
+ */
+ public Category getCategory() {
+ return category;
+ }
+
+ /**
+ * Category de l'erreur.
+ *
+ * @param category category de l'erreur
+ */
+ public void setCategory(Category category) {
+ this.category = category;
+ }
+
+ /**
* Niveau de l'erreur (fatal, error, warning, info).
*
* @return level
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/ValidationService.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/services/ValidationService.java 2010-11-17 15:00:58 UTC (rev 221)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ValidationService.java 2010-11-17 15:03:14 UTC (rev 222)
@@ -120,9 +120,10 @@
* Valide un seul bean, retourne la liste des erreurs trouvées.
*
* @param bean bean to validate
+ * @param category result errors category
* @return
*/
- protected List<ValidationError> validate(AbstractDataEntity bean) {
+ protected List<ValidationError> validate(AbstractDataEntity bean, Category category) {
List<ValidationError> result = new ArrayList<ValidationError>();;
try {
// obligatoire pour les appel dans les thread et swing EDT
@@ -138,6 +139,7 @@
for (List<String> errors : fieldErrors.values()) {
ValidationError error = new ValidationError();
+ error.setCategory(category);
String messages = StringUtils.join(errors, ", ");
error.setMessage(messages);
error.setLevel(validationLevel);
@@ -151,6 +153,7 @@
Collection<String> actionMessages = validationContext.getActionErrors();
if (CollectionUtils.isNotEmpty(actionMessages)) {
ValidationError error = new ValidationError();
+ error.setCategory(category);
String messages = StringUtils.join(actionMessages, ", ");
error.setMessage(messages);
error.setLevel(validationLevel);
@@ -182,6 +185,52 @@
}
/**
+ * Valide toutes les données du projet.
+ *
+ * @param control control a valider
+ * @param progress progress monitor
+ * @return les erreurs de validation
+ */
+ public List<ValidationError> validateData(Control control, ProgressMonitor progress) {
+
+ // compte le nombre de category a valider
+ int categoryCount = 0;
+ for (Category category : Category.values()) {
+ if (category.isDataCategory()) {
+ categoryCount++;
+ }
+ }
+
+ // valide chaque category
+ int categoryIndex = 0;
+ List<ValidationError> validationErrors = new ArrayList<ValidationError>();
+ for (Category category : Category.values()) {
+ if (category.isDataCategory()) {
+ // validation de la category seule (generique)
+ List<ValidationError> categoryErrors = validateCategoryXWork(control, category, progress);
+ if (categoryErrors != null) {
+ validationErrors.addAll(categoryErrors);
+ }
+ // validation specifique de la category
+ List<ValidationError> specificErrors = validateCategorySpecific(control, category, progress);
+ if (specificErrors != null) {
+ categoryErrors.addAll(specificErrors);
+ }
+ }
+ }
+
+ // cas particulier, s'il n'y a aucune erreur, on ajout une erreur de
+ // type info pour dire qu'il n'y a pas d'erreur
+ if (validationErrors.isEmpty()) {
+ ValidationError noErrorError = new ValidationError();
+ noErrorError.setLevel(ValidationLevel.INFO);
+ noErrorError.setMessage(_("coser.business.control.noerrorfound"));
+ validationErrors.add(noErrorError);
+ }
+ return validationErrors;
+ }
+
+ /**
* Valide une category entière d'un project.
*
* @param control control a valider
@@ -190,6 +239,7 @@
* @return les erreurs de validation
*/
public List<ValidationError> validateCategory(Control control, Category category, ProgressMonitor progress) {
+
// validation de la category seule (generique)
List<ValidationError> errors = validateCategoryXWork(control, category, progress);
// validation specifique de la category
@@ -198,14 +248,6 @@
errors.addAll(specificErrors);
}
- // cas particulier, s'il n'y a aucune erreur, on ajout une erreur de
- // type info pour dire qu'il n'y a pas d'erreur
- if (errors.isEmpty()) {
- ValidationError noErrorError = new ValidationError();
- noErrorError.setLevel(ValidationLevel.INFO);
- noErrorError.setMessage(_("coser.business.control.noerrorfound"));
- errors.add(noErrorError);
- }
return errors;
}
@@ -245,7 +287,7 @@
// update progress
int total = dataToCheck.size() - 1;
if (progress != null) {
- progress.setText(_("coser.business.control.step.xworks", 0));
+ progress.setText(_("coser.business.control.step.xworks", _(category.getTranslationKey()), 0));
progress.setTotal(total);
}
@@ -270,19 +312,19 @@
switch (category) {
case CATCH:
beanCatch.setData(line);
- errors = validate(beanCatch);
+ errors = validate(beanCatch, category);
break;
case HAUL:
beanHaul.setData(line);
- errors = validate(beanHaul);
+ errors = validate(beanHaul, category);
break;
case LENGTH:
beanLength.setData(line);
- errors = validate(beanLength);
+ errors = validate(beanLength, category);
break;
case STRATA:
beanStrata.setData(line);
- errors = validate(beanStrata);
+ errors = validate(beanStrata, category);
break;
}
if (errors != null) {
@@ -293,6 +335,7 @@
String uniqueDataKey = getSignificantData(category, line);
if (uniqueDataKeys.contains(uniqueDataKey)) {
ValidationError error = new ValidationError();
+ error.setCategory(category);
error.setLevel(ValidationLevel.ERROR);
error.setLineNumber(line[AbstractDataEntity.INDEX_LINE]);
error.setMessage(_("coser.business.control.error.duplicatedLine"));
@@ -477,6 +520,7 @@
String lineNumber = firstLineForKey.get(key);
ValidationError error = new ValidationError();
+ error.setCategory(Category.CATCH);
error.setLevel(ValidationLevel.WARNING);
error.setLineNumber(lineNumber);
error.setMessage(_("coser.business.control.error.minObservationCount"));
@@ -569,6 +613,7 @@
String lineNumber = firstLineForKey.get(key);
ValidationError error = new ValidationError();
+ error.setCategory(Category.LENGTH);
error.setLevel(ValidationLevel.WARNING);
error.setLineNumber(lineNumber);
error.setMessage(_("coser.business.control.error.minObservationCount", key, value));
Modified: trunk/coser-business/src/main/resources/fr/ifremer/coser/data/Catch-error-validation.xml
===================================================================
--- trunk/coser-business/src/main/resources/fr/ifremer/coser/data/Catch-error-validation.xml 2010-11-17 15:00:58 UTC (rev 221)
+++ trunk/coser-business/src/main/resources/fr/ifremer/coser/data/Catch-error-validation.xml 2010-11-17 15:03:14 UTC (rev 222)
@@ -64,6 +64,6 @@
</field>
<validator type="coserExpression">
<param name="expression"><![CDATA[ (weight > 0 && number > 0) || weight == 0]]></param>
- <message><![CDATA[coser.business.control.error.noCatchNumberWithWeight]]></message>
+ <message>coser.business.control.error.noCatchNumberWithWeight</message>
</validator>
</validators>
\ No newline at end of file
Modified: trunk/coser-business/src/main/resources/fr/ifremer/coser/data/Haul-fatal-validation.xml
===================================================================
--- trunk/coser-business/src/main/resources/fr/ifremer/coser/data/Haul-fatal-validation.xml 2010-11-17 15:00:58 UTC (rev 221)
+++ trunk/coser-business/src/main/resources/fr/ifremer/coser/data/Haul-fatal-validation.xml 2010-11-17 15:03:14 UTC (rev 222)
@@ -29,19 +29,19 @@
<field name="sweptSurface">
<field-validator type="regex">
<param name="expression">\-?[0-9]+\.[0-9]{3,}</param>
- <message>lat must contains at least 5 decimal</message>
+ <message>lat must contains at least 3 decimal</message>
</field-validator>
</field>
<field name="lat">
<field-validator type="regex">
<param name="expression">\-?[0-9]+\.[0-9]{3,}</param>
- <message>lat must contains at least 5 decimal</message>
+ <message>lat must contains at least 3 decimal</message>
</field-validator>
</field>
<field name="long">
<field-validator type="regex">
<param name="expression">\-?[0-9]+\.[0-9]{3,}</param>
- <message>long must contains at least 5 decimal</message>
+ <message>long must contains at least 3 decimal</message>
</field-validator>
</field>
</validators>
\ No newline at end of file
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 2010-11-17 15:00:58 UTC (rev 221)
+++ trunk/coser-business/src/main/resources/i18n/coser-business-en_GB.properties 2010-11-17 15:03:14 UTC (rev 222)
@@ -37,6 +37,7 @@
coser.business.control.error.duplicatedLine=
coser.business.control.error.minObservationCount=
coser.business.control.error.minObservationCountDetail=
+coser.business.control.error.noCatchNumberWithWeight=
coser.business.control.noerrorfound=No error found
coser.business.control.step.observation=
coser.business.control.step.xworks=
@@ -50,10 +51,10 @@
coser.config.reference.typeEspeces.description=
coser.config.validator.directory.description=
lat\ attribute\ is\ not\ a\ valid\ double=
-lat\ must\ contains\ at\ least\ 5\ decimal=
+lat\ must\ contains\ at\ least\ 3\ decimal=
length\ attribute\ is\ not\ a\ valid\ double=
long\ attribute\ is\ not\ a\ valid\ double=
-long\ must\ contains\ at\ least\ 5\ decimal=
+long\ must\ contains\ at\ least\ 3\ decimal=
number\ attribute\ is\ not\ a\ valid\ double=
sweptSurface\ attribute\ is\ not\ a\ valid\ double=
year\ is\ not\ valid=
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 2010-11-17 15:00:58 UTC (rev 221)
+++ trunk/coser-business/src/main/resources/i18n/coser-business-fr_FR.properties 2010-11-17 15:03:14 UTC (rev 222)
@@ -37,6 +37,7 @@
coser.business.control.error.duplicatedLine=Ligne en doublon
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.noCatchNumberWithWeight=Poids sp\u00E9cifi\u00E9 sans captures
coser.business.control.noerrorfound=Aucune erreur d\u00E9tect\u00E9e
coser.business.control.step.observation=V\u00E9rification du nombre d'observation (%d%%)
coser.business.control.step.xworks=Validation par lignes (%d%%)
@@ -50,10 +51,10 @@
coser.config.reference.typeEspeces.description=Emplacement du fichier de code type des esp\u00E8ces
coser.config.validator.directory.description=Emplacement des fichiers de validations
lat\ attribute\ is\ not\ a\ valid\ double=
-lat\ must\ contains\ at\ least\ 5\ decimal=
+lat\ must\ contains\ at\ least\ 3\ decimal=
length\ attribute\ is\ not\ a\ valid\ double=
long\ attribute\ is\ not\ a\ valid\ double=
-long\ must\ contains\ at\ least\ 5\ decimal=
+long\ must\ contains\ at\ least\ 3\ decimal=
number\ attribute\ is\ not\ a\ valid\ double=
sweptSurface\ attribute\ is\ not\ a\ valid\ double=
year\ is\ not\ valid=
Modified: trunk/coser-business/src/test/java/fr/ifremer/coser/services/ValidationServiceTest.java
===================================================================
--- trunk/coser-business/src/test/java/fr/ifremer/coser/services/ValidationServiceTest.java 2010-11-17 15:00:58 UTC (rev 221)
+++ trunk/coser-business/src/test/java/fr/ifremer/coser/services/ValidationServiceTest.java 2010-11-17 15:03:14 UTC (rev 222)
@@ -64,12 +64,12 @@
Catch myCatch = new Catch();
myCatch.setData(new String[]{"1", "","","","","",""});
- List<ValidationError> errors = validationService.validate(myCatch);
+ List<ValidationError> errors = validationService.validate(myCatch, Category.CATCH);
Assert.assertNotNull(errors);
Assert.assertEquals(3, errors.size());
myCatch.setData(new String[]{"1", "Toto","","","","999",""});
- errors = validationService.validate(myCatch);
+ errors = validationService.validate(myCatch, Category.CATCH);
Assert.assertNotNull(errors);
Assert.assertEquals(2, errors.size());
}
@@ -81,7 +81,7 @@
public void testDoubleValidation() {
Catch myCatch = new Catch();
myCatch.setData(new String[]{"1", "Test survey","1999","Test trait","Test sp","NA","12"});
- List<ValidationError> errors = validationService.validate(myCatch);
+ List<ValidationError> errors = validationService.validate(myCatch, Category.CATCH);
log.warn(errors);
Assert.assertTrue(errors.isEmpty());
}
@@ -93,11 +93,11 @@
public void test5DecimalValidation() {
Haul haulBean = new Haul();
haulBean.setData(new String[]{"1", "COSER_TEST","2010","TRAIT3","10","STR3","0.06","43.89","1.73","115.00"});
- List<ValidationError> errors = validationService.validate(haulBean);
+ List<ValidationError> errors = validationService.validate(haulBean, Category.HAUL);
Assert.assertEquals(3, errors.size());
haulBean.setData(new String[]{"1","COSER_TEST","2010","TRAIT3","10","STR3","0.06000","43.89000","1.73234","115.00"});
- errors = validationService.validate(haulBean);
+ errors = validationService.validate(haulBean, Category.HAUL);
Assert.assertTrue(errors.isEmpty());
}
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 2010-11-17 15:00:58 UTC (rev 221)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java 2010-11-17 15:03:14 UTC (rev 222)
@@ -309,7 +309,7 @@
public void checkData(final ControlView view) {
final ValidationService validationService = view.getContextValue(ValidationService.class);
final Project project = view.getContextValue(Project.class);
- final Category category = (Category)view.getCategoryComboBox().getSelectedItem();
+ //final Category category = (Category)view.getCategoryComboBox().getSelectedItem();
final ControlProgressBar progressBar = view.getCheckProgressBar();
SwingWorker<List<ValidationError>, Void> task = new SwingWorker<List<ValidationError>, Void>() {
@@ -319,7 +319,7 @@
@Override
public List<ValidationError> doInBackground() {
- List<ValidationError> validationErrors = validationService.validateCategory(project.getControl(), category, progressBar);
+ List<ValidationError> validationErrors = validationService.validateData(project.getControl(), progressBar);
return validationErrors;
}
@@ -430,8 +430,13 @@
// 2 = validation group (middle level)
// 3 = validation error (last level)
- if (pathWay.length == 3) {
- ValidationError error = (ValidationError)pathWay[2];
+ if (pathWay.length == 4 && pathWay[1] instanceof Category) {
+ Category category = (Category)pathWay[1];
+
+ // swap category
+ view.getCategoryComboBoxModel().setSelectedItem(category);
+
+ ValidationError error = (ValidationError)pathWay[3];
String errorLineNumber = error.getLineNumber();
// peut être null, si l'erreur ne porte pas sur un bean en particulier
if (errorLineNumber != null) {
@@ -465,30 +470,37 @@
Object[] pathWay = selectedError.getPath();
// 2 = validation group (middle level)
- if (pathWay.length == 2) {
- final GlobalValidationGroup validationGroup = (GlobalValidationGroup)pathWay[1];
- JPopupMenu popupMenu = new JPopupMenu(_("coser.ui.control.globalErrorMenuLabel"));
- JMenuItem replaceMenu = new JMenuItem(_("coser.ui.control.globalErrorMenuSelectAll"));
- replaceMenu.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- selectAllErrorGroupLines(controlView, validationGroup);
- }
- });
- popupMenu.add(replaceMenu);
- popupMenu.show(controlView.getValidationGlobalErrorsTable(), event.getX(), event.getY());
+ if (pathWay.length == 3) {
+ if (pathWay[1] instanceof Category) {
+ final Category category = (Category)pathWay[1];
+ final GlobalValidationGroup validationGroup = (GlobalValidationGroup)pathWay[2];
+ JPopupMenu popupMenu = new JPopupMenu(_("coser.ui.control.globalErrorMenuLabel"));
+ JMenuItem replaceMenu = new JMenuItem(_("coser.ui.control.globalErrorMenuSelectAll"));
+ replaceMenu.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ selectAllErrorGroupLines(controlView, category, validationGroup);
+ }
+ });
+ popupMenu.add(replaceMenu);
+ popupMenu.show(controlView.getValidationGlobalErrorsTable(), event.getX(), event.getY());
+ }
}
}
}
}
/**
- * Selectionne toutes les lignes associés au erreur d'un group d'erreur.
+ * Selectionne toutes les lignes associés au erreur d'un groupe d'erreur.
*
* @param controlView controlView
* @param validationGroup validationGroup
*/
- protected void selectAllErrorGroupLines(ControlView controlView, GlobalValidationGroup validationGroup) {
+ protected void selectAllErrorGroupLines(ControlView controlView, Category category, GlobalValidationGroup validationGroup) {
+ // swap category
+ controlView.getCategoryComboBoxModel().setSelectedItem(category);
+
+ // select all lines
GlobalValidationModel model = controlView.getGlobalValidationModel();
controlView.getControlDataTableSelectionModel().clearSelection();
int childCount = model.getChildCount(validationGroup);
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlValidationRenderer.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlValidationRenderer.java 2010-11-17 15:00:58 UTC (rev 221)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlValidationRenderer.java 2010-11-17 15:03:14 UTC (rev 222)
@@ -33,6 +33,7 @@
import javax.swing.tree.DefaultTreeCellRenderer;
import jaxx.runtime.validator.swing.SwingValidatorUtil;
+import fr.ifremer.coser.CoserConstants.Category;
import fr.ifremer.coser.CoserConstants.ValidationLevel;
import fr.ifremer.coser.control.ValidationError;
@@ -73,7 +74,13 @@
ImageIcon icon = null;
String text = null;
- if (value instanceof GlobalValidationGroup) {
+ if (value instanceof String) {
+ text = _((String)value);
+ }
+ else if (value instanceof Category) {
+ text = _(((Category)value).getTranslationKey());
+ }
+ else if (value instanceof GlobalValidationGroup) {
GlobalValidationGroup validationErrorGroup = (GlobalValidationGroup)value;
ValidationLevel level = validationErrorGroup.getValidationLevel();
switch (level) {
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/GlobalValidationGroup.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/GlobalValidationGroup.java 2010-11-17 15:00:58 UTC (rev 221)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/GlobalValidationGroup.java 2010-11-17 15:03:14 UTC (rev 222)
@@ -23,6 +23,7 @@
package fr.ifremer.coser.ui.control;
+import fr.ifremer.coser.CoserConstants.Category;
import fr.ifremer.coser.CoserConstants.ValidationLevel;
/**
@@ -36,36 +37,36 @@
*/
public class GlobalValidationGroup implements Comparable<GlobalValidationGroup> {
- protected ValidationLevel validationLevel;
+ protected final Category category;
+
+ protected final ValidationLevel validationLevel;
- protected String message;
+ protected final String message;
/**
+ * @param category
* @param validationLevel
* @param message
*/
- public GlobalValidationGroup(ValidationLevel validationLevel, String message) {
+ public GlobalValidationGroup(Category category, ValidationLevel validationLevel, String message) {
super();
+ this.category = category;
this.validationLevel = validationLevel;
this.message = message;
}
+ public Category getCategory() {
+ return category;
+ }
+
public ValidationLevel getValidationLevel() {
return validationLevel;
}
- public void setValidationLevel(ValidationLevel validationLevel) {
- this.validationLevel = validationLevel;
- }
-
public String getMessage() {
return message;
}
- public void setMessage(String message) {
- this.message = message;
- }
-
/*
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
@@ -82,6 +83,7 @@
public int hashCode() {
final int prime = 31;
int result = 1;
+ result = prime * result + ((category == null) ? 0 : category.hashCode());
result = prime * result + ((message == null) ? 0 : message.hashCode());
result = prime * result + ((validationLevel == null) ? 0 : validationLevel.hashCode());
return result;
@@ -109,6 +111,9 @@
if (validationLevel != other.validationLevel) {
return false;
}
+ if (category != other.category) {
+ return false;
+ }
return true;
}
}
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/GlobalValidationModel.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/GlobalValidationModel.java 2010-11-17 15:00:58 UTC (rev 221)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/GlobalValidationModel.java 2010-11-17 15:03:14 UTC (rev 222)
@@ -24,17 +24,20 @@
package fr.ifremer.coser.ui.control;
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 java.util.SortedMap;
-import java.util.TreeMap;
import org.jdesktop.swingx.treetable.AbstractTreeTableModel;
+import fr.ifremer.coser.CoserConstants.Category;
import fr.ifremer.coser.CoserConstants.ValidationLevel;
import fr.ifremer.coser.control.ValidationError;
@@ -52,8 +55,9 @@
/** serialVersionUID. */
private static final long serialVersionUID = -32286733264427664L;
- protected List<GlobalValidationGroup> validationErrorsGroups;
- protected SortedMap<GlobalValidationGroup, List<ValidationError>> validationErrorsChilds;
+ protected List<Object> validationErrorCategory;
+ protected Map<Object, List<GlobalValidationGroup>> validationCategoryChild;
+ protected Map<GlobalValidationGroup, List<ValidationError>> validationErrorsChilds;
protected Set<Object> checkedValidationErrors;
public GlobalValidationModel() {
@@ -72,23 +76,53 @@
*/
protected void getValidationErrorAsMaps(List<ValidationError> validationErrors) {
- validationErrorsChilds = new TreeMap<GlobalValidationGroup, List<ValidationError>>();
-
+ validationCategoryChild = new HashMap<Object, List<GlobalValidationGroup>>();
+ validationErrorsChilds = new HashMap<GlobalValidationGroup, List<ValidationError>>();
+
for (ValidationError validationError : validationErrors) {
- GlobalValidationGroup group = new GlobalValidationGroup(validationError.getLevel(), validationError.getMessage());
+
+ Object category = validationError.getCategory() == null ?
+ n_("coser.ui.control.error.allCategories") : validationError.getCategory();
+ List<GlobalValidationGroup> errorGroup = validationCategoryChild.get(category);
+ if (errorGroup == null) {
+ errorGroup = new ArrayList<GlobalValidationGroup>();
+ validationCategoryChild.put(category, errorGroup);
+ }
+ GlobalValidationGroup group = new GlobalValidationGroup(validationError.getCategory(), validationError.getLevel(), validationError.getMessage());
+
List<ValidationError> childErrors = validationErrorsChilds.get(group);
if (childErrors == null) {
childErrors = new ArrayList<ValidationError>();
+ validationErrorsChilds.put(group, childErrors);
+ errorGroup.add(group);
}
childErrors.add(validationError);
- validationErrorsChilds.put(group, childErrors);
}
- validationErrorsGroups = new ArrayList<GlobalValidationGroup>(validationErrorsChilds.keySet());
- Collections.sort(validationErrorsGroups);
+ validationErrorCategory = new ArrayList<Object>(validationCategoryChild.keySet());
+ Collections.sort(validationErrorCategory, 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);
+ }
+ }
+ else if (o1 instanceof Category) {
+ if (o2 instanceof Category) {
+ result = ((Category)o1).compareTo((Category)o2);
+ }
+ }
+ return result;
+ }
+ });
+ for (List<GlobalValidationGroup> groups : validationCategoryChild.values()) {
+ Collections.sort(groups);
+ }
checkedValidationErrors = new HashSet<Object>();
}
@@ -161,8 +195,11 @@
Object result = null;
if (parent == getRoot()) {
- result = validationErrorsGroups.get(index);
+ result = validationErrorCategory.get(index);
}
+ else if (parent instanceof String || parent instanceof Category) {
+ result = validationCategoryChild.get(parent).get(index);
+ }
else if (parent instanceof GlobalValidationGroup) {
List<ValidationError> childError = validationErrorsChilds.get(parent);
result = childError.get(index);
@@ -179,10 +216,13 @@
int result = 0;
if (parent == getRoot()) {
- if (validationErrorsGroups != null) {
- result = validationErrorsGroups.size();
+ if (validationErrorCategory != null) {
+ result = validationErrorCategory.size();
}
}
+ else if (parent instanceof String || parent instanceof Category) {
+ result = validationCategoryChild.get(parent).size();
+ }
else if (parent instanceof GlobalValidationGroup) {
List<ValidationError> childError = validationErrorsChilds.get(parent);
result = childError.size();
@@ -199,8 +239,11 @@
int result = -1;
if (parent == getRoot()) {
- result = validationErrorsGroups.indexOf(child);
+ result = validationErrorCategory.indexOf(child);
}
+ else if (parent instanceof String || parent instanceof Category) {
+ result = validationCategoryChild.get(parent).indexOf(child);
+ }
else if (parent instanceof GlobalValidationGroup) {
List<ValidationError> childError = validationErrorsChilds.get(parent);
result = childError.indexOf(child);
@@ -230,7 +273,7 @@
}
// recursive check of sub errors
- if (node instanceof GlobalValidationGroup) {
+ if (node instanceof String || node instanceof GlobalValidationGroup) {
int childCount = getChildCount(node);
for (int i = 0 ; i < childCount; ++i) {
Object child = getChild(node, i);
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 2010-11-17 15:00:58 UTC (rev 221)
+++ trunk/coser-ui/src/main/resources/i18n/coser-ui-en_GB.properties 2010-11-17 15:03:14 UTC (rev 222)
@@ -29,6 +29,7 @@
coser.ui.control.dataMenuReplace=Replace in %s for selection
coser.ui.control.dataMenuReplaceAll=Replace in %s in all data
coser.ui.control.deleteLine=Delete line
+coser.ui.control.error.allCategories=
coser.ui.control.global.done=\u2026
coser.ui.control.global.message=Message
coser.ui.control.globalErrorMenuLabel=Error menu
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 2010-11-17 15:00:58 UTC (rev 221)
+++ trunk/coser-ui/src/main/resources/i18n/coser-ui-fr_FR.properties 2010-11-17 15:03:14 UTC (rev 222)
@@ -29,6 +29,7 @@
coser.ui.control.dataMenuReplace=Remplacer dans %s pour la s\u00E9lection
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\u00E9gories
coser.ui.control.global.done=\u2026
coser.ui.control.global.message=Message
coser.ui.control.globalErrorMenuLabel=Menu des erreurs
1
0
r221 - trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control
by chatellier@users.labs.libre-entreprise.org 17 Nov '10
by chatellier@users.labs.libre-entreprise.org 17 Nov '10
17 Nov '10
Author: chatellier
Date: 2010-11-17 15:00:58 +0000 (Wed, 17 Nov 2010)
New Revision: 221
Log:
Extends defaultcomboboxmodel (fire works better)
Modified:
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlCategoryListModel.java
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlCategoryListModel.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlCategoryListModel.java 2010-11-17 12:13:13 UTC (rev 220)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlCategoryListModel.java 2010-11-17 15:00:58 UTC (rev 221)
@@ -28,8 +28,7 @@
import java.util.ArrayList;
import java.util.List;
-import javax.swing.AbstractListModel;
-import javax.swing.ComboBoxModel;
+import javax.swing.DefaultComboBoxModel;
import fr.ifremer.coser.CoserConstants.Category;
@@ -42,15 +41,13 @@
* Last update : $Date$
* By : $Author$
*/
-public class ControlCategoryListModel extends AbstractListModel implements ComboBoxModel {
+public class ControlCategoryListModel extends DefaultComboBoxModel {
/** serialVersionUID. */
private static final long serialVersionUID = 6700971928409164642L;
protected List<Category> categories;
- protected Object selectedItem;
-
public ControlCategoryListModel() {
categories = new ArrayList<Category>();
for (Category category : Category.values()) {
@@ -58,7 +55,7 @@
categories.add(category);
}
}
- selectedItem = categories.get(0);
+ setSelectedItem(categories.get(0));
}
/*
@@ -76,21 +73,4 @@
public Object getElementAt(int index) {
return categories.get(index);
}
-
- /*
- * @see javax.swing.ComboBoxModel#setSelectedItem(java.lang.Object)
- */
- @Override
- public void setSelectedItem(Object anItem) {
- this.selectedItem = anItem;
-
- }
-
- /*
- * @see javax.swing.ComboBoxModel#getSelectedItem()
- */
- @Override
- public Object getSelectedItem() {
- return selectedItem;
- }
}
1
0
r220 - in trunk: coser-business/src/main/java/fr/ifremer/coser/services coser-business/src/test/java/fr/ifremer/coser/services coser-ui/src/main/java/fr/ifremer/coser/ui/selection coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model
by chatellier@users.labs.libre-entreprise.org 17 Nov '10
by chatellier@users.labs.libre-entreprise.org 17 Nov '10
17 Nov '10
Author: chatellier
Date: 2010-11-17 12:13:13 +0000 (Wed, 17 Nov 2010)
New Revision: 220
Log:
Add density matrix and model display
Modified:
trunk/coser-business/src/main/java/fr/ifremer/coser/services/ChartService.java
trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java
trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/OccurrenceDensitySpecyListModel.java
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/ChartService.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/services/ChartService.java 2010-11-16 17:12:30 UTC (rev 219)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ChartService.java 2010-11-17 12:13:13 UTC (rev 220)
@@ -41,7 +41,6 @@
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.labels.CategoryToolTipGenerator;
-import org.jfree.chart.labels.StandardCategoryItemLabelGenerator;
import org.jfree.chart.labels.StandardCategoryToolTipGenerator;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PlotOrientation;
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 2010-11-16 17:12:30 UTC (rev 219)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java 2010-11-17 12:13:13 UTC (rev 220)
@@ -1589,9 +1589,9 @@
public MatrixND getDensity(Project project, Selection selection) {
// map species > "year, all density as double"
- Map<String, Map<String, Set<Double>>> densityPerSpeciesAndYear = new HashMap<String, Map<String, Set<Double>>>();
- Set<String> lineNames = new HashSet<String>();
- Set<String> columns = new HashSet<String>();
+ Map<String, Map<String, Map<String, Set<Double>>>> densityPerSpecyStrataYear = new HashMap<String, Map<String, Map<String, Set<Double>>>>();
+ Set<String> speciesList = new HashSet<String>();
+ Set<String> yearsList = new HashSet<String>();
// load map strataname > stratasurface
Map<String, Double> startaAndSurface = new HashMap<String, Double>();
@@ -1621,9 +1621,10 @@
itHaul.next(); // skip header
while (itHaul.hasNext()) {
String[] tuple = itHaul.next();
- String haulKey = tuple[Haul.INDEX_YEAR] + ";" + tuple[Haul.INDEX_HAUL];
+ String haul = tuple[Haul.INDEX_HAUL];
+ String haulKey = tuple[Haul.INDEX_YEAR] + ";" + haul;
String strataName = tuple[Haul.INDEX_STRATUM];
- haulAndStratas.put(haulKey, strataName);
+ haulAndStratas.put(haul, strataName);
String sweptSurfaceAsString = tuple[Haul.INDEX_SWEPT_SURFACE];
try {
@@ -1648,51 +1649,67 @@
while (itData.hasNext()) {
String[] tuple = itData.next();
+ String species = tuple[Catch.INDEX_SPECIES];
String year = tuple[Catch.INDEX_YEAR];
String haul = tuple[Catch.INDEX_HAUL];
- String species = tuple[Catch.INDEX_SPECIES];
String numberAsString = tuple[Catch.INDEX_NUMBER];
+ String strata = haulAndStratas.get(haul);
- lineNames.add(species);
- columns.add(year);
+ speciesList.add(species);
+ yearsList.add(year);
// compute density
+ // densparstrate=tapply(tab$Nombre/tab$SurfaceBalayee,list(tab$Espece, tab$Annee, tab$Strate), mean)
try {
Double number = Double.valueOf(numberAsString);
Double sweptSurface = haulAndSweptSurface.get(year + ";" + haul);
+ Double density = null;
if (sweptSurface == null) {
if (log.isWarnEnabled()) {
log.warn("Can't find swept surface for " + year + ";" + haul);
}
- continue;
+ density = 0.0;
}
- Double density = number / sweptSurface;
+ else {
+ density = number / sweptSurface;
+ }
// count for species and year
- Map<String, Set<Double>> specyDensityPerYear = densityPerSpeciesAndYear.get(species);
- if (specyDensityPerYear == null) {
- specyDensityPerYear = new HashMap<String, Set<Double>>();
+ Map<String, Map<String, Set<Double>>> specyDensityPerStrataYear = densityPerSpecyStrataYear.get(species);
+ if (specyDensityPerStrataYear == null) {
+ specyDensityPerStrataYear = new HashMap<String, Map<String, Set<Double>>>();
+ Map<String, Set<Double>> strataDensityPerYear = new HashMap<String, Set<Double>>();
Set<Double> densities = new HashSet<Double>();
densities.add(density);
- specyDensityPerYear.put(year, densities);
- densityPerSpeciesAndYear.put(species, specyDensityPerYear);
+ strataDensityPerYear.put(strata, densities);
+ specyDensityPerStrataYear.put(year, strataDensityPerYear);
+ densityPerSpecyStrataYear.put(species, specyDensityPerStrataYear);
}
else {
- Set<Double> specyYearDensity = specyDensityPerYear.get(year);
- if (specyYearDensity == null) {
+ Map<String, Set<Double>> strataDensityPerYear = specyDensityPerStrataYear.get(year);
+ if (strataDensityPerYear == null) {
+ strataDensityPerYear = new HashMap<String, Set<Double>>();
Set<Double> densities = new HashSet<Double>();
densities.add(density);
- specyDensityPerYear.put(year, densities);
+ strataDensityPerYear.put(strata, densities);
+ specyDensityPerStrataYear.put(year, strataDensityPerYear);
+ } else {
+ Set<Double> specyYearDensity = strataDensityPerYear.get(strata);
+ if (specyYearDensity == null) {
+ specyYearDensity = new HashSet<Double>();
+ specyYearDensity.add(density);
+ strataDensityPerYear.put(strata, specyYearDensity);
+ }
+ else {
+ specyYearDensity.add(density);
+ }
}
- else {
- specyYearDensity.add(density);
- }
}
// surfaceparstrate
- String strata = haulAndStratas.get(haul);
Double surface = startaAndSurface.get(strata);
- surfacesParStrates.put(year + ";" + species, surface);
+
+ surfacesParStrates.put(species + ";" + year + ";" + strata, surface);
}
catch (NumberFormatException ex) {
if (log.isWarnEnabled()) {
@@ -1702,30 +1719,44 @@
}
// convert to matrix
- List<String> lineNames2 = new ArrayList<String>(lineNames);
- Collections.sort(lineNames2);
- List<String> columnsNames2 = new ArrayList<String>(columns);
- Collections.sort(columnsNames2);
+ List<String> sortedSpecies = new ArrayList<String>(speciesList);
+ Collections.sort(sortedSpecies);
+ List<String> sortedYears = new ArrayList<String>(yearsList);
+ Collections.sort(sortedYears);
MatrixND matrix = MatrixFactory.getInstance().create("density", new List<?>[] {
- lineNames2 , columnsNames2});
+ sortedSpecies , sortedYears});
- for (Map.Entry<String, Map<String, Set<Double>>> dynMatrixEntry : densityPerSpeciesAndYear.entrySet()) {
- for (Map.Entry<String, Set<Double>> haulCountForYearEntry : dynMatrixEntry.getValue().entrySet()) {
-
- // mean density
- double totalDensity = 0;
- double densityCount = 0;
- for (Double singleDensity : haulCountForYearEntry.getValue()) {
- totalDensity += singleDensity;
- densityCount++;
+ for (Map.Entry<String, Map<String, Map<String, Set<Double>>>> dynMatrixEntry : densityPerSpecyStrataYear.entrySet()) {
+ String specy = dynMatrixEntry.getKey();
+ for (Map.Entry<String, Map<String, Set<Double>>> haulCountForYearEntry : dynMatrixEntry.getValue().entrySet()) {
+ String year = haulCountForYearEntry.getKey();
+
+ // nombreparstrate= surfaceparstrate*densparstrate
+ // densiteparannee=apply(nombreparstrate,c(1,2),sum)/totsurface
+ double totalNombreparstrate = 0;
+ for (Map.Entry<String, Set<Double>> densityForYear : haulCountForYearEntry.getValue().entrySet()) {
+
+ // maen density
+ double totalDensity = 0;
+ double densityCount = 0;
+ for (Double singleDensity : densityForYear.getValue()) {
+ totalDensity += singleDensity;
+ densityCount++;
+ }
+ double meanDensity = totalDensity / densityCount;
+
+ String strata = densityForYear.getKey();
+ Double surfaceparstrate = surfacesParStrates.get(specy + ";" + year + ";" + strata);
+ if (surfaceparstrate == null) {
+ log.warn("no surface for " + specy + ";" + year + ";" + strata);
+ surfaceparstrate = 0.0;
+ }
+ double nombreparstrate = surfaceparstrate * meanDensity;
+ totalNombreparstrate += nombreparstrate;
}
- double meanDensity = totalDensity / densityCount;
-
- // surfaceparstrate
- //double surfaceparstrate = surfacesParStrates.get(haulCountForYearEntry.getKey() + ";" + dynMatrixEntry.getKey());
-
- //TODO echatellier 20101109 finir
- //matrix.setValue(dynMatrixEntry.getKey(), haulCountForYearEntry.getKey(), occurence);
+ double densiteparannee = totalNombreparstrate / totalSourface;
+
+ matrix.setValue(specy, year, densiteparannee);
}
}
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 2010-11-16 17:12:30 UTC (rev 219)
+++ trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java 2010-11-17 12:13:13 UTC (rev 220)
@@ -354,8 +354,6 @@
Assert.assertTrue(commands.get(3) instanceof DeleteLineCommand);
Assert.assertTrue(commands.get(4) instanceof ModifyFieldCommand);
Assert.assertTrue(commands.get(5) instanceof MergeSpeciesCommand);
-
-
}
/**
@@ -385,4 +383,18 @@
MatrixND matrix = projectService.getOccurrence(project, selection);
Assert.assertNotNull(matrix);
}
+
+ /**
+ * Test de la méthode densité.
+ *
+ * @throws CoserBusinessException
+ */
+ @Test
+ public void getDensity() throws CoserBusinessException {
+ Project project = createTestProject(projectService);
+ Selection selection = projectService.initProjectSelection(project);
+ selection.setName("test");
+ MatrixND matrix = projectService.getDensity(project, selection);
+ Assert.assertNotNull(matrix);
+ }
}
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 2010-11-16 17:12:30 UTC (rev 219)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java 2010-11-17 12:13:13 UTC (rev 220)
@@ -96,11 +96,12 @@
Project project = view.getContextValue(Project.class);
ProjectService projectService = view.getContextValue(ProjectService.class);
MatrixND occurrence = projectService.getOccurrence(project, selection);
- //MatrixND density = projectService.getDensity(project, selection);
+ MatrixND density = projectService.getDensity(project, selection);
//MatrixND samplingEffort = projectService.getSamplingEffort(project, selection);
// set matrix on list model
selectionListsView.getSelectionOccurrenceDensityListModel().setOccurrence(occurrence);
+ selectionListsView.getSelectionOccurrenceDensityListModel().setDensity(density);
// fill all specy data (at final)
selectionListsView.getSelectionAllSpeciesListModel().setSpecies(selectionSpecyList);
@@ -485,6 +486,5 @@
view.getMatrixPanelEditor().setMatrix(samplingEffort);
view.getMatrixPanelEditor().getTable().setDefaultRenderer(String.class,
new SamplingEffortRenderer((MatrixTableModelND)view.getMatrixPanelEditor().getTableModel()));
- //projectService.getOccurence(project, selection);
}
}
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/OccurrenceDensitySpecyListModel.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/OccurrenceDensitySpecyListModel.java 2010-11-16 17:12:30 UTC (rev 219)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/OccurrenceDensitySpecyListModel.java 2010-11-17 12:13:13 UTC (rev 220)
@@ -55,6 +55,8 @@
protected MatrixND occurrence = null;
+ protected MatrixND density = null;
+
public List<String> getSpecies() {
return species;
}
@@ -68,14 +70,20 @@
this.occurrence = occurrence;
}
+ public void setDensity(MatrixND density) {
+ this.density = density;
+ }
+
public double getOccurrence(String specy) {
List<String> years = (List<String>)occurrence.getSemantic(1);
double result = occurrence.getValue(specy, years.get(0));
return result;
}
-
+
public double getDensity(String specy) {
- return 6.0;
+ List<String> years = (List<String>)density.getSemantic(1);
+ double result = density.getValue(specy, years.get(0));
+ return result;
}
/*
1
0
r219 - trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection
by chatellier@users.labs.libre-entreprise.org 16 Nov '10
by chatellier@users.labs.libre-entreprise.org 16 Nov '10
16 Nov '10
Author: chatellier
Date: 2010-11-16 17:12:30 +0000 (Tue, 16 Nov 2010)
New Revision: 219
Log:
Ajout d'un renderer pour la matrice d'effort d'echantillonage
Added:
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SamplingEffortRenderer.java
Modified:
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java
Added: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SamplingEffortRenderer.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SamplingEffortRenderer.java (rev 0)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SamplingEffortRenderer.java 2010-11-16 17:12:30 UTC (rev 219)
@@ -0,0 +1,89 @@
+/*
+ * #%L
+ *
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 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.ui.selection;
+
+import java.awt.Color;
+import java.awt.Component;
+
+import javax.swing.JTable;
+
+import org.nuiton.math.matrix.gui.MatrixTableModelND;
+import org.nuiton.math.matrix.gui.MatrixTableModelND.MatrixCellRenderer;
+
+/**
+ * Renderer de nombre entier pour le panel matrix de sampling effort.
+ *
+ * Surligne en rouge les valeurs nulle.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class SamplingEffortRenderer extends MatrixCellRenderer {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = -5652185461372011347L;
+
+ /**
+ * @param model
+ */
+ public SamplingEffortRenderer(MatrixTableModelND model) {
+ super(model);
+ }
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value,
+ boolean isSelected, boolean hasFocus, int row, int column) {
+
+
+ Component comp = null;
+
+ if (value instanceof Double) {
+ Double number = (Double)value;
+ int intNumber = number.intValue();
+
+ comp = super.getTableCellRendererComponent(table, intNumber, isSelected, hasFocus,
+ row, column);
+
+ if (intNumber <= 0) {
+ comp.setBackground(Color.RED);
+ }
+ else {
+ comp.setBackground(null);
+ }
+ }
+ else {
+ comp = super.getTableCellRendererComponent(table, value, isSelected, hasFocus,
+ row, column);
+ }
+
+ return comp;
+ }
+
+
+}
Property changes on: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SamplingEffortRenderer.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
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 2010-11-16 15:35:47 UTC (rev 218)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java 2010-11-16 17:12:30 UTC (rev 219)
@@ -43,6 +43,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.math.matrix.MatrixND;
+import org.nuiton.math.matrix.gui.MatrixTableModelND;
import fr.ifremer.coser.CoserBusinessException;
import fr.ifremer.coser.CoserException;
@@ -472,7 +473,9 @@
}
/**
+ * Show sampling effort data.
*
+ * @param view view
*/
public void showSamplingEffort(SelectionDetailsView view) {
Project project = view.getContextValue(Project.class);
@@ -480,7 +483,8 @@
ProjectService projectService = view.getContextValue(ProjectService.class);
MatrixND samplingEffort = projectService.getSamplingEffort(project, selection);
view.getMatrixPanelEditor().setMatrix(samplingEffort);
-
+ view.getMatrixPanelEditor().getTable().setDefaultRenderer(String.class,
+ new SamplingEffortRenderer((MatrixTableModelND)view.getMatrixPanelEditor().getTableModel()));
//projectService.getOccurence(project, selection);
}
}
1
0
r218 - trunk/coser-business/src/test/java/fr/ifremer/coser/services
by chatellier@users.labs.libre-entreprise.org 16 Nov '10
by chatellier@users.labs.libre-entreprise.org 16 Nov '10
16 Nov '10
Author: chatellier
Date: 2010-11-16 15:35:47 +0000 (Tue, 16 Nov 2010)
New Revision: 218
Log:
Unused import
Modified:
trunk/coser-business/src/test/java/fr/ifremer/coser/services/CoserTestAbstract.java
Modified: trunk/coser-business/src/test/java/fr/ifremer/coser/services/CoserTestAbstract.java
===================================================================
--- trunk/coser-business/src/test/java/fr/ifremer/coser/services/CoserTestAbstract.java 2010-11-16 15:34:33 UTC (rev 217)
+++ trunk/coser-business/src/test/java/fr/ifremer/coser/services/CoserTestAbstract.java 2010-11-16 15:35:47 UTC (rev 218)
@@ -31,7 +31,6 @@
import java.util.Locale;
import java.util.Map;
-import org.apache.commons.io.FileUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.AfterClass;
1
0
r217 - trunk/coser-business/src/main/java/fr/ifremer/coser/services
by chatellier@users.labs.libre-entreprise.org 16 Nov '10
by chatellier@users.labs.libre-entreprise.org 16 Nov '10
16 Nov '10
Author: chatellier
Date: 2010-11-16 15:34:33 +0000 (Tue, 16 Nov 2010)
New Revision: 217
Log:
N'affiche pas les nombres sur le graphique
Modified:
trunk/coser-business/src/main/java/fr/ifremer/coser/services/ChartService.java
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/ChartService.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/services/ChartService.java 2010-11-16 15:25:11 UTC (rev 216)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ChartService.java 2010-11-16 15:34:33 UTC (rev 217)
@@ -171,10 +171,12 @@
valueAxis.setUpperMargin(0.1);
CategoryItemRenderer renderer = new LineAndShapeRenderer();
- StandardCategoryItemLabelGenerator itemLabelGenerator = new StandardCategoryItemLabelGenerator();
- renderer.setBaseItemLabelGenerator(itemLabelGenerator);
- renderer.setBaseItemLabelsVisible(true);
+ // n'affiche pas les nombre sur le graphique
+ //StandardCategoryItemLabelGenerator itemLabelGenerator = new StandardCategoryItemLabelGenerator();
+ //renderer.setBaseItemLabelGenerator(itemLabelGenerator);
+ //renderer.setBaseItemLabelsVisible(true);
+
CategoryToolTipGenerator cttg = new StandardCategoryToolTipGenerator("{0}: {2}", NumberFormat.getInstance());
renderer.setBaseToolTipGenerator(cttg);
1
0
r216 - in trunk: coser-business/src/main/java/fr/ifremer/coser/bean coser-ui/src/main/java/fr/ifremer/coser/ui coser-ui/src/main/java/fr/ifremer/coser/ui/control coser-ui/src/main/resources/i18n coser-ui/src/main/resources/icons
by chatellier@users.labs.libre-entreprise.org 16 Nov '10
by chatellier@users.labs.libre-entreprise.org 16 Nov '10
16 Nov '10
Author: chatellier
Date: 2010-11-16 15:25:11 +0000 (Tue, 16 Nov 2010)
New Revision: 216
Log:
Ajout d'une validation explicite du controle.
Added:
trunk/coser-ui/src/main/resources/icons/accept.png
Modified:
trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Control.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/SelectionsListMenuItem.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/ControlView.jaxx
trunk/coser-ui/src/main/resources/i18n/coser-ui-en_GB.properties
trunk/coser-ui/src/main/resources/i18n/coser-ui-fr_FR.properties
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Control.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Control.java 2010-11-16 09:32:24 UTC (rev 215)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Control.java 2010-11-16 15:25:11 UTC (rev 216)
@@ -41,8 +41,13 @@
/** serialVersionUID. */
private static final long serialVersionUID = 3693938021315541627L;
+ public static final String PROPERTY_VALIDATED = "validated";
+
protected String comment;
+ /** If control has been explicitly validated. */
+ protected boolean validated;
+
public String getComment() {
return comment;
}
@@ -53,11 +58,22 @@
getPropertyChangeSupport().firePropertyChange("comment", oldValue, comment);
}
+ public boolean isValidated() {
+ return validated;
+ }
+
+ public void setValidated(boolean validated) {
+ boolean oldValue = this.validated;
+ this.validated = validated;
+ getPropertyChangeSupport().firePropertyChange(PROPERTY_VALIDATED, oldValue, validated);
+ }
+
public Properties toProperties() {
Properties props = new Properties();
if (comment != null) {
props.setProperty("control.comment", comment);
}
+ props.setProperty("control.validated", String.valueOf(validated));
return props;
}
@@ -65,5 +81,8 @@
if (props.containsKey("control.comment")) {
setComment(props.getProperty("control.comment"));
}
+ if (props.containsKey("control.validated")) {
+ setValidated(Boolean.parseBoolean(props.getProperty("control.validated")));
+ }
}
}
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java 2010-11-16 09:32:24 UTC (rev 215)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java 2010-11-16 15:25:11 UTC (rev 216)
@@ -366,11 +366,6 @@
*/
public void showSelectionView() {
- // verifie que les données sont toutes validée d'abord
- if (!checkControlSession()) {
- return;
- }
-
// create new selection
ProjectService projectService = view.getContextValue(ProjectService.class);
Project project = view.getContextValue(Project.class);
@@ -404,31 +399,6 @@
}
/**
- * Cette methode vérifie que si une session de control est en cours on
- * verifie que la liste des erreurs ne contient pas d'erreur ou
- * de message warning non coché.
- *
- * @return {@code true} if user confirm selection creation even if there is some errors
- */
- protected boolean checkControlSession() {
-
- boolean result = true;
-
- // basé sur un hack, car ici, on ne sais pas ce que contient
- // le panel principal
- // attention, c'est du big hack ;)
- if (view.getMainViewContent().getComponentCount() > 0) {
- Component comp = view.getMainViewContent().getComponent(0);
- if (comp instanceof ControlView) {
- ControlView controlView = (ControlView)comp;
- result = controlView.getHandler().checkValidationModelErrors(controlView);
- }
- }
-
- return result;
- }
-
- /**
* Show selection view to open selection.
*
* @param selectionName selection name to open
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/SelectionsListMenuItem.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/SelectionsListMenuItem.java 2010-11-16 09:32:24 UTC (rev 215)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/SelectionsListMenuItem.java 2010-11-16 15:25:11 UTC (rev 216)
@@ -40,6 +40,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import fr.ifremer.coser.bean.Control;
import fr.ifremer.coser.bean.Project;
import fr.ifremer.coser.bean.Selection;
@@ -76,9 +77,11 @@
public void setProject(Project project) {
if (this.project != null) {
this.project.removePropertyChangeListener(Project.PROPERTY_SELECTIONS, this);
+ this.project.getControl().removePropertyChangeListener(Control.PROPERTY_VALIDATED, this);
}
this.project = project;
this.project.addPropertyChangeListener(Project.PROPERTY_SELECTIONS, this);
+ this.project.getControl().addPropertyChangeListener(Control.PROPERTY_VALIDATED, this);
updateMenuContent();
}
@@ -91,33 +94,41 @@
if (project != null) {
- Map<String, Selection> selections = project.getSelections();
-
- if (selections == null || selections.isEmpty()) {
- JMenuItem menuItem = new JMenuItem(_("coser.ui.mainframe.menu.data.noSelection"));
+ if (!project.getControl().isValidated()) {
+ JMenuItem menuItem = new JMenuItem(_("coser.ui.mainframe.menu.data.noValidation"));
menuItem.setFont(menuItem.getFont().deriveFont(Font.ITALIC));
menuItem.setEnabled(false);
add(menuItem);
}
else {
- for (String selectionName : selections.keySet()) {
- // new selection
- JMenuItem menuItem = new JMenuItem(selectionName);
- menuItem.setActionCommand(selectionName);
- menuItem.addActionListener(this);
+ Map<String, Selection> selections = project.getSelections();
+
+ if (selections == null || selections.isEmpty()) {
+ JMenuItem menuItem = new JMenuItem(_("coser.ui.mainframe.menu.data.noSelection"));
+ menuItem.setFont(menuItem.getFont().deriveFont(Font.ITALIC));
+ menuItem.setEnabled(false);
add(menuItem);
}
+ else {
+ for (String selectionName : selections.keySet()) {
+ // new selection
+ JMenuItem menuItem = new JMenuItem(selectionName);
+ menuItem.setActionCommand(selectionName);
+ menuItem.addActionListener(this);
+ add(menuItem);
+ }
+ }
+
+ // seperator
+ add(new JSeparator());
+
+ // new selection
+ JMenuItem menuItem = new JMenuItem(_("coser.ui.mainframe.menu.data.newSelection"));
+ menuItem.setActionCommand(""); // peut pas etre null, c'est nul !
+ menuItem.addActionListener(this);
+ add(menuItem);
}
-
- // seperator
- add(new JSeparator());
}
-
- // new selection
- JMenuItem menuItem = new JMenuItem(_("coser.ui.mainframe.menu.data.newSelection"));
- menuItem.setActionCommand(""); // peut pas etre null, c'est nul !
- menuItem.addActionListener(this);
- add(menuItem);
}
/*
@@ -141,6 +152,9 @@
*/
@Override
public void propertyChange(PropertyChangeEvent evt) {
+
+ // quand la liste de selection change
+ // ou la validation du controle
updateMenuContent();
}
}
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 2010-11-16 09:32:24 UTC (rev 215)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java 2010-11-16 15:25:11 UTC (rev 216)
@@ -68,7 +68,6 @@
import fr.ifremer.coser.CoserConstants.Category;
import fr.ifremer.coser.CoserConstants.ValidationLevel;
import fr.ifremer.coser.CoserException;
-import fr.ifremer.coser.bean.Control;
import fr.ifremer.coser.bean.Project;
import fr.ifremer.coser.control.ValidationError;
import fr.ifremer.coser.data.AbstractDataEntity;
@@ -193,6 +192,10 @@
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if (response == JOptionPane.YES_OPTION) {
+
+ // disableValidAction
+ disableValidAction(controlView);
+
Project project = controlView.getContextValue(Project.class);
ProjectService projectService = controlView.getContextValue(ProjectService.class);
Category category = (Category)controlView.getCategoryComboBox().getSelectedItem();
@@ -346,7 +349,7 @@
errorFound = true;
}
}
- view.getSaveButton().setEnabled(true);
+ view.setCanValidControl(!errorFound);
} catch (Exception ex) {
throw new CoserException("Can't validate data", ex);
}
@@ -687,64 +690,6 @@
}
/**
- * Verifie que le modele ne contient pas d'erreur (error/fatal) et
- * demande à l'utilisateur s'il confirme vouloir sauver lorsque des warning
- * ont été trouvé.
- *
- * La liste peut être vide, soit parce que le check global n'a pas été
- * lancé, soit parce qu'il n'y a réelement pas d'erreur.
- *
- * @param controlView view
- * @return {@code true} if should perform save
- */
- public boolean checkValidationModelErrors(ControlView controlView) {
- GlobalValidationModel model = controlView.getGlobalValidationModel();
- controlView.getControlDataTableSelectionModel().clearSelection();
-
- int errorFound = 0;
- int nonCheckedWarningFound = 0;
-
- int groupCount = model.getChildCount(model.getRoot());
- for (int indexGroup = 0 ; indexGroup < groupCount ; ++indexGroup) {
- Object group = model.getChild(model.getRoot(), indexGroup);
-
- int childCount = model.getChildCount(group);
- for (int indexChild = 0 ; indexChild < childCount ; ++indexChild) {
- ValidationError validationError = (ValidationError)model.getChild(group, indexChild);
- if (validationError.getLevel() == ValidationLevel.ERROR ||
- validationError.getLevel() == ValidationLevel.FATAL) {
- errorFound++;
- }
- else if (validationError.getLevel() == ValidationLevel.WARNING) {
-
- // on verifie que le warning est coché ou pas
- Boolean checked = (Boolean)model.getValueAt(validationError, 1);
- if (!checked) {
- nonCheckedWarningFound++;
- }
- }
- }
- }
-
- boolean perform = true;
- if (errorFound > 0) {
- int response = JOptionPane.showConfirmDialog(controlView, _("coser.ui.control.check.containsError"),
- _("coser.ui.control.check.title"), JOptionPane.ERROR_MESSAGE, JOptionPane.YES_NO_OPTION);
- if (response == JOptionPane.NO_OPTION) {
- perform = false;
- }
- }
- else if (nonCheckedWarningFound > 0) {
- int response = JOptionPane.showConfirmDialog(controlView, _("coser.ui.control.check.containsUncheckedWarning", nonCheckedWarningFound),
- _("coser.ui.control.check.title"), JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION);
- if (response == JOptionPane.NO_OPTION) {
- perform = false;
- }
- }
- return perform;
- }
-
- /**
* Display data graph, initialized with graph for first specy
* selected in specyComboModel.
*
@@ -796,6 +741,9 @@
*/
public void validDataModification(ControlView view) {
+ // disable valid button
+ disableValidAction(view);
+
Project project = view.getContextValue(Project.class);
JTable controlDataTable = view.getControlDataTable();
ControlDataTableModel model = (ControlDataTableModel)controlDataTable.getModel();
@@ -849,9 +797,12 @@
*/
public void deleteData(ControlView view) {
int response = JOptionPane.showConfirmDialog(view, _("coser.ui.control.confirmDeletionMessage"),
- _("coser.ui.control.confirmDeletionTitle"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
+ _("coser.ui.control.confirmDeletionTitle"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
if (response == JOptionPane.YES_OPTION) {
+ // disableValidAction
+ disableValidAction(view);
+
Project project = view.getContextValue(Project.class);
ProjectService projectService = view.getContextValue(ProjectService.class);
@@ -871,4 +822,26 @@
}
}
}
+
+ /**
+ * Desactive le bouton de validation du control. Positionne également
+ * le flag "validated" du control a false, pour cohérence, binding et
+ * en cas de sauvegarde par l'utilisateur.
+ */
+ protected void disableValidAction(ControlView view) {
+ Project project = view.getContextValue(Project.class);
+ project.getControl().setValidated(false);
+ view.setCanValidControl(false);
+ }
+
+ /**
+ * Set validated control flag to true and save control.
+ *
+ * @param view view
+ */
+ public void validControl(ControlView view) {
+ Project project = view.getContextValue(Project.class);
+ project.getControl().setValidated(true);
+ saveControl(view);
+ }
}
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 2010-11-16 09:32:24 UTC (rev 215)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlView.jaxx 2010-11-16 15:25:11 UTC (rev 216)
@@ -36,12 +36,12 @@
<ControlHandler id="handler" javaBean="null" />
<fr.ifremer.coser.bean.Control id="control" javaBean="null" />
+ <Boolean id="canValidControl" javaBean="false" />
<row>
<cell fill="horizontal" insets="0" anchor="west" columns="2">
<JToolBar floatable="false">
- <JButton id="saveButton" icon="disk.png"
- text="coser.ui.control.save" enabled="false"
+ <JButton icon="disk.png" text="coser.ui.control.save"
onActionPerformed="getHandler().saveControl(this)" />
<JToolBar.Separator />
<JLabel text="coser.ui.control.categorylabel" />
@@ -57,6 +57,10 @@
onActionPerformed="getHandler().displayCompareNumberCatchGraph(this)"/>
<JButton icon="chart_bar.png" text="coser.ui.graph.lengthStructure"
onActionPerformed="getHandler().displayLengthStructureGraph(this)"/>
+ <JToolBar.Separator />
+ <JButton icon="accept.png" onActionPerformed="getHandler().validControl(this)"
+ text="coser.ui.control.validcontrol" toolTipText="coser.ui.control.validcontroltip"
+ enabled="{isCanValidControl()}"/>
</JToolBar>
</cell>
</row>
@@ -142,8 +146,8 @@
<JScrollPane constraints="BorderLayout.CENTER">
<JTextArea id="controlComment" rows="3" text="{getControl().getComment()}" />
<javax.swing.text.Document javaBean="controlComment.getDocument()"
- onInsertUpdate='getControl().setComment(controlComment.getText()); saveButton.setEnabled(true)'
- onRemoveUpdate='getControl().setComment(controlComment.getText()); saveButton.setEnabled(true)' />
+ onInsertUpdate='getControl().setComment(controlComment.getText())'
+ onRemoveUpdate='getControl().setComment(controlComment.getText())' />
</JScrollPane>
</JPanel>
</JSplitPane>
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 2010-11-16 09:32:24 UTC (rev 215)
+++ trunk/coser-ui/src/main/resources/i18n/coser-ui-en_GB.properties 2010-11-16 15:25:11 UTC (rev 216)
@@ -46,6 +46,8 @@
coser.ui.control.replace.replace=Replace \:
coser.ui.control.replace.title=Find and replace
coser.ui.control.save=Save
+coser.ui.control.validcontrol=
+coser.ui.control.validcontroltip=
coser.ui.error.htmlmessage=An error occurs \: %s
coser.ui.error.title=Global application error
coser.ui.graph.compareNumberCatchSize=
@@ -55,6 +57,7 @@
coser.ui.mainframe.menu.data.control=Control
coser.ui.mainframe.menu.data.newSelection=New selection
coser.ui.mainframe.menu.data.noSelection=No selection
+coser.ui.mainframe.menu.data.noValidation=
coser.ui.mainframe.menu.data.selection=S\u00E9lection
coser.ui.mainframe.menu.file=File
coser.ui.mainframe.menu.locale.fr=Fran\u00E7ais
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 2010-11-16 09:32:24 UTC (rev 215)
+++ trunk/coser-ui/src/main/resources/i18n/coser-ui-fr_FR.properties 2010-11-16 15:25:11 UTC (rev 216)
@@ -46,6 +46,8 @@
coser.ui.control.replace.replace=Remplacer \:
coser.ui.control.replace.title=Chercher et remplacer
coser.ui.control.save=Sauvegarder
+coser.ui.control.validcontrol=Valider le contr\u00F4le
+coser.ui.control.validcontroltip=Marque le contr\u00F4le comme valid\u00E9. Ne peut \u00EAtre effectu\u00E9 qu'apr\u00E8s une v\u00E9rification des donn\u00E9es termin\u00E9e sans erreurs.
coser.ui.error.htmlmessage=Une erreur s'est produite \: %s
coser.ui.error.title=Erreur globale
coser.ui.graph.compareNumberCatchSize=Comparaison Captures/Tailles
@@ -55,7 +57,8 @@
coser.ui.mainframe.menu.data.control=Contr\u00F4le
coser.ui.mainframe.menu.data.newSelection=Nouvelle s\u00E9lection
coser.ui.mainframe.menu.data.noSelection=Aucune s\u00E9lection
-coser.ui.mainframe.menu.data.selection=S\u00E9lection
+coser.ui.mainframe.menu.data.noValidation=Contr\u00F4le non valid\u00E9
+coser.ui.mainframe.menu.data.selection=S\u00E9lections
coser.ui.mainframe.menu.file=Fichier
coser.ui.mainframe.menu.locale.fr=Fran\u00E7ais
coser.ui.mainframe.menu.locale.uk=English
Added: trunk/coser-ui/src/main/resources/icons/accept.png
===================================================================
(Binary files differ)
Property changes on: trunk/coser-ui/src/main/resources/icons/accept.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
1
0
r215 - in trunk/coser-business/src/main/java/fr/ifremer/coser: bean services
by chatellier@users.labs.libre-entreprise.org 16 Nov '10
by chatellier@users.labs.libre-entreprise.org 16 Nov '10
16 Nov '10
Author: chatellier
Date: 2010-11-16 09:32:24 +0000 (Tue, 16 Nov 2010)
New Revision: 215
Log:
Lecture des donn?\195?\169es du control ?\195?\160 l'ouverture du projet.
Lecture des commandes lors du chargement des donn?\195?\169es.
Modified:
trunk/coser-business/src/main/java/fr/ifremer/coser/bean/AbstractDataContainer.java
trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/bean/AbstractDataContainer.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/bean/AbstractDataContainer.java 2010-11-16 08:43:10 UTC (rev 214)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/bean/AbstractDataContainer.java 2010-11-16 09:32:24 UTC (rev 215)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2010 Codelutin, Chatellier Eric
+ * Copyright (C) 2010 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
@@ -79,6 +79,7 @@
deletedDataHaul = null;
dataLength = null;
deletedDataLength = null;
+ historyCommand = null;
}
public DataStorage getCatch() {
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 2010-11-16 08:43:10 UTC (rev 214)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java 2010-11-16 09:32:24 UTC (rev 215)
@@ -275,7 +275,31 @@
}
}
- // reload selection without data
+ // load control (without data and commands)
+ File controlDirectory = new File(projectDirectory, CoserConstants.STORAGE_CONTROL_DIRECTORY);
+ File controlPropertiesFile = new File(controlDirectory, "control.properties");
+ Control control = new Control();
+ if (controlPropertiesFile.exists()) { // si on a vraiment pas sauve le control ...
+ InputStream inputStream = null;
+ try {
+ Properties props = new Properties();
+ inputStream = new FileInputStream(controlPropertiesFile);
+ props.load(inputStream);
+ control.fromProperties(props);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Read control properties file : " + controlPropertiesFile);
+ }
+ } catch (IOException ex) {
+ throw new CoserBusinessException("Can't read control properties file", ex);
+ }
+ finally {
+ IOUtils.closeQuietly(inputStream);
+ }
+ }
+ project.setControl(control);
+
+ // reload selection (without data and commands)
Map<String, Selection> selections = new HashMap<String, Selection>();
File selectionsDirectory = new File(projectDirectory, CoserConstants.STORAGE_SELECTION_DIRECTORY);
if (selectionsDirectory.isDirectory()) {
@@ -286,19 +310,16 @@
selection.setName(selectionDirectory.getName());
// relecture des informations de la selection (properties)
- File propertiesFile = new File(selectionDirectory, "selection.properties");
+ File selectionPropertiesFile = new File(selectionDirectory, "selection.properties");
InputStream inputStream = null;
try {
Properties props = new Properties();
- inputStream = new FileInputStream(propertiesFile);
+ inputStream = new FileInputStream(selectionPropertiesFile);
props.load(inputStream);
selection.fromProperties(props);
-
- List<Command> commands = getHistoryCommandsFromProperties(props, "selection.commands");
- selection.setHistoryCommand(commands);
if (log.isDebugEnabled()) {
- log.debug("Read selection properties file : " + propertiesFile);
+ log.debug("Read selection properties file : " + selectionPropertiesFile);
}
} catch (IOException ex) {
throw new CoserBusinessException("Can't read selection properties file", ex);
@@ -311,20 +332,19 @@
}
}
}
-
project.setSelections(selections);
// relecture des informations du projet (properties)
- File propertiesFile = new File(projectDirectory, "project.properties");
+ File projectPropertiesFile = new File(projectDirectory, "project.properties");
InputStream inputStream = null;
try {
Properties props = new Properties();
- inputStream = new FileInputStream(propertiesFile);
+ inputStream = new FileInputStream(projectPropertiesFile);
props.load(inputStream);
project.fromProperties(props);
if (log.isDebugEnabled()) {
- log.debug("Read project properties file : " + propertiesFile);
+ log.debug("Read project properties file : " + projectPropertiesFile);
}
} catch (IOException ex) {
throw new CoserBusinessException("Can't read project properties file", ex);
@@ -351,7 +371,7 @@
// first free memory, clear all data
project.clearData();
- Control control = new Control();
+ Control control = project.getControl();
// try to load validated data first
File controlDirectory = new File(projectDirectory, CoserConstants.STORAGE_CONTROL_DIRECTORY);
@@ -418,21 +438,20 @@
}
}
- // relecture des informations du control (properties)
- File propertiesFile = new File(controlDirectory, "control.properties");
- if (propertiesFile.exists()) { // si on a vraiment pas sauve le control ...
+ // load control commands
+ File controlPropertiesFile = new File(controlDirectory, "control.properties");
+ if (controlPropertiesFile.exists()) { // si on a vraiment pas sauve le control ...
InputStream inputStream = null;
try {
Properties props = new Properties();
- inputStream = new FileInputStream(propertiesFile);
+ inputStream = new FileInputStream(controlPropertiesFile);
props.load(inputStream);
- control.fromProperties(props);
List<Command> commands = getHistoryCommandsFromProperties(props, "control.commands");
control.setHistoryCommand(commands);
if (log.isDebugEnabled()) {
- log.debug("Read control properties file : " + propertiesFile);
+ log.debug("Read control properties file : " + controlPropertiesFile);
}
} catch (IOException ex) {
throw new CoserBusinessException("Can't read control properties file", ex);
@@ -442,11 +461,10 @@
}
}
else {
+ // FIX future NPE
control.setHistoryCommand(new ArrayList<Command>());
}
-
- project.setControl(control);
-
+
return project;
}
@@ -488,7 +506,28 @@
}
}
}
+
+ // relecture des commandes de la selection (properties)
+ File selectionPropertiesFile = new File(selectionDirectory, "selection.properties");
+ InputStream inputStream = null;
+ try {
+ Properties props = new Properties();
+ inputStream = new FileInputStream(selectionPropertiesFile);
+ props.load(inputStream);
+
+ List<Command> commands = getHistoryCommandsFromProperties(props, "selection.commands");
+ selection.setHistoryCommand(commands);
+ if (log.isDebugEnabled()) {
+ log.debug("Read selection properties file : " + selectionPropertiesFile);
+ }
+ } catch (IOException ex) {
+ throw new CoserBusinessException("Can't read selection properties file", ex);
+ }
+ finally {
+ IOUtils.closeQuietly(inputStream);
+ }
+
return project;
}
1
0