Tony CHEMIT pushed to branch develop at ultreiaio / ird-t3 Commits: fcbee305 by Tony CHEMIT at 2018-02-23T03:59:47+01:00 [N0.3] Rendre la conversion des catégories de poids AVDTH->T3 générique (deplacer l'ancien code dans un package legacy) (See #244) - - - - - 15 changed files: - t3-actions/src/main/java/fr/ird/t3/actions/data/level0/ConvertCatchesWeightCategoriesAction.java - t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertorProvider.java - t3-domain/src/main/java/fr/ird/t3/entities/conversion/AbstractWeightCategoryLogBookConvertor.java → t3-domain/src/main/java/fr/ird/t3/entities/conversion/legacy/AbstractWeightCategoryLogBookConvertor.java - + t3-domain/src/main/java/fr/ird/t3/entities/conversion/legacy/LegacyWeightCategoryLogBookConvertorProvider.java - t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertorFOR_OABI.java → t3-domain/src/main/java/fr/ird/t3/entities/conversion/legacy/WeightCategoryLogBookConvertorFOR_OABI.java - t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertorFOR_OABL.java → t3-domain/src/main/java/fr/ird/t3/entities/conversion/legacy/WeightCategoryLogBookConvertorFOR_OABL.java - t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertorFOR_OABO.java → t3-domain/src/main/java/fr/ird/t3/entities/conversion/legacy/WeightCategoryLogBookConvertorFOR_OABO.java - t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertorFOR_OIBI.java → t3-domain/src/main/java/fr/ird/t3/entities/conversion/legacy/WeightCategoryLogBookConvertorFOR_OIBI.java - t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertorFOR_OIBL.java → t3-domain/src/main/java/fr/ird/t3/entities/conversion/legacy/WeightCategoryLogBookConvertorFOR_OIBL.java - t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertorFOR_OIBO.java → t3-domain/src/main/java/fr/ird/t3/entities/conversion/legacy/WeightCategoryLogBookConvertorFOR_OIBO.java - t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertorFOR_OPBI.java → t3-domain/src/main/java/fr/ird/t3/entities/conversion/legacy/WeightCategoryLogBookConvertorFOR_OPBI.java - t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertorFOR_OPBL.java → t3-domain/src/main/java/fr/ird/t3/entities/conversion/legacy/WeightCategoryLogBookConvertorFOR_OPBL.java - t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertorFOR_OPBO.java → t3-domain/src/main/java/fr/ird/t3/entities/conversion/legacy/WeightCategoryLogBookConvertorFOR_OPBO.java - t3-domain/src/test/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertorProviderTest.java → t3-domain/src/test/java/fr/ird/t3/entities/conversion/legacy/LegacyWeightCategoryLogBookConvertorProviderTest.java - t3-domain/src/test/java/fr/ird/t3/services/migration/T3MigrationTest.java Changes: ===================================== t3-actions/src/main/java/fr/ird/t3/actions/data/level0/ConvertCatchesWeightCategoriesAction.java ===================================== --- a/t3-actions/src/main/java/fr/ird/t3/actions/data/level0/ConvertCatchesWeightCategoriesAction.java +++ b/t3-actions/src/main/java/fr/ird/t3/actions/data/level0/ConvertCatchesWeightCategoriesAction.java @@ -20,11 +20,11 @@ */ package fr.ird.t3.actions.data.level0; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Multimap; import fr.ird.t3.entities.conversion.WeightCategoryLogBookConvertor; import fr.ird.t3.entities.conversion.WeightCategoryLogBookConvertorProvider; +import fr.ird.t3.entities.conversion.legacy.LegacyWeightCategoryLogBookConvertorProvider; import fr.ird.t3.entities.data.Activity; import fr.ird.t3.entities.data.CorrectedElementaryCatch; import fr.ird.t3.entities.data.CorrectedElementaryCatchTopiaDao; @@ -37,15 +37,16 @@ import fr.ird.t3.entities.reference.SpeciesTopiaDao; import fr.ird.t3.entities.reference.WeightCategoryLogBook; import fr.ird.t3.entities.reference.WeightCategoryTreatment; import fr.ird.t3.services.ioc.InjectDAO; -import java.util.Collection; -import java.util.List; -import java.util.Map; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.topia.persistence.TopiaException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; import static org.nuiton.i18n.I18n.l; @@ -59,16 +60,11 @@ import static org.nuiton.i18n.I18n.l; */ public class ConvertCatchesWeightCategoriesAction extends AbstractLevel0Action<ConvertCatchesWeightCategoriesConfiguration> { - /** Logger. */ - private static final Log log = LogFactory.getLog( - ConvertCatchesWeightCategoriesAction.class); - + private static final Log log = LogFactory.getLog(ConvertCatchesWeightCategoriesAction.class); + Map<Species, CatchWeightResult> specieWeightResult; @InjectDAO(entityType = CorrectedElementaryCatch.class) - protected CorrectedElementaryCatchTopiaDao correctedElementaryCatchDAO; - - protected WeightCategoryLogBookConvertorProvider convertorProvider; - - protected Map<Species, CatchWeightResult> specieWeightResult; + private CorrectedElementaryCatchTopiaDao correctedElementaryCatchDAO; + private WeightCategoryLogBookConvertorProvider convertorProvider; public ConvertCatchesWeightCategoriesAction() { super(Level0Step.CONVERT_CATCHES_WEIGHT_CATEGORIES); @@ -82,7 +78,7 @@ public class ConvertCatchesWeightCategoriesAction extends AbstractLevel0Action<C return specieWeightResult.get(species); } - protected CatchWeightResult getCatchWeithResult(Map<Species, CatchWeightResult> specieWeightResult, Species species) { + private CatchWeightResult getCatchWeithResult(Map<Species, CatchWeightResult> specieWeightResult, Species species) { CatchWeightResult result = specieWeightResult.get(species); if (result == null) { result = new CatchWeightResult(); @@ -96,8 +92,7 @@ public class ConvertCatchesWeightCategoriesAction extends AbstractLevel0Action<C super.prepareAction(); - setConvertorProvider( - WeightCategoryLogBookConvertorProvider.newInstance(getT3TopiaPersistenceContext().get())); + setConvertorProvider(LegacyWeightCategoryLogBookConvertorProvider.newInstance(getT3TopiaPersistenceContext().get())); List<Trip> tripList = getUsableTrips(null, true); setTrips(tripList); @@ -130,7 +125,7 @@ public class ConvertCatchesWeightCategoriesAction extends AbstractLevel0Action<C return result; } - protected boolean executeForTrip(Trip trip) throws TopiaException { + private boolean executeForTrip(Trip trip) throws TopiaException { incrementsProgression(); @@ -162,22 +157,19 @@ public class ConvertCatchesWeightCategoriesAction extends AbstractLevel0Action<C } if (log.isInfoEnabled()) { - log.info("Treat activity " + activity.getDate() + - " with " + activity.sizeElementaryCatch()); + log.info(String.format("Treat activity %s with %d", activity.getDate(), activity.sizeElementaryCatch())); } Ocean currentOcean = activity.getOcean(); SchoolType schoolType = activity.getSchoolType(); // get converter for this ocean and school type - WeightCategoryLogBookConvertor converter = - convertorProvider.getConvertor(currentOcean, schoolType); + WeightCategoryLogBookConvertor converter = convertorProvider.getConvertor(currentOcean, schoolType); if (converter == null) { // can not redistribute if no weight categories found message = l(locale, "t3.level0.convertCatchesWeightCategories.warning.noconvertor.found", - currentOcean.getLabel1(), - schoolType.getLabel1()); + currentOcean.getLabel1(), schoolType.getLabel1()); if (log.isWarnEnabled()) { log.warn(message); } @@ -185,33 +177,24 @@ public class ConvertCatchesWeightCategoriesAction extends AbstractLevel0Action<C continue; } - if (log.isDebugEnabled()) { - log.debug("Use converter " + converter); - } - // split catches by species - Multimap<Species, ElementaryCatch> catchesBySpecie = - SpeciesTopiaDao.groupBySpecies(activity.getElementaryCatch()); + Multimap<Species, ElementaryCatch> catchesBySpecie = SpeciesTopiaDao.groupBySpecies(activity.getElementaryCatch()); for (Species species : catchesBySpecie.keySet()) { - CatchWeightResult catchWeightResult = - getCatchWeithResult(tripResult, species); + CatchWeightResult catchWeightResult = getCatchWeithResult(tripResult, species); - Collection<ElementaryCatch> catches = - catchesBySpecie.get(species); + Collection<ElementaryCatch> catches = catchesBySpecie.get(species); catchWeightResult.addLogBookWeight(catches); if (log.isInfoEnabled()) { - log.info("Treat species " + species.getCode() + " with " + - catches.size() + " catches"); + log.info(String.format("Treat species %d with %d catches", species.getCode(), catches.size())); } // converts to weight category treatment for this species - Map<WeightCategoryTreatment, Float> distribution = - converter.distribute(species, catches); + Map<WeightCategoryTreatment, Float> distribution = converter.distribute(species, catches); if (MapUtils.isEmpty(distribution)) { @@ -219,20 +202,17 @@ public class ConvertCatchesWeightCategoriesAction extends AbstractLevel0Action<C continue; } - Collection<CorrectedElementaryCatch> newCatches = - Lists.newArrayList(); + Collection<CorrectedElementaryCatch> newCatches = new ArrayList<>(); // create new catches - for (Map.Entry<WeightCategoryTreatment, Float> e2 : - distribution.entrySet()) { + for (Map.Entry<WeightCategoryTreatment, Float> e2 : distribution.entrySet()) { WeightCategoryTreatment weightCategoryTreatment = e2.getKey(); Float weight = e2.getValue(); CorrectedElementaryCatch correctedElementaryCatch = correctedElementaryCatchDAO.create( CorrectedElementaryCatch.PROPERTY_WEIGHT_CATEGORY_TREATMENT, weightCategoryTreatment, CorrectedElementaryCatch.PROPERTY_SPECIES, species, - CorrectedElementaryCatch.PROPERTY_CATCH_WEIGHT, weight - ); + CorrectedElementaryCatch.PROPERTY_CATCH_WEIGHT, weight); newCatches.add(correctedElementaryCatch); } @@ -272,15 +252,14 @@ public class ConvertCatchesWeightCategoriesAction extends AbstractLevel0Action<C return true; } - public void setConvertorProvider(WeightCategoryLogBookConvertorProvider convertorProvider) { + private void setConvertorProvider(WeightCategoryLogBookConvertorProvider convertorProvider) { this.convertorProvider = convertorProvider; } public static class CatchWeightResult { - protected float logBookTotalWeight; - - protected float treatmentTotalWeight; + float logBookTotalWeight; + float treatmentTotalWeight; public float getLogBookTotalWeight() { return logBookTotalWeight; ===================================== t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertorProvider.java ===================================== --- a/t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertorProvider.java +++ b/t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertorProvider.java @@ -8,28 +8,27 @@ * it under the terms of the GNU Affero 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 Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% */ package fr.ird.t3.entities.conversion; -import com.google.common.base.Preconditions; -import com.google.common.collect.Lists; -import fr.ird.t3.entities.T3TopiaPersistenceContext; import fr.ird.t3.entities.reference.Ocean; import fr.ird.t3.entities.reference.SchoolType; import fr.ird.t3.entities.reference.WeightCategoryTreatment; import fr.ird.t3.entities.reference.WeightCategoryTreatmentTopiaDao; -import java.util.Collection; import org.nuiton.topia.persistence.TopiaException; +import java.util.Collection; +import java.util.Objects; + /** * To obtain a ll available wieght convertors. * @@ -38,157 +37,23 @@ import org.nuiton.topia.persistence.TopiaException; */ public class WeightCategoryLogBookConvertorProvider { - protected static final String OCEAN = - WeightCategoryTreatment.PROPERTY_OCEAN + "." + Ocean.PROPERTY_CODE; - - protected static final String SCHOOL_TYPE = - WeightCategoryTreatment.PROPERTY_SCHOOL_TYPE + "." + - SchoolType.PROPERTY_CODE; - - protected final Collection<WeightCategoryLogBookConvertor> convertors; - - public static final int OA = 1; - - public static final int OI = 2; - - public static final int OP = 5; - - public static final int BO = 1; - - public static final int BL = 2; - - public static final int BI = 3; - - public static WeightCategoryLogBookConvertorProvider newInstance(T3TopiaPersistenceContext transaction) throws TopiaException { - - WeightCategoryTreatmentTopiaDao dao = transaction.getWeightCategoryTreatmentDao(); - - Collection<WeightCategoryLogBookConvertor> converters = - Lists.newArrayList(); - - // BO = 1, BL = 2, BI = 3 - // OA = 1, OI = 2, OP = 5 - - prepareForOA(dao, converters); - prepareForOI(dao, converters); - prepareForOP(dao, converters); - - return new WeightCategoryLogBookConvertorProvider(converters); - } - - private static void prepareForOA(WeightCategoryTreatmentTopiaDao dao, - Collection<WeightCategoryLogBookConvertor> converters) throws TopiaException { - { - // BO Convertor - WeightCategoryLogBookConvertor convertor = - new WeightCategoryLogBookConvertorFOR_OABO( - getCategory(dao, OA, BO, null, null), - getCategory(dao, OA, BO, 0, 10), - getCategory(dao, OA, BO, 10, null) - ); - converters.add(convertor); - } - { - // BL Convertor - WeightCategoryLogBookConvertor convertor = - new WeightCategoryLogBookConvertorFOR_OABL( - getCategory(dao, OA, BL, null, null), - getCategory(dao, OA, BL, 0, 10), - getCategory(dao, OA, BL, 10, 30), - getCategory(dao, OA, BL, 30, null) - ); - converters.add(convertor); - } - { - // BI Convertor - WeightCategoryLogBookConvertor convertor = - new WeightCategoryLogBookConvertorFOR_OABI( - getCategory(dao, OA, BI, null, null), - getCategory(dao, OA, BI, 0, 10), - getCategory(dao, OA, BI, 10, 30), - getCategory(dao, OA, BI, 30, null) - ); - converters.add(convertor); - } - - } - - private static void prepareForOI(WeightCategoryTreatmentTopiaDao dao, - Collection<WeightCategoryLogBookConvertor> converters) throws TopiaException { - - { - // BO Convertor - WeightCategoryLogBookConvertor convertor = - new WeightCategoryLogBookConvertorFOR_OIBO( - getCategory(dao, OI, BO, null, null), - getCategory(dao, OI, BO, 0, 10), - getCategory(dao, OI, BO, 10, null) - ); - converters.add(convertor); - } - { - // BL Convertor - WeightCategoryLogBookConvertor convertor = - new WeightCategoryLogBookConvertorFOR_OIBL( - getCategory(dao, OI, BL, null, null), - getCategory(dao, OI, BL, 0, 10), - getCategory(dao, OI, BL, 10, null) - ); - converters.add(convertor); - } - { - // BI Convertor - WeightCategoryLogBookConvertor convertor = - new WeightCategoryLogBookConvertorFOR_OIBI( - getCategory(dao, OI, BI, null, null), - getCategory(dao, OI, BI, 0, 10), - getCategory(dao, OI, BI, 10, null) - ); - converters.add(convertor); - } - } - - private static void prepareForOP(WeightCategoryTreatmentTopiaDao dao, - Collection<WeightCategoryLogBookConvertor> converters) throws TopiaException { - - { - // BO Convertor - WeightCategoryLogBookConvertor convertor = - new WeightCategoryLogBookConvertorFOR_OPBO( - getCategory(dao, OP, BO, null, null), - getCategory(dao, OP, BO, 0, 10), - getCategory(dao, OP, BO, 10, null) - ); - converters.add(convertor); - } - { - // BL Convertor - WeightCategoryLogBookConvertor convertor = - new WeightCategoryLogBookConvertorFOR_OPBL( - getCategory(dao, OP, BL, null, null), - getCategory(dao, OP, BL, 0, 10), - getCategory(dao, OP, BL, 10, null) - ); - converters.add(convertor); - } - { - // BI Convertor - WeightCategoryLogBookConvertor convertor = - new WeightCategoryLogBookConvertorFOR_OPBI( - getCategory(dao, OP, BI, null, null), - getCategory(dao, OP, BI, 0, 10), - getCategory(dao, OP, BI, 10, null) - ); - converters.add(convertor); - } - } + private final Collection<WeightCategoryLogBookConvertor> convertors; protected WeightCategoryLogBookConvertorProvider(Collection<WeightCategoryLogBookConvertor> convertors) { this.convertors = convertors; } - public WeightCategoryLogBookConvertor getConvertor(Ocean ocean, - SchoolType schoolType) { + protected static WeightCategoryTreatment getCategory(WeightCategoryTreatmentTopiaDao dao, + int oceanCode, + int schoolTypeCode, + Integer min, + Integer max) throws TopiaException { + WeightCategoryTreatment result = dao.findByOceanSchoolTypeAndBound(oceanCode, schoolTypeCode, min, max); + return Objects.requireNonNull(result, + String.format("Could not find weight treatment category with parameters : [ocean:%d, schoolType:%d, min:%d, max:%d]", oceanCode, schoolTypeCode, min, max)); + } + + public WeightCategoryLogBookConvertor getConvertor(Ocean ocean, SchoolType schoolType) { WeightCategoryLogBookConvertor result = null; for (WeightCategoryLogBookConvertor converter : convertors) { if (converter.accept(ocean, schoolType)) { @@ -198,26 +63,4 @@ public class WeightCategoryLogBookConvertorProvider { } return result; } - - private static WeightCategoryTreatment getCategory(WeightCategoryTreatmentTopiaDao dao, - int oceanCode, - int schoolTypeCode, - Integer min, - Integer max) throws TopiaException { - - WeightCategoryTreatment result = dao.findByOceanSchoolTypeAndBound( - oceanCode, - schoolTypeCode, - min, - max - ); - - Preconditions.checkNotNull( - result, - "Could not find weight treatment category with " + - "parameters : [ocean:" + oceanCode + ", schoolType:" + - schoolTypeCode + ", min:" + min + ", max:" + max + "]" - ); - return result; - } } ===================================== t3-domain/src/main/java/fr/ird/t3/entities/conversion/AbstractWeightCategoryLogBookConvertor.java → t3-domain/src/main/java/fr/ird/t3/entities/conversion/legacy/AbstractWeightCategoryLogBookConvertor.java ===================================== --- a/t3-domain/src/main/java/fr/ird/t3/entities/conversion/AbstractWeightCategoryLogBookConvertor.java +++ b/t3-domain/src/main/java/fr/ird/t3/entities/conversion/legacy/AbstractWeightCategoryLogBookConvertor.java @@ -18,8 +18,9 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% */ -package fr.ird.t3.entities.conversion; +package fr.ird.t3.entities.conversion.legacy; +import fr.ird.t3.entities.conversion.WeightCategoryLogBookConvertor; import fr.ird.t3.entities.data.ElementaryCatch; import fr.ird.t3.entities.reference.Ocean; import fr.ird.t3.entities.reference.SchoolType; ===================================== t3-domain/src/main/java/fr/ird/t3/entities/conversion/legacy/LegacyWeightCategoryLogBookConvertorProvider.java ===================================== --- /dev/null +++ b/t3-domain/src/main/java/fr/ird/t3/entities/conversion/legacy/LegacyWeightCategoryLogBookConvertorProvider.java @@ -0,0 +1,176 @@ +/* + * #%L + * T3 :: Domain + * %% + * Copyright (C) 2010 - 2017 IRD, Code Lutin, Ultreia.io + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package fr.ird.t3.entities.conversion.legacy; + +import com.google.common.collect.Lists; +import fr.ird.t3.entities.T3TopiaPersistenceContext; +import fr.ird.t3.entities.conversion.WeightCategoryLogBookConvertor; +import fr.ird.t3.entities.conversion.WeightCategoryLogBookConvertorProvider; +import fr.ird.t3.entities.reference.WeightCategoryTreatmentTopiaDao; +import org.nuiton.topia.persistence.TopiaException; + +import java.util.Collection; + +/** + * To obtain a ll available wieght convertors. + * + * @author Tony Chemit - dev@tchemit.fr + * @since 1.0 + */ +public class LegacyWeightCategoryLogBookConvertorProvider extends WeightCategoryLogBookConvertorProvider { + + public static final int OA = 1; + public static final int OI = 2; + public static final int OP = 5; + public static final int BO = 1; + public static final int BL = 2; + public static final int BI = 3; + + private LegacyWeightCategoryLogBookConvertorProvider(Collection<WeightCategoryLogBookConvertor> convertors) { + super(convertors); + } + + public static WeightCategoryLogBookConvertorProvider newInstance(T3TopiaPersistenceContext transaction) throws TopiaException { + + WeightCategoryTreatmentTopiaDao dao = transaction.getWeightCategoryTreatmentDao(); + + Collection<WeightCategoryLogBookConvertor> converters = + Lists.newArrayList(); + + // BO = 1, BL = 2, BI = 3 + // OA = 1, OI = 2, OP = 5 + + prepareForOA(dao, converters); + prepareForOI(dao, converters); + prepareForOP(dao, converters); + + return new LegacyWeightCategoryLogBookConvertorProvider(converters); + } + + private static void prepareForOA(WeightCategoryTreatmentTopiaDao dao, + Collection<WeightCategoryLogBookConvertor> converters) throws TopiaException { + { + // BO Convertor + WeightCategoryLogBookConvertor convertor = + new WeightCategoryLogBookConvertorFOR_OABO( + getCategory(dao, OA, BO, null, null), + getCategory(dao, OA, BO, 0, 10), + getCategory(dao, OA, BO, 10, null) + ); + converters.add(convertor); + } + { + // BL Convertor + WeightCategoryLogBookConvertor convertor = + new WeightCategoryLogBookConvertorFOR_OABL( + getCategory(dao, OA, BL, null, null), + getCategory(dao, OA, BL, 0, 10), + getCategory(dao, OA, BL, 10, 30), + getCategory(dao, OA, BL, 30, null) + ); + converters.add(convertor); + } + { + // BI Convertor + WeightCategoryLogBookConvertor convertor = + new WeightCategoryLogBookConvertorFOR_OABI( + getCategory(dao, OA, BI, null, null), + getCategory(dao, OA, BI, 0, 10), + getCategory(dao, OA, BI, 10, 30), + getCategory(dao, OA, BI, 30, null) + ); + converters.add(convertor); + } + + } + + private static void prepareForOI(WeightCategoryTreatmentTopiaDao dao, + Collection<WeightCategoryLogBookConvertor> converters) throws TopiaException { + + { + // BO Convertor + WeightCategoryLogBookConvertor convertor = + new WeightCategoryLogBookConvertorFOR_OIBO( + getCategory(dao, OI, BO, null, null), + getCategory(dao, OI, BO, 0, 10), + getCategory(dao, OI, BO, 10, null) + ); + converters.add(convertor); + } + { + // BL Convertor + WeightCategoryLogBookConvertor convertor = + new WeightCategoryLogBookConvertorFOR_OIBL( + getCategory(dao, OI, BL, null, null), + getCategory(dao, OI, BL, 0, 10), + getCategory(dao, OI, BL, 10, null) + ); + converters.add(convertor); + } + { + // BI Convertor + WeightCategoryLogBookConvertor convertor = + new WeightCategoryLogBookConvertorFOR_OIBI( + getCategory(dao, OI, BI, null, null), + getCategory(dao, OI, BI, 0, 10), + getCategory(dao, OI, BI, 10, null) + ); + converters.add(convertor); + } + } + + private static void prepareForOP(WeightCategoryTreatmentTopiaDao dao, + Collection<WeightCategoryLogBookConvertor> converters) throws TopiaException { + + { + // BO Convertor + WeightCategoryLogBookConvertor convertor = + new WeightCategoryLogBookConvertorFOR_OPBO( + getCategory(dao, OP, BO, null, null), + getCategory(dao, OP, BO, 0, 10), + getCategory(dao, OP, BO, 10, null) + ); + converters.add(convertor); + } + { + // BL Convertor + WeightCategoryLogBookConvertor convertor = + new WeightCategoryLogBookConvertorFOR_OPBL( + getCategory(dao, OP, BL, null, null), + getCategory(dao, OP, BL, 0, 10), + getCategory(dao, OP, BL, 10, null) + ); + converters.add(convertor); + } + { + // BI Convertor + WeightCategoryLogBookConvertor convertor = + new WeightCategoryLogBookConvertorFOR_OPBI( + getCategory(dao, OP, BI, null, null), + getCategory(dao, OP, BI, 0, 10), + getCategory(dao, OP, BI, 10, null) + ); + converters.add(convertor); + } + } + + +} ===================================== t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertorFOR_OABI.java → t3-domain/src/main/java/fr/ird/t3/entities/conversion/legacy/WeightCategoryLogBookConvertorFOR_OABI.java ===================================== --- a/t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertorFOR_OABI.java +++ b/t3-domain/src/main/java/fr/ird/t3/entities/conversion/legacy/WeightCategoryLogBookConvertorFOR_OABI.java @@ -18,7 +18,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% */ -package fr.ird.t3.entities.conversion; +package fr.ird.t3.entities.conversion.legacy; import fr.ird.t3.entities.data.ElementaryCatch; import fr.ird.t3.entities.reference.Species; @@ -47,7 +47,7 @@ public class WeightCategoryLogBookConvertorFOR_OABI extends AbstractWeightCatego WeightCategoryTreatment plus10Category, WeightCategoryTreatment plus30Category) { - super(WeightCategoryLogBookConvertorProvider.OA, WeightCategoryLogBookConvertorProvider.BI, minus10Category, unknownCategory); + super(LegacyWeightCategoryLogBookConvertorProvider.OA, LegacyWeightCategoryLogBookConvertorProvider.BI, minus10Category, unknownCategory); this.plus10Category = plus10Category; this.plus30Category = plus30Category; } ===================================== t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertorFOR_OABL.java → t3-domain/src/main/java/fr/ird/t3/entities/conversion/legacy/WeightCategoryLogBookConvertorFOR_OABL.java ===================================== --- a/t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertorFOR_OABL.java +++ b/t3-domain/src/main/java/fr/ird/t3/entities/conversion/legacy/WeightCategoryLogBookConvertorFOR_OABL.java @@ -18,7 +18,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% */ -package fr.ird.t3.entities.conversion; +package fr.ird.t3.entities.conversion.legacy; import com.google.common.collect.Maps; import fr.ird.t3.entities.data.ElementaryCatch; @@ -45,8 +45,8 @@ public class WeightCategoryLogBookConvertorFOR_OABL extends AbstractWeightCatego WeightCategoryTreatment plus10Category, WeightCategoryTreatment plus30Category) { - super(WeightCategoryLogBookConvertorProvider.OA, - WeightCategoryLogBookConvertorProvider.BL, + super(LegacyWeightCategoryLogBookConvertorProvider.OA, + LegacyWeightCategoryLogBookConvertorProvider.BL, minus10Category, unknownCategory); this.plus10Category = plus10Category; this.plus30Category = plus30Category; ===================================== t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertorFOR_OABO.java → t3-domain/src/main/java/fr/ird/t3/entities/conversion/legacy/WeightCategoryLogBookConvertorFOR_OABO.java ===================================== --- a/t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertorFOR_OABO.java +++ b/t3-domain/src/main/java/fr/ird/t3/entities/conversion/legacy/WeightCategoryLogBookConvertorFOR_OABO.java @@ -18,7 +18,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% */ -package fr.ird.t3.entities.conversion; +package fr.ird.t3.entities.conversion.legacy; import com.google.common.collect.Maps; import fr.ird.t3.entities.data.ElementaryCatch; @@ -42,8 +42,8 @@ public class WeightCategoryLogBookConvertorFOR_OABO extends AbstractWeightCatego WeightCategoryTreatment minus10Category, WeightCategoryTreatment plus10Category) { - super(WeightCategoryLogBookConvertorProvider.OA, - WeightCategoryLogBookConvertorProvider.BO, + super(LegacyWeightCategoryLogBookConvertorProvider.OA, + LegacyWeightCategoryLogBookConvertorProvider.BO, minus10Category, unknownCategory); this.plus10Category = plus10Category; } ===================================== t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertorFOR_OIBI.java → t3-domain/src/main/java/fr/ird/t3/entities/conversion/legacy/WeightCategoryLogBookConvertorFOR_OIBI.java ===================================== --- a/t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertorFOR_OIBI.java +++ b/t3-domain/src/main/java/fr/ird/t3/entities/conversion/legacy/WeightCategoryLogBookConvertorFOR_OIBI.java @@ -18,7 +18,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% */ -package fr.ird.t3.entities.conversion; +package fr.ird.t3.entities.conversion.legacy; import fr.ird.t3.entities.data.ElementaryCatch; import fr.ird.t3.entities.reference.Species; @@ -44,8 +44,8 @@ public class WeightCategoryLogBookConvertorFOR_OIBI extends AbstractWeightCatego WeightCategoryTreatment minus10Category, WeightCategoryTreatment plus10Category) { - super(WeightCategoryLogBookConvertorProvider.OI, - WeightCategoryLogBookConvertorProvider.BI, + super(LegacyWeightCategoryLogBookConvertorProvider.OI, + LegacyWeightCategoryLogBookConvertorProvider.BI, minus10Category, unknownCategory); this.plus10Category = plus10Category; } ===================================== t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertorFOR_OIBL.java → t3-domain/src/main/java/fr/ird/t3/entities/conversion/legacy/WeightCategoryLogBookConvertorFOR_OIBL.java ===================================== --- a/t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertorFOR_OIBL.java +++ b/t3-domain/src/main/java/fr/ird/t3/entities/conversion/legacy/WeightCategoryLogBookConvertorFOR_OIBL.java @@ -18,7 +18,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% */ -package fr.ird.t3.entities.conversion; +package fr.ird.t3.entities.conversion.legacy; import com.google.common.collect.Maps; import fr.ird.t3.entities.data.ElementaryCatch; @@ -42,8 +42,8 @@ public class WeightCategoryLogBookConvertorFOR_OIBL extends AbstractWeightCatego WeightCategoryTreatment minus10Category, WeightCategoryTreatment plus10Category) { - super(WeightCategoryLogBookConvertorProvider.OI, - WeightCategoryLogBookConvertorProvider.BL, + super(LegacyWeightCategoryLogBookConvertorProvider.OI, + LegacyWeightCategoryLogBookConvertorProvider.BL, minus10Category, unknownCategory); this.plus10Category = plus10Category; } ===================================== t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertorFOR_OIBO.java → t3-domain/src/main/java/fr/ird/t3/entities/conversion/legacy/WeightCategoryLogBookConvertorFOR_OIBO.java ===================================== --- a/t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertorFOR_OIBO.java +++ b/t3-domain/src/main/java/fr/ird/t3/entities/conversion/legacy/WeightCategoryLogBookConvertorFOR_OIBO.java @@ -18,7 +18,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% */ -package fr.ird.t3.entities.conversion; +package fr.ird.t3.entities.conversion.legacy; import com.google.common.collect.Maps; import fr.ird.t3.entities.data.ElementaryCatch; @@ -42,8 +42,8 @@ public class WeightCategoryLogBookConvertorFOR_OIBO extends AbstractWeightCatego WeightCategoryTreatment minus10Category, WeightCategoryTreatment plus10Category) { - super(WeightCategoryLogBookConvertorProvider.OI, - WeightCategoryLogBookConvertorProvider.BO, + super(LegacyWeightCategoryLogBookConvertorProvider.OI, + LegacyWeightCategoryLogBookConvertorProvider.BO, minus10Category, unknownCategory); this.plus10Category = plus10Category; } ===================================== t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertorFOR_OPBI.java → t3-domain/src/main/java/fr/ird/t3/entities/conversion/legacy/WeightCategoryLogBookConvertorFOR_OPBI.java ===================================== --- a/t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertorFOR_OPBI.java +++ b/t3-domain/src/main/java/fr/ird/t3/entities/conversion/legacy/WeightCategoryLogBookConvertorFOR_OPBI.java @@ -18,7 +18,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% */ -package fr.ird.t3.entities.conversion; +package fr.ird.t3.entities.conversion.legacy; import com.google.common.collect.Maps; import fr.ird.t3.entities.data.ElementaryCatch; @@ -42,8 +42,8 @@ public class WeightCategoryLogBookConvertorFOR_OPBI extends AbstractWeightCatego WeightCategoryTreatment minus10Category, WeightCategoryTreatment plus10Category) { - super(WeightCategoryLogBookConvertorProvider.OP, - WeightCategoryLogBookConvertorProvider.BI, + super(LegacyWeightCategoryLogBookConvertorProvider.OP, + LegacyWeightCategoryLogBookConvertorProvider.BI, minus10Category, unknownCategory); this.plus10Category = plus10Category; } ===================================== t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertorFOR_OPBL.java → t3-domain/src/main/java/fr/ird/t3/entities/conversion/legacy/WeightCategoryLogBookConvertorFOR_OPBL.java ===================================== --- a/t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertorFOR_OPBL.java +++ b/t3-domain/src/main/java/fr/ird/t3/entities/conversion/legacy/WeightCategoryLogBookConvertorFOR_OPBL.java @@ -18,7 +18,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% */ -package fr.ird.t3.entities.conversion; +package fr.ird.t3.entities.conversion.legacy; import com.google.common.collect.Maps; import fr.ird.t3.entities.data.ElementaryCatch; @@ -42,8 +42,8 @@ public class WeightCategoryLogBookConvertorFOR_OPBL extends AbstractWeightCatego WeightCategoryTreatment minus10Category, WeightCategoryTreatment plus10Category) { - super(WeightCategoryLogBookConvertorProvider.OP, - WeightCategoryLogBookConvertorProvider.BL, + super(LegacyWeightCategoryLogBookConvertorProvider.OP, + LegacyWeightCategoryLogBookConvertorProvider.BL, minus10Category, unknownCategory); this.plus10Category = plus10Category; } ===================================== t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertorFOR_OPBO.java → t3-domain/src/main/java/fr/ird/t3/entities/conversion/legacy/WeightCategoryLogBookConvertorFOR_OPBO.java ===================================== --- a/t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertorFOR_OPBO.java +++ b/t3-domain/src/main/java/fr/ird/t3/entities/conversion/legacy/WeightCategoryLogBookConvertorFOR_OPBO.java @@ -18,7 +18,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% */ -package fr.ird.t3.entities.conversion; +package fr.ird.t3.entities.conversion.legacy; import com.google.common.collect.Maps; import fr.ird.t3.entities.data.ElementaryCatch; @@ -42,8 +42,8 @@ public class WeightCategoryLogBookConvertorFOR_OPBO extends AbstractWeightCatego WeightCategoryTreatment minus10Category, WeightCategoryTreatment plus10Category) { - super(WeightCategoryLogBookConvertorProvider.OP, - WeightCategoryLogBookConvertorProvider.BO, + super(LegacyWeightCategoryLogBookConvertorProvider.OP, + LegacyWeightCategoryLogBookConvertorProvider.BO, minus10Category, unknownCategory); this.plus10Category = plus10Category; } ===================================== t3-domain/src/test/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertorProviderTest.java → t3-domain/src/test/java/fr/ird/t3/entities/conversion/legacy/LegacyWeightCategoryLogBookConvertorProviderTest.java ===================================== --- a/t3-domain/src/test/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertorProviderTest.java +++ b/t3-domain/src/test/java/fr/ird/t3/entities/conversion/legacy/LegacyWeightCategoryLogBookConvertorProviderTest.java @@ -18,10 +18,11 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% */ -package fr.ird.t3.entities.conversion; +package fr.ird.t3.entities.conversion.legacy; import fr.ird.t3.entities.AbstractDatabaseTest; import fr.ird.t3.entities.T3TopiaPersistenceContext; +import fr.ird.t3.entities.conversion.WeightCategoryLogBookConvertorProvider; import org.junit.Assert; import org.junit.Test; @@ -31,15 +32,15 @@ import org.junit.Test; * @author Tony Chemit - dev@tchemit.fr * @since 1.0 */ -public class WeightCategoryLogBookConvertorProviderTest extends AbstractDatabaseTest { +public class LegacyWeightCategoryLogBookConvertorProviderTest extends AbstractDatabaseTest { @Test - public void newInstance() throws Exception { + public void newInstance() { db.loadClassPathScript("/db/WeightCategoryLogBookConvertorProviderTest.sql"); try (T3TopiaPersistenceContext tx = beginTransaction()) { - WeightCategoryLogBookConvertorProvider provider = WeightCategoryLogBookConvertorProvider.newInstance(tx); + WeightCategoryLogBookConvertorProvider provider = LegacyWeightCategoryLogBookConvertorProvider.newInstance(tx); Assert.assertNotNull(provider); } ===================================== t3-domain/src/test/java/fr/ird/t3/services/migration/T3MigrationTest.java ===================================== --- a/t3-domain/src/test/java/fr/ird/t3/services/migration/T3MigrationTest.java +++ b/t3-domain/src/test/java/fr/ird/t3/services/migration/T3MigrationTest.java @@ -24,16 +24,17 @@ package fr.ird.t3.services.migration; import fr.ird.t3.entities.T3TopiaApplicationContext; import fr.ird.t3.entities.T3TopiaPersistenceContext; import fr.ird.t3.entities.conversion.WeightCategoryLogBookConvertor; -import fr.ird.t3.entities.conversion.WeightCategoryLogBookConvertorFOR_OABI; -import fr.ird.t3.entities.conversion.WeightCategoryLogBookConvertorFOR_OABL; -import fr.ird.t3.entities.conversion.WeightCategoryLogBookConvertorFOR_OABO; -import fr.ird.t3.entities.conversion.WeightCategoryLogBookConvertorFOR_OIBI; -import fr.ird.t3.entities.conversion.WeightCategoryLogBookConvertorFOR_OIBL; -import fr.ird.t3.entities.conversion.WeightCategoryLogBookConvertorFOR_OIBO; -import fr.ird.t3.entities.conversion.WeightCategoryLogBookConvertorFOR_OPBI; -import fr.ird.t3.entities.conversion.WeightCategoryLogBookConvertorFOR_OPBL; -import fr.ird.t3.entities.conversion.WeightCategoryLogBookConvertorFOR_OPBO; import fr.ird.t3.entities.conversion.WeightCategoryLogBookConvertorProvider; +import fr.ird.t3.entities.conversion.legacy.LegacyWeightCategoryLogBookConvertorProvider; +import fr.ird.t3.entities.conversion.legacy.WeightCategoryLogBookConvertorFOR_OABI; +import fr.ird.t3.entities.conversion.legacy.WeightCategoryLogBookConvertorFOR_OABL; +import fr.ird.t3.entities.conversion.legacy.WeightCategoryLogBookConvertorFOR_OABO; +import fr.ird.t3.entities.conversion.legacy.WeightCategoryLogBookConvertorFOR_OIBI; +import fr.ird.t3.entities.conversion.legacy.WeightCategoryLogBookConvertorFOR_OIBL; +import fr.ird.t3.entities.conversion.legacy.WeightCategoryLogBookConvertorFOR_OIBO; +import fr.ird.t3.entities.conversion.legacy.WeightCategoryLogBookConvertorFOR_OPBI; +import fr.ird.t3.entities.conversion.legacy.WeightCategoryLogBookConvertorFOR_OPBL; +import fr.ird.t3.entities.conversion.legacy.WeightCategoryLogBookConvertorFOR_OPBO; import fr.ird.t3.entities.reference.Ocean; import fr.ird.t3.entities.reference.OceanTopiaDao; import fr.ird.t3.entities.reference.SchoolType; @@ -119,7 +120,7 @@ public class T3MigrationTest { try (T3TopiaPersistenceContext persistenceContext = rootContext.newPersistenceContext()) { - WeightCategoryLogBookConvertorProvider convertorProvider = WeightCategoryLogBookConvertorProvider.newInstance(persistenceContext); + WeightCategoryLogBookConvertorProvider convertorProvider = LegacyWeightCategoryLogBookConvertorProvider.newInstance(persistenceContext); OceanTopiaDao oceanDao = persistenceContext.getOceanDao(); speciesDao = persistenceContext.getSpeciesDao(); View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/fcbee3056fb34ba8001e0f2ead801be33... --- View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/fcbee3056fb34ba8001e0f2ead801be33... You're receiving this email because of your account on gitlab.com.