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 26816a1b87606ebbe336148b891a8f5a01a5749e Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Mar 8 15:20:47 2016 +0100 Revue des constantes dans le modèle de service --- .../ui/util/tripMap/TripMapContentBuilder.java | 47 +++++++++++----------- .../observe/services/dto/constants/GearType.java | 33 +++++---------- .../services/dto/constants/ReferenceStatus.java | 22 +--------- .../services/dto/constants/TripMapPointType.java | 46 +++++++++------------ .../seine/NonTargetCatchComputedValueSource.java | 6 +-- 5 files changed, 57 insertions(+), 97 deletions(-) diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/tripMap/TripMapContentBuilder.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/tripMap/TripMapContentBuilder.java index 290cfb3..4be65a3 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/tripMap/TripMapContentBuilder.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/tripMap/TripMapContentBuilder.java @@ -36,6 +36,7 @@ import com.vividsolutions.jts.geom.Polygon; import fr.ird.observe.ObserveSwingTechnicalException; import fr.ird.observe.services.dto.TripMapPointDto; import fr.ird.observe.services.dto.constants.TripMapPointType; +import fr.ird.observe.services.util.I18nEnumUtil; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateUtils; import org.geotools.data.FileDataStore; @@ -83,16 +84,16 @@ public class TripMapContentBuilder { public static final String TRIP_POINTS_LAYER_NAME = "Trip points"; protected static final Set<TripMapPointType> TRIP_MAP_POINT_TYPES_IN_LEGEND = ImmutableSet.of( - TripMapPointType.SEINE_ACTIVITY_IN_HARBOUR, - TripMapPointType.SEINE_ACTIVITY_WITH_FREE_SCHOOL_TYPE, - TripMapPointType.SEINE_ACTIVITY_WITH_OBJECT_SCHOOL_TYPE, - TripMapPointType.LONGLINE_IN_HARBOUR, - TripMapPointType.LONGLINE_ACTIVITY_WITH_SETTING_START, - TripMapPointType.LONGLINE_ACTIVITY_WITH_SETTING_END, - TripMapPointType.LONGLINE_ACTIVITY_WITH_HAULING_START, - TripMapPointType.LONGLINE_ACTIVITY_WITH_HAULING_END, - TripMapPointType.LONGLINE_ACTIVITY_WITH_STATION, - TripMapPointType.LONGLINE_ACTIVITY_WITH_INTERACTION); + TripMapPointType.seineActivityInHarbour, + TripMapPointType.seineActivityWithFreeSchoolType, + TripMapPointType.seineActivityWithObjectSchoolType, + TripMapPointType.longlineActivityInHarbour, + TripMapPointType.longlineActivityWithSettingStart, + TripMapPointType.longlineActivityWithSettingEnd, + TripMapPointType.longlineActivityWithHaulingStart, + TripMapPointType.longlineActivityWithHaulingEnd, + TripMapPointType.longlineActivityWithStation, + TripMapPointType.longlineActivityWithInteraction); public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd/MM"); @@ -241,10 +242,10 @@ public class TripMapContentBuilder { DefaultFeatureCollection polygonsFeatures = new DefaultFeatureCollection(); for (int indexPoint = 3; indexPoint < tripMapPoints.size(); indexPoint++) { - if (tripMapPoints.get(indexPoint).getType().equals(TripMapPointType.LONGLINE_ACTIVITY_WITH_HAULING_END) - && tripMapPoints.get(indexPoint - 1).getType().equals(TripMapPointType.LONGLINE_ACTIVITY_WITH_HAULING_START) - && tripMapPoints.get(indexPoint - 2).getType().equals(TripMapPointType.LONGLINE_ACTIVITY_WITH_SETTING_END) - && tripMapPoints.get(indexPoint - 3).getType().equals(TripMapPointType.LONGLINE_ACTIVITY_WITH_SETTING_START)) { + if (tripMapPoints.get(indexPoint).getType().equals(TripMapPointType.longlineActivityWithHaulingEnd) + && tripMapPoints.get(indexPoint - 1).getType().equals(TripMapPointType.longlineActivityWithHaulingStart) + && tripMapPoints.get(indexPoint - 2).getType().equals(TripMapPointType.longlineActivityWithSettingEnd) + && tripMapPoints.get(indexPoint - 3).getType().equals(TripMapPointType.longlineActivityWithSettingStart)) { Coordinate[] coordinates = { new Coordinate(tripMapPoints.get(indexPoint - 3).getLongitude(), tripMapPoints.get(indexPoint - 3).getLatitude()), @@ -290,17 +291,17 @@ public class TripMapContentBuilder { List<Coordinate> defaultLineCoordinates = Lists.newLinkedList(); for (int indexPoint = 0; indexPoint < tripMapPoints.size(); indexPoint++) { - if (indexPoint > 1 && tripMapPoints.get(indexPoint).getType().equals(TripMapPointType.LONGLINE_ACTIVITY_WITH_SETTING_END) - && tripMapPoints.get(indexPoint - 1).getType().equals(TripMapPointType.LONGLINE_ACTIVITY_WITH_SETTING_START) - || tripMapPoints.get(indexPoint).getType().equals(TripMapPointType.LONGLINE_ACTIVITY_WITH_HAULING_END) - && tripMapPoints.get(indexPoint - 1).getType().equals(TripMapPointType.LONGLINE_ACTIVITY_WITH_HAULING_START)) { + if (indexPoint > 1 && tripMapPoints.get(indexPoint).getType().equals(TripMapPointType.longlineActivityWithSettingEnd) + && tripMapPoints.get(indexPoint - 1).getType().equals(TripMapPointType.longlineActivityWithSettingStart) + || tripMapPoints.get(indexPoint).getType().equals(TripMapPointType.longlineActivityWithHaulingEnd) + && tripMapPoints.get(indexPoint - 1).getType().equals(TripMapPointType.longlineActivityWithHaulingStart)) { 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.LONGLINE_ACTIVITY_WITH_SETTING_END); + boolean setting = tripMapPoints.get(indexPoint).getType().equals(TripMapPointType.longlineActivityWithSettingEnd); LineString lineString = geometryFactory.createLineString(coordinates); lineBuilder.add(lineString); lineBuilder.add(setting ? "setting" : "hauling"); @@ -310,14 +311,14 @@ public class TripMapContentBuilder { defaultLineCoordinates.clear(); } - if (! (tripMapPoints.get(indexPoint).getType().equals(TripMapPointType.LONGLINE_ACTIVITY_WITH_SETTING_END) - || tripMapPoints.get(indexPoint).getType().equals(TripMapPointType.LONGLINE_ACTIVITY_WITH_HAULING_START))) { + if (! (tripMapPoints.get(indexPoint).getType().equals(TripMapPointType.longlineActivityWithSettingEnd) + || tripMapPoints.get(indexPoint).getType().equals(TripMapPointType.longlineActivityWithHaulingStart))) { defaultLineCoordinates.add(new Coordinate(tripMapPoints.get(indexPoint).getLongitude(), tripMapPoints.get(indexPoint).getLatitude())); } - if ((tripMapPoints.get(indexPoint).getType().equals(TripMapPointType.LONGLINE_ACTIVITY_WITH_SETTING_START) + if ((tripMapPoints.get(indexPoint).getType().equals(TripMapPointType.longlineActivityWithSettingStart) || indexPoint == tripMapPoints.size() - 1) && defaultLineCoordinates.size() > 1) { LineString lineString = geometryFactory.createLineString(defaultLineCoordinates.toArray( new Coordinate[0])); @@ -406,7 +407,7 @@ public class TripMapContentBuilder { ObserveMapPaneLegendItem legendPoint = new ObserveMapPaneLegendItem( pointBuilder.buildFeature(null), stylePoints, - type.getLabel()); + I18nEnumUtil.getLabel(type)); legendItems.add(legendPoint); pointTypeInLegend.add(type); } diff --git a/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/GearType.java b/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/GearType.java index a7ec1a6..70832c8 100644 --- a/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/GearType.java +++ b/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/GearType.java @@ -31,32 +31,19 @@ package fr.ird.observe.services.dto.constants; public enum GearType { /** Seine */ - seine { - @Override - public String getPrefix() { - return "PS"; - } - }, + seine("PS"), /** Longline */ - longline { - @Override - public String getPrefix() { - return "LL"; - } - }; - - public static GearType fromOrdinal(int ordinal) { - - GearType result = null; - for (GearType gearType : values()) { - if (ordinal == gearType.ordinal()) { - result = gearType; - } - } - return result; + longline("LL"); + + private final String prefix; + + GearType(String prefix) { + this.prefix = prefix; } - public abstract String getPrefix(); + public String getPrefix() { + return prefix; + } } diff --git a/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/ReferenceStatus.java b/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/ReferenceStatus.java index 445e694..dbc6eef 100644 --- a/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/ReferenceStatus.java +++ b/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/ReferenceStatus.java @@ -22,9 +22,6 @@ package fr.ird.observe.services.dto.constants; * #L% */ -import static org.nuiton.i18n.I18n.n; -import static org.nuiton.i18n.I18n.t; - /** * Une énumération pour caractériser les valeurs des status d'une entité du * référentiel @@ -35,24 +32,9 @@ import static org.nuiton.i18n.I18n.t; public enum ReferenceStatus { /** status desactive */ - disabled(n("observe.reference.status.disabled")), + disabled, /** status active */ - enabled(n("observe.reference.status.enabled")); - - private String i18nKey; - - ReferenceStatus(String i18nKey) { - this.i18nKey = i18nKey; - } - - public String getI18nKey() { - return i18nKey; - } - - @Override - public String toString() { - return t(i18nKey); - } + enabled; } diff --git a/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/TripMapPointType.java b/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/TripMapPointType.java index f686560..4af4528 100644 --- a/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/TripMapPointType.java +++ b/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/TripMapPointType.java @@ -22,37 +22,27 @@ package fr.ird.observe.services.dto.constants; * #L% */ -import static org.nuiton.i18n.I18n.n; -import static org.nuiton.i18n.I18n.t; - /** * @author Sylvain Bavencoff - bavencoff@codelutin.com */ public enum TripMapPointType { - 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; - - TripMapPointType(String label) { - this.label = label; - } - - public String getLabel() { - return t(label); - } + seineDepartureHarbour, + seineLandingHarbour, + seineActivity, + seineActivityInHarbour, + seineActivityWithFreeSchoolType, + seineActivityWithObjectSchoolType, + + longlineActivity, + longlineDepartureHarbour, + longlineLandingHarbour, + longlineActivityInHarbour, + longlineActivityWithSettingStart, + longlineActivityWithSettingEnd, + longlineActivityWithHaulingStart, + longlineActivityWithHaulingEnd, + longlineActivityWithInteraction, + longlineActivityWithStation; + } diff --git a/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/seine/NonTargetCatchComputedValueSource.java b/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/seine/NonTargetCatchComputedValueSource.java index 40469be..6e5ab78 100644 --- a/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/seine/NonTargetCatchComputedValueSource.java +++ b/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/seine/NonTargetCatchComputedValueSource.java @@ -35,18 +35,18 @@ public enum NonTargetCatchComputedValueSource { * * @since 3.0 */ - FROM_DATA, + fromData, /** * Donnée calculée à partir de l'échantillon pour la même espèce et la même calée. * * @since 3.0 */ - FROM_SAMPLE, + fromSample, /** * Donnée calculée à partir du référentiel. * * @since 3.0 */ - FROM_REFERENTIEL; + fromReferentiel; } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.