Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe Commits: a670d27c by Tony Chemit at 2020-06-30T12:58:27+02:00 Élimination des points non effectifs dans la carte - Cloes #1560 - - - - - 2ed828cc by Tony Chemit at 2020-06-30T12:59:02+02:00 Carte - Cloes #1517 - - - - - 20 changed files: - client-datasource-editor-common/src/main/java/fr/ird/observe/client/datasource/editor/content/data/trip/map/ObserveMapPaneLegendItem.java - client-datasource-editor-common/src/main/java/fr/ird/observe/client/datasource/editor/content/data/trip/map/TripMapContentBuilder.java - client-datasource-editor-common/src/main/java/fr/ird/observe/client/datasource/editor/content/data/trip/map/TripMapUIHandler.java - client-datasource-editor-common/src/main/map/ll-style.xml - client-datasource-editor-common/src/main/map/ps-style.xml - client-datasource-editor-ll/src/main/i18n/getters/java.getter - client-datasource-editor-ll/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ll/common/TripMapContentBuilder.java - client-datasource-editor-ps/src/main/i18n/getters/java.getter - client-datasource-editor-ps/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ps/common/TripMapContentBuilder.java - dto/src/main/java/fr/ird/observe/dto/data/TripMapPoint.java - dto/src/main/java/fr/ird/observe/spi/DtoModelClasses.java - observe-i18n/src/main/i18n/translations/observe_en_GB.properties - observe-i18n/src/main/i18n/translations/observe_es_ES.properties - observe-i18n/src/main/i18n/translations/observe_fr_FR.properties - persistence/src/main/java/fr/ird/observe/entities/Entities.java - persistence/src/main/java/fr/ird/observe/entities/data/ll/common/TripTopiaDao.java - persistence/src/main/java/fr/ird/observe/entities/data/ps/common/TripTopiaDao.java - services-local/src/main/java/fr/ird/observe/services/local/service/actions/validate/ValidateServiceLocal.java - services-local/src/main/java/fr/ird/observe/services/local/service/referential/ReferentialServiceLocal.java - services-local/src/main/java/fr/ird/observe/services/local/service/sql/SqlScriptProducerServiceLocal.java Changes: ===================================== client-datasource-editor-common/src/main/java/fr/ird/observe/client/datasource/editor/content/data/trip/map/ObserveMapPaneLegendItem.java ===================================== @@ -49,13 +49,13 @@ public class ObserveMapPaneLegendItem { public static Coordinate[] lineCoordinates() { Coordinate[] coordinates = new Coordinate[2]; - coordinates[0] = new Coordinate(LEGEND_MARGIN, LEGEND_ITEM_HEIGHT / 2); - coordinates[1] = new Coordinate(LEGEND_SYMBOL_WIDTH - LEGEND_MARGIN, LEGEND_ITEM_HEIGHT / 2); + coordinates[0] = new Coordinate(LEGEND_MARGIN, LEGEND_ITEM_HEIGHT / 2.); + coordinates[1] = new Coordinate(LEGEND_SYMBOL_WIDTH - LEGEND_MARGIN, LEGEND_ITEM_HEIGHT / 2.); return coordinates; } public static Coordinate pointCoordinates() { - return new Coordinate(LEGEND_SYMBOL_WIDTH / 2, LEGEND_ITEM_HEIGHT / 2); + return new Coordinate(LEGEND_SYMBOL_WIDTH / 2., LEGEND_ITEM_HEIGHT / 2.); } public SimpleFeature getSimpleFeature() { ===================================== client-datasource-editor-common/src/main/java/fr/ird/observe/client/datasource/editor/content/data/trip/map/TripMapContentBuilder.java ===================================== @@ -62,11 +62,14 @@ import java.io.IOException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.HashSet; +import java.util.LinkedList; import java.util.List; import java.util.Optional; import java.util.ServiceLoader; import java.util.Set; +import static io.ultreia.java4all.i18n.I18n.t; + /** * @author Tony Chemit - dev@tchemit.fr */ @@ -76,12 +79,14 @@ public abstract class TripMapContentBuilder { protected static final String TRIP_LOGBOOK_POINTS_LAYER_NAME = "Trip Logbook points"; protected static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd/MM"); - protected MapContent mapContent; + private static ImmutableSet<TripMapContentBuilder> PROVIDERS; + protected final List<ObserveMapPaneLegendItem> legendItems; + protected final List<TripMapPoint> notValidPoints = new LinkedList<>(); protected final Set<TripMapPointType> acceptedTripPointTypes; + protected MapContent mapContent; protected StyledLayerDescriptor styledLayerDescriptor; - private static ImmutableSet<TripMapContentBuilder> PROVIDERS; public abstract boolean accept(TripMapDto tripMapDto); @@ -121,7 +126,8 @@ public abstract class TripMapContentBuilder { private void reset() { legendItems.clear(); - mapContent=new MapContent(); + notValidPoints.clear(); + mapContent = new MapContent(); } protected TripMapContentBuilder(Set<TripMapPointType> acceptedTripPointTypes) { @@ -152,7 +158,7 @@ public abstract class TripMapContentBuilder { mapContent.addLayer(layer); } - public void addPoints(List<TripMapPoint> tripMapPoints, String layerName) throws FactoryException { + public void addPoints(List<TripMapPoint> tripMapPoints, String layerName, String notValidPointsLabel) throws FactoryException { GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(); @@ -171,8 +177,11 @@ public abstract class TripMapContentBuilder { Style stylePoints = findStyle(styledLayerDescriptor, layerName, null); Set<TripMapPointType> pointTypeInLegend = new HashSet<>(); - for (TripMapPoint tripMapPoint : tripMapPoints) { + if (!tripMapPoint.isValid()) { + notValidPoints.add(tripMapPoint); + continue; + } Coordinate coordinate = new Coordinate(tripMapPoint.getLongitude(), tripMapPoint.getLatitude()); TripMapPointType type = tripMapPoint.getType(); @@ -205,6 +214,19 @@ public abstract class TripMapContentBuilder { mapContent.addLayer(pointsLayer); } + if (!notValidPoints.isEmpty()) { + Point point = geometryFactory.createPoint(ObserveMapPaneLegendItem.pointCoordinates()); + pointBuilder.add(point); + pointBuilder.add(""); + pointBuilder.add("notValidPoint"); + + ObserveMapPaneLegendItem legendPoint = new ObserveMapPaneLegendItem( + pointBuilder.buildFeature(null), + stylePoints, + t(notValidPointsLabel, notValidPoints.size())); + legendItems.add(legendPoint); + } + } ===================================== client-datasource-editor-common/src/main/java/fr/ird/observe/client/datasource/editor/content/data/trip/map/TripMapUIHandler.java ===================================== @@ -94,7 +94,9 @@ public class TripMapUIHandler implements UIHandler<TripMapUI> { // set zoom tripArea = new ReferencedEnvelope(); for (TripMapPoint point : tripMapPoints) { - tripArea.expandToInclude(new DirectPosition2D(point.getLongitude(), point.getLatitude())); + if (point.isValid()) { + tripArea.expandToInclude(new DirectPosition2D(point.getLongitude(), point.getLatitude())); + } } tripArea.expandBy(1.1); ===================================== client-datasource-editor-common/src/main/map/ll-style.xml ===================================== @@ -118,7 +118,7 @@ <LineSymbolizer> <Stroke> <CssParameter name="stroke">#00FF00</CssParameter> - <CssParameter name="stroke-width">1</CssParameter> + <CssParameter name="stroke-width">2</CssParameter> <CssParameter name="stroke-dasharray">5 7</CssParameter> </Stroke> </LineSymbolizer> @@ -404,6 +404,33 @@ </TextSymbolizer> </Rule> </FeatureTypeStyle> + <FeatureTypeStyle> + <Rule> + <Name>Not valid observation point</Name> + <ogc:Filter> + <ogc:PropertyIsEqualTo> + <ogc:PropertyName>pointType</ogc:PropertyName> + <ogc:Literal>notValidPoint</ogc:Literal> + </ogc:PropertyIsEqualTo> + </ogc:Filter> + <PointSymbolizer> + <Graphic> + <Mark> + <WellKnownName>ttf://Serif#U+0021</WellKnownName> + <Fill> + <CssParameter name="fill">#00FF00</CssParameter> + </Fill> + <Stroke> + <CssParameter name="stroke">#000000</CssParameter> + <CssParameter name="stroke-width">1</CssParameter> + </Stroke> + </Mark> + <Size>12</Size> + </Graphic> + </PointSymbolizer> + </Rule> + </FeatureTypeStyle> + </UserStyle> </NamedLayer> @@ -596,6 +623,33 @@ </Rule> </FeatureTypeStyle> + <FeatureTypeStyle> + <Rule> + <Name>Not valid logbook point</Name> + <ogc:Filter> + <ogc:PropertyIsEqualTo> + <ogc:PropertyName>pointType</ogc:PropertyName> + <ogc:Literal>notValidPoint</ogc:Literal> + </ogc:PropertyIsEqualTo> + </ogc:Filter> + <PointSymbolizer> + <Graphic> + <Mark> + <WellKnownName>ttf://Serif#U+0021</WellKnownName> + <Fill> + <CssParameter name="fill">#FF0000</CssParameter> + </Fill> + <Stroke> + <CssParameter name="stroke">#000000</CssParameter> + <CssParameter name="stroke-width">1</CssParameter> + </Stroke> + </Mark> + <Size>12</Size> + </Graphic> + </PointSymbolizer> + </Rule> + </FeatureTypeStyle> + </UserStyle> </NamedLayer> ===================================== client-datasource-editor-common/src/main/map/ps-style.xml ===================================== @@ -196,6 +196,33 @@ </Rule> </FeatureTypeStyle> + <FeatureTypeStyle> + <Rule> + <Name>Not valid point</Name> + <ogc:Filter> + <ogc:PropertyIsEqualTo> + <ogc:PropertyName>pointType</ogc:PropertyName> + <ogc:Literal>notValidPoint</ogc:Literal> + </ogc:PropertyIsEqualTo> + </ogc:Filter> + <PointSymbolizer> + <Graphic> + <Mark> + <WellKnownName>ttf://Serif#U+0021</WellKnownName> + <Fill> + <CssParameter name="fill">#00FF00</CssParameter> + </Fill> + <Stroke> + <CssParameter name="stroke">#000000</CssParameter> + <CssParameter name="stroke-width">1</CssParameter> + </Stroke> + </Mark> + <Size>12</Size> + </Graphic> + </PointSymbolizer> + </Rule> + </FeatureTypeStyle> + </UserStyle> </NamedLayer> ===================================== client-datasource-editor-ll/src/main/i18n/getters/java.getter ===================================== @@ -317,6 +317,8 @@ observe.data.ll.observation.WeightMeasure.table.weight.tip observe.data.ll.observation.WeightMeasure.table.weightMeasureType observe.data.ll.observation.WeightMeasure.table.weightMeasureType.tip observe.data.ps.common.GearUseFeatures.delete +observe.map.logbook.points.not.valid +observe.map.observation.points.not.valid observe.menu.navigation.action.move.activityLongline observe.menu.navigation.action.move.sample observe.menu.navigation.action.move.sample.choice ===================================== client-datasource-editor-ll/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ll/common/TripMapContentBuilder.java ===================================== @@ -51,6 +51,7 @@ import java.util.LinkedList; import java.util.List; import java.util.stream.Collectors; +import static io.ultreia.java4all.i18n.I18n.n; import static io.ultreia.java4all.i18n.I18n.t; /** @@ -106,8 +107,8 @@ public class TripMapContentBuilder extends fr.ird.observe.client.datasource.edit @Override protected void addPoints(List<TripMapPoint> tripMapPoints) throws FactoryException { - addPoints(tripMapPoints.stream().filter(f->f.getType().isTrip() || f.getType().isObs()).collect(Collectors.toList()), TRIP_OBS_POINTS_LAYER_NAME); - addPoints(tripMapPoints.stream().filter(f->f.getType().isTrip() || f.getType().isLogbook()).collect(Collectors.toList()), TRIP_LOGBOOK_POINTS_LAYER_NAME); + addPoints(tripMapPoints.stream().filter(f -> f.getType().isTrip() || f.getType().isObs()).collect(Collectors.toList()), TRIP_OBS_POINTS_LAYER_NAME, n("observe.map.observation.points.not.valid")); + addPoints(tripMapPoints.stream().filter(f -> f.getType().isTrip() || f.getType().isLogbook()).collect(Collectors.toList()), TRIP_LOGBOOK_POINTS_LAYER_NAME, n("observe.map.logbook.points.not.valid")); } private void addLonglineObsFishingZone(List<TripMapPoint> tripMapPoints) throws FactoryException { @@ -126,24 +127,31 @@ public class TripMapContentBuilder extends fr.ird.observe.client.datasource.edit DefaultFeatureCollection polygonsFeatures = new DefaultFeatureCollection(); for (int indexPoint = 3; indexPoint < tripMapPoints.size(); indexPoint++) { - if (tripMapPoints.get(indexPoint).getType().equals(TripMapPointType.llActivityObsWithHaulingEnd) - && tripMapPoints.get(indexPoint - 1).getType().equals(TripMapPointType.llActivityObsWithHaulingStart) - && tripMapPoints.get(indexPoint - 2).getType().equals(TripMapPointType.llActivityObsWithSettingEnd) - && tripMapPoints.get(indexPoint - 3).getType().equals(TripMapPointType.llActivityObsWithSettingStart)) { + TripMapPoint tripMapPoint = tripMapPoints.get(indexPoint); + TripMapPoint tripMapPoint1 = tripMapPoints.get(indexPoint - 1); + TripMapPoint tripMapPoint2 = tripMapPoints.get(indexPoint - 2); + TripMapPoint tripMapPoint3 = tripMapPoints.get(indexPoint - 3); + if (!(tripMapPoint.isValid()&& tripMapPoint1.isValid() && tripMapPoint2.isValid() && tripMapPoint3.isValid())) { + continue; + } + if (tripMapPoint.getType().equals(TripMapPointType.llActivityObsWithHaulingEnd) + && tripMapPoint1.getType().equals(TripMapPointType.llActivityObsWithHaulingStart) + && tripMapPoint2.getType().equals(TripMapPointType.llActivityObsWithSettingEnd) + && tripMapPoint3.getType().equals(TripMapPointType.llActivityObsWithSettingStart)) { Coordinate[] coordinates = { - new Coordinate(tripMapPoints.get(indexPoint - 3).getLongitude(), tripMapPoints.get(indexPoint - 3).getLatitude()), - new Coordinate(tripMapPoints.get(indexPoint - 2).getLongitude(), tripMapPoints.get(indexPoint - 2).getLatitude()), - new Coordinate(tripMapPoints.get(indexPoint - 1).getLongitude(), tripMapPoints.get(indexPoint - 1).getLatitude()), - new Coordinate(tripMapPoints.get(indexPoint).getLongitude(), tripMapPoints.get(indexPoint).getLatitude()), - new Coordinate(tripMapPoints.get(indexPoint - 3).getLongitude(), tripMapPoints.get(indexPoint - 3).getLatitude()) + new Coordinate(tripMapPoint3.getLongitude(), tripMapPoint3.getLatitude()), + new Coordinate(tripMapPoint2.getLongitude(), tripMapPoint2.getLatitude()), + new Coordinate(tripMapPoint1.getLongitude(), tripMapPoint1.getLatitude()), + new Coordinate(tripMapPoint.getLongitude(), tripMapPoint.getLatitude()), + new Coordinate(tripMapPoint3.getLongitude(), tripMapPoint3.getLatitude()) }; Polygon polygon = geometryFactory.createPolygon(coordinates); //polygon = (Polygon) polygon.convexHull(); // permet de transformer un poliqgone croisé en polygon convex polygonBuilder.add(polygon); - polygonBuilder.add(DATE_FORMAT.format(tripMapPoints.get(indexPoint - 3).getTime())); + polygonBuilder.add(DATE_FORMAT.format(tripMapPoint3.getTime())); polygonBuilder.add("longlineFishingZone"); SimpleFeature feature = polygonBuilder.buildFeature(null); polygonsFeatures.add(feature); @@ -174,24 +182,31 @@ public class TripMapContentBuilder extends fr.ird.observe.client.datasource.edit DefaultFeatureCollection polygonsFeatures = new DefaultFeatureCollection(); for (int indexPoint = 3; indexPoint < tripMapPoints.size(); indexPoint++) { - if (tripMapPoints.get(indexPoint).getType().equals(TripMapPointType.llActivityLogbookWithHaulingEnd) - && tripMapPoints.get(indexPoint - 1).getType().equals(TripMapPointType.llActivityLogbookWithHaulingStart) - && tripMapPoints.get(indexPoint - 2).getType().equals(TripMapPointType.llActivityLogbookWithSettingEnd) - && tripMapPoints.get(indexPoint - 3).getType().equals(TripMapPointType.llActivityLogbookWithSettingStart)) { + TripMapPoint tripMapPoint = tripMapPoints.get(indexPoint); + TripMapPoint tripMapPoint1 = tripMapPoints.get(indexPoint - 1); + TripMapPoint tripMapPoint2 = tripMapPoints.get(indexPoint - 2); + TripMapPoint tripMapPoint3 = tripMapPoints.get(indexPoint - 3); + if (!(tripMapPoint.isValid()&& tripMapPoint1.isValid() && tripMapPoint2.isValid() && tripMapPoint3.isValid())) { + continue; + } + if (tripMapPoint.getType().equals(TripMapPointType.llActivityLogbookWithHaulingEnd) + && tripMapPoint1.getType().equals(TripMapPointType.llActivityLogbookWithHaulingStart) + && tripMapPoint2.getType().equals(TripMapPointType.llActivityLogbookWithSettingEnd) + && tripMapPoint3.getType().equals(TripMapPointType.llActivityLogbookWithSettingStart)) { Coordinate[] coordinates = { - new Coordinate(tripMapPoints.get(indexPoint - 3).getLongitude(), tripMapPoints.get(indexPoint - 3).getLatitude()), - new Coordinate(tripMapPoints.get(indexPoint - 2).getLongitude(), tripMapPoints.get(indexPoint - 2).getLatitude()), - new Coordinate(tripMapPoints.get(indexPoint - 1).getLongitude(), tripMapPoints.get(indexPoint - 1).getLatitude()), - new Coordinate(tripMapPoints.get(indexPoint).getLongitude(), tripMapPoints.get(indexPoint).getLatitude()), - new Coordinate(tripMapPoints.get(indexPoint - 3).getLongitude(), tripMapPoints.get(indexPoint - 3).getLatitude()) + new Coordinate(tripMapPoint3.getLongitude(), tripMapPoint3.getLatitude()), + new Coordinate(tripMapPoint2.getLongitude(), tripMapPoint2.getLatitude()), + new Coordinate(tripMapPoint1.getLongitude(), tripMapPoint1.getLatitude()), + new Coordinate(tripMapPoint.getLongitude(), tripMapPoint.getLatitude()), + new Coordinate(tripMapPoint3.getLongitude(), tripMapPoint3.getLatitude()) }; Polygon polygon = geometryFactory.createPolygon(coordinates); //polygon = (Polygon) polygon.convexHull(); // permet de transformer un poliqgone croisé en polygon convex polygonBuilder.add(polygon); - polygonBuilder.add(DATE_FORMAT.format(tripMapPoints.get(indexPoint - 3).getTime())); + polygonBuilder.add(DATE_FORMAT.format(tripMapPoint3.getTime())); polygonBuilder.add("longlineFishingZone"); SimpleFeature feature = polygonBuilder.buildFeature(null); polygonsFeatures.add(feature); @@ -223,35 +238,44 @@ public class TripMapContentBuilder extends fr.ird.observe.client.datasource.edit List<Coordinate> defaultLineCoordinates = new LinkedList<>(); boolean found = false; for (int indexPoint = 0; indexPoint < tripMapPoints.size(); indexPoint++) { - if (indexPoint > 1 && tripMapPoints.get(indexPoint).getType().equals(TripMapPointType.llActivityObsWithSettingEnd) - && tripMapPoints.get(indexPoint - 1).getType().equals(TripMapPointType.llActivityObsWithSettingStart) - || tripMapPoints.get(indexPoint).getType().equals(TripMapPointType.llActivityObsWithHaulingEnd) - && tripMapPoints.get(indexPoint - 1).getType().equals(TripMapPointType.llActivityObsWithHaulingStart)) { - - found = true; - Coordinate[] coordinates = { - new Coordinate(tripMapPoints.get(indexPoint - 1).getLongitude(), tripMapPoints.get(indexPoint - 1).getLatitude()), - new Coordinate(tripMapPoints.get(indexPoint).getLongitude(), tripMapPoints.get(indexPoint).getLatitude()), - }; - - boolean setting = tripMapPoints.get(indexPoint).getType().equals(TripMapPointType.llActivityObsWithSettingEnd); - LineString lineString = geometryFactory.createLineString(coordinates); - lineBuilder.add(lineString); - lineBuilder.add(setting ? "setting" : "hauling"); - SimpleFeature feature = lineBuilder.buildFeature(null); - linesFeatures.add(feature); - - defaultLineCoordinates.clear(); + TripMapPoint tripMapPoint = tripMapPoints.get(indexPoint); + TripMapPointType pointType = tripMapPoint.getType(); + if (tripMapPoint.isValid() && indexPoint > 1) { + + TripMapPoint previousTripMapPoint = tripMapPoints.get(indexPoint - 1); + TripMapPointType previousTripMapPointType = previousTripMapPoint.getType(); + if (previousTripMapPoint.isValid()) { + if ( + pointType.equals(TripMapPointType.llActivityObsWithSettingEnd) && previousTripMapPointType.equals(TripMapPointType.llActivityObsWithSettingStart) + || + pointType.equals(TripMapPointType.llActivityObsWithHaulingEnd) && previousTripMapPointType.equals(TripMapPointType.llActivityObsWithHaulingStart)) { + + found = true; + Coordinate[] coordinates = { + new Coordinate(previousTripMapPoint.getLongitude(), previousTripMapPoint.getLatitude()), + new Coordinate(tripMapPoint.getLongitude(), tripMapPoint.getLatitude()), + }; + + boolean setting = pointType.equals(TripMapPointType.llActivityObsWithSettingEnd); + LineString lineString = geometryFactory.createLineString(coordinates); + lineBuilder.add(lineString); + lineBuilder.add(setting ? "setting" : "hauling"); + SimpleFeature feature = lineBuilder.buildFeature(null); + linesFeatures.add(feature); + + defaultLineCoordinates.clear(); + } + } } - if (!(tripMapPoints.get(indexPoint).getType().equals(TripMapPointType.llActivityObsWithSettingEnd) - || tripMapPoints.get(indexPoint).getType().equals(TripMapPointType.llActivityObsWithHaulingStart))) { + if (tripMapPoint.isValid() && !(pointType.equals(TripMapPointType.llActivityObsWithSettingEnd) + || pointType.equals(TripMapPointType.llActivityObsWithHaulingStart))) { - defaultLineCoordinates.add(new Coordinate(tripMapPoints.get(indexPoint).getLongitude(), tripMapPoints.get(indexPoint).getLatitude())); + defaultLineCoordinates.add(new Coordinate(tripMapPoint.getLongitude(), tripMapPoint.getLatitude())); } - if ((tripMapPoints.get(indexPoint).getType().equals(TripMapPointType.llActivityObsWithSettingStart) + if ((pointType.equals(TripMapPointType.llActivityObsWithSettingStart) || indexPoint == tripMapPoints.size() - 1) && defaultLineCoordinates.size() > 1) { LineString lineString = geometryFactory.createLineString(defaultLineCoordinates.toArray(new Coordinate[0])); @@ -315,34 +339,40 @@ public class TripMapContentBuilder extends fr.ird.observe.client.datasource.edit List<Coordinate> defaultLineCoordinates = new LinkedList<>(); boolean found = false; for (int indexPoint = 0; indexPoint < tripMapPoints.size(); indexPoint++) { - if (indexPoint > 1 && tripMapPoints.get(indexPoint).getType().equals(TripMapPointType.llActivityLogbookWithSettingEnd) - && tripMapPoints.get(indexPoint - 1).getType().equals(TripMapPointType.llActivityLogbookWithSettingStart) - || tripMapPoints.get(indexPoint).getType().equals(TripMapPointType.llActivityLogbookWithHaulingEnd) - && tripMapPoints.get(indexPoint - 1).getType().equals(TripMapPointType.llActivityLogbookWithHaulingStart)) { - found = true; - Coordinate[] coordinates = { - new Coordinate(tripMapPoints.get(indexPoint - 1).getLongitude(), tripMapPoints.get(indexPoint - 1).getLatitude()), - new Coordinate(tripMapPoints.get(indexPoint).getLongitude(), tripMapPoints.get(indexPoint).getLatitude()), - }; - - boolean setting = tripMapPoints.get(indexPoint).getType().equals(TripMapPointType.llActivityLogbookWithSettingEnd); - LineString lineString = geometryFactory.createLineString(coordinates); - lineBuilder.add(lineString); - lineBuilder.add(setting ? "setting" : "hauling"); - SimpleFeature feature = lineBuilder.buildFeature(null); - linesFeatures.add(feature); - - defaultLineCoordinates.clear(); + TripMapPoint tripMapPoint = tripMapPoints.get(indexPoint); + TripMapPointType tripMapPointType = tripMapPoint.getType(); + if (tripMapPoint.isValid() && indexPoint > 1) { + TripMapPoint previousTripMapPoint = tripMapPoints.get(indexPoint - 1); + if (previousTripMapPoint.isValid()) { + TripMapPointType previousTripMapPointType = previousTripMapPoint.getType(); + if (tripMapPointType.equals(TripMapPointType.llActivityLogbookWithSettingEnd) + && previousTripMapPointType.equals(TripMapPointType.llActivityLogbookWithSettingStart) + || tripMapPointType.equals(TripMapPointType.llActivityLogbookWithHaulingEnd) + && previousTripMapPointType.equals(TripMapPointType.llActivityLogbookWithHaulingStart)) { + found = true; + Coordinate[] coordinates = { + new Coordinate(previousTripMapPoint.getLongitude(), previousTripMapPoint.getLatitude()), + new Coordinate(tripMapPoint.getLongitude(), tripMapPoint.getLatitude()), + }; + + boolean setting = tripMapPointType.equals(TripMapPointType.llActivityLogbookWithSettingEnd); + LineString lineString = geometryFactory.createLineString(coordinates); + lineBuilder.add(lineString); + lineBuilder.add(setting ? "setting" : "hauling"); + SimpleFeature feature = lineBuilder.buildFeature(null); + linesFeatures.add(feature); + + defaultLineCoordinates.clear(); + } + } } - - if (!(tripMapPoints.get(indexPoint).getType().equals(TripMapPointType.llActivityLogbookWithSettingEnd) - || tripMapPoints.get(indexPoint).getType().equals(TripMapPointType.llActivityLogbookWithHaulingStart))) { - - defaultLineCoordinates.add(new Coordinate(tripMapPoints.get(indexPoint).getLongitude(), tripMapPoints.get(indexPoint).getLatitude())); + if (tripMapPoint.isValid() && + !(tripMapPointType.equals(TripMapPointType.llActivityLogbookWithSettingEnd) || tripMapPointType.equals(TripMapPointType.llActivityLogbookWithHaulingStart))) { + defaultLineCoordinates.add(new Coordinate(tripMapPoint.getLongitude(), tripMapPoint.getLatitude())); } - if ((tripMapPoints.get(indexPoint).getType().equals(TripMapPointType.llActivityLogbookWithSettingStart) + if ((tripMapPointType.equals(TripMapPointType.llActivityLogbookWithSettingStart) || indexPoint == tripMapPoints.size() - 1) && defaultLineCoordinates.size() > 1) { LineString lineString = geometryFactory.createLineString(defaultLineCoordinates.toArray(new Coordinate[0])); ===================================== client-datasource-editor-ps/src/main/i18n/getters/java.getter ===================================== @@ -171,6 +171,7 @@ observe.data.ps.observation.TargetLength.table.species observe.data.ps.observation.TargetLength.table.species.tip observe.data.ps.observation.TargetLength.table.totalWeight observe.data.ps.observation.TargetLength.table.totalWeight.tip +observe.map.observation.points.not.valid observe.menu.navigation.action.move.activity observe.menu.navigation.action.move.route observe.menu.navigation.action.move.trip ===================================== client-datasource-editor-ps/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ps/common/TripMapContentBuilder.java ===================================== @@ -51,6 +51,7 @@ import java.text.DateFormat; import java.util.LinkedList; import java.util.List; +import static io.ultreia.java4all.i18n.I18n.n; import static io.ultreia.java4all.i18n.I18n.t; /** @@ -85,8 +86,7 @@ public class TripMapContentBuilder extends fr.ird.observe.client.datasource.edit @Override protected void addPoints(List<TripMapPoint> tripMapPoints) throws FactoryException { - addPoints(tripMapPoints, TRIP_OBS_POINTS_LAYER_NAME); -// addPoints(tripMapPoints, TRIP_LOGBOOK_POINTS_LAYER_NAME); + addPoints(tripMapPoints, TRIP_OBS_POINTS_LAYER_NAME, n("observe.map.observation.points.not.valid")); } @Override ===================================== dto/src/main/java/fr/ird/observe/dto/data/TripMapPoint.java ===================================== @@ -22,29 +22,33 @@ package fr.ird.observe.dto.data; * #L% */ -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"; +import fr.ird.observe.dto.ObserveDto; - public static final String PROPERTY_LONGITUDE = "longitude"; - - public static final String PROPERTY_TYPE = "type"; - - private static final long serialVersionUID = 1L; +import java.util.Date; +import java.util.Objects; + +public class TripMapPoint implements ObserveDto { + + public static TripMapPoint of(TripMapPointType type, Date time, Float latitude, Float longitude) { + TripMapPoint result = new TripMapPoint(); + result.setType(Objects.requireNonNull(type)); + result.setTime(time); + result.setLatitude(latitude); + result.setLongitude(longitude); + result.setValid(time != null && latitude != null && longitude != null); + return result; + } protected Date time; - protected float latitude; + protected Float latitude; - protected float longitude; + protected Float longitude; protected TripMapPointType type; + protected boolean valid; + public Date getTime() { return time; } @@ -53,19 +57,19 @@ public class TripMapPoint implements Serializable { this.time = time; } - public float getLatitude() { + public Float getLatitude() { return latitude; } - public void setLatitude(float latitude) { + public void setLatitude(Float latitude) { this.latitude = latitude; } - public float getLongitude() { + public Float getLongitude() { return longitude; } - public void setLongitude(float longitude) { + public void setLongitude(Float longitude) { this.longitude = longitude; } @@ -76,4 +80,12 @@ public class TripMapPoint implements Serializable { public void setType(TripMapPointType type) { this.type = type; } + + public boolean isValid() { + return valid; + } + + public void setValid(boolean valid) { + this.valid = valid; + } } ===================================== dto/src/main/java/fr/ird/observe/spi/DtoModelClasses.java ===================================== @@ -28,6 +28,8 @@ import fr.ird.observe.dto.referential.ReferentialDto; import fr.ird.observe.dto.referential.ll.common.HealthStatusDto; import fr.ird.observe.dto.referential.ll.observation.StomachFullnessDto; +import java.util.function.Predicate; + /** * Created by tchemit on 03/09/17. * @@ -35,6 +37,9 @@ import fr.ird.observe.dto.referential.ll.observation.StomachFullnessDto; */ public class DtoModelClasses { + public static final Predicate<String> IS_SEINE_ID = DtoModelClasses::isSeineId; + public static final Predicate<String> IS_LONGLINE_ID = DtoModelClasses::isLonglineId; + public static final ImmutableSet<Class<? extends ReferentialDto>> COMMON_REFERENTIAL_TYPES = ImmutableSet.of( fr.ird.observe.dto.referential.common.VesselSizeCategoryDto.class, fr.ird.observe.dto.referential.common.CountryDto.class, @@ -87,7 +92,7 @@ public class DtoModelClasses { fr.ird.observe.dto.referential.ps.observation.ReasonForDiscardDto.class, fr.ird.observe.dto.referential.ps.observation.SpeciesStatusDto.class, fr.ird.observe.dto.referential.ps.observation.ObservedSystemDto.class - ); + ); public static final ImmutableSet<Class<? extends ReferentialDto>> SEINE_REFERENTIAL_TYPES = ImmutableSet.<Class<? extends ReferentialDto>>builder() .addAll(SEINE_COMMON_REFERENTIAL_TYPES) @@ -141,7 +146,6 @@ public class DtoModelClasses { .addAll(SEINE_REFERENTIAL_TYPES) .addAll(LONGLINE_REFERENTIAL_TYPES) .build(); - private static final ImmutableSet<Class<? extends DataDto>> SEINE_ENTITY_DATA_TYPES = ImmutableSet.of( fr.ird.observe.dto.data.ps.observation.ActivityDto.class, fr.ird.observe.dto.data.ps.observation.FloatingObjectDto.class, ===================================== observe-i18n/src/main/i18n/translations/observe_en_GB.properties ===================================== @@ -2324,6 +2324,8 @@ observe.init.local.db.error=Could not find local database, will load last backup observe.init.no.initial.dump.detected=Internal data source %1$s not detected. observe.init.no.local.db.detected=Local data source %1$s not detected. observe.init.storage.done=Init of Persistent Service done. +observe.map.logbook.points.not.valid=LogBook - Number of none displayed points\: %d +observe.map.observation.points.not.valid=Observation - Number of none displayed points\: %d observe.menu.actions=Actions observe.menu.configuration=Configuration observe.menu.configuration.tip=To configure application ===================================== observe-i18n/src/main/i18n/translations/observe_es_ES.properties ===================================== @@ -2324,6 +2324,8 @@ observe.init.local.db.error=Imposible cargar la base local, se cargará el últi observe.init.no.initial.dump.detected=fuente de datos interna %1$s no detectada. observe.init.no.local.db.detected=Base local %1$s no detectada. observe.init.storage.done=Inicialización del servicio de persistencia terminado. +observe.map.logbook.points.not.valid=LogBook - Number of none displayed points\: %d \#TODO +observe.map.observation.points.not.valid=Observation - Number of none displayed points\: %d \#TODO observe.menu.actions=Acciones observe.menu.configuration=Configuración observe.menu.configuration.tip=Menú de configuración ===================================== observe-i18n/src/main/i18n/translations/observe_fr_FR.properties ===================================== @@ -2324,6 +2324,8 @@ observe.init.local.db.error=Impossible de charger la base locale, la dernière s observe.init.no.initial.dump.detected=Base embarquée %1$s non détectée. observe.init.no.local.db.detected=Base locale %1$s non détectée. observe.init.storage.done=Initialisation du service de persistance terminé. +observe.map.logbook.points.not.valid=Libre de bord - Nombre de points non affichés \: %d +observe.map.observation.points.not.valid=Observation - Nombre de points non affichés \: %d observe.menu.actions=Actions observe.menu.configuration=Configuration observe.menu.configuration.tip=Menu de configuration ===================================== persistence/src/main/java/fr/ird/observe/entities/Entities.java ===================================== @@ -22,10 +22,17 @@ package fr.ird.observe.entities; * #L% */ +import fr.ird.observe.dto.data.TripMapPoint; +import fr.ird.observe.dto.data.TripMapPointType; +import fr.ird.observe.entities.referential.common.Harbour; + +import java.sql.ResultSet; +import java.sql.SQLException; import java.util.Arrays; import java.util.Collections; +import java.util.Date; import java.util.List; -import java.util.function.Predicate; +import java.util.Optional; /** * Created on 8/27/14. @@ -122,15 +129,28 @@ public class Entities { }; public static final List<ObserveEntityEnum> REFERENCE_ENTITIES_LIST = Collections.unmodifiableList(Arrays.asList(REFERENCE_ENTITIES)); - public static final Predicate<String> IS_SEINE_ID = Entities::isSeineId; - public static final Predicate<String> IS_LONGLINE_ID = Entities::isLonglineId; - public static boolean isSeineId(String id) { - return id.contains(".ps."); + public static Float getFloat(ResultSet resultSet, int columnIndex) throws SQLException { + float result = resultSet.getFloat(columnIndex); + return resultSet.wasNull() ? null : result; + } + + public static Optional<TripMapPoint> createHarbourPoint(Harbour harbour, Date date, TripMapPointType tripMapPointType) { + TripMapPoint result = null; + if (harbour != null) { + result = TripMapPoint.of(tripMapPointType, date, harbour.getLatitude(), harbour.getLongitude()); + } + return Optional.ofNullable(result); } - public static boolean isLonglineId(String id) { - return id.contains(".ll."); + public static TripMapPoint createPoint(TripMapPointType type, Date dateTime, ResultSet resultSet, int columnIndex) throws SQLException { + Float latitude = getFloat(resultSet, columnIndex); + Float longitude = getFloat(resultSet, columnIndex + 1); + return TripMapPoint.of(type, dateTime, latitude, longitude); } + public static TripMapPoint createPoint(TripMapPointType type, ResultSet resultSet, int dateColumnIndex) throws SQLException { + java.sql.Date date = resultSet.getDate(dateColumnIndex); + return createPoint(type, date, resultSet, dateColumnIndex + 1); + } } ===================================== persistence/src/main/java/fr/ird/observe/entities/data/ll/common/TripTopiaDao.java ===================================== @@ -26,7 +26,7 @@ import com.google.common.collect.ImmutableMap; import fr.ird.observe.dto.data.TripMapConfigDto; import fr.ird.observe.dto.data.TripMapPoint; import fr.ird.observe.dto.data.TripMapPointType; -import fr.ird.observe.entities.referential.common.Harbour; +import fr.ird.observe.entities.Entities; import org.nuiton.topia.persistence.support.TopiaSqlQuery; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import org.nuiton.util.DateUtil; @@ -42,7 +42,6 @@ import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.Objects; -import java.util.Optional; import java.util.stream.Collectors; public class TripTopiaDao extends AbstractTripTopiaDao<Trip> { @@ -57,7 +56,7 @@ public class TripTopiaDao extends AbstractTripTopiaDao<Trip> { LinkedHashSet<TripMapPoint> tripMapPoints = new LinkedHashSet<>(); // add departure harbour - createPoint(trip.getDepartureHarbour(), trip.getStartDate(), TripMapPointType.llTripDepartureHarbour).map(tripMapPoints::add); + Entities.createHarbourPoint(trip.getDepartureHarbour(), trip.getStartDate(), TripMapPointType.llTripDepartureHarbour).map(tripMapPoints::add); if (addObservation) { // Add Activities Observation @@ -73,7 +72,7 @@ public class TripTopiaDao extends AbstractTripTopiaDao<Trip> { } // add landing harbour - createPoint(trip.getLandingHarbour(), trip.getEndDate(), TripMapPointType.llTripLandingHarbour).map(tripMapPoints::add); + Entities.createHarbourPoint(trip.getLandingHarbour(), trip.getEndDate(), TripMapPointType.llTripLandingHarbour).map(tripMapPoints::add); return tripMapPoints; } @@ -128,10 +127,10 @@ public class TripTopiaDao extends AbstractTripTopiaDao<Trip> { return Collections.emptyList(); } return this. - <Trip>stream("From TripImpl Where vessel.id = :vesselId " + - "And (( :startDate <= endDate And :endDate >= endDate ) " + - " Or ( :endDate <= startDate And :endDate >= startDate )) " + - "Order By startDate, endDate", ImmutableMap.of( + <Trip>stream("From fr.ird.observe.entities.data.ll.common.TripImpl Where vessel.id = :vesselId " + + "And (( :startDate <= endDate And :endDate >= endDate ) " + + " Or ( :endDate <= startDate And :endDate >= startDate )) " + + "Order By startDate, endDate", ImmutableMap.of( "vesselId", vesselId, "startDate", startDate, "endDate", endDate)) @@ -146,6 +145,7 @@ public class TripTopiaDao extends AbstractTripTopiaDao<Trip> { " a.latitude," + " a.longitude," + " a.vesselActivity," + + " s.topiaId," + " s.settingStartTimestamp," + " s.settingStartLatitude," + " s.settingStartLongitude," + @@ -184,26 +184,32 @@ public class TripTopiaDao extends AbstractTripTopiaDao<Trip> { if (resultSet.getString(5) == null) { // simple activity - Optional<TripMapPoint> activity = createPoint(resultSet, 1, TripMapPointType.llActivityObs); - activity.ifPresent(result::add); + TripMapPoint activity = Entities.createPoint(TripMapPointType.llActivityObs, resultSet, 1); + result.add(activity); } // settingStart - Optional<TripMapPoint> settingStart = createPoint(resultSet, 5, TripMapPointType.llActivityObsWithSettingStart); - settingStart.ifPresent(result::add); + TripMapPoint settingStart = Entities.createPoint(TripMapPointType.llActivityObsWithSettingStart, resultSet, 6); + result.add(settingStart); // settingEnd - Optional<TripMapPoint> settingEnd = createPoint(resultSet, 8, TripMapPointType.llActivityObsWithSettingEnd); - settingEnd.ifPresent(result::add); + TripMapPoint settingEnd = Entities.createPoint(TripMapPointType.llActivityObsWithSettingEnd, resultSet, 9); + result.add(settingEnd); // haulingStart - Optional<TripMapPoint> haulingStart = createPoint(resultSet, 11, TripMapPointType.llActivityObsWithHaulingStart); - haulingStart.ifPresent(result::add); + TripMapPoint haulingStart = Entities.createPoint(TripMapPointType.llActivityObsWithHaulingStart, resultSet, 12); + result.add(haulingStart); // haulingEnd - Optional<TripMapPoint> haulingEnd = createPoint(resultSet, 14, TripMapPointType.llActivityObsWithHaulingEnd); - haulingEnd.ifPresent(result::add); - + TripMapPoint haulingEnd = Entities.createPoint(TripMapPointType.llActivityObsWithHaulingEnd, resultSet, 15); + result.add(haulingEnd); + + if (!(settingStart.isValid() && settingEnd.isValid() && haulingStart.isValid() && haulingEnd.isValid())) { + settingStart.setValid(false); + settingEnd.setValid(false); + haulingStart.setValid(false); + haulingEnd.setValid(false); + } return result; } } @@ -215,6 +221,7 @@ public class TripTopiaDao extends AbstractTripTopiaDao<Trip> { " a.latitude," + " a.longitude," + " a.vesselActivity," + + " s.topiaId," + " s.settingStartTimestamp," + " s.settingStartLatitude," + " s.settingStartLongitude," + @@ -253,25 +260,32 @@ public class TripTopiaDao extends AbstractTripTopiaDao<Trip> { if (resultSet.getString(5) == null) { // simple activity - Optional<TripMapPoint> activity = createPoint(resultSet, 1, TripMapPointType.llActivityLogbook); - activity.ifPresent(result::add); + TripMapPoint activity = Entities.createPoint(TripMapPointType.llActivityLogbook, resultSet, 1); + result.add(activity); } // settingStart - Optional<TripMapPoint> settingStart = createPoint(resultSet, 5, TripMapPointType.llActivityLogbookWithSettingStart); - settingStart.ifPresent(result::add); + TripMapPoint settingStart = Entities.createPoint(TripMapPointType.llActivityLogbookWithSettingStart, resultSet, 6); + result.add(settingStart); // settingEnd - Optional<TripMapPoint> settingEnd = createPoint(resultSet, 8, TripMapPointType.llActivityLogbookWithSettingEnd); - settingEnd.ifPresent(result::add); + TripMapPoint settingEnd = Entities.createPoint(TripMapPointType.llActivityLogbookWithSettingEnd, resultSet, 9); + result.add(settingEnd); // haulingStart - Optional<TripMapPoint> haulingStart = createPoint(resultSet, 11, TripMapPointType.llActivityLogbookWithHaulingStart); - haulingStart.ifPresent(result::add); + TripMapPoint haulingStart = Entities.createPoint(TripMapPointType.llActivityLogbookWithHaulingStart, resultSet, 12); + result.add(haulingStart); // haulingEnd - Optional<TripMapPoint> haulingEnd = createPoint(resultSet, 14, TripMapPointType.llActivityLogbookWithHaulingEnd); - haulingEnd.ifPresent(result::add); + TripMapPoint haulingEnd = Entities.createPoint(TripMapPointType.llActivityLogbookWithHaulingEnd, resultSet, 15); + result.add(haulingEnd); + + if (!(settingStart.isValid() && settingEnd.isValid() && haulingStart.isValid() && haulingEnd.isValid())) { + settingStart.setValid(false); + settingEnd.setValid(false); + haulingStart.setValid(false); + haulingEnd.setValid(false); + } return result; } @@ -315,29 +329,4 @@ public class TripTopiaDao extends AbstractTripTopiaDao<Trip> { } - private static Optional<TripMapPoint> createPoint(Harbour harbour, Date date, TripMapPointType tripMapPointType) { - TripMapPoint result = null; - if (harbour != null && harbour.getLatitude() != null && harbour.getLongitude() != null) { - result = new TripMapPoint(); - result.setTime(date); - result.setLatitude(harbour.getLatitude()); - result.setLongitude(harbour.getLongitude()); - result.setType(tripMapPointType); - } - return Optional.ofNullable(result); - } - - private static Optional<TripMapPoint> createPoint(ResultSet resultSet, int dateColumnIndex, TripMapPointType tripMapPointType) throws SQLException { - - TripMapPoint result = null; - if (resultSet.getString(dateColumnIndex) != null) { - result = new TripMapPoint(); - result.setTime(resultSet.getDate(dateColumnIndex)); - result.setLatitude(resultSet.getFloat(dateColumnIndex + 1)); - result.setLongitude(resultSet.getFloat(dateColumnIndex + 2)); - result.setType(tripMapPointType); - } - return Optional.ofNullable(result); - } - } ===================================== persistence/src/main/java/fr/ird/observe/entities/data/ps/common/TripTopiaDao.java ===================================== @@ -26,7 +26,7 @@ import fr.ird.observe.dto.ProtectedIds; import fr.ird.observe.dto.data.TripMapConfigDto; import fr.ird.observe.dto.data.TripMapPoint; import fr.ird.observe.dto.data.TripMapPointType; -import fr.ird.observe.entities.referential.common.Harbour; +import fr.ird.observe.entities.Entities; import org.nuiton.topia.persistence.support.TopiaSqlQuery; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import org.nuiton.util.DateUtil; @@ -40,7 +40,6 @@ import java.util.Date; import java.util.LinkedHashSet; import java.util.List; import java.util.Objects; -import java.util.Optional; import java.util.stream.Collectors; /** @@ -58,14 +57,14 @@ public class TripTopiaDao extends AbstractTripTopiaDao<Trip> { LinkedHashSet<TripMapPoint> tripMapPoints = new LinkedHashSet<>(); // add departure harbour - createPoint(trip.getDepartureHarbour(), trip.getStartDate(), TripMapPointType.psTripDepartureHarbour).map(tripMapPoints::add); + Entities.createHarbourPoint(trip.getDepartureHarbour(), trip.getStartDate(), TripMapPointType.psTripDepartureHarbour).map(tripMapPoints::add); // Add Activities TripMapActivityPointQuery tripMapActivityPointQuery = new TripMapActivityPointQuery(tripId); tripMapPoints.addAll(topiaSqlSupport.findMultipleResult(tripMapActivityPointQuery)); // add landing harbour - createPoint(trip.getLandingHarbour(), trip.getEndDate(), TripMapPointType.psTripLandingHarbour).map(tripMapPoints::add); + Entities.createHarbourPoint(trip.getLandingHarbour(), trip.getEndDate(), TripMapPointType.psTripLandingHarbour).map(tripMapPoints::add); return tripMapPoints; } @@ -75,7 +74,7 @@ public class TripTopiaDao extends AbstractTripTopiaDao<Trip> { return Collections.emptyList(); } return this. - <Trip>stream("From TripImpl Where vessel.id = :vesselId " + + <Trip>stream("From fr.ird.observe.entities.data.ps.common.TripImpl Where vessel.id = :vesselId " + "And (( :startDate <= endDate And :endDate >= endDate ) " + " Or ( :endDate <= startDate And :endDate >= startDate )) " + "Order By startDate, endDate", ImmutableMap.of( @@ -119,32 +118,32 @@ public class TripTopiaDao extends AbstractTripTopiaDao<Trip> { @Override public TripMapPoint prepareResult(ResultSet resultSet) throws SQLException { - 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)); + TripMapPointType type; + if (ProtectedIds.PS_COMMON_ACTIVITY_HARBOUR_ID.equals(resultSet.getString(5))) { - point.setType(TripMapPointType.psActivityObsInHarbour); + type = TripMapPointType.psActivityObsInHarbour; } else if (resultSet.getString(6) == null) { - point.setType(TripMapPointType.psActivityObs); + type = TripMapPointType.psActivityObs; } else { String schoolType = resultSet.getString(6); switch (schoolType) { case ProtectedIds.PS_COMMON_SCHOOL_TYPE_FREE_ID: - point.setType(TripMapPointType.psActivityObsWithFreeSchoolType); + type = TripMapPointType.psActivityObsWithFreeSchoolType; break; case ProtectedIds.PS_COMMON_SCHOOL_TYPE_OBJECT_ID: - point.setType(TripMapPointType.psActivityObsWithObjectSchoolType); + type = TripMapPointType.psActivityObsWithObjectSchoolType; break; default: - point.setType(TripMapPointType.psActivityObs); + type = TripMapPointType.psActivityObs; } } - return point; + + Date time = DateUtil.getDateAndTime(resultSet.getDate(1), resultSet.getTime(2), true, false); + return Entities.createPoint(type, time, resultSet, 3); } } + public boolean updateEndDate(Trip trip) { boolean wasUpdated = false; @@ -230,16 +229,4 @@ public class TripTopiaDao extends AbstractTripTopiaDao<Trip> { } - private static Optional<TripMapPoint> createPoint(Harbour harbour, Date date, TripMapPointType tripMapPointType) { - TripMapPoint result = null; - if (harbour != null && harbour.getLatitude() != null && harbour.getLongitude() != null) { - result = new TripMapPoint(); - result.setTime(date); - result.setLatitude(harbour.getLatitude()); - result.setLongitude(harbour.getLongitude()); - result.setType(tripMapPointType); - } - return Optional.ofNullable(result); - } - } ===================================== services-local/src/main/java/fr/ird/observe/services/local/service/actions/validate/ValidateServiceLocal.java ===================================== @@ -31,7 +31,6 @@ import fr.ird.observe.dto.referential.ReferentialDto; import fr.ird.observe.dto.referential.ReferentialLocale; import fr.ird.observe.dto.referential.common.SpeciesDto; import fr.ird.observe.dto.referential.ps.observation.ObservedSystemReference; -import fr.ird.observe.entities.Entities; import fr.ird.observe.entities.data.TripAware; import fr.ird.observe.entities.referential.ReferentialEntity; import fr.ird.observe.entities.referential.common.Species; @@ -47,6 +46,7 @@ import fr.ird.observe.services.service.actions.validate.ValidateService; import fr.ird.observe.services.service.actions.validate.ValidationRequest; import fr.ird.observe.services.service.referential.ReferentialService; import fr.ird.observe.spi.DbModelHelper; +import fr.ird.observe.spi.DtoModelClasses; import fr.ird.observe.spi.type.TypeTranslators; import fr.ird.observe.validation.ServiceValidationContext; import fr.ird.observe.validation.ValidatorsMap; @@ -156,7 +156,7 @@ public class ValidateServiceLocal extends ObserveServiceLocal implements Validat private void validateData(String dataId, ValidationMessageDetector detector, ServiceValidationContext validationContext, Set<SpeciesDto> species) { TripAware<?, ?> trip; - if (Entities.isSeineId(dataId)) { + if (DtoModelClasses.isSeineId(dataId)) { trip = fr.ird.observe.entities.data.ps.common.Trip.loadEntity(getTopiaPersistenceContext(), dataId); } else { trip = fr.ird.observe.entities.data.ll.common.Trip.loadEntity(getTopiaPersistenceContext(), dataId); ===================================== services-local/src/main/java/fr/ird/observe/services/local/service/referential/ReferentialServiceLocal.java ===================================== @@ -34,7 +34,6 @@ import fr.ird.observe.dto.referential.ReferenceStatus; import fr.ird.observe.dto.referential.ReferentialDto; import fr.ird.observe.dto.referential.ReferentialLocale; import fr.ird.observe.dto.result.SaveResultDto; -import fr.ird.observe.entities.Entities; import fr.ird.observe.entities.ObserveEntityEnum; import fr.ird.observe.entities.ObserveTopiaPersistenceContext; import fr.ird.observe.entities.data.ll.common.Trip; @@ -247,11 +246,11 @@ public class ReferentialServiceLocal extends ObserveServiceLocal implements Refe ReferentialShellBuilder referentialShellBuilder = ReferentialShellBuilder.builder(request.getCentralSourceReferential()); for (String tripId : request.getTripIds()) { - if (Entities.isLonglineId(tripId)) { + if (DtoModelClasses.isLonglineId(tripId)) { Trip trip = fr.ird.observe.entities.data.ll.common.Trip.loadEntity(getTopiaPersistenceContext(), tripId); log.info("Compute missing referential for trip: " + tripId); referentialShellBuilder.scan(trip); - } else if (Entities.isSeineId(tripId)) { + } else if (DtoModelClasses.isSeineId(tripId)) { fr.ird.observe.entities.data.ps.common.Trip trip = fr.ird.observe.entities.data.ps.common.Trip.loadEntity(getTopiaPersistenceContext(), tripId); log.info("Compute missing referential for trip: " + tripId); referentialShellBuilder.scan(trip); ===================================== services-local/src/main/java/fr/ird/observe/services/local/service/sql/SqlScriptProducerServiceLocal.java ===================================== @@ -25,7 +25,6 @@ package fr.ird.observe.services.local.service.sql; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ListMultimap; import fr.ird.observe.dto.reference.ReferentialDtoReference; -import fr.ird.observe.entities.Entities; import fr.ird.observe.entities.ObserveEntityEnum; import fr.ird.observe.entities.ObserveTopiaApplicationContext; import fr.ird.observe.services.local.service.ObserveServiceLocal; @@ -33,6 +32,7 @@ import fr.ird.observe.services.service.sql.AddSqlScriptProducerRequest; import fr.ird.observe.services.service.sql.DeleteSqlScriptProducerRequest; import fr.ird.observe.services.service.sql.SqlScriptProducerService; import fr.ird.observe.spi.DbModelHelper; +import fr.ird.observe.spi.DtoModelClasses; import org.apache.commons.collections4.CollectionUtils; import org.nuiton.topia.persistence.metadata.TopiaMetadataModel; import org.nuiton.topia.persistence.script.TopiaBlobsContainer; @@ -46,8 +46,8 @@ import java.util.List; import java.util.Set; import java.util.stream.Collectors; -import static fr.ird.observe.entities.Entities.IS_LONGLINE_ID; -import static fr.ird.observe.entities.Entities.IS_SEINE_ID; +import static fr.ird.observe.spi.DtoModelClasses.IS_LONGLINE_ID; +import static fr.ird.observe.spi.DtoModelClasses.IS_SEINE_ID; import static fr.ird.observe.entities.Entities.REFERENCE_ENTITIES_LIST; /** @@ -174,14 +174,14 @@ public class SqlScriptProducerServiceLocal extends ObserveServiceLocal implement } else { { - Set<String> tripIds1 = tripIds.stream().filter(Entities.IS_SEINE_ID).collect(Collectors.toSet()); + Set<String> tripIds1 = tripIds.stream().filter(DtoModelClasses.IS_SEINE_ID).collect(Collectors.toSet()); if (!tripIds1.isEmpty()) { builder.addDeleteTablesRequest(topiaApplicationContext.getTripSeineTables(), TopiaSqlTableSelectArgument.of(tripIds1)); } } { - Set<String> tripIds1 = tripIds.stream().filter(Entities.IS_LONGLINE_ID).collect(Collectors.toSet()); + Set<String> tripIds1 = tripIds.stream().filter(DtoModelClasses.IS_LONGLINE_ID).collect(Collectors.toSet()); if (!tripIds1.isEmpty()) { builder.addDeleteTablesRequest(topiaApplicationContext.getTripLonglineTables(), TopiaSqlTableSelectArgument.of(tripIds1)); } View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/fddb45997dd5c9dd2e087dedb... -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/fddb45997dd5c9dd2e087dedb... You're receiving this email because of your account on gitlab.com.