Tony CHEMIT pushed to branch develop at ultreiaio / ird-t3 Commits: 9b357a07 by Tony CHEMIT at 2018-03-19T15:42:43Z correction sur les requetes du niveau 2 et 3 - - - - - 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: ===================================== t3-actions/src/main/java/fr/ird/t3/actions/data/level2/Level2Action.java ===================================== --- a/t3-actions/src/main/java/fr/ird/t3/actions/data/level2/Level2Action.java +++ b/t3-actions/src/main/java/fr/ird/t3/actions/data/level2/Level2Action.java @@ -99,7 +99,7 @@ public class Level2Action extends T3Action<Level2Configuration> { * * @since 1.3 */ - WeightCompositionAggregateModel inputCatchModelForAllSpecies; + private WeightCompositionAggregateModel inputCatchModelForAllSpecies; /** * Output Weight composition * (based on {@link CorrectedElementaryCatch#getCorrectedCatchWeight()}) for all @@ -107,13 +107,13 @@ public class Level2Action extends T3Action<Level2Configuration> { * * @since 1.3 */ - WeightCompositionAggregateModel outputCatchModelForAllSpecies; + private WeightCompositionAggregateModel outputCatchModelForAllSpecies; /** * For each stratum gets his result. * * @since 1.3 */ - Collection<L2StratumResult> stratumsResult; + private Collection<L2StratumResult> stratumsResult; @InjectDAO(entityType = Activity.class) private ActivityTopiaDao activityDAO; @InjectDAO(entityType = WeightCategoryTreatment.class) @@ -126,9 +126,9 @@ public class Level2Action extends T3Action<Level2Configuration> { @InjectFromDAO(entityType = SchoolType.class, method = "findAllForStratum") private Set<SchoolType> schoolTypes; @InjectEntitiesById(entityType = Country.class) - private Set<Country> catchFleets; + private Collection<Country> catchFleets; @InjectEntitiesById(entityType = Ocean.class) - private Set<Ocean> oceans; + private Collection<Ocean> oceans; @InjectEntitiesById(entityType = Species.class, path = "configuration.speciesIds") private Collection<Species> species; @InjectEntitiesById(entityType = Country.class) ===================================== t3-domain/src/main/java/fr/ird/t3/entities/data/AbstractActivityTopiaDao.java ===================================== --- a/t3-domain/src/main/java/fr/ird/t3/entities/data/AbstractActivityTopiaDao.java +++ b/t3-domain/src/main/java/fr/ird/t3/entities/data/AbstractActivityTopiaDao.java @@ -267,17 +267,19 @@ public class AbstractActivityTopiaDao<E extends Activity> extends GeneratedActiv schoolTypeParameters.append(", ?"); } PreparedStatement ps = connection.prepareStatement( - "SELECT a.topiaid FROM trip t, activity a, " + zoneTableName + " z " + - "WHERE a.trip = t.topiaId " + - "AND t." + Trip.PROPERTY_TRIP_TYPE + " IN (0, 2)" + + "SELECT a.topiaid FROM trip t, route r, activity a, " + zoneTableName + " z " + + "WHERE " + + "a.route = r.topiaId " + + "AND r.trip = t.topiaId " + + "AND t." + Trip.PROPERTY_TRIP_TYPE + " IN ('STANDARD', 'LOGBOOKMISSING')" + "AND t." + Trip.PROPERTY_COMPLETION_STATUS + " IS NOT NULL " + "AND t." + Trip.PROPERTY_COMPLETION_STATUS + " > 0 " + "AND ST_WITHIN(a.the_geom, z.the_geom) " + "AND z.topiaid = ? " + "AND a.expertflag != 0 " + "AND a.schooltype IN (" + schoolTypeParameters.substring(2) + ")" + - "AND a.date::date >= ? " + - "AND a.date::date <= ? " + + "AND r.date::date >= ? " + + "AND r.date::date <= ? " + "AND (SELECT COUNT(*) FROM CorrectedElementaryCatch c WHERE c.activity = a.topiaid) > 0" ); @@ -330,19 +332,20 @@ public class AbstractActivityTopiaDao<E extends Activity> extends GeneratedActiv schoolTypeParameters.append(", ?"); } PreparedStatement ps = connection.prepareStatement( - "SELECT a.topiaid FROM trip t, activity a, " + + "SELECT a.topiaid FROM trip t, route r, activity a, " + zoneTableName + " z WHERE " + - "a.trip = t.topiaId " + - "AND t." + Trip.PROPERTY_TRIP_TYPE + " IN (0, 2)" + + "r.trip = t.topiaId " + + "AND a.route = r.topiaId " + + "AND t." + Trip.PROPERTY_TRIP_TYPE + " IN ('STANDARD', 'LOGBOOKMISSING')" + "AND t." + Trip.PROPERTY_COMPLETION_STATUS + " IS NOT NULL " + "AND t." + Trip.PROPERTY_COMPLETION_STATUS + " > 0 " + "AND ST_INTERSECTS(a.the_geom, z.the_geom) " + "AND NOT ST_WITHIN(a.the_geom, z.the_geom) " + "AND z.topiaid = ? " + "AND a.expertflag != 0 " + - "AND a.schooltype = IN (" + schoolTypeParameters.substring(2) + ") " + - "AND a.date::date >= ? " + - "AND a.date::date <= ? " + + "AND a.schooltype IN (" + schoolTypeParameters.substring(2) + ") " + + "AND r.date::date >= ? " + + "AND r.date::date <= ? " + "AND (SELECT COUNT(*) FROM CorrectedElementaryCatch c WHERE c.activity = a.topiaid) > 0"); int index = 0; @@ -394,17 +397,18 @@ public class AbstractActivityTopiaDao<E extends Activity> extends GeneratedActiv schoolTypeParameters.append(", ?"); } PreparedStatement ps = connection.prepareStatement( - "SELECT a.topiaid FROM trip t, activity a, " + + "SELECT a.topiaid FROM trip t, route r, activity a, " + zoneTableName + " z WHERE " + - "a.trip = t.topiaId " + - "AND (t." + Trip.PROPERTY_TRIP_TYPE + " = 1 OR (" + + "r.trip = t.topiaId " + + "AND a.route = r.topiaId " + + "AND (t." + Trip.PROPERTY_TRIP_TYPE + " = 'SAMPLEONLY' OR (" + "t." + Trip.PROPERTY_COMPLETION_STATUS + " IS NOT NULL " + "AND t." + Trip.PROPERTY_COMPLETION_STATUS + " > 0 ))" + "AND ST_WITHIN(a.the_geom, z.the_geom) " + "AND z.topiaid = ? " + - "AND a.schooltype = IN (" + schoolTypeParameters.substring(2) + ")" + - "AND a.date::date >= ? " + - "AND a.date::date <= ? " + + "AND a.schooltype IN (" + schoolTypeParameters.substring(2) + ")" + + "AND r.date::date >= ? " + + "AND r.date::date <= ? " + "AND (SELECT COUNT(*) FROM SetSpeciesCatWeight c WHERE c.activity = a.topiaid) > 0"); int index = 0; ps.setString(++index, zoneId); @@ -446,16 +450,17 @@ public class AbstractActivityTopiaDao<E extends Activity> extends GeneratedActiv @Override public PreparedStatement prepareQuery(Connection connection) throws SQLException { PreparedStatement ps = connection.prepareStatement( - "SELECT a.topiaid FROM trip t, activity a, " + + "SELECT a.topiaid FROM trip t, route r, activity a, " + zoneTableName + " z WHERE " + - "a.trip = t.topiaId " + - "AND (t." + Trip.PROPERTY_TRIP_TYPE + " = 1 OR (" + + "r.trip = t.topiaId " + + "AND a.route = r.topiaId " + + "AND (t." + Trip.PROPERTY_TRIP_TYPE + " = 'SAMPLEONLY' OR (" + "t." + Trip.PROPERTY_COMPLETION_STATUS + " IS NOT NULL " + "AND t." + Trip.PROPERTY_COMPLETION_STATUS + " > 0 ))" + "AND ST_WITHIN(a.the_geom, z.the_geom) " + "AND z.topiaid = ? " + - "AND a.date::date >= ? " + - "AND a.date::date <= ? " + + "AND r.date::date >= ? " + + "AND r.date::date <= ? " + "AND (SELECT COUNT(*) FROM SetSpeciesCatWeight c WHERE c.activity = a.topiaid) > 0" ); ps.setString(1, zoneId); ===================================== t3-web/src/main/java/fr/ird/t3/web/actions/data/level2/Level2RunAction.java ===================================== --- a/t3-web/src/main/java/fr/ird/t3/web/actions/data/level2/Level2RunAction.java +++ b/t3-web/src/main/java/fr/ird/t3/web/actions/data/level2/Level2RunAction.java @@ -31,6 +31,7 @@ import fr.ird.t3.entities.reference.zone.ZoneVersion; import fr.ird.t3.services.ioc.InjectDecoratedBeans; import fr.ird.t3.web.actions.AbstractRunAction; +import java.util.Arrays; import java.util.Date; import java.util.Map; @@ -59,7 +60,6 @@ public class Level2RunAction extends AbstractRunAction<Level2Configuration, Leve private Map<String, String> sampleFleets; @InjectDecoratedBeans(beanType = Country.class, filterById = true) private Map<String, String> sampleFlags; - @InjectDecoratedBeans(beanType = SchoolTypeIndeterminate.class) private Map<String, String> schoolTypeIndeterminate; private Map<String, String> useSamplesOrNot; private Map<String, String> useWeightCategoriesInStratumOrNot; @@ -127,6 +127,7 @@ public class Level2RunAction extends AbstractRunAction<Level2Configuration, Leve public void prepare() throws Exception { useSamplesOrNot = createLevel2UseSamplesOrNotMap(); useWeightCategoriesInStratumOrNot = createUseWeightCategoriesInStratumOrNot(); + schoolTypeIndeterminate = sortAndDecorateIdAbles(Arrays.asList(SchoolTypeIndeterminate.values())); super.prepare(); } ===================================== t3-web/src/main/java/fr/ird/t3/web/actions/data/level3/Level3RunAction.java ===================================== --- a/t3-web/src/main/java/fr/ird/t3/web/actions/data/level3/Level3RunAction.java +++ b/t3-web/src/main/java/fr/ird/t3/web/actions/data/level3/Level3RunAction.java @@ -33,6 +33,7 @@ import fr.ird.t3.entities.reference.zone.ZoneVersion; import fr.ird.t3.services.ioc.InjectDecoratedBeans; import fr.ird.t3.web.actions.AbstractRunAction; +import java.util.Arrays; import java.util.Date; import java.util.Map; import java.util.TreeMap; @@ -69,7 +70,6 @@ public class Level3RunAction extends AbstractRunAction<Level3Configuration, Leve /** all sample flags. */ @InjectDecoratedBeans(beanType = Country.class, filterById = true) private Map<String, String> sampleFlags; - @InjectDecoratedBeans(beanType = SchoolTypeIndeterminate.class) private Map<String, String> schoolTypeIndeterminate; private Map<String, String> useSamplesOrNot; private Map<String, String> useWeightCategoriesOrNot; @@ -159,6 +159,7 @@ public class Level3RunAction extends AbstractRunAction<Level3Configuration, Leve useSamplesOrNot = createLevel3UseSamplesOrNotMap(); useWeightCategoriesOrNot = createLevel3UseWeightCategoriesOrNotMap(); useWeightCategoriesInStratumOrNot = createUseWeightCategoriesInStratumOrNot(); + schoolTypeIndeterminate = sortAndDecorateIdAbles(Arrays.asList(SchoolTypeIndeterminate.values())); super.prepare(); // on level 3, can't treat Indeterminate school type schoolTypeIndeterminate.remove(SchoolTypeTopiaDao.SCHOOL_TYPE_INDETERMINATE_ID); View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/9b357a079348524012c3360a374d45f57... --- View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/9b357a079348524012c3360a374d45f57... You're receiving this email because of your account on gitlab.com.