Tony CHEMIT pushed to branch develop at ultreiaio / ird-t3 Commits: 7b035f83 by Tony CHEMIT at 2018-03-08T14:53:16Z Marées sans logbooks : gestion de leurs échantillons - ajout de check de cohérence sur Trip.logbookAvaibility (See #116) + fix typo - - - - - 27 changed files: - .gitlab-ci.yml - t3-actions/src/main/java/fr/ird/t3/actions/data/level0/ComputeRF1Action.java - t3-actions/src/main/java/fr/ird/t3/actions/io/input/AnalyzeInputSourceAction.java - t3-actions/src/main/resources/ftl/fr/ird/t3/actions/data/level3/Level3Action_en.ftl - t3-actions/src/main/resources/i18n/t3-actions_en_GB.properties - t3-actions/src/main/resources/i18n/t3-actions_fr_FR.properties - t3-actions/src/test/java/fr/ird/t3/actions/data/level0/ComputeRF1ActionResumeTest.java - t3-domain/src/main/java/fr/ird/t3/entities/T3Predicates.java - t3-domain/src/main/java/fr/ird/t3/entities/data/AbstractTripTopiaDao.java - t3-domain/src/main/java/fr/ird/t3/entities/data/TripImpl.java - t3-domain/src/main/java/fr/ird/t3/io/input/T3Input.java - t3-domain/src/main/java/fr/ird/t3/io/input/access/AbstractT3InputMSAccess.java - t3-domain/src/main/java/fr/ird/t3/io/input/access/T3AccessDataSource.java - t3-domain/src/main/java/fr/ird/t3/io/input/access/T3AvdthDataEntityVisitor.java - t3-domain/src/main/resources/db/migration/V2_3_01_add-Trip-tripType.sql - t3-domain/src/main/xmi/t3-persistence.zargo - t3-domain/src/test/java/fr/ird/t3/entities/reference/WeightCategoryTreatmentImplTest.java - t3-input-avdthv33/src/main/java/fr/ird/t3/io/input/avdth/v33/T3InputAvdth33.java - t3-input-avdthv36/src/main/java/fr/ird/t3/io/input/avdth/v36/T3InputAvdth36.java - t3-output-balbayav32/src/main/java/fr/ird/t3/io/output/balbaya/v32/BalbayaOperationExecutionTripImpl.java - t3-web/src/main/java/fr/ird/t3/web/T3StaticContentLoader.java - t3-web/src/main/java/fr/ird/t3/web/actions/T3ActionSupport.java - t3-web/src/main/java/fr/ird/t3/web/actions/io/output/ExportConfigureAction.java - t3-web/src/main/java/fr/ird/t3/web/actions/json/GetOutputProviderOperationsAction.java - t3-web/src/main/java/fr/ird/t3/web/actions/json/GetZoneVersionsAction.java - t3-web/src/main/resources/i18n/t3-web_en_GB.properties - t3-web/src/main/webapp/WEB-INF/jsp/admin/tripDetail.jsp Changes: ===================================== .gitlab-ci.yml ===================================== --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -28,7 +28,13 @@ image: registry.gitlab.com/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/docker:lat environment: name: test script: - - if [ -n "${BUILD_FOR_RELEASE}" ]; then ultreiaio-maven-execute 'clean verify -U -DperformRelease -Dmaven.javadoc.skip'; fi + - if [ -n "${BUILD_FOR_RELEASE}" ]; then ultreiaio-maven-execute 'clean verify -U -DperformRelease -Dmaven.source.skip -Dmaven.javadoc.skip'; fi + +.deploy-snapshot: &deploy-snapshot + environment: + name: snapshot + script: + - if [ -n "${DEPLOY_SNAPSHOT}" ]; then ultreiaio-maven-execute 'clean deploy -am -rf t3-domain -DperformRelease -Dmaven.source.skip -Dmaven.javadoc.skip'; fi .publish-site: &publish-site environment: @@ -84,6 +90,11 @@ trigger-build-for-release: <<: *triggers <<: *build-for-release +trigger-deploy-snapshot: + <<: *stage_release + <<: *triggers + <<: *deploy-snapshot + trigger-deploy-demo: <<: *stage_test <<: *triggers @@ -167,6 +178,13 @@ create-docker: before_script: - export CREATE_DOCKER=true +deploy-snapshot: + <<: *stage_release + <<: *manual + <<: *deploy-snapshot + before_script: + - export DEPLOY_SNAPSHOT=true + make-release: <<: *stage_release <<: *manual ===================================== t3-actions/src/main/java/fr/ird/t3/actions/data/level0/ComputeRF1Action.java ===================================== --- a/t3-actions/src/main/java/fr/ird/t3/actions/data/level0/ComputeRF1Action.java +++ b/t3-actions/src/main/java/fr/ird/t3/actions/data/level0/ComputeRF1Action.java @@ -50,20 +50,19 @@ import static org.nuiton.i18n.I18n.l; */ public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configuration> { - /** Logger. */ private static final Log log = LogFactory.getLog(ComputeRF1Action.class); /** total catch weight for trips with rf1 != null. */ - protected float totalCatchWeightRF1; + float totalCatchWeightRF1; /** total landing weight for trips with rf1 != null. */ - protected float totalLandingWeight; + float totalLandingWeight; /** Number of trips rejected (with no logbook). */ - protected int nbRejectedTrips; + int nbRejectedTrips; /** Number of accepted trips (says with a rf1 computation). */ - protected int nbAcceptedTrips; + int nbAcceptedTrips; /** Number of accepted complete trips (says with a rf1 computation). */ - protected int nbCompleteAcceptedTrips; + int nbCompleteAcceptedTrips; /** Number of complete accepted trips (says with a rf1 computation, but not in defined bound). */ - protected int nbCompleteAcceptedTripsWithBadRF1; + int nbCompleteAcceptedTripsWithBadRF1; @InjectDAO(entityType = RF1SpeciesForFleet.class) private RF1SpeciesForFleetTopiaDao rF1SpecieForFleetDAO; /** usable trips group by vessel */ @@ -205,7 +204,6 @@ public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configurati treatCompleteTrip(completeTrip, species, minimumRate, maximumRate); // complete trip was consumed completeTrip.removeTrips(tripList); -// tripList.removeAll(completeTrip); } if (CollectionUtils.isNotEmpty(tripList)) { // still some trips not complete @@ -289,7 +287,7 @@ public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configurati for (Trip trip : trips) { String tripStr = decorate(trip); Float rf1ToUse = rf1; - if (trip.getLogBookAvailability() != 1) { + if (!trip.isWithLogbook()) { // means can not apply any rf1 : rf1 must stay at null... rf1ToUse = null; addWarningMessage(l(locale, "t3.level0.computeRF1.warning.no.logbook", tripStr)); @@ -309,28 +307,6 @@ public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configurati decorate(completeTrip.getLandingTrip()), tripTotalCatchWeightRf1, tripTotalLandingWeight)); log.debug(String.format("After trip %s totalCatchWeightRF1 = %s totalLandingWeight = %s", decorate(completeTrip.getLandingTrip()), totalCatchWeightRF1, totalLandingWeight)); -// for (Trip trip : completeTrip) { -// -// float tripTotalCatchWeightRf1 = -// trip.getElementaryCatchTotalWeightRf1(species); -// totalCatchWeightRF1 += tripTotalCatchWeightRf1; -// -// float tripTotalLandingWeight = -// trip.getElementaryLandingTotalWeight(species); -// totalLandingWeight += tripTotalLandingWeight; -// -// if (log.isInfoEnabled()) { -// -// log.info("After trip " + decorate(trip) + -// " tripTotalCatchWeightRf1 = " + tripTotalCatchWeightRf1 + -// " tripTotalLandingWeight = " + tripTotalLandingWeight); -// } -// if (log.isDebugEnabled()) { -// log.debug("After trip " + decorate(trip) + -// " totalCatchWeightRF1 = " + totalCatchWeightRF1 + -// " totalLandingWeight = " + totalLandingWeight); -// } -// } } private float computeRF1ForCompleteTrip(Iterable<Trip> completeTrip, Collection<Species> speciesList) { ===================================== t3-actions/src/main/java/fr/ird/t3/actions/io/input/AnalyzeInputSourceAction.java ===================================== --- a/t3-actions/src/main/java/fr/ird/t3/actions/io/input/AnalyzeInputSourceAction.java +++ b/t3-actions/src/main/java/fr/ird/t3/actions/io/input/AnalyzeInputSourceAction.java @@ -82,7 +82,6 @@ public class AnalyzeInputSourceAction extends T3Action<AnalyzeInputSourceConfigu private T3Input inputPilot; private boolean safe; - // Ne pas supprimer, utilisé dans la template de résumé @SuppressWarnings("unused") public Trip getTripToReplace(Trip trip) { Map<Trip, Trip> resultAsMap = getResultAsMap(RESULT_TRIPS_TO_REPLACE); @@ -117,10 +116,8 @@ public class AnalyzeInputSourceAction extends T3Action<AnalyzeInputSourceConfigu } String[] analyzeWarnings = inputPilot.getAnalyzeWarnings(); if (analyzeWarnings != null && analyzeWarnings.length > 0) { - // some errors on db - StringBuilder sb = new StringBuilder( - l(locale, "t3.import.warning.on.analyze", analyzeWarnings.length) - ); + // some warnings on db + StringBuilder sb = new StringBuilder(l(locale, "t3.import.warning.on.analyze", analyzeWarnings.length)); for (String analyzeWarning : analyzeWarnings) { sb.append('\n').append(analyzeWarning); } @@ -224,7 +221,6 @@ public class AnalyzeInputSourceAction extends T3Action<AnalyzeInputSourceConfigu } putResult(RESULT_SAFE_TRIPS, safeTrips); putResult(RESULT_UNSAFE_TRIPS, unsafeTrips); - // while analyzing db, nothing to commit in db return false; } finally { @@ -245,11 +241,9 @@ public class AnalyzeInputSourceAction extends T3Action<AnalyzeInputSourceConfigu if (!withWell) { // no well for this trip can remove all missing fk for wells addWarningMessage(l(locale, "t3.import.warning.no.wellPlan", decorate(trip))); - // remove missing keys Sample->Well since there is no well removeWellMissingForeignKeys(missingForeignKeys, false, SAMPLE_TO_WELL, missingFkToMessage); - - // remove missing keys WellPlan->Activity Ssince there is no well + // remove missing keys WellPlan->Activity since there is no well removeWellMissingForeignKeys(missingForeignKeys, true, WELL_PLAN_TO_ACTIVITY, missingFkToMessage); } else { // there is some wells for this trip @@ -282,6 +276,11 @@ public class AnalyzeInputSourceAction extends T3Action<AnalyzeInputSourceConfigu addInfoMessage(l(locale, "t3.import.message.use.new.vessel.for.trip", decorate(vessel), decorate(trip))); } } + String tripTypeNotSafeMessage = inputPilot.getTripTypeNotSafeMessage(trip); + if (tripTypeNotSafeMessage != null) { + tripSafe = false; + addInfoMessage(l(locale, "t3.import.error.bad.tripType", decorate(trip), tripTypeNotSafeMessage)); + } //TODO Use this when Will have exact list of entities to exclude... // check we are not using bad references // tripSafe &= checkReferences(trip, entitiesUsed); ===================================== t3-actions/src/main/resources/ftl/fr/ird/t3/actions/data/level3/Level3Action_en.ftl ===================================== --- a/t3-actions/src/main/resources/ftl/fr/ird/t3/actions/data/level3/Level3Action_en.ftl +++ b/t3-actions/src/main/resources/ftl/fr/ird/t3/actions/data/level3/Level3Action_en.ftl @@ -30,7 +30,7 @@ Time step: ${configuration.timeStep} Treatment to apply to catches with samples: <#if configuration.useAllSamplesOfStratum> -Apply length structures from the sample statrum +Apply length structures from the sample stratum <#else> Keep their own samples (do nothing) </#if> ===================================== t3-actions/src/main/resources/i18n/t3-actions_en_GB.properties ===================================== --- a/t3-actions/src/main/resources/i18n/t3-actions_en_GB.properties +++ b/t3-actions/src/main/resources/i18n/t3-actions_en_GB.properties @@ -3,6 +3,7 @@ t3.admin.deleteTrip=Delete trip %s t3.admin.deleteTripDatas=Delete data of trip %s t3.common.rf1.maximumRate.acceptable=Maximum acceptable rf1 rate t3.common.rf1.minimumRate.acceptable=Minimum acceptable rf1 rate +t3.import.error.bad.tripType=Trip type is not consistent\: %s t3.import.error.badReferenceCode=Trip %s uses a reference of type %s with forbidden code %s t3.import.error.missingForeignKey=It miss on trip %s foreign keys from %s %s to %s %s t3.import.error.missingForeignKeyInT3=On trip %s, it miss in T3+ referentials, entity %s (natural key\: %s) ===================================== t3-actions/src/main/resources/i18n/t3-actions_fr_FR.properties ===================================== --- a/t3-actions/src/main/resources/i18n/t3-actions_fr_FR.properties +++ b/t3-actions/src/main/resources/i18n/t3-actions_fr_FR.properties @@ -3,6 +3,7 @@ t3.admin.deleteTrip=Suppresion de la marée %s t3.admin.deleteTripDatas=Suppresion des données de la marée %s t3.common.rf1.maximumRate.acceptable=Seuil maximum acceptable du rf1 t3.common.rf1.minimumRate.acceptable=Seuil minimum acceptable du rf1 +t3.import.error.bad.tripType=Le type de la marée %s n'est pas cohérent \: %s t3.import.error.badReferenceCode=La marée %s utilise un référentiel de type %s avec le code %s t3.import.error.missingForeignKey=Il manque sur la marée %s des clefs étrangères type %s %s vers %s %s t3.import.error.missingForeignKeyInT3=Pour la marée %s, il manque dans le référentiel T3+ l'entité %s (clef métier\: %s) ===================================== t3-actions/src/test/java/fr/ird/t3/actions/data/level0/ComputeRF1ActionResumeTest.java ===================================== --- a/t3-actions/src/test/java/fr/ird/t3/actions/data/level0/ComputeRF1ActionResumeTest.java +++ b/t3-actions/src/test/java/fr/ird/t3/actions/data/level0/ComputeRF1ActionResumeTest.java @@ -63,19 +63,13 @@ public class ComputeRF1ActionResumeTest extends AbstractActionResumeTest<Compute @Override protected Map<String, Object> createTemplateParameters() { - Map<String, Object> parameters = super.createTemplateParameters(); - Map<String, String> vesselSimpleTypes = new TreeMap<>(); - putInMap(vesselSimpleTypes, - fixtures.vesselSimpleTypeCanneur(), - fixtures.vesselSimpleTypeSenneur()); + putInMap(vesselSimpleTypes, fixtures.vesselSimpleTypeCanneur(), fixtures.vesselSimpleTypeSenneur()); parameters.put("vesselSimpleTypes", vesselSimpleTypes); - Map<String, String> fleets = new TreeMap<>(); putInMap(fleets, fixtures.frenchCountry()); parameters.put("fleets", fleets); - return parameters; } ===================================== t3-domain/src/main/java/fr/ird/t3/entities/T3Predicates.java ===================================== --- a/t3-domain/src/main/java/fr/ird/t3/entities/T3Predicates.java +++ b/t3-domain/src/main/java/fr/ird/t3/entities/T3Predicates.java @@ -8,12 +8,12 @@ * 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% @@ -45,38 +45,6 @@ import java.util.function.Predicate; */ public class T3Predicates { -// /** -// * Predicates that trip has no data computed. -// * -// * @see Trip#isNoDataComputed() -// * @since 1.1 -// */ -// public static final Predicate<Trip> TRIP_WITH_NO_DATA_COMPUTED = Trip::isNoDataComputed; -// -// /** -// * Predicates that trip has some data computed. -// * -// * @see Trip#isSomeDataComputed() -// * @since 1.1 -// */ -// public static final Predicate<Trip> TRIP_WITH_SOME_DATA_COMPUTED = Trip::isSomeDataComputed; -// -// /** -// * Predicates that trip has all his data computed. -// * -// * @see Trip#isAllDataComputed() () -// * @since 1.1 -// */ -// public static final Predicate<Trip> TRIP_WITH_ALL_DATA_COMPUTED = Trip::isAllDataComputed; - - /** - * Predicates that trip has a log book. - * - * @see Trip#getLogBookAvailability() - * @since 1.1 - */ - public static final Predicate<Trip> TRIP_WITH_LOG_BOOK = input -> input.getLogBookAvailability() == 1; - /** * Predicates that trip ends a complete trip. * @@ -85,21 +53,6 @@ public class T3Predicates { */ public static final Predicate<Trip> TRIP_ENDS_A_COMPLETE_TRIP = input -> input.getFishHoldEmpty() == 1; - -// /** -// * Predicates that trip is inside a complete trip (as a simple trip or a -// * partial complete trip). -// * <p/> -// * Notes that a such trip can be used in level 0, and 1. -// * -// * @see Trip#getCompletionStatus() -// * @since 1.2 -// */ -// public static final Predicate<Trip> TRIP_INSIDE_A_COMPLETE_TRIP = input -> { -// Integer completionStatus = input.getCompletionStatus(); -// return completionStatus != null && completionStatus > 0; -// }; - public static final Predicate<Activity> ACTIVITY_WITH_SET_SAMPLE = input -> !input.isSetSpeciesCatWeightEmpty(); public static final Predicate<LengthWeightConversion> LENGTH_WEIGHT_CONVERSION_BY_COEFFICIENT = input -> { boolean result = true; @@ -197,9 +150,7 @@ public class T3Predicates { public static Predicate<Trip> tripUsingOcean(Collection<Ocean> oceans) { return input -> { boolean result = false; - - if (!input.isActivityEmpty()) { - + if (input.isActivityNotEmpty()) { Set<Ocean> allOceans = input.getAllOceans(); for (Ocean ocean : allOceans) { if (oceans.contains(ocean)) { @@ -273,4 +224,18 @@ public class T3Predicates { // public static <E extends TopiaEntity> Predicate<E> equalsTopiaEntity(String id) { // return input -> id.equals(input.getTopiaId()); // } + +// /** +// * Predicates that trip is inside a complete trip (as a simple trip or a partial complete trip). +// * <p/> +// * Notes that a such trip can be used in level 0, and 1. +// * +// * @see Trip#getCompletionStatus() +// * @since 1.2 +// */ +// public static final Predicate<Trip> TRIP_INSIDE_A_COMPLETE_TRIP = input -> { +// Integer completionStatus = input.getCompletionStatus(); +// return completionStatus != null && completionStatus > 0; +// }; + } ===================================== t3-domain/src/main/java/fr/ird/t3/entities/data/AbstractTripTopiaDao.java ===================================== --- a/t3-domain/src/main/java/fr/ird/t3/entities/data/AbstractTripTopiaDao.java +++ b/t3-domain/src/main/java/fr/ird/t3/entities/data/AbstractTripTopiaDao.java @@ -49,6 +49,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Comparator; @@ -69,12 +70,57 @@ import java.util.stream.StreamSupport; public class AbstractTripTopiaDao<E extends Trip> extends GeneratedTripTopiaDao<E> { public static final Ocean EMPTY_OCEAN = new OceanImpl(); + private static final int TRIP_WITHOUT_LOGBOOK = 0; + private static final int TRIP_WITH_LOGBOOK = 1; private static final Log log = LogFactory.getLog(AbstractTripTopiaDao.class); static { EMPTY_OCEAN.setTopiaId("fr.ird.t3.entities.reference.Ocean#EMPTY#EMPTY"); } + /** + * Check that a standard trip ({@link TripType#STANDARD}) is consistent with {@code logBookAvailability} flag. + * + * @param trip trip to check + * @param pKey primary key of this trip + */ + public static void checkAndSetStandardTripType(Trip trip, Object[] pKey) { + int logBookAvailability = trip.getLogBookAvailability(); + switch (logBookAvailability) { + case TRIP_WITHOUT_LOGBOOK: + if (trip.isActivityNotEmpty()) { + trip.setTripType(TripType.STANDARD); + throw new IllegalStateException(String.format("Trip [%s] has some logBook but logBookAvailability says the opposite, please fix this trip.", Arrays.toString(pKey))); + } + trip.setTripType(TripType.LOGBOOKMISSING); + break; + case TRIP_WITH_LOGBOOK: + if (trip.isActivityEmpty()) { + trip.setTripType(TripType.LOGBOOKMISSING); + throw new IllegalStateException(String.format("Trip [%s] has some logBook but logBookAvailability says the opposite, please fix this trip.", Arrays.toString(pKey))); + } + trip.setTripType(TripType.STANDARD); + break; + } + } + + /** + * Check that a standard trip ({@link TripType#LOGBOOKMISSING}) is consistent with {@code logBookAvailability} flag. + * + * @param trip trip to check + * @param pKey primary key of this trip + */ + public static void checkAndSetLogbookMissingTripType(Trip trip, Object[] pKey) { + int logBookAvailability = trip.getLogBookAvailability(); + if (trip.getTripType() == TripType.LOGBOOKMISSING) { + if (TRIP_WITH_LOGBOOK == logBookAvailability) { + throw new IllegalStateException(String.format("Trip %s has no logBook but logBookAvailability says the opposite, please fix this trip.", Arrays.toString(pKey))); + } + } else { + checkAndSetStandardTripType(trip, pKey); + } + } + public static String getSamplesOnlyFilter(String prefix, Boolean samplesOnly) { if (samplesOnly == null) { return ""; @@ -138,7 +184,7 @@ public class AbstractTripTopiaDao<E extends Trip> extends GeneratedTripTopiaDao< } public static boolean isTripsAllWithLogBook(Iterable<Trip> trips) { - return StreamSupport.stream(trips.spliterator(), false).allMatch(T3Predicates.TRIP_WITH_LOG_BOOK); + return StreamSupport.stream(trips.spliterator(), false).allMatch(Trip::isWithLogbook); } /** ===================================== t3-domain/src/main/java/fr/ird/t3/entities/data/TripImpl.java ===================================== --- a/t3-domain/src/main/java/fr/ird/t3/entities/data/TripImpl.java +++ b/t3-domain/src/main/java/fr/ird/t3/entities/data/TripImpl.java @@ -8,12 +8,12 @@ * 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% @@ -63,8 +63,9 @@ public class TripImpl extends TripAbstract { } private transient Boolean level2Computed; - private transient Boolean level3Computed; + // only used for avdth import + private transient int logBookAvailability; @Override public boolean isSomeDataComputed() { @@ -91,6 +92,12 @@ public class TripImpl extends TripAbstract { return TripType.LOGBOOKMISSING == getTripType(); } + @Override + public boolean isWithLogbook() { + return TripType.STANDARD == getTripType(); + } + + @SuppressWarnings("WeakerAccess") public boolean isLevel2Computed() { if (level2Computed == null) { level2Computed = false; @@ -108,6 +115,7 @@ public class TripImpl extends TripAbstract { return level2Computed; } + @SuppressWarnings("WeakerAccess") public boolean isLevel3Computed() { if (level3Computed == null) { level3Computed = false; @@ -137,7 +145,19 @@ public class TripImpl extends TripAbstract { return result; } -// /** @return the sum of all activities set duration in hours. */ + // only used for avdth import + @Override + public int getLogBookAvailability() { + return logBookAvailability; + } + + // only used for avdth import + @Override + public void setLogBookAvailability(int logbookAvaibility) { + this.logBookAvailability = logbookAvaibility; + } + + // /** @return the sum of all activities set duration in hours. */ // @Override // public float getTotalSetsDuration() { // float result = 0; ===================================== t3-domain/src/main/java/fr/ird/t3/io/input/T3Input.java ===================================== --- a/t3-domain/src/main/java/fr/ird/t3/io/input/T3Input.java +++ b/t3-domain/src/main/java/fr/ird/t3/io/input/T3Input.java @@ -121,6 +121,8 @@ public interface T3Input { */ List<MissingForeignKey> getMissingForeignKeys(Trip trip); + String getTripTypeNotSafeMessage(Trip trip); + /** * Method to clean input internal states. * <p/> ===================================== t3-domain/src/main/java/fr/ird/t3/io/input/access/AbstractT3InputMSAccess.java ===================================== --- a/t3-domain/src/main/java/fr/ird/t3/io/input/access/AbstractT3InputMSAccess.java +++ b/t3-domain/src/main/java/fr/ird/t3/io/input/access/AbstractT3InputMSAccess.java @@ -25,6 +25,7 @@ import fr.ird.t3.entities.ReferenceEntityMap; import fr.ird.t3.entities.T3EntityEnum; import fr.ird.t3.entities.T3EntityMap; import fr.ird.t3.entities.data.Trip; +import fr.ird.t3.entities.data.TripTopiaDao; import fr.ird.t3.entities.data.TripType; import fr.ird.t3.entities.reference.Vessel; import fr.ird.t3.io.input.MissingForeignKey; @@ -39,9 +40,11 @@ import org.nuiton.topia.persistence.TopiaException; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.File; +import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; @@ -56,13 +59,14 @@ import java.util.stream.Collectors; public abstract class AbstractT3InputMSAccess implements T3Input { private static final Log log = LogFactory.getLog(AbstractT3InputMSAccess.class); - protected T3AccessDataSource dataSource; - protected T3InputConfiguration configuration; - protected Map<Integer, Vessel> vessels; + private T3InputConfiguration configuration; + private Map<Integer, Vessel> vessels; + private T3AccessDataSource dataSource; private ReferenceEntityMap safeReferences; private Map<Trip, List<MissingForeignKey>> missingFK; - private String[] errors; - private String[] warnings; + private List<String> errors; + private List<String> warnings; + private Map<Trip, String> tripTypeNotSafeMessages; public abstract T3AccessDataSource newDataSource(File inputFile); @@ -91,27 +95,25 @@ public abstract class AbstractT3InputMSAccess implements T3Input { T3AccessHitModel hitModel = new T3AccessHitModel(); hitModel.addPropertyChangeListener(new LoadDbPropertyChangeListener(t3DataTypes)); // analyse data source - if (configuration.getTripType() == TripType.LOGBOOKMISSING) { - dataSource.analyzeDb(TripType.LOGBOOKMISSING, hitModel); - } else { - dataSource.analyzeDb(hitModel); - } + dataSource.analyzeDb(hitModel); + errors = new ArrayList<>(); if (dataSource.hasError()) { - errors = dataSource.getErrors(); + errors.addAll(Arrays.asList(dataSource.getErrors())); } + warnings = new ArrayList<>(); if (dataSource.hasWarning()) { - warnings = dataSource.getWarnings(); + warnings.addAll(Arrays.asList(dataSource.getWarnings())); } } @Override public String[] getAnalyzeErrors() { - return errors; + return errors.toArray(new String[errors.size()]); } @Override public String[] getAnalyzeWarnings() { - return warnings; + return warnings.toArray(new String[warnings.size()]); } @Override @@ -168,7 +170,7 @@ public abstract class AbstractT3InputMSAccess implements T3Input { T3EntityEnum constant = T3EntityEnum.valueOf(Trip.class); T3AccessEntityMeta meta = dataSource.getMeta(constant); List<Trip> entities = dataSource.loadEntities(meta); - Map<Trip, T3EntityMap> result = Maps.newLinkedHashMap(); + Map<Trip, T3EntityMap> result = new LinkedHashMap<>(); missingFK = new HashMap<>(); T3DataEntityVisitor dataVisitor = newDataVisitor(dataSource, safeReferences); try { @@ -233,6 +235,18 @@ public abstract class AbstractT3InputMSAccess implements T3Input { return missingFK.get(trip); } + @Override + public String getTripTypeNotSafeMessage(Trip trip) { + return tripTypeNotSafeMessages == null ? null : tripTypeNotSafeMessages.get(trip); + } + + private void addTripTypeNotSafeMessage(Trip trip, String message) { + if (tripTypeNotSafeMessages == null) { + tripTypeNotSafeMessages = new LinkedHashMap<>(); + } + tripTypeNotSafeMessages.put(trip, message); + } + private Trip loadTrip(int vesselCode, Trip trip, T3DataEntityVisitor dataVisitor, TripType tripType, boolean canCreateVessel) { RemoveProxyEntityVisitor visitor = new RemoveProxyEntityVisitor(); try { @@ -241,8 +255,29 @@ public abstract class AbstractT3InputMSAccess implements T3Input { dataVisitor.doVisit(trip, true); // remove proxy on data Trip loadedTrip = visitor.doVisit(trip); - // set tripType flag - loadedTrip.setTripType(tripType); + T3AccessEntity a = (T3AccessEntity) trip; + Object[] pKey = a.getPKey(); + switch (tripType) { + case STANDARD: + try { + TripTopiaDao.checkAndSetStandardTripType(loadedTrip, pKey); + } catch (Exception e) { + errors.add(e.getMessage()); + } + break; + case SAMPLEONLY: + // no check + loadedTrip.setTripType(TripType.SAMPLEONLY); + break; + case LOGBOOKMISSING: + try { + TripTopiaDao.checkAndSetLogbookMissingTripType(loadedTrip, pKey); + } catch (Exception e) { + errors.add(e.getMessage()); + + } + break; + } if (trip.getVessel() == null && canCreateVessel) { // use new created vessel Vessel vessel = getNewVessels().get(vesselCode); ===================================== t3-domain/src/main/java/fr/ird/t3/io/input/access/T3AccessDataSource.java ===================================== --- a/t3-domain/src/main/java/fr/ird/t3/io/input/access/T3AccessDataSource.java +++ b/t3-domain/src/main/java/fr/ird/t3/io/input/access/T3AccessDataSource.java @@ -22,7 +22,6 @@ package fr.ird.t3.io.input.access; import fr.ird.msaccess.importer.AbstractAccessDataSource; import fr.ird.t3.entities.T3EntityEnum; -import fr.ird.t3.entities.data.TripType; import fr.ird.t3.entities.reference.T3ReferenceEntity; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -99,10 +98,6 @@ public class T3AccessDataSource extends AbstractAccessDataSource<T3EntityEnum, T } public void analyzeDb(T3AccessHitModel hits) throws Exception { - analyzeDb(null, hits); - } - - public void analyzeDb(TripType tripType, T3AccessHitModel hits) throws Exception { // always init the data source init(); Set<String> tables = getTableNames(); ===================================== t3-domain/src/main/java/fr/ird/t3/io/input/access/T3AvdthDataEntityVisitor.java ===================================== --- a/t3-domain/src/main/java/fr/ird/t3/io/input/access/T3AvdthDataEntityVisitor.java +++ b/t3-domain/src/main/java/fr/ird/t3/io/input/access/T3AvdthDataEntityVisitor.java @@ -78,6 +78,8 @@ public abstract class T3AvdthDataEntityVisitor extends T3DataEntityVisitor { activity.setSchoolType(Objects.requireNonNull(sampleSet.getActivitySchoolType())); sampleSet.setActivity(endActivity(activity)); parent.addActivity(activity); + // Force tripType, so later we will know that this trip has no logBook + parent.setTripType(TripType.LOGBOOKMISSING); } }; } else { ===================================== t3-domain/src/main/resources/db/migration/V2_3_01_add-Trip-tripType.sql ===================================== --- a/t3-domain/src/main/resources/db/migration/V2_3_01_add-Trip-tripType.sql +++ b/t3-domain/src/main/resources/db/migration/V2_3_01_add-Trip-tripType.sql @@ -20,5 +20,8 @@ --- ALTER TABLE Trip ADD COLUMN tripType VARCHAR(255) DEFAULT 'STANDARD' NOT NULL; UPDATE Trip set tripType = 'SAMPLEONLY' WHERE samplesonly = TRUE; +UPDATE Trip set tripType = 'STANDARD' WHERE logbookavailability = 1; +UPDATE Trip set tripType = 'LOGBOOKMISSING' WHERE logbookavailability = 0; CREATE INDEX idx_trip_tripType ON Trip(tripType); +ALTER TABLE Trip DROP COLUMN logbookavailability; ALTER TABLE Trip DROP COLUMN samplesonly; \ No newline at end of file ===================================== t3-domain/src/main/xmi/t3-persistence.zargo ===================================== Binary files a/t3-domain/src/main/xmi/t3-persistence.zargo and b/t3-domain/src/main/xmi/t3-persistence.zargo differ ===================================== t3-domain/src/test/java/fr/ird/t3/entities/reference/WeightCategoryTreatmentImplTest.java ===================================== --- a/t3-domain/src/test/java/fr/ird/t3/entities/reference/WeightCategoryTreatmentImplTest.java +++ b/t3-domain/src/test/java/fr/ird/t3/entities/reference/WeightCategoryTreatmentImplTest.java @@ -20,7 +20,6 @@ */ package fr.ird.t3.entities.reference; -import com.google.common.collect.Maps; import fr.ird.t3.entities.AbstractDatabaseTest; import fr.ird.t3.entities.T3TopiaPersistenceContext; import org.junit.Assert; @@ -28,6 +27,7 @@ import org.junit.Test; import java.util.ArrayList; import java.util.Comparator; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -154,7 +154,7 @@ public class WeightCategoryTreatmentImplTest extends AbstractDatabaseTest { catUnbound.setMax(null); Map<WeightCategoryTreatment, Integer> weightCategories = - Maps.newLinkedHashMap(); + new LinkedHashMap<>(); weightCategories.put(catBound, 20); weightCategories.put(catUnbound, Integer.MAX_VALUE); @@ -208,7 +208,7 @@ public class WeightCategoryTreatmentImplTest extends AbstractDatabaseTest { catUnbound.setMax(null); Map<WeightCategoryTreatment, Integer> weightCategories = - Maps.newLinkedHashMap(); + new LinkedHashMap<>(); weightCategories.put(catBound, 20); weightCategories.put(catBound2, 40); ===================================== t3-input-avdthv33/src/main/java/fr/ird/t3/io/input/avdth/v33/T3InputAvdth33.java ===================================== --- a/t3-input-avdthv33/src/main/java/fr/ird/t3/io/input/avdth/v33/T3InputAvdth33.java +++ b/t3-input-avdthv33/src/main/java/fr/ird/t3/io/input/avdth/v33/T3InputAvdth33.java @@ -82,7 +82,7 @@ public class T3InputAvdth33 extends AbstractT3InputMSAccess { @Override public T3DataEntityVisitor newDataVisitor(T3AccessDataSource dataSource, ReferenceEntityMap safeReferences) { - return new T3DataEntityVisitorAvdth33(dataSource, safeReferences, configuration); + return new T3DataEntityVisitorAvdth33(dataSource, safeReferences, getConfiguration()); } @Override ===================================== t3-input-avdthv36/src/main/java/fr/ird/t3/io/input/avdth/v36/T3InputAvdth36.java ===================================== --- a/t3-input-avdthv36/src/main/java/fr/ird/t3/io/input/avdth/v36/T3InputAvdth36.java +++ b/t3-input-avdthv36/src/main/java/fr/ird/t3/io/input/avdth/v36/T3InputAvdth36.java @@ -96,7 +96,7 @@ public class T3InputAvdth36 extends AbstractT3InputMSAccess { @Override public T3DataEntityVisitor newDataVisitor(T3AccessDataSource dataSource, ReferenceEntityMap safeReferences) { - return new T3DataEntityVisitorAvdth36(dataSource, safeReferences, configuration); + return new T3DataEntityVisitorAvdth36(dataSource, safeReferences, getConfiguration()); } @Override ===================================== t3-output-balbayav32/src/main/java/fr/ird/t3/io/output/balbaya/v32/BalbayaOperationExecutionTripImpl.java ===================================== --- a/t3-output-balbayav32/src/main/java/fr/ird/t3/io/output/balbaya/v32/BalbayaOperationExecutionTripImpl.java +++ b/t3-output-balbayav32/src/main/java/fr/ird/t3/io/output/balbaya/v32/BalbayaOperationExecutionTripImpl.java @@ -8,12 +8,12 @@ * 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% @@ -39,182 +39,153 @@ import static org.nuiton.i18n.I18n.l; */ public class BalbayaOperationExecutionTripImpl extends AbstractBalbayaOperationExecution { - public BalbayaOperationExecutionTripImpl(Connection connection) { + private static final String CHECK_TRIP = "SELECT count(*) FROM maree where c_bat = %1$s AND d_dbq = '%2$s'::date;"; + /** + * To insert a new line into maree table (from Trip entity). + * <p/> + * c_bat | numeric(4,0) | not null + * d_dbq | date | not null + * d_depart | date | + * c_port_dep | numeric(3,0) | not null + * c_port_dbq | numeric(3,0) | not null + * c_zone_geo | numeric(4,0) | + * v_temps_m | numeric(4,0) | not null + * v_temps_p | numeric(4,0) | not null + * v_poids_dbq | numeric(7,3) | not null + * v_poids_fp | numeric(6,3) | not null + * f_enq | numeric(1,0) | not null + * f_cal_vid | numeric(1,0) | not null + * v_loch | numeric(5,0) | + * id_jeu_d | numeric(4,0) | not null + * c_pays_d | numeric(3,0) | not null + */ + private static final String INSERT_MAREE = "INSERT INTO maree (" + + "c_bat," + + "d_dbq," + + "d_depart," + + "c_port_dep, " + + "c_port_dbq," + + "v_temps_m," + + "v_temps_p," + + "v_poids_dbq," + + "v_poids_fp," + + "f_enq," + + "f_cal_vid," + + "v_loch," + + "id_jeu_d," + + "c_pays_d" + + ") VALUES (" + + "%1$s," + + "'%2$s'::date," + + "'%3$s'::date," + + "%4$s," + + "%5$s," + + "%6$s," + + "%7$s," + + "%8$s," + + "%9$s," + + "%10$s," + + "%11$s," + + "%12$s," + + "%13$s," + + "%14$s" + + ");"; + /** + * To insert a new line into lot_com table (from ElementaryLanding entity). + * <p/> + * c_bat | numeric(4,0) | not null + * d_dbq | date | not null + * n_lot | numeric(4,0) | not null + * c_esp | numeric(3,0) | not null + * c_cat_c | numeric(2,0) | not null + * v_poids_lc | numeric(7,3) | not null + */ + private static final String INSERT_LOT_COM = "INSERT INTO lot_com (" + + "c_bat, " + + "d_dbq," + + "n_lot, " + + "c_esp," + + "c_cat_c," + + "v_poids_lc" + + ") VALUES(" + + "%1$s," + + "'%2$s'::date," + + "%3$s," + + "%4$s," + + "%5$s," + + "%6$s" + + ");"; + private int nbTrips; + private int nbElementaryLandings; + + BalbayaOperationExecutionTripImpl(Connection connection) { super(connection, T3OutputOperationBalbayaImpl.TRIP_AND_LANDING); } @Override protected boolean checkDatas(T3OutputBalbayaImpl output, List<Trip> trips) throws SQLException { - // check pKeys before all for (Trip trip : trips) { - int tripVesselCode = trip.getVessel().getCode(); Date tripLandingDate = trip.getLandingDate(); - - boolean exists = - checkPKey(CHECK_TRIP, tripVesselCode, tripLandingDate); - + boolean exists = checkPKey(CHECK_TRIP, tripVesselCode, tripLandingDate); if (exists) { - // this trip already exists, can not import it, stop operation Locale locale = output.getLocale(); output.getMessager().addErrorMessage( - l(locale, "t3.output.balbaya.error.trip.already.exists", - tripVesselCode, tripLandingDate) - ); + l(locale, "t3.output.balbaya.error.trip.already.exists", tripVesselCode, tripLandingDate)); return false; } } return true; } - protected int nbTrips; - - protected int nbElementaryLandings; - @Override - protected String getSuccessSummary(T3OutputBalbayaImpl output, - T3OutputBalbayaImpl.TreatmentId id) { + protected String getSuccessSummary(T3OutputBalbayaImpl output, T3OutputBalbayaImpl.TreatmentId id) { Locale locale = output.getLocale(); - return l(locale, "t3.output.balbabya.operation.tripAndLanding.success", - id.getNumber(), nbTrips, nbElementaryLandings); + return l(locale, "t3.output.balbabya.operation.tripAndLanding.success", id.getNumber(), nbTrips, nbElementaryLandings); } @Override - protected void buildRequests(T3OutputBalbayaImpl output, - T3OutputBalbayaImpl.TreatmentId id, - List<Trip> trips) { - + protected void buildRequests(T3OutputBalbayaImpl output, T3OutputBalbayaImpl.TreatmentId id, List<Trip> trips) { nbTrips = nbElementaryLandings = 0; - int countryCode = id.getCountryCode(); int treatmentNumber = id.getNumber(); - for (Trip trip : trips) { - int tripVesselCode = trip.getVessel().getCode(); Date tripLandingDate = trip.getLandingDate(); - // add trip - nbTrips++; addRequest(INSERT_MAREE, - requests, - tripVesselCode, - tripLandingDate, - trip.getDepartureDate(), - trip.getDepartureHarbour().getCode(), - trip.getLandingHarbour().getCode(), - trip.getTimeAtSea(), - trip.getFishingTime(), - trip.getLandingTotalWeight(), - trip.getFalseFishesWeight(), - trip.getLogBookAvailability(), - trip.getFishHoldEmpty(), - trip.getLoch(), - treatmentNumber, - countryCode - ); + requests, + tripVesselCode, + tripLandingDate, + trip.getDepartureDate(), + trip.getDepartureHarbour().getCode(), + trip.getLandingHarbour().getCode(), + trip.getTimeAtSea(), + trip.getFishingTime(), + trip.getLandingTotalWeight(), + trip.getFalseFishesWeight(), + trip.isWithLogbook() ? 1 : 0, + trip.getFishHoldEmpty(), + trip.getLoch(), + treatmentNumber, + countryCode); if (!trip.isElementaryLandingEmpty()) { - // add elementary landing for (ElementaryLanding elementaryLanding : trip.getElementaryLanding()) { - nbElementaryLandings++; - addRequest(INSERT_LOT_COM, - requests, - tripVesselCode, - tripLandingDate, - elementaryLanding.getNumber(), - elementaryLanding.getWeightCategoryLanding().getSpecies().getCode(), - elementaryLanding.getWeightCategoryLanding().getCode(), - elementaryLanding.getWeight() - ); + requests, + tripVesselCode, + tripLandingDate, + elementaryLanding.getNumber(), + elementaryLanding.getWeightCategoryLanding().getSpecies().getCode(), + elementaryLanding.getWeightCategoryLanding().getCode(), + elementaryLanding.getWeight()); } } } } - - public static final String CHECK_TRIP = "SELECT count(*) FROM maree where " + - "c_bat = %1$s AND d_dbq = '%2$s'::date;"; - - /** - * To insert a new line into maree table (from Trip entity). - * <p/> - * c_bat | numeric(4,0) | not null - * d_dbq | date | not null - * d_depart | date | - * c_port_dep | numeric(3,0) | not null - * c_port_dbq | numeric(3,0) | not null - * c_zone_geo | numeric(4,0) | - * v_temps_m | numeric(4,0) | not null - * v_temps_p | numeric(4,0) | not null - * v_poids_dbq | numeric(7,3) | not null - * v_poids_fp | numeric(6,3) | not null - * f_enq | numeric(1,0) | not null - * f_cal_vid | numeric(1,0) | not null - * v_loch | numeric(5,0) | - * id_jeu_d | numeric(4,0) | not null - * c_pays_d | numeric(3,0) | not null - */ - public static final String INSERT_MAREE = "INSERT INTO maree (" + - "c_bat," + - "d_dbq," + - "d_depart," + - "c_port_dep, " + - "c_port_dbq," + - "v_temps_m," + - "v_temps_p," + - "v_poids_dbq," + - "v_poids_fp," + - "f_enq," + - "f_cal_vid," + - "v_loch," + - "id_jeu_d," + - "c_pays_d" + - ") VALUES (" + - "%1$s," + - "'%2$s'::date," + - "'%3$s'::date," + - "%4$s," + - "%5$s," + - "%6$s," + - "%7$s," + - "%8$s," + - "%9$s," + - "%10$s," + - "%11$s," + - "%12$s," + - "%13$s," + - "%14$s" + - ");"; - - - /** - * To insert a new line into lot_com table (from ElementaryLanding entity). - * <p/> - * c_bat | numeric(4,0) | not null - * d_dbq | date | not null - * n_lot | numeric(4,0) | not null - * c_esp | numeric(3,0) | not null - * c_cat_c | numeric(2,0) | not null - * v_poids_lc | numeric(7,3) | not null - */ - public static final String INSERT_LOT_COM = "INSERT INTO lot_com (" + - "c_bat, " + - "d_dbq," + - "n_lot, " + - "c_esp," + - "c_cat_c," + - "v_poids_lc" + - ") VALUES(" + - "%1$s," + - "'%2$s'::date," + - "%3$s," + - "%4$s," + - "%5$s," + - "%6$s" + - ");"; } ===================================== t3-web/src/main/java/fr/ird/t3/web/T3StaticContentLoader.java ===================================== --- a/t3-web/src/main/java/fr/ird/t3/web/T3StaticContentLoader.java +++ b/t3-web/src/main/java/fr/ird/t3/web/T3StaticContentLoader.java @@ -10,12 +10,12 @@ package fr.ird.t3.web; * 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% @@ -35,9 +35,10 @@ import java.io.OutputStream; import java.util.Calendar; /** + * FIXME See if we still need this ? * To fix some javascript loading problem. * <p/> - * Some javascript files have some strange first caracter (ckeditor for example) + + * Some javascript files have some strange first character (ckeditor for example) + * problem while loading charsets for french translate files. * * @author Tony Chemit - dev@tchemit.fr @@ -45,25 +46,18 @@ import java.util.Calendar; */ public class T3StaticContentLoader extends DefaultStaticContentLoader { - /** Logger. */ - private final Logger log = - LoggerFactory.getLogger(T3StaticContentLoader.class); + private final Logger log = LoggerFactory.getLogger(T3StaticContentLoader.class); @Override - protected void process(InputStream is, - String path, - HttpServletRequest request, - HttpServletResponse response) throws IOException { + protected void process(InputStream is, String path, HttpServletRequest request, HttpServletResponse response) throws IOException { if (is != null) { Calendar cal = Calendar.getInstance(); - // check for if-modified-since, prior to any other headers long ifModifiedSince = 0; try { ifModifiedSince = request.getDateHeader("If-Modified-Since"); } catch (Exception e) { - log.warn("Invalid If-Modified-Since header value: '" - + request.getHeader("If-Modified-Since") + "', ignoring"); + log.warn(String.format("Invalid If-Modified-Since header value: '%s', ignoring", request.getHeader("If-Modified-Since"))); } long lastModifiedMillis = lastModifiedCal.getTimeInMillis(); long now = cal.getTimeInMillis(); @@ -97,34 +91,29 @@ public class T3StaticContentLoader extends DefaultStaticContentLoader { response.setHeader("Pragma", "no-cache"); response.setHeader("Expires", "-1"); } - try { copy(is, response.getOutputStream(), path); - } finally { is.close(); } } } - protected void copy(InputStream input, - OutputStream output, - String path) throws IOException { + protected void copy(InputStream input, OutputStream output, String path) throws IOException { if (path.contains(".js")) { - String content = IOUtils.toString(input); + String content = IOUtils.toString(input, Charsets.UTF_8); if (content.indexOf("/") == 1) { - // fix nasty first strange caracter for ckeditor (only on firefox :() + // fix nasty first strange character for ckeditor (only on firefox :() content = content.substring(1); } - if (log.isDebugEnabled()) { - log.debug("Content:\n" + content); - } + log.debug("Content:\n" + content); // always want to have file in IS0 (even if we serve UTF8 files) + //FIXME Why should we serve ISO ? IOUtils.write(content, output, Charsets.ISO_8859_1); } else { - // no special tratment for other files + // no special treatment for other files IOUtils.copy(input, output); } } ===================================== t3-web/src/main/java/fr/ird/t3/web/actions/T3ActionSupport.java ===================================== --- a/t3-web/src/main/java/fr/ird/t3/web/actions/T3ActionSupport.java +++ b/t3-web/src/main/java/fr/ird/t3/web/actions/T3ActionSupport.java @@ -21,7 +21,6 @@ package fr.ird.t3.web.actions; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Maps; import com.google.common.collect.Multimap; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionSupport; @@ -63,6 +62,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Date; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.function.Supplier; @@ -261,7 +261,7 @@ public class T3ActionSupport extends ActionSupport implements T3TopiaPersistence } protected Map<String, String> createTimeSteps() { - Map<String, String> timeSteps = Maps.newLinkedHashMap(); + Map<String, String> timeSteps = new LinkedHashMap<>(); for (int i = 1; i < 13; i++) { timeSteps.put("" + i, "" + i); } ===================================== t3-web/src/main/java/fr/ird/t3/web/actions/io/output/ExportConfigureAction.java ===================================== --- a/t3-web/src/main/java/fr/ird/t3/web/actions/io/output/ExportConfigureAction.java +++ b/t3-web/src/main/java/fr/ird/t3/web/actions/io/output/ExportConfigureAction.java @@ -8,19 +8,18 @@ * 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.web.actions.io.output; -import com.google.common.collect.Maps; import fr.ird.t3.actions.io.output.ExportConfiguration; import fr.ird.t3.entities.T3EntityHelper; import fr.ird.t3.entities.data.Trip; @@ -49,6 +48,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -116,14 +116,13 @@ public class ExportConfigureAction extends AbstractConfigureAction<ExportConfigu // make sur configuration is inited before all getConfiguration(); - operations = Maps.newLinkedHashMap(); + operations = new LinkedHashMap<>(); - for (T3OutputOperation operation : - getT3OutputService().getOperations(configuration.getOutputProviderId())) { + for (T3OutputOperation operation : getT3OutputService().getOperations(configuration.getOutputProviderId())) { operations.put(operation.getId(), operation.getLibelle(getLocale())); } - // inject everything needed (daos, ...) + // inject everything needed (dao, ...) injectExcept(InjectDecoratedBeans.class); boolean configurationInSession = isConfigurationInSession(); ===================================== t3-web/src/main/java/fr/ird/t3/web/actions/json/GetOutputProviderOperationsAction.java ===================================== --- a/t3-web/src/main/java/fr/ird/t3/web/actions/json/GetOutputProviderOperationsAction.java +++ b/t3-web/src/main/java/fr/ird/t3/web/actions/json/GetOutputProviderOperationsAction.java @@ -8,24 +8,24 @@ * 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.web.actions.json; -import com.google.common.collect.Maps; import fr.ird.t3.io.output.T3OutputOperation; import fr.ird.t3.web.actions.T3ActionSupport; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import java.util.LinkedHashMap; import java.util.Map; @@ -39,13 +39,10 @@ public class GetOutputProviderOperationsAction extends T3ActionSupport { private static final long serialVersionUID = 1L; - /** Logger. */ - private static final Log log = - LogFactory.getLog(GetOutputProviderOperationsAction.class); + private static final Log log = LogFactory.getLog(GetOutputProviderOperationsAction.class); - protected String outputProviderId; - - protected Map<String, String> operations; + private String outputProviderId; + private Map<String, String> operations; public void setOutputProviderId(String outputProviderId) { this.outputProviderId = outputProviderId; @@ -57,18 +54,11 @@ public class GetOutputProviderOperationsAction extends T3ActionSupport { @Override public String execute() { - - if (log.isInfoEnabled()) { - log.info("outputProviderId = " + outputProviderId); - } - - operations = Maps.newLinkedHashMap(); - - for (T3OutputOperation operation : - getT3OutputService().getOperations(outputProviderId)) { + log.info(String.format("outputProviderId = %s", outputProviderId)); + operations = new LinkedHashMap<>(); + for (T3OutputOperation operation : getT3OutputService().getOperations(outputProviderId)) { operations.put(operation.getId(), operation.getLibelle(getLocale())); } - return SUCCESS; } } ===================================== t3-web/src/main/java/fr/ird/t3/web/actions/json/GetZoneVersionsAction.java ===================================== --- a/t3-web/src/main/java/fr/ird/t3/web/actions/json/GetZoneVersionsAction.java +++ b/t3-web/src/main/java/fr/ird/t3/web/actions/json/GetZoneVersionsAction.java @@ -8,19 +8,18 @@ * 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.web.actions.json; -import com.google.common.collect.Maps; import fr.ird.t3.entities.reference.zone.ZoneStratumAwareMeta; import fr.ird.t3.entities.reference.zone.ZoneVersion; import fr.ird.t3.web.actions.T3ActionSupport; @@ -28,6 +27,7 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -41,14 +41,11 @@ public class GetZoneVersionsAction extends T3ActionSupport { private static final long serialVersionUID = 1L; - /** Logger. */ - private static final Log log = - LogFactory.getLog(GetZoneVersionsAction.class); + private static final Log log = LogFactory.getLog(GetZoneVersionsAction.class); /** Selected zoneTypeId. */ - protected String zoneTypeId; - - protected Map<String, String> zoneVersions; + private String zoneTypeId; + private Map<String, String> zoneVersions; public void setZoneTypeId(String zoneTypeId) { this.zoneTypeId = zoneTypeId; @@ -60,23 +57,12 @@ public class GetZoneVersionsAction extends T3ActionSupport { @Override public String execute() { - - if (log.isInfoEnabled()) { - log.info("zoneTypeId = " + zoneTypeId); - } - - zoneVersions = Maps.newLinkedHashMap(); - + log.info(String.format("zoneTypeId = %s", zoneTypeId)); + zoneVersions = new LinkedHashMap<>(); if (!StringUtils.isEmpty(zoneTypeId)) { - - ZoneStratumAwareMeta zoneType = - getZoneStratumService().getZoneMetaById(zoneTypeId); - - List<ZoneVersion> allVersions = - zoneType.getAllZoneVersions(getT3TopiaPersistenceContext().get()); - + ZoneStratumAwareMeta zoneType = getZoneStratumService().getZoneMetaById(zoneTypeId); + List<ZoneVersion> allVersions = zoneType.getAllZoneVersions(getT3TopiaPersistenceContext().get()); zoneVersions = sortAndDecorateIdAbles(allVersions); - } return SUCCESS; } ===================================== t3-web/src/main/resources/i18n/t3-web_en_GB.properties ===================================== --- a/t3-web/src/main/resources/i18n/t3-web_en_GB.properties +++ b/t3-web/src/main/resources/i18n/t3-web_en_GB.properties @@ -267,7 +267,7 @@ t3.label.data.level3.configuration.samplesToUse=Treatment to apply to catches wi t3.label.data.level3.configuration.step1=Level 3 configuration step 1 t3.label.data.level3.configuration.step2=Level 3 configuration step 2 t3.label.data.level3.configuration.useAllSamples=Keep their own sample (do nothing) -t3.label.data.level3.configuration.useCatchSamples=Apply length structures from the sample statrum +t3.label.data.level3.configuration.useCatchSamples=Apply length structures from the sample stratum t3.label.data.level3.configuration.useWeightCategories=Use weight categories t3.label.data.level3.configuration.useWeightCategoriesOrNot=Extrapolation method t3.label.data.treatment.level0=Level 0 treatment ===================================== t3-web/src/main/webapp/WEB-INF/jsp/admin/tripDetail.jsp ===================================== --- a/t3-web/src/main/webapp/WEB-INF/jsp/admin/tripDetail.jsp +++ b/t3-web/src/main/webapp/WEB-INF/jsp/admin/tripDetail.jsp @@ -72,9 +72,7 @@ <s:label value='%{loch}' label="%{getText('t3.common.loch')}"/> - <s:label value='%{getBoolean(logBookAvailability)}' - label="%{getText('t3.common.logBookAvailability')}"/> - <s:label value='%{getText(tripType)}' + <s:label value='%{tripType.label}' label="%{getText('t3.common.tripType')}"/> <s:label value='%{getBoolean(fishHoldEmpty)}' label="%{getText('t3.common.fishHoldEmpty')}"/> View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/7b035f837397ea3df73975985a2af3054... --- View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/7b035f837397ea3df73975985a2af3054... You're receiving this email because of your account on gitlab.com.