Tony CHEMIT pushed to branch develop at ultreiaio / ird-t3
Commits:
-
7b035f83
by Tony CHEMIT at 2018-03-08T14:53:16Z
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:
| ... | ... | @@ -28,7 +28,13 @@ image: registry.gitlab.com/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/docker:lat |
| 28 | 28 |
environment:
|
| 29 | 29 |
name: test
|
| 30 | 30 |
script:
|
| 31 |
- - if [ -n "${BUILD_FOR_RELEASE}" ]; then ultreiaio-maven-execute 'clean verify -U -DperformRelease -Dmaven.javadoc.skip'; fi
|
|
| 31 |
+ - if [ -n "${BUILD_FOR_RELEASE}" ]; then ultreiaio-maven-execute 'clean verify -U -DperformRelease -Dmaven.source.skip -Dmaven.javadoc.skip'; fi
|
|
| 32 |
+ |
|
| 33 |
+.deploy-snapshot: &deploy-snapshot
|
|
| 34 |
+ environment:
|
|
| 35 |
+ name: snapshot
|
|
| 36 |
+ script:
|
|
| 37 |
+ - if [ -n "${DEPLOY_SNAPSHOT}" ]; then ultreiaio-maven-execute 'clean deploy -am -rf t3-domain -DperformRelease -Dmaven.source.skip -Dmaven.javadoc.skip'; fi
|
|
| 32 | 38 |
|
| 33 | 39 |
.publish-site: &publish-site
|
| 34 | 40 |
environment:
|
| ... | ... | @@ -84,6 +90,11 @@ trigger-build-for-release: |
| 84 | 90 |
<<: *triggers
|
| 85 | 91 |
<<: *build-for-release
|
| 86 | 92 |
|
| 93 |
+trigger-deploy-snapshot:
|
|
| 94 |
+ <<: *stage_release
|
|
| 95 |
+ <<: *triggers
|
|
| 96 |
+ <<: *deploy-snapshot
|
|
| 97 |
+ |
|
| 87 | 98 |
trigger-deploy-demo:
|
| 88 | 99 |
<<: *stage_test
|
| 89 | 100 |
<<: *triggers
|
| ... | ... | @@ -167,6 +178,13 @@ create-docker: |
| 167 | 178 |
before_script:
|
| 168 | 179 |
- export CREATE_DOCKER=true
|
| 169 | 180 |
|
| 181 |
+deploy-snapshot:
|
|
| 182 |
+ <<: *stage_release
|
|
| 183 |
+ <<: *manual
|
|
| 184 |
+ <<: *deploy-snapshot
|
|
| 185 |
+ before_script:
|
|
| 186 |
+ - export DEPLOY_SNAPSHOT=true
|
|
| 187 |
+ |
|
| 170 | 188 |
make-release:
|
| 171 | 189 |
<<: *stage_release
|
| 172 | 190 |
<<: *manual
|
| ... | ... | @@ -50,20 +50,19 @@ import static org.nuiton.i18n.I18n.l; |
| 50 | 50 |
*/
|
| 51 | 51 |
public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configuration> {
|
| 52 | 52 |
|
| 53 |
- /** Logger. */
|
|
| 54 | 53 |
private static final Log log = LogFactory.getLog(ComputeRF1Action.class);
|
| 55 | 54 |
/** total catch weight for trips with rf1 != null. */
|
| 56 |
- protected float totalCatchWeightRF1;
|
|
| 55 |
+ float totalCatchWeightRF1;
|
|
| 57 | 56 |
/** total landing weight for trips with rf1 != null. */
|
| 58 |
- protected float totalLandingWeight;
|
|
| 57 |
+ float totalLandingWeight;
|
|
| 59 | 58 |
/** Number of trips rejected (with no logbook). */
|
| 60 |
- protected int nbRejectedTrips;
|
|
| 59 |
+ int nbRejectedTrips;
|
|
| 61 | 60 |
/** Number of accepted trips (says with a rf1 computation). */
|
| 62 |
- protected int nbAcceptedTrips;
|
|
| 61 |
+ int nbAcceptedTrips;
|
|
| 63 | 62 |
/** Number of accepted complete trips (says with a rf1 computation). */
|
| 64 |
- protected int nbCompleteAcceptedTrips;
|
|
| 63 |
+ int nbCompleteAcceptedTrips;
|
|
| 65 | 64 |
/** Number of complete accepted trips (says with a rf1 computation, but not in defined bound). */
|
| 66 |
- protected int nbCompleteAcceptedTripsWithBadRF1;
|
|
| 65 |
+ int nbCompleteAcceptedTripsWithBadRF1;
|
|
| 67 | 66 |
@InjectDAO(entityType = RF1SpeciesForFleet.class)
|
| 68 | 67 |
private RF1SpeciesForFleetTopiaDao rF1SpecieForFleetDAO;
|
| 69 | 68 |
/** usable trips group by vessel */
|
| ... | ... | @@ -205,7 +204,6 @@ public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configurati |
| 205 | 204 |
treatCompleteTrip(completeTrip, species, minimumRate, maximumRate);
|
| 206 | 205 |
// complete trip was consumed
|
| 207 | 206 |
completeTrip.removeTrips(tripList);
|
| 208 |
-// tripList.removeAll(completeTrip);
|
|
| 209 | 207 |
}
|
| 210 | 208 |
if (CollectionUtils.isNotEmpty(tripList)) {
|
| 211 | 209 |
// still some trips not complete
|
| ... | ... | @@ -289,7 +287,7 @@ public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configurati |
| 289 | 287 |
for (Trip trip : trips) {
|
| 290 | 288 |
String tripStr = decorate(trip);
|
| 291 | 289 |
Float rf1ToUse = rf1;
|
| 292 |
- if (trip.getLogBookAvailability() != 1) {
|
|
| 290 |
+ if (!trip.isWithLogbook()) {
|
|
| 293 | 291 |
// means can not apply any rf1 : rf1 must stay at null...
|
| 294 | 292 |
rf1ToUse = null;
|
| 295 | 293 |
addWarningMessage(l(locale, "t3.level0.computeRF1.warning.no.logbook", tripStr));
|
| ... | ... | @@ -309,28 +307,6 @@ public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configurati |
| 309 | 307 |
decorate(completeTrip.getLandingTrip()), tripTotalCatchWeightRf1, tripTotalLandingWeight));
|
| 310 | 308 |
log.debug(String.format("After trip %s totalCatchWeightRF1 = %s totalLandingWeight = %s",
|
| 311 | 309 |
decorate(completeTrip.getLandingTrip()), totalCatchWeightRF1, totalLandingWeight));
|
| 312 |
-// for (Trip trip : completeTrip) {
|
|
| 313 |
-//
|
|
| 314 |
-// float tripTotalCatchWeightRf1 =
|
|
| 315 |
-// trip.getElementaryCatchTotalWeightRf1(species);
|
|
| 316 |
-// totalCatchWeightRF1 += tripTotalCatchWeightRf1;
|
|
| 317 |
-//
|
|
| 318 |
-// float tripTotalLandingWeight =
|
|
| 319 |
-// trip.getElementaryLandingTotalWeight(species);
|
|
| 320 |
-// totalLandingWeight += tripTotalLandingWeight;
|
|
| 321 |
-//
|
|
| 322 |
-// if (log.isInfoEnabled()) {
|
|
| 323 |
-//
|
|
| 324 |
-// log.info("After trip " + decorate(trip) +
|
|
| 325 |
-// " tripTotalCatchWeightRf1 = " + tripTotalCatchWeightRf1 +
|
|
| 326 |
-// " tripTotalLandingWeight = " + tripTotalLandingWeight);
|
|
| 327 |
-// }
|
|
| 328 |
-// if (log.isDebugEnabled()) {
|
|
| 329 |
-// log.debug("After trip " + decorate(trip) +
|
|
| 330 |
-// " totalCatchWeightRF1 = " + totalCatchWeightRF1 +
|
|
| 331 |
-// " totalLandingWeight = " + totalLandingWeight);
|
|
| 332 |
-// }
|
|
| 333 |
-// }
|
|
| 334 | 310 |
}
|
| 335 | 311 |
|
| 336 | 312 |
private float computeRF1ForCompleteTrip(Iterable<Trip> completeTrip, Collection<Species> speciesList) {
|
| ... | ... | @@ -82,7 +82,6 @@ public class AnalyzeInputSourceAction extends T3Action<AnalyzeInputSourceConfigu |
| 82 | 82 |
private T3Input inputPilot;
|
| 83 | 83 |
private boolean safe;
|
| 84 | 84 |
|
| 85 |
- // Ne pas supprimer, utilisé dans la template de résumé
|
|
| 86 | 85 |
@SuppressWarnings("unused")
|
| 87 | 86 |
public Trip getTripToReplace(Trip trip) {
|
| 88 | 87 |
Map<Trip, Trip> resultAsMap = getResultAsMap(RESULT_TRIPS_TO_REPLACE);
|
| ... | ... | @@ -117,10 +116,8 @@ public class AnalyzeInputSourceAction extends T3Action<AnalyzeInputSourceConfigu |
| 117 | 116 |
}
|
| 118 | 117 |
String[] analyzeWarnings = inputPilot.getAnalyzeWarnings();
|
| 119 | 118 |
if (analyzeWarnings != null && analyzeWarnings.length > 0) {
|
| 120 |
- // some errors on db
|
|
| 121 |
- StringBuilder sb = new StringBuilder(
|
|
| 122 |
- l(locale, "t3.import.warning.on.analyze", analyzeWarnings.length)
|
|
| 123 |
- );
|
|
| 119 |
+ // some warnings on db
|
|
| 120 |
+ StringBuilder sb = new StringBuilder(l(locale, "t3.import.warning.on.analyze", analyzeWarnings.length));
|
|
| 124 | 121 |
for (String analyzeWarning : analyzeWarnings) {
|
| 125 | 122 |
sb.append('\n').append(analyzeWarning);
|
| 126 | 123 |
}
|
| ... | ... | @@ -224,7 +221,6 @@ public class AnalyzeInputSourceAction extends T3Action<AnalyzeInputSourceConfigu |
| 224 | 221 |
}
|
| 225 | 222 |
putResult(RESULT_SAFE_TRIPS, safeTrips);
|
| 226 | 223 |
putResult(RESULT_UNSAFE_TRIPS, unsafeTrips);
|
| 227 |
- |
|
| 228 | 224 |
// while analyzing db, nothing to commit in db
|
| 229 | 225 |
return false;
|
| 230 | 226 |
} finally {
|
| ... | ... | @@ -245,11 +241,9 @@ public class AnalyzeInputSourceAction extends T3Action<AnalyzeInputSourceConfigu |
| 245 | 241 |
if (!withWell) {
|
| 246 | 242 |
// no well for this trip can remove all missing fk for wells
|
| 247 | 243 |
addWarningMessage(l(locale, "t3.import.warning.no.wellPlan", decorate(trip)));
|
| 248 |
- |
|
| 249 | 244 |
// remove missing keys Sample->Well since there is no well
|
| 250 | 245 |
removeWellMissingForeignKeys(missingForeignKeys, false, SAMPLE_TO_WELL, missingFkToMessage);
|
| 251 |
- |
|
| 252 |
- // remove missing keys WellPlan->Activity Ssince there is no well
|
|
| 246 |
+ // remove missing keys WellPlan->Activity since there is no well
|
|
| 253 | 247 |
removeWellMissingForeignKeys(missingForeignKeys, true, WELL_PLAN_TO_ACTIVITY, missingFkToMessage);
|
| 254 | 248 |
} else {
|
| 255 | 249 |
// there is some wells for this trip
|
| ... | ... | @@ -282,6 +276,11 @@ public class AnalyzeInputSourceAction extends T3Action<AnalyzeInputSourceConfigu |
| 282 | 276 |
addInfoMessage(l(locale, "t3.import.message.use.new.vessel.for.trip", decorate(vessel), decorate(trip)));
|
| 283 | 277 |
}
|
| 284 | 278 |
}
|
| 279 |
+ String tripTypeNotSafeMessage = inputPilot.getTripTypeNotSafeMessage(trip);
|
|
| 280 |
+ if (tripTypeNotSafeMessage != null) {
|
|
| 281 |
+ tripSafe = false;
|
|
| 282 |
+ addInfoMessage(l(locale, "t3.import.error.bad.tripType", decorate(trip), tripTypeNotSafeMessage));
|
|
| 283 |
+ }
|
|
| 285 | 284 |
//TODO Use this when Will have exact list of entities to exclude...
|
| 286 | 285 |
// check we are not using bad references
|
| 287 | 286 |
// tripSafe &= checkReferences(trip, entitiesUsed);
|
| ... | ... | @@ -30,7 +30,7 @@ Time step: ${configuration.timeStep} |
| 30 | 30 |
|
| 31 | 31 |
Treatment to apply to catches with samples:
|
| 32 | 32 |
<#if configuration.useAllSamplesOfStratum>
|
| 33 |
-Apply length structures from the sample statrum
|
|
| 33 |
+Apply length structures from the sample stratum
|
|
| 34 | 34 |
<#else>
|
| 35 | 35 |
Keep their own samples (do nothing)
|
| 36 | 36 |
</#if>
|
| ... | ... | @@ -3,6 +3,7 @@ t3.admin.deleteTrip=Delete trip %s |
| 3 | 3 |
t3.admin.deleteTripDatas=Delete data of trip %s
|
| 4 | 4 |
t3.common.rf1.maximumRate.acceptable=Maximum acceptable rf1 rate
|
| 5 | 5 |
t3.common.rf1.minimumRate.acceptable=Minimum acceptable rf1 rate
|
| 6 |
+t3.import.error.bad.tripType=Trip type is not consistent\: %s
|
|
| 6 | 7 |
t3.import.error.badReferenceCode=Trip %s uses a reference of type %s with forbidden code %s
|
| 7 | 8 |
t3.import.error.missingForeignKey=It miss on trip %s foreign keys from %s %s to %s %s
|
| 8 | 9 |
t3.import.error.missingForeignKeyInT3=On trip %s, it miss in T3+ referentials, entity %s (natural key\: %s)
|
| ... | ... | @@ -3,6 +3,7 @@ t3.admin.deleteTrip=Suppresion de la marée %s |
| 3 | 3 |
t3.admin.deleteTripDatas=Suppresion des données de la marée %s
|
| 4 | 4 |
t3.common.rf1.maximumRate.acceptable=Seuil maximum acceptable du rf1
|
| 5 | 5 |
t3.common.rf1.minimumRate.acceptable=Seuil minimum acceptable du rf1
|
| 6 |
+t3.import.error.bad.tripType=Le type de la marée %s n'est pas cohérent \: %s
|
|
| 6 | 7 |
t3.import.error.badReferenceCode=La marée %s utilise un référentiel de type %s avec le code %s
|
| 7 | 8 |
t3.import.error.missingForeignKey=Il manque sur la marée %s des clefs étrangères type %s %s vers %s %s
|
| 8 | 9 |
t3.import.error.missingForeignKeyInT3=Pour la marée %s, il manque dans le référentiel T3+ l'entité %s (clef métier\: %s)
|
| ... | ... | @@ -63,19 +63,13 @@ public class ComputeRF1ActionResumeTest extends AbstractActionResumeTest<Compute |
| 63 | 63 |
|
| 64 | 64 |
@Override
|
| 65 | 65 |
protected Map<String, Object> createTemplateParameters() {
|
| 66 |
- |
|
| 67 | 66 |
Map<String, Object> parameters = super.createTemplateParameters();
|
| 68 |
- |
|
| 69 | 67 |
Map<String, String> vesselSimpleTypes = new TreeMap<>();
|
| 70 |
- putInMap(vesselSimpleTypes,
|
|
| 71 |
- fixtures.vesselSimpleTypeCanneur(),
|
|
| 72 |
- fixtures.vesselSimpleTypeSenneur());
|
|
| 68 |
+ putInMap(vesselSimpleTypes, fixtures.vesselSimpleTypeCanneur(), fixtures.vesselSimpleTypeSenneur());
|
|
| 73 | 69 |
parameters.put("vesselSimpleTypes", vesselSimpleTypes);
|
| 74 |
- |
|
| 75 | 70 |
Map<String, String> fleets = new TreeMap<>();
|
| 76 | 71 |
putInMap(fleets, fixtures.frenchCountry());
|
| 77 | 72 |
parameters.put("fleets", fleets);
|
| 78 |
- |
|
| 79 | 73 |
return parameters;
|
| 80 | 74 |
}
|
| 81 | 75 |
|
| ... | ... | @@ -8,12 +8,12 @@ |
| 8 | 8 |
* it under the terms of the GNU Affero General Public License as published by
|
| 9 | 9 |
* the Free Software Foundation, either version 3 of the License, or
|
| 10 | 10 |
* (at your option) any later version.
|
| 11 |
- *
|
|
| 11 |
+ *
|
|
| 12 | 12 |
* This program is distributed in the hope that it will be useful,
|
| 13 | 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 14 | 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 15 | 15 |
* GNU General Public License for more details.
|
| 16 |
- *
|
|
| 16 |
+ *
|
|
| 17 | 17 |
* You should have received a copy of the GNU Affero General Public License
|
| 18 | 18 |
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
| 19 | 19 |
* #L%
|
| ... | ... | @@ -45,38 +45,6 @@ import java.util.function.Predicate; |
| 45 | 45 |
*/
|
| 46 | 46 |
public class T3Predicates {
|
| 47 | 47 |
|
| 48 |
-// /**
|
|
| 49 |
-// * Predicates that trip has no data computed.
|
|
| 50 |
-// *
|
|
| 51 |
-// * @see Trip#isNoDataComputed()
|
|
| 52 |
-// * @since 1.1
|
|
| 53 |
-// */
|
|
| 54 |
-// public static final Predicate<Trip> TRIP_WITH_NO_DATA_COMPUTED = Trip::isNoDataComputed;
|
|
| 55 |
-//
|
|
| 56 |
-// /**
|
|
| 57 |
-// * Predicates that trip has some data computed.
|
|
| 58 |
-// *
|
|
| 59 |
-// * @see Trip#isSomeDataComputed()
|
|
| 60 |
-// * @since 1.1
|
|
| 61 |
-// */
|
|
| 62 |
-// public static final Predicate<Trip> TRIP_WITH_SOME_DATA_COMPUTED = Trip::isSomeDataComputed;
|
|
| 63 |
-//
|
|
| 64 |
-// /**
|
|
| 65 |
-// * Predicates that trip has all his data computed.
|
|
| 66 |
-// *
|
|
| 67 |
-// * @see Trip#isAllDataComputed() ()
|
|
| 68 |
-// * @since 1.1
|
|
| 69 |
-// */
|
|
| 70 |
-// public static final Predicate<Trip> TRIP_WITH_ALL_DATA_COMPUTED = Trip::isAllDataComputed;
|
|
| 71 |
- |
|
| 72 |
- /**
|
|
| 73 |
- * Predicates that trip has a log book.
|
|
| 74 |
- *
|
|
| 75 |
- * @see Trip#getLogBookAvailability()
|
|
| 76 |
- * @since 1.1
|
|
| 77 |
- */
|
|
| 78 |
- public static final Predicate<Trip> TRIP_WITH_LOG_BOOK = input -> input.getLogBookAvailability() == 1;
|
|
| 79 |
- |
|
| 80 | 48 |
/**
|
| 81 | 49 |
* Predicates that trip ends a complete trip.
|
| 82 | 50 |
*
|
| ... | ... | @@ -85,21 +53,6 @@ public class T3Predicates { |
| 85 | 53 |
*/
|
| 86 | 54 |
public static final Predicate<Trip> TRIP_ENDS_A_COMPLETE_TRIP = input -> input.getFishHoldEmpty() == 1;
|
| 87 | 55 |
|
| 88 |
- |
|
| 89 |
-// /**
|
|
| 90 |
-// * Predicates that trip is inside a complete trip (as a simple trip or a
|
|
| 91 |
-// * partial complete trip).
|
|
| 92 |
-// * <p/>
|
|
| 93 |
-// * Notes that a such trip can be used in level 0, and 1.
|
|
| 94 |
-// *
|
|
| 95 |
-// * @see Trip#getCompletionStatus()
|
|
| 96 |
-// * @since 1.2
|
|
| 97 |
-// */
|
|
| 98 |
-// public static final Predicate<Trip> TRIP_INSIDE_A_COMPLETE_TRIP = input -> {
|
|
| 99 |
-// Integer completionStatus = input.getCompletionStatus();
|
|
| 100 |
-// return completionStatus != null && completionStatus > 0;
|
|
| 101 |
-// };
|
|
| 102 |
- |
|
| 103 | 56 |
public static final Predicate<Activity> ACTIVITY_WITH_SET_SAMPLE = input -> !input.isSetSpeciesCatWeightEmpty();
|
| 104 | 57 |
public static final Predicate<LengthWeightConversion> LENGTH_WEIGHT_CONVERSION_BY_COEFFICIENT = input -> {
|
| 105 | 58 |
boolean result = true;
|
| ... | ... | @@ -197,9 +150,7 @@ public class T3Predicates { |
| 197 | 150 |
public static Predicate<Trip> tripUsingOcean(Collection<Ocean> oceans) {
|
| 198 | 151 |
return input -> {
|
| 199 | 152 |
boolean result = false;
|
| 200 |
- |
|
| 201 |
- if (!input.isActivityEmpty()) {
|
|
| 202 |
- |
|
| 153 |
+ if (input.isActivityNotEmpty()) {
|
|
| 203 | 154 |
Set<Ocean> allOceans = input.getAllOceans();
|
| 204 | 155 |
for (Ocean ocean : allOceans) {
|
| 205 | 156 |
if (oceans.contains(ocean)) {
|
| ... | ... | @@ -273,4 +224,18 @@ public class T3Predicates { |
| 273 | 224 |
// public static <E extends TopiaEntity> Predicate<E> equalsTopiaEntity(String id) {
|
| 274 | 225 |
// return input -> id.equals(input.getTopiaId());
|
| 275 | 226 |
// }
|
| 227 |
+ |
|
| 228 |
+// /**
|
|
| 229 |
+// * Predicates that trip is inside a complete trip (as a simple trip or a partial complete trip).
|
|
| 230 |
+// * <p/>
|
|
| 231 |
+// * Notes that a such trip can be used in level 0, and 1.
|
|
| 232 |
+// *
|
|
| 233 |
+// * @see Trip#getCompletionStatus()
|
|
| 234 |
+// * @since 1.2
|
|
| 235 |
+// */
|
|
| 236 |
+// public static final Predicate<Trip> TRIP_INSIDE_A_COMPLETE_TRIP = input -> {
|
|
| 237 |
+// Integer completionStatus = input.getCompletionStatus();
|
|
| 238 |
+// return completionStatus != null && completionStatus > 0;
|
|
| 239 |
+// };
|
|
| 240 |
+ |
|
| 276 | 241 |
}
|
| ... | ... | @@ -49,6 +49,7 @@ import java.sql.PreparedStatement; |
| 49 | 49 |
import java.sql.ResultSet;
|
| 50 | 50 |
import java.sql.SQLException;
|
| 51 | 51 |
import java.util.ArrayList;
|
| 52 |
+import java.util.Arrays;
|
|
| 52 | 53 |
import java.util.Collection;
|
| 53 | 54 |
import java.util.Collections;
|
| 54 | 55 |
import java.util.Comparator;
|
| ... | ... | @@ -69,12 +70,57 @@ import java.util.stream.StreamSupport; |
| 69 | 70 |
public class AbstractTripTopiaDao<E extends Trip> extends GeneratedTripTopiaDao<E> {
|
| 70 | 71 |
|
| 71 | 72 |
public static final Ocean EMPTY_OCEAN = new OceanImpl();
|
| 73 |
+ private static final int TRIP_WITHOUT_LOGBOOK = 0;
|
|
| 74 |
+ private static final int TRIP_WITH_LOGBOOK = 1;
|
|
| 72 | 75 |
private static final Log log = LogFactory.getLog(AbstractTripTopiaDao.class);
|
| 73 | 76 |
|
| 74 | 77 |
static {
|
| 75 | 78 |
EMPTY_OCEAN.setTopiaId("fr.ird.t3.entities.reference.Ocean#EMPTY#EMPTY");
|
| 76 | 79 |
}
|
| 77 | 80 |
|
| 81 |
+ /**
|
|
| 82 |
+ * Check that a standard trip ({@link TripType#STANDARD}) is consistent with {@code logBookAvailability} flag.
|
|
| 83 |
+ *
|
|
| 84 |
+ * @param trip trip to check
|
|
| 85 |
+ * @param pKey primary key of this trip
|
|
| 86 |
+ */
|
|
| 87 |
+ public static void checkAndSetStandardTripType(Trip trip, Object[] pKey) {
|
|
| 88 |
+ int logBookAvailability = trip.getLogBookAvailability();
|
|
| 89 |
+ switch (logBookAvailability) {
|
|
| 90 |
+ case TRIP_WITHOUT_LOGBOOK:
|
|
| 91 |
+ if (trip.isActivityNotEmpty()) {
|
|
| 92 |
+ trip.setTripType(TripType.STANDARD);
|
|
| 93 |
+ throw new IllegalStateException(String.format("Trip [%s] has some logBook but logBookAvailability says the opposite, please fix this trip.", Arrays.toString(pKey)));
|
|
| 94 |
+ }
|
|
| 95 |
+ trip.setTripType(TripType.LOGBOOKMISSING);
|
|
| 96 |
+ break;
|
|
| 97 |
+ case TRIP_WITH_LOGBOOK:
|
|
| 98 |
+ if (trip.isActivityEmpty()) {
|
|
| 99 |
+ trip.setTripType(TripType.LOGBOOKMISSING);
|
|
| 100 |
+ throw new IllegalStateException(String.format("Trip [%s] has some logBook but logBookAvailability says the opposite, please fix this trip.", Arrays.toString(pKey)));
|
|
| 101 |
+ }
|
|
| 102 |
+ trip.setTripType(TripType.STANDARD);
|
|
| 103 |
+ break;
|
|
| 104 |
+ }
|
|
| 105 |
+ }
|
|
| 106 |
+ |
|
| 107 |
+ /**
|
|
| 108 |
+ * Check that a standard trip ({@link TripType#LOGBOOKMISSING}) is consistent with {@code logBookAvailability} flag.
|
|
| 109 |
+ *
|
|
| 110 |
+ * @param trip trip to check
|
|
| 111 |
+ * @param pKey primary key of this trip
|
|
| 112 |
+ */
|
|
| 113 |
+ public static void checkAndSetLogbookMissingTripType(Trip trip, Object[] pKey) {
|
|
| 114 |
+ int logBookAvailability = trip.getLogBookAvailability();
|
|
| 115 |
+ if (trip.getTripType() == TripType.LOGBOOKMISSING) {
|
|
| 116 |
+ if (TRIP_WITH_LOGBOOK == logBookAvailability) {
|
|
| 117 |
+ throw new IllegalStateException(String.format("Trip %s has no logBook but logBookAvailability says the opposite, please fix this trip.", Arrays.toString(pKey)));
|
|
| 118 |
+ }
|
|
| 119 |
+ } else {
|
|
| 120 |
+ checkAndSetStandardTripType(trip, pKey);
|
|
| 121 |
+ }
|
|
| 122 |
+ }
|
|
| 123 |
+ |
|
| 78 | 124 |
public static String getSamplesOnlyFilter(String prefix, Boolean samplesOnly) {
|
| 79 | 125 |
if (samplesOnly == null) {
|
| 80 | 126 |
return "";
|
| ... | ... | @@ -138,7 +184,7 @@ public class AbstractTripTopiaDao<E extends Trip> extends GeneratedTripTopiaDao< |
| 138 | 184 |
}
|
| 139 | 185 |
|
| 140 | 186 |
public static boolean isTripsAllWithLogBook(Iterable<Trip> trips) {
|
| 141 |
- return StreamSupport.stream(trips.spliterator(), false).allMatch(T3Predicates.TRIP_WITH_LOG_BOOK);
|
|
| 187 |
+ return StreamSupport.stream(trips.spliterator(), false).allMatch(Trip::isWithLogbook);
|
|
| 142 | 188 |
}
|
| 143 | 189 |
|
| 144 | 190 |
/**
|
| ... | ... | @@ -8,12 +8,12 @@ |
| 8 | 8 |
* it under the terms of the GNU Affero General Public License as published by
|
| 9 | 9 |
* the Free Software Foundation, either version 3 of the License, or
|
| 10 | 10 |
* (at your option) any later version.
|
| 11 |
- *
|
|
| 11 |
+ *
|
|
| 12 | 12 |
* This program is distributed in the hope that it will be useful,
|
| 13 | 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 14 | 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 15 | 15 |
* GNU General Public License for more details.
|
| 16 |
- *
|
|
| 16 |
+ *
|
|
| 17 | 17 |
* You should have received a copy of the GNU Affero General Public License
|
| 18 | 18 |
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
| 19 | 19 |
* #L%
|
| ... | ... | @@ -63,8 +63,9 @@ public class TripImpl extends TripAbstract { |
| 63 | 63 |
}
|
| 64 | 64 |
|
| 65 | 65 |
private transient Boolean level2Computed;
|
| 66 |
- |
|
| 67 | 66 |
private transient Boolean level3Computed;
|
| 67 |
+ // only used for avdth import
|
|
| 68 |
+ private transient int logBookAvailability;
|
|
| 68 | 69 |
|
| 69 | 70 |
@Override
|
| 70 | 71 |
public boolean isSomeDataComputed() {
|
| ... | ... | @@ -91,6 +92,12 @@ public class TripImpl extends TripAbstract { |
| 91 | 92 |
return TripType.LOGBOOKMISSING == getTripType();
|
| 92 | 93 |
}
|
| 93 | 94 |
|
| 95 |
+ @Override
|
|
| 96 |
+ public boolean isWithLogbook() {
|
|
| 97 |
+ return TripType.STANDARD == getTripType();
|
|
| 98 |
+ }
|
|
| 99 |
+ |
|
| 100 |
+ @SuppressWarnings("WeakerAccess")
|
|
| 94 | 101 |
public boolean isLevel2Computed() {
|
| 95 | 102 |
if (level2Computed == null) {
|
| 96 | 103 |
level2Computed = false;
|
| ... | ... | @@ -108,6 +115,7 @@ public class TripImpl extends TripAbstract { |
| 108 | 115 |
return level2Computed;
|
| 109 | 116 |
}
|
| 110 | 117 |
|
| 118 |
+ @SuppressWarnings("WeakerAccess")
|
|
| 111 | 119 |
public boolean isLevel3Computed() {
|
| 112 | 120 |
if (level3Computed == null) {
|
| 113 | 121 |
level3Computed = false;
|
| ... | ... | @@ -137,7 +145,19 @@ public class TripImpl extends TripAbstract { |
| 137 | 145 |
return result;
|
| 138 | 146 |
}
|
| 139 | 147 |
|
| 140 |
-// /** @return the sum of all activities set duration in hours. */
|
|
| 148 |
+ // only used for avdth import
|
|
| 149 |
+ @Override
|
|
| 150 |
+ public int getLogBookAvailability() {
|
|
| 151 |
+ return logBookAvailability;
|
|
| 152 |
+ }
|
|
| 153 |
+ |
|
| 154 |
+ // only used for avdth import
|
|
| 155 |
+ @Override
|
|
| 156 |
+ public void setLogBookAvailability(int logbookAvaibility) {
|
|
| 157 |
+ this.logBookAvailability = logbookAvaibility;
|
|
| 158 |
+ }
|
|
| 159 |
+ |
|
| 160 |
+ // /** @return the sum of all activities set duration in hours. */
|
|
| 141 | 161 |
// @Override
|
| 142 | 162 |
// public float getTotalSetsDuration() {
|
| 143 | 163 |
// float result = 0;
|
| ... | ... | @@ -121,6 +121,8 @@ public interface T3Input { |
| 121 | 121 |
*/
|
| 122 | 122 |
List<MissingForeignKey> getMissingForeignKeys(Trip trip);
|
| 123 | 123 |
|
| 124 |
+ String getTripTypeNotSafeMessage(Trip trip);
|
|
| 125 |
+ |
|
| 124 | 126 |
/**
|
| 125 | 127 |
* Method to clean input internal states.
|
| 126 | 128 |
* <p/>
|
| ... | ... | @@ -25,6 +25,7 @@ import fr.ird.t3.entities.ReferenceEntityMap; |
| 25 | 25 |
import fr.ird.t3.entities.T3EntityEnum;
|
| 26 | 26 |
import fr.ird.t3.entities.T3EntityMap;
|
| 27 | 27 |
import fr.ird.t3.entities.data.Trip;
|
| 28 |
+import fr.ird.t3.entities.data.TripTopiaDao;
|
|
| 28 | 29 |
import fr.ird.t3.entities.data.TripType;
|
| 29 | 30 |
import fr.ird.t3.entities.reference.Vessel;
|
| 30 | 31 |
import fr.ird.t3.io.input.MissingForeignKey;
|
| ... | ... | @@ -39,9 +40,11 @@ import org.nuiton.topia.persistence.TopiaException; |
| 39 | 40 |
import java.beans.PropertyChangeEvent;
|
| 40 | 41 |
import java.beans.PropertyChangeListener;
|
| 41 | 42 |
import java.io.File;
|
| 43 |
+import java.util.ArrayList;
|
|
| 42 | 44 |
import java.util.Arrays;
|
| 43 | 45 |
import java.util.HashMap;
|
| 44 | 46 |
import java.util.HashSet;
|
| 47 |
+import java.util.LinkedHashMap;
|
|
| 45 | 48 |
import java.util.List;
|
| 46 | 49 |
import java.util.Map;
|
| 47 | 50 |
import java.util.Set;
|
| ... | ... | @@ -56,13 +59,14 @@ import java.util.stream.Collectors; |
| 56 | 59 |
public abstract class AbstractT3InputMSAccess implements T3Input {
|
| 57 | 60 |
|
| 58 | 61 |
private static final Log log = LogFactory.getLog(AbstractT3InputMSAccess.class);
|
| 59 |
- protected T3AccessDataSource dataSource;
|
|
| 60 |
- protected T3InputConfiguration configuration;
|
|
| 61 |
- protected Map<Integer, Vessel> vessels;
|
|
| 62 |
+ private T3InputConfiguration configuration;
|
|
| 63 |
+ private Map<Integer, Vessel> vessels;
|
|
| 64 |
+ private T3AccessDataSource dataSource;
|
|
| 62 | 65 |
private ReferenceEntityMap safeReferences;
|
| 63 | 66 |
private Map<Trip, List<MissingForeignKey>> missingFK;
|
| 64 |
- private String[] errors;
|
|
| 65 |
- private String[] warnings;
|
|
| 67 |
+ private List<String> errors;
|
|
| 68 |
+ private List<String> warnings;
|
|
| 69 |
+ private Map<Trip, String> tripTypeNotSafeMessages;
|
|
| 66 | 70 |
|
| 67 | 71 |
public abstract T3AccessDataSource newDataSource(File inputFile);
|
| 68 | 72 |
|
| ... | ... | @@ -91,27 +95,25 @@ public abstract class AbstractT3InputMSAccess implements T3Input { |
| 91 | 95 |
T3AccessHitModel hitModel = new T3AccessHitModel();
|
| 92 | 96 |
hitModel.addPropertyChangeListener(new LoadDbPropertyChangeListener(t3DataTypes));
|
| 93 | 97 |
// analyse data source
|
| 94 |
- if (configuration.getTripType() == TripType.LOGBOOKMISSING) {
|
|
| 95 |
- dataSource.analyzeDb(TripType.LOGBOOKMISSING, hitModel);
|
|
| 96 |
- } else {
|
|
| 97 |
- dataSource.analyzeDb(hitModel);
|
|
| 98 |
- }
|
|
| 98 |
+ dataSource.analyzeDb(hitModel);
|
|
| 99 |
+ errors = new ArrayList<>();
|
|
| 99 | 100 |
if (dataSource.hasError()) {
|
| 100 |
- errors = dataSource.getErrors();
|
|
| 101 |
+ errors.addAll(Arrays.asList(dataSource.getErrors()));
|
|
| 101 | 102 |
}
|
| 103 |
+ warnings = new ArrayList<>();
|
|
| 102 | 104 |
if (dataSource.hasWarning()) {
|
| 103 |
- warnings = dataSource.getWarnings();
|
|
| 105 |
+ warnings.addAll(Arrays.asList(dataSource.getWarnings()));
|
|
| 104 | 106 |
}
|
| 105 | 107 |
}
|
| 106 | 108 |
|
| 107 | 109 |
@Override
|
| 108 | 110 |
public String[] getAnalyzeErrors() {
|
| 109 |
- return errors;
|
|
| 111 |
+ return errors.toArray(new String[errors.size()]);
|
|
| 110 | 112 |
}
|
| 111 | 113 |
|
| 112 | 114 |
@Override
|
| 113 | 115 |
public String[] getAnalyzeWarnings() {
|
| 114 |
- return warnings;
|
|
| 116 |
+ return warnings.toArray(new String[warnings.size()]);
|
|
| 115 | 117 |
}
|
| 116 | 118 |
|
| 117 | 119 |
@Override
|
| ... | ... | @@ -168,7 +170,7 @@ public abstract class AbstractT3InputMSAccess implements T3Input { |
| 168 | 170 |
T3EntityEnum constant = T3EntityEnum.valueOf(Trip.class);
|
| 169 | 171 |
T3AccessEntityMeta meta = dataSource.getMeta(constant);
|
| 170 | 172 |
List<Trip> entities = dataSource.loadEntities(meta);
|
| 171 |
- Map<Trip, T3EntityMap> result = Maps.newLinkedHashMap();
|
|
| 173 |
+ Map<Trip, T3EntityMap> result = new LinkedHashMap<>();
|
|
| 172 | 174 |
missingFK = new HashMap<>();
|
| 173 | 175 |
T3DataEntityVisitor dataVisitor = newDataVisitor(dataSource, safeReferences);
|
| 174 | 176 |
try {
|
| ... | ... | @@ -233,6 +235,18 @@ public abstract class AbstractT3InputMSAccess implements T3Input { |
| 233 | 235 |
return missingFK.get(trip);
|
| 234 | 236 |
}
|
| 235 | 237 |
|
| 238 |
+ @Override
|
|
| 239 |
+ public String getTripTypeNotSafeMessage(Trip trip) {
|
|
| 240 |
+ return tripTypeNotSafeMessages == null ? null : tripTypeNotSafeMessages.get(trip);
|
|
| 241 |
+ }
|
|
| 242 |
+ |
|
| 243 |
+ private void addTripTypeNotSafeMessage(Trip trip, String message) {
|
|
| 244 |
+ if (tripTypeNotSafeMessages == null) {
|
|
| 245 |
+ tripTypeNotSafeMessages = new LinkedHashMap<>();
|
|
| 246 |
+ }
|
|
| 247 |
+ tripTypeNotSafeMessages.put(trip, message);
|
|
| 248 |
+ }
|
|
| 249 |
+ |
|
| 236 | 250 |
private Trip loadTrip(int vesselCode, Trip trip, T3DataEntityVisitor dataVisitor, TripType tripType, boolean canCreateVessel) {
|
| 237 | 251 |
RemoveProxyEntityVisitor visitor = new RemoveProxyEntityVisitor();
|
| 238 | 252 |
try {
|
| ... | ... | @@ -241,8 +255,29 @@ public abstract class AbstractT3InputMSAccess implements T3Input { |
| 241 | 255 |
dataVisitor.doVisit(trip, true);
|
| 242 | 256 |
// remove proxy on data
|
| 243 | 257 |
Trip loadedTrip = visitor.doVisit(trip);
|
| 244 |
- // set tripType flag
|
|
| 245 |
- loadedTrip.setTripType(tripType);
|
|
| 258 |
+ T3AccessEntity a = (T3AccessEntity) trip;
|
|
| 259 |
+ Object[] pKey = a.getPKey();
|
|
| 260 |
+ switch (tripType) {
|
|
| 261 |
+ case STANDARD:
|
|
| 262 |
+ try {
|
|
| 263 |
+ TripTopiaDao.checkAndSetStandardTripType(loadedTrip, pKey);
|
|
| 264 |
+ } catch (Exception e) {
|
|
| 265 |
+ errors.add(e.getMessage());
|
|
| 266 |
+ }
|
|
| 267 |
+ break;
|
|
| 268 |
+ case SAMPLEONLY:
|
|
| 269 |
+ // no check
|
|
| 270 |
+ loadedTrip.setTripType(TripType.SAMPLEONLY);
|
|
| 271 |
+ break;
|
|
| 272 |
+ case LOGBOOKMISSING:
|
|
| 273 |
+ try {
|
|
| 274 |
+ TripTopiaDao.checkAndSetLogbookMissingTripType(loadedTrip, pKey);
|
|
| 275 |
+ } catch (Exception e) {
|
|
| 276 |
+ errors.add(e.getMessage());
|
|
| 277 |
+ |
|
| 278 |
+ }
|
|
| 279 |
+ break;
|
|
| 280 |
+ }
|
|
| 246 | 281 |
if (trip.getVessel() == null && canCreateVessel) {
|
| 247 | 282 |
// use new created vessel
|
| 248 | 283 |
Vessel vessel = getNewVessels().get(vesselCode);
|
| ... | ... | @@ -22,7 +22,6 @@ package fr.ird.t3.io.input.access; |
| 22 | 22 |
|
| 23 | 23 |
import fr.ird.msaccess.importer.AbstractAccessDataSource;
|
| 24 | 24 |
import fr.ird.t3.entities.T3EntityEnum;
|
| 25 |
-import fr.ird.t3.entities.data.TripType;
|
|
| 26 | 25 |
import fr.ird.t3.entities.reference.T3ReferenceEntity;
|
| 27 | 26 |
import org.apache.commons.logging.Log;
|
| 28 | 27 |
import org.apache.commons.logging.LogFactory;
|
| ... | ... | @@ -99,10 +98,6 @@ public class T3AccessDataSource extends AbstractAccessDataSource<T3EntityEnum, T |
| 99 | 98 |
}
|
| 100 | 99 |
|
| 101 | 100 |
public void analyzeDb(T3AccessHitModel hits) throws Exception {
|
| 102 |
- analyzeDb(null, hits);
|
|
| 103 |
- }
|
|
| 104 |
- |
|
| 105 |
- public void analyzeDb(TripType tripType, T3AccessHitModel hits) throws Exception {
|
|
| 106 | 101 |
// always init the data source
|
| 107 | 102 |
init();
|
| 108 | 103 |
Set<String> tables = getTableNames();
|
| ... | ... | @@ -78,6 +78,8 @@ public abstract class T3AvdthDataEntityVisitor extends T3DataEntityVisitor { |
| 78 | 78 |
activity.setSchoolType(Objects.requireNonNull(sampleSet.getActivitySchoolType()));
|
| 79 | 79 |
sampleSet.setActivity(endActivity(activity));
|
| 80 | 80 |
parent.addActivity(activity);
|
| 81 |
+ // Force tripType, so later we will know that this trip has no logBook
|
|
| 82 |
+ parent.setTripType(TripType.LOGBOOKMISSING);
|
|
| 81 | 83 |
}
|
| 82 | 84 |
};
|
| 83 | 85 |
} else {
|
| ... | ... | @@ -20,5 +20,8 @@ |
| 20 | 20 |
---
|
| 21 | 21 |
ALTER TABLE Trip ADD COLUMN tripType VARCHAR(255) DEFAULT 'STANDARD' NOT NULL;
|
| 22 | 22 |
UPDATE Trip set tripType = 'SAMPLEONLY' WHERE samplesonly = TRUE;
|
| 23 |
+UPDATE Trip set tripType = 'STANDARD' WHERE logbookavailability = 1;
|
|
| 24 |
+UPDATE Trip set tripType = 'LOGBOOKMISSING' WHERE logbookavailability = 0;
|
|
| 23 | 25 |
CREATE INDEX idx_trip_tripType ON Trip(tripType);
|
| 26 |
+ALTER TABLE Trip DROP COLUMN logbookavailability;
|
|
| 24 | 27 |
ALTER TABLE Trip DROP COLUMN samplesonly;
|
| \ No newline at end of file |
No preview for this file type
| ... | ... | @@ -20,7 +20,6 @@ |
| 20 | 20 |
*/
|
| 21 | 21 |
package fr.ird.t3.entities.reference;
|
| 22 | 22 |
|
| 23 |
-import com.google.common.collect.Maps;
|
|
| 24 | 23 |
import fr.ird.t3.entities.AbstractDatabaseTest;
|
| 25 | 24 |
import fr.ird.t3.entities.T3TopiaPersistenceContext;
|
| 26 | 25 |
import org.junit.Assert;
|
| ... | ... | @@ -28,6 +27,7 @@ import org.junit.Test; |
| 28 | 27 |
|
| 29 | 28 |
import java.util.ArrayList;
|
| 30 | 29 |
import java.util.Comparator;
|
| 30 |
+import java.util.LinkedHashMap;
|
|
| 31 | 31 |
import java.util.List;
|
| 32 | 32 |
import java.util.Map;
|
| 33 | 33 |
|
| ... | ... | @@ -154,7 +154,7 @@ public class WeightCategoryTreatmentImplTest extends AbstractDatabaseTest { |
| 154 | 154 |
catUnbound.setMax(null);
|
| 155 | 155 |
|
| 156 | 156 |
Map<WeightCategoryTreatment, Integer> weightCategories =
|
| 157 |
- Maps.newLinkedHashMap();
|
|
| 157 |
+ new LinkedHashMap<>();
|
|
| 158 | 158 |
|
| 159 | 159 |
weightCategories.put(catBound, 20);
|
| 160 | 160 |
weightCategories.put(catUnbound, Integer.MAX_VALUE);
|
| ... | ... | @@ -208,7 +208,7 @@ public class WeightCategoryTreatmentImplTest extends AbstractDatabaseTest { |
| 208 | 208 |
catUnbound.setMax(null);
|
| 209 | 209 |
|
| 210 | 210 |
Map<WeightCategoryTreatment, Integer> weightCategories =
|
| 211 |
- Maps.newLinkedHashMap();
|
|
| 211 |
+ new LinkedHashMap<>();
|
|
| 212 | 212 |
|
| 213 | 213 |
weightCategories.put(catBound, 20);
|
| 214 | 214 |
weightCategories.put(catBound2, 40);
|
| ... | ... | @@ -82,7 +82,7 @@ public class T3InputAvdth33 extends AbstractT3InputMSAccess { |
| 82 | 82 |
|
| 83 | 83 |
@Override
|
| 84 | 84 |
public T3DataEntityVisitor newDataVisitor(T3AccessDataSource dataSource, ReferenceEntityMap safeReferences) {
|
| 85 |
- return new T3DataEntityVisitorAvdth33(dataSource, safeReferences, configuration);
|
|
| 85 |
+ return new T3DataEntityVisitorAvdth33(dataSource, safeReferences, getConfiguration());
|
|
| 86 | 86 |
}
|
| 87 | 87 |
|
| 88 | 88 |
@Override
|
| ... | ... | @@ -96,7 +96,7 @@ public class T3InputAvdth36 extends AbstractT3InputMSAccess { |
| 96 | 96 |
|
| 97 | 97 |
@Override
|
| 98 | 98 |
public T3DataEntityVisitor newDataVisitor(T3AccessDataSource dataSource, ReferenceEntityMap safeReferences) {
|
| 99 |
- return new T3DataEntityVisitorAvdth36(dataSource, safeReferences, configuration);
|
|
| 99 |
+ return new T3DataEntityVisitorAvdth36(dataSource, safeReferences, getConfiguration());
|
|
| 100 | 100 |
}
|
| 101 | 101 |
|
| 102 | 102 |
@Override
|
| ... | ... | @@ -8,12 +8,12 @@ |
| 8 | 8 |
* it under the terms of the GNU Affero General Public License as published by
|
| 9 | 9 |
* the Free Software Foundation, either version 3 of the License, or
|
| 10 | 10 |
* (at your option) any later version.
|
| 11 |
- *
|
|
| 11 |
+ *
|
|
| 12 | 12 |
* This program is distributed in the hope that it will be useful,
|
| 13 | 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 14 | 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 15 | 15 |
* GNU General Public License for more details.
|
| 16 |
- *
|
|
| 16 |
+ *
|
|
| 17 | 17 |
* You should have received a copy of the GNU Affero General Public License
|
| 18 | 18 |
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
| 19 | 19 |
* #L%
|
| ... | ... | @@ -39,182 +39,153 @@ import static org.nuiton.i18n.I18n.l; |
| 39 | 39 |
*/
|
| 40 | 40 |
public class BalbayaOperationExecutionTripImpl extends AbstractBalbayaOperationExecution {
|
| 41 | 41 |
|
| 42 |
- public BalbayaOperationExecutionTripImpl(Connection connection) {
|
|
| 42 |
+ private static final String CHECK_TRIP = "SELECT count(*) FROM maree where c_bat = %1$s AND d_dbq = '%2$s'::date;";
|
|
| 43 |
+ /**
|
|
| 44 |
+ * To insert a new line into maree table (from Trip entity).
|
|
| 45 |
+ * <p/>
|
|
| 46 |
+ * c_bat | numeric(4,0) | not null
|
|
| 47 |
+ * d_dbq | date | not null
|
|
| 48 |
+ * d_depart | date |
|
|
| 49 |
+ * c_port_dep | numeric(3,0) | not null
|
|
| 50 |
+ * c_port_dbq | numeric(3,0) | not null
|
|
| 51 |
+ * c_zone_geo | numeric(4,0) |
|
|
| 52 |
+ * v_temps_m | numeric(4,0) | not null
|
|
| 53 |
+ * v_temps_p | numeric(4,0) | not null
|
|
| 54 |
+ * v_poids_dbq | numeric(7,3) | not null
|
|
| 55 |
+ * v_poids_fp | numeric(6,3) | not null
|
|
| 56 |
+ * f_enq | numeric(1,0) | not null
|
|
| 57 |
+ * f_cal_vid | numeric(1,0) | not null
|
|
| 58 |
+ * v_loch | numeric(5,0) |
|
|
| 59 |
+ * id_jeu_d | numeric(4,0) | not null
|
|
| 60 |
+ * c_pays_d | numeric(3,0) | not null
|
|
| 61 |
+ */
|
|
| 62 |
+ private static final String INSERT_MAREE = "INSERT INTO maree (" +
|
|
| 63 |
+ "c_bat," +
|
|
| 64 |
+ "d_dbq," +
|
|
| 65 |
+ "d_depart," +
|
|
| 66 |
+ "c_port_dep, " +
|
|
| 67 |
+ "c_port_dbq," +
|
|
| 68 |
+ "v_temps_m," +
|
|
| 69 |
+ "v_temps_p," +
|
|
| 70 |
+ "v_poids_dbq," +
|
|
| 71 |
+ "v_poids_fp," +
|
|
| 72 |
+ "f_enq," +
|
|
| 73 |
+ "f_cal_vid," +
|
|
| 74 |
+ "v_loch," +
|
|
| 75 |
+ "id_jeu_d," +
|
|
| 76 |
+ "c_pays_d" +
|
|
| 77 |
+ ") VALUES (" +
|
|
| 78 |
+ "%1$s," +
|
|
| 79 |
+ "'%2$s'::date," +
|
|
| 80 |
+ "'%3$s'::date," +
|
|
| 81 |
+ "%4$s," +
|
|
| 82 |
+ "%5$s," +
|
|
| 83 |
+ "%6$s," +
|
|
| 84 |
+ "%7$s," +
|
|
| 85 |
+ "%8$s," +
|
|
| 86 |
+ "%9$s," +
|
|
| 87 |
+ "%10$s," +
|
|
| 88 |
+ "%11$s," +
|
|
| 89 |
+ "%12$s," +
|
|
| 90 |
+ "%13$s," +
|
|
| 91 |
+ "%14$s" +
|
|
| 92 |
+ ");";
|
|
| 93 |
+ /**
|
|
| 94 |
+ * To insert a new line into lot_com table (from ElementaryLanding entity).
|
|
| 95 |
+ * <p/>
|
|
| 96 |
+ * c_bat | numeric(4,0) | not null
|
|
| 97 |
+ * d_dbq | date | not null
|
|
| 98 |
+ * n_lot | numeric(4,0) | not null
|
|
| 99 |
+ * c_esp | numeric(3,0) | not null
|
|
| 100 |
+ * c_cat_c | numeric(2,0) | not null
|
|
| 101 |
+ * v_poids_lc | numeric(7,3) | not null
|
|
| 102 |
+ */
|
|
| 103 |
+ private static final String INSERT_LOT_COM = "INSERT INTO lot_com (" +
|
|
| 104 |
+ "c_bat, " +
|
|
| 105 |
+ "d_dbq," +
|
|
| 106 |
+ "n_lot, " +
|
|
| 107 |
+ "c_esp," +
|
|
| 108 |
+ "c_cat_c," +
|
|
| 109 |
+ "v_poids_lc" +
|
|
| 110 |
+ ") VALUES(" +
|
|
| 111 |
+ "%1$s," +
|
|
| 112 |
+ "'%2$s'::date," +
|
|
| 113 |
+ "%3$s," +
|
|
| 114 |
+ "%4$s," +
|
|
| 115 |
+ "%5$s," +
|
|
| 116 |
+ "%6$s" +
|
|
| 117 |
+ ");";
|
|
| 118 |
+ private int nbTrips;
|
|
| 119 |
+ private int nbElementaryLandings;
|
|
| 120 |
+ |
|
| 121 |
+ BalbayaOperationExecutionTripImpl(Connection connection) {
|
|
| 43 | 122 |
super(connection, T3OutputOperationBalbayaImpl.TRIP_AND_LANDING);
|
| 44 | 123 |
}
|
| 45 | 124 |
|
| 46 | 125 |
@Override
|
| 47 | 126 |
protected boolean checkDatas(T3OutputBalbayaImpl output, List<Trip> trips) throws SQLException {
|
| 48 |
- |
|
| 49 | 127 |
// check pKeys before all
|
| 50 | 128 |
for (Trip trip : trips) {
|
| 51 |
- |
|
| 52 | 129 |
int tripVesselCode = trip.getVessel().getCode();
|
| 53 | 130 |
Date tripLandingDate = trip.getLandingDate();
|
| 54 |
- |
|
| 55 |
- boolean exists =
|
|
| 56 |
- checkPKey(CHECK_TRIP, tripVesselCode, tripLandingDate);
|
|
| 57 |
- |
|
| 131 |
+ boolean exists = checkPKey(CHECK_TRIP, tripVesselCode, tripLandingDate);
|
|
| 58 | 132 |
if (exists) {
|
| 59 |
- |
|
| 60 | 133 |
// this trip already exists, can not import it, stop operation
|
| 61 | 134 |
Locale locale = output.getLocale();
|
| 62 | 135 |
output.getMessager().addErrorMessage(
|
| 63 |
- l(locale, "t3.output.balbaya.error.trip.already.exists",
|
|
| 64 |
- tripVesselCode, tripLandingDate)
|
|
| 65 |
- );
|
|
| 136 |
+ l(locale, "t3.output.balbaya.error.trip.already.exists", tripVesselCode, tripLandingDate));
|
|
| 66 | 137 |
return false;
|
| 67 | 138 |
}
|
| 68 | 139 |
}
|
| 69 | 140 |
return true;
|
| 70 | 141 |
}
|
| 71 | 142 |
|
| 72 |
- protected int nbTrips;
|
|
| 73 |
- |
|
| 74 |
- protected int nbElementaryLandings;
|
|
| 75 |
- |
|
| 76 | 143 |
@Override
|
| 77 |
- protected String getSuccessSummary(T3OutputBalbayaImpl output,
|
|
| 78 |
- T3OutputBalbayaImpl.TreatmentId id) {
|
|
| 144 |
+ protected String getSuccessSummary(T3OutputBalbayaImpl output, T3OutputBalbayaImpl.TreatmentId id) {
|
|
| 79 | 145 |
Locale locale = output.getLocale();
|
| 80 |
- return l(locale, "t3.output.balbabya.operation.tripAndLanding.success",
|
|
| 81 |
- id.getNumber(), nbTrips, nbElementaryLandings);
|
|
| 146 |
+ return l(locale, "t3.output.balbabya.operation.tripAndLanding.success", id.getNumber(), nbTrips, nbElementaryLandings);
|
|
| 82 | 147 |
}
|
| 83 | 148 |
|
| 84 | 149 |
@Override
|
| 85 |
- protected void buildRequests(T3OutputBalbayaImpl output,
|
|
| 86 |
- T3OutputBalbayaImpl.TreatmentId id,
|
|
| 87 |
- List<Trip> trips) {
|
|
| 88 |
- |
|
| 150 |
+ protected void buildRequests(T3OutputBalbayaImpl output, T3OutputBalbayaImpl.TreatmentId id, List<Trip> trips) {
|
|
| 89 | 151 |
nbTrips = nbElementaryLandings = 0;
|
| 90 |
- |
|
| 91 | 152 |
int countryCode = id.getCountryCode();
|
| 92 | 153 |
int treatmentNumber = id.getNumber();
|
| 93 |
- |
|
| 94 | 154 |
for (Trip trip : trips) {
|
| 95 |
- |
|
| 96 | 155 |
int tripVesselCode = trip.getVessel().getCode();
|
| 97 | 156 |
Date tripLandingDate = trip.getLandingDate();
|
| 98 |
- |
|
| 99 | 157 |
// add trip
|
| 100 |
- |
|
| 101 | 158 |
nbTrips++;
|
| 102 | 159 |
addRequest(INSERT_MAREE,
|
| 103 |
- requests,
|
|
| 104 |
- tripVesselCode,
|
|
| 105 |
- tripLandingDate,
|
|
| 106 |
- trip.getDepartureDate(),
|
|
| 107 |
- trip.getDepartureHarbour().getCode(),
|
|
| 108 |
- trip.getLandingHarbour().getCode(),
|
|
| 109 |
- trip.getTimeAtSea(),
|
|
| 110 |
- trip.getFishingTime(),
|
|
| 111 |
- trip.getLandingTotalWeight(),
|
|
| 112 |
- trip.getFalseFishesWeight(),
|
|
| 113 |
- trip.getLogBookAvailability(),
|
|
| 114 |
- trip.getFishHoldEmpty(),
|
|
| 115 |
- trip.getLoch(),
|
|
| 116 |
- treatmentNumber,
|
|
| 117 |
- countryCode
|
|
| 118 |
- );
|
|
| 160 |
+ requests,
|
|
| 161 |
+ tripVesselCode,
|
|
| 162 |
+ tripLandingDate,
|
|
| 163 |
+ trip.getDepartureDate(),
|
|
| 164 |
+ trip.getDepartureHarbour().getCode(),
|
|
| 165 |
+ trip.getLandingHarbour().getCode(),
|
|
| 166 |
+ trip.getTimeAtSea(),
|
|
| 167 |
+ trip.getFishingTime(),
|
|
| 168 |
+ trip.getLandingTotalWeight(),
|
|
| 169 |
+ trip.getFalseFishesWeight(),
|
|
| 170 |
+ trip.isWithLogbook() ? 1 : 0,
|
|
| 171 |
+ trip.getFishHoldEmpty(),
|
|
| 172 |
+ trip.getLoch(),
|
|
| 173 |
+ treatmentNumber,
|
|
| 174 |
+ countryCode);
|
|
| 119 | 175 |
if (!trip.isElementaryLandingEmpty()) {
|
| 120 |
- |
|
| 121 | 176 |
// add elementary landing
|
| 122 | 177 |
for (ElementaryLanding elementaryLanding : trip.getElementaryLanding()) {
|
| 123 |
- |
|
| 124 | 178 |
nbElementaryLandings++;
|
| 125 |
- |
|
| 126 | 179 |
addRequest(INSERT_LOT_COM,
|
| 127 |
- requests,
|
|
| 128 |
- tripVesselCode,
|
|
| 129 |
- tripLandingDate,
|
|
| 130 |
- elementaryLanding.getNumber(),
|
|
| 131 |
- elementaryLanding.getWeightCategoryLanding().getSpecies().getCode(),
|
|
| 132 |
- elementaryLanding.getWeightCategoryLanding().getCode(),
|
|
| 133 |
- elementaryLanding.getWeight()
|
|
| 134 |
- );
|
|
| 180 |
+ requests,
|
|
| 181 |
+ tripVesselCode,
|
|
| 182 |
+ tripLandingDate,
|
|
| 183 |
+ elementaryLanding.getNumber(),
|
|
| 184 |
+ elementaryLanding.getWeightCategoryLanding().getSpecies().getCode(),
|
|
| 185 |
+ elementaryLanding.getWeightCategoryLanding().getCode(),
|
|
| 186 |
+ elementaryLanding.getWeight());
|
|
| 135 | 187 |
}
|
| 136 | 188 |
}
|
| 137 | 189 |
}
|
| 138 | 190 |
}
|
| 139 |
- |
|
| 140 |
- public static final String CHECK_TRIP = "SELECT count(*) FROM maree where " +
|
|
| 141 |
- "c_bat = %1$s AND d_dbq = '%2$s'::date;";
|
|
| 142 |
- |
|
| 143 |
- /**
|
|
| 144 |
- * To insert a new line into maree table (from Trip entity).
|
|
| 145 |
- * <p/>
|
|
| 146 |
- * c_bat | numeric(4,0) | not null
|
|
| 147 |
- * d_dbq | date | not null
|
|
| 148 |
- * d_depart | date |
|
|
| 149 |
- * c_port_dep | numeric(3,0) | not null
|
|
| 150 |
- * c_port_dbq | numeric(3,0) | not null
|
|
| 151 |
- * c_zone_geo | numeric(4,0) |
|
|
| 152 |
- * v_temps_m | numeric(4,0) | not null
|
|
| 153 |
- * v_temps_p | numeric(4,0) | not null
|
|
| 154 |
- * v_poids_dbq | numeric(7,3) | not null
|
|
| 155 |
- * v_poids_fp | numeric(6,3) | not null
|
|
| 156 |
- * f_enq | numeric(1,0) | not null
|
|
| 157 |
- * f_cal_vid | numeric(1,0) | not null
|
|
| 158 |
- * v_loch | numeric(5,0) |
|
|
| 159 |
- * id_jeu_d | numeric(4,0) | not null
|
|
| 160 |
- * c_pays_d | numeric(3,0) | not null
|
|
| 161 |
- */
|
|
| 162 |
- public static final String INSERT_MAREE = "INSERT INTO maree (" +
|
|
| 163 |
- "c_bat," +
|
|
| 164 |
- "d_dbq," +
|
|
| 165 |
- "d_depart," +
|
|
| 166 |
- "c_port_dep, " +
|
|
| 167 |
- "c_port_dbq," +
|
|
| 168 |
- "v_temps_m," +
|
|
| 169 |
- "v_temps_p," +
|
|
| 170 |
- "v_poids_dbq," +
|
|
| 171 |
- "v_poids_fp," +
|
|
| 172 |
- "f_enq," +
|
|
| 173 |
- "f_cal_vid," +
|
|
| 174 |
- "v_loch," +
|
|
| 175 |
- "id_jeu_d," +
|
|
| 176 |
- "c_pays_d" +
|
|
| 177 |
- ") VALUES (" +
|
|
| 178 |
- "%1$s," +
|
|
| 179 |
- "'%2$s'::date," +
|
|
| 180 |
- "'%3$s'::date," +
|
|
| 181 |
- "%4$s," +
|
|
| 182 |
- "%5$s," +
|
|
| 183 |
- "%6$s," +
|
|
| 184 |
- "%7$s," +
|
|
| 185 |
- "%8$s," +
|
|
| 186 |
- "%9$s," +
|
|
| 187 |
- "%10$s," +
|
|
| 188 |
- "%11$s," +
|
|
| 189 |
- "%12$s," +
|
|
| 190 |
- "%13$s," +
|
|
| 191 |
- "%14$s" +
|
|
| 192 |
- ");";
|
|
| 193 |
- |
|
| 194 |
- |
|
| 195 |
- /**
|
|
| 196 |
- * To insert a new line into lot_com table (from ElementaryLanding entity).
|
|
| 197 |
- * <p/>
|
|
| 198 |
- * c_bat | numeric(4,0) | not null
|
|
| 199 |
- * d_dbq | date | not null
|
|
| 200 |
- * n_lot | numeric(4,0) | not null
|
|
| 201 |
- * c_esp | numeric(3,0) | not null
|
|
| 202 |
- * c_cat_c | numeric(2,0) | not null
|
|
| 203 |
- * v_poids_lc | numeric(7,3) | not null
|
|
| 204 |
- */
|
|
| 205 |
- public static final String INSERT_LOT_COM = "INSERT INTO lot_com (" +
|
|
| 206 |
- "c_bat, " +
|
|
| 207 |
- "d_dbq," +
|
|
| 208 |
- "n_lot, " +
|
|
| 209 |
- "c_esp," +
|
|
| 210 |
- "c_cat_c," +
|
|
| 211 |
- "v_poids_lc" +
|
|
| 212 |
- ") VALUES(" +
|
|
| 213 |
- "%1$s," +
|
|
| 214 |
- "'%2$s'::date," +
|
|
| 215 |
- "%3$s," +
|
|
| 216 |
- "%4$s," +
|
|
| 217 |
- "%5$s," +
|
|
| 218 |
- "%6$s" +
|
|
| 219 |
- ");";
|
|
| 220 | 191 |
}
|
| ... | ... | @@ -10,12 +10,12 @@ package fr.ird.t3.web; |
| 10 | 10 |
* it under the terms of the GNU Affero General Public License as published by
|
| 11 | 11 |
* the Free Software Foundation, either version 3 of the License, or
|
| 12 | 12 |
* (at your option) any later version.
|
| 13 |
- *
|
|
| 13 |
+ *
|
|
| 14 | 14 |
* This program is distributed in the hope that it will be useful,
|
| 15 | 15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 16 | 16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 17 | 17 |
* GNU General Public License for more details.
|
| 18 |
- *
|
|
| 18 |
+ *
|
|
| 19 | 19 |
* You should have received a copy of the GNU Affero General Public License
|
| 20 | 20 |
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
| 21 | 21 |
* #L%
|
| ... | ... | @@ -35,9 +35,10 @@ import java.io.OutputStream; |
| 35 | 35 |
import java.util.Calendar;
|
| 36 | 36 |
|
| 37 | 37 |
/**
|
| 38 |
+ * FIXME See if we still need this ?
|
|
| 38 | 39 |
* To fix some javascript loading problem.
|
| 39 | 40 |
* <p/>
|
| 40 |
- * Some javascript files have some strange first caracter (ckeditor for example) +
|
|
| 41 |
+ * Some javascript files have some strange first character (ckeditor for example) +
|
|
| 41 | 42 |
* problem while loading charsets for french translate files.
|
| 42 | 43 |
*
|
| 43 | 44 |
* @author Tony Chemit - dev@tchemit.fr
|
| ... | ... | @@ -45,25 +46,18 @@ import java.util.Calendar; |
| 45 | 46 |
*/
|
| 46 | 47 |
public class T3StaticContentLoader extends DefaultStaticContentLoader {
|
| 47 | 48 |
|
| 48 |
- /** Logger. */
|
|
| 49 |
- private final Logger log =
|
|
| 50 |
- LoggerFactory.getLogger(T3StaticContentLoader.class);
|
|
| 49 |
+ private final Logger log = LoggerFactory.getLogger(T3StaticContentLoader.class);
|
|
| 51 | 50 |
|
| 52 | 51 |
@Override
|
| 53 |
- protected void process(InputStream is,
|
|
| 54 |
- String path,
|
|
| 55 |
- HttpServletRequest request,
|
|
| 56 |
- HttpServletResponse response) throws IOException {
|
|
| 52 |
+ protected void process(InputStream is, String path, HttpServletRequest request, HttpServletResponse response) throws IOException {
|
|
| 57 | 53 |
if (is != null) {
|
| 58 | 54 |
Calendar cal = Calendar.getInstance();
|
| 59 |
- |
|
| 60 | 55 |
// check for if-modified-since, prior to any other headers
|
| 61 | 56 |
long ifModifiedSince = 0;
|
| 62 | 57 |
try {
|
| 63 | 58 |
ifModifiedSince = request.getDateHeader("If-Modified-Since");
|
| 64 | 59 |
} catch (Exception e) {
|
| 65 |
- log.warn("Invalid If-Modified-Since header value: '"
|
|
| 66 |
- + request.getHeader("If-Modified-Since") + "', ignoring");
|
|
| 60 |
+ log.warn(String.format("Invalid If-Modified-Since header value: '%s', ignoring", request.getHeader("If-Modified-Since")));
|
|
| 67 | 61 |
}
|
| 68 | 62 |
long lastModifiedMillis = lastModifiedCal.getTimeInMillis();
|
| 69 | 63 |
long now = cal.getTimeInMillis();
|
| ... | ... | @@ -97,34 +91,29 @@ public class T3StaticContentLoader extends DefaultStaticContentLoader { |
| 97 | 91 |
response.setHeader("Pragma", "no-cache");
|
| 98 | 92 |
response.setHeader("Expires", "-1");
|
| 99 | 93 |
}
|
| 100 |
- |
|
| 101 | 94 |
try {
|
| 102 | 95 |
copy(is, response.getOutputStream(), path);
|
| 103 |
- |
|
| 104 | 96 |
} finally {
|
| 105 | 97 |
is.close();
|
| 106 | 98 |
}
|
| 107 | 99 |
}
|
| 108 | 100 |
}
|
| 109 | 101 |
|
| 110 |
- protected void copy(InputStream input,
|
|
| 111 |
- OutputStream output,
|
|
| 112 |
- String path) throws IOException {
|
|
| 102 |
+ protected void copy(InputStream input, OutputStream output, String path) throws IOException {
|
|
| 113 | 103 |
|
| 114 | 104 |
if (path.contains(".js")) {
|
| 115 |
- String content = IOUtils.toString(input);
|
|
| 105 |
+ String content = IOUtils.toString(input, Charsets.UTF_8);
|
|
| 116 | 106 |
if (content.indexOf("/") == 1) {
|
| 117 |
- // fix nasty first strange caracter for ckeditor (only on firefox :()
|
|
| 107 |
+ // fix nasty first strange character for ckeditor (only on firefox :()
|
|
| 118 | 108 |
content = content.substring(1);
|
| 119 | 109 |
}
|
| 120 |
- if (log.isDebugEnabled()) {
|
|
| 121 |
- log.debug("Content:\n" + content);
|
|
| 122 |
- }
|
|
| 110 |
+ log.debug("Content:\n" + content);
|
|
| 123 | 111 |
// always want to have file in IS0 (even if we serve UTF8 files)
|
| 112 |
+ //FIXME Why should we serve ISO ?
|
|
| 124 | 113 |
IOUtils.write(content, output, Charsets.ISO_8859_1);
|
| 125 | 114 |
} else {
|
| 126 | 115 |
|
| 127 |
- // no special tratment for other files
|
|
| 116 |
+ // no special treatment for other files
|
|
| 128 | 117 |
IOUtils.copy(input, output);
|
| 129 | 118 |
}
|
| 130 | 119 |
}
|
| ... | ... | @@ -21,7 +21,6 @@ |
| 21 | 21 |
package fr.ird.t3.web.actions;
|
| 22 | 22 |
|
| 23 | 23 |
import com.google.common.collect.ImmutableMap;
|
| 24 |
-import com.google.common.collect.Maps;
|
|
| 25 | 24 |
import com.google.common.collect.Multimap;
|
| 26 | 25 |
import com.opensymphony.xwork2.ActionContext;
|
| 27 | 26 |
import com.opensymphony.xwork2.ActionSupport;
|
| ... | ... | @@ -63,6 +62,7 @@ import java.util.ArrayList; |
| 63 | 62 |
import java.util.Arrays;
|
| 64 | 63 |
import java.util.Collection;
|
| 65 | 64 |
import java.util.Date;
|
| 65 |
+import java.util.LinkedHashMap;
|
|
| 66 | 66 |
import java.util.List;
|
| 67 | 67 |
import java.util.Map;
|
| 68 | 68 |
import java.util.function.Supplier;
|
| ... | ... | @@ -261,7 +261,7 @@ public class T3ActionSupport extends ActionSupport implements T3TopiaPersistence |
| 261 | 261 |
}
|
| 262 | 262 |
|
| 263 | 263 |
protected Map<String, String> createTimeSteps() {
|
| 264 |
- Map<String, String> timeSteps = Maps.newLinkedHashMap();
|
|
| 264 |
+ Map<String, String> timeSteps = new LinkedHashMap<>();
|
|
| 265 | 265 |
for (int i = 1; i < 13; i++) {
|
| 266 | 266 |
timeSteps.put("" + i, "" + i);
|
| 267 | 267 |
}
|
| ... | ... | @@ -8,19 +8,18 @@ |
| 8 | 8 |
* it under the terms of the GNU Affero General Public License as published by
|
| 9 | 9 |
* the Free Software Foundation, either version 3 of the License, or
|
| 10 | 10 |
* (at your option) any later version.
|
| 11 |
- *
|
|
| 11 |
+ *
|
|
| 12 | 12 |
* This program is distributed in the hope that it will be useful,
|
| 13 | 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 14 | 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 15 | 15 |
* GNU General Public License for more details.
|
| 16 |
- *
|
|
| 16 |
+ *
|
|
| 17 | 17 |
* You should have received a copy of the GNU Affero General Public License
|
| 18 | 18 |
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
| 19 | 19 |
* #L%
|
| 20 | 20 |
*/
|
| 21 | 21 |
package fr.ird.t3.web.actions.io.output;
|
| 22 | 22 |
|
| 23 |
-import com.google.common.collect.Maps;
|
|
| 24 | 23 |
import fr.ird.t3.actions.io.output.ExportConfiguration;
|
| 25 | 24 |
import fr.ird.t3.entities.T3EntityHelper;
|
| 26 | 25 |
import fr.ird.t3.entities.data.Trip;
|
| ... | ... | @@ -49,6 +48,7 @@ import java.util.ArrayList; |
| 49 | 48 |
import java.util.Arrays;
|
| 50 | 49 |
import java.util.Collection;
|
| 51 | 50 |
import java.util.HashMap;
|
| 51 |
+import java.util.LinkedHashMap;
|
|
| 52 | 52 |
import java.util.List;
|
| 53 | 53 |
import java.util.Map;
|
| 54 | 54 |
|
| ... | ... | @@ -116,14 +116,13 @@ public class ExportConfigureAction extends AbstractConfigureAction<ExportConfigu |
| 116 | 116 |
// make sur configuration is inited before all
|
| 117 | 117 |
getConfiguration();
|
| 118 | 118 |
|
| 119 |
- operations = Maps.newLinkedHashMap();
|
|
| 119 |
+ operations = new LinkedHashMap<>();
|
|
| 120 | 120 |
|
| 121 |
- for (T3OutputOperation operation :
|
|
| 122 |
- getT3OutputService().getOperations(configuration.getOutputProviderId())) {
|
|
| 121 |
+ for (T3OutputOperation operation : getT3OutputService().getOperations(configuration.getOutputProviderId())) {
|
|
| 123 | 122 |
operations.put(operation.getId(), operation.getLibelle(getLocale()));
|
| 124 | 123 |
}
|
| 125 | 124 |
|
| 126 |
- // inject everything needed (daos, ...)
|
|
| 125 |
+ // inject everything needed (dao, ...)
|
|
| 127 | 126 |
injectExcept(InjectDecoratedBeans.class);
|
| 128 | 127 |
|
| 129 | 128 |
boolean configurationInSession = isConfigurationInSession();
|
| ... | ... | @@ -8,24 +8,24 @@ |
| 8 | 8 |
* it under the terms of the GNU Affero General Public License as published by
|
| 9 | 9 |
* the Free Software Foundation, either version 3 of the License, or
|
| 10 | 10 |
* (at your option) any later version.
|
| 11 |
- *
|
|
| 11 |
+ *
|
|
| 12 | 12 |
* This program is distributed in the hope that it will be useful,
|
| 13 | 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 14 | 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 15 | 15 |
* GNU General Public License for more details.
|
| 16 |
- *
|
|
| 16 |
+ *
|
|
| 17 | 17 |
* You should have received a copy of the GNU Affero General Public License
|
| 18 | 18 |
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
| 19 | 19 |
* #L%
|
| 20 | 20 |
*/
|
| 21 | 21 |
package fr.ird.t3.web.actions.json;
|
| 22 | 22 |
|
| 23 |
-import com.google.common.collect.Maps;
|
|
| 24 | 23 |
import fr.ird.t3.io.output.T3OutputOperation;
|
| 25 | 24 |
import fr.ird.t3.web.actions.T3ActionSupport;
|
| 26 | 25 |
import org.apache.commons.logging.Log;
|
| 27 | 26 |
import org.apache.commons.logging.LogFactory;
|
| 28 | 27 |
|
| 28 |
+import java.util.LinkedHashMap;
|
|
| 29 | 29 |
import java.util.Map;
|
| 30 | 30 |
|
| 31 | 31 |
|
| ... | ... | @@ -39,13 +39,10 @@ public class GetOutputProviderOperationsAction extends T3ActionSupport { |
| 39 | 39 |
|
| 40 | 40 |
private static final long serialVersionUID = 1L;
|
| 41 | 41 |
|
| 42 |
- /** Logger. */
|
|
| 43 |
- private static final Log log =
|
|
| 44 |
- LogFactory.getLog(GetOutputProviderOperationsAction.class);
|
|
| 42 |
+ private static final Log log = LogFactory.getLog(GetOutputProviderOperationsAction.class);
|
|
| 45 | 43 |
|
| 46 |
- protected String outputProviderId;
|
|
| 47 |
- |
|
| 48 |
- protected Map<String, String> operations;
|
|
| 44 |
+ private String outputProviderId;
|
|
| 45 |
+ private Map<String, String> operations;
|
|
| 49 | 46 |
|
| 50 | 47 |
public void setOutputProviderId(String outputProviderId) {
|
| 51 | 48 |
this.outputProviderId = outputProviderId;
|
| ... | ... | @@ -57,18 +54,11 @@ public class GetOutputProviderOperationsAction extends T3ActionSupport { |
| 57 | 54 |
|
| 58 | 55 |
@Override
|
| 59 | 56 |
public String execute() {
|
| 60 |
- |
|
| 61 |
- if (log.isInfoEnabled()) {
|
|
| 62 |
- log.info("outputProviderId = " + outputProviderId);
|
|
| 63 |
- }
|
|
| 64 |
- |
|
| 65 |
- operations = Maps.newLinkedHashMap();
|
|
| 66 |
- |
|
| 67 |
- for (T3OutputOperation operation :
|
|
| 68 |
- getT3OutputService().getOperations(outputProviderId)) {
|
|
| 57 |
+ log.info(String.format("outputProviderId = %s", outputProviderId));
|
|
| 58 |
+ operations = new LinkedHashMap<>();
|
|
| 59 |
+ for (T3OutputOperation operation : getT3OutputService().getOperations(outputProviderId)) {
|
|
| 69 | 60 |
operations.put(operation.getId(), operation.getLibelle(getLocale()));
|
| 70 | 61 |
}
|
| 71 |
- |
|
| 72 | 62 |
return SUCCESS;
|
| 73 | 63 |
}
|
| 74 | 64 |
}
|
| ... | ... | @@ -8,19 +8,18 @@ |
| 8 | 8 |
* it under the terms of the GNU Affero General Public License as published by
|
| 9 | 9 |
* the Free Software Foundation, either version 3 of the License, or
|
| 10 | 10 |
* (at your option) any later version.
|
| 11 |
- *
|
|
| 11 |
+ *
|
|
| 12 | 12 |
* This program is distributed in the hope that it will be useful,
|
| 13 | 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 14 | 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 15 | 15 |
* GNU General Public License for more details.
|
| 16 |
- *
|
|
| 16 |
+ *
|
|
| 17 | 17 |
* You should have received a copy of the GNU Affero General Public License
|
| 18 | 18 |
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
| 19 | 19 |
* #L%
|
| 20 | 20 |
*/
|
| 21 | 21 |
package fr.ird.t3.web.actions.json;
|
| 22 | 22 |
|
| 23 |
-import com.google.common.collect.Maps;
|
|
| 24 | 23 |
import fr.ird.t3.entities.reference.zone.ZoneStratumAwareMeta;
|
| 25 | 24 |
import fr.ird.t3.entities.reference.zone.ZoneVersion;
|
| 26 | 25 |
import fr.ird.t3.web.actions.T3ActionSupport;
|
| ... | ... | @@ -28,6 +27,7 @@ import org.apache.commons.lang3.StringUtils; |
| 28 | 27 |
import org.apache.commons.logging.Log;
|
| 29 | 28 |
import org.apache.commons.logging.LogFactory;
|
| 30 | 29 |
|
| 30 |
+import java.util.LinkedHashMap;
|
|
| 31 | 31 |
import java.util.List;
|
| 32 | 32 |
import java.util.Map;
|
| 33 | 33 |
|
| ... | ... | @@ -41,14 +41,11 @@ public class GetZoneVersionsAction extends T3ActionSupport { |
| 41 | 41 |
|
| 42 | 42 |
private static final long serialVersionUID = 1L;
|
| 43 | 43 |
|
| 44 |
- /** Logger. */
|
|
| 45 |
- private static final Log log =
|
|
| 46 |
- LogFactory.getLog(GetZoneVersionsAction.class);
|
|
| 44 |
+ private static final Log log = LogFactory.getLog(GetZoneVersionsAction.class);
|
|
| 47 | 45 |
|
| 48 | 46 |
/** Selected zoneTypeId. */
|
| 49 |
- protected String zoneTypeId;
|
|
| 50 |
- |
|
| 51 |
- protected Map<String, String> zoneVersions;
|
|
| 47 |
+ private String zoneTypeId;
|
|
| 48 |
+ private Map<String, String> zoneVersions;
|
|
| 52 | 49 |
|
| 53 | 50 |
public void setZoneTypeId(String zoneTypeId) {
|
| 54 | 51 |
this.zoneTypeId = zoneTypeId;
|
| ... | ... | @@ -60,23 +57,12 @@ public class GetZoneVersionsAction extends T3ActionSupport { |
| 60 | 57 |
|
| 61 | 58 |
@Override
|
| 62 | 59 |
public String execute() {
|
| 63 |
- |
|
| 64 |
- if (log.isInfoEnabled()) {
|
|
| 65 |
- log.info("zoneTypeId = " + zoneTypeId);
|
|
| 66 |
- }
|
|
| 67 |
- |
|
| 68 |
- zoneVersions = Maps.newLinkedHashMap();
|
|
| 69 |
- |
|
| 60 |
+ log.info(String.format("zoneTypeId = %s", zoneTypeId));
|
|
| 61 |
+ zoneVersions = new LinkedHashMap<>();
|
|
| 70 | 62 |
if (!StringUtils.isEmpty(zoneTypeId)) {
|
| 71 |
- |
|
| 72 |
- ZoneStratumAwareMeta zoneType =
|
|
| 73 |
- getZoneStratumService().getZoneMetaById(zoneTypeId);
|
|
| 74 |
- |
|
| 75 |
- List<ZoneVersion> allVersions =
|
|
| 76 |
- zoneType.getAllZoneVersions(getT3TopiaPersistenceContext().get());
|
|
| 77 |
- |
|
| 63 |
+ ZoneStratumAwareMeta zoneType = getZoneStratumService().getZoneMetaById(zoneTypeId);
|
|
| 64 |
+ List<ZoneVersion> allVersions = zoneType.getAllZoneVersions(getT3TopiaPersistenceContext().get());
|
|
| 78 | 65 |
zoneVersions = sortAndDecorateIdAbles(allVersions);
|
| 79 |
- |
|
| 80 | 66 |
}
|
| 81 | 67 |
return SUCCESS;
|
| 82 | 68 |
}
|
| ... | ... | @@ -267,7 +267,7 @@ t3.label.data.level3.configuration.samplesToUse=Treatment to apply to catches wi |
| 267 | 267 |
t3.label.data.level3.configuration.step1=Level 3 configuration step 1
|
| 268 | 268 |
t3.label.data.level3.configuration.step2=Level 3 configuration step 2
|
| 269 | 269 |
t3.label.data.level3.configuration.useAllSamples=Keep their own sample (do nothing)
|
| 270 |
-t3.label.data.level3.configuration.useCatchSamples=Apply length structures from the sample statrum
|
|
| 270 |
+t3.label.data.level3.configuration.useCatchSamples=Apply length structures from the sample stratum
|
|
| 271 | 271 |
t3.label.data.level3.configuration.useWeightCategories=Use weight categories
|
| 272 | 272 |
t3.label.data.level3.configuration.useWeightCategoriesOrNot=Extrapolation method
|
| 273 | 273 |
t3.label.data.treatment.level0=Level 0 treatment
|
| ... | ... | @@ -72,9 +72,7 @@ |
| 72 | 72 |
<s:label value='%{loch}'
|
| 73 | 73 |
label="%{getText('t3.common.loch')}"/>
|
| 74 | 74 |
|
| 75 |
- <s:label value='%{getBoolean(logBookAvailability)}'
|
|
| 76 |
- label="%{getText('t3.common.logBookAvailability')}"/>
|
|
| 77 |
- <s:label value='%{getText(tripType)}'
|
|
| 75 |
+ <s:label value='%{tripType.label}'
|
|
| 78 | 76 |
label="%{getText('t3.common.tripType')}"/>
|
| 79 | 77 |
<s:label value='%{getBoolean(fishHoldEmpty)}'
|
| 80 | 78 |
label="%{getText('t3.common.fishHoldEmpty')}"/>
|