|
From: <de...@us...> - 2009-10-24 01:02:29
|
Revision: 5449
http://fudaa.svn.sourceforge.net/fudaa/?rev=5449&view=rev
Author: deniger
Date: 2009-10-24 01:02:21 +0000 (Sat, 24 Oct 2009)
Log Message:
-----------
Modified Paths:
--------------
trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/common/DateDurationConverter.java
trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/io/AbstractCrue9FileFormat.java
trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/io/dao/CrueConverterDRSO.java
trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/io/neuf/DCFileReader.java
trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/io/neuf/DHReader.java
trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/io/neuf/DHWriter.java
trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/metier/emh/CatEMHBranche.java
trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/metier/emh/DefaultValues.java
trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/metier/emh/ParamCalcScenario.java
trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/metier/emh/ParamNumCalcTrans.java
trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/metier/emh/PdtCst.java
trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/metier/helper/FactoryEMH.java
trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/metier/helper/LoiFactory.java
trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/projet/ScenarioLoader.java
trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/projet/ScenarioLoaderCrue10.java
trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/validation/CruePrefix.java
trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/validation/ValidateEMHProperties.java
trunk/soft/fudaa-crue/dodico/src/main/resources/org/fudaa/dodico/crue/common/commonMessages.properties
trunk/soft/fudaa-crue/dodico/src/main/resources/org/fudaa/dodico/crue/io/ioMessages.properties
trunk/soft/fudaa-crue/dodico/src/test/java/org/fudaa/dodico/crue/io/TestCrueDC.java
trunk/soft/fudaa-crue/dodico/src/test/java/org/fudaa/dodico/crue/io/TestCrueDH.java
trunk/soft/fudaa-crue/dodico/src/test/java/org/fudaa/dodico/crue/validation/TestEMHPropertiesValidator.java
trunk/soft/fudaa-crue/dodico/src/test/java/org/fudaa/dodico/crue/validation/TestValidateModeleScenario.java
trunk/soft/fudaa-crue/fudaa/src/main/java/org/fudaa/fudaa/crue/projet/CrueProjet.java
Added Paths:
-----------
trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/validation/ValidateModeleScenarioWithSchema.java
trunk/soft/fudaa-crue/dodico/src/test/java/org/fudaa/dodico/crue/validation/TestCruePrefix.java
trunk/soft/fudaa-crue/dodico/src/test/resources/Etu3-2/
trunk/soft/fudaa-crue/dodico/src/test/resources/Etu3-2/M3-2_c9.dc
trunk/soft/fudaa-crue/dodico/src/test/resources/Etu3-2/M3-2_c9.dh
trunk/soft/fudaa-crue/dodico/src/test/resources/Etu4-0/
trunk/soft/fudaa-crue/dodico/src/test/resources/Etu4-0/M4-0_c9.dc
trunk/soft/fudaa-crue/dodico/src/test/resources/Etu4-0/M4-0_c9.dh
trunk/soft/fudaa-crue/dodico/src/test/resources/Etu4-0/M4-0_e1c9.dh
trunk/soft/fudaa-crue/dodico/src/test/resources/Etu4-0/M4-0_v1c9.dh
Removed Paths:
-------------
trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/validation/ValidateModeleScenario.java
Modified: trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/common/DateDurationConverter.java
===================================================================
--- trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/common/DateDurationConverter.java 2009-10-23 20:34:57 UTC (rev 5448)
+++ trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/common/DateDurationConverter.java 2009-10-24 01:02:21 UTC (rev 5449)
@@ -5,7 +5,6 @@
package org.fudaa.dodico.crue.common;
import org.apache.commons.lang.StringUtils;
-import org.fudaa.dodico.crue.metier.helper.LoiFactory;
import org.joda.time.Duration;
import org.joda.time.LocalDateTime;
import org.joda.time.MutablePeriod;
@@ -23,6 +22,11 @@
*/
public final class DateDurationConverter {
+ /**
+ * La date null
+ */
+ public final static LocalDateTime ZERO_DATE = new LocalDateTime(01, 01, 01, 0, 0, 0, 0);
+
private DateDurationConverter() {
// classe utilitaire
}
@@ -85,7 +89,7 @@
* @return la date en partant du zero de Crue.
*/
public static LocalDateTime getDateFromZeroDate(final Duration p) {
- return LoiFactory.ZERO_DATE.plus(p);
+ return DateDurationConverter.ZERO_DATE.plus(p);
}
/**
@@ -164,7 +168,7 @@
*/
public static String dateToCrueFormat(final LocalDateTime date) {
if (date == null) { return CRUE_ZERO; }
- return durationToCrueFormat(new Duration(LoiFactory.ZERO_DATE.toDateTime(), date.toDateTime()));
+ return durationToCrueFormat(new Duration(DateDurationConverter.ZERO_DATE.toDateTime(), date.toDateTime()));
}
Modified: trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/io/AbstractCrue9FileFormat.java
===================================================================
--- trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/io/AbstractCrue9FileFormat.java 2009-10-23 20:34:57 UTC (rev 5448)
+++ trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/io/AbstractCrue9FileFormat.java 2009-10-24 01:02:21 UTC (rev 5449)
@@ -102,6 +102,7 @@
final CrueIOResu<CrueData> source = (CrueIOResu<CrueData>) read.getSource();
analyzer.merge(read.getAnalyze());
analyzer.setDesc(IOMessages.getString("read.file", url.toString()));
+ source.setAnalyse(analyzer);
return source;
}
Modified: trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/io/dao/CrueConverterDRSO.java
===================================================================
--- trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/io/dao/CrueConverterDRSO.java 2009-10-23 20:34:57 UTC (rev 5448)
+++ trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/io/dao/CrueConverterDRSO.java 2009-10-24 01:02:21 UTC (rev 5449)
@@ -304,7 +304,7 @@
// -- on remplit les sections persistantes avec celle de la branche --//
if (branchePersist.Sections != null) {
- branche.setListeSections(remplirSectionsBrancheAvecPersistanceDRSO(branche, res, isSaintVenant,
+ branche.addListeSections(remplirSectionsBrancheAvecPersistanceDRSO(branche, res, isSaintVenant,
branchePersist.Sections, analyser));
}
Modified: trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/io/neuf/DCFileReader.java
===================================================================
--- trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/io/neuf/DCFileReader.java 2009-10-23 20:34:57 UTC (rev 5448)
+++ trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/io/neuf/DCFileReader.java 2009-10-24 01:02:21 UTC (rev 5449)
@@ -140,7 +140,7 @@
FactoryEMH.addSectionSansGeometrie(branche, xp, metier);
} else {
// -- on ajoute la liste des relations EMH à la branche --//
- branche.setListeSections(listeRelationEmh);
+ branche.addListeSections(listeRelationEmh);
if (!listeRelationEmh.isEmpty()) {
((RelationEMHSectionDansBranche) listeRelationEmh.get(0)).setPos(EnumPositionSection.AMONT);
}
@@ -261,62 +261,47 @@
public void completeSaintVenantWithDistMax(final EMHBrancheSaintVenant branche, final double distmax,
final CrueData data) {
- final List<RelationEMH> relationEMH = branche.getRelationEMH();
- for (int i = 0; i < relationEMH.size(); i++) {
-
- final RelationEMH relation1 = relationEMH.get(i);
-
+ final List<RelationEMHSectionDansBranche> sectionEMH = branche.getListeSections();
+ if (CollectionUtils.isEmpty(sectionEMH)) { return; }
+ branche.getRelationEMH().removeAll(sectionEMH);
+ // branche.getRelationEMH().add(relation2);
+ branche.getRelationEMH().add(sectionEMH.get(0));
+ for (int i = 0; i < sectionEMH.size() - 1; i++) {
+ final RelationEMHSectionDansBranche relation1 = sectionEMH.get(i);
// -- si la relation concerne les sections --//
- if (relation1.getEmh() instanceof CatEMHSection) {
- RelationEMH relation2 = null;
- // -- on recherche la prochaine relation --//
- for (int j = i + 1; j < relationEMH.size() && relation2 == null; j++) {
- if (relationEMH.get(j).getEmh() instanceof CatEMHSection) {
- relation2 = relationEMH.get(j);
- }
- }
+ final RelationEMHSectionDansBranche relation2 = sectionEMH.get(i + 1);
+ final double xpos1 = relation1.getXp();
+ final double xpos2 = relation2.getXp();
- if (relation2 == null) { return; }
+ double distance = Math.abs(xpos1 - xpos2);
+ if (distmax < distance) {
- final double xpos1 = EMHHelper.getXpSection(relation1);
- final double xpos2 = EMHHelper.getXpSection(relation2);
+ // -- il faut ajouter des profils interpolées --//
- double distance = Math.abs(xpos1 - xpos2);
- if (distmax < distance) {
+ // -- etape 1: on compte combien on en ajoute --//
+ final int nbProfilsToAdd = EMHHelper.getDistDiviseurForDistMax(distmax, distance);
- // -- il faut ajouter des profils interpolées --//
-
- // -- etape 1: on compte combien on en ajoute --//
- final int nbProfilsToAdd = EMHHelper.getDistDiviseurForDistMax(distmax, distance);
-
- // -- on creer une section interpolee pour chaque besoin et on l'ajoute dans cruedata puis dans les relations
- // branche --//.
- final double distMaxCorrige = distance / nbProfilsToAdd;
- // on commence a 1: c'est normal on cree un prol
- for (int k = 1; k < nbProfilsToAdd; k++) {
- final double xpos = xpos1 + (k) * distMaxCorrige;
- double doubleForNom = xpos;
- if (doubleForNom >= 1) {
- doubleForNom = Math.floor(doubleForNom);
- }
- final EMHSectionInterpolee interpol = FactoryEMH.createSectionInterpoleFromDistmax(doubleForNom, branche
- .getNom(), distMaxCorrige);
- final RelationEMH relation = FactoryEMH.createRelationSectionDansBranche(branche, interpol, xpos);
- // -- ajout dans metier --//
- data.add(interpol);
-
- // -- ajout de la relation a l'emplacement k+1 a partir de i--//
- branche.getRelationEMH().add((i + k), relation);
-
+ // -- on creer une section interpolee pour chaque besoin et on l'ajoute dans cruedata puis dans les relations
+ // branche --//.
+ final double distMaxCorrige = distance / nbProfilsToAdd;
+ // on commence a 1: c'est normal on cree un prol
+ for (int k = 1; k < nbProfilsToAdd; k++) {
+ final double xpos = xpos1 + (k) * distMaxCorrige;
+ double doubleForNom = xpos;
+ if (doubleForNom >= 1) {
+ doubleForNom = Math.floor(doubleForNom);
}
+ final EMHSectionInterpolee interpol = FactoryEMH.createSectionInterpoleFromDistmax(doubleForNom, branche
+ .getNom(), distMaxCorrige);
+ final RelationEMH relation = FactoryEMH.createRelationSectionDansBranche(branche, interpol, xpos);
+ // -- ajout dans metier --//
+ data.add(interpol);
+ branche.getRelationEMH().add(relation);
- // -- on translate i de k+1 itérations pour revenir a l'indice de la relation2 --//
- i += nbProfilsToAdd;
- // ATTENTION, le k+1 ici est indirect, car le +1 sera ajouté par la boucle for.
}
}
-
+ branche.getRelationEMH().add(relation2);
}
}
Modified: trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/io/neuf/DHReader.java
===================================================================
--- trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/io/neuf/DHReader.java 2009-10-23 20:34:57 UTC (rev 5448)
+++ trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/io/neuf/DHReader.java 2009-10-24 01:02:21 UTC (rev 5449)
@@ -361,14 +361,14 @@
// lecture Ligne E : Niveaux d'eau initiaux des branches / sections
if (ile == 0) {
- reader.readLine();
- final int iligne = reader.intField(0);
// On doit avoir autant de lignes e2 ou e3 que de branches.
// final int nbBranche = getNbBranches();
final int nbBranche = nomsBranches.size();
String brancheName = null;
for (int i = 0; i < nbBranche; i++) {
reader.readLine();
+ final int iligne = reader.intField(0);
+ reader.readLine();
brancheName = nomsBranches.get(i);
final CatEMHBranche br = res.findBrancheByReference(brancheName);
@@ -395,16 +395,16 @@
int idxOnLine = 0;
int maxOnLine = reader.getNumberOfFields();
for (int j = 0; j < nbDataToRead; j++) {
- final double niveauEauPourProfilJ = reader.doubleField(idxOnLine++);
- final DonPrtCIniSection section = new DonPrtCIniSection();
- section.setZini(niveauEauPourProfilJ);
- sectionsBranche.get(j).getEmh().addInfosEMH(section);
// données sur plusieurs lignes
if (idxOnLine >= maxOnLine) {
reader.readLine();
maxOnLine = reader.getNumberOfFields();
idxOnLine = 0;
}
+ final double niveauEauPourProfilJ = reader.doubleField(idxOnLine++);
+ final DonPrtCIniSection section = new DonPrtCIniSection();
+ section.setZini(niveauEauPourProfilJ);
+ sectionsBranche.get(j).getEmh().addInfosEMH(section);
}
} else if (iligne == 2) { // Ligne E3
@@ -427,9 +427,9 @@
}
}
- reader.readLine();// lecture de la ligne FIN
- if (!FIN.equalsIgnoreCase(reader.stringField(0))) {
- analyze_.addErrorFromFile("io.dh.tagFINNotFound.error", reader.getCurrent() //$NON-NLS-1$
+ // reader.readLine();// lecture de la ligne FIN
+ if (FIN.equalsIgnoreCase(reader.stringField(0))) {
+ analyze_.addErrorFromFile("io.dh.tagFINFound.error", reader.getCurrent() //$NON-NLS-1$
.getLineNumber());
}
@@ -1292,8 +1292,19 @@
final List<PtEvolutionFF> pts = new ArrayList<PtEvolutionFF>();
evolutionFF.setPtEvolutionFF(pts);
// les pas de temps
+ Duration lastDuration = null;
while (!FIN.equalsIgnoreCase(reader.stringField(0))) {
+ if (reader.getNumberOfFields() != 5) {
+ analyze_.addError("io.dh.ref.emh.ligneE2.error", reader.getLineNumber());
+ return;
+ }
final Duration date = readDuration(reader);
+ if (lastDuration != null && lastDuration.compareTo(date) > 0) {
+ analyze_.addError("io.dh.ref.emh.ligneE2.notCroissant.error", reader.getLineNumber());
+ return;
+ }
+
+ lastDuration = date;
final PtEvolutionFF pt = new PtEvolutionFF();
// on cree une date avec des secondes uniquement, pour l'instant
pt.setX(date.getStandardSeconds());
Modified: trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/io/neuf/DHWriter.java
===================================================================
--- trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/io/neuf/DHWriter.java 2009-10-23 20:34:57 UTC (rev 5448)
+++ trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/io/neuf/DHWriter.java 2009-10-24 01:02:21 UTC (rev 5449)
@@ -256,12 +256,11 @@
// Ecriture ligne E1
writeCom(" ligne ");
- fortranWriter.intField(0, 1);
- fortranWriter.writeFields();
// Ecriture lignes E2
for (int i = 0, branchesDptiSize = branchesDPTI.size(); i < branchesDptiSize; i++) {
-
+ fortranWriter.intField(0, 1);
+ fortranWriter.writeFields();
final CatEMHBranche brancheDPTI = branchesDPTI.get(i);
final List<RelationEMHSectionDansBranche> sectionsBrancheDPTI = brancheDPTI.getListeSections();
final List<DonPrtCIni> dptis = brancheDPTI.getDPTI();
@@ -278,7 +277,7 @@
int idxOnLine = 0;
for (int j = 0; j < countSectionsBranche; j++) {
- final DonPrtCIniSection dpti = EMHHelper.getFirstOfClass(sectionsBrancheDPTI.get(i).getEmh().getInfosEMH(),
+ final DonPrtCIniSection dpti = EMHHelper.getFirstOfClass(sectionsBrancheDPTI.get(j).getEmh().getInfosEMH(),
DonPrtCIniSection.class);
double zIniPourProfilJ = 0;
if (dpti != null) {
Modified: trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/metier/emh/CatEMHBranche.java
===================================================================
--- trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/metier/emh/CatEMHBranche.java 2009-10-23 20:34:57 UTC (rev 5448)
+++ trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/metier/emh/CatEMHBranche.java 2009-10-24 01:02:21 UTC (rev 5449)
@@ -43,7 +43,7 @@
return EMHHelper.getListeRelationsSectionsSortedByXp(this);
}
- public void setListeSections(final List<? extends RelationEMH> liste) {
+ public void addListeSections(final List<? extends RelationEMH> liste) {
EMHHelper.addListeSectionsToRelations(this, liste);
}
Modified: trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/metier/emh/DefaultValues.java
===================================================================
--- trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/metier/emh/DefaultValues.java 2009-10-23 20:34:57 UTC (rev 5448)
+++ trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/metier/emh/DefaultValues.java 2009-10-24 01:02:21 UTC (rev 5449)
@@ -1,6 +1,8 @@
package org.fudaa.dodico.crue.metier.emh;
import org.fudaa.dodico.crue.common.CrueNumberUtils;
+import org.fudaa.dodico.crue.common.DateDurationConverter;
+import org.joda.time.Duration;
/**
* Valeures par defaut des EMHs. Ces valeurs sont statiques finales et sont distinguees par fichiers xml.
@@ -169,6 +171,16 @@
public static final double PM_TOL_ND_Z = 0.01;
/**
+ * P0Y0M1DT0H0M0S
+ */
+ public static final Duration DUREE_SCENARIO = DateDurationConverter.getDuration(1, 0, 0, 0);
+
+ /**
+ * P0Y0M0DT1H0M0S
+ */
+ public static final PdtCst PDT_ONE_HOUR = new PdtCst(DateDurationConverter.getDuration(0, 1, 0, 0));
+
+ /**
* @param ordPrtGeoModeleBase
*/
public static void initDefaultValues(final OrdPrtGeoModeleBase ordPrtGeoModeleBase) {
Modified: trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/metier/emh/ParamCalcScenario.java
===================================================================
--- trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/metier/emh/ParamCalcScenario.java 2009-10-23 20:34:57 UTC (rev 5448)
+++ trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/metier/emh/ParamCalcScenario.java 2009-10-24 01:02:21 UTC (rev 5449)
@@ -6,19 +6,20 @@
package org.fudaa.dodico.crue.metier.emh;
+import org.fudaa.dodico.crue.common.DateDurationConverter;
import org.joda.time.Duration;
import org.joda.time.LocalDateTime;
/** @pdOid 06f3be55-38bc-4c84-9e40-14ede80db7b1 */
public class ParamCalcScenario implements InfosEMH {
/** @pdOid f78103e1-696e-4ea2-aa7c-954d686c8627 */
- private LocalDateTime dateDebSce;
+ private LocalDateTime dateDebSce = DateDurationConverter.ZERO_DATE;
/** @pdOid 11a96da7-c43a-4dc1-aef8-c665519a8279 */
- private Duration dureeSce;
+ private Duration dureeSce = DefaultValues.DUREE_SCENARIO;
/** @pdOid a02b0fc0-f0f1-4cfe-9d2f-fd13a9d64afb */
private Pdt pdtCouplage;
/** @pdOid 2b6da816-3b11-4e15-b77d-0345ce751910 */
- private Pdt pdtRes;
+ private Pdt pdtRes = DefaultValues.PDT_ONE_HOUR;
/** @pdOid b53800e8-dc94-4d00-8455-7270f28b7f9a */
private EnumVerbosite verbosite = DefaultValues.VERBOSITE;
Modified: trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/metier/emh/ParamNumCalcTrans.java
===================================================================
--- trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/metier/emh/ParamNumCalcTrans.java 2009-10-23 20:34:57 UTC (rev 5448)
+++ trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/metier/emh/ParamNumCalcTrans.java 2009-10-24 01:02:21 UTC (rev 5449)
@@ -16,7 +16,7 @@
private double thetaPreissmann = DefaultValues.THETA;
/** @pdRoleInfo migr=no name=Pdt assc=association115 mult=1..1 type=Composition */
- private Pdt pdt;
+ private Pdt pdt = DefaultValues.PDT_ONE_HOUR;
/** @pdGenerated default parent getter */
public Pdt getPdt() {
Modified: trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/metier/emh/PdtCst.java
===================================================================
--- trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/metier/emh/PdtCst.java 2009-10-23 20:34:57 UTC (rev 5448)
+++ trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/metier/emh/PdtCst.java 2009-10-24 01:02:21 UTC (rev 5449)
@@ -14,7 +14,19 @@
/** @pdOid 88c6bab9-ffcb-42d5-bff1-2dd665af42ed */
private Duration pdtCst;
+ public PdtCst() {
+
+ }
+
/**
+ * @param pdtCst le pas de temps
+ */
+ public PdtCst(Duration pdtCst) {
+ super();
+ this.pdtCst = pdtCst;
+ }
+
+ /**
* @return the pdtCst
*/
public Duration getPdtCst() {
Modified: trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/metier/helper/FactoryEMH.java
===================================================================
--- trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/metier/helper/FactoryEMH.java 2009-10-23 20:34:57 UTC (rev 5448)
+++ trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/metier/helper/FactoryEMH.java 2009-10-24 01:02:21 UTC (rev 5449)
@@ -131,7 +131,7 @@
+ "_Aval");
metier.add(amont);
metier.add(aval);
- branche.setListeSections(Arrays
+ branche.addListeSections(Arrays
.asList(createRelationSectionDansBranche(branche, amont, 0, EnumPositionSection.AMONT),
createRelationSectionDansBranche(branche, aval, longueur, EnumPositionSection.AVAL)));
Modified: trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/metier/helper/LoiFactory.java
===================================================================
--- trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/metier/helper/LoiFactory.java 2009-10-23 20:34:57 UTC (rev 5448)
+++ trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/metier/helper/LoiFactory.java 2009-10-24 01:02:21 UTC (rev 5449)
@@ -6,13 +6,13 @@
import java.util.ArrayList;
import java.util.List;
+import org.fudaa.dodico.crue.common.DateDurationConverter;
import org.fudaa.dodico.crue.metier.emh.EnumTypeLoi;
import org.fudaa.dodico.crue.metier.emh.EvolutionFF;
import org.fudaa.dodico.crue.metier.emh.Loi;
import org.fudaa.dodico.crue.metier.emh.LoiDF;
import org.fudaa.dodico.crue.metier.emh.LoiFF;
import org.fudaa.dodico.crue.metier.emh.PtEvolutionFF;
-import org.joda.time.LocalDateTime;
/**
* @author cde
@@ -37,7 +37,7 @@
public static void alimenteDebutLoiDF(final LoiDF loiDF, final String nom, final EnumTypeLoi type) {
alimenteDebutLoi(loiDF, nom, type);
- loiDF.setDateZeroLoiDF(ZERO_DATE);
+ loiDF.setDateZeroLoiDF(DateDurationConverter.ZERO_DATE);
}
/**
@@ -99,9 +99,4 @@
return null;
}
- /**
- * La date null
- */
- public final static LocalDateTime ZERO_DATE = new LocalDateTime(01, 01, 01, 0, 0, 0, 0);
-
}
Modified: trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/projet/ScenarioLoader.java
===================================================================
--- trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/projet/ScenarioLoader.java 2009-10-23 20:34:57 UTC (rev 5448)
+++ trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/projet/ScenarioLoader.java 2009-10-24 01:02:21 UTC (rev 5449)
@@ -84,7 +84,7 @@
final ValidateEMHProperties propValidator = new ValidateEMHProperties();
emhScenario.setNom(scenario.getNom());
final List<EMH> allEMH = emhScenario.getAllEMH();
- final IdValidator res = propValidator.validateNoms(allEMH, false);
+ final IdValidator res = propValidator.validateNoms(allEMH);
final CtuluAnalyze nomValidationRes = res.getRes();
validationBilan.addAnalyzer(nomValidationRes);
scenario.setCompatibleCrue9(res.isCrue9Compatible());
@@ -96,7 +96,8 @@
// finalement tout va bien:
scenario.setEmh(emhScenario);
if (scenario.getEmh() != null) {
- final List<CtuluAnalyze> validateValues = propValidator.validateValues(scenario.getEmh().getAllEMH());
+ final List<CtuluAnalyze> validateValues = propValidator.validateValues(scenario.getEmh().getAllEMH(), scenario
+ .getEmh());
validationBilan.getAnalyser().addAll(validateValues);
}
return errorMng;
Modified: trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/projet/ScenarioLoaderCrue10.java
===================================================================
--- trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/projet/ScenarioLoaderCrue10.java 2009-10-23 20:34:57 UTC (rev 5448)
+++ trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/projet/ScenarioLoaderCrue10.java 2009-10-24 01:02:21 UTC (rev 5449)
@@ -29,7 +29,7 @@
import org.fudaa.dodico.crue.metier.emh.EMHScenario;
import org.fudaa.dodico.crue.metier.emh.EMHSousModele;
import org.fudaa.dodico.crue.metier.helper.EMHHelper;
-import org.fudaa.dodico.crue.validation.ValidateModeleScenario;
+import org.fudaa.dodico.crue.validation.ValidateModeleScenarioWithSchema;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -77,7 +77,7 @@
protected EMHScenario compute(final Map<String, File> files) {
// pour crue10, on vérifie les fichiers xml
- final ValidateModeleScenario crue10Valid = new ValidateModeleScenario(createFrom(files), scenario);
+ final ValidateModeleScenarioWithSchema crue10Valid = new ValidateModeleScenarioWithSchema(createFrom(files), scenario);
crue10Valid.validate(errorMng);
if (errorMng.containsError()) { return null; }
return ordonnanceChargementCrue10(files);
Modified: trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/validation/CruePrefix.java
===================================================================
--- trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/validation/CruePrefix.java 2009-10-23 20:34:57 UTC (rev 5448)
+++ trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/validation/CruePrefix.java 2009-10-24 01:02:21 UTC (rev 5449)
@@ -3,10 +3,7 @@
*/
package org.fudaa.dodico.crue.validation;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
+import java.util.*;
import org.apache.commons.lang.StringUtils;
import org.fudaa.ctulu.CtuluAnalyze;
@@ -119,13 +116,13 @@
}
/**
- * Renvoie true si le préfixe doit être ajouté au nom.
+ * Renvoie true si le préfixe doit être ajouté au nom. Comparaison case sensitive
*
* @param prefixe
* @param nom
* @return true si le préfixe doit être ajouté au nom
*/
- public static boolean prefixMustBeAdded(final String prefixe, final String nom) {
+ private static boolean prefixMustBeAdded(final String prefixe, final String nom) {
// On n'ajoute pas de préfixe si le nom est null ou si le préfixe est null ou vide
if (nom == null || prefixe == null || prefixe.length() == 0) { return false; }
@@ -133,23 +130,37 @@
return !nom.startsWith(prefixe);
}
- public static String getPrefix(final EnumTypeLoi typeLoi) {
+ private static String getPrefix(final EnumTypeLoi typeLoi) {
return typeLoi.toString() + "_";
}
+ /**
+ * @param nom le nom a modifier
+ * @param oldPref le prefixe a enleve: non case sensitive. Si non présent, dans le nom initial il n'est pas enleve.
+ * @param newPref le nouveau prefixe. Si le nom initial commence déja par ce newPrefixe, il est remplace par le
+ * prefixe case-sensitive.
+ * @return le nom modifie
+ */
public static String changePrefix(final String nom, final String oldPref, final String newPref) {
- return newPref + StringUtils.removeStart(nom, oldPref);
+ if (oldPref != null && StringUtils.startsWithIgnoreCase(nom, oldPref)) { return newPref
+ + StringUtils.removeStartIgnoreCase(nom, oldPref); }
+ return newPref + StringUtils.removeStartIgnoreCase(nom, newPref);
}
+ private static String addPrefix(final String newPref, final String nom) {
+ return changePrefix(nom, null, newPref);
+ }
+
public static String getNom(final EnumTypeLoi typeLoi, final String suffixe) {
- return getPrefix(typeLoi) + suffixe;
+ return addPrefix(getPrefix(typeLoi), suffixe);
}
public static String addPrefixIfNeeded(final EnumTypeLoi typeLoi, final String init) {
+
if (init == null) { return null; }
final String pref = getPrefix(typeLoi);
if (init.startsWith(pref)) { return init; }
- return getPrefix(typeLoi) + init;
+ return getNom(typeLoi, init);
}
/**
@@ -174,11 +185,11 @@
return prefix;
}
- public static String getNomAvecPrefix(final Loi loi) {
- if (loi == null) { return null; }
- final String prefix = getPrefix(loi.getType());
- return getNomAvecPrefixe(prefix, loi.getNom());
- }
+ // public static String getNomAvecPrefix(final Loi loi) {
+ // if (loi == null) { return null; }
+ // final String prefix = getPrefix(loi.getType());
+ // return getNomAvecPrefixe(prefix, loi.getNom());
+ // }
/**
* La taille max autorisé pour les noms crue 9
@@ -193,25 +204,38 @@
*/
public static final int NB_CAR_MAX = 32;
- protected static void computeNom(final ObjetNomme obj, final String prefixe, final CtuluAnalyze analyze,
- final String codeErreur) {
- final String newNom = getNomAvecPrefixe(prefixe, StringUtils.replaceChars(obj.getNom(), '#', '_'));
+ private static void computeNom(final ObjetNomme obj, final String prefixe, final CtuluAnalyze analyze,
+ final String codeErreur, final Map<String, Set<String>> newNameOldNames) {
+ final String oldName = obj.getNom();
+ final String newNom = getNomAvecPrefixe(prefixe, oldName);
// il faut ajouter un warning uniquement
final int length = newNom.length();
if (length > NB_CAR_MAX) {
- analyze.addError(codeErreur, obj.getNom(), newNom);
+ analyze.addError(codeErreur, oldName, newNom);
} else {
// cas des casier profil a part.
if ((obj instanceof EMHCasierProfil && length > NB_CAR_MAX_CRUE9_CASIER_PROFIL) || (length > NB_CAR_MAX_CRUE9)) {
- analyze.addWarn(codeErreur + ".warn", obj.getNom(), newNom);
+ analyze.addWarn(codeErreur + ".warn", oldName, newNom);
}
if (length > NB_CAR_MAX) {
- analyze.addError(codeErreur, obj.getNom(), newNom);
+ analyze.addError(codeErreur, oldName, newNom);
}
obj.setNom(newNom);
+ if (!newNom.equals(oldName)) {
+ Set<String> oldNames = newNameOldNames.get(newNom);
+ if (oldNames == null) {
+ oldNames = new HashSet<String>(2);
+ newNameOldNames.put(newNom, oldNames);
+ }
+ oldNames.add(oldName);
+ }
}
}
+ private static String cleanNom(final String nom) {
+ return nom == null ? null : nom.replace('#', '_').replace('/', '_');
+ }
+
/**
* @param prefixe
* @param loi
@@ -247,18 +271,19 @@
}
/**
- * @param prefixe
- * @param nomInitial
- * @return
+ * @param prefixe le prefixe qui doit etre utilise
+ * @param nomInitial le nom intial
+ * @return le nom transforme.
*/
- private static String getNomAvecPrefixe(final String prefixe, final String nomInitial) {
+ private static String getNomAvecPrefixe(final String prefixe, final String nomInitialNonClean) {
// pas de nom initial: on ne fait rien
- if (nomInitial == null) { return null; }
+ if (nomInitialNonClean == null) { return null; }
+ final String nomInitial = cleanNom(nomInitialNonClean);
if (prefixMustBeAdded(prefixe, nomInitial)) {
// le nom comporte deja un prefixe connu, on le change
- final String usedPRefix = startWithKnownPrefix(nomInitial);
- if (usedPRefix != null) { return changePrefix(nomInitial, usedPRefix, prefixe); }
+ final String usedPrefix = startWithKnownPrefix(nomInitial);
+ if (usedPrefix != null) { return changePrefix(nomInitial, usedPrefix, prefixe); }
return (prefixe + nomInitial);
}
return nomInitial;
@@ -266,13 +291,13 @@
/**
* @param nomInitial
- * @return le prefixe connu utilise par le nom.
+ * @return le prefixe connu utilise par le nom: attention non case sensitive.
*/
private static String startWithKnownPrefix(final String nomInitial) {
for (final String pref : ENUM_PREFIX.values()) {
if (!prefixMustBeAdded(pref, nomInitial)) { return pref; }
final String upperCase = pref.toUpperCase();
- if (!prefixMustBeAdded(upperCase, nomInitial)) { return upperCase; }
+ if (!prefixMustBeAdded(upperCase, nomInitial.toUpperCase())) { return upperCase; }
}
return null;
@@ -283,11 +308,12 @@
* @return Les messages d'erreur éventuels
*/
public static CtuluAnalyze verifiePrefixeNomDonneesCrue9(final CrueData crueData) {
+ final Map<String, Set<String>> newNameOldNames = new HashMap<String, Set<String>>();
final List<EMH> listeEMHs = crueData.getAllSimpleEMH();
final CtuluAnalyze analyze = new CtuluAnalyze(CommonMessages.RESOURCE_BUNDLE);
for (final EMH emh : listeEMHs) {
- computeNom(emh, getPrefixFor(emh), analyze, "crue9.cant.rename.emh");
+ computeNom(emh, getPrefixFor(emh), analyze, "crue9.cant.rename.emh", newNameOldNames);
}
final DonFrtConteneur frottements = crueData.getFrottements();
if (frottements != null) {
@@ -295,7 +321,7 @@
for (final DonFrt donFrt : listFrt) {
final LoiFF loi = donFrt.getLoi();
final String pref = (loi.getType().equals(EnumTypeLoi.LoiFK)) ? P_FROTT_STRICKLER : P_FROTT_MANNING;
- computeNom(donFrt, pref, analyze, "crue9.cant.rename.frt");
+ computeNom(donFrt, pref, analyze, "crue9.cant.rename.frt", newNameOldNames);
}
}
@@ -308,20 +334,20 @@
if (donnee instanceof DonPrtGeoProfilSection) {
final DonPrtGeoProfilSection donneeProfilSection = (DonPrtGeoProfilSection) donnee;
- computeNom(donneeProfilSection, P_PROFIL_SECTION, analyze, "crue9.cant.rename.profil");
+ computeNom(donneeProfilSection, P_PROFIL_SECTION, analyze, "crue9.cant.rename.profil", newNameOldNames);
final List<LitNumerote> litsNumerotes = donneeProfilSection.getLitNumerote();
if (litsNumerotes != null) {
for (int i = 0, imax = litsNumerotes.size(); i < imax; i++) {
final LitNomme nomLit = litsNumerotes.get(i).getNomLit();
if (nomLit != null) {
- computeNom(nomLit, P_LIT, analyze, "crue9.cant.rename.lit");
+ computeNom(nomLit, P_LIT, analyze, "crue9.cant.rename.lit", newNameOldNames);
}
}
}
} else if (donnee instanceof DonPrtGeoProfilCasier) {
- computeNom((ObjetNomme) donnee, P_PROFIL_CASIER, analyze, "crue9.cant.rename.profilCasier");
+ computeNom((ObjetNomme) donnee, P_PROFIL_CASIER, analyze, "crue9.cant.rename.profilCasier", newNameOldNames);
} else if (donnee instanceof DonPrtGeoBatiCasier) {
- computeNom((ObjetNomme) donnee, P_BATI_CASIER, analyze, "crue9.cant.rename.profilCasier");
+ computeNom((ObjetNomme) donnee, P_BATI_CASIER, analyze, "crue9.cant.rename.profilCasier", newNameOldNames);
}
}
}
@@ -379,7 +405,14 @@
// }
// }
// }
+ for (final Map.Entry<String, Set<String>> it : newNameOldNames.entrySet()) {
+ if (it.getValue().size() > 1) {
+ analyze.addError("crue9.sameId.forDifferentNames.error", it.getKey(), StringUtils.join(
+ it.getValue().iterator(), ", "));
+ }
+ }
+
return analyze;
}
Modified: trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/validation/ValidateEMHProperties.java
===================================================================
--- trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/validation/ValidateEMHProperties.java 2009-10-23 20:34:57 UTC (rev 5448)
+++ trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/validation/ValidateEMHProperties.java 2009-10-24 01:02:21 UTC (rev 5449)
@@ -34,7 +34,7 @@
* @author deniger
*/
public class IdValidator implements Validator {
- private final boolean errorForCrue9;
+ // private final boolean errorForCrue9;
boolean isCrue10Compatible = true;
boolean isCrue9Compatible = true;
@@ -42,9 +42,8 @@
private final Map<String, Object> used = new HashMap<String, Object>();
- public IdValidator(final boolean errorForCrue9) {
+ public IdValidator() {
super();
- this.errorForCrue9 = errorForCrue9;
res.setDefaultResourceBundle(CommonMessages.RESOURCE_BUNDLE);
res.setDesc(CommonMessages.getString("validation.noms"));
}
@@ -100,11 +99,7 @@
&& o instanceof EMHCasierProfil)
&& isWrittenByCrue9(o)) {
isCrue9Compatible = false;
- if (errorForCrue9) {
- res.addError("valid.nom.tooLong.crue9", nom);
- } else {
- res.addWarn("valid.nom.tooLong.crue9", nom);
- }
+ res.addWarn("valid.nom.tooLong.crue9", nom);
}
final Object usedObject = used.get(id);
if (usedObject == null) {
@@ -457,14 +452,22 @@
return res;
}
- public IdValidator validateNoms(final List<EMH> emhs, final boolean errorForCrue9) {
+ public IdValidator validateNoms(final List<EMH> emhs) {
validatedObjects.clear();
- final IdValidator validator = new IdValidator(errorForCrue9);
+ final IdValidator validator = new IdValidator();
validateValues(emhs, validator, null);
return validator;
}
- public List<CtuluAnalyze> validateValues(final List<EMH> emhs) {
+ EMHScenario scenario;
+
+ /**
+ * @param emhs les emhs a valider
+ * @param scenario le scenario contenant pour savoir
+ * @return
+ */
+ public List<CtuluAnalyze> validateValues(final List<EMH> emhs, EMHScenario scenario) {
+ this.scenario = scenario;
validatedObjects.clear();
final CtuluAnalyze analyze = new CtuluAnalyze();
final PropertyValidatorsBuilder builder = PropertyValidatorsBuilder.load(new VariableBuilder(), analyze);
@@ -477,7 +480,7 @@
return validateValues(emhs, value, res);
}
- public List<CtuluAnalyze> validateValues(final List<EMH> emhs, final Validator validator, final List<CtuluAnalyze> in) {
+ private List<CtuluAnalyze> validateValues(final List<EMH> emhs, final Validator validator, final List<CtuluAnalyze> in) {
final List<CtuluAnalyze> res = in == null ? new ArrayList<CtuluAnalyze>() : in;
for (final EMH emh : emhs) {
if (!validatedObjects.contains(emh)) {
Deleted: trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/validation/ValidateModeleScenario.java
===================================================================
--- trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/validation/ValidateModeleScenario.java 2009-10-23 20:34:57 UTC (rev 5448)
+++ trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/validation/ValidateModeleScenario.java 2009-10-24 01:02:21 UTC (rev 5449)
@@ -1,177 +0,0 @@
-/**
- * Licence GPL
- * Copyright Genesis
- */
-package org.fudaa.dodico.crue.validation;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-import javax.xml.validation.SchemaFactory;
-
-import org.apache.commons.lang.StringUtils;
-import org.fudaa.ctulu.CtuluAnalyze;
-import org.fudaa.dodico.crue.common.CommonMessages;
-import org.fudaa.dodico.crue.common.CrueErrorManager;
-import org.fudaa.dodico.crue.metier.ManagerEMHScenario;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-import org.xml.sax.helpers.DefaultHandler;
-
-/**
- * Classe permettant de valider la cohérence des fichiers d'un modèle
- *
- * @author deniger
- */
-public class ValidateModeleScenario {
-
- private final Map<String, URL> idFile;
- private final ManagerEMHScenario scenario;
-
- private final String grammaireVersion = "1.0.0";
-
- private static final String JAXP_SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
- private static final String W3C_XML_SCHEMA = "http://www.w3.org/2001/XMLSchema";
- private static final String JAXP_SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
-
- /**
- * @param destDir le répertoire de travail de cette validation
- * @param scenario le scénario à valider
- */
- public ValidateModeleScenario(final Map<String, URL> destDir, final ManagerEMHScenario scenario) {
- super();
- this.idFile = destDir;
- this.scenario = scenario;
- }
-
- /**
- * Ecrit le fichier scenario.xml
- *
- * @return Les messages d'erreur éventuels
- */
- public CtuluAnalyze writeScenario() {
- final ScenarioWriter.InputFormatWriter out = new ScenarioWriter.InputFormatWriter();
- out.scenario = scenario;
- out.version = grammaireVersion;
- out.idFile = idFile;
- final ScenarioWriter writer = new ScenarioWriter();
- writer.setFile(getScenarioFile());
- return writer.write(out).getAnalyze();
- }
-
- private final static Logger LOGGER = LoggerFactory.getLogger(ValidateModeleScenario.class);
-
- private File dest;
-
- /**
- * @return le fichier utilisé pour écrire le fichier concaténé
- */
- public File getScenarioFile() {
- if (dest == null) {
- try {
- dest = File.createTempFile("valide", "scenario.xml");
- } catch (final IOException e) {
- LOGGER.error("createTempFile", e);
- }
- }
- return dest;
- }
-
- public CrueErrorManager validate() {
- return validate(null);
- }
-
- /**
- * @param in le conteneur d'erreur: peut etre null
- * @return le manager d'erreur.
- */
- public CrueErrorManager validate(final CrueErrorManager in) {
- final CrueErrorManager res = in == null ? new CrueErrorManager(CommonMessages.RESOURCE_BUNDLE) : in;
- final CtuluAnalyze analyze = writeScenario();
- if (analyze.containsErrors()) {
- res.getAnalyser().add(analyze);
- return res;
- }
- validateFile(res);
- return res;
- }
-
- private CrueErrorManager validateFile(final CrueErrorManager res) {
-
- final Map<String, CtuluAnalyze> map = new HashMap<String, CtuluAnalyze>();
- try {
-
- final URL xsdURL = ValidateModeleScenario.class.getResource("/xsd/scenario-" + grammaireVersion + ".xsd");
- // final URL xsddfrtURL = AbstractIOTestCase.class.getResource("/xsd/dfrt-1.0.xsd");
- final URL xml = getScenarioFile().toURI().toURL();
- final SchemaFactory schemaFactory = SchemaFactory.newInstance(W3C_XML_SCHEMA);
- // schemaFactory.setResourceResolver(resourceResolver)
- /* final Schema schema = */schemaFactory.newSchema(xsdURL);
- // //
- //
- // // parser.setSchema(schema);
- final DefaultHandler handler = new DefaultHandler() {
-
- @Override
- public void error(final SAXParseException e) throws SAXException {
- final String message = e.getMessage();
- final Throwable cause = e.getException();
- final String msg = message.indexOf(':') > 0 ? StringUtils.substringAfter(message, ":") : message;
- if (msg.contains("no grammar found") || msg.contains("must match DOCTYPE root")
- || msg.contains("Attribute 'xml:base'")) { return; }
- LOGGER.debug("error in validation", e);
- CtuluAnalyze analyze = map.get(e.getSystemId());
- if (analyze == null) {
- analyze = res.getNewAnalyser();
- analyze.setResource(e.getSystemId());
- analyze.setDesc(e.getSystemId());
- map.put(e.getSystemId(), analyze);
-
- }
- e.printStackTrace();
- analyze.addErrorFromFile(CommonMessages.RESOURCE_BUNDLE.getString("valid.line") + " " + e.getLineNumber()
- + ": " + msg, e.getLineNumber());
- // e.printStackTrace();
- }
-
- @Override
- public void fatalError(final SAXParseException e) throws SAXException {
- error(e);
- }
-
- @Override
- public void warning(final SAXParseException e) throws SAXException {
- // e.printStackTrace();
- }
- };
- // final Validator validator = schema.newValidator();
- // // validator.s
- // // SAXSource source = new SAXSource(new InputSource(xml.toString()));
- // // validator.validate(source);
- final SAXParserFactory parser = SAXParserFactory.newInstance();
- // parser.setSchema(schema);
- parser.setNamespaceAware(true);
- parser.setXIncludeAware(true);
- parser.setValidating(true);
- final SAXParser newSAXParser = parser.newSAXParser();
- newSAXParser.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
- newSAXParser.setProperty(JAXP_SCHEMA_SOURCE, new InputSource(xsdURL.toString()));
- newSAXParser.parse(new InputSource(xml.toString()), handler);
-
- } catch (final Exception e) {
- res.getNewAnalyser().manageException(e);
- LOGGER.error("validation", e);
- // e.printStackTrace();
- }
- return res;
-
- }
-}
Copied: trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/validation/ValidateModeleScenarioWithSchema.java (from rev 5403, trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/validation/ValidateModeleScenario.java)
===================================================================
--- trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/validation/ValidateModeleScenarioWithSchema.java (rev 0)
+++ trunk/soft/fudaa-crue/dodico/src/main/java/org/fudaa/dodico/crue/validation/ValidateModeleScenarioWithSchema.java 2009-10-24 01:02:21 UTC (rev 5449)
@@ -0,0 +1,177 @@
+/**
+ * Licence GPL
+ * Copyright Genesis
+ */
+package org.fudaa.dodico.crue.validation;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import javax.xml.validation.SchemaFactory;
+
+import org.apache.commons.lang.StringUtils;
+import org.fudaa.ctulu.CtuluAnalyze;
+import org.fudaa.dodico.crue.common.CommonMessages;
+import org.fudaa.dodico.crue.common.CrueErrorManager;
+import org.fudaa.dodico.crue.metier.ManagerEMHScenario;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * Classe permettant de valider la cohérence des fichiers d'un modèle pour Crue 10.
+ *
+ * @author deniger
+ */
+public class ValidateModeleScenarioWithSchema {
+
+ private final Map<String, URL> idFile;
+ private final ManagerEMHScenario scenario;
+
+ private final String grammaireVersion = "1.0.0";
+
+ private static final String JAXP_SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
+ private static final String W3C_XML_SCHEMA = "http://www.w3.org/2001/XMLSchema";
+ private static final String JAXP_SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
+
+ /**
+ * @param destDir le répertoire de travail de cette validation
+ * @param scenario le scénario à valider
+ */
+ public ValidateModeleScenarioWithSchema(final Map<String, URL> destDir, final ManagerEMHScenario scenario) {
+ super();
+ this.idFile = destDir;
+ this.scenario = scenario;
+ }
+
+ /**
+ * Ecrit le fichier scenario.xml
+ *
+ * @return Les messages d'erreur éventuels
+ */
+ public CtuluAnalyze writeScenario() {
+ final ScenarioWriter.InputFormatWriter out = new ScenarioWriter.InputFormatWriter();
+ out.scenario = scenario;
+ out.version = grammaireVersion;
+ out.idFile = idFile;
+ final ScenarioWriter writer = new ScenarioWriter();
+ writer.setFile(getScenarioFile());
+ return writer.write(out).getAnalyze();
+ }
+
+ private final static Logger LOGGER = LoggerFactory.getLogger(ValidateModeleScenarioWithSchema.class);
+
+ private File dest;
+
+ /**
+ * @return le fichier utilisé pour écrire le fichier concaténé
+ */
+ public File getScenarioFile() {
+ if (dest == null) {
+ try {
+ dest = File.createTempFile("valide", "scenario.xml");
+ } catch (final IOException e) {
+ LOGGER.error("createTempFile", e);
+ }
+ }
+ return dest;
+ }
+
+ public CrueErrorManager validate() {
+ return validate(null);
+ }
+
+ /**
+ * @param in le conteneur d'erreur: peut etre null
+ * @return le manager d'erreur.
+ */
+ public CrueErrorManager validate(final CrueErrorManager in) {
+ final CrueErrorManager res = in == null ? new CrueErrorManager(CommonMessages.RESOURCE_BUNDLE) : in;
+ final CtuluAnalyze analyze = writeScenario();
+ if (analyze.containsErrors()) {
+ res.getAnalyser().add(analyze);
+ return res;
+ }
+ validateFile(res);
+ return res;
+ }
+
+ private CrueErrorManager validateFile(final CrueErrorManager res) {
+
+ final Map<String, CtuluAnalyze> map = new HashMap<String, CtuluAnalyze>();
+ try {
+
+ final URL xsdURL = ValidateModeleScenarioWithSchema.class.getResource("/xsd/scenario-" + grammaireVersion + ".xsd");
+ // final URL xsddfrtURL = AbstractIOTestCase.class.getResource("/xsd/dfrt-1.0.xsd");
+ final URL xml = getScenarioFile().toURI().toURL();
+ final SchemaFactory schemaFactory = SchemaFactory.newInstance(W3C_XML_SCHEMA);
+ // schemaFactory.setResourceResolver(resourceResolver)
+ /* final Schema schema = */schemaFactory.newSchema(xsdURL);
+ // //
+ //
+ // // parser.setSchema(schema);
+ final DefaultHandler handler = new DefaultHandler() {
+
+ @Override
+ public void error(final SAXParseException e) throws SAXException {
+ final String message = e.getMessage();
+ final Throwable cause = e.getException();
+ final String msg = message.indexOf(':') > 0 ? StringUtils.substringAfter(message, ":") : message;
+ if (msg.contains("no grammar found") || msg.contains("must match DOCTYPE root")
+ || msg.contains("Attribute 'xml:base'")) { return; }
+ LOGGER.debug("error in validation", e);
+ CtuluAnalyze analyze = map.get(e.getSystemId());
+ if (analyze == null) {
+ analyze = res.getNewAnalyser();
+ analyze.setResource(e.getSystemId());
+ analyze.setDesc(e.getSystemId());
+ map.put(e.getSystemId(), analyze);
+
+ }
+ e.printStackTrace();
+ analyze.addErrorFromFile(CommonMessages.RESOURCE_BUNDLE.getString("valid.line") + " " + e.getLineNumber()
+ + ": " + msg, e.getLineNumber());
+ // e.printStackTrace();
+ }
+
+ @Override
+ public void fatalError(final SAXParseException e) throws SAXException {
+ error(e);
+ }
+
+ @Override
+ public void warning(final SAXParseException e) throws SAXException {
+ // e.printStackTrace();
+ }
+ };
+ // final Validator validator = schema.newValidator();
+ // // validator.s
+ // // SAXSource source = new SAXSource(new InputSource(xml.toString()));
+ // // validator.validate(source);
+ final SAXParserFactory parser = SAXParserFactory.newInstance();
+ // parser.setSchema(schema);
+ parser.setNamespaceAware(true);
+ parser.setXIncludeAware(true);
+ parser.setValidating(true);
+ final SAXParser newSAXParser = parser.newSAXParser();
+ newSAXParser.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
+ newSAXParser.setProperty(JAXP_SCHEMA_SOURCE, new InputSource(xsdURL.toString()));
+ newSAXParser.parse(new InputSource(xml.toString()), handler);
+
+ } catch (final Exception e) {
+ res.getNewAnalyser().manageException(e);
+ LOGGER.error("validation", e);
+ // e.printStackTrace();
+ }
+ return res;
+
+ }
+}
Modified: trunk/soft/fudaa-crue/dodico/src/main/resources/org/fudaa/dodico/crue/common/commonMessages.properties
===================================================================
--- trunk/soft/fudaa-crue/dodico/src/main/resources/org/fudaa/dodico/crue/common/commonMessages.properties 2009-10-23 20:34:57 UTC (rev 5448)
+++ trunk/soft/fudaa-crue/dodico/src/main/resources/org/fudaa/dodico/crue/common/commonMessages.properties 2009-10-24 01:02:21 UTC (rev 5449)
@@ -76,3 +76,4 @@
write.modele.noFound = Le mod\u00E8le {0} n''a pas \u00E9t\u00E9 trouv\u00E9 dans le sc\u00E9nario {1}
write.scenario.action = Sauvegarde du sc\u00E9nario {0}
write.sousModele.noFound = Le sous-mod\u00E8le {0} n''a pas \u00E9t\u00E9 trouv\u00E9 dans le mod\u00E8le {1}
+crue9.sameId.forDifferentNames.error=L''identifiant {0} est partag\u00E9 par plusieurs nom d''origine {1}
\ No newline at end of file
Modified: trunk/soft/fudaa-crue/dodico/src/main/resources/org/fudaa/dodico/crue/io/ioMessages.properties
===================================================================
--- trunk/soft/fudaa-crue/dodico/src/main/resources/org/fudaa/dodico/crue/io/ioMessages.properties 2009-10-23 20:34:57 UTC (rev 5448)
+++ trunk/soft/fudaa-crue/dodico/src/main/resources/org/fudaa/dodico/crue/io/ioMessages.properties 2009-10-24 01:02:21 UTC (rev 5449)
@@ -118,6 +118,9 @@
io.dh.sections.dpti.troplong.error = Les niveaux des sections de la branche {0} ne sont pas toutes \u00E9crites car cela d\u00E9passe la ligne.
io.dh.sections.ligneE2.error = Le nombre de valeurs pour la ligne E2 du fichier DH ne correspond pas au nombre de sections de la branche {0}.
io.dh.tagFINNotFound.error = Ligne {0}: la balise FIN n''a pas \u00E9t\u00E9 trouv\u00E9
+io.dh.tagFINFound.error = Ligne {0}: la balise FIN ne doit pas \u00EAtre utilis\u00E9e
+io.dh.ref.emh.ligneE2.error = Ligne {0}: la ligne ne contient pas un coupe date-valeur
+io.dh.ref.emh.ligneE2.notCroissant.error = Ligne {0}: les temps ne sont pas donn\u00E9s dans l''ordre croissant
io.dh.tdeb.notsupported.message = La date de d\u00E9but de sortie des r\u00E9sultats (d\u00E9finie dans les donn\u00E9es transitoires de crue9) n''est plus support\u00E9e sous crue10.
io.dh.unknownConlimTransitoire.error = Lecture DH : Condition \u00E0 la limite du calcul transitoire inconnue.
io.dptg.branche.ref.error = R\u00E9f\u00E9rence Branche DPTG : Impossible de trouver la Branche de r\u00E9f\u00E9rence {0}.
@@ -136,7 +139,7 @@
io.dpti.ecriture.branche.error = Ecriture DPTI : pas de condition initiale pour la branche de reference {0}.
io.dpti.ecriture.casier.error = Ecriture DPTI : pas de condition initiale pour le casier de reference {0}.
io.dpti.ecriture.noeud.error = Ecriture DPTI : pas de condition initiale pour le noeud de reference {0}.
-io.dpti.lecture.error = Lecture DPTI : Impossible de r\u00E9cup\u00E9rer les donn\u00E9es r\u00E9saux (DRSO). Les r\u00E9f\u00E9rences du fichier DPTI ne pourront etre utilis\u00E9es.
+io.dpti.lecture.error = Lecture DPTI : Impossible de r\u00E9cup\u00E9rer les donn\u00E9es r\u00E9saux (DRSO). Les r\u00E9f\u00E9rences du fichier DPTI ne pourront \u00EAtre utilis\u00E9es.
io.dpti.noeud.ref.error = Lecture DPTI : Impossible de trouver le noeud de r\u00E9f\u00E9rence {0}.
io.drso.branches.no.noeud.amont.error = Lecture DRSO : Branches: Il n''y a pas de noeud amont pour la branche {0}.
io.drso.branches.no.noeud.aval.error = Lecture DRSO : Branches: Il n''y a pas de noeud aval pour la branche {0}.
Modified: trunk/soft/fudaa-crue/dodico/src/test/java/org/fudaa/dodico/crue/io/TestCrueDC.java
===================================================================
--- trunk/soft/fudaa-crue/dodico/src/test/java/org/fudaa/dodico/crue/io/TestCrueDC.java 2009-10-23 20:34:57 UTC (rev 5448)
+++ trunk/soft/fudaa-crue/dodico/src/test/java/org/fudaa/dodico/crue/io/TestCrueDC.java 2009-10-24 01:02:21 UTC (rev 5449)
@@ -11,11 +11,7 @@
import org.fudaa.dodico.crue.io.common.CrueData;
import org.fudaa.dodico.crue.io.common.CrueIOResu;
import org.fudaa.dodico.crue.io.common.IOMessages;
-import org.fudaa.dodico.crue.metier.emh.CatEMHCasier;
-import org.fudaa.dodico.crue.metier.emh.DonFrt;
-import org.fudaa.dodico.crue.metier.emh.DonPrtGeoBatiCasier;
-import org.fudaa.dodico.crue.metier.emh.EMHSectionIdem;
-import org.fudaa.dodico.crue.metier.emh.OrdPrtGeoModeleBase;
+import org.fudaa.dodico.crue.metier.emh.*;
import org.fudaa.dodico.crue.metier.helper.EMHHelper;
import org.fudaa.dodico.crue.validation.CruePrefix;
@@ -216,7 +212,15 @@
final CrueData data = testLectureFichierDC(FICHIER_TEST_MODELE3_DC);
final EMHSectionIdem findByReference = (EMHSectionIdem) data.findSectionByReference("PROF6B");
assertEquals("PROF6A", findByReference.getSectionRef().getNom());
-
+ CatEMHBranche br1 = data.findBrancheByReference("B1");
+ assertNotNull(br1);
+ List<RelationEMHSectionDansBranche> sections = br1.getSections();
+ assertEquals(11, sections.size());
+ double x = 0;
+ for (int i = 0; i < sections.size(); i++) {
+ assertEquals(x, sections.get(i).getXp());
+ x = x + 50;
+ }
// -- ecriture --//
final File f = createTemptxtFile("modele3");
writeModeleCrue9(analyzer, f, data);
Modified: trunk/soft/fudaa-crue/dodico/src/test/java/org/fudaa/dodico/crue/io/TestCrueDH.java
===================================================================
--- trunk/soft/fudaa-crue/dodico/src/test/java/org/fudaa/dodico/crue/io/TestCrueDH.java 2009-10-23 20:34:57 UTC (rev 5448)
+++ trunk/soft/fudaa-crue/dodico/src/test/java/org/fudaa/dodico/crue/io/TestCrueDH.java 2009-10-24 01:02:21 UTC (rev 5449)
@@ -54,13 +54,19 @@
}
/**
- * @return le resultat de la lecture du modele7
+ * Test du modele 4 fourni par la CNR.
*/
+ public void testLectureSc_M4_0_v1c9() {
+ final CtuluAnalyze analyzer = new CtuluAnalyze();
+ final CrueIOResu<CrueData> readModele = readModele(analyzer, "/Etu4-0/M4-0_c9.dc", "/Etu4-0/M4-0_c9.dh");
+ testAnalyser(analyzer);
+ assertNotNull(readModele.getMetier());
+ testAnalyser(readModele.getAnalyse());
+ }
+
public void testLectureModele7() {
final CrueIOResu<CrueData> data = readModele7();
testModele7(data);
- // testData(data.getMetier(), false);
- // return data.getMetier();
}
public void testEcritureModele7() {
@@ -73,7 +79,7 @@
testAnalyser(analyse);
try {
data = readModele(analyse, fdc.toURI().toURL(), fdh.toURI().toURL());
- } catch (MalformedURLException e) {
+ } catch (final MalformedURLException e) {
e.printStackTrace();
}
testAnalyser(analyse);
@@ -241,6 +247,26 @@
return super.createTempFile();
}
+ /**
+ * Test de M3-2_c9
+ */
+ public void testLectureM3_2_c9() {
+ final CtuluAnalyze log = new CtuluAnalyze();
+ final CrueIOResu<CrueData> readModele = readModele(log, "/Etu3-2/M3-2_c9.dc", "/Etu...
[truncated message content] |