Tony CHEMIT pushed to branch develop at ultreiaio / ird-t3
Commits:
-
9b357a07
by Tony CHEMIT at 2018-03-19T15:42:43Z
4 changed files:
- t3-actions/src/main/java/fr/ird/t3/actions/data/level2/Level2Action.java
- t3-domain/src/main/java/fr/ird/t3/entities/data/AbstractActivityTopiaDao.java
- t3-web/src/main/java/fr/ird/t3/web/actions/data/level2/Level2RunAction.java
- t3-web/src/main/java/fr/ird/t3/web/actions/data/level3/Level3RunAction.java
Changes:
| ... | ... | @@ -99,7 +99,7 @@ public class Level2Action extends T3Action<Level2Configuration> { |
| 99 | 99 |
*
|
| 100 | 100 |
* @since 1.3
|
| 101 | 101 |
*/
|
| 102 |
- WeightCompositionAggregateModel inputCatchModelForAllSpecies;
|
|
| 102 |
+ private WeightCompositionAggregateModel inputCatchModelForAllSpecies;
|
|
| 103 | 103 |
/**
|
| 104 | 104 |
* Output Weight composition
|
| 105 | 105 |
* (based on {@link CorrectedElementaryCatch#getCorrectedCatchWeight()}) for all
|
| ... | ... | @@ -107,13 +107,13 @@ public class Level2Action extends T3Action<Level2Configuration> { |
| 107 | 107 |
*
|
| 108 | 108 |
* @since 1.3
|
| 109 | 109 |
*/
|
| 110 |
- WeightCompositionAggregateModel outputCatchModelForAllSpecies;
|
|
| 110 |
+ private WeightCompositionAggregateModel outputCatchModelForAllSpecies;
|
|
| 111 | 111 |
/**
|
| 112 | 112 |
* For each stratum gets his result.
|
| 113 | 113 |
*
|
| 114 | 114 |
* @since 1.3
|
| 115 | 115 |
*/
|
| 116 |
- Collection<L2StratumResult> stratumsResult;
|
|
| 116 |
+ private Collection<L2StratumResult> stratumsResult;
|
|
| 117 | 117 |
@InjectDAO(entityType = Activity.class)
|
| 118 | 118 |
private ActivityTopiaDao activityDAO;
|
| 119 | 119 |
@InjectDAO(entityType = WeightCategoryTreatment.class)
|
| ... | ... | @@ -126,9 +126,9 @@ public class Level2Action extends T3Action<Level2Configuration> { |
| 126 | 126 |
@InjectFromDAO(entityType = SchoolType.class, method = "findAllForStratum")
|
| 127 | 127 |
private Set<SchoolType> schoolTypes;
|
| 128 | 128 |
@InjectEntitiesById(entityType = Country.class)
|
| 129 |
- private Set<Country> catchFleets;
|
|
| 129 |
+ private Collection<Country> catchFleets;
|
|
| 130 | 130 |
@InjectEntitiesById(entityType = Ocean.class)
|
| 131 |
- private Set<Ocean> oceans;
|
|
| 131 |
+ private Collection<Ocean> oceans;
|
|
| 132 | 132 |
@InjectEntitiesById(entityType = Species.class, path = "configuration.speciesIds")
|
| 133 | 133 |
private Collection<Species> species;
|
| 134 | 134 |
@InjectEntitiesById(entityType = Country.class)
|
| ... | ... | @@ -267,17 +267,19 @@ public class AbstractActivityTopiaDao<E extends Activity> extends GeneratedActiv |
| 267 | 267 |
schoolTypeParameters.append(", ?");
|
| 268 | 268 |
}
|
| 269 | 269 |
PreparedStatement ps = connection.prepareStatement(
|
| 270 |
- "SELECT a.topiaid FROM trip t, activity a, " + zoneTableName + " z " +
|
|
| 271 |
- "WHERE a.trip = t.topiaId " +
|
|
| 272 |
- "AND t." + Trip.PROPERTY_TRIP_TYPE + " IN (0, 2)" +
|
|
| 270 |
+ "SELECT a.topiaid FROM trip t, route r, activity a, " + zoneTableName + " z " +
|
|
| 271 |
+ "WHERE " +
|
|
| 272 |
+ "a.route = r.topiaId " +
|
|
| 273 |
+ "AND r.trip = t.topiaId " +
|
|
| 274 |
+ "AND t." + Trip.PROPERTY_TRIP_TYPE + " IN ('STANDARD', 'LOGBOOKMISSING')" +
|
|
| 273 | 275 |
"AND t." + Trip.PROPERTY_COMPLETION_STATUS + " IS NOT NULL " +
|
| 274 | 276 |
"AND t." + Trip.PROPERTY_COMPLETION_STATUS + " > 0 " +
|
| 275 | 277 |
"AND ST_WITHIN(a.the_geom, z.the_geom) " +
|
| 276 | 278 |
"AND z.topiaid = ? " +
|
| 277 | 279 |
"AND a.expertflag != 0 " +
|
| 278 | 280 |
"AND a.schooltype IN (" + schoolTypeParameters.substring(2) + ")" +
|
| 279 |
- "AND a.date::date >= ? " +
|
|
| 280 |
- "AND a.date::date <= ? " +
|
|
| 281 |
+ "AND r.date::date >= ? " +
|
|
| 282 |
+ "AND r.date::date <= ? " +
|
|
| 281 | 283 |
"AND (SELECT COUNT(*) FROM CorrectedElementaryCatch c WHERE c.activity = a.topiaid) > 0"
|
| 282 | 284 |
);
|
| 283 | 285 |
|
| ... | ... | @@ -330,19 +332,20 @@ public class AbstractActivityTopiaDao<E extends Activity> extends GeneratedActiv |
| 330 | 332 |
schoolTypeParameters.append(", ?");
|
| 331 | 333 |
}
|
| 332 | 334 |
PreparedStatement ps = connection.prepareStatement(
|
| 333 |
- "SELECT a.topiaid FROM trip t, activity a, " +
|
|
| 335 |
+ "SELECT a.topiaid FROM trip t, route r, activity a, " +
|
|
| 334 | 336 |
zoneTableName + " z WHERE " +
|
| 335 |
- "a.trip = t.topiaId " +
|
|
| 336 |
- "AND t." + Trip.PROPERTY_TRIP_TYPE + " IN (0, 2)" +
|
|
| 337 |
+ "r.trip = t.topiaId " +
|
|
| 338 |
+ "AND a.route = r.topiaId " +
|
|
| 339 |
+ "AND t." + Trip.PROPERTY_TRIP_TYPE + " IN ('STANDARD', 'LOGBOOKMISSING')" +
|
|
| 337 | 340 |
"AND t." + Trip.PROPERTY_COMPLETION_STATUS + " IS NOT NULL " +
|
| 338 | 341 |
"AND t." + Trip.PROPERTY_COMPLETION_STATUS + " > 0 " +
|
| 339 | 342 |
"AND ST_INTERSECTS(a.the_geom, z.the_geom) " +
|
| 340 | 343 |
"AND NOT ST_WITHIN(a.the_geom, z.the_geom) " +
|
| 341 | 344 |
"AND z.topiaid = ? " +
|
| 342 | 345 |
"AND a.expertflag != 0 " +
|
| 343 |
- "AND a.schooltype = IN (" + schoolTypeParameters.substring(2) + ") " +
|
|
| 344 |
- "AND a.date::date >= ? " +
|
|
| 345 |
- "AND a.date::date <= ? " +
|
|
| 346 |
+ "AND a.schooltype IN (" + schoolTypeParameters.substring(2) + ") " +
|
|
| 347 |
+ "AND r.date::date >= ? " +
|
|
| 348 |
+ "AND r.date::date <= ? " +
|
|
| 346 | 349 |
"AND (SELECT COUNT(*) FROM CorrectedElementaryCatch c WHERE c.activity = a.topiaid) > 0");
|
| 347 | 350 |
|
| 348 | 351 |
int index = 0;
|
| ... | ... | @@ -394,17 +397,18 @@ public class AbstractActivityTopiaDao<E extends Activity> extends GeneratedActiv |
| 394 | 397 |
schoolTypeParameters.append(", ?");
|
| 395 | 398 |
}
|
| 396 | 399 |
PreparedStatement ps = connection.prepareStatement(
|
| 397 |
- "SELECT a.topiaid FROM trip t, activity a, " +
|
|
| 400 |
+ "SELECT a.topiaid FROM trip t, route r, activity a, " +
|
|
| 398 | 401 |
zoneTableName + " z WHERE " +
|
| 399 |
- "a.trip = t.topiaId " +
|
|
| 400 |
- "AND (t." + Trip.PROPERTY_TRIP_TYPE + " = 1 OR (" +
|
|
| 402 |
+ "r.trip = t.topiaId " +
|
|
| 403 |
+ "AND a.route = r.topiaId " +
|
|
| 404 |
+ "AND (t." + Trip.PROPERTY_TRIP_TYPE + " = 'SAMPLEONLY' OR (" +
|
|
| 401 | 405 |
"t." + Trip.PROPERTY_COMPLETION_STATUS + " IS NOT NULL " +
|
| 402 | 406 |
"AND t." + Trip.PROPERTY_COMPLETION_STATUS + " > 0 ))" +
|
| 403 | 407 |
"AND ST_WITHIN(a.the_geom, z.the_geom) " +
|
| 404 | 408 |
"AND z.topiaid = ? " +
|
| 405 |
- "AND a.schooltype = IN (" + schoolTypeParameters.substring(2) + ")" +
|
|
| 406 |
- "AND a.date::date >= ? " +
|
|
| 407 |
- "AND a.date::date <= ? " +
|
|
| 409 |
+ "AND a.schooltype IN (" + schoolTypeParameters.substring(2) + ")" +
|
|
| 410 |
+ "AND r.date::date >= ? " +
|
|
| 411 |
+ "AND r.date::date <= ? " +
|
|
| 408 | 412 |
"AND (SELECT COUNT(*) FROM SetSpeciesCatWeight c WHERE c.activity = a.topiaid) > 0");
|
| 409 | 413 |
int index = 0;
|
| 410 | 414 |
ps.setString(++index, zoneId);
|
| ... | ... | @@ -446,16 +450,17 @@ public class AbstractActivityTopiaDao<E extends Activity> extends GeneratedActiv |
| 446 | 450 |
@Override
|
| 447 | 451 |
public PreparedStatement prepareQuery(Connection connection) throws SQLException {
|
| 448 | 452 |
PreparedStatement ps = connection.prepareStatement(
|
| 449 |
- "SELECT a.topiaid FROM trip t, activity a, " +
|
|
| 453 |
+ "SELECT a.topiaid FROM trip t, route r, activity a, " +
|
|
| 450 | 454 |
zoneTableName + " z WHERE " +
|
| 451 |
- "a.trip = t.topiaId " +
|
|
| 452 |
- "AND (t." + Trip.PROPERTY_TRIP_TYPE + " = 1 OR (" +
|
|
| 455 |
+ "r.trip = t.topiaId " +
|
|
| 456 |
+ "AND a.route = r.topiaId " +
|
|
| 457 |
+ "AND (t." + Trip.PROPERTY_TRIP_TYPE + " = 'SAMPLEONLY' OR (" +
|
|
| 453 | 458 |
"t." + Trip.PROPERTY_COMPLETION_STATUS + " IS NOT NULL " +
|
| 454 | 459 |
"AND t." + Trip.PROPERTY_COMPLETION_STATUS + " > 0 ))" +
|
| 455 | 460 |
"AND ST_WITHIN(a.the_geom, z.the_geom) " +
|
| 456 | 461 |
"AND z.topiaid = ? " +
|
| 457 |
- "AND a.date::date >= ? " +
|
|
| 458 |
- "AND a.date::date <= ? " +
|
|
| 462 |
+ "AND r.date::date >= ? " +
|
|
| 463 |
+ "AND r.date::date <= ? " +
|
|
| 459 | 464 |
"AND (SELECT COUNT(*) FROM SetSpeciesCatWeight c WHERE c.activity = a.topiaid) > 0"
|
| 460 | 465 |
);
|
| 461 | 466 |
ps.setString(1, zoneId);
|
| ... | ... | @@ -31,6 +31,7 @@ import fr.ird.t3.entities.reference.zone.ZoneVersion; |
| 31 | 31 |
import fr.ird.t3.services.ioc.InjectDecoratedBeans;
|
| 32 | 32 |
import fr.ird.t3.web.actions.AbstractRunAction;
|
| 33 | 33 |
|
| 34 |
+import java.util.Arrays;
|
|
| 34 | 35 |
import java.util.Date;
|
| 35 | 36 |
import java.util.Map;
|
| 36 | 37 |
|
| ... | ... | @@ -59,7 +60,6 @@ public class Level2RunAction extends AbstractRunAction<Level2Configuration, Leve |
| 59 | 60 |
private Map<String, String> sampleFleets;
|
| 60 | 61 |
@InjectDecoratedBeans(beanType = Country.class, filterById = true)
|
| 61 | 62 |
private Map<String, String> sampleFlags;
|
| 62 |
- @InjectDecoratedBeans(beanType = SchoolTypeIndeterminate.class)
|
|
| 63 | 63 |
private Map<String, String> schoolTypeIndeterminate;
|
| 64 | 64 |
private Map<String, String> useSamplesOrNot;
|
| 65 | 65 |
private Map<String, String> useWeightCategoriesInStratumOrNot;
|
| ... | ... | @@ -127,6 +127,7 @@ public class Level2RunAction extends AbstractRunAction<Level2Configuration, Leve |
| 127 | 127 |
public void prepare() throws Exception {
|
| 128 | 128 |
useSamplesOrNot = createLevel2UseSamplesOrNotMap();
|
| 129 | 129 |
useWeightCategoriesInStratumOrNot = createUseWeightCategoriesInStratumOrNot();
|
| 130 |
+ schoolTypeIndeterminate = sortAndDecorateIdAbles(Arrays.asList(SchoolTypeIndeterminate.values()));
|
|
| 130 | 131 |
super.prepare();
|
| 131 | 132 |
}
|
| 132 | 133 |
|
| ... | ... | @@ -33,6 +33,7 @@ import fr.ird.t3.entities.reference.zone.ZoneVersion; |
| 33 | 33 |
import fr.ird.t3.services.ioc.InjectDecoratedBeans;
|
| 34 | 34 |
import fr.ird.t3.web.actions.AbstractRunAction;
|
| 35 | 35 |
|
| 36 |
+import java.util.Arrays;
|
|
| 36 | 37 |
import java.util.Date;
|
| 37 | 38 |
import java.util.Map;
|
| 38 | 39 |
import java.util.TreeMap;
|
| ... | ... | @@ -69,7 +70,6 @@ public class Level3RunAction extends AbstractRunAction<Level3Configuration, Leve |
| 69 | 70 |
/** all sample flags. */
|
| 70 | 71 |
@InjectDecoratedBeans(beanType = Country.class, filterById = true)
|
| 71 | 72 |
private Map<String, String> sampleFlags;
|
| 72 |
- @InjectDecoratedBeans(beanType = SchoolTypeIndeterminate.class)
|
|
| 73 | 73 |
private Map<String, String> schoolTypeIndeterminate;
|
| 74 | 74 |
private Map<String, String> useSamplesOrNot;
|
| 75 | 75 |
private Map<String, String> useWeightCategoriesOrNot;
|
| ... | ... | @@ -159,6 +159,7 @@ public class Level3RunAction extends AbstractRunAction<Level3Configuration, Leve |
| 159 | 159 |
useSamplesOrNot = createLevel3UseSamplesOrNotMap();
|
| 160 | 160 |
useWeightCategoriesOrNot = createLevel3UseWeightCategoriesOrNotMap();
|
| 161 | 161 |
useWeightCategoriesInStratumOrNot = createUseWeightCategoriesInStratumOrNot();
|
| 162 |
+ schoolTypeIndeterminate = sortAndDecorateIdAbles(Arrays.asList(SchoolTypeIndeterminate.values()));
|
|
| 162 | 163 |
super.prepare();
|
| 163 | 164 |
// on level 3, can't treat Indeterminate school type
|
| 164 | 165 |
schoolTypeIndeterminate.remove(SchoolTypeTopiaDao.SCHOOL_TYPE_INDETERMINATE_ID);
|