[Git][ultreiaio/ird-t3][develop] [N0] Calcul des temps de pêche (See #240)
Tony CHEMIT pushed to branch develop at ultreiaio / ird-t3 Commits: ef7c73b1 by Tony CHEMIT at 2018-02-20T22:41:48+01:00 [N0] Calcul des temps de pêche (See #240) - - - - - 27 changed files: - t3-actions/src/main/java/fr/ird/t3/actions/data/level0/AbstractLevel0Action.java - t3-actions/src/main/java/fr/ird/t3/actions/data/level0/ComputeTripEffortsAction.java - t3-actions/src/main/resources/i18n/t3-actions_en_GB.properties - t3-actions/src/main/resources/i18n/t3-actions_fr_FR.properties - + t3-domain/src/main/java/fr/ird/t3/entities/data/AbstractRouteTopiaDao.java - t3-domain/src/main/java/fr/ird/t3/entities/data/AbstractTripTopiaDao.java - t3-domain/src/main/java/fr/ird/t3/entities/data/ActivityImpl.java - + t3-domain/src/main/java/fr/ird/t3/entities/data/RouteImpl.java - t3-domain/src/main/java/fr/ird/t3/entities/data/TripImpl.java - t3-domain/src/main/java/fr/ird/t3/entities/reference/AbstractCountryTopiaDao.java - t3-domain/src/main/java/fr/ird/t3/entities/reference/AbstractVesselSimpleTypeTopiaDao.java - t3-domain/src/main/java/fr/ird/t3/services/DecoratorService.java - + t3-domain/src/main/java/fr/ird/t3/services/migration/T3MigrationCallbackV2_2.java - + t3-domain/src/main/resources/db/migration/V2_2_07_add-Route-table.sql - + t3-domain/src/main/resources/db/migration/V2_2_08_remove-Trip-fields.sql - t3-domain/src/main/xmi/t3-persistence.properties - t3-domain/src/main/xmi/t3-persistence.zargo - t3-domain/src/test/java/fr/ird/t3/entities/T3PersistenceFixtures.java - t3-input-avdthv33/src/main/java/fr/ird/t3/io/input/avdth/v33/T3AccessEntityMetaProviderAvdth33.java - t3-input-avdthv33/src/test/java/fr/ird/t3/actions/io/input/AnalyzeInputSourceActionIT.java - t3-input-avdthv33/src/test/java/fr/ird/t3/actions/io/input/ImportInputSourceActionIT.java - t3-input-avdthv35/src/main/java/fr/ird/t3/io/input/avdth/v35/T3AccessEntityMetaProviderAvdth35.java - t3-input-avdthv35/src/test/java/fr/ird/t3/actions/io/input/AnalyzeInputSourceActionITSupport.java - t3-input-avdthv35/src/test/java/fr/ird/t3/actions/io/input/ImportInputSourceActionITSupport.java - t3-input-avdthv36/src/main/java/fr/ird/t3/io/input/avdth/v36/T3AccessEntityMetaProviderAvdth36.java - t3-input-avdthv36/src/test/java/fr/ird/t3/actions/io/input/AnalyzeInputSourceActionITSupport.java - t3-input-avdthv36/src/test/java/fr/ird/t3/actions/io/input/ImportInputSourceActionITSupport.java Changes: ===================================== t3-actions/src/main/java/fr/ird/t3/actions/data/level0/AbstractLevel0Action.java ===================================== --- a/t3-actions/src/main/java/fr/ird/t3/actions/data/level0/AbstractLevel0Action.java +++ b/t3-actions/src/main/java/fr/ird/t3/actions/data/level0/AbstractLevel0Action.java @@ -21,6 +21,8 @@ package fr.ird.t3.actions.data.level0; import fr.ird.t3.actions.T3Action; +import fr.ird.t3.entities.data.Route; +import fr.ird.t3.entities.data.RouteTopiaDao; import fr.ird.t3.entities.data.Trip; import fr.ird.t3.entities.data.TripTopiaDao; import fr.ird.t3.entities.reference.Country; @@ -54,6 +56,9 @@ public abstract class AbstractLevel0Action<C extends AbstractLevel0Configuration @InjectDAO(entityType = Trip.class) protected TripTopiaDao tripDAO; + @InjectDAO(entityType = Route.class) + protected RouteTopiaDao routeDAO; + @InjectEntitiesById(entityType = Country.class) protected List<Country> fleets; ===================================== t3-actions/src/main/java/fr/ird/t3/actions/data/level0/ComputeTripEffortsAction.java ===================================== --- a/t3-actions/src/main/java/fr/ird/t3/actions/data/level0/ComputeTripEffortsAction.java +++ b/t3-actions/src/main/java/fr/ird/t3/actions/data/level0/ComputeTripEffortsAction.java @@ -8,12 +8,12 @@ * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% @@ -22,26 +22,21 @@ package fr.ird.t3.actions.data.level0; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import com.google.common.collect.Multimap; import com.web_tomorrow.utils.suntimes.SunTimes; import fr.ird.t3.entities.data.Activity; -import fr.ird.t3.entities.data.ActivityTopiaDao; +import fr.ird.t3.entities.data.Route; import fr.ird.t3.entities.data.Trip; import fr.ird.t3.entities.reference.VesselActivity; import fr.ird.t3.entities.type.T3Point; -import java.util.Calendar; -import java.util.Collection; -import java.util.Collections; -import java.util.Date; -import java.util.List; import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.topia.persistence.TopiaException; -import org.nuiton.util.DateUtil; +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.Objects; import static org.nuiton.i18n.I18n.l; @@ -56,22 +51,20 @@ import static org.nuiton.i18n.I18n.l; */ public class ComputeTripEffortsAction extends AbstractLevel0Action<ComputeTripEffortsConfiguration> { - /** Logger. */ - private static final Log log = LogFactory.getLog(ComputeTripEffortsAction.class); - /** * Les codes des activités surlequel on ne calcule pas d'effort de pêche. * * @since 2.0 */ - protected static final ImmutableSet<Integer> VESSEL_ACTIVITY_CODES_TO_SKIP = ImmutableSet.of( + private static final ImmutableSet<Integer> VESSEL_ACTIVITY_CODES_TO_SKIP = ImmutableSet.of( 4, // route sans veille 7, // avarie 8, // à la cape 10, // en attente 15 // au port ); - + /** Logger. */ + private static final Log log = LogFactory.getLog(ComputeTripEffortsAction.class); protected float totalTimeAtSeaN0; protected float totalFishingTimeN0; @@ -127,146 +120,110 @@ public class ComputeTripEffortsAction extends AbstractLevel0Action<ComputeTripEf return result; } - protected boolean executeForTrip(Trip trip) throws TopiaException { + private boolean executeForTrip(Trip trip) throws TopiaException { // compute time at sea - float timeAtSea = computeTimeAtSea(trip); - totalTimeAtSeaN0 += timeAtSea; - - trip.setComputedTimeAtSeaN0(timeAtSea); - incrementsProgression(); - - // compute fishing time - float fishingTime = computeFishingTime(trip); - totalFishingTimeN0 += fishingTime; - trip.setComputedFishingTimeN0(fishingTime); - incrementsProgression(); - - // compute search time - float searchTime = computeTripSearchTime(trip, fishingTime); - totalSearchTimeN0 += searchTime; - trip.setComputedSearchTimeN0(searchTime); - - incrementsProgression(); - - String message = l(locale, "t3.level0.computeTripEffort", - decorate(trip), - trip.getComputedTimeAtSeaN0(), - trip.getComputedFishingTimeN0(), - trip.getComputedSearchTimeN0() - ); - addInfoMessage(message); - if (log.isInfoEnabled()) { - log.info(message); - } - markTripAsTreated(trip); - return true; - } - - protected float computeTimeAtSea(Trip trip) { - float setTimeAtSea; + Route firstRoute = Objects.requireNonNull(trip.getRoute().get(0)); + Route lastRoute = Objects.requireNonNull(Iterables.getLast(trip.getRoute())); - // date depart - date dpq = nb jours - // result = nb heures entre le départ et l'arrivée - Calendar calendarDep = DateUtils.toCalendar(trip.getDepartureDate()); - calendarDep.set(Calendar.MINUTE, 0); - calendarDep.set(Calendar.SECOND, 0); - calendarDep.set(Calendar.MILLISECOND, 0); - Calendar calendarLanding = DateUtils.toCalendar(trip.getLandingDate()); - calendarLanding.set(Calendar.MINUTE, 0); - calendarLanding.set(Calendar.SECOND, 0); - calendarLanding.set(Calendar.MILLISECOND, 0); + for (Route route : trip.getRoute()) { - int months = DateUtil.getDifferenceInHours(calendarDep.getTime(), calendarLanding.getTime()); - setTimeAtSea = months; +// float timeAtSea = computeTimeAtSea(route); +// totalTimeAtSeaN0 += timeAtSea; + totalTimeAtSeaN0 += 24; - if (log.isDebugEnabled()) { - log.debug(decorate(trip) + " : time at sea = " + setTimeAtSea); - } - return setTimeAtSea; - } - - protected float computeFishingTime(Trip trip) throws TopiaException { - - float setFishingTime = 0; +// route.setComputedTimeAtSeaN0(timeAtSea); +// incrementsProgression(); - if (!trip.isActivityEmpty()) { + // compute fishing time + Float fishingTime = computeFishingTime(firstRoute, lastRoute, route); + route.setComputedFishingTimeN0(fishingTime); + incrementsProgression(); - Multimap<Long, Activity> activitiesByDay = ActivityTopiaDao.groupActivitiesByDay(trip.getActivity()); + if (fishingTime == null) { - List<Long> daysIds = Lists.newArrayList(activitiesByDay.keySet()); - Collections.sort(daysIds); - - long firstDay = daysIds.get(0); - long lastDay = Iterables.getLast(daysIds); + route.setComputedSearchTimeN0(null); + incrementsProgression(); + continue; + } - for (Long dayId : daysIds) { + totalFishingTimeN0 += fishingTime; + // compute search time + float searchTime = computeTripSearchTime(route, fishingTime); + totalSearchTimeN0 += searchTime; + route.setComputedSearchTimeN0(searchTime); - Collection<Activity> activities = activitiesByDay.get(dayId); + incrementsProgression(); - if (dayId == firstDay || lastDay == dayId) { - float currentFishingTime = computeSetFishingTimeForFirstOrLayDay(activities); - setFishingTime += currentFishingTime; - continue; - } + String message = l(locale, "t3.level0.computeTripEffort", + decorate(route), + route.getComputedFishingTimeN0(), + route.getComputedSearchTimeN0() + ); - Date date = new Date(dayId); - if (!canComputeSetFishingTime(activities)) { + addInfoMessage(message); + if (log.isInfoEnabled()) { + log.info(message); + } + } + markTripAsTreated(trip); + return true; + } - String message = l(locale, "t3.level0.computeTripEffortSkipForDay", decorate(trip), date); - addInfoMessage(message); - if (log.isInfoEnabled()) { - log.info(message); - } + private Float computeFishingTime(Route firstRoute, Route lastRoute, Route route) throws TopiaException { - continue; - } + Collection<Activity> activities = route.getActivity(); + if (Objects.equals(firstRoute, route) || Objects.equals(lastRoute, route)) { + return computeSetFishingTimeForFirstOrLayDay(activities); + } - T3Point point; + Date date = route.getDate(); + if (!canComputeSetFishingTime(activities)) { - if (activities.size() == 1) { + String message = l(locale, "t3.level0.computeTripEffortSkipForDay", decorate(route)); + addInfoMessage(message); + if (log.isInfoEnabled()) { + log.info(message); + } + return null; + } - // only one activity for this day, - Activity activity = activities.iterator().next(); - point = activity.toPoint(); + T3Point point; - if (log.isDebugEnabled()) { - log.debug("Day [" + date + "] , single activity, point : " + point); - } - } else { + if (activities.size() == 1) { - // compute barycenter for all activities of the day - point = tripDAO.getBarycenterForActivitiesOfADay(trip, date); + // only one activity for this day, + Activity activity = activities.iterator().next(); + point = activity.toPoint(); - if (log.isDebugEnabled()) { - log.debug("Day [" + date + "] Computed barycenter point " + point); - } - } + if (log.isDebugEnabled()) { + log.debug("Day [" + date + "] , single activity, point : " + point); + } + } else { - // compute day duration for this point and day (in minutes) - double duration = SunTimes.getDayDurationInMonths(date, point.getX(), point.getY()); + // compute barycenter for all activities of the day + point = routeDAO.getBarycenterForActivitiesOfADay(route, date); - if (log.isInfoEnabled()) { - log.info("Day [" + date + "] duration = " + duration); - } - // add it to setTime - setFishingTime += duration; + if (log.isDebugEnabled()) { + log.debug("Day [" + date + "] Computed barycenter point " + point); } } - if (log.isDebugEnabled()) { - log.debug(decorate(trip) + " - fishing time = " + setFishingTime); - } + // compute day duration for this point and day (in minutes) + double duration = SunTimes.getDayDurationInMonths(date, point.getX(), point.getY()); - return setFishingTime; + if (log.isInfoEnabled()) { + log.info("Day [" + date + "] duration = " + duration); + } + return (float) duration; } - protected float computeTripSearchTime(Trip trip, float fishingTime) { + private float computeTripSearchTime(Route route, float fishingTime) { // compute sum of catches time - float catchesTime = trip.getTotalSetsDuration(); + float catchesTime = route.getTotalSetsDuration(); if (log.isDebugEnabled()) { log.debug("Total catches time = " + catchesTime); @@ -274,12 +231,12 @@ public class ComputeTripEffortsAction extends AbstractLevel0Action<ComputeTripEf float result = fishingTime - catchesTime; if (log.isDebugEnabled()) { - log.debug(decorate(trip) + " - trip search time = " + result); + log.debug(decorate(route) + " - trip search time = " + result); } return result; } - protected float computeSetFishingTimeForFirstOrLayDay(Collection<Activity> activities) { + private float computeSetFishingTimeForFirstOrLayDay(Collection<Activity> activities) { float result = 0f; for (Activity activity : activities) { @@ -289,7 +246,7 @@ public class ComputeTripEffortsAction extends AbstractLevel0Action<ComputeTripEf } - protected boolean canComputeSetFishingTime(Collection<Activity> activities) { + private boolean canComputeSetFishingTime(Collection<Activity> activities) { boolean result = false; for (Activity activity : activities) { VesselActivity vesselActivity = activity.getVesselActivity(); ===================================== t3-actions/src/main/resources/i18n/t3-actions_en_GB.properties ===================================== --- a/t3-actions/src/main/resources/i18n/t3-actions_en_GB.properties +++ b/t3-actions/src/main/resources/i18n/t3-actions_en_GB.properties @@ -42,8 +42,8 @@ t3.level0.computeRF2.resume.rf1.for.trip=Trip %s total rf1 catches weight %s / t t3.level0.computeRF2.resume.skip.for.trip=Trip %s has not elementary landing (trip not used to compute rf2) t3.level0.computeRF2.resume.total.rf1=Sum total rf1 catches weight %s / Sum total landing weight %s t3.level0.computeSetDurationAndPositiveSetCount.error.noSetDurationFound=SetDuration data not found (ocean %s, fleet %s, school type %s, year %s) -t3.level0.computeTripEffort=Trip efforts %s (sea %s, fishing%s, search%s) -t3.level0.computeTripEffortSkipForDay=Trip %s, Day (%s) without fihsing time (only activities of type « at harbour » or « under way without prospection ») +t3.level0.computeTripEffort=Trip efforts %s (fishing %s, search %s) +t3.level0.computeTripEffortSkipForDay=Trip %s, day without fishing time (only activities of type « at harbour » or « under way without prospection ») t3.level0.computeWellPlanWeightCategoriesProportions.resume.for.weightCategory=Weight category %s, weight \= %s, propWeight \= %s (activity %s) t3.level0.computeWellPlanWeightCategoriesProportions.well.withWellPlan=Well (%s) with well plan filled %s wellSetAllSpecies, total weight %s t3.level0.convertCatchesWeightCategories.resume.for.species=Species %s < logBook total weight \= %s , converted total weight \= %s> ===================================== t3-actions/src/main/resources/i18n/t3-actions_fr_FR.properties ===================================== --- a/t3-actions/src/main/resources/i18n/t3-actions_fr_FR.properties +++ b/t3-actions/src/main/resources/i18n/t3-actions_fr_FR.properties @@ -42,8 +42,8 @@ t3.level0.computeRF2.resume.rf1.for.trip=Marée %s Poids total des captures rf1i t3.level0.computeRF2.resume.skip.for.trip=La marée %s ne possède pas de lots commerciaux (non prise en compte dans le calcul du rf2) t3.level0.computeRF2.resume.total.rf1=Poids cumulé des captures rf1isées %s / Poids cumulé des ventes %s t3.level0.computeSetDurationAndPositiveSetCount.error.noSetDurationFound=Donnée SetDuration non trouvée (ocean %s, flotte %s, type de banc %s, année %s) -t3.level0.computeTripEffort=Efforts de la marée %s (mer %s, pêche %s, recherche %s) -t3.level0.computeTripEffortSkipForDay=Marée %s, Journée (%s) sans temps de pêche (uniquement des activités « au port » ou « route sans veille ») +t3.level0.computeTripEffort=Efforts de la marée %s (pêche %s, recherche %s) +t3.level0.computeTripEffortSkipForDay=Marée %s, jour sans temps de pêche (uniquement des activités « au port » ou « route sans veille ») t3.level0.computeWellPlanWeightCategoriesProportions.resume.for.weightCategory=Catégorie de poids %s, poids \= %s, poids pondéré\= %s (activité %s) t3.level0.computeWellPlanWeightCategoriesProportions.well.withWellPlan=Cuve avec plan de cuve (%s) avec %s wellSetAllSpecies, poids total %s t3.level0.convertCatchesWeightCategories.resume.for.species=Espèce %s < poids total des captures du livre de bord \= %s , poids total converti \= %s> ===================================== t3-domain/src/main/java/fr/ird/t3/entities/data/AbstractRouteTopiaDao.java ===================================== --- /dev/null +++ b/t3-domain/src/main/java/fr/ird/t3/entities/data/AbstractRouteTopiaDao.java @@ -0,0 +1,55 @@ +package fr.ird.t3.entities.data; + +import fr.ird.t3.entities.type.T3Point; +import fr.ird.t3.entities.type.T3PointImpl; +import org.nuiton.topia.persistence.TopiaException; +import org.nuiton.topia.persistence.support.TopiaSqlQuery; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Date; + +public class AbstractRouteTopiaDao<E extends Route> extends GeneratedRouteTopiaDao<E> { + + public T3Point getBarycenterForActivitiesOfADay(E route, Date day) throws TopiaException { + + TopiaSqlQuery<T3Point> query = new GetT3PointQuery<E>(route, day); + return topiaSqlSupport.findSingleResult(query); + } + + private static class GetT3PointQuery<E extends Route> extends TopiaSqlQuery<T3Point> { + private final E route; + + private final Date day; + + public GetT3PointQuery(E route, Date day) { + this.route = route; + this.day = day; + } + + @Override + public PreparedStatement prepareQuery(Connection connection) throws SQLException { + PreparedStatement ps = connection.prepareStatement( + "SELECT ST_X(record.point), ST_Y(record.point) FROM " + + "(" + + " SELECT ST_Centroid(ST_Collect(a.the_geom)) AS point" + + " FROM activity a " + + " WHERE a.route = ? AND a.date::DATE = ?" + + ") AS record;"); + ps.setString(1, route.getTopiaId()); + ps.setDate(2, new java.sql.Date(day.getTime())); + return ps; + } + + @Override + public T3Point prepareResult(ResultSet set) throws SQLException { + float x = set.getFloat(1); + float y = set.getFloat(2); + return new T3PointImpl(x, y); + } + } + +} + ===================================== t3-domain/src/main/java/fr/ird/t3/entities/data/AbstractTripTopiaDao.java ===================================== --- a/t3-domain/src/main/java/fr/ird/t3/entities/data/AbstractTripTopiaDao.java +++ b/t3-domain/src/main/java/fr/ird/t3/entities/data/AbstractTripTopiaDao.java @@ -128,13 +128,13 @@ public class AbstractTripTopiaDao<E extends Trip> extends GeneratedTripTopiaDao< // query = createQuery("t") // .setSelect("t.id") // .addWhere("size(t." + Trip.PROPERTY_ACTIVITY + ") = 0"); - hql = "SELECT t.id FROM TripImpl t WHERE size(t.activity) = 0"; + hql = "SELECT t.id FROM TripImpl as t WHERE size(t.route) = 0"; // params = Collections.emptyList(); } else { // query = new TopiaQuery(Activity.class, "a") // .setSelect("distinct(a.trip.id)") // .addWhere("a.ocean", TopiaQuery.Op.EQ, ocean); - hql = "SELECT DISTINCT(a.trip.id) FROM ActivityImpl a WHERE a.ocean = :ocean"; + hql = "SELECT DISTINCT(a.route.trip.id) FROM ActivityImpl a WHERE a.ocean = :ocean"; paramsBuilder.put("ocean", ocean); // params = Lists.<Object>newArrayList("ocean", ocean); } ===================================== t3-domain/src/main/java/fr/ird/t3/entities/data/ActivityImpl.java ===================================== --- a/t3-domain/src/main/java/fr/ird/t3/entities/data/ActivityImpl.java +++ b/t3-domain/src/main/java/fr/ird/t3/entities/data/ActivityImpl.java @@ -26,12 +26,13 @@ import fr.ird.t3.entities.reference.VesselActivity; import fr.ird.t3.entities.type.T3Point; import fr.ird.t3.entities.type.T3PointImpl; import fr.ird.type.CoordinateHelper; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import java.util.Calendar; import java.util.Collection; import java.util.Date; import java.util.Set; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; /** * Implementation of {@link Activity} with manual quadrant @@ -60,6 +61,11 @@ public class ActivityImpl extends ActivityAbstract { protected Integer quadrant; @Override + public Trip getTrip() { + return getRoute().getTrip(); + } + + @Override public Integer getQuadrant() { if (quadrant == null) { ===================================== t3-domain/src/main/java/fr/ird/t3/entities/data/RouteImpl.java ===================================== --- /dev/null +++ b/t3-domain/src/main/java/fr/ird/t3/entities/data/RouteImpl.java @@ -0,0 +1,49 @@ +package fr.ird.t3.entities.data; + +public class RouteImpl extends RouteAbstract { + + private static final long serialVersionUID = 1L; + + /** @return the sum of all activities set duration in hours. */ + @Override + public float getTotalSetsDuration() { + float result = 0; + if (!isActivityEmpty()) { + for (Activity activity : getActivity()) { + + // get the setDuration + Float setTime = activity.getSetDuration(); + + result += setTime == null ? 0f : setTime; + } + } + return result / 60; + } + + @Override + public void deleteComputedDataLevel0() { + setComputedFishingTimeN0(null); + setComputedSearchTimeN0(null); + ComputedDataHelper.deleteComputedDataLevel0(getActivity()); + } + + @Override + public void deleteComputedData() { + ComputedDataHelper.deleteComputedDatas(this); + } + + @Override + public void deleteComputedDataLevel1() { + ComputedDataHelper.deleteComputedDataLevel1(getActivity()); + } + + @Override + public void deleteComputedDataLevel2() { + ComputedDataHelper.deleteComputedDataLevel2(getActivity()); + } + + @Override + public void deleteComputedDataLevel3() { + ComputedDataHelper.deleteComputedDataLevel3(getActivity()); + } +} ===================================== t3-domain/src/main/java/fr/ird/t3/entities/data/TripImpl.java ===================================== --- a/t3-domain/src/main/java/fr/ird/t3/entities/data/TripImpl.java +++ b/t3-domain/src/main/java/fr/ird/t3/entities/data/TripImpl.java @@ -30,9 +30,17 @@ import fr.ird.t3.entities.reference.Ocean; import fr.ird.t3.entities.reference.Species; import fr.ird.t3.entities.reference.Vessel; import fr.ird.t3.entities.reference.VesselImpl; +import org.nuiton.util.DateUtil; import java.util.Collection; +import java.util.Date; +import java.util.LinkedList; +import java.util.List; +import java.util.Objects; +import java.util.Optional; import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; import static org.nuiton.i18n.I18n.n; @@ -119,21 +127,21 @@ public class TripImpl extends TripAbstract { return result; } - /** @return the sum of all activities set duration in hours. */ - @Override - public float getTotalSetsDuration() { - float result = 0; - if (!isActivityEmpty()) { - for (Activity activity : getActivity()) { - - // get the setDuration - Float setTime = activity.getSetDuration(); - - result += setTime == null ? 0f : setTime; - } - } - return result / 60; - } +// /** @return the sum of all activities set duration in hours. */ +// @Override +// public float getTotalSetsDuration() { +// float result = 0; +// if (!isActivityEmpty()) { +// for (Activity activity : getActivity()) { +// +// // get the setDuration +// Float setTime = activity.getSetDuration(); +// +// result += setTime == null ? 0f : setTime; +// } +// } +// return result / 60; +// } @Override public float getElementaryCatchTotalWeight(Collection<Species> species) { @@ -436,19 +444,17 @@ public class TripImpl extends TripAbstract { setCompletionStatus(null); setRf1(null); setRf2(null); - setComputedFishingTimeN0(null); - setComputedSearchTimeN0(null); - setComputedTimeAtSeaN0(null); +// setComputedFishingTimeN0(null); +// setComputedSearchTimeN0(null); +// setComputedTimeAtSeaN0(null); - ComputedDataHelper.deleteComputedDataLevel0(getActivity()); + ComputedDataHelper.deleteComputedDataLevel0(getRoute()); ComputedDataHelper.deleteComputedDataLevel0(getSample()); ComputedDataHelper.deleteComputedDataLevel0(getWell()); } @Override public void deleteComputedDataLevel1() { - - // level 1 flags setExtrapolateSampleCountedAndMeasured(false); setStandardizeSampleMeasures(false); setComputeWeightOfCategoriesForSet(false); @@ -457,27 +463,97 @@ public class TripImpl extends TripAbstract { setConvertSetSpeciesFrequencyToWeight(false); setConvertSampleSetSpeciesFrequencyToWeight(false); - ComputedDataHelper.deleteComputedDataLevel1(getActivity()); + ComputedDataHelper.deleteComputedDataLevel1(getRoute()); ComputedDataHelper.deleteComputedDataLevel1(getSample()); ComputedDataHelper.deleteComputedDataLevel1(getWell()); } @Override public void deleteComputedDataLevel2() { - // level 2 flags - - ComputedDataHelper.deleteComputedDataLevel2(getActivity()); + ComputedDataHelper.deleteComputedDataLevel2(getRoute()); ComputedDataHelper.deleteComputedDataLevel2(getSample()); ComputedDataHelper.deleteComputedDataLevel2(getWell()); } @Override public void deleteComputedDataLevel3() { - // level 3 flags - - ComputedDataHelper.deleteComputedDataLevel3(getActivity()); + ComputedDataHelper.deleteComputedDataLevel3(getRoute()); ComputedDataHelper.deleteComputedDataLevel3(getSample()); ComputedDataHelper.deleteComputedDataLevel3(getWell()); } + @Override + public int getComputedTimeAtSeaN0() { + return 24 * sizeRoute(); + } + + @Override + public int sizeActivity() { + return (int) activityStream().count(); + } + + @Override + public boolean isActivityEmpty() { + return isRouteEmpty() || activityStream().count() == 0; + } + + @Override + public boolean isActivityNotEmpty() { + return isRouteNotEmpty() && activityStream().count() > 0; + } + + @Override + public List<Activity> getActivity() { + return activityStream().collect(Collectors.toList()); + } + + @Override + public void setActivity(List<Activity> activities) { + clearRoute(); + for (Activity activity : activities) { + addActivity(activity); + } + } + + @Override + public Activity getActivityByTopiaId(String topiaId) { + return activityStream().filter(a -> topiaId.equals(a.getTopiaId())).findFirst().orElse(null); + } + + @Override + public Collection<String> getActivityTopiaIds() { + return activityStream().map(Activity::getTopiaId).collect(Collectors.toList()); + } + + @Override + public void addActivity(Activity activity) { + Date date = DateUtil.getDay(activity.getDate()); + Optional<Route> optionalRoute = routeStream().filter(r -> Objects.equals(r.getDate(), date)).findFirst(); + Route route; + if (optionalRoute.isPresent()) { + route = optionalRoute.get(); + } else { + route = new RouteImpl(); + route.setDate(date); + addRoute(route); + } + route.addActivity(activity); + } + + @Override + public List<Route> getRoute() { + List<Route> route = super.getRoute(); + if (route == null) { + setRoute(route = new LinkedList<>()); + } + return route; + } + + private Stream<Route> routeStream() { + return getRoute().stream(); + } + + private Stream<Activity> activityStream() { + return routeStream().flatMap(r -> r.getActivity().stream()); + } } ===================================== t3-domain/src/main/java/fr/ird/t3/entities/reference/AbstractCountryTopiaDao.java ===================================== --- a/t3-domain/src/main/java/fr/ird/t3/entities/reference/AbstractCountryTopiaDao.java +++ b/t3-domain/src/main/java/fr/ird/t3/entities/reference/AbstractCountryTopiaDao.java @@ -126,7 +126,7 @@ public class AbstractCountryTopiaDao<E extends Country> extends GeneratedCountry // .addParam("oceanId", oceanId); String hql = "SELECT DISTINCT(c) " + - "FROM CountryImpl c, TripImpl t LEFT JOIN t.activity as a " + + "FROM CountryImpl c, TripImpl t LEFT JOIN t.route as r LEFT JOIN r.activity as a " + "WHERE t.vessel.fleetCountry = c.id AND a.ocean.id = :oceanId"; // FIXME : trouvé pk cela est aussi long... // .addWhere("(SELECT count(*) FROM " + SetSpeciesFrequencyImpl.class.getSimpleName() + " s WHERE s." + SetSpeciesFrequency.PROPERTY_ACTIVITY + " = a.id) > 0") @@ -155,7 +155,7 @@ public class AbstractCountryTopiaDao<E extends Country> extends GeneratedCountry // .addParam("oceanId", oceanId); String hql = "SELECT DISTINCT(c) " + - "FROM CountryImpl c, TripImpl t LEFT JOIN t.activity as a " + + "FROM CountryImpl c, TripImpl t LEFT JOIN t.route as r LEFT JOIN r.activity as a " + "WHERE t.vessel.flagCountry = c.id AND a.ocean.id = :oceanId"; // FIXME : trouvé pk cela est aussi long... // .addWhere("(SELECT count(*) FROM " + SetSpeciesFrequencyImpl.class.getSimpleName() + " s WHERE s." + SetSpeciesFrequency.PROPERTY_ACTIVITY + " = a.id) >0") ===================================== t3-domain/src/main/java/fr/ird/t3/entities/reference/AbstractVesselSimpleTypeTopiaDao.java ===================================== --- a/t3-domain/src/main/java/fr/ird/t3/entities/reference/AbstractVesselSimpleTypeTopiaDao.java +++ b/t3-domain/src/main/java/fr/ird/t3/entities/reference/AbstractVesselSimpleTypeTopiaDao.java @@ -37,11 +37,11 @@ public class AbstractVesselSimpleTypeTopiaDao<E extends VesselSimpleType> extend /** * Obtains all vessel simple types used by all trips in the database. * - * @param sampleOnly if null no filter else filter on value + * @param samplesOnly if null no filter else filter on value * @return the set of used vessel simple types in trips in the database * @throws TopiaException if any problem while querying the database */ - public Set<E> findAllUsedInTrip(Boolean sampleOnly) throws TopiaException { + public Set<E> findAllUsedInTrip(Boolean samplesOnly) throws TopiaException { // TopiaQuery query = createQuery("vst") // .addFrom(Trip.class, "t") @@ -50,8 +50,8 @@ public class AbstractVesselSimpleTypeTopiaDao<E extends VesselSimpleType> extend // Vessel.PROPERTY_VESSEL_TYPE + "." + // VesselType.PROPERTY_VESSEL_SIMPLE_TYPE + " = vst.id"); - String sampleOnlyFilter = sampleOnly == null ? "" : (" AND t.sampleOnly = " + sampleOnly); - String hql = "SELECT DISTINCT(vst) FROM VesselSimpleTypeImpl vst, TripImpl t WHERE t.vessel.vesselType.vesselSimpleType = vst.id" + sampleOnlyFilter; + String samplesOnlyFilter = samplesOnly == null ? "" : (" AND t.samplesOnly = " + samplesOnly); + String hql = "SELECT DISTINCT(vst) FROM VesselSimpleTypeImpl vst, TripImpl t WHERE t.vessel.vesselType.vesselSimpleType = vst.id" + samplesOnlyFilter; return new HashSet<>(findAll(hql)); // return T3EntityHelper.querytoSet(hql, this); } ===================================== t3-domain/src/main/java/fr/ird/t3/services/DecoratorService.java ===================================== --- a/t3-domain/src/main/java/fr/ird/t3/services/DecoratorService.java +++ b/t3-domain/src/main/java/fr/ird/t3/services/DecoratorService.java @@ -25,6 +25,7 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import fr.ird.t3.entities.data.Activity; import fr.ird.t3.entities.data.CompleteTrip; +import fr.ird.t3.entities.data.Route; import fr.ird.t3.entities.data.Sample; import fr.ird.t3.entities.data.Trip; import fr.ird.t3.entities.data.Well; @@ -167,6 +168,9 @@ public class DecoratorService extends T3ServiceSupport implements T3ServiceSingl // trip decorator registerJXPathDecorator(locale, Trip.class, "${vesselLabel}$s - ${landingDate}$td/%2$tm/%2$tY"); + // route decorator + registerJXPathDecorator(locale, Route.class, "${trip.vesselLabel}$s - ${trip.landingDate}$td/%2$tm/%2$tY - ${date}$td/%3$tm/%3$tY"); + // trip (with topiaid) decorator registerJXPathDecorator(locale, Trip.class, WITH_ID, "${vesselLabel}$s - ${landingDate}$td/%2$tm/%2$tY [${topiaId}$s]"); ===================================== t3-domain/src/main/java/fr/ird/t3/services/migration/T3MigrationCallbackV2_2.java ===================================== --- /dev/null +++ b/t3-domain/src/main/java/fr/ird/t3/services/migration/T3MigrationCallbackV2_2.java @@ -0,0 +1,133 @@ +package fr.ird.t3.services.migration; + +/* + * #%L + * T3 :: Domain + * %% + * Copyright (C) 2010 - 2017 IRD, Code Lutin, Ultreia.io + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import com.google.auto.service.AutoService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.topia.migration.TopiaMigrationCallbackByClassNG; +import org.nuiton.topia.persistence.TopiaException; +import org.nuiton.topia.persistence.support.TopiaSqlQuery; +import org.nuiton.topia.persistence.support.TopiaSqlSupport; +import org.nuiton.util.DateUtil; +import org.nuiton.version.Versions; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; + +/** + * Created by tchemit on 18/02/2018. + * + * @author Tony Chemit - dev@tchemit.fr + */ +@AutoService(TopiaMigrationCallbackByClassNG.MigrationCallBackForVersion.class) +public class T3MigrationCallbackV2_2 extends T3MigrationCallbackSupport { + + private static final Log log = LogFactory.getLog(T3MigrationCallbackV2_2.class); + + public T3MigrationCallbackV2_2() { + super(Versions.valueOf("2.2")); + } + + @Override + protected void prepareMigrationScript(TopiaSqlSupport sqlSupport, List<String> queries, boolean showSql, boolean showProgression) throws TopiaException { + addScript("07", "add-Route-table", queries); + + + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); + + List<String> tripList = sqlSupport.findMultipleResult(new TopiaSqlQuery<String>() { + @Override + public PreparedStatement prepareQuery(Connection connection) throws SQLException { + return connection.prepareStatement("SELECT DISTINCT(a.trip) FROM activity a"); + } + + @Override + public String prepareResult(ResultSet set) throws SQLException { + return set.getString(1); + } + }); + + for (String tripId : tripList) { + + int i = tripId.indexOf('#'); + String routeIdPrefix = "fr.ird.t3.entities.data.Route#" + tripId.substring(i + 1, tripId.lastIndexOf('#') + 1); + + log.info("Route prefix: " + routeIdPrefix); + List<TripActivity> activityList = sqlSupport.findMultipleResult(new TopiaSqlQuery<TripActivity>() { + @Override + public PreparedStatement prepareQuery(Connection connection) throws SQLException { + PreparedStatement preparedStatement = connection.prepareStatement("SELECT a.topiaId, a.date FROM activity a WHERE a.trip = ?"); + preparedStatement.setString(1, tripId); + return preparedStatement; + } + + @Override + public TripActivity prepareResult(ResultSet set) throws SQLException { + return new TripActivity(set.getString(1), set.getDate(2)); + } + }); + + + Set<Date> days = new LinkedHashSet<>(); + int activityIndex = 0; + for (TripActivity activity : activityList) { + + String dayDateStr = df.format(activity.date); + String routeId = routeIdPrefix + dayDateStr.replaceAll("-", ""); + + if (days.add(activity.date)) { + + log.info(String.format("[%s] new Route: %s", tripId, routeId)); + // create new route + queries.add(String.format("INSERT INTO Route(topiaId, topiaVersion, topiaCreateDate, trip, trip_idx, date) VALUES('%s', 0, CURRENT_TIMESTAMP, '%s', %d, to_date('%s', 'YYY-MM-DD'));", routeId, tripId, days.size(), dayDateStr)); + } + queries.add(String.format("UPDATE Activity SET route = '%s', route_idx = %d , topiaVersion = topiaVersion + 1 WHERE topiaId = '%s';", routeId, (activityIndex++), activity.activity)); + } + + if (!activityList.isEmpty()) { + queries.add(String.format("UPDATE Trip SET effortComputed = false, topiaVersion = topiaVersion + 1 WHERE topiaId = '%s';", tripId)); + } + } + + addScript("08", "remove-Trip-fields", queries); + } + + private static class TripActivity { + + private final String activity; + private final Date date; + + private TripActivity(String activity, Date date) { + this.activity = activity; + this.date = DateUtil.getDay(date); + } + } + +} ===================================== t3-domain/src/main/resources/db/migration/V2_2_07_add-Route-table.sql ===================================== --- /dev/null +++ b/t3-domain/src/main/resources/db/migration/V2_2_07_add-Route-table.sql @@ -0,0 +1,29 @@ +--- +-- #%L +-- T3 :: Domain +-- %% +-- Copyright (C) 2010 - 2018 IRD, Code Lutin, Ultreia.io +-- %% +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU Affero General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU Affero General Public License +-- along with this program. If not, see <http://www.gnu.org/licenses/>. +-- #L% +--- +CREATE TABLE Route( topiaid VARCHAR(255) PRIMARY KEY NOT NULL, topiaversion BIGINT NOT NULL, topiacreatedate TIMESTAMP NOT NULL, trip VARCHAR(255) NOT NULL, trip_idx INTEGER NOT NULL, date DATE NOT NULL, computedFishingTimeN0 REAL, computedSearchTimeN0 REAL); +CREATE UNIQUE INDEX uk_route ON Route(trip, date); +ALTER TABLE Route ADD CONSTRAINT fk_route_trip FOREIGN KEY (trip) REFERENCES Trip(topiaid); +CREATE INDEX idx_route_trip ON Route(trip); + +ALTER TABLE Activity ADD COLUMN route VARCHAR(255); +ALTER TABLE Activity ADD COLUMN route_idx INTEGER; +ALTER TABLE Activity ADD CONSTRAINT fk_activity_route FOREIGN KEY (route) REFERENCES Route(topiaid); +CREATE INDEX idx_activity_route ON Activity(route); ===================================== t3-domain/src/main/resources/db/migration/V2_2_08_remove-Trip-fields.sql ===================================== --- /dev/null +++ b/t3-domain/src/main/resources/db/migration/V2_2_08_remove-Trip-fields.sql @@ -0,0 +1,28 @@ +--- +-- #%L +-- T3 :: Domain +-- %% +-- Copyright (C) 2010 - 2018 IRD, Code Lutin, Ultreia.io +-- %% +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU Affero General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU Affero General Public License +-- along with this program. If not, see <http://www.gnu.org/licenses/>. +-- #L% +--- + +ALTER TABLE Activity DROP COLUMN trip; +ALTER TABLE Activity DROP COLUMN trip_idx; +ALTER TABLE Activity DROP COLUMN date; +ALTER TABLE Trip DROP COLUMN computedfishingtimen0; +ALTER TABLE Trip DROP COLUMN computedsearchtimen0; +ALTER TABLE Trip DROP COLUMN computedtimeatsean0; +ALTER TABLE Activity ALTER COLUMN route_idx SET NOT NULL; \ No newline at end of file ===================================== t3-domain/src/main/xmi/t3-persistence.properties ===================================== --- a/t3-domain/src/main/xmi/t3-persistence.properties +++ b/t3-domain/src/main/xmi/t3-persistence.properties @@ -22,11 +22,17 @@ model.tagValue.notGenerateToString=true model.tagValue.generateOperatorForDAOHelper=true model.tagValue.constantPrefix=PROPERTY_ -model.tagValue.version=2.1 +model.tagValue.version=2.2 model.tagValue.indexForeignKeys=true -fr.ird.t3.entities.data.Trip.attribute.activity.stereotype=ordered -fr.ird.t3.entities.data.Trip.attribute.activity.tagvalue.orderBy=date +fr.ird.t3.entities.data.Trip.attribute.route.stereotype=ordered +fr.ird.t3.entities.data.Route.attribute.activity.stereotype=ordered + +fr.ird.t3.entities.data.Trip.attribute.route.tagvalue.orderBy=date +fr.ird.t3.entities.data.Route.attribute.activity.tagvalue.orderBy=date + +fr.ird.t3.entities.data.Route.attribute.date.tagvalue.hibernateAttributeType.java.util.Date=date +fr.ird.t3.entities.data.Activity.attribute.time.tagvalue.hibernateAttributeType.java.util.Date=time fr.ird.t3.entities.data.Activity.attribute.comment.tagvalue.sqlType=text fr.ird.t3.entities.data.LocalMarketBatch.attribute.origin.tagvalue.sqlType=text ===================================== t3-domain/src/main/xmi/t3-persistence.zargo ===================================== Binary files a/t3-domain/src/main/xmi/t3-persistence.zargo and b/t3-domain/src/main/xmi/t3-persistence.zargo differ ===================================== t3-domain/src/test/java/fr/ird/t3/entities/T3PersistenceFixtures.java ===================================== --- a/t3-domain/src/test/java/fr/ird/t3/entities/T3PersistenceFixtures.java +++ b/t3-domain/src/test/java/fr/ird/t3/entities/T3PersistenceFixtures.java @@ -56,8 +56,8 @@ public class T3PersistenceFixtures { return tx.getTripDao().create(Trip.PROPERTY_CODE, code, Trip.PROPERTY_LANDING_DATE, date); } - public static Trip newTrip(T3TopiaPersistenceContext tx, int code, Date date, boolean sampleOnly) { - return tx.getTripDao().create(Trip.PROPERTY_CODE, code, Trip.PROPERTY_LANDING_DATE, date, Trip.PROPERTY_SAMPLES_ONLY, sampleOnly); + public static Trip newTrip(T3TopiaPersistenceContext tx, int code, Date date, boolean samplesOnly) { + return tx.getTripDao().create(Trip.PROPERTY_CODE, code, Trip.PROPERTY_LANDING_DATE, date, Trip.PROPERTY_SAMPLES_ONLY, samplesOnly); } public static Harbour newHarbour(T3TopiaPersistenceContext tx, int code) { ===================================== t3-input-avdthv33/src/main/java/fr/ird/t3/io/input/avdth/v33/T3AccessEntityMetaProviderAvdth33.java ===================================== --- a/t3-input-avdthv33/src/main/java/fr/ird/t3/io/input/avdth/v33/T3AccessEntityMetaProviderAvdth33.java +++ b/t3-input-avdthv33/src/main/java/fr/ird/t3/io/input/avdth/v33/T3AccessEntityMetaProviderAvdth33.java @@ -55,11 +55,12 @@ import fr.ird.t3.io.input.access.T3AccessEntityMeta; import fr.ird.t3.io.input.access.T3AccessEntityMetaProvider; import fr.ird.t3.io.input.access.T3AccessReferentielEntityMeta; import fr.ird.t3.io.input.access.type.IntToBoolean; -import java.util.Date; -import java.util.Set; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import java.util.Date; +import java.util.Set; + /** * Provider of {@link T3AccessEntityMeta}. * @@ -86,9 +87,7 @@ public class T3AccessEntityMetaProviderAvdth33 implements T3AccessEntityMetaProv Activity.PROPERTY_ACTIVITY_FISHING_CONTEXT, ActivityFishingContext.class, Activity.PROPERTY_ELEMENTARY_CATCH, ElementaryCatch.class }, - new Object[]{ - Activity.PROPERTY_TRIP, Trip.class - }, + new Object[]{ /* Nothing to do any longer */}, Activity.PROPERTY_DATE, Date.class, "D_ACT", Activity.PROPERTY_NUMBER, Integer.class, "N_ACT", Activity.PROPERTY_OCEAN, Ocean.class, "C_OCEA", ===================================== t3-input-avdthv33/src/test/java/fr/ird/t3/actions/io/input/AnalyzeInputSourceActionIT.java ===================================== --- a/t3-input-avdthv33/src/test/java/fr/ird/t3/actions/io/input/AnalyzeInputSourceActionIT.java +++ b/t3-input-avdthv33/src/test/java/fr/ird/t3/actions/io/input/AnalyzeInputSourceActionIT.java @@ -163,7 +163,7 @@ public class AnalyzeInputSourceActionIT implements T3AVDTHV33Test { int nbUnsafe, int nbSafeWithoutwell, int nbUnsafeWithoutWell, - boolean sampleOnly, + boolean samplesOnly, boolean canCreateVessel, boolean createVirtualVessel) throws Exception { @@ -172,7 +172,7 @@ public class AnalyzeInputSourceActionIT implements T3AVDTHV33Test { T3ServiceFactory serviceFactory = serviceContext.getServiceFactory(); AnalyzeInputSourceConfiguration actionConfiguration = AnalyzeInputSourceConfiguration.newConfiguration( - inputProvider, target, useWells, sampleOnly, canCreateVessel, createVirtualVessel + inputProvider, target, useWells, samplesOnly, canCreateVessel, createVirtualVessel ); T3ActionContext<AnalyzeInputSourceConfiguration> context = serviceFactory.newT3ActionContext(actionConfiguration, serviceContext); ===================================== t3-input-avdthv33/src/test/java/fr/ird/t3/actions/io/input/ImportInputSourceActionIT.java ===================================== --- a/t3-input-avdthv33/src/test/java/fr/ird/t3/actions/io/input/ImportInputSourceActionIT.java +++ b/t3-input-avdthv33/src/test/java/fr/ird/t3/actions/io/input/ImportInputSourceActionIT.java @@ -115,14 +115,14 @@ public class ImportInputSourceActionIT implements T3AVDTHV33Test { } public void testExecute(int nbSafe, int nbUnsafe, - boolean sampleOnly, + boolean samplesOnly, boolean canCreateVessel, boolean createVirtualVessel) throws Exception { if (msConfig.doTest(serviceContext.getTestName())) { AnalyzeInputSourceConfiguration analyzeActionConfiguration = AnalyzeInputSourceConfiguration.newConfiguration( - inputProvider, target, true, sampleOnly, canCreateVessel, createVirtualVessel + inputProvider, target, true, samplesOnly, canCreateVessel, createVirtualVessel ); T3ServiceFactory serviceFactory = serviceContext.getServiceFactory(); ===================================== t3-input-avdthv35/src/main/java/fr/ird/t3/io/input/avdth/v35/T3AccessEntityMetaProviderAvdth35.java ===================================== --- a/t3-input-avdthv35/src/main/java/fr/ird/t3/io/input/avdth/v35/T3AccessEntityMetaProviderAvdth35.java +++ b/t3-input-avdthv35/src/main/java/fr/ird/t3/io/input/avdth/v35/T3AccessEntityMetaProviderAvdth35.java @@ -34,9 +34,9 @@ import fr.ird.t3.entities.data.LocalMarketSampleSpeciesFrequency; import fr.ird.t3.entities.data.LocalMarketSampleWell; import fr.ird.t3.entities.data.LocalMarketSurvey; import fr.ird.t3.entities.data.Sample; +import fr.ird.t3.entities.data.SampleSet; import fr.ird.t3.entities.data.SampleSpecies; import fr.ird.t3.entities.data.SampleSpeciesFrequency; -import fr.ird.t3.entities.data.SampleSet; import fr.ird.t3.entities.data.Trip; import fr.ird.t3.entities.data.Well; import fr.ird.t3.entities.data.WellPlan; @@ -98,9 +98,7 @@ public class T3AccessEntityMetaProviderAvdth35 implements T3AccessEntityMetaProv Activity.PROPERTY_ACTIVITY_FISHING_CONTEXT, ActivityFishingContext.class, Activity.PROPERTY_ELEMENTARY_CATCH, ElementaryCatch.class }, - new Object[]{ - Activity.PROPERTY_TRIP, Trip.class - }, + new Object[]{/* Nothing to do any longer */}, Activity.PROPERTY_DATE, Date.class, "D_ACT", Activity.PROPERTY_NUMBER, Integer.class, "N_ACT", Activity.PROPERTY_OCEAN, Ocean.class, "C_OCEA", ===================================== t3-input-avdthv35/src/test/java/fr/ird/t3/actions/io/input/AnalyzeInputSourceActionITSupport.java ===================================== --- a/t3-input-avdthv35/src/test/java/fr/ird/t3/actions/io/input/AnalyzeInputSourceActionITSupport.java +++ b/t3-input-avdthv35/src/test/java/fr/ird/t3/actions/io/input/AnalyzeInputSourceActionITSupport.java @@ -165,7 +165,7 @@ public class AnalyzeInputSourceActionITSupport { int nbUnsafe, int nbSafeWithoutwell, int nbUnsafeWithoutWell, - boolean sampleOnly, + boolean samplesOnly, boolean canCreateVessel, boolean createVirtualVessel) throws Exception { @@ -174,7 +174,7 @@ public class AnalyzeInputSourceActionITSupport { T3ServiceFactory serviceFactory = serviceContext.getServiceFactory(); AnalyzeInputSourceConfiguration actionConfiguration = AnalyzeInputSourceConfiguration.newConfiguration( - inputProvider, target, true, sampleOnly, canCreateVessel, createVirtualVessel + inputProvider, target, true, samplesOnly, canCreateVessel, createVirtualVessel ); T3ActionContext<AnalyzeInputSourceConfiguration> context = serviceFactory.newT3ActionContext(actionConfiguration, serviceContext); ===================================== t3-input-avdthv35/src/test/java/fr/ird/t3/actions/io/input/ImportInputSourceActionITSupport.java ===================================== --- a/t3-input-avdthv35/src/test/java/fr/ird/t3/actions/io/input/ImportInputSourceActionITSupport.java +++ b/t3-input-avdthv35/src/test/java/fr/ird/t3/actions/io/input/ImportInputSourceActionITSupport.java @@ -116,14 +116,14 @@ public abstract class ImportInputSourceActionITSupport { } public void testExecute(int nbSafe, int nbUnsafe, - boolean sampleOnly, + boolean samplesOnly, boolean canCreateVessel, boolean createVirtualVessel) throws Exception { if (msConfig.doTest(serviceContext.getTestName())) { AnalyzeInputSourceConfiguration analyzeActionConfiguration = AnalyzeInputSourceConfiguration.newConfiguration( - inputProvider, target, true, sampleOnly, canCreateVessel, createVirtualVessel + inputProvider, target, true, samplesOnly, canCreateVessel, createVirtualVessel ); T3ServiceFactory serviceFactory = serviceContext.getServiceFactory(); ===================================== t3-input-avdthv36/src/main/java/fr/ird/t3/io/input/avdth/v36/T3AccessEntityMetaProviderAvdth36.java ===================================== --- a/t3-input-avdthv36/src/main/java/fr/ird/t3/io/input/avdth/v36/T3AccessEntityMetaProviderAvdth36.java +++ b/t3-input-avdthv36/src/main/java/fr/ird/t3/io/input/avdth/v36/T3AccessEntityMetaProviderAvdth36.java @@ -34,9 +34,9 @@ import fr.ird.t3.entities.data.LocalMarketSampleSpeciesFrequency; import fr.ird.t3.entities.data.LocalMarketSampleWell; import fr.ird.t3.entities.data.LocalMarketSurvey; import fr.ird.t3.entities.data.Sample; +import fr.ird.t3.entities.data.SampleSet; import fr.ird.t3.entities.data.SampleSpecies; import fr.ird.t3.entities.data.SampleSpeciesFrequency; -import fr.ird.t3.entities.data.SampleSet; import fr.ird.t3.entities.data.Trip; import fr.ird.t3.entities.data.Well; import fr.ird.t3.entities.data.WellPlan; @@ -100,9 +100,7 @@ public class T3AccessEntityMetaProviderAvdth36 implements T3AccessEntityMetaProv Activity.PROPERTY_ACTIVITY_FISHING_CONTEXT, ActivityFishingContext.class, Activity.PROPERTY_ELEMENTARY_CATCH, ElementaryCatch.class }, - new Object[]{ - Activity.PROPERTY_TRIP, Trip.class - }, + new Object[]{ /* Nothing to do any longer */}, Activity.PROPERTY_DATE, Date.class, "D_ACT", Activity.PROPERTY_NUMBER, Integer.class, "N_ACT", Activity.PROPERTY_OCEAN, Ocean.class, "C_OCEA", ===================================== t3-input-avdthv36/src/test/java/fr/ird/t3/actions/io/input/AnalyzeInputSourceActionITSupport.java ===================================== --- a/t3-input-avdthv36/src/test/java/fr/ird/t3/actions/io/input/AnalyzeInputSourceActionITSupport.java +++ b/t3-input-avdthv36/src/test/java/fr/ird/t3/actions/io/input/AnalyzeInputSourceActionITSupport.java @@ -168,7 +168,7 @@ public class AnalyzeInputSourceActionITSupport { int nbUnsafe, int nbSafeWithoutwell, int nbUnsafeWithoutWell, - boolean sampleOnly, + boolean samplesOnly, boolean canCreateVessel, boolean createVirtualVessel) throws Exception { @@ -177,7 +177,7 @@ public class AnalyzeInputSourceActionITSupport { T3ServiceFactory serviceFactory = serviceContext.getServiceFactory(); AnalyzeInputSourceConfiguration actionConfiguration = AnalyzeInputSourceConfiguration.newConfiguration( - inputProvider, target, useWells, sampleOnly, canCreateVessel, createVirtualVessel + inputProvider, target, useWells, samplesOnly, canCreateVessel, createVirtualVessel ); T3ActionContext<AnalyzeInputSourceConfiguration> context = serviceFactory.newT3ActionContext(actionConfiguration, serviceContext); ===================================== t3-input-avdthv36/src/test/java/fr/ird/t3/actions/io/input/ImportInputSourceActionITSupport.java ===================================== --- a/t3-input-avdthv36/src/test/java/fr/ird/t3/actions/io/input/ImportInputSourceActionITSupport.java +++ b/t3-input-avdthv36/src/test/java/fr/ird/t3/actions/io/input/ImportInputSourceActionITSupport.java @@ -116,14 +116,14 @@ public abstract class ImportInputSourceActionITSupport { } public void testExecute(int nbSafe, int nbUnsafe, - boolean sampleOnly, + boolean samplesOnly, boolean canCreateVessel, boolean createVirtualVessel) throws Exception { if (msConfig.doTest(serviceContext.getTestName())) { AnalyzeInputSourceConfiguration analyzeActionConfiguration = AnalyzeInputSourceConfiguration.newConfiguration( - inputProvider, target, true, sampleOnly, canCreateVessel, createVirtualVessel + inputProvider, target, true, samplesOnly, canCreateVessel, createVirtualVessel ); T3ServiceFactory serviceFactory = serviceContext.getServiceFactory(); View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/ef7c73b147b73da7e7c2888852019d1bf... --- View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/ef7c73b147b73da7e7c2888852019d1bf... You're receiving this email because of your account on gitlab.com.
participants (1)
-
Tony CHEMIT