branch feature/7531 updated (a74653a -> 3f97619)
This is an automated email from the git hooks/post-receive script. New change to branch feature/7531 in repository observe. See http://git.codelutin.com/observe.git discards a74653a utilisation des services dans doSave et doDelete discards e6cec26 début d'utilisation des services dans doSave et doDelete (refs #7531) adds ea09607 lancement de l'application + connexion aux bases H2 et PG (refs #7528 #7529) adds 93fd18f utilisation de la classe ObserveSwingDataSource pour gérer les connection au source de données, (refs #7529) adds fdde99f commexion au serveur de données (refs #7529) adds dc60289 ignorer un test et mise à jour des dépendences (refs #7529) adds 733fcf2 creation d'un base local (refs #7529) adds 726eaba chargement de la base de données local au démarage (refs #7528) adds 9076109 Fix merge adds 5abc310 Renommage getModle en getModel adds 4ce182d Démarage de client swing (termine #7328) estion des data source dans l'application swing (termine #7529) Merge branch 'feature/7528' into develop new e11ff67 début d'utilisation des services dans doSave et doDelete (refs #7531) new 4a26bd2 utilisation des services dans doSave et doDelete new 3f97619 Fix merge This update added new revisions after undoing existing revisions. That is to say, some revisions that were in the old version of the branch are not in the new version. This situation occurs when a user --force pushes a change and generates a repository containing something like this: * -- * -- B -- O -- O -- O (a74653a) \ N -- N -- N refs/heads/feature/7531 (3f97619) You should already have received notification emails for all of the O revisions, and so the following emails describe only the N revisions from the common base, B. Any revisions marked "omits" are not gone; other references still refer to them. Any revisions marked "discards" are gone forever. The 3 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 3f9761934c1677a16f7bf67a3637350a4a27b054 Author: Tony CHEMIT <chemit@codelutin.com> Date: Thu Sep 24 19:26:43 2015 +0200 Fix merge commit 4a26bd22257c118708548289976a12a23c7fe298 Author: Kevin Morin <morin@codelutin.com> Date: Thu Sep 24 18:15:26 2015 +0200 utilisation des services dans doSave et doDelete commit e11ff675ce00b4d47b7fdcb9ccc73043b1442bcf Author: Kevin Morin <morin@codelutin.com> Date: Thu Sep 24 17:08:04 2015 +0200 début d'utilisation des services dans doSave et doDelete (refs #7531) Summary of changes: observe-application-swing/pom.xml | 11 + .../src/main/filters/observe-ui.properties | 1 + .../java/fr/ird/observe/ObserveActionExecutor.java | 22 +- .../main/java/fr/ird/observe/ObserveCLAction.java | 30 +- .../main/java/fr/ird/observe/ObserveConfig.java | 1004 ----- .../main/java/fr/ird/observe/ObserveContext.java | 594 --- .../fr/ird/observe/ObserveResourceManager.java | 20 +- .../main/java/fr/ird/observe/ObserveRunner.java | 74 +- .../{business => }/ObserveServiceHelper.java | 63 +- .../observe/ObserveSwingApplicationContext.java | 764 ++++ .../fr/ird/observe/business/IObserveConfig.java | 4 +- .../business/ObserveApplicationContext.java | 9 +- .../ird/observe/business/db/DataSourceConfig.java | 2 +- .../ird/observe/business/db/DataSourceFactory.java | 2 +- .../db/constants/CommonDataSourceConfigParam.java | 1 + .../business/report/model/ReportExecute.java | 15 +- .../business/validation/ObserveValidator.java | 6 +- .../validation/ValidationMessageDetector.java | 2 +- .../ObserveApplicationConfigProvider.java | 7 +- .../ObserveSwingApplicationConfig.java | 1152 +++++ .../ObserveSwingApplicationConfigOption.java} | 217 +- .../ObserveSwingApplicationConfigProvider.java | 37 + .../fr/ird/observe/db/ObserveSwingDataSource.java | 304 ++ .../constantes}/ConnexionStatus.java | 2 +- .../constants => db/constantes}/CreationMode.java | 28 +- .../db/constants => db/constantes}/DbMode.java | 7 +- .../db/event/ObserveSwingDataSourceEvent.java | 18 +- .../db/event/ObserveSwingDataSourceListener.java | 22 +- .../ObserveSwingDataSourceListenerAdapter.java | 14 +- .../src/main/java/fr/ird/observe/package.html | 2 +- .../main/java/fr/ird/observe/ui/ObserveMainUI.css | 1 + .../main/java/fr/ird/observe/ui/ObserveMainUI.jaxx | 4 +- .../fr/ird/observe/ui/ObserveMainUIHandler.java | 51 +- .../java/fr/ird/observe/ui/ObserveUICallback.java | 12 +- .../src/main/java/fr/ird/observe/ui/UIHelper.java | 18 +- .../actions/ChangeApplicationLanguageAction.java | 12 +- .../observe/ui/actions/ChangeDbLanguageAction.java | 12 +- .../observe/ui/actions/ChangeStorageAction.java | 6 +- .../observe/ui/actions/CloseApplicationAction.java | 6 +- .../fr/ird/observe/ui/actions/CloseHelpAction.java | 10 +- .../ird/observe/ui/actions/CloseStorageAction.java | 21 +- .../fr/ird/observe/ui/actions/GotoSiteAction.java | 8 +- .../ui/actions/ImportStorageFromFileAction.java | 9 +- .../ird/observe/ui/actions/LaunchAdminAction.java | 4 +- .../ui/actions/ReloadApplicationAction.java | 8 +- .../actions/ReloadDefaultConfigurationAction.java | 12 +- .../observe/ui/actions/ReloadResourcesAction.java | 8 +- .../observe/ui/actions/ReloadStorageAction.java | 92 +- .../ui/actions/SaveStorageToFileAction.java | 32 +- .../ird/observe/ui/actions/ShowConfigAction.java | 128 +- .../observe/ui/actions/ShowStorageInfoAction.java | 4 +- .../observe/ui/actions/StartServerModeAction.java | 7 +- .../ui/actions/shared/CloseAndCreateUIAction.java | 6 +- .../ui/actions/shared/CloseOpenUIAction.java | 6 +- .../observe/ui/actions/shared/ReOpenUIAction.java | 5 +- .../java/fr/ird/observe/ui/admin/AdminStep.java | 2 +- .../java/fr/ird/observe/ui/admin/AdminTabUI.jaxx | 6 +- .../fr/ird/observe/ui/admin/AdminTabUIHandler.java | 33 +- .../fr/ird/observe/ui/admin/AdminUILauncher.java | 28 +- .../java/fr/ird/observe/ui/admin/AdminUIModel.java | 107 +- .../observe/ui/admin/config/ConfigUIHandler.java | 2 - .../ui/admin/consolidate/ConsolidateModel.java | 8 +- .../ui/admin/consolidate/ConsolidateUIHandler.java | 8 +- .../ird/observe/ui/admin/export/ExportModel.java | 14 +- .../observe/ui/admin/export/ExportUIHandler.java | 12 +- .../ui/admin/gps/GPSActivityTableModel.java | 4 +- .../observe/ui/admin/gps/ImportGPSConfigUI.jaxx | 6 +- .../observe/ui/admin/gps/ImportGPSUIHandler.java | 5 +- .../observe/ui/admin/report/ReportUIHandler.java | 21 +- .../observe/ui/admin/save/SaveLocalUIHandler.java | 28 +- .../ObsoleteEntityListCellRenderer.java | 4 +- .../ui/admin/synchronize/SynchronizeModel.java | 20 +- .../ui/admin/synchronize/SynchronizeUIHandler.java | 17 +- .../ui/admin/validate/ValidateConfigUI.jaxx | 6 +- .../validate/ValidateEntityListCellRenderer.java | 4 +- .../observe/ui/admin/validate/ValidateModel.java | 6 +- .../ui/admin/validate/ValidateUIHandler.java | 11 +- .../java/fr/ird/observe/ui/content/ContentUI.jaxx | 15 +- .../ird/observe/ui/content/ContentUIHandler.java | 143 +- .../observe/ui/content/ContentUIInitializer.java | 215 +- .../content/impl/longline/BranchlineUIHandler.java | 15 +- .../impl/longline/LonglineDetailCompositionUI.jaxx | 4 +- .../LonglineDetailCompositionUIHandler.java | 28 +- .../impl/longline/LonglineGlobalCompositionUI.jaxx | 14 +- .../LonglineGlobalCompositionUIHandler.java | 10 - .../impl/longline/SetLonglineUIHandler.java | 11 - .../ActivitySeineObservedSystemUIHandler.java | 11 - .../impl/seine/FloatingObjectUIHandler.java | 11 - .../ui/content/impl/seine/SetSeineUIHandler.java | 11 - .../ui/content/list/ContentListUIHandler.java | 23 +- .../ui/content/open/ContentOpenableUIHandler.java | 10 - .../open/impl/longline/TripLonglineUIHandler.java | 4 +- .../ui/content/open/impl/seine/RouteUIHandler.java | 7 +- .../open/impl/seine/TripSeineUIHandler.java | 4 +- .../ui/content/ref/ContentReferenceUIHandler.java | 4 +- .../ui/content/ref/ReferenceHomeUIHandler.java | 11 - .../ui/content/ref/UniqueKeyTableModel.java | 4 +- .../ui/content/table/ContentTableUIHandler.java | 25 +- .../impl/longline/CatchLonglineUIHandler.java | 21 +- .../table/impl/longline/EncounterUIHandler.java | 6 +- .../longline/GearUseFeaturesLonglineUIHandler.java | 12 +- .../table/impl/longline/SensorUsedUIHandler.java | 9 +- .../content/table/impl/longline/TdrUIHandler.java | 16 +- .../impl/seine/GearUseFeaturesSeineUIHandler.java | 12 +- .../table/impl/seine/NonTargetCatchUIHandler.java | 18 +- .../impl/seine/ObjectObservedSpeciesUIHandler.java | 19 +- .../impl/seine/ObjectSchoolEstimateUIHandler.java | 6 +- .../table/impl/seine/SchoolEstimateUIHandler.java | 10 +- .../table/impl/seine/TargetCatchUIHandler.java | 2 +- .../impl/seine/TargetDiscardCatchUIHandler.java | 2 +- .../ird/observe/ui/storage/ObstunaAdminAction.java | 2 +- .../ird/observe/ui/storage/RemoteUILauncher.java | 3 +- .../ui/storage/StorageBackupUILauncher.java | 68 +- .../ird/observe/ui/storage/StorageUIHandler.java | 893 ++-- .../ird/observe/ui/storage/StorageUILauncher.java | 52 +- .../fr/ird/observe/ui/storage/StorageUIModel.java | 1213 +++--- .../ird/observe/ui/storage/tabs/ChooseDbModeUI.css | 13 + .../observe/ui/storage/tabs/ChooseDbModeUI.jaxx | 14 +- .../ird/observe/ui/storage/tabs/ConfigDataUI.jaxx | 2 +- .../ui/storage/tabs/ConfigReferentielUI.jaxx | 2 +- .../fr/ird/observe/ui/storage/tabs/ConfigUI.css | 26 + .../fr/ird/observe/ui/storage/tabs/ConfigUI.jaxx | 46 +- .../ui/storage/tabs}/DataSelectionModel.java | 255 +- .../ird/observe/ui/storage/tabs/SelectDataUI.jaxx | 4 +- .../ui/storage/tabs/StorageTabUIHandler.java | 67 +- .../ui/tree/AbstractObserveTreeCellRenderer.java | 23 +- .../ui/tree/DataSelectionTreeSelectionModel.java | 95 +- .../ui/tree/NavigationTreeSelectionModel.java | 4 +- .../ird/observe/ui/tree/ObserveDataProvider.java | 10 +- .../tree/ObserveNavigationTreeShowPopupAction.java | 14 +- .../fr/ird/observe/ui/tree/ObserveTreeHelper.java | 27 +- .../ui/tree/loadors/AbstractNodeChildLoador.java | 6 +- .../loadors/ActivityLonglinesNodeChildLoador.java | 4 +- .../tree/loadors/ActivitySeineNodeChildLoador.java | 4 +- .../loadors/ActivitySeinesNodeChildLoador.java | 4 +- .../loadors/ProgramLonglineNodeChildLoador.java | 4 +- .../tree/loadors/ProgramSeineNodeChildLoador.java | 4 +- .../ui/tree/loadors/RootNodeChildLoador.java | 4 +- .../ui/tree/loadors/RoutesNodeChildLoador.java | 4 +- .../java/fr/ird/observe/ui/usage/UsagesUI.jaxx | 6 +- .../fr/ird/observe/ui/usage/UsagesUIHandler.java | 4 +- ...ObserveSimpleValidatorMessageTableRenderer.java | 4 +- .../util/ObserveValidatorMessageTableRenderer.java | 4 +- .../observe/ui/util/tripMap/TripMapUIHandler.java | 12 +- .../org.nuiton.config.ApplicationConfigProvider | 2 +- .../observe-application-swing_en_GB.properties | 1823 ++++---- .../observe-application-swing_es_ES.properties | 2125 +++++----- .../observe-application-swing_fr_FR.properties | 4405 ++++++++++---------- ...{action-import-gps.png => action-db-server.png} | Bin .../src/main/resources/observeSwing.conf | 5 + ...glineDetailCompositionValidatorServiceTest.java | 127 +- .../DataSourceDumpProducerServiceController.java | 29 + .../controller/v1/DataSourceServiceController.java | 3 +- .../web/controller/v1/PingServiceController.java | 8 +- .../ObserveWebSecurityApplicationContext.java | 2 +- observe-entities/pom.xml | 62 +- .../src/main/xmi/observe-common.properties | 2 +- .../src/main/xmi/observe-longline.properties | 2 +- .../src/main/xmi/observe-seine.properties | 2 +- .../ird/observe/services/service/PingService.java | 2 + observe-services-configuration-api/pom.xml | 6 + .../configuration/ObserveDataSourceConnection.java | 5 + .../ObserveDataSourceConnectionSupport.java | 13 +- observe-services-configuration-rest/pom.xml | 6 + .../ObserveDataSourceConnectionRest.java | 7 +- observe-services-configuration-topia/pom.xml | 4 +- .../ObserveDataSourceConnectionTopia.java | 7 +- .../services/dto/gson/ObserveDtoGsonSupplier.java | 2 + .../observe/services/dto/gson/VersionAdapter.java | 36 + .../services/dto/referential/ProgramDtos.java | 44 + .../services/dto/referential/ReferentialDtos.java | 116 +- .../main/xmi/observe-services-dto-common.zargo~ | Bin 35328 -> 0 bytes .../ird/observe/services/TestMethodResource.java | 2 +- .../fr/ird/observe/services/ObserveJdbcHelper.java | 35 + .../services/ObserveServiceContextTopia.java | 3 + .../EntityToReferentialReferenceDtoBuilder.java | 13 + .../services/dto/ObserveDtosInitializer.java | 284 +- .../services/service/DataSourceServiceTopia.java | 12 +- .../ObserveDataSourceConnectionTopiaTaiste.java | 3 +- ...EntityToReferentialReferenceDtoBuilderTest.java | 57 + pom.xml | 3 + 181 files changed, 9865 insertions(+), 8270 deletions(-) delete mode 100644 observe-application-swing/src/main/java/fr/ird/observe/ObserveConfig.java delete mode 100644 observe-application-swing/src/main/java/fr/ird/observe/ObserveContext.java rename observe-application-swing/src/main/java/fr/ird/observe/{business => }/ObserveServiceHelper.java (85%) create mode 100644 observe-application-swing/src/main/java/fr/ird/observe/ObserveSwingApplicationContext.java rename observe-application-swing/src/main/java/fr/ird/observe/{ => configuration}/ObserveApplicationConfigProvider.java (90%) create mode 100644 observe-application-swing/src/main/java/fr/ird/observe/configuration/ObserveSwingApplicationConfig.java rename observe-application-swing/src/main/java/fr/ird/observe/{ObserveConfigOption.java => configuration/ObserveSwingApplicationConfigOption.java} (75%) create mode 100644 observe-application-swing/src/main/java/fr/ird/observe/configuration/ObserveSwingApplicationConfigProvider.java create mode 100644 observe-application-swing/src/main/java/fr/ird/observe/db/ObserveSwingDataSource.java rename observe-application-swing/src/main/java/fr/ird/observe/{business/db/constants => db/constantes}/ConnexionStatus.java (97%) rename observe-application-swing/src/main/java/fr/ird/observe/{business/db/constants => db/constantes}/CreationMode.java (72%) rename observe-application-swing/src/main/java/fr/ird/observe/{business/db/constants => db/constantes}/DbMode.java (88%) copy observe-business/src/main/java/fr/ird/observe/db/event/DataSourceEvent.java => observe-application-swing/src/main/java/fr/ird/observe/db/event/ObserveSwingDataSourceEvent.java (74%) copy observe-business/src/main/java/fr/ird/observe/db/event/DataSourceListener.java => observe-application-swing/src/main/java/fr/ird/observe/db/event/ObserveSwingDataSourceListener.java (74%) copy observe-business/src/main/java/fr/ird/observe/db/event/DataSourceListenerAdapter.java => observe-application-swing/src/main/java/fr/ird/observe/db/event/ObserveSwingDataSourceListenerAdapter.java (70%) rename {observe-business/src/main/java/fr/ird/observe/db/model => observe-application-swing/src/main/java/fr/ird/observe/ui/storage/tabs}/DataSelectionModel.java (60%) copy observe-application-swing/src/main/resources/icons/{action-import-gps.png => action-db-server.png} (100%) create mode 100644 observe-application-swing/src/main/resources/observeSwing.conf create mode 100644 observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/DataSourceDumpProducerServiceController.java create mode 100644 observe-services-model/src/main/java/fr/ird/observe/services/dto/gson/VersionAdapter.java create mode 100644 observe-services-model/src/main/java/fr/ird/observe/services/dto/referential/ProgramDtos.java delete mode 100644 observe-services-model/src/main/xmi/observe-services-dto-common.zargo~ create mode 100644 observe-services-topia/src/test/java/fr/ird/observe/services/builder/EntityToReferentialReferenceDtoBuilderTest.java -- 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/7531 in repository observe. See http://git.codelutin.com/observe.git commit e11ff675ce00b4d47b7fdcb9ccc73043b1442bcf Author: Kevin Morin <morin@codelutin.com> Date: Thu Sep 24 17:08:04 2015 +0200 début d'utilisation des services dans doSave et doDelete (refs #7531) --- .../ird/observe/ui/content/ContentUIHandler.java | 5 +- .../content/impl/longline/BranchlineUIHandler.java | 29 ++- .../FloatingObjectTransmittingBuoyOperationUI.jaxx | 6 +- ...ngObjectTransmittingBuoyOperationUIHandler.java | 139 ++++++------ ...tingObjectTransmittingBuoyOperationUIModel.java | 16 +- .../impl/seine/FloatingObjectUIHandler.java | 31 ++- .../impl/longline/ActivityLonglineUIHandler.java | 145 ++++++------- .../open/impl/seine/ActivitySeineUIHandler.java | 98 ++++----- .../ui/content/ref/ContentReferenceUIHandler.java | 239 +++++++++++---------- .../ui/content/table/ContentTableUIHandler.java | 64 +++--- .../v1/ReferentialServiceController.java | 4 +- .../ActivityLonglineServiceController.java | 9 +- .../v1/seine/ActivitySeineServiceController.java | 4 +- .../v1/seine/FloatingObjectServiceController.java | 4 +- ...TransmittingBuoyOperationServiceController.java | 4 +- .../services/service/ReferentialService.java | 2 +- .../service/longline/ActivityLonglineService.java | 8 +- .../service/seine/ActivitySeineService.java | 2 +- .../service/seine/FloatingObjectService.java | 2 +- .../seine/TransmittingBuoyOperationService.java | 2 +- .../src/main/xmi/observe-services-dto-common.zargo | Bin 35328 -> 36919 bytes ...on.zargo => observe-services-dto-common.zargo~} | Bin .../services/service/ReferentialServiceTopia.java | 6 +- .../longline/ActivityLonglineServiceTopia.java | 24 ++- .../service/seine/ActivitySeineServiceTopia.java | 4 +- .../service/seine/FloatingObjectServiceTopia.java | 4 +- .../TransmittingBuoyOperationServiceTopia.java | 4 +- 27 files changed, 423 insertions(+), 432 deletions(-) diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIHandler.java index ed5acc4..dde86d0 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIHandler.java @@ -510,9 +510,9 @@ public abstract class ContentUIHandler<E extends IdDto> { public final void saveUI(boolean refresh) { boolean ok = false; - //FIXME try { ok = doSave(getBean()); + } catch (Exception e) { ErrorDialogUI.showError(e); if (log.isErrorEnabled()) { @@ -525,7 +525,6 @@ public abstract class ContentUIHandler<E extends IdDto> { } } -//FIXME protected boolean doSave(E bean) throws Exception { return false; } @@ -572,8 +571,10 @@ public abstract class ContentUIHandler<E extends IdDto> { boolean ok = false; ui.stopEdit(); removeAllMessages(ui); + try { ok = doDelete(getBean()); + } catch (Exception e) { ErrorDialogUI.showError(e); if (log.isErrorEnabled()) { diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/BranchlineUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/BranchlineUIHandler.java index 568475e..f3d5478 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/BranchlineUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/BranchlineUIHandler.java @@ -218,23 +218,20 @@ public class BranchlineUIHandler extends ContentUIHandler<BranchlineDto> { } - //FIXME -// @Override -// protected boolean doSave(BranchlineDto bean, -// DataService dataService, -// DataSource dataSource, -// TopiaEntityBinder<BranchlineDto> binder) throws Exception { -// -// // bind back to model branchline -// BranchlineDto beanToSave = getModel().getBranchline(); + @Override + protected boolean doSave(BranchlineDto bean) throws Exception { + + // bind back to model branchline + BranchlineDto beanToSave = getModel().getBranchline(); + //FIXME // binder.copy(bean, beanToSave); -// -// // for external models -// getModel().fireSaved(); -// -// return true; -// -// } + + // for external models + getModel().fireSaved(); + + return true; + + } @Override public void resetEditUI() { diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/FloatingObjectTransmittingBuoyOperationUI.jaxx b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/FloatingObjectTransmittingBuoyOperationUI.jaxx index fef4675..17116e2 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/FloatingObjectTransmittingBuoyOperationUI.jaxx +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/FloatingObjectTransmittingBuoyOperationUI.jaxx @@ -20,12 +20,12 @@ #L% --> -<fr.ird.observe.ui.content.ContentUI superGenericType='FloatingObjectDto' +<fr.ird.observe.ui.content.ContentUI superGenericType='FloatingObjectTransmittingBuoyDto' contentTitle='{n("observe.floatingObjectTransmittingBuoyOperation.title")}'> <import> fr.ird.observe.services.dto.ReferenceDto - fr.ird.observe.services.dto.seine.FloatingObjectDto + fr.ird.observe.services.dto.seine.FloatingObjectTransmittingBuoyDto fr.ird.observe.services.dto.seine.TransmittingBuoyDto fr.ird.observe.services.dto.constants.seine.Ownership fr.ird.observe.services.dto.constants.seine.TypeTransmittingBuoyOperation @@ -51,7 +51,7 @@ <FloatingObjectTransmittingBuoyOperationUIModel id='model'/> <!-- edit bean --> - <FloatingObjectDto id='bean'/> + <FloatingObjectTransmittingBuoyDto id='bean'/> <!-- transmittingBuoy1 edit bean --> <TransmittingBuoyDto id='transmittingBuoy1' initializer='new TransmittingBuoyDto()'/> diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/FloatingObjectTransmittingBuoyOperationUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/FloatingObjectTransmittingBuoyOperationUIHandler.java index 1d7d3f0..d461585 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/FloatingObjectTransmittingBuoyOperationUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/FloatingObjectTransmittingBuoyOperationUIHandler.java @@ -24,13 +24,16 @@ package fr.ird.observe.ui.content.impl.seine; import fr.ird.observe.business.db.DataContext; import fr.ird.observe.business.db.DataSource; import fr.ird.observe.business.db.constants.DataContextType; +import fr.ird.observe.services.dto.FormDto; import fr.ird.observe.services.dto.constants.seine.Ownership; import fr.ird.observe.services.dto.constants.seine.TypeTransmittingBuoyOperation; import fr.ird.observe.services.dto.referential.ReferentialReferenceDto; import fr.ird.observe.services.dto.referential.seine.TransmittingBuoyOperationDto; import fr.ird.observe.services.dto.seine.ActivitySeineDto; import fr.ird.observe.services.dto.seine.FloatingObjectDto; +import fr.ird.observe.services.dto.seine.FloatingObjectTransmittingBuoyDto; import fr.ird.observe.services.dto.seine.TransmittingBuoyDto; +import fr.ird.observe.services.service.seine.TransmittingBuoyOperationService; import fr.ird.observe.ui.UIHelper; import fr.ird.observe.ui.content.ContentMode; import fr.ird.observe.ui.content.ContentUIHandler; @@ -38,9 +41,10 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.validator.NuitonValidatorScope; -import javax.swing.JPanel; -import javax.swing.SwingUtilities; -import java.awt.GridLayout; +import javax.swing.*; +import java.awt.*; +import java.util.ArrayList; +import java.util.Collection; import java.util.List; import static org.nuiton.i18n.I18n.t; @@ -49,7 +53,7 @@ import static org.nuiton.i18n.I18n.t; * @author Tony Chemit - chemit@codelutin.com * @since 1.0 */ -public class FloatingObjectTransmittingBuoyOperationUIHandler extends ContentUIHandler<FloatingObjectDto> { +public class FloatingObjectTransmittingBuoyOperationUIHandler extends ContentUIHandler<FloatingObjectTransmittingBuoyDto> { /** Logger */ static private Log log = LogFactory.getLog(FloatingObjectTransmittingBuoyOperationUIHandler.class); @@ -103,7 +107,7 @@ public class FloatingObjectTransmittingBuoyOperationUIHandler extends ContentUIH log.info("dcpId = " + dcpId); } - FloatingObjectDto bean = getBean(); + FloatingObjectTransmittingBuoyDto bean = getBean(); //FIXME // bean.clearTransmittingBuoy(); @@ -204,17 +208,18 @@ public class FloatingObjectTransmittingBuoyOperationUIHandler extends ContentUIH FloatingObjectTransmittingBuoyOperationUI ui = getUi(); addInfoMessage(t("observe.message.updating.floatingObject")); - //FIXME -// List<TransmittingBuoyDto> balises = getBean().getTransmittingBuoy(); -// if (balises != null && !balises.isEmpty()) { -// TransmittingBuoyDto transmittingBuoy1 = ui.getTransmittingBuoy1(); -// ui.getValidatorBalise1().setBean(transmittingBuoy1); -// -// if (balises.size() == 2) { -// TransmittingBuoyDto transmittingBuoy2 = ui.getTransmittingBuoy2(); -// ui.getValidatorBalise2().setBean(transmittingBuoy2); -// } -// } + + Collection<TransmittingBuoyDto> balises = getBean().getTransmittingBuoy(); + if (balises != null && !balises.isEmpty()) { + TransmittingBuoyDto transmittingBuoy1 = ui.getTransmittingBuoy1(); + ui.getValidatorBalise1().setBean(transmittingBuoy1); + + if (balises.size() == 2) { + TransmittingBuoyDto transmittingBuoy2 = ui.getTransmittingBuoy2(); + ui.getValidatorBalise2().setBean(transmittingBuoy2); + } + } + UIHelper.processDataBinding( ui, //FIXME @@ -243,16 +248,13 @@ public class FloatingObjectTransmittingBuoyOperationUIHandler extends ContentUIH } //FIXME -// @Override -// protected boolean doSave(FloatingObject bean, -// DataService dataService, -// DataSource dataSource, -// TopiaEntityBinder<FloatingObject> binder) throws Exception { -// -// dataService.update(dataSource, null, bean, getUpdateExecutor()); -// //FIXME, il faut declancher un evenement dans le cache du storage pour pouvoir redessiner le noeud -// return true; -// } + @Override + protected boolean doSave(FloatingObjectTransmittingBuoyDto bean) throws Exception { + + getTransmittingBuoyOperationService().save(bean); + //FIXME, il faut declancher un evenement dans le cache du storage pour pouvoir redessiner le noeud + return true; + } //FIXME // @Override @@ -303,6 +305,16 @@ public class FloatingObjectTransmittingBuoyOperationUIHandler extends ContentUIH resetEditUI(); } + @Override + protected FormDto<FloatingObjectTransmittingBuoyDto> loadToEdit(String id) { + return null; + } + + @Override + protected FormDto<FloatingObjectTransmittingBuoyDto> loadToReadDto(String id) { + return null; + } + protected void changeTypeOperation(TypeTransmittingBuoyOperation typeOperation, boolean reset) { FloatingObjectTransmittingBuoyOperationUI ui = getUi(); @@ -312,22 +324,21 @@ public class FloatingObjectTransmittingBuoyOperationUIHandler extends ContentUIH } int nbBalises = typeOperation.getNbBalises(); - FloatingObjectDto bean = getBean(); + FloatingObjectTransmittingBuoyDto bean = getBean(); - //FIXME -// boolean hasBalise = !bean.isTransmittingBuoyEmpty(); -// -// List<TransmittingBuoyDto> objets = new ArrayList<TransmittingBuoyDto>(); -// if (!reset) { -// if (hasBalise) { -// objets.addAll(bean.getTransmittingBuoy()); -// } -// } -// -// if (hasBalise) { -// // always reset balise lues of editBean to avoid side-effects -// bean.getTransmittingBuoy().clear(); -// } + boolean hasBalise = !bean.isTransmittingBuoyEmpty(); + + List<TransmittingBuoyDto> objets = new ArrayList<TransmittingBuoyDto>(); + if (!reset) { + if (hasBalise) { + objets.addAll(bean.getTransmittingBuoy()); + } + } + + if (hasBalise) { + // always reset balise lues of editBean to avoid side-effects + bean.getTransmittingBuoy().clear(); + } // clean container JPanel editorPanel = ui.getTransmittingBuoys(); @@ -338,7 +349,7 @@ public class FloatingObjectTransmittingBuoyOperationUIHandler extends ContentUIH ui.getTransmittingBuoyOperation1().getData(); TransmittingBuoyDto transmittingBuoy; - TransmittingBuoyOperationDto objectOperation; + ReferentialReferenceDto<TransmittingBuoyOperationDto> objectOperation; switch (nbBalises) { case 0: // no balise @@ -353,10 +364,10 @@ public class FloatingObjectTransmittingBuoyOperationUIHandler extends ContentUIH case 1: //FIXME -// transmittingBuoy = reset ? null : objets.get(0); -// -// objectOperation = reset ? getObjectOperation(operations, codeOperations[0]) : null; -// bindEditBalise(ui.getTransmittingBuoy1(), objectOperation, transmittingBuoy); + transmittingBuoy = reset ? null : objets.get(0); + + objectOperation = reset ? getObjectOperation(operations, codeOperations[0]) : null; + bindEditBalise(ui.getTransmittingBuoy1(), objectOperation, transmittingBuoy); editorPanel.setLayout(new GridLayout(1, 0)); editorPanel.add(ui.getTransmittingBuoy1Editor()); @@ -368,13 +379,13 @@ public class FloatingObjectTransmittingBuoyOperationUIHandler extends ContentUIH case 2: //FIXME -// transmittingBuoy = reset ? null : objets.get(0); -// objectOperation = reset ? getObjectOperation(operations, codeOperations[0]) : null; -// bindEditBalise(ui.getTransmittingBuoy1(), objectOperation, transmittingBuoy); -// -// transmittingBuoy = reset ? null : objets.get(1); -// objectOperation = reset ? getObjectOperation(operations, codeOperations[1]) : null; -// bindEditBalise(ui.getTransmittingBuoy2(), objectOperation, transmittingBuoy); + transmittingBuoy = reset ? null : objets.get(0); + objectOperation = reset ? getObjectOperation(operations, codeOperations[0]) : null; + bindEditBalise(ui.getTransmittingBuoy1(), objectOperation, transmittingBuoy); + + transmittingBuoy = reset ? null : objets.get(1); + objectOperation = reset ? getObjectOperation(operations, codeOperations[1]) : null; + bindEditBalise(ui.getTransmittingBuoy2(), objectOperation, transmittingBuoy); editorPanel.setLayout(new GridLayout(2, 0)); editorPanel.add(ui.getTransmittingBuoy1Editor()); @@ -398,7 +409,7 @@ public class FloatingObjectTransmittingBuoyOperationUIHandler extends ContentUIH } protected void bindEditBalise(TransmittingBuoyDto editBean, - TransmittingBuoyOperationDto transmittingBuoyOperation, + ReferentialReferenceDto<TransmittingBuoyOperationDto> transmittingBuoyOperation, TransmittingBuoyDto transmittingBuoy) { //FIXME @@ -406,12 +417,11 @@ public class FloatingObjectTransmittingBuoyOperationUIHandler extends ContentUIH if (transmittingBuoy == null) { - //FIXME -// editBean.setTransmittingBuoyOperation(transmittingBuoyOperation); + editBean.setTransmittingBuoyOperation(transmittingBuoyOperation); if (log.isDebugEnabled()) { log.debug("Reuse an empty balise lue for objectOperation " + - transmittingBuoyOperation.getLabel1()); + transmittingBuoyOperation.getPropertyValue(TransmittingBuoyOperationDto.PROPERTY_LABEL1)); } if (isBalisePose(transmittingBuoyOperation)) { @@ -422,7 +432,7 @@ public class FloatingObjectTransmittingBuoyOperationUIHandler extends ContentUIH } } - FloatingObjectDto bean = getBean(); + FloatingObjectTransmittingBuoyDto bean = getBean(); // if (bean.getTransmittingBuoy() == null) { // bean.setTransmittingBuoy(new ArrayList<TransmittingBuoy>()); @@ -430,11 +440,11 @@ public class FloatingObjectTransmittingBuoyOperationUIHandler extends ContentUIH // bean.getTransmittingBuoy().add(editBean); } - protected TransmittingBuoyOperationDto getObjectOperation(List<TransmittingBuoyOperationDto> objectOperations, + protected ReferentialReferenceDto<TransmittingBuoyOperationDto> getObjectOperation(List<ReferentialReferenceDto<TransmittingBuoyOperationDto>> objectOperations, String codeOperation) { - TransmittingBuoyOperationDto objectOperation = null; - for (TransmittingBuoyOperationDto op : objectOperations) { - if (codeOperation.equals(op.getCode())) { + ReferentialReferenceDto<TransmittingBuoyOperationDto> objectOperation = null; + for (ReferentialReferenceDto<TransmittingBuoyOperationDto> op : objectOperations) { + if (codeOperation.equals(op.getPropertyValue(TransmittingBuoyOperationDto.PROPERTY_CODE))) { objectOperation = op; break; } @@ -447,4 +457,9 @@ public class FloatingObjectTransmittingBuoyOperationUIHandler extends ContentUIH return objectOperation; } + //FIXME + protected TransmittingBuoyOperationService getTransmittingBuoyOperationService() { + return null; + } + } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/FloatingObjectTransmittingBuoyOperationUIModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/FloatingObjectTransmittingBuoyOperationUIModel.java index 70dab24..815f408 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/FloatingObjectTransmittingBuoyOperationUIModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/FloatingObjectTransmittingBuoyOperationUIModel.java @@ -23,7 +23,7 @@ package fr.ird.observe.ui.content.impl.seine; */ import fr.ird.observe.business.BinderService; -import fr.ird.observe.services.dto.seine.FloatingObjectDto; +import fr.ird.observe.services.dto.seine.FloatingObjectTransmittingBuoyDto; import fr.ird.observe.ui.content.ContentUIModel; import org.nuiton.util.beans.BinderModelBuilder; @@ -33,7 +33,7 @@ import org.nuiton.util.beans.BinderModelBuilder; * @author Tony Chemit - chemit@codelutin.com * @since XXX */ -public class FloatingObjectTransmittingBuoyOperationUIModel extends ContentUIModel<FloatingObjectDto> { +public class FloatingObjectTransmittingBuoyOperationUIModel extends ContentUIModel<FloatingObjectTransmittingBuoyDto> { private static final long serialVersionUID = 1L; @@ -41,7 +41,7 @@ public class FloatingObjectTransmittingBuoyOperationUIModel extends ContentUIMod // protected TopiaEntityBinder<TransmittingBuoyDto> childLoador; public FloatingObjectTransmittingBuoyOperationUIModel() { - super(FloatingObjectDto.class); + super(FloatingObjectTransmittingBuoyDto.class); String binderName = getClass().getName() + "-open"; @@ -76,12 +76,12 @@ public class FloatingObjectTransmittingBuoyOperationUIModel extends ContentUIMod // } @Override - protected BinderModelBuilder<FloatingObjectDto, FloatingObjectDto> createOpeningBinder(BinderService binderService, String binderName) { + protected BinderModelBuilder<FloatingObjectTransmittingBuoyDto, FloatingObjectTransmittingBuoyDto> createOpeningBinder(BinderService binderService, String binderName) { - BinderModelBuilder<FloatingObjectDto, FloatingObjectDto> builder = binderService.newBinderBuilder( - FloatingObjectDto.class, - FloatingObjectDto.PROPERTY_COMMENT, - FloatingObjectDto.PROPERTY_OBJECT_OPERATION + BinderModelBuilder<FloatingObjectTransmittingBuoyDto, FloatingObjectTransmittingBuoyDto> builder = binderService.newBinderBuilder( + FloatingObjectTransmittingBuoyDto.class, + FloatingObjectTransmittingBuoyDto.PROPERTY_COMMENT +// FloatingObjectTransmittingBuoyDto.PROPERTY_OBJECT_OPERATION ); return builder; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/FloatingObjectUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/FloatingObjectUIHandler.java index 165703c..a1b3d7a 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/FloatingObjectUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/FloatingObjectUIHandler.java @@ -26,6 +26,7 @@ import fr.ird.observe.business.db.DataSource; import fr.ird.observe.business.db.constants.DataContextType; import fr.ird.observe.services.dto.seine.ActivitySeineDto; import fr.ird.observe.services.dto.seine.FloatingObjectDto; +import fr.ird.observe.services.service.seine.FloatingObjectService; import fr.ird.observe.ui.content.ContentMode; import fr.ird.observe.ui.content.ContentUIHandler; import fr.ird.observe.ui.content.ContentUIModel; @@ -153,23 +154,15 @@ public class FloatingObjectUIHandler extends ContentUIHandler<FloatingObjectDto> } //FIXME -// @Override -// protected boolean doSave(FloatingObject bean, -// DataService dataService, -// DataSource dataSource, -// TopiaEntityBinder<FloatingObject> binder) throws Exception { -// -// String activityId = getSelectedParentId(); -// -// if (bean.getTopiaId() == null) { -// -// dataService.create(dataSource, activityId, bean, binder, getCreateExecutor()); -// } else { -// -// dataService.update(dataSource, null, bean, getUpdateExecutor()); -// } -// return true; -// } + @Override + protected boolean doSave(FloatingObjectDto bean) throws Exception { + + String activityId = getSelectedParentId(); + + getFloatingObjectService().save(activityId, bean); + + return true; + } //FIXME // @Override @@ -246,4 +239,8 @@ public class FloatingObjectUIHandler extends ContentUIHandler<FloatingObjectDto> // parentBean.removeFloatingObject(beanToDelete); // } + //FIXME + protected FloatingObjectService getFloatingObjectService() { + return null; + } } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/longline/ActivityLonglineUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/longline/ActivityLonglineUIHandler.java index 4af6b58..7b21fd9 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/longline/ActivityLonglineUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/longline/ActivityLonglineUIHandler.java @@ -22,13 +22,13 @@ package fr.ird.observe.ui.content.open.impl.longline; * #L% */ -import fr.ird.observe.business.ObserveTechnicalException; import fr.ird.observe.business.db.DataContext; import fr.ird.observe.business.db.DataSource; -import fr.ird.observe.business.db.DataSourceException; import fr.ird.observe.business.db.constants.DataContextType; import fr.ird.observe.services.dto.longline.ActivityLonglineDto; import fr.ird.observe.services.dto.longline.TripLonglineDto; +import fr.ird.observe.services.dto.result.TripChildSaveResultDto; +import fr.ird.observe.services.service.longline.ActivityLonglineService; import fr.ird.observe.ui.content.ContentMode; import fr.ird.observe.ui.content.ContentUIModel; import fr.ird.observe.ui.content.open.ContentOpenableUIHandler; @@ -38,9 +38,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.validator.NuitonValidatorScope; -import java.util.Calendar; -import java.util.Date; - import static org.nuiton.i18n.I18n.n; import static org.nuiton.i18n.I18n.t; @@ -271,36 +268,27 @@ public class ActivityLonglineUIHandler extends ContentOpenableUIHandler<Activity model.setModified(create); } - //FIXME -// @Override -// protected boolean doSave(ActivityLongline bean, -// DataService dataService, -// DataSource dataSource, -// TopiaEntityBinder<ActivityLongline> binder) throws Exception { -// -// if (log.isDebugEnabled()) { -// log.debug(" long - lat = " + bean.getLongitude() + " - " + bean.getLatitude()); -// } -// boolean create = bean.getTopiaId() == null; -// -// String tripId = getSelectedParentId(); -// -// bean.setOpen(true); -// -// if (create) { -// bean = dataService.create(dataSource, tripId, bean, binder, getCreateExecutor()); -// -// } else { -// -// dataService.update(dataSource, tripId, bean, getUpdateExecutor()); -// } -// -// updateTripEndDate(tripId); -// -// obtainChildPosition(bean, dataService, dataSource); -// -// return true; -// } + @Override + protected boolean doSave(ActivityLonglineDto bean) throws Exception { + + if (log.isDebugEnabled()) { + log.debug(" long - lat = " + bean.getLongitude() + " - " + bean.getLatitude()); + } + + String tripId = getSelectedParentId(); + + bean.setOpen(true); + + TripChildSaveResultDto saveResult = getActivityLonglineService().save(tripId, getModel().getBean()); + bean.setId(saveResult.getId()); + + setUpdateMareeNodeTag(saveResult.isTripEndDateUpdated()); + + //FIXME quand on gèrera l'arbre +// obtainChildPosition(bean); + + return true; + } //FIXME // @Override @@ -332,30 +320,26 @@ public class ActivityLonglineUIHandler extends ContentOpenableUIHandler<Activity // return beanToSave; // } - //FIXME -// @Override -// protected boolean doDelete(ActivityLongline bean, -// DataService dataService, -// DataSource dataSource, -// TopiaExecutor2<? extends TopiaEntity, ActivityLongline> deletor) throws Exception { -// -// if (askToDelete(bean)) { -// return false; -// } -// if (log.isInfoEnabled()) { -// log.info("Will delete Activity " + bean.getTopiaId()); -// } -// -// String tripId = getSelectedParentId(); -// dataService.delete(dataSource, tripId, bean, deletor); -// if (log.isInfoEnabled()) { -// log.info("Delete done for Activity " + bean.getTopiaId()); -// } -// -// updateTripEndDate(tripId); -// return true; -// -// } + @Override + protected boolean doDelete(ActivityLonglineDto bean) throws Exception { + + if (askToDelete(bean)) { + return false; + } + if (log.isInfoEnabled()) { + log.info("Will delete Activity " + bean.getId()); + } + + String tripId = getSelectedParentId(); + boolean wasTripEndDateUpdated = getActivityLonglineService().delete(tripId, bean.getId()); + if (log.isInfoEnabled()) { + log.info("Delete done for Activity " + bean.getId()); + } + + setUpdateMareeNodeTag(wasTripEndDateUpdated); + return true; + + } //FIXME // @Override @@ -392,31 +376,20 @@ public class ActivityLonglineUIHandler extends ContentOpenableUIHandler<Activity public static final String UPDATE_MAREE_NODE = "updateTripNode"; - //FIXME -// protected void updateTripEndDate(String tripId) { -// -// boolean wasUpdated; -// -// // on met a jour si necessaire la date de fin de la maree -// try { -// wasUpdated = getDataService().updateEndDate(getDataSource(), tripId); -// -// } catch (DataSourceException e) { -// throw new ObserveTechnicalException("Could not update end date", e); -// } -// -// if (wasUpdated) { -// -// // la date de fin a ete modifiee, il faut : redessiner le noeud de la maree le repositionner -// getUi().setContextValue(Boolean.TRUE, UPDATE_MAREE_NODE); -// -// } else { -// -// getUi().removeContextValue(Boolean.class, UPDATE_MAREE_NODE); -// -// } -// -// } + protected void setUpdateMareeNodeTag(boolean wasUpdated) { + + if (wasUpdated) { + + // la date de fin a ete modifiee, il faut : redessiner le noeud de la maree le repositionner + getUi().setContextValue(Boolean.TRUE, UPDATE_MAREE_NODE); + + } else { + + getUi().removeContextValue(Boolean.class, UPDATE_MAREE_NODE); + + } + + } protected void repaintTripNode() { @@ -437,4 +410,8 @@ public class ActivityLonglineUIHandler extends ContentOpenableUIHandler<Activity } + //FIXME + protected ActivityLonglineService getActivityLonglineService() { + return null; + } } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/seine/ActivitySeineUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/seine/ActivitySeineUIHandler.java index 60ff366..23e0109 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/seine/ActivitySeineUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/seine/ActivitySeineUIHandler.java @@ -23,27 +23,23 @@ package fr.ird.observe.ui.content.open.impl.seine; import fr.ird.observe.business.db.DataContext; import fr.ird.observe.business.db.DataSource; -import fr.ird.observe.business.db.DataSourceException; import fr.ird.observe.business.db.constants.DataContextType; 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 fr.ird.observe.services.service.seine.ActivitySeineService; import fr.ird.observe.ui.content.ContentMode; import fr.ird.observe.ui.content.ContentUIModel; import fr.ird.observe.ui.content.open.ContentOpenableUIHandler; -import jaxx.runtime.swing.ErrorDialogUI; import jaxx.runtime.validator.swing.SwingValidatorMessage; import jaxx.runtime.validator.swing.SwingValidatorMessageTableModel; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.nuiton.util.DateUtil; import org.nuiton.validator.NuitonValidatorScope; import javax.swing.event.TableModelEvent; import javax.swing.event.TableModelListener; -import java.util.Date; import java.util.HashSet; -import java.util.List; import java.util.Set; import static org.nuiton.i18n.I18n.n; @@ -314,34 +310,25 @@ public class ActivitySeineUIHandler extends ContentOpenableUIHandler<ActivitySei model.setModified(create); } - //FIXME -// @Override -// protected boolean doSave(ActivitySeine bean, -// DataService dataService, -// DataSource dataSource, -// TopiaEntityBinder<ActivitySeine> binder) throws Exception { -// -// if (log.isDebugEnabled()) { -// log.debug(" long - lat = " + bean.getLongitude() + " - " + bean.getLatitude()); -// } -// boolean create = bean.getTopiaId() == null; -// -// String routeId = getSelectedParentId(); -// -// bean.setOpen(true); -// -// if (create) { -// bean = dataService.create(dataSource, routeId, bean, binder, getCreateExecutor()); -// -// } else { -// -// dataService.update(dataSource, routeId, bean, getUpdateExecutor()); -// } -// -// obtainChildPosition(bean, dataService, dataSource); -// -// return true; -// } + @Override + protected boolean doSave(ActivitySeineDto bean) throws Exception { + + if (log.isDebugEnabled()) { + log.debug(" long - lat = " + bean.getLongitude() + " - " + bean.getLatitude()); + } + + String routeId = getSelectedParentId(); + + bean.setOpen(true); + + String beanId = getActivitySeineService().save(routeId, getModel().getBean()); + bean.setId(beanId); + + //FIXME quand on gèrera l'arbre +// obtainChildPosition(bean); + + return true; + } //FIXME // @Override @@ -378,27 +365,24 @@ public class ActivitySeineUIHandler extends ContentOpenableUIHandler<ActivitySei // return beanToSave; // } - //FIXME -// @Override -// protected boolean doDelete(ActivitySeine bean, -// DataService dataService, -// DataSource dataSource, -// TopiaExecutor2<? extends TopiaEntity, ActivitySeine> deletor) throws Exception { -// -// if (askToDelete(bean)) { -// return false; -// } -// if (log.isInfoEnabled()) { -// log.info("Will delete Activity " + bean.getTopiaId()); -// } -// -// String routeId = getSelectedParentId(); -// dataService.delete(dataSource, routeId, bean, deletor); -// if (log.isInfoEnabled()) { -// log.info("Delete done for Activity " + bean.getTopiaId()); -// } -// return true; -// } + @Override + protected boolean doDelete(ActivitySeineDto bean) throws Exception { + + if (askToDelete(bean)) { + return false; + } + if (log.isInfoEnabled()) { + log.info("Will delete Activity " + bean.getId()); + } + + String routeId = getSelectedParentId(); + getActivitySeineService().delete(routeId, bean.getId()); + + if (log.isInfoEnabled()) { + log.info("Delete done for Activity " + bean.getId()); + } + return true; + } //FIXME @@ -460,4 +444,10 @@ public class ActivitySeineUIHandler extends ContentOpenableUIHandler<ActivitySei } + + //FIXME + protected ActivitySeineService getActivitySeineService() { + return null; + } + } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/ContentReferenceUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/ContentReferenceUIHandler.java index f71bc47..dfebca8 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/ContentReferenceUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/ContentReferenceUIHandler.java @@ -26,15 +26,21 @@ import fr.ird.observe.ObserveSwingApplicationContext; import fr.ird.observe.business.db.DataContext; import fr.ird.observe.business.db.DataSource; import fr.ird.observe.business.validation.ValidationContext; +import fr.ird.observe.services.dto.FormDto; import fr.ird.observe.services.dto.IdDto; +import fr.ird.observe.services.dto.ReferenceDto; +import fr.ird.observe.services.dto.constants.ReferenceStatus; import fr.ird.observe.services.dto.constants.ReferentialLocale; import fr.ird.observe.services.dto.referential.I18nReferentialDto; +import fr.ird.observe.services.dto.referential.ProgramDto; import fr.ird.observe.services.dto.referential.ReferentialDto; import fr.ird.observe.services.dto.referential.VesselSizeCategoryDto; +import fr.ird.observe.services.service.ReferentialService; import fr.ird.observe.ui.DecoratorService; import fr.ird.observe.ui.UIHelper; import fr.ird.observe.ui.content.ContentMode; import fr.ird.observe.ui.content.ContentUIHandler; +import fr.ird.observe.ui.tree.ObserveTreeHelper; import fr.ird.observe.ui.usage.UsagesUI; import fr.ird.observe.ui.util.SpringUtilities; import jaxx.runtime.JAXXContext; @@ -45,24 +51,10 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.decorator.Decorator; -import javax.swing.JButton; -import javax.swing.JComponent; -import javax.swing.JLabel; -import javax.swing.JList; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; -import javax.swing.JScrollPane; -import javax.swing.JTable; -import javax.swing.JToolBar; -import javax.swing.ListModel; -import javax.swing.SpringLayout; -import javax.swing.SwingUtilities; +import javax.swing.*; import javax.swing.border.TitledBorder; import javax.swing.table.TableCellRenderer; -import java.awt.Container; -import java.awt.Dimension; -import java.awt.Font; +import java.awt.*; import java.beans.Introspector; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; @@ -114,7 +106,7 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content E entity, Map<Class<? extends IdDto>, List<? extends IdDto>> usages) { - DecoratorService service = ObserveSwingApplicationContext.get().getDecoratorService(); + DecoratorService service = ObserveContext.get().getDecoratorService(); Decorator<?> decorator = service.getDecoratorByType(entity.getClass()); String type = DecoratorService.getEntityLabel(entity.getClass()); type = t(type); @@ -142,7 +134,7 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content E entity, Map<Class<? extends IdDto>, List<? extends IdDto>> usages) { - DecoratorService service = ObserveSwingApplicationContext.get().getDecoratorService(); + DecoratorService service = ObserveContext.get().getDecoratorService(); Decorator<?> decorator = service.getDecoratorByType(entity.getClass()); String type = DecoratorService.getEntityLabel(entity.getClass()); type = t(type); @@ -185,6 +177,10 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content //FIXME // getLoadBinder().load(selectedBean, getBean(), true); + loadBean(selectedBean); + + //TODO update data cache + } @Override @@ -333,7 +329,7 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content // } // return; // } - DecoratorService dService = ObserveSwingApplicationContext.get().getDecoratorService(); + DecoratorService dService = ObserveContext.get().getDecoratorService(); Decorator<?> decorator = dService.getDecoratorByType(bean.getClass()); String type = DecoratorService.getEntityLabel(bean.getClass()); type = t(type); @@ -399,7 +395,6 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content public void initUI() throws Exception { ReferentialContentUIInitializer<E, ContentReferenceUI<E>> uiInitializer = new ReferentialContentUIInitializer<E, ContentReferenceUI<E>>(getUi()); - //FIXME uiInitializer.initUI(); ContentReferenceUI<E> ui = getUi(); @@ -540,9 +535,8 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content @Override protected void prepareValidationContext() { super.prepareValidationContext(); - //FIXME - BeanListHeader<E> jList = (BeanListHeader)getUi().getListHeader(); - List<E> data = jList.getData(); + BeanListHeader<ReferenceDto> jList = getUi().getListHeader(); + List<ReferenceDto> data = jList.getData(); ValidationContext validationContext = ObserveServiceHelper.get().getValidationContext(); if (log.isDebugEnabled()) { @@ -569,6 +563,7 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content //FIXME // getLoadBinder().load(null, getBean(), true); + loadBean((E) null); // on demarre l'edition ui.startEdit(null); @@ -585,6 +580,7 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content //FIXME // getLoadBinder().load(model.getSelectedBean(), getBean(), true); + loadBean(model.getSelectedBean()); getUi().startEdit(null); } @@ -627,57 +623,52 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content // repush selected bean to bean //FIXME // getLoadBinder().load(model.getSelectedBean(), getBean(), true); + loadBean(model.getSelectedBean()); } } //FIXME -// @Override -// protected boolean doSave(E bean, -// DataService dataService, -// DataSource dataSource, -// TopiaEntityBinder<E> binder) throws Exception { -// -// ContentReferenceUIModel<EDto> model = getModel(); -// -// if (bean.getTopiaId() == null) { -// -// if (log.isInfoEnabled()) { -// log.info("Create referentiel " + bean); -// } -// dataService.create(dataSource, -// null, -// bean, -// binder, -// getCreateExecutor() -// ); -// -// if (bean instanceof Program) { -// -// // add the program in tree -// ObserveTreeHelper treeHelper = getTreeHelper(getUi()); -// treeHelper.addProgram((Program) bean); -// } -// -// return true; -// } -// -// if (log.isInfoEnabled()) { -// log.info("Will update exisintg entity : " + bean.getTopiaId()); -// } -// // le bean original -// E oldBean = model.getSelectedBean(); -// -// if (oldBean != null && -// oldBean.getStatus() == ReferenceStatus.enabled && -// bean.getStatus() == ReferenceStatus.disabled) { -// -// // l'entite a ete desactive -// // on recherche les objets utilisant cette entitee -// // on indique a l'utilisateur ce changement -// if (log.isDebugEnabled()) { -// log.debug("entity status was desactivated, looking " + -// "for usage"); -// } + @Override + protected boolean doSave(E bean) throws Exception { + + ContentReferenceUIModel<E> model = getModel(); + + if (bean.getId() == null) { + + if (log.isInfoEnabled()) { + log.info("Create referentiel " + bean); + } + + String beanId = getReferentialService().save(bean); + bean.setId(beanId); + + if (bean instanceof ProgramDto) { + + // add the program in tree + ObserveTreeHelper treeHelper = getTreeHelper(getUi()); + treeHelper.addProgram((ProgramDto) bean); + } + + return true; + } + + if (log.isInfoEnabled()) { + log.info("Will update exisintg entity : " + bean.getId()); + } + // le bean original + E oldBean = model.getSelectedBean(); + + if (oldBean != null && + oldBean.getStatus() == ReferenceStatus.enabled && + bean.getStatus() == ReferenceStatus.disabled) { + + // l'entite a ete desactive + // on recherche les objets utilisant cette entitee + // on indique a l'utilisateur ce changement + if (log.isDebugEnabled()) { + log.debug("entity status was desactivated, looking " + + "for usage"); + } // EntityMap usages = dataService.findAllUsages(dataSource, bean); // // if (usages.isEmpty()) { @@ -696,23 +687,22 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content // return false; // } // } -// } -// // sauvegarde du bean d'edition dans le bean de la base -// bean = dataService.update(dataSource, -// null, // pas de parent a sauvegarder -// bean, -// getUpdateExecutor() -// ); -// -// if (bean instanceof Program) { -// -// // update the program in tree -// ObserveTreeHelper treeHelper = getTreeHelper(getUi()); -// treeHelper.updateProgram((Program) bean); -// } -// -// return true; -// } + } + + + // sauvegarde du bean d'edition dans le bean de la base + String beanId = getReferentialService().save(bean); + bean.setId(beanId); + + if (bean instanceof ProgramDto) { + + // update the program in tree + ObserveTreeHelper treeHelper = getTreeHelper(getUi()); + treeHelper.updateProgram((ProgramDto) bean); + } + + return true; + } //FIXME // @Override @@ -726,19 +716,16 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content //FIXME @Override -// protected boolean doDelete(E bean, -// DataService dataService, -// DataSource dataSource, -// TopiaExecutor2<? extends TopiaEntity, E> deletor) throws Exception { -// -// ContentReferenceUI<E> ui = getUi(); -// ContentReferenceUIModel<EDto> model = getModel(); -// -// if (log.isInfoEnabled()) { -// log.info("entity to be deleted, looking for usage"); -// } -// -// // recherche des utilisation du bean dans la base + protected boolean doDelete(E bean) throws Exception { + + ContentReferenceUI<E> ui = getUi(); + ContentReferenceUIModel<E> model = getModel(); + + if (log.isInfoEnabled()) { + log.info("entity to be deleted, looking for usage"); + } + + // recherche des utilisation du bean dans la base // EntityMap usages = dataService.findAllUsages(getDataSource(), bean); // // if (usages.isEmpty()) { @@ -754,22 +741,22 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content // showUsagesForDelete(ui, bean, usages); // return false; // } -// -// if (!UIHelper.confirmForEntityDelete(ui, model.getBeanType(), bean)) { -// return false; -// } -// -// String beanId = bean.getTopiaId(); -// dataService.delete(dataSource, null, bean, deletor); -// -// if (bean instanceof Program) { -// -// // remove the program in tree -// ObserveTreeHelper treeHelper = getTreeHelper(getUi()); -// treeHelper.removeProgram(beanId); -// } -// return true; -// } + + if (!UIHelper.confirmForEntityDelete(ui, model.getBeanType(), bean)) { + return false; + } + + String beanId = bean.getId(); + getReferentialService().delete(getBeanType(), beanId); + + if (bean instanceof ProgramDto) { + + // remove the program in tree + ObserveTreeHelper treeHelper = getTreeHelper(getUi()); + treeHelper.removeProgram(beanId); + } + return true; + } //FIXME // @Override @@ -864,4 +851,24 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content ContentReferenceUI.DETAIL_VIEW : ContentReferenceUI.LIST_VIEW; } + + @Override + protected FormDto<E> loadToEdit(String id) { + ReferentialService referentialService = getReferentialService(); + FormDto<E> formDto = referentialService.loadToEdit(getBeanType(), id); + return formDto; + } + + @Override + protected FormDto<E> loadToReadDto(String id) { + ReferentialService referentialService = getReferentialService(); + FormDto<E> formDto = referentialService.loadToRead(getBeanType(), id); + return formDto; + } + + //FIXME + protected ReferentialService getReferentialService() { + return null; + } + } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableUIHandler.java index b3249d7..47438ab 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableUIHandler.java @@ -35,6 +35,7 @@ import fr.ird.observe.ui.content.ContentMode; import fr.ird.observe.ui.content.ContentUIHandler; import fr.ird.observe.ui.content.ObserveContentUI; import fr.ird.observe.ui.tree.ObserveNode; +import jaxx.runtime.swing.ErrorDialogUI; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.validator.NuitonValidatorScope; @@ -348,42 +349,35 @@ public abstract class ContentTableUIHandler<E extends IdDto, D extends IdDto> ex } //FIXME -// @Override -// protected boolean doSave(E bean, -// DataService dataService, -// DataSource dataSource, -// TopiaEntityBinder<E> binder) throws Exception { -// -// ObserveContentTableUI<E, D> ui = getUi(); -// -// List<D> objets = ui.getTableModel().getData(); -// -// boolean canContinue; -// try { -// canContinue = prepareSave(bean, objets); -// } catch (Exception e) { -// if (log.isErrorEnabled()) { -// log.error(e); -// } -// ErrorDialogUI.showError(e); -// canContinue = false; -// } -// if (!canContinue) { -// -// // l'utilisateur a choisi de ne pas sauvegarder -// return false; -// } -// doPersist(bean, dataService, dataSource); -// -// -// return true; -// } + @Override + protected boolean doSave(E bean) throws Exception { - //FIXME -// protected void doPersist(E bean, DataService dataService, DataSource dataSource) throws DataSourceException { -// // sauvegarde du bean en base -// dataService.update(dataSource, null, bean, getUpdateExecutor()); -// } + ObserveContentTableUI<E, D> ui = getUi(); + + List<D> objets = ui.getTableModel().getData(); + + boolean canContinue; + try { + canContinue = prepareSave(bean, objets); + } catch (Exception e) { + if (log.isErrorEnabled()) { + log.error(e); + } + ErrorDialogUI.showError(e); + canContinue = false; + } + if (!canContinue) { + + // l'utilisateur a choisi de ne pas sauvegarder + return false; + } + doPersist(bean); + + + return true; + } + + protected abstract void doPersist(E bean); //FIXME // @Override diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/ReferentialServiceController.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/ReferentialServiceController.java index a917f4f..c28786d 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/ReferentialServiceController.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/ReferentialServiceController.java @@ -68,8 +68,8 @@ public class ReferentialServiceController extends ObserveAuthenticatedServiceCon } @Override - public <R extends ReferentialDto> String save(FormDto<R> form) { - return service.save(form); + public <R extends ReferentialDto> String save(R bean) { + return service.save(bean); } @Override diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/longline/ActivityLonglineServiceController.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/longline/ActivityLonglineServiceController.java index 88ed874..10d8c27 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/longline/ActivityLonglineServiceController.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/longline/ActivityLonglineServiceController.java @@ -26,6 +26,7 @@ import fr.ird.observe.application.web.controller.v1.ObserveAuthenticatedServiceC import fr.ird.observe.services.dto.FormDto; import fr.ird.observe.services.dto.longline.ActivityLonglineDto; import fr.ird.observe.services.dto.longline.ActivityLonglineStubDto; +import fr.ird.observe.services.dto.result.TripChildSaveResultDto; import fr.ird.observe.services.service.longline.ActivityLonglineService; import java.util.List; @@ -60,12 +61,12 @@ public class ActivityLonglineServiceController extends ObserveAuthenticatedServi } @Override - public String save(String tripLonglineId, FormDto<ActivityLonglineDto> form) { - return service.save(tripLonglineId, form); + public TripChildSaveResultDto save(String tripLonglineId, ActivityLonglineDto bean) { + return service.save(tripLonglineId, bean); } @Override - public void delete(String tripLonglineId, String activityLonglineId) { - service.delete(tripLonglineId, activityLonglineId); + public boolean delete(String tripLonglineId, String activityLonglineId) { + return service.delete(tripLonglineId, activityLonglineId); } } diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/seine/ActivitySeineServiceController.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/seine/ActivitySeineServiceController.java index daec866..7c0d960 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/seine/ActivitySeineServiceController.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/seine/ActivitySeineServiceController.java @@ -60,8 +60,8 @@ public class ActivitySeineServiceController extends ObserveAuthenticatedServiceC } @Override - public String save(String routeId, FormDto<ActivitySeineDto> form) { - return service.save(routeId, form); + public String save(String routeId, ActivitySeineDto dto) { + return service.save(routeId, dto); } @Override diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/seine/FloatingObjectServiceController.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/seine/FloatingObjectServiceController.java index a819989..f2b2ce4 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/seine/FloatingObjectServiceController.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/seine/FloatingObjectServiceController.java @@ -60,8 +60,8 @@ public class FloatingObjectServiceController extends ObserveAuthenticatedService } @Override - public String save(String activitySeineId, FormDto<FloatingObjectDto> form) { - return service.save(activitySeineId, form); + public String save(String activitySeineId, FloatingObjectDto dto) { + return service.save(activitySeineId, dto); } @Override diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/seine/TransmittingBuoyOperationServiceController.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/seine/TransmittingBuoyOperationServiceController.java index 53171fc..a291d0f 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/seine/TransmittingBuoyOperationServiceController.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/seine/TransmittingBuoyOperationServiceController.java @@ -47,7 +47,7 @@ public class TransmittingBuoyOperationServiceController extends ObserveAuthentic } @Override - public String save(FormDto<FloatingObjectTransmittingBuoyDto> form) { - return service.save(form); + public String save(FloatingObjectTransmittingBuoyDto dto) { + return service.save(dto); } } diff --git a/observe-services-api/src/main/java/fr/ird/observe/services/service/ReferentialService.java b/observe-services-api/src/main/java/fr/ird/observe/services/service/ReferentialService.java index 950b4fe..9d4921f 100644 --- a/observe-services-api/src/main/java/fr/ird/observe/services/service/ReferentialService.java +++ b/observe-services-api/src/main/java/fr/ird/observe/services/service/ReferentialService.java @@ -60,7 +60,7 @@ public interface ReferentialService extends ObserveService { @WriteReferentialPermission @Write @PostRequest - <R extends ReferentialDto> String save(FormDto<R> form); + <R extends ReferentialDto> String save(R bean); @WriteReferentialPermission @Write diff --git a/observe-services-api/src/main/java/fr/ird/observe/services/service/longline/ActivityLonglineService.java b/observe-services-api/src/main/java/fr/ird/observe/services/service/longline/ActivityLonglineService.java index 607a902..14812b8 100644 --- a/observe-services-api/src/main/java/fr/ird/observe/services/service/longline/ActivityLonglineService.java +++ b/observe-services-api/src/main/java/fr/ird/observe/services/service/longline/ActivityLonglineService.java @@ -26,6 +26,7 @@ import fr.ird.observe.services.ObserveService; import fr.ird.observe.services.dto.FormDto; import fr.ird.observe.services.dto.longline.ActivityLonglineDto; import fr.ird.observe.services.dto.longline.ActivityLonglineStubDto; +import fr.ird.observe.services.dto.result.TripChildSaveResultDto; import fr.ird.observe.services.spi.DeleteRequest; import fr.ird.observe.services.spi.PostRequest; import fr.ird.observe.services.spi.ReadDataPermission; @@ -54,10 +55,13 @@ public interface ActivityLonglineService extends ObserveService { @Write @WriteDataPermission @PostRequest - String save(String tripLonglineId, FormDto<ActivityLonglineDto> form); + TripChildSaveResultDto save(String tripLonglineId, ActivityLonglineDto bean); @Write @WriteDataPermission @DeleteRequest - void delete(String tripLonglineId, String activityLonglineId); + /** + * @return true if the trip end date has been updated + */ + boolean delete(String tripLonglineId, String activityLonglineId); } diff --git a/observe-services-api/src/main/java/fr/ird/observe/services/service/seine/ActivitySeineService.java b/observe-services-api/src/main/java/fr/ird/observe/services/service/seine/ActivitySeineService.java index 161bd55..cb6549d 100644 --- a/observe-services-api/src/main/java/fr/ird/observe/services/service/seine/ActivitySeineService.java +++ b/observe-services-api/src/main/java/fr/ird/observe/services/service/seine/ActivitySeineService.java @@ -54,7 +54,7 @@ public interface ActivitySeineService extends ObserveService { @Write @WriteDataPermission @PostRequest - String save(String routeId, FormDto<ActivitySeineDto> form); + String save(String routeId, ActivitySeineDto dto); @Write @WriteDataPermission diff --git a/observe-services-api/src/main/java/fr/ird/observe/services/service/seine/FloatingObjectService.java b/observe-services-api/src/main/java/fr/ird/observe/services/service/seine/FloatingObjectService.java index 424aa7d..7a541fd 100644 --- a/observe-services-api/src/main/java/fr/ird/observe/services/service/seine/FloatingObjectService.java +++ b/observe-services-api/src/main/java/fr/ird/observe/services/service/seine/FloatingObjectService.java @@ -54,7 +54,7 @@ public interface FloatingObjectService extends ObserveService { @Write @WriteDataPermission @PostRequest - String save(String activitySeineId, FormDto<FloatingObjectDto> form); + String save(String activitySeineId, FloatingObjectDto dto); @Write @WriteDataPermission diff --git a/observe-services-api/src/main/java/fr/ird/observe/services/service/seine/TransmittingBuoyOperationService.java b/observe-services-api/src/main/java/fr/ird/observe/services/service/seine/TransmittingBuoyOperationService.java index 88cf87e..72987d9 100644 --- a/observe-services-api/src/main/java/fr/ird/observe/services/service/seine/TransmittingBuoyOperationService.java +++ b/observe-services-api/src/main/java/fr/ird/observe/services/service/seine/TransmittingBuoyOperationService.java @@ -44,6 +44,6 @@ public interface TransmittingBuoyOperationService extends ObserveService { @Write @WriteDataPermission @PostRequest - String save(FormDto<FloatingObjectTransmittingBuoyDto> form); + String save(FloatingObjectTransmittingBuoyDto dto); } diff --git a/observe-services-model/src/main/xmi/observe-services-dto-common.zargo b/observe-services-model/src/main/xmi/observe-services-dto-common.zargo index 59c5da7..346fde6 100644 Binary files a/observe-services-model/src/main/xmi/observe-services-dto-common.zargo and b/observe-services-model/src/main/xmi/observe-services-dto-common.zargo differ diff --git a/observe-services-model/src/main/xmi/observe-services-dto-common.zargo b/observe-services-model/src/main/xmi/observe-services-dto-common.zargo~ similarity index 100% copy from observe-services-model/src/main/xmi/observe-services-dto-common.zargo copy to observe-services-model/src/main/xmi/observe-services-dto-common.zargo~ diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/service/ReferentialServiceTopia.java b/observe-services-topia/src/main/java/fr/ird/observe/services/service/ReferentialServiceTopia.java index 70b7b16..0b8c41f 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/service/ReferentialServiceTopia.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/service/ReferentialServiceTopia.java @@ -86,10 +86,10 @@ public class ReferentialServiceTopia extends ObserveServiceTopia implements Refe return form; } - public <D extends ReferentialDto> String save(FormDto<D> form) { - Class<D> dtoType = form.getType(); + public <D extends ReferentialDto> String save(D bean) { + Class<D> dtoType = (Class<D>) bean.getClass(); Class<TopiaEntity> entityType = getEntityType(dtoType); - TopiaEntity entity = dtoToEntity(dtoType, entityType, form.getForm()); + TopiaEntity entity = dtoToEntity(dtoType, entityType, bean); entity = saveEntity(entityType, entity); FormDto<D> model = entityToEditFormDto(dtoType, entityType, entity); return model.getForm().getId(); diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/service/longline/ActivityLonglineServiceTopia.java b/observe-services-topia/src/main/java/fr/ird/observe/services/service/longline/ActivityLonglineServiceTopia.java index 101dd16..b0e1928 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/service/longline/ActivityLonglineServiceTopia.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/service/longline/ActivityLonglineServiceTopia.java @@ -27,11 +27,13 @@ import com.google.common.collect.Lists; import fr.ird.observe.entities.constants.ReferenceLocale; import fr.ird.observe.entities.longline.ActivityLongline; import fr.ird.observe.entities.longline.TripLongline; +import fr.ird.observe.entities.longline.TripLonglineTopiaDao; import fr.ird.observe.services.ObserveServiceTopia; import fr.ird.observe.services.dto.FormDto; import fr.ird.observe.services.dto.longline.ActivityLonglineDto; import fr.ird.observe.services.dto.longline.ActivityLonglineStubDto; import fr.ird.observe.services.dto.longline.TripLonglineDto; +import fr.ird.observe.services.dto.result.TripChildSaveResultDto; import fr.ird.observe.services.service.DataNotFoundException; import fr.ird.type.CoordinateHelper; @@ -140,16 +142,18 @@ public class ActivityLonglineServiceTopia extends ObserveServiceTopia implements } @Override - public String save(String tripLonglineId, FormDto<ActivityLonglineDto> form) { + public TripChildSaveResultDto save(String tripLonglineId, ActivityLonglineDto activityLonglineDto) { - TripLongline tripLongline = loadEntity(TripLonglineDto.class, TripLongline.class, tripLonglineId); + TripChildSaveResultDto result = new TripChildSaveResultDto(); - ActivityLonglineDto activityLonglineDto = form.getForm(); + TripLongline tripLongline = loadEntity(TripLonglineDto.class, TripLongline.class, tripLonglineId); ActivityLongline activityLongline = dtoToEntity(ActivityLonglineDto.class, ActivityLongline.class, activityLonglineDto); activityLongline = saveEntity(ActivityLongline.class, activityLongline); + result.setId(activityLongline.getTopiaId()); + if (activityLonglineDto.isNotPersisted()) { tripLongline.addActivityLongline(activityLongline); @@ -158,12 +162,17 @@ public class ActivityLonglineServiceTopia extends ObserveServiceTopia implements } - return activityLongline.getTopiaId(); + TripLonglineTopiaDao tripLonglineTopiaDao = getTopiaPersistenceContext().getTripLonglineDao(); + boolean wasEndDateUpdated = tripLonglineTopiaDao.updateEndDate(tripLongline); + + result.setTripEndDateUpdated(wasEndDateUpdated); + + return result; } @Override - public void delete(String tripLonglineId, String activityLonglineId) { + public boolean delete(String tripLonglineId, String activityLonglineId) { TripLongline tripLongline = loadEntity(TripLonglineDto.class, TripLongline.class, tripLonglineId); @@ -177,7 +186,10 @@ public class ActivityLonglineServiceTopia extends ObserveServiceTopia implements tripLongline.removeActivityLongline(activityLongline); - } + TripLonglineTopiaDao tripLonglineTopiaDao = getTopiaPersistenceContext().getTripLonglineDao(); + boolean wasEndDateUpdated = tripLonglineTopiaDao.updateEndDate(tripLongline); + return wasEndDateUpdated; + } } diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/ActivitySeineServiceTopia.java b/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/ActivitySeineServiceTopia.java index 2dc4065..4c286b4 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/ActivitySeineServiceTopia.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/ActivitySeineServiceTopia.java @@ -140,12 +140,10 @@ public class ActivitySeineServiceTopia extends ObserveServiceTopia implements Ac } @Override - public String save(String routeId, FormDto<ActivitySeineDto> form) { + public String save(String routeId, ActivitySeineDto activitySeineDto) { Route route = loadEntity(RouteDto.class, Route.class, routeId); - ActivitySeineDto activitySeineDto = form.getForm(); - ActivitySeine activitySeine = dtoToEntity(ActivitySeineDto.class, ActivitySeine.class, activitySeineDto); activitySeine = saveEntity(ActivitySeine.class, activitySeine); diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/FloatingObjectServiceTopia.java b/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/FloatingObjectServiceTopia.java index de441c3..18a8b19 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/FloatingObjectServiceTopia.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/FloatingObjectServiceTopia.java @@ -92,12 +92,10 @@ public class FloatingObjectServiceTopia extends ObserveServiceTopia implements F } @Override - public String save(String activitySeineId, FormDto<FloatingObjectDto> form) { + public String save(String activitySeineId, FloatingObjectDto floatingObjectDto) { ActivitySeine activitySeine = loadEntity(ActivitySeineDto.class, ActivitySeine.class, activitySeineId); - FloatingObjectDto floatingObjectDto = form.getForm(); - FloatingObject floatingObject = dtoToEntity(FloatingObjectDto.class, FloatingObject.class, floatingObjectDto); floatingObject = saveEntity(FloatingObject.class, floatingObject); diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/TransmittingBuoyOperationServiceTopia.java b/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/TransmittingBuoyOperationServiceTopia.java index b8027b9..a505456 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/TransmittingBuoyOperationServiceTopia.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/TransmittingBuoyOperationServiceTopia.java @@ -64,10 +64,10 @@ public class TransmittingBuoyOperationServiceTopia extends ObserveServiceTopia i } @Override - public String save(FormDto<FloatingObjectTransmittingBuoyDto> form) { + public String save(FloatingObjectTransmittingBuoyDto dto) { FloatingObject floatingObject = - dtoToEntity(FloatingObjectTransmittingBuoyDto.class, FloatingObject.class, form.getForm()); + dtoToEntity(FloatingObjectTransmittingBuoyDto.class, FloatingObject.class, dto); floatingObject = saveEntity(FloatingObject.class, floatingObject); -- 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/7531 in repository observe. See http://git.codelutin.com/observe.git commit 4a26bd22257c118708548289976a12a23c7fe298 Author: Kevin Morin <morin@codelutin.com> Date: Thu Sep 24 18:15:26 2015 +0200 utilisation des services dans doSave et doDelete --- .../impl/longline/SetLonglineUIHandler.java | 68 +++++------ .../impl/seine/FloatingObjectUIHandler.java | 42 ++++--- .../ui/content/impl/seine/SetSeineUIHandler.java | 70 +++++------ .../open/impl/longline/TripLonglineUIHandler.java | 112 ++++++++--------- .../ui/content/open/impl/seine/RouteUIHandler.java | 133 +++++++++------------ .../open/impl/seine/TripSeineUIHandler.java | 109 ++++++++--------- .../ui/content/table/ContentTableUIHandler.java | 1 - .../impl/seine/TargetDiscardCatchUIHandler.java | 35 +++--- .../v1/longline/SetLonglineServiceController.java | 4 +- .../v1/longline/TripLonglineServiceController.java | 4 +- .../v1/seine/RouteServiceController.java | 9 +- .../v1/seine/SetSeineServiceController.java | 4 +- .../v1/seine/TripSeineServiceController.java | 4 +- .../service/longline/SetLonglineService.java | 2 +- .../service/longline/TripLonglineService.java | 2 +- .../services/service/seine/RouteService.java | 5 +- .../services/service/seine/SetSeineService.java | 2 +- .../services/service/seine/TripSeineService.java | 2 +- .../services/dto/ObserveDtosInitializer.java | 5 + .../service/longline/SetLonglineServiceTopia.java | 4 +- .../service/longline/TripLonglineServiceTopia.java | 7 +- .../services/service/seine/RouteServiceTopia.java | 36 +++++- .../service/seine/SetSeineServiceTopia.java | 5 +- .../service/seine/TripSeineServiceTopia.java | 7 +- .../fr/ird/observe/services/service/RigthTest.java | 2 +- 25 files changed, 338 insertions(+), 336 deletions(-) diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/SetLonglineUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/SetLonglineUIHandler.java index 0ed76f6..62b2f46 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/SetLonglineUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/SetLonglineUIHandler.java @@ -27,6 +27,7 @@ import fr.ird.observe.business.db.DataSource; import fr.ird.observe.business.db.constants.DataContextType; import fr.ird.observe.services.dto.longline.ActivityLonglineDto; import fr.ird.observe.services.dto.longline.SetLonglineDto; +import fr.ird.observe.services.service.longline.SetLonglineService; import fr.ird.observe.ui.content.ContentMode; import fr.ird.observe.ui.content.ContentUIHandler; import fr.ird.observe.ui.content.ContentUIModel; @@ -388,27 +389,17 @@ public class SetLonglineUIHandler extends ContentUIHandler<SetLonglineDto> { } //FIXME -// @Override -// protected boolean doSave(SetLongline bean, -// DataService dataService, -// DataSource dataSource, -// TopiaEntityBinder<SetLongline> binder) throws Exception { -// -// String activityId = getSelectedParentId(); -// -// if (bean.getTopiaId() == null) { -// -// dataService.create(dataSource, activityId, bean, binder, getCreateExecutor()); -// -// } else { -// -// dataService.update(dataSource, null, bean, getUpdateExecutor()); -// -// } -// -// return true; -// -// } + @Override + protected boolean doSave(SetLonglineDto bean) throws Exception { + + String activityId = getSelectedParentId(); + + String beanId = getSetLonglineService().save(activityId, bean); + bean.setId(beanId); + + return true; + + } //FIXME // @Override @@ -477,23 +468,19 @@ public class SetLonglineUIHandler extends ContentUIHandler<SetLonglineDto> { } - //FIXME -// @Override -// protected boolean doDelete(SetLongline bean, -// DataService dataService, -// DataSource dataSource, -// TopiaExecutor2<? extends TopiaEntity, SetLongline> deletor) throws Exception { -// -// if (askToDelete(bean)) { -// return false; -// } -// -// String activityId = getSelectedParentId(); -// dataService.delete(dataSource, activityId, bean, deletor); -// -// return true; -// -// } + @Override + protected boolean doDelete(SetLonglineDto bean) throws Exception { + + if (askToDelete(bean)) { + return false; + } + + String activityId = getSelectedParentId(); + getSetLonglineService().delete(activityId, bean.getId()); + + return true; + + } //FIXME // @Override @@ -588,4 +575,9 @@ public class SetLonglineUIHandler extends ContentUIHandler<SetLonglineDto> { } } + + //FIXME + protected SetLonglineService getSetLonglineService() { + return null; + } } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/FloatingObjectUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/FloatingObjectUIHandler.java index a1b3d7a..5314afd 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/FloatingObjectUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/FloatingObjectUIHandler.java @@ -24,6 +24,7 @@ package fr.ird.observe.ui.content.impl.seine; import fr.ird.observe.business.db.DataContext; import fr.ird.observe.business.db.DataSource; import fr.ird.observe.business.db.constants.DataContextType; +import fr.ird.observe.services.dto.FormDto; import fr.ird.observe.services.dto.seine.ActivitySeineDto; import fr.ird.observe.services.dto.seine.FloatingObjectDto; import fr.ird.observe.services.service.seine.FloatingObjectService; @@ -213,24 +214,29 @@ public class FloatingObjectUIHandler extends ContentUIHandler<FloatingObjectDto> } } - //FIXME -// @Override -// protected boolean doDelete(FloatingObject bean, -// DataService dataService, -// DataSource dataSource, -// TopiaExecutor2<? extends TopiaEntity, FloatingObject> deletor) throws Exception { -// -// if (askToDelete(bean)) { -// return false; -// } -// -// if (bean.getTopiaId() != null) { -// -// String activityId = getSelectedParentId(); -// dataService.delete(dataSource, activityId, bean, deletor); -// } -// return true; -// } + @Override + protected FormDto<FloatingObjectDto> loadToEdit(String id) { + return null; + } + + @Override + protected FormDto<FloatingObjectDto> loadToReadDto(String id) { + return null; + } + + protected boolean doDelete(FloatingObjectDto bean) throws Exception { + + if (askToDelete(bean)) { + return false; + } + + if (bean.getId() != null) { + + String activityId = getSelectedParentId(); + getFloatingObjectService().delete(activityId, bean.getId()); + } + return true; + } //FIXME // @Override diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/SetSeineUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/SetSeineUIHandler.java index 7c0201b..3b17d4f 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/SetSeineUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/SetSeineUIHandler.java @@ -24,9 +24,11 @@ package fr.ird.observe.ui.content.impl.seine; import fr.ird.observe.business.db.DataContext; import fr.ird.observe.business.db.DataSource; import fr.ird.observe.business.db.constants.DataContextType; +import fr.ird.observe.services.dto.FormDto; import fr.ird.observe.services.dto.constants.seine.SchoolType; import fr.ird.observe.services.dto.seine.ActivitySeineDto; import fr.ird.observe.services.dto.seine.SetSeineDto; +import fr.ird.observe.services.service.seine.SetSeineService; import fr.ird.observe.ui.content.ContentMode; import fr.ird.observe.ui.content.ContentUIHandler; import fr.ird.observe.ui.content.ContentUIModel; @@ -284,25 +286,16 @@ public class SetSeineUIHandler extends ContentUIHandler<SetSeineDto> { model.setModified(create); } - //FIXME -// @Override -// protected boolean doSave(SetSeine bean, -// DataService dataService, -// DataSource dataSource, -// TopiaEntityBinder<SetSeine> binder) throws Exception { -// -// String activityId = getSelectedParentId(); -// -// if (bean.getTopiaId() == null) { -// -// dataService.create(dataSource, activityId, bean, binder, getCreateExecutor()); -// } else { -// -// dataService.update(dataSource, null, bean, getUpdateExecutor()); -// -// } -// return true; -// } + @Override + protected boolean doSave(SetSeineDto bean) throws Exception { + + String activityId = getSelectedParentId(); + + String beanId = getSetSeineService().save(activityId, bean); + bean.setId(beanId); + + return true; + } //FIXME // @Override @@ -354,21 +347,26 @@ public class SetSeineUIHandler extends ContentUIHandler<SetSeineDto> { } } - //FIXME -// @Override -// protected boolean doDelete(SetSeine bean, -// DataService dataService, -// DataSource dataSource, -// TopiaExecutor2<? extends TopiaEntity, SetSeine> deletor) throws Exception { -// -// if (askToDelete(bean)) { -// return false; -// } -// -// String activityId = getSelectedParentId(); -// dataService.delete(dataSource, activityId, bean, deletor); -// return true; -// } + @Override + protected FormDto<SetSeineDto> loadToEdit(String id) { + return null; + } + + @Override + protected FormDto<SetSeineDto> loadToReadDto(String id) { + return null; + } + + protected boolean doDelete(SetSeineDto bean) throws Exception { + + if (askToDelete(bean)) { + return false; + } + + String activityId = getSelectedParentId(); + getSetSeineService().delete(activityId, bean.getId()); + return true; + } //FIXME // @Override @@ -431,4 +429,8 @@ public class SetSeineUIHandler extends ContentUIHandler<SetSeineDto> { } + //FIXME + protected SetSeineService getSetSeineService() { + return null; + } } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/longline/TripLonglineUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/longline/TripLonglineUIHandler.java index c50b765..3ed11d6 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/longline/TripLonglineUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/longline/TripLonglineUIHandler.java @@ -27,6 +27,7 @@ import fr.ird.observe.business.db.DataContext; import fr.ird.observe.business.db.DataSource; import fr.ird.observe.business.db.constants.DataContextType; import fr.ird.observe.services.dto.longline.TripLonglineDto; +import fr.ird.observe.services.service.longline.TripLonglineService; import fr.ird.observe.ui.content.ContentMode; import fr.ird.observe.ui.content.open.ContentOpenableUIHandler; import fr.ird.observe.ui.content.open.ContentOpenableUIModel; @@ -35,8 +36,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.util.DateUtil; -import javax.swing.JTabbedPane; -import javax.swing.SwingUtilities; +import javax.swing.*; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import java.util.Date; @@ -254,47 +254,36 @@ public class TripLonglineUIHandler extends ContentOpenableUIHandler<TripLongline model.setModified(create); } -// @Override -// protected boolean doSave(TripLongline bean, -// DataService dataService, -// DataSource dataSource, -// TopiaEntityBinder<TripLongline> binder) throws Exception { -// -// String programId = getDataContext().getSelectedProgramId(); -// -// // on force toujours la date a etre sans heure, minute,... -// Date startDate = DateUtil.getDay(bean.getStartDate()); -// if (log.isDebugEnabled()) { -// log.debug("startDate = " + startDate); -// } -// bean.setStartDate(startDate); -// -// Date endDate = bean.getEndDate(); -// if (log.isDebugEnabled()) { -// log.debug("endDate = " + endDate); -// } -// -// bean.setOpen(true); -// -// if (bean.getTopiaId() == null) { -// -// dataService.create(dataSource, programId, bean, binder, getCreateExecutor()); -// -// } else { -// -// dataService.update(dataSource, null, bean, getUpdateExecutor()); -// -// } -// -// // mise a jour de la date de fin -// dataService.updateEndDate(dataSource, bean.getTopiaId()); -// -// // recuperation de la position de la maree dans le program + @Override + protected boolean doSave(TripLonglineDto bean) throws Exception { + + String programId = getDataContext().getSelectedProgramId(); + + // on force toujours la date a etre sans heure, minute,... + Date startDate = DateUtil.getDay(bean.getStartDate()); + if (log.isDebugEnabled()) { + log.debug("startDate = " + startDate); + } + bean.setStartDate(startDate); + + Date endDate = bean.getEndDate(); + if (log.isDebugEnabled()) { + log.debug("endDate = " + endDate); + } + + bean.setOpen(true); + + String beanId = getTripLonglineService().save(bean); + bean.setId(beanId); + + // recuperation de la position de la maree dans le program + //FIXME // obtainChildPosition(bean, dataService, dataSource); -// -// return true; -// } + return true; + } + +//FIXME // @Override // protected TripLongline onCreate(TopiaContext tx, Object parent, TripLongline editBean) throws TopiaException { // TripLongline beanToSave = ObserveDAOHelper.getTripLonglineDAO(tx).create(); @@ -312,25 +301,23 @@ public class TripLonglineUIHandler extends ContentOpenableUIHandler<TripLongline // } //FIXME -// @Override -// protected boolean doDelete(TripLongline bean, -// DataService dataService, -// DataSource dataSource, -// TopiaExecutor2<? extends TopiaEntity, TripLongline> deletor) throws Exception { -// -// if (askToDelete(bean)) { -// return false; -// } -// if (log.isInfoEnabled()) { -// log.info("Will delete Trip " + bean.getTopiaId()); -// } -// -// dataService.delete(dataSource, null, bean, deletor); -// if (log.isInfoEnabled()) { -// log.info("Delete done for Trip " + bean.getTopiaId()); -// } -// return true; -// } + @Override + protected boolean doDelete(TripLonglineDto bean) throws Exception { + + if (askToDelete(bean)) { + return false; + } + if (log.isInfoEnabled()) { + log.info("Will delete Trip " + bean.getId()); + } + + getTripLonglineService().delete(bean.getId()); + + if (log.isInfoEnabled()) { + log.info("Delete done for Trip " + bean.getId()); + } + return true; + } //FIXME // @Override @@ -347,4 +334,9 @@ public class TripLonglineUIHandler extends ContentOpenableUIHandler<TripLongline return !create && !dataContext.isOpenTrip(); } + + //FIXME + protected TripLonglineService getTripLonglineService() { + return null; + } } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/seine/RouteUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/seine/RouteUIHandler.java index a5145d4..1847895 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/seine/RouteUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/seine/RouteUIHandler.java @@ -23,21 +23,28 @@ package fr.ird.observe.ui.content.open.impl.seine; import fr.ird.observe.ObserveSwingApplicationContext; import fr.ird.observe.business.db.DataContext; +import fr.ird.observe.business.db.DataSource; +import fr.ird.observe.business.db.DataSourceException; import fr.ird.observe.business.db.constants.DataContextType; import fr.ird.observe.services.dto.referential.seine.VesselActivitySeineDto; +import fr.ird.observe.services.dto.result.TripChildSaveResultDto; 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 fr.ird.observe.services.service.seine.RouteService; import fr.ird.observe.ui.UIHelper; import fr.ird.observe.ui.content.ContentMode; import fr.ird.observe.ui.content.open.ContentOpenableUIHandler; import fr.ird.observe.ui.tree.ObserveNode; import fr.ird.observe.ui.tree.ObserveTreeHelper; +import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.nuiton.util.DateUtil; import org.nuiton.validator.NuitonValidatorScope; -import javax.swing.JOptionPane; +import javax.swing.*; +import java.util.Date; import static org.nuiton.i18n.I18n.n; import static org.nuiton.i18n.I18n.t; @@ -219,43 +226,30 @@ public class RouteUIHandler extends ContentOpenableUIHandler<RouteDto> { getModel().setModified(create); } -// @Override -// protected boolean doSave(Route bean, -// DataService dataService, -// DataSource dataSource, -// TopiaEntityBinder<Route> binder) throws Exception { -// -// String tripId = getSelectedParentId(); -// -// if (log.isInfoEnabled()) { -// log.info("will save route " + bean.getTopiaId()); -// } -// -// // on sauvegarde toujours en debut de jour -// Date date = DateUtil.getDay(bean.getDate()); -// bean.setDate(date); -// bean.setOpen(true); -// -// if (bean.getTopiaId() == null) { -// -// dataService.create(dataSource, tripId, bean, binder, getCreateExecutor()); -// } else { -// -// dataService.update(dataSource, tripId, bean, getUpdateExecutor()); -// -// if( dateHasChanged) { -// -// dataService.updateDayDate(dataSource, bean.getTopiaId()); -// -// } -// } -// -// updateTripEndDate(tripId); -// + @Override + protected boolean doSave(RouteDto bean) throws Exception { + + String tripId = getSelectedParentId(); + + if (log.isInfoEnabled()) { + log.info("will save route " + bean.getId()); + } + + // on sauvegarde toujours en debut de jour + Date date = DateUtil.getDay(bean.getDate()); + bean.setDate(date); + bean.setOpen(true); + + TripChildSaveResultDto saveResult = getRouteService().save(tripId, bean); + bean.setId(saveResult.getId()); + + setUpdateMareeNodeTag(saveResult.isTripEndDateUpdated()); + + //FIXME // obtainChildPosition(bean, dataService, dataSource); -// -// return true; -// } + + return true; + } @Override protected void afterSave(boolean refresh) { @@ -309,29 +303,27 @@ public class RouteUIHandler extends ContentOpenableUIHandler<RouteDto> { // return beanToSave; // } - //FIXME -// @Override -// protected boolean doDelete(Route bean, -// DataService dataService, -// DataSource dataSource, -// TopiaExecutor2<? extends TopiaEntity, Route> deletor) throws Exception { -// -// if (askToDelete(bean)) { -// return false; -// } -// if (log.isInfoEnabled()) { -// log.info("Will delete Route " + bean.getTopiaId()); -// } -// -// String tripId = getSelectedParentId(); -// dataService.delete(dataSource, tripId, bean, deletor); -// if (log.isInfoEnabled()) { -// log.info("Delete done for Route " + bean.getTopiaId()); -// } -// updateTripEndDate(tripId); -// -// return true; -// } + @Override + protected boolean doDelete(RouteDto bean) throws Exception { + + if (askToDelete(bean)) { + return false; + } + if (log.isInfoEnabled()) { + log.info("Will delete Route " + bean.getId()); + } + + String tripId = getSelectedParentId(); + boolean wasEndDateUpdated = getRouteService ().delete(tripId, bean.getId()); + + if (log.isInfoEnabled()) { + log.info("Delete done for Route " + bean.getId()); + } + + setUpdateMareeNodeTag(wasEndDateUpdated); + + return true; + } // @Override // protected void onDelete(TopiaContext tx, Object parent, Route beanToDelete) { @@ -455,7 +447,7 @@ public class RouteUIHandler extends ContentOpenableUIHandler<RouteDto> { // on recupère l'écran d'édition ActivitySeineUI selectedUI = (ActivitySeineUI) - ObserveSwingApplicationContext.get().getSelectedContentUI(); + ObserveContext.get().getSelectedContentUI(); // on recupère l'activity de fin de veille VesselActivitySeineDto vesselActivitySeine = null; @@ -519,20 +511,7 @@ public class RouteUIHandler extends ContentOpenableUIHandler<RouteDto> { // treeHelper.refreshNode(tripNode, false); } - protected void updateTripEndDate(String tripId) { - - //FIXME -// boolean wasUpdated; - boolean wasUpdated = false; - - // on met a jour si necessaire la date de fin de la maree - //FIXME -// try { -// wasUpdated = getDataService().updateEndDate(getDataSource(), tripId); -// -// } catch (DataSourceException e) { -// throw new ObserveTechnicalException("Could not update end date",e); -// } + protected void setUpdateMareeNodeTag(boolean wasUpdated) { if (wasUpdated) { @@ -547,4 +526,8 @@ public class RouteUIHandler extends ContentOpenableUIHandler<RouteDto> { } + //FIXME + protected RouteService getRouteService() { + return null; + } } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/seine/TripSeineUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/seine/TripSeineUIHandler.java index 9b4e2d7..c8ec607 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/seine/TripSeineUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/seine/TripSeineUIHandler.java @@ -26,6 +26,7 @@ import fr.ird.observe.business.db.DataContext; import fr.ird.observe.business.db.DataSource; import fr.ird.observe.business.db.constants.DataContextType; import fr.ird.observe.services.dto.seine.TripSeineDto; +import fr.ird.observe.services.service.seine.TripSeineService; import fr.ird.observe.ui.content.ContentMode; import fr.ird.observe.ui.content.open.ContentOpenableUIHandler; import fr.ird.observe.ui.content.open.ContentOpenableUIModel; @@ -253,46 +254,34 @@ public class TripSeineUIHandler extends ContentOpenableUIHandler<TripSeineDto> { } //FIXME -// @Override -// protected boolean doSave(TripSeine bean, -// DataService dataService, -// DataSource dataSource, -// TopiaEntityBinder<TripSeine> binder) throws Exception { -// -// String programId = getDataContext().getSelectedProgramId(); -// -// // on force toujours la date a etre sans heure, minute,... -// Date startDate = DateUtil.getDay(bean.getStartDate()); -// if (log.isDebugEnabled()) { -// log.debug("startDate = " + startDate); -// } -// bean.setStartDate(startDate); -// -// Date endDate = bean.getEndDate(); -// if (log.isDebugEnabled()) { -// log.debug("endDate = " + endDate); -// } -// -// bean.setOpen(true); -// -// if (bean.getTopiaId() == null) { -// -// dataService.create(dataSource, programId, bean, binder, getCreateExecutor()); -// -// } else { -// -// dataService.update(dataSource, null, bean, getUpdateExecutor()); -// -// } -// -// // mise a jour de la date de fin -// dataService.updateEndDate(dataSource, bean.getTopiaId()); -// -// // recuperation de la position de la maree dans le program + @Override + protected boolean doSave(TripSeineDto bean) throws Exception { + + String programId = getDataContext().getSelectedProgramId(); + + // on force toujours la date a etre sans heure, minute,... + Date startDate = DateUtil.getDay(bean.getStartDate()); + if (log.isDebugEnabled()) { + log.debug("startDate = " + startDate); + } + bean.setStartDate(startDate); + + Date endDate = bean.getEndDate(); + if (log.isDebugEnabled()) { + log.debug("endDate = " + endDate); + } + + bean.setOpen(true); + + String beanId = getTripSeineService().save(bean); + bean.setId(beanId); + + // recuperation de la position de la maree dans le program + //FIXME // obtainChildPosition(bean, dataService, dataSource); -// -// return true; -// } + + return true; + } //FIXME // @Override @@ -311,26 +300,23 @@ public class TripSeineUIHandler extends ContentOpenableUIHandler<TripSeineDto> { // return beanToSave; // } - //FIXME -// @Override -// protected boolean doDelete(TripSeine bean, -// DataService dataService, -// DataSource dataSource, -// TopiaExecutor2<? extends TopiaEntity, TripSeine> deletor) throws Exception { -// -// if (askToDelete(bean)) { -// return false; -// } -// if (log.isInfoEnabled()) { -// log.info("Will delete Trip " + bean.getTopiaId()); -// } -// -// dataService.delete(dataSource, null, bean, deletor); -// if (log.isInfoEnabled()) { -// log.info("Delete done for Trip " + bean.getTopiaId()); -// } -// return true; -// } + @Override + protected boolean doDelete(TripSeineDto bean) throws Exception { + + if (askToDelete(bean)) { + return false; + } + if (log.isInfoEnabled()) { + log.info("Will delete Trip " + bean.getId()); + } + + getTripSeineService().delete(bean.getId()); + + if (log.isInfoEnabled()) { + log.info("Delete done for Trip " + bean.getId()); + } + return true; + } //FIXME // @Override @@ -348,4 +334,9 @@ public class TripSeineUIHandler extends ContentOpenableUIHandler<TripSeineDto> { } + //FIXME + protected TripSeineService getTripSeineService() { + return null; + } + } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableUIHandler.java index 47438ab..b76cd00 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableUIHandler.java @@ -373,7 +373,6 @@ public abstract class ContentTableUIHandler<E extends IdDto, D extends IdDto> ex } doPersist(bean); - return true; } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetDiscardCatchUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetDiscardCatchUIHandler.java index e34db35..ae7a6ec 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetDiscardCatchUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetDiscardCatchUIHandler.java @@ -40,9 +40,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.decorator.Decorator; -import javax.swing.JComponent; -import javax.swing.JOptionPane; -import javax.swing.JTable; +import javax.swing.*; import javax.swing.table.DefaultTableCellRenderer; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; @@ -280,19 +278,23 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeineD // } //FIXME -// @Override -// protected boolean doSave(SetSeine bean, -// DataService dataService, -// DataSource dataSource, -// TopiaEntityBinder<SetSeine> binder) throws Exception { -// try { -// return super.doSave(bean, dataService, dataSource, binder); -// } finally { -// -// // toujours supprimer la référence du context, quoiqu'il arrive -// ALL_TAILLES_TO_DELETE_ENTRY.removeContextValue(getUi()); -// } -// } + @Override + protected boolean doSave(SetSeineDto bean) throws Exception { + + try { + return super.doSave(bean); + + } finally { + + // toujours supprimer la référence du context, quoiqu'il arrive + ALL_TAILLES_TO_DELETE_ENTRY.removeContextValue(getUi()); + } + } + + @Override + protected void doPersist(SetSeineDto bean) { + //FIXME quel service ? + } @Override protected boolean prepareSave(SetSeineDto bean, List<TargetCatchDto> objets) throws DataSourceException { @@ -679,4 +681,5 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeineD } } } + } diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/longline/SetLonglineServiceController.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/longline/SetLonglineServiceController.java index e4af6ba..f79c9db 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/longline/SetLonglineServiceController.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/longline/SetLonglineServiceController.java @@ -52,8 +52,8 @@ public class SetLonglineServiceController extends ObserveAuthenticatedServiceCon } @Override - public String save(String activityLonglineId, FormDto<SetLonglineDto> form) { - return service.save(activityLonglineId, form); + public String save(String activityLonglineId, SetLonglineDto dto) { + return service.save(activityLonglineId, dto); } @Override diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/longline/TripLonglineServiceController.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/longline/TripLonglineServiceController.java index cc402c4..a3dc624 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/longline/TripLonglineServiceController.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/longline/TripLonglineServiceController.java @@ -60,8 +60,8 @@ public class TripLonglineServiceController extends ObserveAuthenticatedServiceCo } @Override - public String save(FormDto<TripLonglineDto> form) { - return service.save(form); + public String save(TripLonglineDto dto) { + return service.save(dto); } @Override diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/seine/RouteServiceController.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/seine/RouteServiceController.java index 2dee7f3..4b65180 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/seine/RouteServiceController.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/seine/RouteServiceController.java @@ -24,6 +24,7 @@ package fr.ird.observe.application.web.controller.v1.seine; import fr.ird.observe.application.web.controller.v1.ObserveAuthenticatedServiceControllerSupport; import fr.ird.observe.services.dto.FormDto; +import fr.ird.observe.services.dto.result.TripChildSaveResultDto; import fr.ird.observe.services.dto.seine.RouteDto; import fr.ird.observe.services.dto.seine.RouteStubDto; import fr.ird.observe.services.service.seine.RouteService; @@ -60,12 +61,12 @@ public class RouteServiceController extends ObserveAuthenticatedServiceControlle } @Override - public String save(String tripSeineId, FormDto<RouteDto> form) { - return service.save(tripSeineId, form); + public TripChildSaveResultDto save(String tripSeineId, RouteDto dto) { + return service.save(tripSeineId, dto); } @Override - public void delete(String tripSeineId, String routeId) { - service.delete(tripSeineId, routeId); + public boolean delete(String tripSeineId, String routeId) { + return service.delete(tripSeineId, routeId); } } diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/seine/SetSeineServiceController.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/seine/SetSeineServiceController.java index b5f6935..58ab321 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/seine/SetSeineServiceController.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/seine/SetSeineServiceController.java @@ -52,8 +52,8 @@ public class SetSeineServiceController extends ObserveAuthenticatedServiceContro } @Override - public String save(String activitySeineId, FormDto<SetSeineDto> form) { - return service.save(activitySeineId, form); + public String save(String activitySeineId, SetSeineDto dto) { + return service.save(activitySeineId, dto); } @Override diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/seine/TripSeineServiceController.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/seine/TripSeineServiceController.java index 864257a..e346f06 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/seine/TripSeineServiceController.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/seine/TripSeineServiceController.java @@ -60,8 +60,8 @@ public class TripSeineServiceController extends ObserveAuthenticatedServiceContr } @Override - public String save(FormDto<TripSeineDto> form) { - return service.save(form); + public String save(TripSeineDto dto) { + return service.save(dto); } @Override diff --git a/observe-services-api/src/main/java/fr/ird/observe/services/service/longline/SetLonglineService.java b/observe-services-api/src/main/java/fr/ird/observe/services/service/longline/SetLonglineService.java index 5cd59c2..5ebc557 100644 --- a/observe-services-api/src/main/java/fr/ird/observe/services/service/longline/SetLonglineService.java +++ b/observe-services-api/src/main/java/fr/ird/observe/services/service/longline/SetLonglineService.java @@ -48,7 +48,7 @@ public interface SetLonglineService extends ObserveService { @WriteDataPermission @Write @PostRequest - String save(String activityLonglineId, FormDto<SetLonglineDto> form); + String save(String activityLonglineId, SetLonglineDto dto); @Write @WriteDataPermission diff --git a/observe-services-api/src/main/java/fr/ird/observe/services/service/longline/TripLonglineService.java b/observe-services-api/src/main/java/fr/ird/observe/services/service/longline/TripLonglineService.java index fb6cd1f..1cf2937 100644 --- a/observe-services-api/src/main/java/fr/ird/observe/services/service/longline/TripLonglineService.java +++ b/observe-services-api/src/main/java/fr/ird/observe/services/service/longline/TripLonglineService.java @@ -54,7 +54,7 @@ public interface TripLonglineService extends ObserveService { @Write @WriteDataPermission @PostRequest - String save(FormDto<TripLonglineDto> form); + String save(TripLonglineDto dto); @Write @WriteDataPermission diff --git a/observe-services-api/src/main/java/fr/ird/observe/services/service/seine/RouteService.java b/observe-services-api/src/main/java/fr/ird/observe/services/service/seine/RouteService.java index b18b547..0c53283 100644 --- a/observe-services-api/src/main/java/fr/ird/observe/services/service/seine/RouteService.java +++ b/observe-services-api/src/main/java/fr/ird/observe/services/service/seine/RouteService.java @@ -24,6 +24,7 @@ package fr.ird.observe.services.service.seine; import fr.ird.observe.services.ObserveService; import fr.ird.observe.services.dto.FormDto; +import fr.ird.observe.services.dto.result.TripChildSaveResultDto; import fr.ird.observe.services.dto.seine.RouteDto; import fr.ird.observe.services.dto.seine.RouteStubDto; import fr.ird.observe.services.spi.DeleteRequest; @@ -54,11 +55,11 @@ public interface RouteService extends ObserveService { @Write @WriteDataPermission @PostRequest - String save(String tripSeineId, FormDto<RouteDto> form); + TripChildSaveResultDto save(String tripSeineId, RouteDto dto); @Write @WriteDataPermission @DeleteRequest - void delete(String tripSeineId, String routeId); + boolean delete(String tripSeineId, String routeId); } diff --git a/observe-services-api/src/main/java/fr/ird/observe/services/service/seine/SetSeineService.java b/observe-services-api/src/main/java/fr/ird/observe/services/service/seine/SetSeineService.java index 5780cde..c0df928 100644 --- a/observe-services-api/src/main/java/fr/ird/observe/services/service/seine/SetSeineService.java +++ b/observe-services-api/src/main/java/fr/ird/observe/services/service/seine/SetSeineService.java @@ -48,7 +48,7 @@ public interface SetSeineService extends ObserveService { @Write @WriteDataPermission @PostRequest - String save(String activitySeineId, FormDto<SetSeineDto> form); + String save(String activitySeineId, SetSeineDto dto); @Write @WriteDataPermission diff --git a/observe-services-api/src/main/java/fr/ird/observe/services/service/seine/TripSeineService.java b/observe-services-api/src/main/java/fr/ird/observe/services/service/seine/TripSeineService.java index ccab5b1..74707e9 100644 --- a/observe-services-api/src/main/java/fr/ird/observe/services/service/seine/TripSeineService.java +++ b/observe-services-api/src/main/java/fr/ird/observe/services/service/seine/TripSeineService.java @@ -54,7 +54,7 @@ public interface TripSeineService extends ObserveService { @Write @WriteDataPermission @PostRequest - String save(FormDto<TripSeineDto> form); + String save(TripSeineDto dto); @Write @WriteDataPermission diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/dto/ObserveDtosInitializer.java b/observe-services-topia/src/main/java/fr/ird/observe/services/dto/ObserveDtosInitializer.java index ebc41b6..4b4c20c 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/dto/ObserveDtosInitializer.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/dto/ObserveDtosInitializer.java @@ -1272,6 +1272,11 @@ public class ObserveDtosInitializer implements ObserveModelInitializer { WindDto.PROPERTY_SPEED_RANGE); } + @Override + public void initTripChildSaveResultDto() { + // do nothing + } + // -------------------------------------------------------------------------------------------------------------- // // -- DATA SEINE ------------------------------------------------------------------------------------------------ // // -------------------------------------------------------------------------------------------------------------- // diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/service/longline/SetLonglineServiceTopia.java b/observe-services-topia/src/main/java/fr/ird/observe/services/service/longline/SetLonglineServiceTopia.java index 955ccec..9f8c9cd 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/service/longline/SetLonglineServiceTopia.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/service/longline/SetLonglineServiceTopia.java @@ -92,12 +92,10 @@ public class SetLonglineServiceTopia extends ObserveServiceTopia implements SetL } @Override - public String save(String activityLonglineId, FormDto<SetLonglineDto> form) { + public String save(String activityLonglineId, SetLonglineDto setLonglineDto) { ActivityLongline activityLongline = loadEntity(ActivityLonglineDto.class, ActivityLongline.class, activityLonglineId); - SetLonglineDto setLonglineDto = form.getForm(); - SetLongline setLongline = dtoToEntity(SetLonglineDto.class, SetLongline.class, setLonglineDto); setLongline = saveEntity(SetLongline.class, setLongline); 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 975e992..23e3de1 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 @@ -120,12 +120,15 @@ public class TripLonglineServiceTopia extends ObserveServiceTopia implements Tri } @Override - public String save(FormDto<TripLonglineDto> form) { + public String save(TripLonglineDto dto) { - TripLongline tripLongline = dtoToEntity(TripLonglineDto.class, TripLongline.class, form.getForm()); + TripLongline tripLongline = dtoToEntity(TripLonglineDto.class, TripLongline.class, dto); tripLongline = saveEntity(TripLongline.class, tripLongline); + TripLonglineTopiaDao dao = getTopiaPersistenceContext().getTripLonglineDao(); + dao.updateEndDate(tripLongline); + return tripLongline.getTopiaId(); } diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/RouteServiceTopia.java b/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/RouteServiceTopia.java index 6a0833e..c352c86 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/RouteServiceTopia.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/RouteServiceTopia.java @@ -25,9 +25,12 @@ package fr.ird.observe.services.service.seine; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import fr.ird.observe.entities.seine.Route; +import fr.ird.observe.entities.seine.RouteTopiaDao; import fr.ird.observe.entities.seine.TripSeine; +import fr.ird.observe.entities.seine.TripSeineTopiaDao; import fr.ird.observe.services.ObserveServiceTopia; import fr.ird.observe.services.dto.FormDto; +import fr.ird.observe.services.dto.result.TripChildSaveResultDto; import fr.ird.observe.services.dto.seine.RouteDto; import fr.ird.observe.services.dto.seine.RouteStubDto; import fr.ird.observe.services.dto.seine.TripSeineDto; @@ -118,15 +121,18 @@ public class RouteServiceTopia extends ObserveServiceTopia implements RouteServi } @Override - public String save(String tripSeineId, FormDto<RouteDto> form) { + public TripChildSaveResultDto save(String tripSeineId, RouteDto routeDto) { - TripSeine tripSeine = loadEntity(TripSeineDto.class, TripSeine.class, tripSeineId); + TripChildSaveResultDto result = new TripChildSaveResultDto(); - RouteDto routeDto = form.getForm(); + TripSeine tripSeine = loadEntity(TripSeineDto.class, TripSeine.class, tripSeineId); + Route route = loadEntity(RouteDto.class, Route.class, routeDto.getId()); + Date oldRouteDate = route.getDate(); - Route route = dtoToEntity(RouteDto.class, Route.class, routeDto); + route = dtoToEntity(RouteDto.class, Route.class, routeDto); route = saveEntity(Route.class, route); + result.setId(route.getTopiaId()); if (routeDto.isNotPersisted()) { @@ -134,13 +140,27 @@ public class RouteServiceTopia extends ObserveServiceTopia implements RouteServi saveEntity(TripSeine.class, tripSeine); + } else { + Date oldDate = DateUtil.getDay(oldRouteDate); + // si le jour a change, il faut mettre à jour les dates des activitéset des sets + boolean dateHasChanged = !oldDate.equals(routeDto.getDate()); + + if (dateHasChanged) { + RouteTopiaDao dao = getTopiaPersistenceContext().getRouteDao(); + dao.updateActivitiesDate(route.getTopiaId()); + } } - return route.getTopiaId(); + TripSeineTopiaDao tripSeineTopiaDao = getTopiaPersistenceContext().getTripSeineDao(); + boolean wasEndDateUpdated = tripSeineTopiaDao.updateEndDate(tripSeine); + + result.setTripEndDateUpdated(wasEndDateUpdated); + + return result; } @Override - public void delete(String tripSeineId, String routeId) { + public boolean delete(String tripSeineId, String routeId) { TripSeine tripSeine = loadEntity(TripSeineDto.class, TripSeine.class, tripSeineId); @@ -154,6 +174,10 @@ public class RouteServiceTopia extends ObserveServiceTopia implements RouteServi tripSeine.removeRoute(route); + TripSeineTopiaDao tripSeineTopiaDao = getTopiaPersistenceContext().getTripSeineDao(); + boolean wasEndDateUpdated = tripSeineTopiaDao.updateEndDate(tripSeine); + + return wasEndDateUpdated; } } diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/SetSeineServiceTopia.java b/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/SetSeineServiceTopia.java index 204926c..319b64f 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/SetSeineServiceTopia.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/SetSeineServiceTopia.java @@ -100,12 +100,10 @@ public class SetSeineServiceTopia extends ObserveServiceTopia implements SetSein } @Override - public String save(String activitySeineId, FormDto<SetSeineDto> form) { + public String save(String activitySeineId, SetSeineDto setSeineDto) { ActivitySeine activitySeine = loadEntity(ActivitySeineDto.class, ActivitySeine.class, activitySeineId); - SetSeineDto setSeineDto = form.getForm(); - SetSeine setSeine = dtoToEntity(SetSeineDto.class, SetSeine.class, setSeineDto); setSeine = saveEntity(SetSeine.class, setSeine); @@ -134,5 +132,6 @@ public class SetSeineServiceTopia extends ObserveServiceTopia implements SetSein activitySeine.setSetSeine(null); + //FIXME kmorin : faudrait pas sauver quelquechose là ? parcequ'on n'a rien supprimé... } } 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 2ae405d..525c082 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 @@ -123,12 +123,15 @@ public class TripSeineServiceTopia extends ObserveServiceTopia implements TripSe } @Override - public String save(FormDto<TripSeineDto> form) { + public String save(TripSeineDto dto) { - TripSeine tripSeine = dtoToEntity(TripSeineDto.class, TripSeine.class, form.getForm()); + TripSeine tripSeine = dtoToEntity(TripSeineDto.class, TripSeine.class, dto); tripSeine = saveEntity(TripSeine.class, tripSeine); + TripSeineTopiaDao dao = getTopiaPersistenceContext().getTripSeineDao(); + dao.updateEndDate(tripSeine); + return tripSeine.getTopiaId(); } diff --git a/observe-services-topia/src/test/java/fr/ird/observe/services/service/RigthTest.java b/observe-services-topia/src/test/java/fr/ird/observe/services/service/RigthTest.java index c1fe848..1509d73 100644 --- a/observe-services-topia/src/test/java/fr/ird/observe/services/service/RigthTest.java +++ b/observe-services-topia/src/test/java/fr/ird/observe/services/service/RigthTest.java @@ -173,7 +173,7 @@ public class RigthTest { FormDto<ProgramDto> formDto = service.loadToEdit(ProgramDto.class, PROGRAM_ID); - service.save(formDto); + service.save(formDto.getForm()); } @Test -- 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/7531 in repository observe. See http://git.codelutin.com/observe.git commit 3f9761934c1677a16f7bf67a3637350a4a27b054 Author: Tony CHEMIT <chemit@codelutin.com> Date: Thu Sep 24 19:26:43 2015 +0200 Fix merge --- .../ui/content/impl/seine/FloatingObjectUIHandler.java | 11 ----------- .../ui/content/impl/seine/SetSeineUIHandler.java | 11 ----------- .../src/main/xmi/observe-services-dto-common.zargo~ | Bin 35328 -> 0 bytes 3 files changed, 22 deletions(-) diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/FloatingObjectUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/FloatingObjectUIHandler.java index 5314afd..7fef2ec 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/FloatingObjectUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/FloatingObjectUIHandler.java @@ -24,7 +24,6 @@ package fr.ird.observe.ui.content.impl.seine; import fr.ird.observe.business.db.DataContext; import fr.ird.observe.business.db.DataSource; import fr.ird.observe.business.db.constants.DataContextType; -import fr.ird.observe.services.dto.FormDto; import fr.ird.observe.services.dto.seine.ActivitySeineDto; import fr.ird.observe.services.dto.seine.FloatingObjectDto; import fr.ird.observe.services.service.seine.FloatingObjectService; @@ -214,16 +213,6 @@ public class FloatingObjectUIHandler extends ContentUIHandler<FloatingObjectDto> } } - @Override - protected FormDto<FloatingObjectDto> loadToEdit(String id) { - return null; - } - - @Override - protected FormDto<FloatingObjectDto> loadToReadDto(String id) { - return null; - } - protected boolean doDelete(FloatingObjectDto bean) throws Exception { if (askToDelete(bean)) { diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/SetSeineUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/SetSeineUIHandler.java index 3b17d4f..8dd1f8d 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/SetSeineUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/SetSeineUIHandler.java @@ -24,7 +24,6 @@ package fr.ird.observe.ui.content.impl.seine; import fr.ird.observe.business.db.DataContext; import fr.ird.observe.business.db.DataSource; import fr.ird.observe.business.db.constants.DataContextType; -import fr.ird.observe.services.dto.FormDto; import fr.ird.observe.services.dto.constants.seine.SchoolType; import fr.ird.observe.services.dto.seine.ActivitySeineDto; import fr.ird.observe.services.dto.seine.SetSeineDto; @@ -347,16 +346,6 @@ public class SetSeineUIHandler extends ContentUIHandler<SetSeineDto> { } } - @Override - protected FormDto<SetSeineDto> loadToEdit(String id) { - return null; - } - - @Override - protected FormDto<SetSeineDto> loadToReadDto(String id) { - return null; - } - protected boolean doDelete(SetSeineDto bean) throws Exception { if (askToDelete(bean)) { diff --git a/observe-services-model/src/main/xmi/observe-services-dto-common.zargo~ b/observe-services-model/src/main/xmi/observe-services-dto-common.zargo~ deleted file mode 100644 index 59c5da7..0000000 Binary files a/observe-services-model/src/main/xmi/observe-services-dto-common.zargo~ and /dev/null differ -- 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