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
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
participants (1)
-
chatellier@users.labs.libre-entreprise.org