This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository tutti. See http://git.codelutin.com/tutti.git commit 8200d6a273a0d29c507cdabe9bfa49aca739724c Author: Tony CHEMIT <chemit@codelutin.com> Date: Sat Jan 9 10:43:38 2016 +0100 Suppression de Numbers (utilisation de NumberUtil) Creation d'objets dans observe-entities pour representer les points d'une marée Suppression du lien services-model → entities --- observe-entities/pom.xml | 8 +- .../java/fr/ird/observe/entities/Entities.java | 6 +- .../java/fr/ird/observe/entities/TripMapPoint.java | 59 +++++ .../constants/TripMapPointPersistType.java | 58 +++++ .../entities/longline/ActivityLonglineImpl.java | 12 - .../entities/longline/TripLonglineImpl.java | 112 --------- .../entities/longline/TripLonglineTopiaDao.java | 158 ++++++------- .../referentiel/LengthWeightParameters.java | 6 +- .../referentiel/LengthWeightParemeterHelper.java | 6 +- .../observe/entities/referentiel/SpeciesImpl.java | 12 +- .../observe/entities/referentiel/VesselImpl.java | 10 +- .../observe/entities/seine/ActivitySeineImpl.java | 8 +- .../observe/entities/seine/NonTargetCatchImpl.java | 8 +- .../entities/seine/NonTargetLengthImpl.java | 8 +- .../fr/ird/observe/entities/seine/RouteImpl.java | 255 +-------------------- .../ird/observe/entities/seine/SetSeineImpl.java | 4 +- .../observe/entities/seine/TargetCatchImpl.java | 4 +- .../observe/entities/seine/TargetLengthImpl.java | 10 +- .../ird/observe/entities/seine/TripSeineImpl.java | 135 ----------- .../observe/entities/seine/TripSeineTopiaDao.java | 114 ++++----- .../test/java/fr/ird/observe/util/NumbersTest.java | 86 ------- .../fr/ird/observe/services/dto/TripMapDtos.java | 15 -- .../longline/SetLonglineGlobalCompositionDto.java | 3 - .../seine/FloatingObjectTransmittingBuoyDto.java | 7 +- .../services/dto/seine/TargetLengthDto.java | 9 +- .../src/main/java/fr/ird/observe/util/Numbers.java | 87 ------- .../observe/services/entity/TripMapDtoFactory.java | 40 ++++ .../service/longline/TripLonglineServiceTopia.java | 8 +- .../service/seine/TripSeineServiceTopia.java | 8 +- pom.xml | 8 +- 30 files changed, 354 insertions(+), 910 deletions(-) diff --git a/observe-entities/pom.xml b/observe-entities/pom.xml index 597cc7d..e7f2c13 100644 --- a/observe-entities/pom.xml +++ b/observe-entities/pom.xml @@ -38,19 +38,13 @@ <dependencies> - <!-- sibling dependencies --> + <!-- sibling dependenNcies --> <dependency> <groupId>${project.groupId}</groupId> <artifactId>observe-test-data</artifactId> <version>${project.version}</version> </dependency> - <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>observe-services-model</artifactId> - <version>${project.version}</version> - </dependency> - <!-- Nuiton --> <dependency> <groupId>org.nuiton</groupId> diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/Entities.java b/observe-entities/src/main/java/fr/ird/observe/entities/Entities.java index c4df77e..2ed9d46 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/Entities.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/Entities.java @@ -29,11 +29,11 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import fr.ird.observe.ObserveEntityEnum; -import fr.ird.observe.util.Numbers; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.topia.persistence.TopiaEntities; +import org.nuiton.util.NumberUtil; import java.util.Arrays; import java.util.Collection; @@ -388,11 +388,11 @@ public class Entities { } public static void printDebugInformations(String propertyName, Object instance, Integer value) { - printDebugInformations0(propertyName, instance, Numbers.IS_INTEGER_CHANGED_TO_ZERO_OR_NULL, value); + printDebugInformations0(propertyName, instance, NumberUtil.NULL_OR_ZERO_INTEGER, value); } public static void printDebugInformations(String propertyName, Object instance, Float value) { - printDebugInformations0(propertyName, instance, Numbers.IS_FLOAT_CHANGED_TO_ZERO_OR_NULL, value); + printDebugInformations0(propertyName, instance, NumberUtil.NULL_OR_ZERO_FLOAT_THREE_DIGITS, value); } private static <O> void printDebugInformations0(String propertyName, Object instance, Predicate<O> nullPredicate, O value) { diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/TripMapPoint.java b/observe-entities/src/main/java/fr/ird/observe/entities/TripMapPoint.java new file mode 100644 index 0000000..7d13fb3 --- /dev/null +++ b/observe-entities/src/main/java/fr/ird/observe/entities/TripMapPoint.java @@ -0,0 +1,59 @@ +package fr.ird.observe.entities; + +import fr.ird.observe.entities.constants.TripMapPointPersistType; + +import java.io.Serializable; +import java.util.Date; + +public class TripMapPoint implements Serializable { + + public static final String PROPERTY_TIME = "time"; + + public static final String PROPERTY_LATITUDE = "latitude"; + + public static final String PROPERTY_LONGITUDE = "longitude"; + + public static final String PROPERTY_TYPE = "type"; + + private static final long serialVersionUID = 1L; + + protected Date time; + + protected float latitude; + + protected float longitude; + + protected TripMapPointPersistType type; + + public Date getTime() { + return time; + } + + public void setTime(Date time) { + this.time = time; + } + + public float getLatitude() { + return latitude; + } + + public void setLatitude(float latitude) { + this.latitude = latitude; + } + + public float getLongitude() { + return longitude; + } + + public void setLongitude(float longitude) { + this.longitude = longitude; + } + + public TripMapPointPersistType getType() { + return type; + } + + public void setType(TripMapPointPersistType type) { + this.type = type; + } +} diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/constants/TripMapPointPersistType.java b/observe-entities/src/main/java/fr/ird/observe/entities/constants/TripMapPointPersistType.java new file mode 100644 index 0000000..331d0e5 --- /dev/null +++ b/observe-entities/src/main/java/fr/ird/observe/entities/constants/TripMapPointPersistType.java @@ -0,0 +1,58 @@ +package fr.ird.observe.entities.constants; + +/* + * #%L + * ObServe :: Entities + * %% + * Copyright (C) 2008 - 2015 IRD, Codelutin, Tony Chemit + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import static org.nuiton.i18n.I18n.n; +import static org.nuiton.i18n.I18n.t; + +/** + * @author Sylvain Bavencoff - bavencoff@codelutin.com + */ +public enum TripMapPointPersistType { + + SEINE_DEPARTURE_HARBOUR(n("observe.map.seine.harbour.departure")), + SEINE_LANDING_HARBOUR(n("observe.map.seine.harbour.landing")), + SEINE_ACTIVITY(n("observe.map.seine.activity")), + SEINE_ACTIVITY_IN_HARBOUR(n("observe.map.seine.activity.inHarbour")), + SEINE_ACTIVITY_WITH_FREE_SCHOOL_TYPE(n("observe.map.seine.activity.schoolType.free")), + SEINE_ACTIVITY_WITH_OBJECT_SCHOOL_TYPE(n("observe.map.seine.activity.schoolType.object")), + + LONGLINE_IN_HARBOUR(n("observe.map.longLine.seine.harbour")), + LONGLINE_ACTIVITY(n("observe.map.longLine.activity")), + LONGLINE_ACTIVITY_WITH_SETTING_START(n("observe.map.longLine.activity.setting.start")), + LONGLINE_ACTIVITY_WITH_SETTING_END(n("observe.map.longLine.activity.setting.end")), + LONGLINE_ACTIVITY_WITH_HAULING_START(n("observe.map.longLine.activity.hauling.start")), + LONGLINE_ACTIVITY_WITH_HAULING_END(n("observe.map.longLine.activity.hauling.end")), + LONGLINE_ACTIVITY_WITH_INTERACTION(n("observe.map.longLine.activity.interaction")), + LONGLINE_ACTIVITY_WITH_STATION(n("observe.map.longLine.activity.station")); + + String label; + + TripMapPointPersistType(String label) { + this.label = label; + } + + public String getLabel() { + return t(label); + } +} diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/longline/ActivityLonglineImpl.java b/observe-entities/src/main/java/fr/ird/observe/entities/longline/ActivityLonglineImpl.java index 247b8b0..8666fcf 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/longline/ActivityLonglineImpl.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/longline/ActivityLonglineImpl.java @@ -46,18 +46,6 @@ public class ActivityLonglineImpl extends ActivityLonglineAbstract { */ protected Integer quadrant; -// @Override -// public OpenableEntity getOpenChild() { -// // sur une activity, pas d'enfant OpenableEntity -// return null; -// } -// -// @Override -// public List getOpenableChilds() { -// // sur une activity, pas d'enfant OpenableEntity -// return null; -// } - @Override public Date getDate() { return timeStamp == null ? null : DateUtil.getDay(timeStamp); diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/longline/TripLonglineImpl.java b/observe-entities/src/main/java/fr/ird/observe/entities/longline/TripLonglineImpl.java index 4edf361..74fc16b 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/longline/TripLonglineImpl.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/longline/TripLonglineImpl.java @@ -47,116 +47,4 @@ public class TripLonglineImpl extends TripLonglineAbstract { return false; } -// @Override -// public ActivityLongline getOpenChild() { -// return OpenableEntities.getOpenEntity(activityLongline); -// } -// -// @Override -// public List<ActivityLongline> getOpenableChilds() { -// return activityLongline; -// } -// -// @Override -// public ActivityLongline getOpenActivity() { -// return getOpenChild(); -// } - -// @Override -// public ActivityLongline getPreviousActivity(ActivityLongline activity) { -// -// if (isActivityLonglineEmpty()) { -// -// // aucune route definie sur la maree -// return null; -// } -// int index = this.activityLongline.indexOf(activity); -// if (index < 1) { -// -// // la route donnee n'est pas definie sur cette maree ou est la -// // premiere route -// return null; -// } -// -// // on retourne la route precedente -// return this.activityLongline.get(index - 1); -// -// } -// -// @Override -// public ActivityLongline getNextActivity(ActivityLongline activity) { -// -// if (isActivityLonglineEmpty()) { -// -// // aucune route definie sur la maree -// return null; -// } -// int index = this.activityLongline.indexOf(activity); -// if (index == -1 || index + 1 >= sizeActivityLongline()) { -// -// // la route n'est pas definie sur cette maree, ou c'est la -// // dernière de la maree -// return null; -// } -// -// // on retourne la route suivante -// return this.activityLongline.get(index + 1); -// -// } -// -// @Override -// public ActivityLongline getLastActivity() { -// -// if (isActivityLonglineEmpty()) { -// -// // aucune route definie sur la maree -// return null; -// } -// -// // on retourne la dernière route de la maree -// return getActivityLongline().get(sizeActivityLongline() - 1); -// -// } - -// @Override -// public Date getEndDateTheorique() { -// Date d; -// if (isActivityLonglineEmpty()) { -// -// // pas de route, donc la date de fin est la date de debut -// d = getStartDate(); -// } else { -// List<ActivityLongline> routes = new ArrayList<ActivityLongline>(getActivityLongline()); -// -// // on trie la liste par jour d'observation -// ActivityLonglines.sort(routes); -// -// // on recupere la derniere route de la maree -// ActivityLongline route = routes.get(routes.size() - 1); -// -// // son jour d'observation est la date de fin de la maree -// d = route.getTimeStamp(); -// } -// -// // on conserve la date epuree (pas de notion de temps dans la date) -// d = DateUtil.getEndOfDay(d); -// return d; -// } - -// @Override -// public void updateDateFin() { -// -// // la date de fin theorique (date de la dernière route de la marée) -// Date endDate = getEndDateTheorique(); -// -// // la date de fin actuelle -// Date realDateFin = getEndDate(); -// -// if (realDateFin == null || endDate.after(realDateFin)) { -// -// // on utilise la nouvelle date theorique car l'ancienne n'existe pas -// // ou est antérieure à la date de fin théoriquue -// setEndDate(endDate); -// } -// } } diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/longline/TripLonglineTopiaDao.java b/observe-entities/src/main/java/fr/ird/observe/entities/longline/TripLonglineTopiaDao.java index b7f25b6..9b0ab9c 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/longline/TripLonglineTopiaDao.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/longline/TripLonglineTopiaDao.java @@ -23,14 +23,14 @@ package fr.ird.observe.entities.longline; */ import com.google.common.collect.Lists; +import fr.ird.observe.entities.TripMapPoint; +import fr.ird.observe.entities.constants.TripMapPointPersistType; import fr.ird.observe.entities.referentiel.Harbour; import fr.ird.observe.entities.referentiel.I18nReferenceEntities; import fr.ird.observe.entities.referentiel.Person; import fr.ird.observe.entities.referentiel.PersonImpl; import fr.ird.observe.entities.referentiel.Vessel; import fr.ird.observe.entities.referentiel.VesselImpl; -import fr.ird.observe.services.dto.TripMapPointDto; -import fr.ird.observe.services.dto.constants.TripMapPointType; import org.nuiton.topia.persistence.support.TopiaSqlQuery; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import org.nuiton.util.DateUtil; @@ -78,72 +78,72 @@ public class TripLonglineTopiaDao extends AbstractTripLonglineTopiaDao<TripLongl } - public LinkedHashSet<TripMapPointDto> extractTripMapActivityPoints(String tripId) { + public LinkedHashSet<TripMapPoint> extractTripMapActivityPoints(String tripId) { TripLongline tripLongline = forTopiaIdEquals(tripId).findUnique(); - LinkedHashSet<TripMapPointDto> tripMapPoints = new LinkedHashSet<>(); + LinkedHashSet<TripMapPoint> tripMapPoints = new LinkedHashSet<>(); // add departure harbours Harbour departureHarbour = tripLongline.getDepartureHarbour(); if (departureHarbour != null - && departureHarbour.getLatitude() != null - && departureHarbour.getLongitude() != null) { - TripMapPointDto departurePoint = new TripMapPointDto(); + && departureHarbour.getLatitude() != null + && departureHarbour.getLongitude() != null) { + TripMapPoint departurePoint = new TripMapPoint(); departurePoint.setTime(tripLongline.getStartDate()); departurePoint.setLatitude(departureHarbour.getLatitude()); departurePoint.setLongitude(departureHarbour.getLongitude()); - departurePoint.setType(TripMapPointType.LONGLINE_IN_HARBOUR); + departurePoint.setType(TripMapPointPersistType.LONGLINE_IN_HARBOUR); tripMapPoints.add(departurePoint); } // Add Activities TripMapActivityPointQuery tripMapActivityPointQuery = new TripMapActivityPointQuery(tripId); - List<List<TripMapPointDto>> results = topiaSqlSupport.findMultipleResult(tripMapActivityPointQuery); - for (List<TripMapPointDto> result : results) { + List<List<TripMapPoint>> results = topiaSqlSupport.findMultipleResult(tripMapActivityPointQuery); + for (List<TripMapPoint> result : results) { tripMapPoints.addAll(result); } // add landing harbours Harbour landingHarbour = tripLongline.getLandingHarbour(); if (landingHarbour != null - && landingHarbour.getLatitude() != null - && landingHarbour.getLongitude() != null) { - TripMapPointDto landingPoint = new TripMapPointDto(); + && landingHarbour.getLatitude() != null + && landingHarbour.getLongitude() != null) { + TripMapPoint landingPoint = new TripMapPoint(); landingPoint.setTime(tripLongline.getEndDate()); landingPoint.setLatitude(landingHarbour.getLatitude()); landingPoint.setLongitude(landingHarbour.getLongitude()); - landingPoint.setType(TripMapPointType.LONGLINE_IN_HARBOUR); + landingPoint.setType(TripMapPointPersistType.LONGLINE_IN_HARBOUR); tripMapPoints.add(landingPoint); } return tripMapPoints; } - private static class TripMapActivityPointQuery extends TopiaSqlQuery<List<TripMapPointDto>> { + private static class TripMapActivityPointQuery extends TopiaSqlQuery<List<TripMapPoint>> { private static String SQL = "SELECT" + - " a.timestamp, " + - " a.latitude," + - " a.longitude," + - " a.vesselActivity," + - " s.settingStartTimestamp," + - " s.settingStartLatitude," + - " s.settingStartLongitude," + - " s.settingEndTimestamp," + - " s.settingEndLatitude," + - " s.settingEndLongitude," + - " s.haulingStartTimestamp," + - " s.haulingStartLatitude," + - " s.haulingStartLongitude," + - " s.haulingEndTimestamp," + - " s.haulingEndLatitude," + - " s.haulingEndLongitude" + - " FROM observe_longLine.activity a" + - " LEFT OUTER JOIN observe_longLine.set s" + - " ON s.topiaId = a.set" + - " WHERE a.trip = ?" + - " ORDER BY a.timestamp"; + " a.timestamp, " + + " a.latitude," + + " a.longitude," + + " a.vesselActivity," + + " s.settingStartTimestamp," + + " s.settingStartLatitude," + + " s.settingStartLongitude," + + " s.settingEndTimestamp," + + " s.settingEndLatitude," + + " s.settingEndLongitude," + + " s.haulingStartTimestamp," + + " s.haulingStartLatitude," + + " s.haulingStartLongitude," + + " s.haulingEndTimestamp," + + " s.haulingEndLatitude," + + " s.haulingEndLongitude" + + " FROM observe_longLine.activity a" + + " LEFT OUTER JOIN observe_longLine.set s" + + " ON s.topiaId = a.set" + + " WHERE a.trip = ?" + + " ORDER BY a.timestamp"; protected String tripId; @@ -159,27 +159,27 @@ public class TripLonglineTopiaDao extends AbstractTripLonglineTopiaDao<TripLongl } @Override - public List<TripMapPointDto> prepareResult(ResultSet resultSet) throws SQLException { + public List<TripMapPoint> prepareResult(ResultSet resultSet) throws SQLException { - List<TripMapPointDto> result = Lists.newLinkedList(); + List<TripMapPoint> result = Lists.newLinkedList(); if (resultSet.getString(5) == null) { // activity - TripMapPointDto activity = new TripMapPointDto(); + TripMapPoint activity = new TripMapPoint(); activity.setTime(resultSet.getDate(1)); activity.setLatitude(resultSet.getFloat(2)); activity.setLongitude(resultSet.getFloat(3)); String vesselActivityId = resultSet.getString(4); if (vesselActivityId == null) { - activity.setType(TripMapPointType.LONGLINE_ACTIVITY); + activity.setType(TripMapPointPersistType.LONGLINE_ACTIVITY); } else if (ACTIVITY_INTERACTION_ID.equals(vesselActivityId)) { - activity.setType(TripMapPointType.LONGLINE_ACTIVITY_WITH_INTERACTION); + activity.setType(TripMapPointPersistType.LONGLINE_ACTIVITY_WITH_INTERACTION); } else if (ACTIVITY_STATION_ID.equals(vesselActivityId)) { - activity.setType(TripMapPointType.LONGLINE_ACTIVITY_WITH_STATION); + activity.setType(TripMapPointPersistType.LONGLINE_ACTIVITY_WITH_STATION); } else { - activity.setType(TripMapPointType.LONGLINE_ACTIVITY); + activity.setType(TripMapPointPersistType.LONGLINE_ACTIVITY); } result.add(activity); @@ -187,41 +187,41 @@ public class TripLonglineTopiaDao extends AbstractTripLonglineTopiaDao<TripLongl // settingStart if (resultSet.getString(5) != null) { - TripMapPointDto settingStart = new TripMapPointDto(); + TripMapPoint settingStart = new TripMapPoint(); settingStart.setTime(resultSet.getDate(5)); settingStart.setLatitude(resultSet.getFloat(6)); settingStart.setLongitude(resultSet.getFloat(7)); - settingStart.setType(TripMapPointType.LONGLINE_ACTIVITY_WITH_SETTING_START); + settingStart.setType(TripMapPointPersistType.LONGLINE_ACTIVITY_WITH_SETTING_START); result.add(settingStart); } // settingEnd if (resultSet.getString(8) != null) { - TripMapPointDto settingEnd = new TripMapPointDto(); + TripMapPoint settingEnd = new TripMapPoint(); settingEnd.setTime(resultSet.getDate(8)); settingEnd.setLatitude(resultSet.getFloat(9)); settingEnd.setLongitude(resultSet.getFloat(10)); - settingEnd.setType(TripMapPointType.LONGLINE_ACTIVITY_WITH_SETTING_END); + settingEnd.setType(TripMapPointPersistType.LONGLINE_ACTIVITY_WITH_SETTING_END); result.add(settingEnd); } // haulingStart if (resultSet.getString(11) != null) { - TripMapPointDto haulingStart = new TripMapPointDto(); + TripMapPoint haulingStart = new TripMapPoint(); haulingStart.setTime(resultSet.getDate(11)); haulingStart.setLatitude(resultSet.getFloat(12)); haulingStart.setLongitude(resultSet.getFloat(13)); - haulingStart.setType(TripMapPointType.LONGLINE_ACTIVITY_WITH_HAULING_START); + haulingStart.setType(TripMapPointPersistType.LONGLINE_ACTIVITY_WITH_HAULING_START); result.add(haulingStart); } // haulingEnd if (resultSet.getString(14) != null) { - TripMapPointDto haulingEnd = new TripMapPointDto(); + TripMapPoint haulingEnd = new TripMapPoint(); haulingEnd.setTime(resultSet.getDate(14)); haulingEnd.setLatitude(resultSet.getFloat(15)); haulingEnd.setLongitude(resultSet.getFloat(16)); - haulingEnd.setType(TripMapPointType.LONGLINE_ACTIVITY_WITH_HAULING_END); + haulingEnd.setType(TripMapPointPersistType.LONGLINE_ACTIVITY_WITH_HAULING_END); result.add(haulingEnd); } @@ -247,19 +247,19 @@ public class TripLonglineTopiaDao extends AbstractTripLonglineTopiaDao<TripLongl public static List<TripLongline> findAll(TopiaSqlSupport context, String programId, int referenceLocale) { String sql = "SELECT" + - " t.topiaId," + - " t.startDate," + - " t.endDate," + - " p.lastName," + - " p.firstName," + - " v.topiaId," + - " v." + I18nReferenceEntities.getPropertyName(referenceLocale) + - " FROM observe_longline.trip t, observe_common.person p, observe_common.vessel v" + - " WHERE " + - " t.program = ?" + - " AND t.observer = p.topiaId" + - " AND t.vessel = v.topiaId" + - " ORDER BY t.endDate"; + " t.topiaId," + + " t.startDate," + + " t.endDate," + + " p.lastName," + + " p.firstName," + + " v.topiaId," + + " v." + I18nReferenceEntities.getPropertyName(referenceLocale) + + " FROM observe_longline.trip t, observe_common.person p, observe_common.vessel v" + + " WHERE " + + " t.program = ?" + + " AND t.observer = p.topiaId" + + " AND t.vessel = v.topiaId" + + " ORDER BY t.endDate"; StubSqlQuery request = new StubSqlQuery(sql, programId, referenceLocale); return context.findMultipleResult(request); @@ -269,19 +269,19 @@ public class TripLonglineTopiaDao extends AbstractTripLonglineTopiaDao<TripLongl public static TripLongline find(TopiaSqlSupport context, String tripId, int referenceLocale) { String sql = "SELECT" + - " t.topiaId," + - " t.startDate," + - " t.endDate," + - " p.lastName," + - " p.firstName," + - " v.topiaId," + - " v." + I18nReferenceEntities.getPropertyName(referenceLocale) + - " FROM observe_longline.trip t, observe_common.person p, observe_common.vessel v" + - " WHERE " + - " t.topiaId = ?" + - " AND t.observer = p.topiaId" + - " AND t.vessel = v.topiaId" + - " ORDER BY t.endDate"; + " t.topiaId," + + " t.startDate," + + " t.endDate," + + " p.lastName," + + " p.firstName," + + " v.topiaId," + + " v." + I18nReferenceEntities.getPropertyName(referenceLocale) + + " FROM observe_longline.trip t, observe_common.person p, observe_common.vessel v" + + " WHERE " + + " t.topiaId = ?" + + " AND t.observer = p.topiaId" + + " AND t.vessel = v.topiaId" + + " ORDER BY t.endDate"; StubSqlQuery request = new StubSqlQuery(sql, tripId, referenceLocale); return context.findSingleResult(request); @@ -383,8 +383,8 @@ public class TripLonglineTopiaDao extends AbstractTripLonglineTopiaDao<TripLongl public static Timestamp find(TopiaSqlSupport context, String tripId) { String sql = "SELECT max(a.timestamp)" + - " FROM observe_longline.activity a" + - " WHERE a.trip = ?"; + " FROM observe_longline.activity a" + + " WHERE a.trip = ?"; TheoricalEndOfDateSqlQuery request = new TheoricalEndOfDateSqlQuery(sql, tripId); return context.findSingleResult(request); diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/LengthWeightParameters.java b/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/LengthWeightParameters.java index e52abe4..768e0e7 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/LengthWeightParameters.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/LengthWeightParameters.java @@ -24,11 +24,11 @@ package fr.ird.observe.entities.referentiel; import com.google.common.base.Preconditions; import fr.ird.observe.ObserveTopiaDaoSupplier; -import fr.ird.observe.util.Numbers; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.nuiton.util.NumberUtil; import javax.script.Bindings; import javax.script.ScriptContext; @@ -302,7 +302,7 @@ public class LengthWeightParameters { ); if (o != null) { - o = Numbers.round1Digit(o); + o = NumberUtil.roundOneDigit(o); } return o; } @@ -317,7 +317,7 @@ public class LengthWeightParameters { ); if (o != null) { - o = Numbers.round2Digits(o); + o = NumberUtil.roundTwoDigits(o); } return o; } diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/LengthWeightParemeterHelper.java b/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/LengthWeightParemeterHelper.java index 2680601..05bfedc 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/LengthWeightParemeterHelper.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/LengthWeightParemeterHelper.java @@ -22,11 +22,11 @@ package fr.ird.observe.entities.referentiel; import fr.ird.observe.ObserveTopiaPersistenceContext; -import fr.ird.observe.util.Numbers; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.topia.persistence.TopiaDao; +import org.nuiton.util.NumberUtil; import javax.script.Bindings; import javax.script.ScriptContext; @@ -145,7 +145,7 @@ public class LengthWeightParemeterHelper { ); if (o != null) { - o = Numbers.round1Digit(o); + o = NumberUtil.roundOneDigit(o); } return o; } @@ -160,7 +160,7 @@ public class LengthWeightParemeterHelper { ); if (o != null) { - o = Numbers.round2Digits(o); + o = NumberUtil.roundTwoDigits(o); } return o; } diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/SpeciesImpl.java b/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/SpeciesImpl.java index d041bb0..0d7ba4d 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/SpeciesImpl.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/SpeciesImpl.java @@ -22,7 +22,7 @@ package fr.ird.observe.entities.referentiel; -import fr.ird.observe.util.Numbers; +import org.nuiton.util.NumberUtil; public class SpeciesImpl extends SpeciesAbstract { @@ -33,7 +33,7 @@ public class SpeciesImpl extends SpeciesAbstract { if (minLength != null) { // on arrondit à 2 décimales - minLength = Numbers.round2Digits(minLength); + minLength = NumberUtil.roundTwoDigits(minLength); } super.setMinLength(minLength); } @@ -43,7 +43,7 @@ public class SpeciesImpl extends SpeciesAbstract { if (maxLength != null) { // on arrondit à 2 décimales - maxLength = Numbers.round2Digits(maxLength); + maxLength = NumberUtil.roundTwoDigits(maxLength); } super.setMaxLength(maxLength); } @@ -53,7 +53,7 @@ public class SpeciesImpl extends SpeciesAbstract { if (minWeight != null) { // on arrondit à 2 décimales - minWeight = Numbers.round2Digits(minWeight); + minWeight = NumberUtil.roundTwoDigits(minWeight); } super.setMinWeight(minWeight); } @@ -63,8 +63,8 @@ public class SpeciesImpl extends SpeciesAbstract { if (maxWeight != null) { // on arrondit à 2 décimales - maxWeight = Numbers.round2Digits(maxWeight); + maxWeight = NumberUtil.roundTwoDigits(maxWeight); } super.setMaxWeight(maxWeight); } -} //SpeciesImpl +} diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/VesselImpl.java b/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/VesselImpl.java index b815e04..ea4de7b 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/VesselImpl.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/VesselImpl.java @@ -22,7 +22,7 @@ package fr.ird.observe.entities.referentiel; -import fr.ird.observe.util.Numbers; +import org.nuiton.util.NumberUtil; public class VesselImpl extends VesselAbstract { @@ -32,7 +32,7 @@ public class VesselImpl extends VesselAbstract { public void setCapacity(Float capacity) { // on arrondit à 2 décimales if (capacity != null) { - capacity = Numbers.round2Digits(capacity); + capacity = NumberUtil.roundTwoDigits(capacity); } super.setCapacity(capacity); } @@ -41,7 +41,7 @@ public class VesselImpl extends VesselAbstract { public void setSearchMaximum(Float searchMaximum) { // on arrondit à 2 décimales if (searchMaximum != null) { - searchMaximum = Numbers.round2Digits(searchMaximum); + searchMaximum = NumberUtil.roundTwoDigits(searchMaximum); } super.setSearchMaximum(searchMaximum); } @@ -50,8 +50,8 @@ public class VesselImpl extends VesselAbstract { public void setLength(Float length) { // on arrondit à 2 décimales if (length != null) { - length = Numbers.round2Digits(length); + length = NumberUtil.roundTwoDigits(length); } super.setLength(length); } -} //VesselImpl +} diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/seine/ActivitySeineImpl.java b/observe-entities/src/main/java/fr/ird/observe/entities/seine/ActivitySeineImpl.java index 52b3790..bbfd092 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/seine/ActivitySeineImpl.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/seine/ActivitySeineImpl.java @@ -25,10 +25,10 @@ import com.google.common.base.MoreObjects; import fr.ird.observe.entities.Entities; import fr.ird.observe.entities.constants.seine.SchoolType; import fr.ird.observe.entities.referentiel.seine.VesselActivitySeine; -import fr.ird.observe.util.Numbers; import fr.ird.type.CoordinateHelper; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.nuiton.util.NumberUtil; import java.util.Arrays; import java.util.List; @@ -169,7 +169,7 @@ public class ActivitySeineImpl extends ActivitySeineAbstract { // on arrondit à 2 décimales observedSystemDistance = - Numbers.round2Digits(observedSystemDistance); + NumberUtil.roundTwoDigits(observedSystemDistance); } super.setObservedSystemDistance(observedSystemDistance); } @@ -179,7 +179,7 @@ public class ActivitySeineImpl extends ActivitySeineAbstract { if (vesselSpeed != null) { // on arrondit à 2 décimales - vesselSpeed = Numbers.round2Digits(vesselSpeed); + vesselSpeed = NumberUtil.roundTwoDigits(vesselSpeed); } super.setVesselSpeed(vesselSpeed); } @@ -189,7 +189,7 @@ public class ActivitySeineImpl extends ActivitySeineAbstract { if (seaSurfaceTemperature != null) { // on arrondit à 2 décimales - seaSurfaceTemperature = Numbers.round2Digits(seaSurfaceTemperature); + seaSurfaceTemperature = NumberUtil.roundTwoDigits(seaSurfaceTemperature); } super.setSeaSurfaceTemperature(seaSurfaceTemperature); } diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/seine/NonTargetCatchImpl.java b/observe-entities/src/main/java/fr/ird/observe/entities/seine/NonTargetCatchImpl.java index 4687589..a55328e 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/seine/NonTargetCatchImpl.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/seine/NonTargetCatchImpl.java @@ -21,11 +21,11 @@ */ package fr.ird.observe.entities.seine; -import fr.ird.observe.util.Numbers; import fr.ird.observe.entities.constants.seine.NonTargetCatchComputedValueSource; import fr.ird.observe.entities.referentiel.LengthWeightParameter; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.nuiton.util.NumberUtil; /** * L'implantation par defaut d'une discarded faune. @@ -92,7 +92,7 @@ public class NonTargetCatchImpl extends NonTargetCatchAbstract { if (meanWeight != null) { // on arrondit à 2 décimales - meanWeight = Numbers.round2Digits(meanWeight); + meanWeight = NumberUtil.roundTwoDigits(meanWeight); if (log.isDebugEnabled()) { log.debug("weight moyen : " + meanWeight); } @@ -105,7 +105,7 @@ public class NonTargetCatchImpl extends NonTargetCatchAbstract { if (catchWeight != null) { // on arrondit à 3 décimales - catchWeight = Numbers.round3Digits(catchWeight); + catchWeight = NumberUtil.roundThreeDigits(catchWeight); if (log.isDebugEnabled()) { log.debug("weight estime : " + catchWeight); } @@ -118,7 +118,7 @@ public class NonTargetCatchImpl extends NonTargetCatchAbstract { if (meanLength != null) { // on arrondit à 1 décimale - meanLength = Numbers.round1Digit(meanLength); + meanLength = NumberUtil.roundOneDigit(meanLength); } super.setMeanLength(meanLength); } diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/seine/NonTargetLengthImpl.java b/observe-entities/src/main/java/fr/ird/observe/entities/seine/NonTargetLengthImpl.java index 09e1d3a..718af2a 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/seine/NonTargetLengthImpl.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/seine/NonTargetLengthImpl.java @@ -21,7 +21,7 @@ */ package fr.ird.observe.entities.seine; -import fr.ird.observe.util.Numbers; +import org.nuiton.util.NumberUtil; public class NonTargetLengthImpl extends NonTargetLengthAbstract { @@ -33,7 +33,7 @@ public class NonTargetLengthImpl extends NonTargetLengthAbstract { if (weight != null) { // on arrondit à trois décimale - weight = Numbers.round2Digits(weight); + weight = NumberUtil.roundTwoDigits(weight); } super.setWeight(weight); } @@ -43,9 +43,9 @@ public class NonTargetLengthImpl extends NonTargetLengthAbstract { if (length != null) { // on arrondit à 1 décimale - length = Numbers.round1Digit(length); + length = NumberUtil.roundOneDigit(length); } super.setLength(length); } -} //NonTargetLengthImpl +} diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/seine/RouteImpl.java b/observe-entities/src/main/java/fr/ird/observe/entities/seine/RouteImpl.java index 3174b82..96151a0 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/seine/RouteImpl.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/seine/RouteImpl.java @@ -21,7 +21,7 @@ */ package fr.ird.observe.entities.seine; -import fr.ird.observe.util.Numbers; +import org.nuiton.util.NumberUtil; /** @author Tony Chemit - chemit@codelutin.com */ public class RouteImpl extends RouteAbstract { @@ -33,7 +33,7 @@ public class RouteImpl extends RouteAbstract { if (startLogValue != null) { // on arrondit à 2 décimales - startLogValue = Numbers.round2Digits(startLogValue); + startLogValue = NumberUtil.roundTwoDigits(startLogValue); } super.setStartLogValue(startLogValue); } @@ -43,258 +43,9 @@ public class RouteImpl extends RouteAbstract { if (endLogValue != null) { // on arrondit à 2 décimales - endLogValue = Numbers.round2Digits(endLogValue); + endLogValue = NumberUtil.roundTwoDigits(endLogValue); } super.setEndLogValue(endLogValue); } -// @Override -// public ActivitySeine getOpenChild() { -// return OpenableEntities.getOpenEntity(activitySeine); -// } -// -// @Override -// public List<ActivitySeine> getOpenableChilds() { -// return activitySeine; -// } -// -// @Override -// public ActivitySeine getOpenActivity() { -// return getOpenChild(); -// } -// -// /** -// * @param activitySeine null -// * @return l'activity precedente celle donnee ou null -// */ -// @Override -// public ActivitySeine getPreviousActivity(ActivitySeine activitySeine) { -// if (isActivitySeineEmpty()) { -// -// // pas d'activity definie sur la route -// return null; -// } -// int index = this.activitySeine.indexOf(activitySeine); -// if (index < 1) { -// -// // activity non trouvée sur cette route ou premiere activity -// // donc pas d'activity précédente -// return null; -// } -// -// // on retourne l'activity precedente -// return this.activitySeine.get(index - 1); -// } -// -// /** -// * @param activitySeine null -// * @return l'activity suivante celle donnee ou null -// */ -// @Override -// public ActivitySeine getNextActivity(ActivitySeine activitySeine) { -// if (isActivitySeineEmpty()) { -// -// // pas d'activity definie sur la route -// return null; -// } -// int index = this.activitySeine.indexOf(activitySeine); -// if (index == -1 || index + 1 >= sizeActivitySeine()) { -// -// // l'activity n'est pas definie sur cette route, ou c'est la -// // dernière de la route -// return null; -// } -// -// // on retourne l'activity suivante -// return this.activitySeine.get(index + 1); -// } -// -// /** @return la derniere activity */ -// @Override -// public ActivitySeine getLastActivity() { -// if (isActivitySeineEmpty()) { -// -// // pas d'activity definie sur la route -// return null; -// } -// -// // on retourne la derniere activity -// return activitySeine.get(sizeActivitySeine() - 1); -// } - -// @Override -// public boolean isActivityFindDeVeilleFound() { -// return getActivityFinDeVeille() != null; -// } -// -// @Override -// public ActivitySeine getActivityFinDeVeille() { -// if (activitySeine == null || isActivitySeineEmpty()) { -// return null; -// } -// ActivitySeine result = null; -// for (ActivitySeine a : activitySeine) { -// if (a.isActivityFinDeVeille()) { -// -// // il existe bien une activity de fin de veille -// result = a; -// break; -// } -// } -// return result; -// } -// -// @Override -// public List<ActivitySeine> getActivityDebutDePechePositive() { -// List<ActivitySeine> result = new ArrayList<ActivitySeine>(); -// if (activitySeine != null && !isActivitySeineEmpty()) { -// for (ActivitySeine a : activitySeine) { -// if (a.isActivityDebutDePechePositive()) { -// -// // activity de debut de peche positive -// result.add(a); -// } -// } -// } -// return result; -// } -// -// @Override -// public List<ActivitySeine> getActivityFinDePeche() { -// List<ActivitySeine> result = new ArrayList<ActivitySeine>(); -// if (activitySeine != null && !isActivitySeineEmpty()) { -// for (ActivitySeine a : activitySeine) { -// if (a.isActivityFinDePeche()) { -// -// // activity de debut de peche positive -// result.add(a); -// } -// } -// } -// return result; -// } -// -// @Override -// public ActivitySeine getNextActivityFinDePeche(ActivitySeine actitiveDebut) { -// if (activitySeine == null || isActivitySeineEmpty()) { -// -// // pas d'actitive dans la route -// return null; -// } -// int position = activitySeine.indexOf(actitiveDebut); -// if (position == -1) { -// -// // activity de debut non trouvee -// return null; -// } -// -// for (int i = position + 1, max = sizeActivitySeine(); i < max; i++) { -// ActivitySeine a = activitySeine.get(i); -// if (a.isActivityFinDePeche()) { -// -// // activity de fin de peche trouvee -// return a; -// } -// } -// return null; -// } -// -// @Override -// public ActivitySeine getNextActivityDebutDePechePositive(ActivitySeine actitiveDebut) { -// if (activitySeine == null || isActivitySeineEmpty()) { -// -// // pas d'actitive dans la route -// return null; -// } -// int position = activitySeine.indexOf(actitiveDebut); -// if (position == -1) { -// -// // activity de debut non trouvee -// return null; -// } -// -// for (int i = position + 1, max = sizeActivitySeine(); i < max; i++) { -// ActivitySeine a = activitySeine.get(i); -// if (a.isActivityDebutDePechePositive()) { -// -// // activity de fin de peche trouvee -// return a; -// } -// } -// return null; -// } -// -// @Override -// public ActivitySeine getLastActivityDebutDePechePositiveBefore(Date actitiveDebut) { -// -// if (activitySeine == null || isActivitySeineEmpty()) { -// -// // pas d'actitive dans la route -// return null; -// } -// -// int position = getLastActivityBefore(actitiveDebut); -// -// if (position == -1) { -// -// // activity avant toute les autres ou non trouvee -// return null; -// } -// -// // on parcours en ordre inverse depuis la position jusqu'à trouver -// // de debut de peche positive -// ActivitySeine result = null; -// for (int i = position; i > -1; i--) { -// ActivitySeine a = activitySeine.get(i); -// if (a.isActivityDebutDePechePositive()) { -// -// // on a trouve une activity de debut de peche positive -// result = a; -// break; -// } -// } -// return result; -// } - -// @Override -// @Deprecated -// public void updateDates() { -// throw new IllegalStateException("A NE PLUS UTILISER!!!"); -// } -// -// protected int getLastActivityBefore(Date currentTime) { -// if (activitySeine == null || isActivitySeineEmpty()) { -// -// // pas d'actitive dans la route -// return -1; -// } -// Iterator<ActivitySeine> itr = activitySeine.iterator(); -// int i = -1; -// while (itr.hasNext()) { -// ActivitySeine a = itr.next(); -// if (currentTime.before(a.getTime()) || -// currentTime.equals(a.getTime())) { -// break; -// } -// i++; -// } -// return i; -// } -// -// @Override -// public boolean isTimeAvailable(String activityId, Date time) { -// boolean result = true; -// if (!isActivitySeineEmpty()) { -// time = DateUtil.getTime(time, false, false); -// for (ActivitySeine a : getActivitySeine()) { -// if (DateUtil.getTime(a.getTime(), false, false).equals(time) && -// !a.getTopiaId().equals(activityId)) { -// // heure observation already used -// result = false; -// break; -// } -// } -// } -// return result; -// } } diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/seine/SetSeineImpl.java b/observe-entities/src/main/java/fr/ird/observe/entities/seine/SetSeineImpl.java index 275787e..6b66572 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/seine/SetSeineImpl.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/seine/SetSeineImpl.java @@ -22,8 +22,8 @@ package fr.ird.observe.entities.seine; import fr.ird.observe.entities.constants.seine.SchoolType; -import fr.ird.observe.util.Numbers; import org.nuiton.util.DateUtil; +import org.nuiton.util.NumberUtil; import java.util.Date; @@ -133,7 +133,7 @@ public class SetSeineImpl extends SetSeineAbstract { if (currentSpeed != null) { // on arrondit à 3 décimales - currentSpeed = Numbers.round3Digits(currentSpeed); + currentSpeed = NumberUtil.roundThreeDigits(currentSpeed); } super.setCurrentSpeed(currentSpeed); } diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/seine/TargetCatchImpl.java b/observe-entities/src/main/java/fr/ird/observe/entities/seine/TargetCatchImpl.java index 5e68325..e859fb2 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/seine/TargetCatchImpl.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/seine/TargetCatchImpl.java @@ -21,8 +21,8 @@ */ package fr.ird.observe.entities.seine; -import fr.ird.observe.util.Numbers; import fr.ird.observe.entities.referentiel.Species; +import org.nuiton.util.NumberUtil; /** @author Tony Chemit - chemit@codelutin.com */ public class TargetCatchImpl extends TargetCatchAbstract { @@ -46,7 +46,7 @@ public class TargetCatchImpl extends TargetCatchAbstract { if (catchWeight != null) { // on arrondit à 3 décimales - catchWeight = Numbers.round3Digits(catchWeight); + catchWeight = NumberUtil.roundThreeDigits(catchWeight); } super.setCatchWeight(catchWeight); } diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/seine/TargetLengthImpl.java b/observe-entities/src/main/java/fr/ird/observe/entities/seine/TargetLengthImpl.java index 4cafaf9..99b8508 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/seine/TargetLengthImpl.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/seine/TargetLengthImpl.java @@ -21,7 +21,7 @@ */ package fr.ird.observe.entities.seine; -import fr.ird.observe.util.Numbers; +import org.nuiton.util.NumberUtil; public class TargetLengthImpl extends TargetLengthAbstract { @@ -33,7 +33,7 @@ public class TargetLengthImpl extends TargetLengthAbstract { if (weight != null) { // on arrondit à 2 décimales - weight = Numbers.round2Digits(weight); + weight = NumberUtil.roundTwoDigits(weight); } super.setWeight(weight); } @@ -43,7 +43,7 @@ public class TargetLengthImpl extends TargetLengthAbstract { if (length != null) { // on arrondit à 1 décimale - length = Numbers.round1Digit(length); + length = NumberUtil.roundOneDigit(length); } super.setLength(length); } @@ -52,9 +52,9 @@ public class TargetLengthImpl extends TargetLengthAbstract { public Float getTotalWeight() { Float result = null; if (getWeight() != null && getCount() != null) { - result = Numbers.round3Digits(getWeight() * getCount() / 1000.0f); + result = NumberUtil.roundThreeDigits(getWeight() * getCount() / 1000.0f); } return result; } -} //TargetLengthImpl +} diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/seine/TripSeineImpl.java b/observe-entities/src/main/java/fr/ird/observe/entities/seine/TripSeineImpl.java index 52d0e37..6ffea33 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/seine/TripSeineImpl.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/seine/TripSeineImpl.java @@ -29,144 +29,9 @@ public class TripSeineImpl extends TripSeineAbstract { private static final long serialVersionUID = 1L; -// @Override -// public Route getOpenChild() { -// return OpenableEntities.getOpenEntity(route); -// } -// -// @Override -// public Set<Route> getOpenableChilds() { -// return route; -// } - -// @Override -// public Route getOpenRoute() { -// return getOpenChild(); -// } -// -// @Override -// public Route getPreviousRoute(Route route) { -// if (isRouteEmpty()) { -// -// // aucune route definie sur la maree -// return null; -// } -// int index = this.route.indexOf(route); -// if (index < 1) { -// -// // la route donnee n'est pas definie sur cette maree ou est la -// // premiere route -// return null; -// } -// -// // on retourne la route precedente -// return this.route.get(index - 1); -// } -// -// /** -// * @param route null -// * @return la route suivante celle donnee ou null -// */ -// @Override -// public Route getNextRoute(Route route) { -// if (isRouteEmpty()) { -// -// // aucune route definie sur la maree -// return null; -// } -// int index = this.route.indexOf(route); -// if (index == -1 || index + 1 >= sizeRoute()) { -// -// // la route n'est pas definie sur cette maree, ou c'est la -// // dernière de la maree -// return null; -// } -// -// // on retourne la route suivante -// return this.route.get(index + 1); -// } -// -// /** @return la derniere route ou null */ -// @Override -// public Route getLastRoute() { -// if (isRouteEmpty()) { -// -// // aucune route definie sur la maree -// return null; -// } -// -// // on retourne la dernière route de la maree -// return getRoute().get(sizeRoute() - 1); -// } - -// @Override -// @Deprecated -// public Date getEndDateTheorique() { -// -// throw new IllegalStateException("A NE PLUS UTILISER!!!"); -// -//// Date d; -//// if (isRouteEmpty()) { -//// -//// // pas de route, donc la date de fin est la date de debut -//// d = getStartDate(); -//// } else { -//// List<Route> routes = new ArrayList<Route>(getRoute()); -//// -//// // on trie la liste par jour d'observation -//// Routes.sort(routes); -//// -//// // on recupere la derniere route de la maree -//// Route route = routes.get(routes.size() - 1); -//// -//// // son jour d'observation est la date de fin de la maree -//// d = route.getDate(); -//// } -//// -//// // on conserve la date epuree (pas de notion de temps dans la date) -//// d = DateUtil.getEndOfDay(d); -//// return d; -// } - -// @Override -// @Deprecated -// public void updateDateFin() { -// -// throw new IllegalStateException("A NE PLUS UTILISER!!!"); -// -//// // la date de fin theorique (date de la dernière route de la marée) -//// Date endDate = getEndDateTheorique(); -//// -//// // la date de fin actuelle -//// Date realDateFin = getEndDate(); -//// -//// if (realDateFin == null || endDate.after(realDateFin)) { -//// -//// // on utilise la nouvelle date theorique car l'ancienne n'existe pas -//// // ou est antérieure à la date de fin théoriquue -//// setEndDate(endDate); -//// } -// } - @Override public String getObserverLabel() { return observer == null ? "" : observer.getLastName() + " " + observer.getFirstName(); } -// @Override -// public boolean isDateAvailable(String routeId, Date date) { -// boolean result = true; -// if (!isRouteEmpty()) { -// date = DateUtil.getDay(date); -// for (Route r : getRoute()) { -// if (DateUtil.getDay(r.getDate()).equals(date) && -// !r.getTopiaId().equals(routeId)) { -// // jour observation already used -// result = false; -// break; -// } -// } -// } -// return result; -// } } diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/seine/TripSeineTopiaDao.java b/observe-entities/src/main/java/fr/ird/observe/entities/seine/TripSeineTopiaDao.java index 10033af..15177a2 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/seine/TripSeineTopiaDao.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/seine/TripSeineTopiaDao.java @@ -21,6 +21,8 @@ */ package fr.ird.observe.entities.seine; +import fr.ird.observe.entities.TripMapPoint; +import fr.ird.observe.entities.constants.TripMapPointPersistType; import fr.ird.observe.entities.constants.seine.SchoolType; import fr.ird.observe.entities.referentiel.Harbour; import fr.ird.observe.entities.referentiel.I18nReferenceEntities; @@ -28,8 +30,6 @@ import fr.ird.observe.entities.referentiel.Person; import fr.ird.observe.entities.referentiel.PersonImpl; import fr.ird.observe.entities.referentiel.Vessel; import fr.ird.observe.entities.referentiel.VesselImpl; -import fr.ird.observe.services.dto.TripMapPointDto; -import fr.ird.observe.services.dto.constants.TripMapPointType; import org.nuiton.topia.persistence.support.TopiaSqlQuery; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import org.nuiton.util.DateUtil; @@ -81,20 +81,20 @@ public class TripSeineTopiaDao extends AbstractTripSeineTopiaDao<TripSeine> { } - public LinkedHashSet<TripMapPointDto> extractTripMapActivityPoints(String tripId) { + public LinkedHashSet<TripMapPoint> extractTripMapActivityPoints(String tripId) { TripSeine tripSeine = forTopiaIdEquals(tripId).findUnique(); - LinkedHashSet<TripMapPointDto> tripMapPoints = new LinkedHashSet<>(); + LinkedHashSet<TripMapPoint> tripMapPoints = new LinkedHashSet<>(); // add departure harbours Harbour departureHarbour = tripSeine.getDepartureHarbour(); if (departureHarbour != null) { - TripMapPointDto departurePoint = new TripMapPointDto(); + TripMapPoint departurePoint = new TripMapPoint(); departurePoint.setTime(tripSeine.getStartDate()); departurePoint.setLatitude(departureHarbour.getLatitude()); departurePoint.setLongitude(departureHarbour.getLongitude()); - departurePoint.setType(TripMapPointType.SEINE_DEPARTURE_HARBOUR); + departurePoint.setType(TripMapPointPersistType.SEINE_DEPARTURE_HARBOUR); tripMapPoints.add(departurePoint); } @@ -105,33 +105,33 @@ public class TripSeineTopiaDao extends AbstractTripSeineTopiaDao<TripSeine> { // add landing harbours Harbour landingHarbour = tripSeine.getLandingHarbour(); if (landingHarbour != null) { - TripMapPointDto landingPoint = new TripMapPointDto(); + TripMapPoint landingPoint = new TripMapPoint(); landingPoint.setTime(tripSeine.getEndDate()); landingPoint.setLatitude(landingHarbour.getLatitude()); landingPoint.setLongitude(landingHarbour.getLongitude()); - landingPoint.setType(TripMapPointType.SEINE_LANDING_HARBOUR); + landingPoint.setType(TripMapPointPersistType.SEINE_LANDING_HARBOUR); tripMapPoints.add(landingPoint); } return tripMapPoints; } - private static class TripMapActivityPointQuery extends TopiaSqlQuery<TripMapPointDto> { + private static class TripMapActivityPointQuery extends TopiaSqlQuery<TripMapPoint> { private static String SQL = "SELECT" + - " r.date, " + - " a.time, " + - " a.latitude," + - " a.longitude," + - " a.vesselactivity, " + - " s.schoolType" + - " FROM observe_seine.route r" + - " INNER JOIN observe_seine.activity a" + - " ON a.route = r.topiaId" + - " LEFT OUTER JOIN observe_seine.set s" + - " ON s.topiaId = a.set" + - " WHERE r.trip = ?" + - " ORDER BY r.date, a.time"; + " r.date, " + + " a.time, " + + " a.latitude," + + " a.longitude," + + " a.vesselactivity, " + + " s.schoolType" + + " FROM observe_seine.route r" + + " INNER JOIN observe_seine.activity a" + + " ON a.route = r.topiaId" + + " LEFT OUTER JOIN observe_seine.set s" + + " ON s.topiaId = a.set" + + " WHERE r.trip = ?" + + " ORDER BY r.date, a.time"; protected String tripId; @@ -147,28 +147,28 @@ public class TripSeineTopiaDao extends AbstractTripSeineTopiaDao<TripSeine> { } @Override - public TripMapPointDto prepareResult(ResultSet resultSet) throws SQLException { + public TripMapPoint prepareResult(ResultSet resultSet) throws SQLException { - TripMapPointDto point = new TripMapPointDto(); + TripMapPoint point = new TripMapPoint(); Date time = DateUtil.getDateAndTime(resultSet.getDate(1), resultSet.getTime(2), true, false); point.setTime(time); point.setLatitude(resultSet.getFloat(3)); point.setLongitude(resultSet.getFloat(4)); if (ACTIVITY_HARBOUR_ID.equals(resultSet.getString(5))) { - point.setType(TripMapPointType.SEINE_ACTIVITY_IN_HARBOUR); + point.setType(TripMapPointPersistType.SEINE_ACTIVITY_IN_HARBOUR); } else if (resultSet.getString(6) == null) { - point.setType(TripMapPointType.SEINE_ACTIVITY); + point.setType(TripMapPointPersistType.SEINE_ACTIVITY); } else { SchoolType schoolType = SchoolType.values()[resultSet.getInt(6)]; switch (schoolType) { case libre: - point.setType(TripMapPointType.SEINE_ACTIVITY_WITH_FREE_SCHOOL_TYPE); + point.setType(TripMapPointPersistType.SEINE_ACTIVITY_WITH_FREE_SCHOOL_TYPE); break; case objet: - point.setType(TripMapPointType.SEINE_ACTIVITY_WITH_OBJECT_SCHOOL_TYPE); + point.setType(TripMapPointPersistType.SEINE_ACTIVITY_WITH_OBJECT_SCHOOL_TYPE); break; default: - point.setType(TripMapPointType.SEINE_ACTIVITY); + point.setType(TripMapPointPersistType.SEINE_ACTIVITY); } } @@ -189,19 +189,19 @@ public class TripSeineTopiaDao extends AbstractTripSeineTopiaDao<TripSeine> { static <E extends TripSeine> List<TripSeine> findAll(TopiaSqlSupport context, String programId, int referenceLocale) { String sql = "SELECT" + - " t.topiaId," + - " t.startDate," + - " t.endDate," + - " p.lastName," + - " p.firstName," + - " v.topiaId, " + - " v." + I18nReferenceEntities.getPropertyName(referenceLocale) + - " FROM observe_seine.trip t, observe_common.person p, observe_common.vessel v" + - " WHERE " + - " t.program = ?" + - " AND t.observer = p.topiaId" + - " AND t.vessel = v.topiaId" + - " ORDER BY t.endDate"; + " t.topiaId," + + " t.startDate," + + " t.endDate," + + " p.lastName," + + " p.firstName," + + " v.topiaId, " + + " v." + I18nReferenceEntities.getPropertyName(referenceLocale) + + " FROM observe_seine.trip t, observe_common.person p, observe_common.vessel v" + + " WHERE " + + " t.program = ?" + + " AND t.observer = p.topiaId" + + " AND t.vessel = v.topiaId" + + " ORDER BY t.endDate"; StubSqlQuery request = new StubSqlQuery(sql, programId, referenceLocale); return context.findMultipleResult(request); @@ -211,19 +211,19 @@ public class TripSeineTopiaDao extends AbstractTripSeineTopiaDao<TripSeine> { static TripSeine find(TopiaSqlSupport context, String tripId, int referenceLocale) { String sql = "SELECT" + - " t.topiaId," + - " t.startDate," + - " t.endDate," + - " p.lastName," + - " p.firstName," + - " v.topiaId," + - " v." + I18nReferenceEntities.getPropertyName(referenceLocale) + - " FROM observe_seine.trip t, observe_common.person p, observe_common.vessel v" + - " WHERE " + - " t.topiaId = ?" + - " AND t.observer = p.topiaId" + - " AND t.vessel = v.topiaId" + - " ORDER BY t.endDate"; + " t.topiaId," + + " t.startDate," + + " t.endDate," + + " p.lastName," + + " p.firstName," + + " v.topiaId," + + " v." + I18nReferenceEntities.getPropertyName(referenceLocale) + + " FROM observe_seine.trip t, observe_common.person p, observe_common.vessel v" + + " WHERE " + + " t.topiaId = ?" + + " AND t.observer = p.topiaId" + + " AND t.vessel = v.topiaId" + + " ORDER BY t.endDate"; StubSqlQuery request = new StubSqlQuery(sql, tripId, referenceLocale); return context.findSingleResult(request); @@ -333,8 +333,8 @@ public class TripSeineTopiaDao extends AbstractTripSeineTopiaDao<TripSeine> { public static Date find(TopiaSqlSupport context, String tripId) { String sql = "SELECT max(r.date)" + - " FROM observe_seine.route r" + - " WHERE r.trip = ?"; + " FROM observe_seine.route r" + + " WHERE r.trip = ?"; TheoricalEndOfDateSqlQuery request = new TheoricalEndOfDateSqlQuery(sql, tripId); return context.findSingleResult(request); diff --git a/observe-entities/src/test/java/fr/ird/observe/util/NumbersTest.java b/observe-entities/src/test/java/fr/ird/observe/util/NumbersTest.java deleted file mode 100644 index 17309d3..0000000 --- a/observe-entities/src/test/java/fr/ird/observe/util/NumbersTest.java +++ /dev/null @@ -1,86 +0,0 @@ -package fr.ird.observe.util; - -/* - * #%L - * ObServe :: Entities - * %% - * Copyright (C) 2008 - 2015 IRD, Codelutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import org.junit.Assert; -import org.junit.Test; - -/** - * Created on 21/08/15. - * - * @author Tony Chemit - chemit@codelutin.com - */ -public class NumbersTest { - - - @Test - public void testRound3Digits() { - - - assertRound3Digits(1.2f, 1.2f); - assertRound3Digits(1.22f, 1.22f); - assertRound3Digits(1.222f, 1.222f); - assertRound3Digits(1.2222f, 1.222f); - assertRound3Digits(1.2225f, 1.222f); - assertRound3Digits(1.2226f, 1.223f); - assertRound3Digits(11.2226f, 11.223f); - assertRound3Digits(111.2226f, 111.223f); - assertRound3Digits(1111.2226f, 1111.223f); - - assertRound3Digits(1111.999f, 1111.999f); - assertRound3Digits(1111.9994f, 1111.999f); - assertRound3Digits(1111.9995f, 1112f); - assertRound3Digits(1111.9996f, 1112f); - } - - @Test - public void testRoundTaille() { - - assertRound1Digit(1.2f, 1.2f); - assertRound1Digit(1.22f, 1.2f); - assertRound1Digit(1.5f, 1.5f); - assertRound1Digit(1.55f, 1.5f); - assertRound1Digit(1.56f, 1.6f); - assertRound1Digit(1.9f, 1.9f); - assertRound1Digit(1.222f, 1.2f); - assertRound1Digit(11.2226f, 11.2f); - assertRound1Digit(111.2226f, 111.2f); - assertRound1Digit(1111.2226f, 1111.2f); - - assertRound1Digit(1111.999f, 1112.0f); - assertRound1Digit(1111.9994f, 1112.0f); - assertRound1Digit(1111.9995f, 1112.0f); - assertRound1Digit(1111.9996f, 1112.0f); - } - - protected void assertRound3Digits(float number, float expected) { - float actual = Numbers.round3Digits(number); - Assert.assertEquals("" + expected, "" + actual); - } - - protected void assertRound1Digit(float number, float expected) { - Float actual = Numbers.round1Digit(number); - Assert.assertEquals("" + expected, "" + actual); - } - -} \ No newline at end of file diff --git a/observe-services-model/src/main/java/fr/ird/observe/services/dto/TripMapDtos.java b/observe-services-model/src/main/java/fr/ird/observe/services/dto/TripMapDtos.java deleted file mode 100644 index 458275a..0000000 --- a/observe-services-model/src/main/java/fr/ird/observe/services/dto/TripMapDtos.java +++ /dev/null @@ -1,15 +0,0 @@ -package fr.ird.observe.services.dto; - - -import java.util.LinkedHashSet; - -public class TripMapDtos extends AbstractTripMapDtos { - - public static TripMapDto newTripMapDto(String tripId, LinkedHashSet<TripMapPointDto> points) { - TripMapDto tripMapDto = new TripMapDto(); - tripMapDto.setId(tripId); - tripMapDto.setPoints(points); - return tripMapDto; - } -} - diff --git a/observe-services-model/src/main/java/fr/ird/observe/services/dto/longline/SetLonglineGlobalCompositionDto.java b/observe-services-model/src/main/java/fr/ird/observe/services/dto/longline/SetLonglineGlobalCompositionDto.java index 2c83aaa..94b72c6 100644 --- a/observe-services-model/src/main/java/fr/ird/observe/services/dto/longline/SetLonglineGlobalCompositionDto.java +++ b/observe-services-model/src/main/java/fr/ird/observe/services/dto/longline/SetLonglineGlobalCompositionDto.java @@ -1,8 +1,5 @@ package fr.ird.observe.services.dto.longline; -import javax.annotation.Generated; - -@Generated(value = "org.nuiton.eugene.java.SimpleJavaBeanWithNoInterfaceTransformer", date = "Thu Oct 22 14:47:01 CEST 2015") public class SetLonglineGlobalCompositionDto extends AbstractSetLonglineGlobalCompositionDto { private static final long serialVersionUID = 3473510292736074595L; diff --git a/observe-services-model/src/main/java/fr/ird/observe/services/dto/seine/FloatingObjectTransmittingBuoyDto.java b/observe-services-model/src/main/java/fr/ird/observe/services/dto/seine/FloatingObjectTransmittingBuoyDto.java index 37255f3..47c9906 100644 --- a/observe-services-model/src/main/java/fr/ird/observe/services/dto/seine/FloatingObjectTransmittingBuoyDto.java +++ b/observe-services-model/src/main/java/fr/ird/observe/services/dto/seine/FloatingObjectTransmittingBuoyDto.java @@ -5,9 +5,6 @@ import fr.ird.observe.services.dto.constants.seine.TypeTransmittingBuoyOperation import fr.ird.observe.services.dto.referential.ReferentialReference; import fr.ird.observe.services.dto.referential.seine.TransmittingBuoyOperationDto; -import javax.annotation.Generated; - -@Generated(value = "org.nuiton.eugene.java.SimpleJavaBeanWithNoInterfaceTransformer", date = "Thu Oct 15 11:11:56 CEST 2015") public class FloatingObjectTransmittingBuoyDto extends AbstractFloatingObjectTransmittingBuoyDto { private static final long serialVersionUID = 7148959059263172961L; @@ -41,7 +38,7 @@ public class FloatingObjectTransmittingBuoyDto extends AbstractFloatingObjectTra case 2: // recuperation - return TypeTransmittingBuoyOperation.recuperation; + return TypeTransmittingBuoyOperation.recupeNration; case 3: // mise a l'eau d'une nouvelle balise @@ -60,4 +57,4 @@ public class FloatingObjectTransmittingBuoyDto extends AbstractFloatingObjectTra } -} //FloatingObjectTransmittingBuoyDto +} diff --git a/observe-services-model/src/main/java/fr/ird/observe/services/dto/seine/TargetLengthDto.java b/observe-services-model/src/main/java/fr/ird/observe/services/dto/seine/TargetLengthDto.java index be99ea7..df44e6c 100644 --- a/observe-services-model/src/main/java/fr/ird/observe/services/dto/seine/TargetLengthDto.java +++ b/observe-services-model/src/main/java/fr/ird/observe/services/dto/seine/TargetLengthDto.java @@ -1,10 +1,7 @@ package fr.ird.observe.services.dto.seine; -import fr.ird.observe.util.Numbers; +import org.nuiton.util.NumberUtil; -import javax.annotation.Generated; - -@Generated(value = "org.nuiton.eugene.java.SimpleJavaBeanWithNoInterfaceTransformer", date = "Tue Oct 20 17:22:11 CEST 2015") public class TargetLengthDto extends AbstractTargetLengthDto { private static final long serialVersionUID = 7005688292510741559L; @@ -12,10 +9,10 @@ public class TargetLengthDto extends AbstractTargetLengthDto { public Float getTotalWeight() { Float result = null; if (getWeight() != null && getCount() != null) { - result = Numbers.round3Digits(getWeight() * getCount() / 1000.0f); + result = NumberUtil.roundThreeDigits(getWeight() * getCount() / 1000.0f); } return result; } -} //TargetLengthDto +} diff --git a/observe-services-model/src/main/java/fr/ird/observe/util/Numbers.java b/observe-services-model/src/main/java/fr/ird/observe/util/Numbers.java deleted file mode 100644 index 8a921ce..0000000 --- a/observe-services-model/src/main/java/fr/ird/observe/util/Numbers.java +++ /dev/null @@ -1,87 +0,0 @@ -package fr.ird.observe.util; - -/* - * #%L - * ObServe :: Entities - * %% - * Copyright (C) 2008 - 2014 IRD, Codelutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import com.google.common.base.Predicate; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.math.BigDecimal; -import java.math.MathContext; - -/** - * Created on 8/25/14. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 3.7 - */ -public class Numbers { - - public static final Predicate<Float> IS_FLOAT_CHANGED_TO_ZERO_OR_NULL = new Predicate<Float>() { - - @Override - public boolean apply(Float input) { - return input == null || Math.abs(round3Digits(input)) < 0.001; - } - }; - - public static final Predicate<Integer> IS_INTEGER_CHANGED_TO_ZERO_OR_NULL = new Predicate<Integer>() { - - @Override - public boolean apply(Integer input) { - return input == null || input == 0; - } - }; - - /** Logger. */ - private static final Log log = LogFactory.getLog(Numbers.class); - - public static final MathContext mc1Digit = new MathContext(1); - - public static final MathContext mc2Digits = new MathContext(2); - - public static final MathContext mc3Digits = new MathContext(3); - - public static Float round3Digits(Float number) { - return round(number, mc3Digits); - } - - public static Float round2Digits(Float number) { - return round(number, mc2Digits); - } - - public static Float round1Digit(Float number) { - return round(number, mc1Digit); - } - - public static Float round(Float number, MathContext mc) { - float old = number; - float partieEntier = (int) old; - float digit = old - (int) old; - number = partieEntier + new BigDecimal(digit).round(mc).floatValue(); - if (log.isDebugEnabled()) { - log.debug("round " + old + " to " + number + " with mc = " + mc); - } - return number; - } -} diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/entity/TripMapDtoFactory.java b/observe-services-topia/src/main/java/fr/ird/observe/services/entity/TripMapDtoFactory.java new file mode 100644 index 0000000..f2306b2 --- /dev/null +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/entity/TripMapDtoFactory.java @@ -0,0 +1,40 @@ +package fr.ird.observe.services.entity; + +import com.google.common.base.Function; +import com.google.common.collect.Iterables; +import com.google.common.collect.Sets; +import fr.ird.observe.entities.TripMapPoint; +import fr.ird.observe.services.dto.TripMapDto; +import fr.ird.observe.services.dto.TripMapPointDto; +import fr.ird.observe.services.dto.constants.TripMapPointType; + +import java.util.LinkedHashSet; +import java.util.Set; + +/** + * Created on 09/01/16. + * + * @author Tony Chemit - chemit@codelutin.com + */ +public class TripMapDtoFactory { + + public static TripMapDto newTripMapDto(String tripId, Set<TripMapPoint> points) { + TripMapDto tripMapDto = new TripMapDto(); + tripMapDto.setId(tripId); + LinkedHashSet<TripMapPointDto> pointDtos = Sets.newLinkedHashSet(Iterables.transform(points, TRIP_MAP_POINT_TRIP_MAP_POINT_DTO_FUNCTION)); + tripMapDto.setPoints(pointDtos); + return tripMapDto; + } + + protected static final Function<TripMapPoint, TripMapPointDto> TRIP_MAP_POINT_TRIP_MAP_POINT_DTO_FUNCTION = new Function<TripMapPoint, TripMapPointDto>() { + @Override + public TripMapPointDto apply(TripMapPoint tripMapPoint) { + TripMapPointDto result = new TripMapPointDto(); + result.setLatitude(tripMapPoint.getLatitude()); + result.setLongitude(tripMapPoint.getLongitude()); + result.setTime(tripMapPoint.getTime()); + result.setType(TripMapPointType.valueOf(tripMapPoint.getType().name())); + return result; + } + }; +} diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/service/longline/TripLonglineServiceTopia.java b/observe-services-topia/src/main/java/fr/ird/observe/services/service/longline/TripLonglineServiceTopia.java index e526d16..765ba40 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/service/longline/TripLonglineServiceTopia.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/service/longline/TripLonglineServiceTopia.java @@ -23,6 +23,7 @@ package fr.ird.observe.services.service.longline; */ import fr.ird.observe.ObserveTopiaPersistenceContext; +import fr.ird.observe.entities.TripMapPoint; import fr.ird.observe.entities.longline.TripLongline; import fr.ird.observe.entities.longline.TripLonglineTopiaDao; import fr.ird.observe.entities.referentiel.Program; @@ -31,12 +32,11 @@ import fr.ird.observe.services.dto.DataReference; import fr.ird.observe.services.dto.DataReferenceSet; import fr.ird.observe.services.dto.Form; import fr.ird.observe.services.dto.TripMapDto; -import fr.ird.observe.services.dto.TripMapDtos; -import fr.ird.observe.services.dto.TripMapPointDto; import fr.ird.observe.services.dto.longline.TripLonglineDto; import fr.ird.observe.services.dto.reference.request.ReferenceSetRequestDefinitions; import fr.ird.observe.services.dto.referential.ProgramDto; import fr.ird.observe.services.dto.result.SaveResultDto; +import fr.ird.observe.services.entity.TripMapDtoFactory; import org.nuiton.util.DateUtil; import java.util.ArrayList; @@ -88,9 +88,9 @@ public class TripLonglineServiceTopia extends ObserveServiceTopia implements Tri @Override public TripMapDto getTripLonglineMap(String tripLonglineId) { - LinkedHashSet<TripMapPointDto> points = getDao().extractTripMapActivityPoints(tripLonglineId); + LinkedHashSet<TripMapPoint> points = getDao().extractTripMapActivityPoints(tripLonglineId); - TripMapDto dto = TripMapDtos.newTripMapDto(tripLonglineId, points); + TripMapDto dto = TripMapDtoFactory.newTripMapDto(tripLonglineId, points); return dto; } diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/TripSeineServiceTopia.java b/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/TripSeineServiceTopia.java index f7a3812..997a3cc 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/TripSeineServiceTopia.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/TripSeineServiceTopia.java @@ -22,6 +22,7 @@ package fr.ird.observe.services.service.seine; * #L% */ +import fr.ird.observe.entities.TripMapPoint; import fr.ird.observe.entities.referentiel.Program; import fr.ird.observe.entities.seine.TripSeine; import fr.ird.observe.entities.seine.TripSeineTopiaDao; @@ -30,13 +31,12 @@ import fr.ird.observe.services.dto.DataReference; import fr.ird.observe.services.dto.DataReferenceSet; import fr.ird.observe.services.dto.Form; import fr.ird.observe.services.dto.TripMapDto; -import fr.ird.observe.services.dto.TripMapDtos; -import fr.ird.observe.services.dto.TripMapPointDto; import fr.ird.observe.services.dto.constants.ReferentialLocale; import fr.ird.observe.services.dto.reference.request.ReferenceSetRequestDefinitions; import fr.ird.observe.services.dto.referential.ProgramDto; import fr.ird.observe.services.dto.result.SaveResultDto; import fr.ird.observe.services.dto.seine.TripSeineDto; +import fr.ird.observe.services.entity.TripMapDtoFactory; import org.nuiton.util.DateUtil; import java.util.ArrayList; @@ -114,9 +114,9 @@ public class TripSeineServiceTopia extends ObserveServiceTopia implements TripSe @Override public TripMapDto getTripSeineMap(String tripSeineId) { - LinkedHashSet<TripMapPointDto> points = getDao().extractTripMapActivityPoints(tripSeineId); + LinkedHashSet<TripMapPoint> points = getDao().extractTripMapActivityPoints(tripSeineId); - TripMapDto tripMapDto = TripMapDtos.newTripMapDto(tripSeineId, points); + TripMapDto tripMapDto = TripMapDtoFactory.newTripMapDto(tripSeineId, points); return tripMapDto; } diff --git a/pom.xml b/pom.xml index 188d937..101a2e5 100644 --- a/pom.xml +++ b/pom.xml @@ -81,16 +81,14 @@ </developers> <modules> - <module>observe-services-model</module> <module>observe-services-configuration-api</module> + <module>observe-services-configuration-topia</module> + <module>observe-services-configuration-rest</module> + <module>observe-services-model</module> <module>observe-services-api</module> <module>observe-test-data</module> <module>observe-entities</module> - <!--<module>observe-business</module>--> - <!--<module>observe-entities-validation</module>--> - <module>observe-services-configuration-topia</module> <module>observe-services-topia</module> - <module>observe-services-configuration-rest</module> <module>observe-services-rest</module> <module>observe-services-runner</module> <module>observe-application-web</module> -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.