| ... |
... |
@@ -33,6 +33,8 @@ import fr.ird.t3.entities.reference.Country; |
|
33
|
33
|
import fr.ird.t3.entities.reference.CountryTopiaDao;
|
|
34
|
34
|
import fr.ird.t3.entities.reference.Harbour;
|
|
35
|
35
|
import fr.ird.t3.entities.reference.HarbourTopiaDao;
|
|
|
36
|
+import fr.ird.t3.entities.reference.RF1SpeciesForFleet;
|
|
|
37
|
+import fr.ird.t3.entities.reference.RF1SpeciesForFleetTopiaDao;
|
|
36
|
38
|
import fr.ird.t3.entities.reference.Species;
|
|
37
|
39
|
import fr.ird.t3.entities.reference.Vessel;
|
|
38
|
40
|
import fr.ird.t3.entities.reference.VesselSimpleType;
|
| ... |
... |
@@ -41,7 +43,6 @@ import fr.ird.t3.entities.type.T3Date; |
|
41
|
43
|
import fr.ird.t3.services.DecoratorService;
|
|
42
|
44
|
import fr.ird.t3.services.ioc.InjectDAO;
|
|
43
|
45
|
import fr.ird.t3.services.ioc.InjectEntitiesById;
|
|
44
|
|
-import fr.ird.t3.services.ioc.InjectFromDAO;
|
|
45
|
46
|
import org.apache.commons.collections.CollectionUtils;
|
|
46
|
47
|
import org.apache.commons.logging.Log;
|
|
47
|
48
|
import org.apache.commons.logging.LogFactory;
|
| ... |
... |
@@ -70,8 +71,6 @@ public class ComputeRF2Action extends AbstractLevel0Action<ComputeRF2Configurati |
|
70
|
71
|
private static final Log log = LogFactory.getLog(ComputeRF2Action.class);
|
|
71
|
72
|
@InjectEntitiesById(entityType = Harbour.class)
|
|
72
|
73
|
private List<Harbour> landingHarbours;
|
|
73
|
|
- @InjectFromDAO(entityType = Species.class)
|
|
74
|
|
- private List<Species> species;
|
|
75
|
74
|
private int nbStratum;
|
|
76
|
75
|
private int nbTripsWithRF2;
|
|
77
|
76
|
@InjectDAO(entityType = RaisingFactor2.class)
|
| ... |
... |
@@ -82,6 +81,10 @@ public class ComputeRF2Action extends AbstractLevel0Action<ComputeRF2Configurati |
|
82
|
81
|
private CountryTopiaDao countryDAO;
|
|
83
|
82
|
@InjectDAO(entityType = VesselSimpleType.class)
|
|
84
|
83
|
private VesselSimpleTypeTopiaDao vesselSimpleTypeDAO;
|
|
|
84
|
+ @InjectDAO(entityType = RF1SpeciesForFleet.class)
|
|
|
85
|
+ private RF1SpeciesForFleetTopiaDao rF1SpecieForFleetDAO;
|
|
|
86
|
+ /** usable species group by country */
|
|
|
87
|
+ private Multimap<Country, Species> speciesByCountry;
|
|
85
|
88
|
/** usable complete trips group by vessel */
|
|
86
|
89
|
private ListMultimap<Vessel, CompleteTrip> completeTripsByVessel;
|
|
87
|
90
|
private Multimap<String, String> tripDone;
|
| ... |
... |
@@ -120,6 +123,9 @@ public class ComputeRF2Action extends AbstractLevel0Action<ComputeRF2Configurati |
|
120
|
123
|
// use all fleets
|
|
121
|
124
|
fleets = countryDAO.findAll();
|
|
122
|
125
|
}
|
|
|
126
|
+ // get all species usable for rf1 for all selected fleet countries
|
|
|
127
|
+ Multimap<Country, Species> result = rF1SpecieForFleetDAO.getSpeciesForCountry(fleets);
|
|
|
128
|
+ setSpeciesByCountry(result);
|
|
123
|
129
|
tripDone = TreeMultimap.create();
|
|
124
|
130
|
List<Trip> tripList = getUsableTrips(landingHarbours, true);
|
|
125
|
131
|
log.info("Trip count: "+tripList.size());
|
| ... |
... |
@@ -153,11 +159,20 @@ public class ComputeRF2Action extends AbstractLevel0Action<ComputeRF2Configurati |
|
153
|
159
|
boolean result = false;
|
|
154
|
160
|
if (CollectionUtils.isNotEmpty(trips)) {
|
|
155
|
161
|
setNbSteps(landingHarbours.size() * fleets.size() * vesselSimpleTypes.size());
|
|
156
|
|
- boolean computeRf2 = !getConfiguration().isConfigurationEmpty();
|
|
|
162
|
+
|
|
157
|
163
|
for (Harbour harbour : landingHarbours) {
|
|
158
|
164
|
String harbourStr = harbour.getLabel1();
|
|
159
|
165
|
for (Country fleet : fleets) {
|
|
160
|
166
|
String countryStr = fleet.getLabel1();
|
|
|
167
|
+
|
|
|
168
|
+ Collection<Species> species = speciesByCountry.get(fleet);
|
|
|
169
|
+
|
|
|
170
|
+ boolean computeRf2 = !getConfiguration().isConfigurationEmpty();
|
|
|
171
|
+
|
|
|
172
|
+ if (species.isEmpty()) {
|
|
|
173
|
+ log.info(String.format("Won't compute rf2 for any stratum of fleet %s since no species found for it.", countryStr));
|
|
|
174
|
+ computeRf2 = false;
|
|
|
175
|
+ }
|
|
161
|
176
|
for (VesselSimpleType vesselSimpleType : vesselSimpleTypes) {
|
|
162
|
177
|
incrementsProgression();
|
|
163
|
178
|
// get all trip usable for this stratum
|
| ... |
... |
@@ -230,7 +245,7 @@ public class ComputeRF2Action extends AbstractLevel0Action<ComputeRF2Configurati |
|
230
|
245
|
Country fleet,
|
|
231
|
246
|
VesselSimpleType vesselSimpleType,
|
|
232
|
247
|
T3Date month,
|
|
233
|
|
- List<Species> species,
|
|
|
248
|
+ Collection<Species> species,
|
|
234
|
249
|
Collection<CompleteTrip> trips,
|
|
235
|
250
|
boolean computeRf2) throws TopiaException {
|
|
236
|
251
|
|
| ... |
... |
@@ -277,7 +292,7 @@ public class ComputeRF2Action extends AbstractLevel0Action<ComputeRF2Configurati |
|
277
|
292
|
}
|
|
278
|
293
|
}
|
|
279
|
294
|
|
|
280
|
|
- private float computeRF2ForStratum(Collection<CompleteTrip> trips, List<Species> species) {
|
|
|
295
|
+ private float computeRF2ForStratum(Collection<CompleteTrip> trips, Collection<Species> species) {
|
|
281
|
296
|
float totalLandingWeight = 0f;
|
|
282
|
297
|
float totalCatchWeight = 0f;
|
|
283
|
298
|
for (CompleteTrip trip : trips) {
|
| ... |
... |
@@ -326,4 +341,11 @@ public class ComputeRF2Action extends AbstractLevel0Action<ComputeRF2Configurati |
|
326
|
341
|
return !exist;
|
|
327
|
342
|
}
|
|
328
|
343
|
|
|
|
344
|
+ public Multimap<Country, Species> getSpeciesByCountry() {
|
|
|
345
|
+ return speciesByCountry;
|
|
|
346
|
+ }
|
|
|
347
|
+
|
|
|
348
|
+ public void setSpeciesByCountry(Multimap<Country, Species> speciesByCountry) {
|
|
|
349
|
+ this.speciesByCountry = speciesByCountry;
|
|
|
350
|
+ }
|
|
329
|
351
|
}
|