Tony CHEMIT pushed to branch develop at ultreiaio / ird-t3

Commits:

2 changed files:

Changes:

  • t3-actions/src/main/java/fr/ird/t3/actions/data/level0/ComputeRF2Action.java
    ... ... @@ -53,7 +53,9 @@ import java.util.Date;
    53 53
     import java.util.HashSet;
    
    54 54
     import java.util.Iterator;
    
    55 55
     import java.util.List;
    
    56
    +import java.util.Map;
    
    56 57
     import java.util.Set;
    
    58
    +import java.util.stream.Collectors;
    
    57 59
     
    
    58 60
     import static org.nuiton.i18n.I18n.l;
    
    59 61
     
    
    ... ... @@ -121,16 +123,22 @@ public class ComputeRF2Action extends AbstractLevel0Action<ComputeRF2Configurati
    121 123
             }
    
    122 124
             tripDone = TreeMultimap.create();
    
    123 125
             List<Trip> tripList = getUsableTrips(landingHarbours, true);
    
    126
    +        log.info("Trip count: "+tripList.size());
    
    124 127
             setTrips(tripList);
    
    125 128
             completeTripsByVessel = ArrayListMultimap.create();
    
    126 129
             // get all trips group by the vessel
    
    127 130
             ListMultimap<Vessel, Trip> tripsByVessel = TripTopiaDao.groupByVessel(tripList);
    
    131
    +        log.info("Trip vessel count: "+tripsByVessel.keySet().size());
    
    132
    +
    
    128 133
             // compute for each vessel list of complete trip
    
    129
    -        for (Vessel vessel : tripsByVessel.keys()) {
    
    130
    -            List<Trip> tripsForVessel = new ArrayList<>(tripsByVessel.get(vessel));
    
    134
    +        for (Map.Entry<Vessel, Collection<Trip>> entry : tripsByVessel.asMap().entrySet()) {
    
    135
    +            Vessel vessel = entry.getKey();
    
    136
    +            List<Trip> tripsForVessel = new ArrayList<>(entry.getValue());
    
    137
    +            log.info("Trip vessel ["+vessel.getLabel1()+"] count: "+tripsForVessel.size());
    
    131 138
                 TripTopiaDao.sortTrips(tripsForVessel);
    
    132 139
                 // get all complete trips
    
    133 140
                 List<CompleteTrip> completeTrips = tripDAO.toCompleteTrip(tripsForVessel);
    
    141
    +            log.info("Complete trip vessel ["+vessel.getLabel1()+"] count: "+completeTrips.size());
    
    134 142
                 completeTripsByVessel.putAll(vessel, completeTrips);
    
    135 143
             }
    
    136 144
     
    
    ... ... @@ -165,8 +173,9 @@ public class ComputeRF2Action extends AbstractLevel0Action<ComputeRF2Configurati
    165 173
                             }
    
    166 174
                             Multimap<T3Date, CompleteTrip> tripsByMonth = TripTopiaDao.splitTripsByMonth(completeTrips);
    
    167 175
                             log.info(String.format("found %d months.", tripsByMonth.keySet().size()));
    
    168
    -                        for (T3Date month : tripsByMonth.keySet()) {
    
    169
    -                            Collection<CompleteTrip> stratumTrips = tripsByMonth.get(month);
    
    176
    +                        for (Map.Entry<T3Date, Collection<CompleteTrip>> entry : tripsByMonth.asMap().entrySet()) {
    
    177
    +                            T3Date month = entry.getKey();
    
    178
    +                            Collection<CompleteTrip> stratumTrips = entry.getValue();
    
    170 179
                                 nbStratum++;
    
    171 180
                                 String message = l(locale, "t3.level0.computeRF2.nbTrips.for.stratum",
    
    172 181
                                         stratumTrips.size(),
    

  • t3-domain/src/main/java/fr/ird/t3/entities/data/TripImpl.java
    ... ... @@ -103,7 +103,7 @@ public class TripImpl extends TripAbstract {
    103 103
         public boolean isLevel2Computed() {
    
    104 104
             if (level2Computed == null) {
    
    105 105
                 level2Computed = false;
    
    106
    -            if (!isActivityEmpty()) {
    
    106
    +            if (isActivityNotEmpty()) {
    
    107 107
                     for (Activity a : getActivity()) {
    
    108 108
                         Boolean b = a.getUseMeanStratumCompositionN2();
    
    109 109
                         if (b != null) {
    
    ... ... @@ -121,7 +121,7 @@ public class TripImpl extends TripAbstract {
    121 121
         public boolean isLevel3Computed() {
    
    122 122
             if (level3Computed == null) {
    
    123 123
                 level3Computed = false;
    
    124
    -            if (!isActivityEmpty()) {
    
    124
    +            if (isActivityNotEmpty()) {
    
    125 125
                     for (Activity a : getActivity()) {
    
    126 126
                         Boolean b = a.getUseMeanStratumCompositionN3();
    
    127 127
                         if (b != null) {
    
    ... ... @@ -163,7 +163,7 @@ public class TripImpl extends TripAbstract {
    163 163
     //    @Override
    
    164 164
     //    public float getTotalSetsDuration() {
    
    165 165
     //        float result = 0;
    
    166
    -//        if (!isActivityEmpty()) {
    
    166
    +//        if (isActivityNotEmpty()) {
    
    167 167
     //            for (Activity activity : getActivity()) {
    
    168 168
     //
    
    169 169
     //                // get the setDuration
    
    ... ... @@ -178,7 +178,7 @@ public class TripImpl extends TripAbstract {
    178 178
         @Override
    
    179 179
         public float getElementaryCatchTotalWeight(Collection<Species> species) {
    
    180 180
             float result = 0;
    
    181
    -        if (!isActivityEmpty()) {
    
    181
    +        if (isActivityNotEmpty()) {
    
    182 182
                 for (Activity activity : getActivity()) {
    
    183 183
                     result += activity.getElementaryCatchTotalWeight(species);
    
    184 184
                 }
    
    ... ... @@ -189,7 +189,7 @@ public class TripImpl extends TripAbstract {
    189 189
         @Override
    
    190 190
         public float getElementaryCatchTotalWeightRf1(Collection<Species> species) {
    
    191 191
             float result = 0;
    
    192
    -        if (getRf1() != null && !isActivityEmpty()) {
    
    192
    +        if (getRf1() != null && isActivityNotEmpty()) {
    
    193 193
                 for (Activity activity : getActivity()) {
    
    194 194
     
    
    195 195
                     if (activity.isElementaryCatchEmpty()) {
    
    ... ... @@ -211,7 +211,7 @@ public class TripImpl extends TripAbstract {
    211 211
         @Override
    
    212 212
         public float getElementaryCatchTotalWeightRf2(Collection<Species> species) {
    
    213 213
             float result = 0;
    
    214
    -        if (getRf1() != null && !isActivityEmpty()) {
    
    214
    +        if (getRf1() != null && isActivityNotEmpty()) {
    
    215 215
                 for (Activity activity : getActivity()) {
    
    216 216
     
    
    217 217
                     if (activity.isElementaryCatchEmpty()) {
    
    ... ... @@ -246,7 +246,7 @@ public class TripImpl extends TripAbstract {
    246 246
         @Override
    
    247 247
         public float getElementaryLandingTotalWeight(Collection<Species> species) {
    
    248 248
             float result = 0;
    
    249
    -        if (!isElementaryLandingEmpty()) {
    
    249
    +        if (isElementaryLandingNotEmpty()) {
    
    250 250
                 for (ElementaryLanding elementaryLanding : getElementaryLanding()) {
    
    251 251
                     if (species.contains(elementaryLanding.getWeightCategoryLanding().getSpecies())) {
    
    252 252
                         result += elementaryLanding.getWeight();
    
    ... ... @@ -260,7 +260,7 @@ public class TripImpl extends TripAbstract {
    260 260
         @Override
    
    261 261
         public Set<Species> getElementaryCatchSpecies() {
    
    262 262
             Set<Species> result = new HashSet<>();
    
    263
    -        if (!isActivityEmpty()) {
    
    263
    +        if (isActivityNotEmpty()) {
    
    264 264
                 for (Activity activity : getActivity()) {
    
    265 265
                     if (!activity.isElementaryCatchEmpty()) {
    
    266 266
                         for (ElementaryCatch aCatch : activity.getElementaryCatch()) {
    
    ... ... @@ -275,7 +275,7 @@ public class TripImpl extends TripAbstract {
    275 275
         @Override
    
    276 276
         public Set<Species> getElementaryLandingSpecies() {
    
    277 277
             Set<Species> result = new HashSet<>();
    
    278
    -        if (!isElementaryLandingEmpty()) {
    
    278
    +        if (isElementaryLandingNotEmpty()) {
    
    279 279
                 for (ElementaryLanding landing : getElementaryLanding()) {
    
    280 280
                     result.add(landing.getWeightCategoryLanding().getSpecies());
    
    281 281
                 }
    
    ... ... @@ -286,7 +286,7 @@ public class TripImpl extends TripAbstract {
    286 286
         @Override
    
    287 287
         public Set<Ocean> getAllOceans() {
    
    288 288
             Set<Ocean> result = new HashSet<>();
    
    289
    -        if (!isActivityEmpty()) {
    
    289
    +        if (isActivityNotEmpty()) {
    
    290 290
                 for (Activity activity : getActivity()) {
    
    291 291
                     result.add(activity.getOcean());
    
    292 292
                 }