[Git][ultreiaio/ird-t3][develop] 2 commits: reformat code
Tony CHEMIT pushed to branch develop at ultreiaio / ird-t3 Commits: 6ed5a91e by Tony CHEMIT at 2018-02-19T08:47:14+01:00 reformat code - - - - - 879a47c3 by Tony CHEMIT at 2018-02-19T08:48:51+01:00 Probleme de calcul de rf1 (See #283) - - - - - 1 changed file: - t3-actions/src/main/java/fr/ird/t3/actions/data/level0/ComputeRF1Action.java Changes: ===================================== 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 @@ -158,7 +158,7 @@ public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configurati } @Override - protected boolean executeAction() throws Exception { + protected boolean executeAction() { Set<Vessel> allVessel = tripsByVessel.keySet(); @@ -174,29 +174,24 @@ public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configurati log.debug("Treat vessel " + vessel.getLabel1()); } - List<Trip> tripsForVessel = - Lists.newArrayList(tripsByVessel.get(vessel)); + List<Trip> tripsForVessel = Lists.newArrayList(tripsByVessel.get(vessel)); TripTopiaDao.sortTrips(tripsForVessel); result |= doExecuteForVessel(vessel, tripsForVessel); } - addInfoMessage(l(locale, "t3.level0.computeRF1.totalCatchWeightRF1", - totalCatchWeightRF1)); - addInfoMessage(l(locale, "t3.level0.computeRF1.totalLandingWeight", - totalLandingWeight)); + addInfoMessage(l(locale, "t3.level0.computeRF1.totalCatchWeightRF1", totalCatchWeightRF1)); + addInfoMessage(l(locale, "t3.level0.computeRF1.totalLandingWeight", totalLandingWeight)); } return result; } - protected boolean doExecuteForVessel(Vessel vessel, - List<Trip> tripList) throws Exception { + protected boolean doExecuteForVessel(Vessel vessel, List<Trip> tripList) { incrementsProgression(); String vesselStr = decorate(vessel); - addInfoMessage(l(locale, "t3.level0.computeRF1.treat.vessel", - vesselStr)); + addInfoMessage(l(locale, "t3.level0.computeRF1.treat.vessel", vesselStr)); if (CollectionUtils.isEmpty(tripList)) { @@ -205,8 +200,7 @@ public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configurati return false; } - addInfoMessage(l(locale, "t3.level0.computeRF1.trips.to.use.for.vessel", - tripList.size(), vesselStr)); + addInfoMessage(l(locale, "t3.level0.computeRF1.trips.to.use.for.vessel", tripList.size(), vesselStr)); // get country of the vessel (always use the fleet country) Country country = vessel.getFleetCountry(); @@ -228,13 +222,12 @@ public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configurati // there is some species to use for rf1 computation StringBuilder sb = new StringBuilder(); - for (Species specy : species) { - sb.append(", ").append(decorate(specy)); + for (Species aSpecies : species) { + sb.append(", ").append(decorate(aSpecies)); } String message = l(locale, "t3.level0.computeRF1.species.to.use", - species.size(), sb.substring(2) - ); + species.size(), sb.substring(2)); if (log.isInfoEnabled()) { log.info(message); } @@ -247,20 +240,15 @@ public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configurati // split trips by complete trips List<CompleteTrip> completeTrips = tripDAO.toCompleteTrip(tripList); - addInfoMessage( - l(locale, "t3.level0.computeRF1.complete.trips.to.use.for.vessel", - completeTrips.size(), vesselStr)); + addInfoMessage(l(locale, "t3.level0.computeRF1.complete.trips.to.use.for.vessel", + completeTrips.size(), vesselStr)); nbCompleteTrips += completeTrips.size(); for (CompleteTrip completeTrip : completeTrips) { // consume the completeTrip - treatCompleteTrip(completeTrip, - species, - minimumRate, - maximumRate - ); + treatCompleteTrip(completeTrip, species, minimumRate, maximumRate); // complete trip was consumed completeTrip.removeTrips(tripList); @@ -288,10 +276,7 @@ public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configurati return true; } - private void treatCompleteTrip(CompleteTrip completeTrip, - Collection<Species> species, - float minimumRate, - float maximumRate) { + private void treatCompleteTrip(CompleteTrip completeTrip, Collection<Species> species, float minimumRate, float maximumRate) { int completionStatus; @@ -306,9 +291,9 @@ public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configurati } applyCompletionStatus(completeTrip, completionStatus); - boolean allwithLogBook = TripTopiaDao.isTripsAllWithLogBook(completeTrip); + boolean allWithLogBook = TripTopiaDao.isTripsAllWithLogBook(completeTrip); - if (!allwithLogBook) { + if (!allWithLogBook) { // there is some trips with no log book // reject all the complete trip @@ -350,8 +335,7 @@ public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configurati completeTrip.getDepartureTrip().getVesselLabel(), DecoratorService.formatDate(completeTrip.getDepartureTrip().getDepartureDate()), DecoratorService.formatDate(completeTrip.getLandingTrip().getLandingDate()), - rf1, - minimumRate); + rf1, minimumRate); addWarningMessage(warnMessage); nbCompleteAcceptedTripsWithBadRF1++; } @@ -363,8 +347,7 @@ public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configurati completeTrip.getDepartureTrip().getVesselLabel(), DecoratorService.formatDate(completeTrip.getDepartureTrip().getDepartureDate()), DecoratorService.formatDate(completeTrip.getLandingTrip().getLandingDate()), - rf1, - maximumRate); + rf1, maximumRate); addWarningMessage(warnMessage); nbCompleteAcceptedTripsWithBadRF1++; } @@ -377,18 +360,13 @@ public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configurati } } - private void applyCompletionStatus(Iterable<Trip> trips, - int completionStatus) { - + private void applyCompletionStatus(Iterable<Trip> trips, int completionStatus) { for (Trip trip : trips) { - trip.setCompletionStatus(completionStatus); } } - private void applyRF1(Float rf1, - CompleteTrip trips, - Collection<Species> species) { + private void applyRF1(Float rf1, CompleteTrip trips, Collection<Species> species) { for (Trip trip : trips) { @@ -400,42 +378,30 @@ public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configurati // means can not apply any rf1 : rf1 must stay at null... rf1ToUse = null; - addWarningMessage( - l(locale, "t3.level0.computeRF1.warning.no.logbook", - tripStr) - ); + addWarningMessage(l(locale, "t3.level0.computeRF1.warning.no.logbook", tripStr)); } trip.applyRf1(rf1ToUse, species); markTripAsTreated(trip); - addInfoMessage( - l(locale, "t3.level0.computeRF1.resume.rf1.for.trip", - tripStr, rf1ToUse) - ); + addInfoMessage(l(locale, "t3.level0.computeRF1.resume.rf1.for.trip", tripStr, rf1ToUse)); } } - protected void updateTotalWeights(CompleteTrip completeTrip, - Collection<Species> species) { + protected void updateTotalWeights(CompleteTrip completeTrip, Collection<Species> species) { - float tripTotalCatchWeightRf1 = - completeTrip.getElementaryCatchTotalWeightRf1(species); + float tripTotalCatchWeightRf1 = completeTrip.getElementaryCatchTotalWeightRf1(species); totalCatchWeightRF1 += tripTotalCatchWeightRf1; - float tripTotalLandingWeight = - completeTrip.getElementaryLandingTotalWeight(species); + float tripTotalLandingWeight = completeTrip.getElementaryLandingTotalWeight(species); totalLandingWeight += tripTotalLandingWeight; if (log.isInfoEnabled()) { - - log.info("After trip " + decorate(completeTrip.getLandingTrip()) + - " tripTotalCatchWeightRf1 = " + tripTotalCatchWeightRf1 + - " tripTotalLandingWeight = " + tripTotalLandingWeight); + log.info(String.format("After trip %s tripTotalCatchWeightRf1 = %s tripTotalLandingWeight = %s", + decorate(completeTrip.getLandingTrip()), tripTotalCatchWeightRf1, tripTotalLandingWeight)); } if (log.isDebugEnabled()) { - log.debug("After trip " + decorate(completeTrip.getLandingTrip()) + - " totalCatchWeightRF1 = " + totalCatchWeightRF1 + - " totalLandingWeight = " + totalLandingWeight); + log.debug(String.format("After trip %s totalCatchWeightRF1 = %s totalLandingWeight = %s", + decorate(completeTrip.getLandingTrip()), totalCatchWeightRF1, totalLandingWeight)); } // for (Trip trip : completeTrip) { // @@ -461,8 +427,7 @@ public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configurati // } } - protected float computeRF1ForCompleteTrip(Iterable<Trip> completeTrip, - Collection<Species> speciesList) { + protected float computeRF1ForCompleteTrip(Iterable<Trip> completeTrip, Collection<Species> speciesList) { // do the computation of rf1 for all trips of the complete trip float sumLanding = 0; @@ -477,10 +442,8 @@ public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configurati log.debug("Start count for trip " + tripStr); } - float elementaryLandingTotalWeight = - trip.getElementaryLandingTotalWeight(speciesList); - float elementaryCatchTotalWeight = - trip.getElementaryCatchTotalWeight(speciesList); + float elementaryLandingTotalWeight = trip.getElementaryLandingTotalWeight(speciesList); + float elementaryCatchTotalWeight = trip.getElementaryCatchTotalWeight(speciesList); if (elementaryCatchTotalWeight == 0 && elementaryLandingTotalWeight > 0) { @@ -488,24 +451,19 @@ public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configurati // Add a warning, seems not possible to have no catches and landing : // the logBookAvaibility flag should be setted to 0. - addWarningMessage( - l(locale, "t3.level0.computeRF1.warning.no.catches.but.some.landings", - tripStr, elementaryLandingTotalWeight) - ); + addWarningMessage(l(locale, "t3.level0.computeRF1.warning.no.catches.but.some.landings", + tripStr, elementaryLandingTotalWeight)); } if (elementaryCatchTotalWeight > 0 && elementaryLandingTotalWeight == 0) { // Special case : no landing - // do not take account of the catch weight - elementaryCatchTotalWeight = 0; + // in fact (see https://gitlab.com/ultreiaio/ird-t3/issues/283), we do not want to loose this catches + //elementaryCatchTotalWeight = 0; - addWarningMessage( - l(locale, "t3.level0.computeRF1.warning.no.landings.but.some.catches", - tripStr, - elementaryLandingTotalWeight) - ); + addWarningMessage(l(locale, "t3.level0.computeRF1.warning.no.landings.but.some.catches", + tripStr, elementaryLandingTotalWeight)); } float localMarketTotalWeight = trip.getFalseFishesWeight(); @@ -536,10 +494,8 @@ public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configurati log.debug("Computed rf1 " + rf1); } - addInfoMessage( - l(locale, "t3.level0.computeRF1.resume.for.complete.trip", + addInfoMessage(l(locale, "t3.level0.computeRF1.resume.for.complete.trip", sumCatch, sumLanding, sumLocalMarket, sumLocalMarketDetailled, rf1)); - return rf1; } View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/compare/334460dbc1efdd9b7d84b493eeeced1c... --- View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/compare/334460dbc1efdd9b7d84b493eeeced1c... You're receiving this email because of your account on gitlab.com.
participants (1)
-
Tony CHEMIT