branch develop-4.x updated (714fbd6 -> 4ae1f93)
This is an automated email from the git hooks/post-receive script. New change to branch develop-4.x in repository observe. See http://git.codelutin.com/observe.git discards 714fbd6 Cacher la barre d'actions une fois l'action d'ouverture de base lancée (See #7673) discards 99af45f Ajout de la migration pour supprimer le champs datearriveeport (termine #7542) discards 51908ea Ajout d'un log pour voir le nombre de données trouvées pour chaque variable d'un rapport (See #7671) discards 80523ed Ajout d'un test pour vérifier la bonne récupération des RTP (See #7628) discards ec418d6 Correction du test sur les plages de validité d'une RTP (See #7673) discards 9b99607 Revue de l'algorithme de recherche d'une RTP (on essaye d'abord avec le sex fourni puis ensuite avec le sex indéterminé si pas trouvé (See #7673) new f495070 Revue de l'algorithme de recherche d'une RTP (on essaye d'abord avec le sex fourni puis ensuite avec le sex indéterminé si pas trouvé (See #7628) new 933d55f Correction du test sur les plages de validité d'une RTP (See #7628) new cd698df Ajout d'un test pour vérifier la bonne récupération des RTP (See #7628) new 91f6b08 Ajout d'un log pour voir le nombre de données trouvées pour chaque variable d'un rapport (See #7671) new 89e4cb7 Ajout de la migration pour supprimer le champs datearriveeport (termine #7542) new 4ae1f93 Cacher la barre d'actions une fois l'action d'ouverture de base lancée (See #7673) This update added new revisions after undoing existing revisions. That is to say, some revisions that were in the old version of the branch are not in the new version. This situation occurs when a user --force pushes a change and generates a repository containing something like this: * -- * -- B -- O -- O -- O (714fbd6) \ N -- N -- N refs/heads/develop-4.x (4ae1f93) You should already have received notification emails for all of the O revisions, and so the following emails describe only the N revisions from the common base, B. Any revisions marked "omits" are not gone; other references still refer to them. Any revisions marked "discards" are gone forever. The 6 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 4ae1f9394aa7db884c0341608be328e5a3867861 Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Nov 3 17:52:24 2015 +0100 Cacher la barre d'actions une fois l'action d'ouverture de base lancée (See #7673) commit 89e4cb7b846f01ee8845d933dc6e72ab1c16d1e6 Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Nov 3 17:25:20 2015 +0100 Ajout de la migration pour supprimer le champs datearriveeport (termine #7542) commit 91f6b08d38efbb9f7bf722f92dd7235fe948ddd6 Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Nov 3 15:39:15 2015 +0100 Ajout d'un log pour voir le nombre de données trouvées pour chaque variable d'un rapport (See #7671) commit cd698df02d5230f4cc23bac81e4621f3c69dc28f Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Nov 3 14:38:20 2015 +0100 Ajout d'un test pour vérifier la bonne récupération des RTP (See #7628) commit 933d55fbcd297a153f771d3dec98c7ea6adf983a Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Nov 3 14:37:55 2015 +0100 Correction du test sur les plages de validité d'une RTP (See #7628) commit f495070e5d842b43e905efce35bb9be20d98cd5e Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Nov 3 14:36:11 2015 +0100 Revue de l'algorithme de recherche d'une RTP (on essaye d'abord avec le sex fourni puis ensuite avec le sex indéterminé si pas trouvé (See #7628) Summary of changes: -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop-4.x in repository observe. See http://git.codelutin.com/observe.git commit f495070e5d842b43e905efce35bb9be20d98cd5e Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Nov 3 14:36:11 2015 +0100 Revue de l'algorithme de recherche d'une RTP (on essaye d'abord avec le sex fourni puis ensuite avec le sex indéterminé si pas trouvé (See #7628) --- .../src/main/java/fr/ird/observe/DataService.java | 153 ++++++++++++++------- 1 file changed, 103 insertions(+), 50 deletions(-) diff --git a/observe-business/src/main/java/fr/ird/observe/DataService.java b/observe-business/src/main/java/fr/ird/observe/DataService.java index 1588771..efb29b8 100644 --- a/observe-business/src/main/java/fr/ird/observe/DataService.java +++ b/observe-business/src/main/java/fr/ird/observe/DataService.java @@ -21,6 +21,7 @@ */ package fr.ird.observe; +import com.google.common.base.Preconditions; import com.google.common.base.Predicate; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; @@ -887,13 +888,110 @@ public class DataService { * @throws DataSourceException pour toute erreur * @since 1.5 */ - public <P extends LengthWeightParameter> P findLengthWeightParameter( + public <P extends LengthWeightParameter> P findLengthWeightParameter(TopiaContext tx, + Species species, + Ocean ocean, + Sex sex, + Date date) throws DataSourceException { + + try { + + Sex unknownSex = getUnknownSex(tx); + + if (sex == null) { + + // on utilise le sexe indéterminé + sex = unknownSex; + } + + List<P> list = findLengthWeightParameter0(tx, species, ocean, sex, date); + + if (CollectionUtils.isEmpty(list) && !unknownSex.equals(sex)) { + + // on essaye avec le sexe indéterminé + + sex = unknownSex; + + list = findLengthWeightParameter0(tx, species, ocean, sex, date); + + } + + if (CollectionUtils.isEmpty(list)) { + + return null; + + } + + + // au final il ne devrait en rester qu'un + + if (list.size() > 1) { + StringBuilder sb = new StringBuilder("Il existe plusieurs paramétrages possibles pour les données suivantes :"); + sb.append("\nEspece : "); + sb.append(getDecoratorService().decorate(species)); + sb.append("\nOcean : "); + sb.append(getDecoratorService().decorate(ocean)); + sb.append("\nSex : "); + sb.append(getDecoratorService().decorate(sex)); + sb.append("\nDate : ").append(date); + sb.append("\nParamétrages trouvés : "); + for (P p : list) { + sb.append("\n - ").append(getDecoratorService().decorate(p)); + } + throw new DataSourceException(sb.toString(), "findLengthWeightParameter"); + } + + P result = list.get(0); + if (log.isDebugEnabled()) { + StringBuilder sb = new StringBuilder("Paramétrage trouvé pour les données suivantes :"); + sb.append("\nEspece : "); + sb.append(getDecoratorService().decorate(species)); + sb.append("\nOcean : "); + sb.append(getDecoratorService().decorate(ocean)); + sb.append("\nSex : "); + sb.append(getDecoratorService().decorate(sex)); + sb.append("\nDate : ").append(date); + sb.append("\nParamétrage: ").append(getDecoratorService().decorate(result)); + log.debug(sb.toString()); + } + return result; + + } catch (Exception e) { + throw new DataSourceException(e, "findLengthWeightParameter"); + } + } + + /** + * Recherche de la liste des {@link LengthWeightParameter} à partir des paramètres donnés. + * + * La recherche peut ne peut être aussi exacte que les paramètres donnés : + * + * Dans le cas d'une espèce faune, si non trouvé alors on recherche sur son + * speciesGroup d'espèce. + * + * Si non trouvé pour l'océan donné (et que celui-ci est non null), alors on + * recherche avec un ocean vide. + * + * @param tx la transaction en cours d'utilisation + * @param species l'espèce sur lequel on recherche le paramétrage + * @param ocean l'ocean recherché (peut être null) + * @param sex le sexe recherché + * @param date le jour recherché (peut être null) + * @return la liste des paramétrages disponibles + * @throws DataSourceException pour toute erreur + * @since 1.5 + */ + public <P extends LengthWeightParameter> List<P> findLengthWeightParameter0( TopiaContext tx, Species species, Ocean ocean, Sex sex, Date date) throws DataSourceException { + Preconditions.checkNotNull(tx, "tx parameter can't be null"); + Preconditions.checkNotNull(species, "species parameter can't be null"); + Preconditions.checkNotNull(sex, "sex parameter can't be null"); + try { List<P> list = LengthWeightParemeterHelper.findBySpecies((TopiaContextImplementor) tx, species); @@ -921,21 +1019,7 @@ public class DataService { } // filtrage par sexe - List<P> filterBySexe = LengthWeightParemeterHelper.filterBySexe(list, sex); - - if (CollectionUtils.isEmpty(filterBySexe)) { - - Sex unkwonSex = getUnknownSex(tx); - - if (sex==null || unkwonSex.equals(sex)) { - - // filtrage par sexe indetermine - filterBySexe = LengthWeightParemeterHelper.filterBySexe(list, unkwonSex); - } - - list = filterBySexe; - - } + list = LengthWeightParemeterHelper.filterBySexe(list, sex); if (CollectionUtils.isEmpty(list)) { @@ -961,38 +1045,7 @@ public class DataService { return null; } - // au final il ne devrait en rester qu'un - - if (list.size() > 1) { - StringBuilder sb = new StringBuilder("Il existe plusieurs paramétrages possibles pour les données suivantes :"); - sb.append("\nEspece : "); - sb.append(getDecoratorService().decorate(species)); - sb.append("\nOcean : "); - sb.append(getDecoratorService().decorate(ocean)); - sb.append("\nSex : "); - sb.append(getDecoratorService().decorate(sex)); - sb.append("\nDate : ").append(date); - sb.append("\nParamétrages trouvés : "); - for (P p : list) { - sb.append("\n - ").append(getDecoratorService().decorate(p)); - } - throw new DataSourceException(sb.toString(), "findLengthWeightParameter"); - } - - P result = list.get(0); - if (log.isDebugEnabled()) { - StringBuilder sb = new StringBuilder("Paramétrage trouvé pour les données suivantes :"); - sb.append("\nEspece : "); - sb.append(getDecoratorService().decorate(species)); - sb.append("\nOcean : "); - sb.append(getDecoratorService().decorate(ocean)); - sb.append("\nSex : "); - sb.append(getDecoratorService().decorate(sex)); - sb.append("\nDate : ").append(date); - sb.append("\nParamétrage: ").append(getDecoratorService().decorate(result)); - log.debug(sb.toString()); - } - return result; + return list; } catch (Exception e) { throw new DataSourceException(e, "findLengthWeightParameter"); @@ -1668,7 +1721,7 @@ public class DataService { closeTransaction(source, tx, txName); } } - + public List<GearUseFeaturesMeasurementLongline> getGearUseFeaturesMeasurementLongline(DataSource source, GearUseFeaturesLongline bean, final TopiaEntityBinder<GearUseFeaturesMeasurementLongline> binder) throws DataSourceException { String txName = "getGearUseFeaturesMeasurementLongline : " + bean.getTopiaId(); @@ -1740,7 +1793,7 @@ public class DataService { } catch (TopiaException e) { throw new DataSourceException(e, txName); - } finally{ + } finally { closeTransaction(source, tx, txName); } return tripMapPoints; -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop-4.x in repository observe. See http://git.codelutin.com/observe.git commit 933d55fbcd297a153f771d3dec98c7ea6adf983a Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Nov 3 14:37:55 2015 +0100 Correction du test sur les plages de validité d'une RTP (See #7628) --- .../entities/referentiel/LengthWeightParemeterHelper.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/LengthWeightParemeterHelper.java b/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/LengthWeightParemeterHelper.java index c4bc8ec..5c101cc 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/LengthWeightParemeterHelper.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/LengthWeightParemeterHelper.java @@ -236,8 +236,10 @@ public class LengthWeightParemeterHelper { for (P parametrageLengthWeight : list) { - if (parametrageLengthWeight.getStartDate().before(startDate) || - parametrageLengthWeight.getStartDate().equals(startDate)) { + // Conversion en date (sinon c'est un timestamp qui est donné et l'égalité ne fonctionne plus) + Date startDate1 = new Date(parametrageLengthWeight.getStartDate().getTime()); + if (startDate1.before(startDate) || + startDate1.equals(startDate)) { result.add(parametrageLengthWeight); } } @@ -265,6 +267,10 @@ public class LengthWeightParemeterHelper { for (P parametrageLengthWeight : list) { Date date = parametrageLengthWeight.getEndDate(); + if (date!=null) { + // Conversion en date (sinon c'est un timestamp qui est donné et l'égalité ne fonctionne plus) + date = new Date(date.getTime()); + } if (date == null || date.after(endDate) || date.equals(endDate)) { -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop-4.x in repository observe. See http://git.codelutin.com/observe.git commit cd698df02d5230f4cc23bac81e4621f3c69dc28f Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Nov 3 14:38:20 2015 +0100 Ajout d'un test pour vérifier la bonne récupération des RTP (See #7628) --- .../LengthWeightParemeterHelperTest.java | 294 +++++++++++++++++++++ 1 file changed, 294 insertions(+) diff --git a/observe-business/src/test/java/fr/ird/observe/entities/referentiel/LengthWeightParemeterHelperTest.java b/observe-business/src/test/java/fr/ird/observe/entities/referentiel/LengthWeightParemeterHelperTest.java new file mode 100644 index 0000000..4cba24f --- /dev/null +++ b/observe-business/src/test/java/fr/ird/observe/entities/referentiel/LengthWeightParemeterHelperTest.java @@ -0,0 +1,294 @@ +/* + * #%L + * ObServe :: Entities + * %% + * Copyright (C) 2008 - 2010 IRD, Codelutin, Tony Chemit + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package fr.ird.observe.entities.referentiel; + +import fr.ird.observe.DataService; +import fr.ird.observe.IObserveConfig; +import fr.ird.observe.ObserveServiceHelper; +import fr.ird.observe.db.DBTestHelper; +import fr.ird.observe.db.DataSource; +import fr.ird.observe.db.DataSourceException; +import fr.ird.observe.entities.constants.ReferenceStatus; +import fr.ird.observe.test.TestHelper; +import fr.ird.observe.util.Scripts; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.nuiton.topia.TopiaContext; +import org.nuiton.util.DateUtil; + +import java.io.File; +import java.net.URL; +import java.util.Date; + +/** + * Test de la classe {@link LengthWeightParemeterHelper}. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 1.8 + */ +public class LengthWeightParemeterHelperTest { + + /** Logger */ + private static final Log log = LogFactory.getLog(LengthWeightParemeterHelperTest.class); + + + /** La base de test chargée à partir du la sauvegarde. */ + private static DataSource dataSource; + + private DataService dataService; + + @BeforeClass + public static void init() throws Exception { + + TestHelper.initTest(LengthWeightParemeterHelperTest.class); + + TestHelper.createApplicationContext(); + + TestHelper.setConfig(IObserveConfig.DB_VERSION, Scripts.V_LAST.toString()); + + File localDB = TestHelper.newLocalDB(TestHelper.class.getSimpleName()); + + String dbPath = Scripts.getBackupScript(Scripts.V_LAST, "referentiel"); + + URL dbUrl = LengthWeightParemeterHelperTest.class.getResource(dbPath); + + Assert.assertNotNull("could not find resource : " + dbPath, dbUrl); + + dataSource = DBTestHelper.createAndOpenFromDump( + localDB, + dbUrl, + false, + false, + true, + true, + true); + + DataService dataService = ObserveServiceHelper.get().getDataService(); + dataService.registerDataSource(dataSource); + + TopiaContext tx = dataService.beginTransaction(dataSource, "testGetCorrectLengthWeightParameter"); + + try { + + SpeciesDAO speciesDAO = (SpeciesDAO) dataSource.getDAO(tx, Species.class); + OceanDAO oceanDAO = (OceanDAO) dataSource.getDAO(tx, Ocean.class); + SexDAO sexDao = (SexDAO) dataSource.getDAO(tx, Sex.class); + + Species species = speciesDAO.findByFaoCode("DOL"); + Assert.assertNotNull("Could not find species with faoCode: DOL", species); + + Sex undeterminedSex = sexDao.findByCode("0"); + Assert.assertNotNull("Could not find sex with code 0 (Undetermined)", undeterminedSex); + + Sex maleSex = sexDao.findByCode("1"); + Assert.assertNotNull("Could not find sex with code 1 (male)", maleSex); + + Sex femaleSex = sexDao.findByCode("2"); + Assert.assertNotNull("Could not find sex with code 2 (female)", femaleSex); + + Date firstStartDate = DateUtil.createDate(1, 1, 2010); + Date firstEndDate = DateUtil.createDate(31, 12, 2010); + Date secondStartDate = DateUtil.createDate(1, 1, 2011); + + Ocean atlanticOcean = oceanDAO.findByCode("1"); + Assert.assertNotNull("Could not find ocean with code 1 (Atlantic)", atlanticOcean); + + Ocean indianOcean = oceanDAO.findByCode("2"); + Assert.assertNotNull("Could not find ocean with code 2 (Indian)", indianOcean); + + LengthWeightParameterDAO lengthWeightParameterDao = (LengthWeightParameterDAO) dataSource.getDAO(tx, LengthWeightParameter.class); + + // Ajout parametrage Male / Atlantique (2010) + createLengthWeightParameter(lengthWeightParameterDao, species, atlanticOcean, maleSex, firstStartDate, firstEndDate); + // Ajout parametrage Male / Atlantique (après 2010) + createLengthWeightParameter(lengthWeightParameterDao, species, atlanticOcean, maleSex, secondStartDate, null); + // Ajout parametrage Male / Indien (2010) + createLengthWeightParameter(lengthWeightParameterDao, species, indianOcean, maleSex, firstStartDate, firstEndDate); + // Ajout parametrage Male / Indien (Après 2010) + createLengthWeightParameter(lengthWeightParameterDao, species, indianOcean, maleSex, secondStartDate, null); + + tx.commitTransaction(); + + + } finally { + + tx.closeContext(); + + } + + } + + protected static void createLengthWeightParameter(LengthWeightParameterDAO lengthWeightParameterDao, + Species species, + Ocean ocean, + Sex sex, + Date startDate, + Date endDate) { + + LengthWeightParameter entity = lengthWeightParameterDao.newInstance(); + + entity.setSpecies(species); + entity.setSex(sex); + entity.setOcean(ocean); + entity.setStartDate(startDate); + entity.setEndDate(endDate); + entity.setStatus(ReferenceStatus.enabled); + entity.setCoefficients("a=3.8E-5:b=2.78"); + entity.setLengthWeightFormula("a * Math.pow(L, b)"); + entity.setWeightLengthFormula("Math.pow(P/a, 1/b)"); + lengthWeightParameterDao.create(entity); + + + } + + @Before + public void setUp() throws Exception { + + dataService = ObserveServiceHelper.get().getDataService(); + + } + + @After + public final void tearDown() throws Exception { + + try { + dataSource.doClose(false); + } finally { + + ObserveServiceHelper.get().close(); + ObserveServiceHelper.close(); + + } + + } + + /** + * Pour tester que l'on récupère la bonne relation. + * See http://forge.codelutin.com/issues/7628 + */ + @Test + public void testGetCorrectLengthWeightParameter() throws DataSourceException { + + + TopiaContext tx = dataService.beginTransaction(dataSource, "testGetCorrectLengthWeightParameter"); + + try { + + SpeciesDAO speciesDAO = (SpeciesDAO) dataSource.getDAO(tx, Species.class); + OceanDAO oceanDAO = (OceanDAO) dataSource.getDAO(tx, Ocean.class); + SexDAO sexDao = (SexDAO) dataSource.getDAO(tx, Sex.class); + + Species species = speciesDAO.findByFaoCode("DOL"); + Assert.assertNotNull("Could not find species with faoCode: DOL", species); + + Sex undeterminedSex = sexDao.findByCode("0"); + Assert.assertNotNull("Could not find sex with code 0 (Undetermined)", undeterminedSex); + + Sex maleSex = sexDao.findByCode("1"); + Assert.assertNotNull("Could not find sex with code 1 (male)", maleSex); + + Sex femaleSex = sexDao.findByCode("2"); + Assert.assertNotNull("Could not find sex with code 2 (female)", femaleSex); + + Date date1970 = DateUtil.createDate(1, 1, 1970); + Date date2009 = DateUtil.createDate(1, 1, 2009); + Date date2010 = DateUtil.createDate(1, 1, 2010); + Date date2011 = DateUtil.createDate(1, 1, 2011); + + Ocean atlanticOcean = oceanDAO.findByCode("1"); + Assert.assertNotNull("Could not find ocean with code 1 (Atlantic)", atlanticOcean); + + Ocean indianOcean = oceanDAO.findByCode("2"); + Assert.assertNotNull("Could not find ocean with code 2 (Indian)", indianOcean); + + Ocean pacificOcean = oceanDAO.findByCode("3"); + Assert.assertNotNull("Could not find ocean with code 3 (Pacific)", pacificOcean); + + assertFoundLengthWeightParameter(tx, species, atlanticOcean, null, undeterminedSex, date2009, date1970); + assertFoundLengthWeightParameter(tx, species, atlanticOcean, undeterminedSex, undeterminedSex, date2009, date1970); + assertFoundLengthWeightParameter(tx, species, atlanticOcean, maleSex, undeterminedSex, date2009, date1970); + assertFoundLengthWeightParameter(tx, species, atlanticOcean, femaleSex, undeterminedSex, date2009, date1970); + + assertFoundLengthWeightParameter(tx, species, atlanticOcean, null, undeterminedSex, date2010, date1970); + assertFoundLengthWeightParameter(tx, species, atlanticOcean, undeterminedSex, undeterminedSex, date2010, date1970); + assertFoundLengthWeightParameter(tx, species, atlanticOcean, maleSex, maleSex, date2010, date2010); + assertFoundLengthWeightParameter(tx, species, atlanticOcean, femaleSex, undeterminedSex, date2010, date1970); + + assertFoundLengthWeightParameter(tx, species, atlanticOcean, null, undeterminedSex, date2011, date1970); + assertFoundLengthWeightParameter(tx, species, atlanticOcean, undeterminedSex, undeterminedSex, date2011, date1970); + assertFoundLengthWeightParameter(tx, species, atlanticOcean, maleSex, maleSex, date2011, date2011); + assertFoundLengthWeightParameter(tx, species, atlanticOcean, femaleSex, undeterminedSex, date2011, date1970); + + assertFoundLengthWeightParameter(tx, species, indianOcean, null, undeterminedSex, date2009, date1970); + assertFoundLengthWeightParameter(tx, species, indianOcean, undeterminedSex, undeterminedSex, date2009, date1970); + assertFoundLengthWeightParameter(tx, species, indianOcean, maleSex, undeterminedSex, date2009, date1970); + assertFoundLengthWeightParameter(tx, species, indianOcean, femaleSex, undeterminedSex, date2009, date1970); + + assertFoundLengthWeightParameter(tx, species, indianOcean, undeterminedSex, undeterminedSex, date2010, date1970); + assertFoundLengthWeightParameter(tx, species, indianOcean, maleSex, maleSex, date2010, date2010); + assertFoundLengthWeightParameter(tx, species, indianOcean, femaleSex, undeterminedSex, date2010, date1970); + + assertFoundLengthWeightParameter(tx, species, indianOcean, undeterminedSex, undeterminedSex, date2011, date1970); + assertFoundLengthWeightParameter(tx, species, indianOcean, maleSex, maleSex, date2011, date2011); + assertFoundLengthWeightParameter(tx, species, indianOcean, femaleSex, undeterminedSex, date2011, date1970); + + assertNotFoundLengthWeightParameter(tx, species, pacificOcean, undeterminedSex, date2010); + assertNotFoundLengthWeightParameter(tx, species, pacificOcean, maleSex, date2010); + assertNotFoundLengthWeightParameter(tx, species, pacificOcean, femaleSex, date2010); + + } finally { + + tx.closeContext(); + + } + + } + + protected void assertFoundLengthWeightParameter(TopiaContext tx, Species species, Ocean ocean, Sex sex, Sex expectedSex, Date date, Date expectedStartDate) throws DataSourceException { + + if (log.isInfoEnabled()) { + log.info("Try to find length weith parameter for species " + species.getFaoCode() + " - ocean " + ocean.getLabel1() + " - sex " + (sex == null ? "null" : sex.getLabel1()) + " at " + date); + } + LengthWeightParameter lengthWeightParameter = dataService.findLengthWeightParameter(tx, species, ocean, sex, date); + + Assert.assertNotNull("length weith parameter not found for species " + species.getFaoCode() + " - ocean " + ocean.getLabel1() + " - sex " + (sex == null ? "null" : sex.getLabel1()) + " at " + date, lengthWeightParameter); + Assert.assertEquals("Expected sex is " + expectedSex.getLabel1() + " but the one found was " + lengthWeightParameter.getSex().getLabel1(), expectedSex, lengthWeightParameter.getSex()); + Date startDate = new Date(lengthWeightParameter.getStartDate().getTime()); + Assert.assertEquals("Expected startDate is " + expectedStartDate + " but the one found was " + startDate, expectedStartDate, startDate); + } + + protected void assertNotFoundLengthWeightParameter(TopiaContext tx, Species species, Ocean ocean, Sex sex, Date date) throws DataSourceException { + + if (log.isInfoEnabled()) { + log.info("Try to find length weith parameter for species " + species.getFaoCode() + " - ocean " + ocean.getLabel1() + " - sex " + (sex == null ? "null" : sex.getLabel1()) + " at " + date); + } + LengthWeightParameter lengthWeightParameter = dataService.findLengthWeightParameter(tx, species, ocean, sex, date); + + Assert.assertNull("length weith parameter should not ne found for species " + species.getFaoCode() + " - ocean " + ocean.getLabel1() + " - sex " + (sex == null ? "null" : sex.getLabel1()) + " at " + date, lengthWeightParameter); + } + +} -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop-4.x in repository observe. See http://git.codelutin.com/observe.git commit 91f6b08d38efbb9f7bf722f92dd7235fe948ddd6 Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Nov 3 15:39:15 2015 +0100 Ajout d'un log pour voir le nombre de données trouvées pour chaque variable d'un rapport (See #7671) --- .../src/main/java/fr/ird/observe/report/model/ReportExecute.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/observe-business/src/main/java/fr/ird/observe/report/model/ReportExecute.java b/observe-business/src/main/java/fr/ird/observe/report/model/ReportExecute.java index 94500ef..fc81476 100644 --- a/observe-business/src/main/java/fr/ird/observe/report/model/ReportExecute.java +++ b/observe-business/src/main/java/fr/ird/observe/report/model/ReportExecute.java @@ -244,6 +244,9 @@ public class ReportExecute { String hql = variable.getRequest(); Object[] objects = ReportRequest.getParams(hql, vars); List<?> universe = tx.findAll(hql, objects); + if (log.isInfoEnabled()) { + log.info(String.format("Found for variable %s : %d", variable.getName(), universe.size())); + } variablesUniverse.put(variable.getName(), universe); } } finally { -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop-4.x in repository observe. See http://git.codelutin.com/observe.git commit 89e4cb7b846f01ee8845d933dc6e72ab1c16d1e6 Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Nov 3 17:25:20 2015 +0100 Ajout de la migration pour supprimer le champs datearriveeport (termine #7542) --- .../src/test/resources/db/4.0.4/referentiel.sql.gz | Bin 0 -> 138244 bytes .../migration/AbstractDataSourceMigration.java | 4 +- .../DataSourceMigrationForVersion_4_0_4.java | 48 +++++++++++++++++++++ .../4.0.4/remove-trip-datearriveeport-field-H2.sql | 23 ++++++++++ .../4.0.4/remove-trip-datearriveeport-field-PG.sql | 23 ++++++++++ .../src/main/xmi/observe-common.properties | 2 +- .../src/main/xmi/observe-longline.properties | 2 +- .../src/main/xmi/observe-seine.properties | 2 +- observe-entities/src/main/xmi/observe-seine.zargo | Bin 85905 -> 85857 bytes 9 files changed, 100 insertions(+), 4 deletions(-) diff --git a/observe-business/src/test/resources/db/4.0.4/referentiel.sql.gz b/observe-business/src/test/resources/db/4.0.4/referentiel.sql.gz new file mode 100644 index 0000000..7cd9cbe Binary files /dev/null and b/observe-business/src/test/resources/db/4.0.4/referentiel.sql.gz differ diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/AbstractDataSourceMigration.java b/observe-entities/src/main/java/fr/ird/observe/entities/migration/AbstractDataSourceMigration.java index 2ea4149..4333afa 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/AbstractDataSourceMigration.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/migration/AbstractDataSourceMigration.java @@ -91,10 +91,12 @@ public abstract class AbstractDataSourceMigration extends TopiaMigrationCallback public static final Version V_4_0_2 = Versions.valueOf("4.0.2"); + public static final Version V_4_0_4 = Versions.valueOf("4.0.4"); + /** Les versions de mise à jour disponibles. */ public static final Version[] availableVersions = new Version[]{ V_3_1, V_3_5, V_3_7, V_3_8, V_3_9, V_3_10, V_3_11, V_3_12, V_3_14, V_3_15, V_3_16, V_4_0_RC2, - V_4_0_RC3, V_4_0_RC4, V_4_0_RC6, V_4_0_RC7, V_4_0, V_4_0_1, V_4_0_2 + V_4_0_RC3, V_4_0_RC4, V_4_0_RC6, V_4_0_RC7, V_4_0, V_4_0_1, V_4_0_2, V_4_0_4 }; private static Supplier<ApplicationConfig> applicationConfigSupplier; diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_4.java b/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_4.java new file mode 100644 index 0000000..46daf0a --- /dev/null +++ b/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_4.java @@ -0,0 +1,48 @@ +package fr.ird.observe.entities.migration.versions; + +import fr.ird.observe.entities.migration.AbstractDataSourceMigration; +import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; +import fr.ird.observe.entities.migration.H2DataSourceMigration; +import fr.ird.observe.entities.migration.PGDataSourceMigration; +import org.nuiton.topia.TopiaException; +import org.nuiton.topia.framework.TopiaContextImplementor; + +import java.util.List; + +/** + * Created on 03/11/15. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 4.0.4 + */ +public class DataSourceMigrationForVersion_4_0_4 extends AbstractObserveMigrationCallBack { + + public DataSourceMigrationForVersion_4_0_4(AbstractDataSourceMigration callBack, String scriptSuffix) { + super(AbstractDataSourceMigration.V_4_0_4, callBack, scriptSuffix); + } + + @Override + protected void prepareMigrationScript(TopiaContextImplementor tx, List<String> queries, boolean showSql, boolean showProgression) throws TopiaException { + + // supprimer un champs résiduel (Voir http://forge.codelutin.com/issues/7542) + addScript("remove-trip-datearriveeport-field", queries); + + } + + public static class H2DataSourceMigrationForVersion extends DataSourceMigrationForVersion_4_0_4 { + + public H2DataSourceMigrationForVersion(AbstractDataSourceMigration callBack) { + super(callBack, H2DataSourceMigration.TYPE); + } + + } + + public static class PGDataSourceMigrationForVersion extends DataSourceMigrationForVersion_4_0_4 { + + public PGDataSourceMigrationForVersion(AbstractDataSourceMigration callBack) { + super(callBack, PGDataSourceMigration.TYPE); + } + + } + +} diff --git a/observe-entities/src/main/resources/db/4.0.4/remove-trip-datearriveeport-field-H2.sql b/observe-entities/src/main/resources/db/4.0.4/remove-trip-datearriveeport-field-H2.sql new file mode 100644 index 0000000..e029d1f --- /dev/null +++ b/observe-entities/src/main/resources/db/4.0.4/remove-trip-datearriveeport-field-H2.sql @@ -0,0 +1,23 @@ +--- +-- #%L +-- ObServe :: Entities +-- %% +-- Copyright (C) 2008 - 2015 IRD, Codelutin, Tony Chemit +-- %% +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU 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 Public License for more details. +-- +-- You should have received a copy of the GNU General Public +-- License along with this program. If not, see +-- <http://www.gnu.org/licenses/gpl-3.0.html>. +-- #L% +--- + +ALTER TABLE observe_seine.trip DROP COLUMN datearriveeport; \ No newline at end of file diff --git a/observe-entities/src/main/resources/db/4.0.4/remove-trip-datearriveeport-field-PG.sql b/observe-entities/src/main/resources/db/4.0.4/remove-trip-datearriveeport-field-PG.sql new file mode 100644 index 0000000..e029d1f --- /dev/null +++ b/observe-entities/src/main/resources/db/4.0.4/remove-trip-datearriveeport-field-PG.sql @@ -0,0 +1,23 @@ +--- +-- #%L +-- ObServe :: Entities +-- %% +-- Copyright (C) 2008 - 2015 IRD, Codelutin, Tony Chemit +-- %% +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU 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 Public License for more details. +-- +-- You should have received a copy of the GNU General Public +-- License along with this program. If not, see +-- <http://www.gnu.org/licenses/gpl-3.0.html>. +-- #L% +--- + +ALTER TABLE observe_seine.trip DROP COLUMN datearriveeport; \ No newline at end of file diff --git a/observe-entities/src/main/xmi/observe-common.properties b/observe-entities/src/main/xmi/observe-common.properties index 9b32ae1..9227f7e 100644 --- a/observe-entities/src/main/xmi/observe-common.properties +++ b/observe-entities/src/main/xmi/observe-common.properties @@ -19,7 +19,7 @@ # <http://www.gnu.org/licenses/gpl-3.0.html>. # #L% ### -model.tagvalue.version=4.0.2 +model.tagvalue.version=4.0.4 model.tagvalue.notGenerateToString=true model.tagvalue.generateOperatorForDAOHelper=true model.tagvalue.generateStandaloneEnumForDAOHelper=true diff --git a/observe-entities/src/main/xmi/observe-longline.properties b/observe-entities/src/main/xmi/observe-longline.properties index 7a5450e..6187717 100644 --- a/observe-entities/src/main/xmi/observe-longline.properties +++ b/observe-entities/src/main/xmi/observe-longline.properties @@ -19,7 +19,7 @@ # <http://www.gnu.org/licenses/gpl-3.0.html>. # #L% ### -model.tagvalue.version=4.0.2 +model.tagvalue.version=4.0.4 model.tagvalue.notGenerateToString=true model.tagvalue.generateOperatorForDAOHelper=true model.tagvalue.generateStandaloneEnumForDAOHelper=true diff --git a/observe-entities/src/main/xmi/observe-seine.properties b/observe-entities/src/main/xmi/observe-seine.properties index 21d5297..650acc8 100644 --- a/observe-entities/src/main/xmi/observe-seine.properties +++ b/observe-entities/src/main/xmi/observe-seine.properties @@ -19,7 +19,7 @@ # <http://www.gnu.org/licenses/gpl-3.0.html>. # #L% ### -model.tagvalue.version=4.0.2 +model.tagvalue.version=4.0.4 model.tagvalue.notGenerateToString=true model.tagvalue.generateOperatorForDAOHelper=true model.tagvalue.generateStandaloneEnumForDAOHelper=true diff --git a/observe-entities/src/main/xmi/observe-seine.zargo b/observe-entities/src/main/xmi/observe-seine.zargo index 9116a17..d64b15c 100644 Binary files a/observe-entities/src/main/xmi/observe-seine.zargo and b/observe-entities/src/main/xmi/observe-seine.zargo differ -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop-4.x in repository observe. See http://git.codelutin.com/observe.git commit 4ae1f9394aa7db884c0341608be328e5a3867861 Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Nov 3 17:52:24 2015 +0100 Cacher la barre d'actions une fois l'action d'ouverture de base lancée (See #7673) --- .../java/fr/ird/observe/ui/storage/StorageUI.css | 4 ++++ .../java/fr/ird/observe/ui/storage/StorageUI.jaxx | 2 +- .../ird/observe/ui/storage/StorageUIHandler.java | 2 ++ .../fr/ird/observe/ui/storage/StorageUIModel.java | 24 ++++++++++++++++++++++ 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/observe-swing/src/main/java/fr/ird/observe/ui/storage/StorageUI.css b/observe-swing/src/main/java/fr/ird/observe/ui/storage/StorageUI.css index 1fb9545..173ea78 100644 --- a/observe-swing/src/main/java/fr/ird/observe/ui/storage/StorageUI.css +++ b/observe-swing/src/main/java/fr/ird/observe/ui/storage/StorageUI.css @@ -69,3 +69,7 @@ enabled:{getModel().isValidStep()}; visible:{getModel().getNextStep() == null}; } + +#actions { + visible:{!getModel().isAlreadyApplied()}; +} \ No newline at end of file diff --git a/observe-swing/src/main/java/fr/ird/observe/ui/storage/StorageUI.jaxx b/observe-swing/src/main/java/fr/ird/observe/ui/storage/StorageUI.jaxx index b46f1d1..404516d 100644 --- a/observe-swing/src/main/java/fr/ird/observe/ui/storage/StorageUI.jaxx +++ b/observe-swing/src/main/java/fr/ird/observe/ui/storage/StorageUI.jaxx @@ -161,7 +161,7 @@ void $afterCompleteSetup() { onStateChanged='if (getSelectedStep() != null) { getModel().gotoStep(getSelectedStep()); }'/> <!-- les actions --> - <Table weightx='1' fill='both' constraints='BorderLayout.SOUTH'> + <Table id='actions' weightx='1' fill='both' constraints='BorderLayout.SOUTH'> <row> <cell weightx='0.5' fill="both"> <!-- pour annuler --> diff --git a/observe-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIHandler.java b/observe-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIHandler.java index 360f72f..e74d350 100644 --- a/observe-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIHandler.java +++ b/observe-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIHandler.java @@ -317,6 +317,8 @@ public class StorageUIHandler { public void launchApply(final StorageUI ui) { + ui.getModel().setAlreadyApplied(true); + Runnable action = WizardUILancher.APPLY_DEF.getContextValue(ui); if (action == null) { diff --git a/observe-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIModel.java b/observe-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIModel.java index 5b1a8af..74635ff 100644 --- a/observe-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIModel.java +++ b/observe-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIModel.java @@ -113,6 +113,8 @@ public class StorageUIModel extends WizardModel<StorageStep> { public static final String VALID_PROPERTY_NAME = "valid"; + public static final String ALREADY_APPLIED_PROPERTY_NAME = "alreadyApplied"; + private static final char[] EMPTY_PASSWORD = new char[0]; private static final String LOGIN_REFERENTIEL = "referentiel"; @@ -133,6 +135,12 @@ public class StorageUIModel extends WizardModel<StorageStep> { protected boolean doBackup; /** + * Un drapeau pour savoir si on a déjà lancé l'action Appliquer (pour éviter le code ré-entrant). + * @since 4.0.4 + */ + protected boolean alreadyApplied; + + /** * le fichier ou effectuer la sauvegarde de la base locale si le drapeau * doBackup est active. */ @@ -207,6 +215,12 @@ public class StorageUIModel extends WizardModel<StorageStep> { securityModel = new SecurityModel(); } + @Override + public void setStep(StorageStep step) { + setAlreadyApplied(false); + super.setStep(step); + } + /** * La méthode pour initialiser le modèle à partir du context applicatif et * d'un service existant. @@ -946,6 +960,16 @@ public class StorageUIModel extends WizardModel<StorageStep> { firePropertyChange(VALID_PROPERTY_NAME, isValid()); } + public boolean isAlreadyApplied() { + return alreadyApplied; + } + + public void setAlreadyApplied(boolean alreadyApplied) { + boolean oldValue = isAlreadyApplied(); + this.alreadyApplied = alreadyApplied; + firePropertyChange(ALREADY_APPLIED_PROPERTY_NAME, oldValue, alreadyApplied); + } + public boolean isValid() { boolean result = false; if (dbMode != null) { -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.
participants (1)
-
codelutin.com scm