branch feature/7469 created (now 0c38504)
This is an automated email from the git hooks/post-receive script. New change to branch feature/7469 in repository observe. See http://git.codelutin.com/observe.git at 0c38504 ajout d'un gestionnaire pour les données ouvertes (refs #7469) This branch includes the following new commits: new 0c38504 ajout d'un gestionnaire pour les données ouvertes (refs #7469) The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 0c3850490182189f90cecc9cce0b6ed6b5f6b3ea Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Mon Oct 5 11:11:08 2015 +0200 ajout d'un gestionnaire pour les données ouvertes (refs #7469) -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/7469 in repository observe. See http://git.codelutin.com/observe.git commit 0c3850490182189f90cecc9cce0b6ed6b5f6b3ea Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Mon Oct 5 11:11:08 2015 +0200 ajout d'un gestionnaire pour les données ouvertes (refs #7469) --- .../fr/ird/observe/ObserveOpenDataManager.java | 116 +++++++++++++++++++++ .../observe/ObserveSwingApplicationContext.java | 15 +++ 2 files changed, 131 insertions(+) diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ObserveOpenDataManager.java b/observe-application-swing/src/main/java/fr/ird/observe/ObserveOpenDataManager.java new file mode 100644 index 0000000..a0291a7 --- /dev/null +++ b/observe-application-swing/src/main/java/fr/ird/observe/ObserveOpenDataManager.java @@ -0,0 +1,116 @@ +package fr.ird.observe; + +import com.google.common.base.Preconditions; +import fr.ird.observe.services.dto.longline.ActivityLonglineDto; +import fr.ird.observe.services.dto.longline.TripLonglineDto; +import fr.ird.observe.services.dto.seine.ActivitySeineDto; +import fr.ird.observe.services.dto.seine.RouteDto; +import fr.ird.observe.services.dto.seine.TripSeineDto; +import org.apache.commons.lang3.StringUtils; + +/** + * @author Sylvain Bavencoff - bavencoff@codelutin.com + */ +public class ObserveOpenDataManager { + + protected String openTripId; + + protected String openRouteId; + + protected String openActivityId; + + // Trips + public boolean canOpenTrip() { + return StringUtils.isBlank(openTripId); + } + + // Trip Seine + + public void open(TripSeineDto tripSeineDto) { + Preconditions.checkState(canOpenTrip()); + openTripId = tripSeineDto.getId(); + } + + public boolean isOpen(TripSeineDto tripSeineDto) { + return tripSeineDto.getId().equals(openTripId); + } + + public void close(TripSeineDto tripSeineDto) { + Preconditions.checkState(isOpen(tripSeineDto)); + openTripId = null; + } + + // Trip Longline + + public void open(TripLonglineDto tripLonglineDto) { + Preconditions.checkState(canOpenTrip()); + openTripId = tripLonglineDto.getId(); + } + + public boolean isOpen(TripLonglineDto tripLonglineDto) { + return tripLonglineDto.getId().equals(openTripId); + } + + public void close(TripLonglineDto tripLonglineDto) { + Preconditions.checkState(isOpen(tripLonglineDto)); + openTripId = null; + } + + // Route + public boolean canOpenRoute(TripSeineDto parentTripDto) { + return isOpen(parentTripDto) && StringUtils.isBlank(openRouteId); + } + + public void open(TripSeineDto parentTripDto, RouteDto routeDto) { + Preconditions.checkState(canOpenRoute(parentTripDto)); + openRouteId = routeDto.getId(); + } + + public boolean isOpen(RouteDto routeDto) { + return routeDto.getId().equals(openRouteId); + } + + public void close(RouteDto routeDto) { + Preconditions.checkState(isOpen(routeDto)); + openRouteId = null; + } + + // Activity Seine + public boolean canOpenActivity(RouteDto parentRouteDto) { + return isOpen(parentRouteDto) && StringUtils.isBlank(openActivityId); + } + + public void open(RouteDto parentRouteDto, ActivitySeineDto activitySeineDto) { + Preconditions.checkState(canOpenActivity(parentRouteDto)); + openActivityId = activitySeineDto.getId(); + } + + public boolean isOpen(ActivitySeineDto activitySeineDto) { + return activitySeineDto.getId().equals(openActivityId); + } + + public void close(ActivitySeineDto activitySeineDto) { + Preconditions.checkState(isOpen(activitySeineDto)); + openActivityId = null; + } + + // Activity Longline + public boolean canOpenActivity(TripLonglineDto parentTripDto) { + return isOpen(parentTripDto) && StringUtils.isBlank(openActivityId); + } + + public void open(TripLonglineDto parentTripDto, ActivityLonglineDto activityLonglineDto) { + Preconditions.checkState(canOpenActivity(parentTripDto)); + openActivityId = activityLonglineDto.getId(); + } + + public boolean isOpen(ActivityLonglineDto activityLonglineDto) { + return activityLonglineDto.getId().equals(openActivityId); + } + + public void close(ActivityLonglineDto activityLonglineDto) { + Preconditions.checkState(isOpen(activityLonglineDto)); + openActivityId = null; + } + +} diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ObserveSwingApplicationContext.java b/observe-application-swing/src/main/java/fr/ird/observe/ObserveSwingApplicationContext.java index 77fee7f..450870e 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ObserveSwingApplicationContext.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ObserveSwingApplicationContext.java @@ -130,6 +130,10 @@ public class ObserveSwingApplicationContext extends DefaultApplicationContext { public static final JAXXContextEntryDef<ObserveDataSourceConfigurationMainFactory> DATA_SOURCE_CONFIGURATION_FACTORY_ENTRY_DEF = JAXXUtil.newContextEntryDef(ObserveDataSourceConfigurationMainFactory.class); + /** the jaxx context entry to store the data source configuration factory */ + public static final JAXXContextEntryDef<ObserveOpenDataManager> OPEN_DATA_MANAGER_ENTRY_DEF = + JAXXUtil.newContextEntryDef(ObserveOpenDataManager.class); + /** the jaxx context entry to store the decorator service */ public static final JAXXContextEntryDef<BinderService> BINDER_SERVICE_ENTRY_DEF = @@ -229,6 +233,17 @@ public class ObserveSwingApplicationContext extends DefaultApplicationContext { return textGenerator; } + public final ObserveOpenDataManager getOpenDataManager() { + ObserveOpenDataManager openDataManager = + OPEN_DATA_MANAGER_ENTRY_DEF.getContextValue(this); + if (openDataManager == null) { + + openDataManager = new ObserveOpenDataManager(); + OPEN_DATA_MANAGER_ENTRY_DEF.setContextValue(this, openDataManager); + } + return openDataManager; + } + public final ObserveDataSourceConfigurationMainFactory getObserveDataSourceConfigurationMainFactory() { -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.
participants (1)
-
codelutin.com scm