branch feature/7610 updated (56915d0 -> c9befda)
This is an automated email from the git hooks/post-receive script. New change to branch feature/7610 in repository observe. See http://git.codelutin.com/observe.git discards 56915d0 modification des decorateurs pour aller chercher en profondeur les attributs des referencedto qui sont eux même attributs (exemple de LengthWeightParameterDto : ocean est un attribut de type referencedto, il faut qu'on aille chercher le label) (refs #7610) discards 7840e88 déplacement de la clé i18n de referencestatus dans le dto plutôt que dans l'entité (refs #7610) discards 9fdca20 correction du decorateur de referencedto pour le cas où des tokens sont des referencedtos (refs #7610) discards ed3328e correction du decorateur de referencedto pour que le tri fonctionne (refs #7610) discards d2e1010 filterReferentialListByStatus dans les combo discards 162bca1 correction du ReferentielListRenderer pour grises les lignes désactivées quand les objets sont des referencedto (refs #7610) discards 6f68958 fix typo discards 085ea34 trad discards 849801d ouverture des écrans de référentiel commun (refs #7610) discards 355ffec modif des linkedhashset en list dans certains dto pour faire marcher les double listes (refs #7610) adds 9b06a03 affichage de la calée dans l'arbre de navigation (refs #7598) adds 5dd20f8 migration de l'écran (refs #7598) adds 0fa1a91 ajout de la validation (refs #7598) adds a718909 Merge branch 'feature/7598' into develop adds 440123c traduction des types de bancs (refs #7598) adds 5d71046 migration de l'écran d'un object flottant (refs #7599) adds 44d772e mise en place de la validation (refs #7599) adds 522269d Merge branch 'feature/7599' into develop adds 9b62f13 correction de la validation de l'écran activity seine (refs #7595) adds 5a58912 Migration de l'écran d'opération sur l'object (refs #7600) adds 563c0b7 mise en place de la validation (refs #7600) adds d5db9ba Merge branch 'feature/7600' into develop adds ec568b5 Migration de l'écran des estimations sur l'object (refs #7601) adds e543f39 mise en place de la validation (refs #7601) adds 620eb01 Merge branch 'feature/7601' into develop adds d398a48 Migration de l'écran de la faune observés sur l'object (refs #7602) adds b1f853b mise en place de la validation (refs #7602) adds 03d0c00 Merge branch 'feature/7602' into develop new 6ca2905 modif des linkedhashset en list dans certains dto pour faire marcher les double listes (refs #7610) new c4575a4 ouverture des écrans de référentiel commun (refs #7610) new 22cbd16 trad new 63eaf83 fix typo new d554512 correction du ReferentielListRenderer pour grises les lignes désactivées quand les objets sont des referencedto (refs #7610) new 43decc9 filterReferentialListByStatus dans les combo new ee984be correction du decorateur de referencedto pour que le tri fonctionne (refs #7610) new 06f3130 correction du decorateur de referencedto pour le cas où des tokens sont des referencedtos (refs #7610) new 49a44e8 déplacement de la clé i18n de referencestatus dans le dto plutôt que dans l'entité (refs #7610) new e74f1f4 modification des decorateurs pour aller chercher en profondeur les attributs des referencedto qui sont eux même attributs (exemple de LengthWeightParameterDto : ocean est un attribut de type referencedto, il faut qu'on aille chercher le label) (refs #7610) new c9befda ajout du programme dans l'arbre après création (refs #7610) 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 (56915d0) \ N -- N -- N refs/heads/feature/7610 (c9befda) 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 11 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 c9befdad82bb5ef0118896a7078df484b6f32d1d Author: Kevin Morin <morin@codelutin.com> Date: Fri Oct 16 10:50:52 2015 +0200 ajout du programme dans l'arbre après création (refs #7610) commit e74f1f40bfbf149a49f741f58a05a3d3fb779f8d Author: Kevin Morin <morin@codelutin.com> Date: Thu Oct 15 17:44:21 2015 +0200 modification des decorateurs pour aller chercher en profondeur les attributs des referencedto qui sont eux même attributs (exemple de LengthWeightParameterDto : ocean est un attribut de type referencedto, il faut qu'on aille chercher le label) (refs #7610) commit 49a44e8bc818b7d0214cf7a838b0e54687ca3f6b Author: Kevin Morin <morin@codelutin.com> Date: Thu Oct 15 14:45:07 2015 +0200 déplacement de la clé i18n de referencestatus dans le dto plutôt que dans l'entité (refs #7610) commit 06f31303d6f789a479258c6ab850fbffd80174ac Author: Kevin Morin <morin@codelutin.com> Date: Thu Oct 15 14:06:25 2015 +0200 correction du decorateur de referencedto pour le cas où des tokens sont des referencedtos (refs #7610) commit ee984be242987c6a65b1f66c42281b3bc64fda98 Author: Kevin Morin <morin@codelutin.com> Date: Thu Oct 15 11:17:06 2015 +0200 correction du decorateur de referencedto pour que le tri fonctionne (refs #7610) commit 43decc9d8e2dc6be17abe77c9e5e0caaf6324d92 Author: Kevin Morin <morin@codelutin.com> Date: Thu Oct 15 10:44:43 2015 +0200 filterReferentialListByStatus dans les combo commit d55451223ebafa6c5e8a7babb70a1373cb45751b Author: Kevin Morin <morin@codelutin.com> Date: Thu Oct 15 10:43:00 2015 +0200 correction du ReferentielListRenderer pour grises les lignes désactivées quand les objets sont des referencedto (refs #7610) commit 63eaf8326979af4b08fab447104d10ea92f4e80f Author: Kevin Morin <morin@codelutin.com> Date: Thu Oct 15 10:32:32 2015 +0200 fix typo commit 22cbd16809c9a23ad074ecc64b1ea3d3e54ebc2e Author: Kevin Morin <morin@codelutin.com> Date: Thu Oct 15 10:20:37 2015 +0200 trad commit c4575a4a1cc0089bdd089a4c43da1c4c1b7bbb5e Author: Kevin Morin <morin@codelutin.com> Date: Wed Oct 14 18:03:45 2015 +0200 ouverture des écrans de référentiel commun (refs #7610) commit 6ca290570a491ecbc2262f5bb3f6f7c375eb85bf Author: Kevin Morin <morin@codelutin.com> Date: Wed Oct 14 11:03:12 2015 +0200 modif des linkedhashset en list dans certains dto pour faire marcher les double listes (refs #7610) Summary of changes: .../fr/ird/observe/ObserveOpenDataManager.java | 5 + .../ird/observe/db/constantes/ConstantsI18n.java | 23 +++ .../ird/observe/ui/content/ContentUIManager.java | 4 +- .../FloatingObjectTransmittingBuoyOperationUI.css | 16 +- .../FloatingObjectTransmittingBuoyOperationUI.jaxx | 9 +- ...ngObjectTransmittingBuoyOperationUIHandler.java | 167 ++++++--------------- ...tingObjectTransmittingBuoyOperationUIModel.java | 39 +---- .../impl/seine/FloatingObjectUIHandler.java | 40 +---- .../ui/content/impl/seine/SetSeineUIHandler.java | 107 ++----------- .../ui/content/impl/seine/SetSeineUIModel.java | 3 - .../ui/content/ref/ContentReferenceUIHandler.java | 4 +- .../ui/content/table/ContentTableUIHandler.java | 2 +- .../table/impl/seine/ObjectObservedSpeciesUI.jaxx | 14 +- .../impl/seine/ObjectObservedSpeciesUIHandler.java | 40 ++--- .../impl/seine/ObjectObservedSpeciesUIModel.java | 39 +++-- .../table/impl/seine/ObjectSchoolEstimateUI.jaxx | 14 +- .../impl/seine/ObjectSchoolEstimateUIHandler.java | 38 ++--- .../impl/seine/ObjectSchoolEstimateUIModel.java | 40 +++-- .../tree/loadors/ActivitySeineNodeChildLoador.java | 18 +-- .../loadors/FloatingObjectNodeChildLoador.java | 16 +- ...ActivitySeineDto-n1-update-error-validation.xml | 2 +- ...loatingObjectDto-n1-create-error-validation.xml | 0 ...atingObjectDto-n1-create-warning-validation.xml | 0 ...loatingObjectDto-n1-update-error-validation.xml | 0 ...atingObjectDto-n1-update-warning-validation.xml | 0 ...choolEstimateDto-n1-update-error-validation.xml | 0 ...nsmittingBuoyDto-n1-update-error-validation.xml | 19 ++- ...servedSpeciesDto-n1-update-error-validation.xml | 0 ...choolEstimateDto-n1-update-error-validation.xml | 0 ...oolEstimateDto-n1-update-warning-validation.xml | 0 .../SetSeineDto-n1-create-error-validation.xml | 15 +- .../SetSeineDto-n1-create-warning-validation.xml | 2 +- .../SetSeineDto-n1-update-error-validation.xml | 18 +-- .../SetSeineDto-n1-update-warning-validation.xml | 2 +- .../observe-application-swing_en_GB.properties | 4 + .../observe-application-swing_es_ES.properties | 4 + .../observe-application-swing_fr_FR.properties | 8 +- .../ObjectObservedSpeciesServiceController.java | 4 +- .../ObjectSchoolEstimateServiceController.java | 4 +- .../ird/observe/entities/referentiel/Species2.java | 18 +++ .../observe/entities/referentiel/SpeciesLists.java | 13 ++ .../seine/ObjectObservedSpeciesService.java | 2 +- .../service/seine/ObjectSchoolEstimateService.java | 2 +- .../fr/ird/observe/services/dto/ReferenceDtos.java | 45 ++++++ .../services/dto/referential/ProgramDtos.java | 36 +++++ .../services/dto/seine/ActivitySeineDto.java | 9 +- .../services/dto/seine/FloatingObjectDtos.java | 26 ++++ .../seine/FloatingObjectTransmittingBuoyDto.java | 49 ++---- .../observe/services/dto/seine/SetSeineDto.java | 77 ++++++++++ .../main/xmi/observe-services-dto-seine.properties | 1 + .../src/main/xmi/observe-services-dto-seine.zargo | Bin 60981 -> 61137 bytes .../ird/observe/services/ObserveServiceTopia.java | 22 ++- .../services/builder/EntityToDtoBuilder.java | 12 ++ .../services/dto/ObserveDtosInitializer.java | 3 +- .../ird/observe/services/entity/EntitiesSet.java | 36 +++++ .../services/entity/ObserveEntitiesFilters.java | 92 ++++++++---- .../services/entity/ObserveEntityFilter.java | 11 +- .../services/entity/SpeciesListEntitiesSet.java | 27 ++++ .../services/entity/UniverseEntitiesSet.java | 30 ++++ .../service/seine/ActivitySeineServiceTopia.java | 7 +- .../service/seine/FloatingObjectServiceTopia.java | 23 +-- .../seine/ObjectObservedSpeciesServiceTopia.java | 5 +- .../seine/ObjectSchoolEstimateServiceTopia.java | 4 +- .../TransmittingBuoyOperationServiceTopia.java | 4 +- 64 files changed, 731 insertions(+), 543 deletions(-) create mode 100644 observe-application-swing/src/main/java/fr/ird/observe/db/constantes/ConstantsI18n.java copy observe-entities-validation/src/main/resources/fr/ird/observe/entities/seine/FloatingObject-n1-create-error-validation.xml => observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/FloatingObjectDto-n1-create-error-validation.xml (100%) copy observe-entities-validation/src/main/resources/fr/ird/observe/entities/seine/FloatingObject-n1-update-warning-validation.xml => observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/FloatingObjectDto-n1-create-warning-validation.xml (100%) copy observe-entities-validation/src/main/resources/fr/ird/observe/entities/seine/FloatingObject-n1-update-error-validation.xml => observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/FloatingObjectDto-n1-update-error-validation.xml (100%) copy observe-entities-validation/src/main/resources/fr/ird/observe/entities/seine/FloatingObject-n1-update-warning-validation.xml => observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/FloatingObjectDto-n1-update-warning-validation.xml (100%) copy observe-entities-validation/src/main/resources/fr/ird/observe/entities/seine/FloatingObject-n1-update-objectSchoolEstimate-error-validation.xml => observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/FloatingObjectSchoolEstimateDto-n1-update-error-validation.xml (100%) copy observe-entities-validation/src/main/resources/fr/ird/observe/entities/seine/FloatingObject-n1-update-transmittingBuoyOperation-error-validation.xml => observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/FloatingObjectTransmittingBuoyDto-n1-update-error-validation.xml (72%) copy observe-entities-validation/src/main/resources/fr/ird/observe/entities/seine/ObjectObservedSpecies-n1-update-error-validation.xml => observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/ObjectObservedSpeciesDto-n1-update-error-validation.xml (100%) copy observe-entities-validation/src/main/resources/fr/ird/observe/entities/seine/ObjectSchoolEstimate-n1-update-error-validation.xml => observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/ObjectSchoolEstimateDto-n1-update-error-validation.xml (100%) copy observe-entities-validation/src/main/resources/fr/ird/observe/entities/seine/ObjectSchoolEstimate-n1-update-warning-validation.xml => observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/ObjectSchoolEstimateDto-n1-update-warning-validation.xml (100%) copy observe-entities-validation/src/main/resources/fr/ird/observe/entities/seine/SetSeine-n1-create-error-validation.xml => observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/SetSeineDto-n1-create-error-validation.xml (89%) copy observe-entities-validation/src/main/resources/fr/ird/observe/entities/seine/SetSeine-n1-update-warning-validation.xml => observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/SetSeineDto-n1-create-warning-validation.xml (89%) copy observe-entities-validation/src/main/resources/fr/ird/observe/entities/seine/SetSeine-n1-update-error-validation.xml => observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/SetSeineDto-n1-update-error-validation.xml (86%) copy observe-entities-validation/src/main/resources/fr/ird/observe/entities/seine/SetSeine-n1-update-warning-validation.xml => observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/SetSeineDto-n1-update-warning-validation.xml (89%) create mode 100644 observe-entities/src/main/java/fr/ird/observe/entities/referentiel/SpeciesLists.java create mode 100644 observe-services-model/src/main/java/fr/ird/observe/services/dto/seine/FloatingObjectDtos.java copy observe-entities/src/main/java/fr/ird/observe/entities/seine/FloatingObjectImpl.java => observe-services-model/src/main/java/fr/ird/observe/services/dto/seine/FloatingObjectTransmittingBuoyDto.java (51%) create mode 100644 observe-services-model/src/main/java/fr/ird/observe/services/dto/seine/SetSeineDto.java create mode 100644 observe-services-topia/src/main/java/fr/ird/observe/services/entity/EntitiesSet.java create mode 100644 observe-services-topia/src/main/java/fr/ird/observe/services/entity/SpeciesListEntitiesSet.java create mode 100644 observe-services-topia/src/main/java/fr/ird/observe/services/entity/UniverseEntitiesSet.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/7610 in repository observe. See http://git.codelutin.com/observe.git commit 6ca290570a491ecbc2262f5bb3f6f7c375eb85bf Author: Kevin Morin <morin@codelutin.com> Date: Wed Oct 14 11:03:12 2015 +0200 modif des linkedhashset en list dans certains dto pour faire marcher les double listes (refs #7610) --- .../src/main/xmi/observe-services-dto-common.properties | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/observe-services-model/src/main/xmi/observe-services-dto-common.properties b/observe-services-model/src/main/xmi/observe-services-dto-common.properties index 3333ab3..a7eba67 100644 --- a/observe-services-model/src/main/xmi/observe-services-dto-common.properties +++ b/observe-services-model/src/main/xmi/observe-services-dto-common.properties @@ -27,10 +27,10 @@ model.tagvalue.simpleBeanWithNoInterfaceClassNameSuffix=Dto package.fr.ird.observe.services.dto.stereotype=bean -fr.ird.observe.services.dto.referential.Gear.attribute.gearCaracteristic.stereotype=unique,ordered +fr.ird.observe.services.dto.referential.Gear.attribute.gearCaracteristic.stereotype=ordered fr.ird.observe.services.dto.referential.GearCaracteristic.attribute.gearCaracteristicType.stereotype=unique,ordered -fr.ird.observe.services.dto.referential.Species.attribute.ocean.stereotype=unique,ordered -fr.ird.observe.services.dto.referential.SpeciesList.attribute.species.stereotype=unique,ordered +fr.ird.observe.services.dto.referential.Species.attribute.ocean.stereotype=ordered +fr.ird.observe.services.dto.referential.SpeciesList.attribute.species.stereotype=ordered fr.ird.observe.services.dto.ReferenceSet.attribute.reference.stereotype=unique,ordered fr.ird.observe.services.dto.TripMap.attribute.points.stereotype=unique,ordered -- 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/7610 in repository observe. See http://git.codelutin.com/observe.git commit c4575a4a1cc0089bdd089a4c43da1c4c1b7bbb5e Author: Kevin Morin <morin@codelutin.com> Date: Wed Oct 14 18:03:45 2015 +0200 ouverture des écrans de référentiel commun (refs #7610) --- .../observe/ui/content/ContentUIInitializer.java | 2 +- .../ird/observe/ui/content/ContentUIManager.java | 1 - .../fr/ird/observe/ui/content/ContentUIModel.java | 12 - .../observe/ui/content/ref/ContentReferenceUI.jaxx | 2 +- .../ui/content/ref/ContentReferenceUIHandler.java | 332 +++++++++++---------- .../observe/ui/content/ref/impl/GearUIHandler.java | 3 +- .../ref/impl/LengthWeightParameterUIHandler.java | 3 +- .../ui/content/ref/impl/ProgramUIHandler.java | 3 +- .../ui/content/ref/impl/SpeciesListUIHandler.java | 3 +- .../ui/content/ref/impl/SpeciesUIHandler.java | 3 +- .../ui/content/ref/impl/VesselUIHandler.java | 3 +- .../fr/ird/observe/ui/tree/DtoNodeSupport.java | 14 +- .../java/fr/ird/observe/ui/usage/UsagesUI.jaxx | 4 +- .../fr/ird/observe/ui/usage/UsagesUIHandler.java | 13 +- .../observe-application-swing_fr_FR.properties | 52 ++-- .../v1/ReferentialServiceController.java | 5 + .../services/service/ReferentialService.java | 6 + .../java/fr/ird/observe/services/dto/DtoMap.java | 43 +++ .../services/dto/referential/ReferentialDtos.java | 1 - .../services/service/ReferentialServiceTopia.java | 40 +++ 20 files changed, 328 insertions(+), 217 deletions(-) diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIInitializer.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIInitializer.java index 978aaab..44d811d 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIInitializer.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIInitializer.java @@ -26,7 +26,6 @@ import com.google.common.base.Predicate; import com.google.common.collect.Collections2; import com.google.common.collect.Lists; import fr.ird.observe.ObserveSwingApplicationContext; -import fr.ird.observe.validation.ObserveSwingValidator; import fr.ird.observe.services.dto.FormDto; import fr.ird.observe.services.dto.IdDto; import fr.ird.observe.services.dto.ReferenceDto; @@ -37,6 +36,7 @@ import fr.ird.observe.ui.UIHelper; import fr.ird.observe.ui.actions.shared.AbstractUIAction; import fr.ird.observe.ui.util.BooleanEditor; import fr.ird.observe.ui.util.tripMap.ObserveMapPane; +import fr.ird.observe.validation.ObserveSwingValidator; import jaxx.runtime.JAXXValidator; import jaxx.runtime.SwingUtil; import jaxx.runtime.swing.JAXXWidgetUtil; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIManager.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIManager.java index aeaca36..119fadc 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIManager.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIManager.java @@ -175,7 +175,6 @@ public class ContentUIManager { // --- Referential --- // - //FIXME for (Class<? extends ReferentialDto> editType : ReferentialDtos.REFERENCE_COMMON_DTOS) { String simpleName = StringUtils.removeEnd(editType.getSimpleName(), "Dto"); String fqn = ContentReferenceUI.class.getPackage().getName() + ".impl." + simpleName + "UI"; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIModel.java index 4d9f4ea..c78578c 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIModel.java @@ -100,18 +100,6 @@ public abstract class ContentUIModel<E extends IdDto> extends AbstractSerializab log.error(e); } } - //FIXME -// ObserveEntityEnum constant = ObserveEntityEnum.valueOf(beanType); -// if (constant != null) { -// try { -// setBean((E) constant.getImplementation().newInstance()); -// } catch (Exception e) { -// // ne devrait jamain arrive -// if (log.isErrorEnabled()) { -// log.error(e); -// } -// } -// } } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/ContentReferenceUI.jaxx b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/ContentReferenceUI.jaxx index a8b65ea..cd9bbfd 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/ContentReferenceUI.jaxx +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/ContentReferenceUI.jaxx @@ -84,7 +84,7 @@ viewLayout.addLayoutComponent(editView, DETAIL_VIEW); <JScrollPane id='listPane' constraints='BorderLayout.CENTER' columnHeaderView='{listHeader}'> <JList id='list' - onValueChanged='getHandler().selectBean((E)getSelectedBean(list))' + onValueChanged='getHandler().selectBean((ReferenceDto<E>)getSelectedBean(list))' onMouseClicked='if (event.getClickCount() == 2) { getHandler().modifyUI(); }'/> <BeanListHeader id='listHeader' genericType='ReferenceDto' _entityClass="getModel().getBeanType()"/> 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 1adb75e..51ffcab 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 @@ -21,14 +21,15 @@ */ package fr.ird.observe.ui.content.ref; -import fr.ird.observe.ObserveSwingApplicationContext; import fr.ird.observe.ObserveServiceHelper; +import fr.ird.observe.ObserveSwingApplicationContext; import fr.ird.observe.business.db.DataContext; -import fr.ird.observe.validation.ValidationContext; -import fr.ird.observe.services.dto.FormDto; import fr.ird.observe.db.ObserveSwingDataSource; +import fr.ird.observe.services.dto.DtoMap; +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.ReferenceSetDto; import fr.ird.observe.services.dto.constants.ReferenceStatus; import fr.ird.observe.services.dto.constants.ReferentialLocale; import fr.ird.observe.services.dto.referential.I18nReferentialDto; @@ -36,6 +37,7 @@ import fr.ird.observe.services.dto.referential.ProgramDto; import fr.ird.observe.services.dto.referential.ReferentialDto; import fr.ird.observe.services.dto.referential.ReferentialDtos; import fr.ird.observe.services.dto.referential.VesselSizeCategoryDto; +import fr.ird.observe.services.service.DataNotFoundException; import fr.ird.observe.services.service.ReferentialService; import fr.ird.observe.ui.DecoratorService; import fr.ird.observe.ui.UIHelper; @@ -44,22 +46,46 @@ 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 fr.ird.observe.validation.ValidationContext; import jaxx.runtime.JAXXContext; import jaxx.runtime.swing.CardLayout2Ext; +import jaxx.runtime.swing.ErrorDialogUI; import jaxx.runtime.swing.editor.bean.BeanListHeader; import jaxx.runtime.validator.swing.SwingValidatorUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.decorator.Decorator; - -import javax.swing.*; +import org.nuiton.decorator.DecoratorUtil; +import org.nuiton.decorator.JXPathDecorator; +import org.nuiton.util.beans.Binder; +import org.nuiton.util.beans.BinderFactory; + +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.RowSorter; +import javax.swing.SortOrder; +import javax.swing.SpringLayout; +import javax.swing.SwingUtilities; import javax.swing.border.TitledBorder; +import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.TableCellRenderer; -import java.awt.*; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.Font; import java.beans.Introspector; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.List; import java.util.Map; @@ -119,8 +145,7 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content String message2 = t("observe.message.show.usage.for.delete2"); UsagesUI usagesUI = new UsagesUI(tx); - //FIXME - usagesUI.init(message, message2, null, null); + usagesUI.init(message, message2, null, usages); UIHelper.askUser(null, t("observe.title.can.not.delete.referentiel"), @@ -145,9 +170,7 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content String message3 = t("observe.message.show.usage.for.desactivated3"); UsagesUI usagesUI = new UsagesUI(tx); - - //FIXME - usagesUI.init(message, message2, message3, null); + usagesUI.init(message, message2, message3, usages); int reponse = UIHelper.askUser(null, t("observe.title.need.confirm.to.desactivate.referentiel"), @@ -171,7 +194,17 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content return false; } - public void selectBean(E selectedBean) { + public void selectBean(ReferenceDto<E> selectedReference) { + + FormDto<E> formDto; + if (getDataSource().canWriteReferential()) { + formDto = getReferentialService().loadToEdit(getBeanType(), selectedReference.getId()); + } else { + formDto = getReferentialService().loadToRead(getBeanType(), selectedReference.getId()); + } + + E selectedBean = formDto.getForm(); + getModel().setSelectedBean(selectedBean); // copy right now the selected bean to the model bean to respect contract @@ -179,7 +212,8 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content //FIXME // getLoadBinder().load(selectedBean, getBean(), true); - ReferentialDtos.copyReferentialDto(selectedBean, getBean()); + Binder<E, E> binder = BinderFactory.newBinder(getBeanType()); + binder.copy(selectedBean, getBean()); //TODO update data cache @@ -214,21 +248,10 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content * @param button le boutton qui a declanche l'action */ public void showUniqueKeys(JButton button) { - List<E> entities; - Class<E> beanType = getBeanType(); - //FIXME -// try { -// entities = getDataService().loadDecoratedEntities(getDataSource(), -// beanType); -// -// } catch (DataSourceException e) { -// ErrorDialogUI.showError(e); -// return; -// } -// -// List<Object[]> datas = new ArrayList<Object[]>(entities.size()); + ReferenceSetDto<E> entities = getReferentialService().getReferentialReferenceSet(beanType); + List<Object[]> datas = new ArrayList<>(entities.sizeReference()); String[] naturalIds = getModel().getNaturalIds(); int nbColumns = naturalIds.length + 1; @@ -238,75 +261,74 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content columns[0] = Introspector.decapitalize(beanType.getSimpleName()); DecoratorService dService = getDecoratorService(); - //FIXME -// Loador<E> binder = getLoadBinder(); -// -// Decorator<E> decorator = dService.getDecoratorByType(beanType); -// for (E e : entities) { -// Map<String, Object> values = binder.obtainProperties(e, naturalIds); -// Object[] data = new Object[nbColumns]; -// int index = 0; -// data[0] = decorator.toString(e); -// for (String property : naturalIds) { -// Object o = values.get(property); -// if (ContentReferenceUIModel.DEFAULT_PROPERTIES[0].equals(property) && o == null) { -// // cas special du code à 0, le loador ne retourne pas -// // de valeur car c'est la valeur par defaut d'un type -// // primitif, on force donc l'utilisation du zero. -// o = 0; -// } -// if ("code".equals(property) && o == null) { -// // cas special du code à 0, le loador ne retourne pas -// // de valeur car c'est la valeur par defaut d'un type -// // primitif, on force donc l'utilisation du zero. -// o = 0; -// } -// if ("gender".equals(property) && o == null) { -// // cas special du code à 0, le loador ne retourne pas -// // de valeur car c'est la valeur par defaut d'un type -// // primitif, on force donc l'utilisation du zero. -// o = 0; -// } -// Object value; -// if (o instanceof ReferenceEntity) { -// // on doit decoree la valeur -// Decorator<?> d = dService.getDecoratorByType(o.getClass()); -// value = d.toString(o); -// } else { -// value = o; -// } -// data[++index] = value; -// } -// datas.add(data); -// } -// -// JTable table = new JTable(new UniqueKeyTableModel(columns, datas)); -// -// table.setAutoCreateRowSorter(true); -// table.getRowSorter().setSortKeys(Arrays.asList( -// new RowSorter.SortKey(0, SortOrder.ASCENDING))); -// table.setFillsViewportHeight(true); -// JScrollPane pane = new JScrollPane(); -// -// getUi().decorateUniqueKeyTable(table, new DefaultTableCellRenderer(), pane); -// -// pane.setViewportView(table); -// pane.setVerticalScrollBarPolicy( -// JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); -// -// String title = t("observe.title.unique.key", -// t(DecoratorService.getEntityLabel(beanType))); -// -// pane.setBorder(new TitledBorder(title)); -// -// JPopupMenu popup = new JPopupMenu(); -// popup.setBorder(null); -// popup.add(pane); -// popup.pack(); -// Dimension dim = popup.getPreferredSize(); -// int x = (int) (button.getPreferredSize().getWidth() - dim.getWidth()); -// int y = button.getHeight(); -// popup.show(button, x, y); + Decorator<E> decorator = dService.getDecoratorByType(beanType); + + for (ReferenceDto<E> e : entities.getReference()) { + + Object[] data = new Object[nbColumns]; + int index = 0; + data[0] = decorator.toString(e); + + for (String property : naturalIds) { + Object o = e.getPropertyValue(property); + if (ContentReferenceUIModel.DEFAULT_PROPERTIES[0].equals(property) && o == null) { + // cas special du code à 0, le loador ne retourne pas + // de valeur car c'est la valeur par defaut d'un type + // primitif, on force donc l'utilisation du zero. + o = 0; + } + if ("code".equals(property) && o == null) { + // cas special du code à 0, le loador ne retourne pas + // de valeur car c'est la valeur par defaut d'un type + // primitif, on force donc l'utilisation du zero. + o = 0; + } + if ("gender".equals(property) && o == null) { + // cas special du code à 0, le loador ne retourne pas + // de valeur car c'est la valeur par defaut d'un type + // primitif, on force donc l'utilisation du zero. + o = 0; + } + Object value; + if (o instanceof ReferentialDto) { + // on doit decorer la valeur + Decorator<?> d = dService.getDecoratorByType(o.getClass()); + value = d.toString(o); + } else { + value = o; + } + data[++index] = value; + } + datas.add(data); + } + + JTable table = new JTable(new UniqueKeyTableModel(columns, datas)); + + table.setAutoCreateRowSorter(true); + table.getRowSorter().setSortKeys(Arrays.asList( + new RowSorter.SortKey(0, SortOrder.ASCENDING))); + table.setFillsViewportHeight(true); + JScrollPane pane = new JScrollPane(); + + getUi().decorateUniqueKeyTable(table, new DefaultTableCellRenderer(), pane); + + pane.setViewportView(table); + pane.setVerticalScrollBarPolicy( + JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); + + String title = t("observe.title.unique.key", + t(DecoratorService.getEntityLabel(beanType))); + + pane.setBorder(new TitledBorder(title)); + + JPopupMenu popup = new JPopupMenu(); + popup.setBorder(null); + popup.add(pane); + popup.pack(); + Dimension dim = popup.getPreferredSize(); + int x = (int) (button.getPreferredSize().getWidth() - dim.getWidth()); + int y = button.getHeight(); + popup.show(button, x, y); } public void showUsages() { @@ -320,17 +342,18 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content } // recherche des utilisation du bean dans la base - //FIXME -// EntityMap usages; -// try { -// usages = getDataService().findAllUsages(getDataSource(), bean); -// } catch (DataSourceException e) { -// ErrorDialogUI.showError(e); -// if (log.isErrorEnabled()) { -// log.error(e); -// } -// return; -// } + DtoMap usages; + try { + usages = getReferentialService().findAllUsages(bean); + + } catch (DataNotFoundException e) { + ErrorDialogUI.showError(e); + if (log.isErrorEnabled()) { + log.error(e); + } + return; + } + DecoratorService dService = getDecoratorService(); Decorator<?> decorator = dService.getDecoratorByType(bean.getClass()); String type = DecoratorService.getEntityLabel(bean.getClass()); @@ -341,8 +364,7 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content ContentReferenceUI<E> ui = getUi(); UsagesUI usagesUI = new UsagesUI(ui); - //FIXME - usagesUI.init(message, null, null, null); + usagesUI.init(message, null, null, usages); UIHelper.askUser(ui, t("observe.title.show.usage"), @@ -412,6 +434,8 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content } }); + fillListWithReferentials(); + // UIHelper.getLayer(ui.getEditKeyTable()).setUI(ui.getEditKeyTableLayerUI()); } @@ -659,24 +683,25 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content log.debug("entity status was desactivated, looking " + "for usage"); } -// EntityMap usages = dataService.findAllUsages(dataSource, bean); -// -// if (usages.isEmpty()) { -// if (log.isInfoEnabled()) { -// log.info("No usage found, no warning to display"); -// } -// } else { -// // some usages were found -// boolean willsave = showUsagesForDesactivated(getUi(), bean, -// usages); -// if (!willsave) { -// if (log.isDebugEnabled()) { -// log.debug("User refuses to continue, skip " + -// "saving..."); -// } -// return false; -// } -// } + + DtoMap usages = getReferentialService().findAllUsages(bean); + + if (usages.isEmpty()) { + if (log.isInfoEnabled()) { + log.info("No usage found, no warning to display"); + } + } else { + // some usages were found + boolean willsave = showUsagesForDesactivated(getUi(), bean, + usages); + if (!willsave) { + if (log.isDebugEnabled()) { + log.debug("User refuses to continue, skip " + + "saving..."); + } + return false; + } + } } @@ -716,21 +741,21 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content } // recherche des utilisation du bean dans la base -// EntityMap usages = dataService.findAllUsages(getDataSource(), bean); -// -// if (usages.isEmpty()) { -// if (log.isDebugEnabled()) { -// log.debug("No usage found, no warning to display"); -// } -// } else { -// -// // some usages were found -// if (log.isDebugEnabled()) { -// log.debug("can not delete referentiel entity (found usages)"); -// } -// showUsagesForDelete(ui, bean, usages); -// return false; -// } + DtoMap usages = getReferentialService().findAllUsages(bean); + + if (usages.isEmpty()) { + if (log.isDebugEnabled()) { + log.debug("No usage found, no warning to display"); + } + } else { + + // some usages were found + if (log.isDebugEnabled()) { + log.debug("can not delete referentiel entity (found usages)"); + } + showUsagesForDelete(ui, bean, usages); + return false; + } if (!UIHelper.confirmForEntityDelete(ui, model.getBeanType(), bean)) { return false; @@ -842,19 +867,18 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content 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; -// } + protected void fillListWithReferentials() { + ReferenceSetDto referentialReferenceSet = getReferentialService().getReferentialReferenceSet(getBeanType()); + List<ReferenceDto> data = new ArrayList<>(referentialReferenceSet.getReference()); + + Decorator<ReferenceDto> decorator = ObserveSwingApplicationContext.get().getDecorator(ReferenceDto.class, + getBeanType().getSimpleName()); + DecoratorUtil.sort((JXPathDecorator<ReferenceDto>) decorator, data, 0); + + BeanListHeader list = getUi().getListHeader(); + list.setData(data); + list.putClientProperty("data", data); + } protected ReferentialService getReferentialService() { return ObserveSwingApplicationContext.get().newService(ReferentialService.class); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/GearUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/GearUIHandler.java index 1f3c332..f69b03b 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/GearUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/GearUIHandler.java @@ -22,6 +22,7 @@ package fr.ird.observe.ui.content.ref.impl; * #L% */ +import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.referential.GearDto; import fr.ird.observe.ui.content.ref.ContentReferenceUI; import fr.ird.observe.ui.content.ref.ContentReferenceUIHandler; @@ -70,7 +71,7 @@ public class GearUIHandler extends ContentReferenceUIHandler<GearDto> { } @Override - public void selectBean(GearDto selectedBean) { + public void selectBean(ReferenceDto<GearDto> selectedBean) { super.selectBean(selectedBean); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/LengthWeightParameterUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/LengthWeightParameterUIHandler.java index 0e3a1d9..caac165 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/LengthWeightParameterUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/LengthWeightParameterUIHandler.java @@ -22,6 +22,7 @@ package fr.ird.observe.ui.content.ref.impl; * #L% */ +import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.referential.LengthWeightParameterDto; import fr.ird.observe.ui.content.ref.ContentReferenceUI; import fr.ird.observe.ui.content.ref.ContentReferenceUIHandler; @@ -70,7 +71,7 @@ public class LengthWeightParameterUIHandler extends ContentReferenceUIHandler<Le } @Override - public void selectBean(LengthWeightParameterDto selectedBean) { + public void selectBean(ReferenceDto<LengthWeightParameterDto> selectedBean) { super.selectBean(selectedBean); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/ProgramUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/ProgramUIHandler.java index 84aac6b..e20b5d4 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/ProgramUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/ProgramUIHandler.java @@ -22,6 +22,7 @@ package fr.ird.observe.ui.content.ref.impl; * #L% */ +import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.referential.ProgramDto; import fr.ird.observe.ui.content.ref.ContentReferenceUI; import fr.ird.observe.ui.content.ref.ContentReferenceUIHandler; @@ -70,7 +71,7 @@ public class ProgramUIHandler extends ContentReferenceUIHandler<ProgramDto> { } @Override - public void selectBean(ProgramDto selectedBean) { + public void selectBean(ReferenceDto<ProgramDto> selectedBean) { super.selectBean(selectedBean); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/SpeciesListUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/SpeciesListUIHandler.java index 7969a5f..e94f308 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/SpeciesListUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/SpeciesListUIHandler.java @@ -22,6 +22,7 @@ package fr.ird.observe.ui.content.ref.impl; * #L% */ +import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.referential.SpeciesListDto; import fr.ird.observe.ui.content.ref.ContentReferenceUI; import fr.ird.observe.ui.content.ref.ContentReferenceUIHandler; @@ -70,7 +71,7 @@ public class SpeciesListUIHandler extends ContentReferenceUIHandler<SpeciesListD } @Override - public void selectBean(SpeciesListDto selectedBean) { + public void selectBean(ReferenceDto<SpeciesListDto> selectedBean) { super.selectBean(selectedBean); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/SpeciesUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/SpeciesUIHandler.java index f85adb8..ce33651 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/SpeciesUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/SpeciesUIHandler.java @@ -22,6 +22,7 @@ package fr.ird.observe.ui.content.ref.impl; * #L% */ +import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.referential.SpeciesDto; import fr.ird.observe.ui.content.ref.ContentReferenceUI; import fr.ird.observe.ui.content.ref.ContentReferenceUIHandler; @@ -70,7 +71,7 @@ public class SpeciesUIHandler extends ContentReferenceUIHandler<SpeciesDto> { } @Override - public void selectBean(SpeciesDto selectedBean) { + public void selectBean(ReferenceDto<SpeciesDto> selectedBean) { super.selectBean(selectedBean); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/VesselUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/VesselUIHandler.java index 90dec36..ec88a5a 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/VesselUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/VesselUIHandler.java @@ -22,6 +22,7 @@ package fr.ird.observe.ui.content.ref.impl; * #L% */ +import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.referential.VesselDto; import fr.ird.observe.ui.content.ref.ContentReferenceUI; import fr.ird.observe.ui.content.ref.ContentReferenceUIHandler; @@ -70,7 +71,7 @@ public class VesselUIHandler extends ContentReferenceUIHandler<VesselDto> { } @Override - public void selectBean(VesselDto selectedBean) { + public void selectBean(ReferenceDto<VesselDto> selectedBean) { super.selectBean(selectedBean); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/DtoNodeSupport.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/DtoNodeSupport.java index ea710e6..a67ab87 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/DtoNodeSupport.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/DtoNodeSupport.java @@ -126,13 +126,13 @@ public abstract class DtoNodeSupport<E extends IdDto> extends ObserveNode { protected void loadEntity(ObserveDataProvider oProvider) { //FIXME - if (oProvider.getSelectionModel() != null) { - - if (log.isDebugEnabled()) { - log.debug("try to get entity from selectionModel " + internalClass + " : " + id); - } - entity = (ReferenceDto<E>) oProvider.getSelectionModel().getEntityCache(id); - } +// if (oProvider.getSelectionModel() != null) { +// +// if (log.isDebugEnabled()) { +// log.debug("try to get entity from selectionModel " + internalClass + " : " + id); +// } +// entity = (ReferenceDto<E>) oProvider.getSelectionModel().getEntityCache(id); +// } if (entity == null) { diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/usage/UsagesUI.jaxx b/observe-application-swing/src/main/java/fr/ird/observe/ui/usage/UsagesUI.jaxx index a2e144b..cf668af 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/usage/UsagesUI.jaxx +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/usage/UsagesUI.jaxx @@ -29,7 +29,7 @@ Interface graphique pour afficher la liste des usages d'une entitee donnee. fr.ird.observe.ObserveSwingApplicationContext fr.ird.observe.ui.UIHelper - fr.ird.observe.services.dto.AbstractObserveDto + fr.ird.observe.services.dto.IdDto java.awt.Dimension java.util.List @@ -43,7 +43,7 @@ private UsagesUIHandler handler = new UsagesUIHandler(); public void init(String message, String message2, String message3, - Map<Class<? extends AbstractObserveDto>, List<? extends AbstractObserveDto>> usages) { + Map<Class<? extends IdDto>, List<? extends IdDto>> usages) { getHandler().initUI(this, message,message2, message3, usages); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/usage/UsagesUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/usage/UsagesUIHandler.java index a890a8d..8538cb2 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/usage/UsagesUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/usage/UsagesUIHandler.java @@ -22,6 +22,7 @@ package fr.ird.observe.ui.usage; import fr.ird.observe.ObserveSwingApplicationContext; +import fr.ird.observe.services.dto.IdDto; import fr.ird.observe.ui.DecoratorService; import fr.ird.observe.services.dto.AbstractObserveDto; import fr.ird.observe.services.dto.referential.ReferentialDto; @@ -61,8 +62,8 @@ public class UsagesUIHandler { public void initUI(UsagesUI ui, String message, String message2, String message3, - Map<Class<? extends AbstractObserveDto>, - List<? extends AbstractObserveDto>> usages) { + Map<Class<? extends IdDto>, + List<? extends IdDto>> usages) { // toujours nettoyer l'ui avant tout cleanUI(ui); @@ -80,10 +81,10 @@ public class UsagesUIHandler { t("observe.message.no.usage.for.entity"))); } else { - for (Map.Entry<Class<? extends AbstractObserveDto>, - List<? extends AbstractObserveDto>> entry : usages.entrySet()) { - Class<? extends AbstractObserveDto> type = entry.getKey(); - List<? extends AbstractObserveDto> entitites = entry.getValue(); + for (Map.Entry<Class<? extends IdDto>, + List<? extends IdDto>> entry : usages.entrySet()) { + Class<? extends IdDto> type = entry.getKey(); + List<? extends IdDto> entitites = entry.getValue(); String typeTitle = DecoratorService.getEntityLabel(type); typeTitle = t(typeTitle); addUsages(ui, type, entitites, typeTitle); diff --git a/observe-application-swing/src/main/resources/i18n/observe-application-swing_fr_FR.properties b/observe-application-swing/src/main/resources/i18n/observe-application-swing_fr_FR.properties index cdaaeec..c83fcf8 100644 --- a/observe-application-swing/src/main/resources/i18n/observe-application-swing_fr_FR.properties +++ b/observe-application-swing/src/main/resources/i18n/observe-application-swing_fr_FR.properties @@ -893,16 +893,16 @@ observe.common.observer=Observateur observe.common.observerLabel= observe.common.obsolete.entity=Le référentiel %1$s est désactivé. observe.common.ocean=Océan -observe.common.ocean/label1= -observe.common.ocean/label2= -observe.common.ocean/label3= -observe.common.ocean/label4= -observe.common.ocean/label5= -observe.common.ocean/label6= -observe.common.ocean/label7= -observe.common.ocean/label8= +observe.common.ocean/label1=Océan +observe.common.ocean/label2=Océan +observe.common.ocean/label3=Océan +observe.common.ocean/label4=Océan +observe.common.ocean/label5=Océan +observe.common.ocean/label6=Océan +observe.common.ocean/label7=Océan +observe.common.ocean/label8=Océan observe.common.oceanForSpecies=Liste des océans -observe.common.oldCode3L= +observe.common.oldCode3L=ancien code \: observe.common.operation.resume=Résumé des opérations observe.common.organism=Organisme observe.common.ownership=Appartenance @@ -1012,25 +1012,25 @@ observe.common.undefined=< non défini > observe.common.undefined.tip=< non défini > observe.common.uri=URI observe.common.vessel=Bateau -observe.common.vessel/label1= -observe.common.vessel/label2= -observe.common.vessel/label3= -observe.common.vessel/label4= -observe.common.vessel/label5= -observe.common.vessel/label6= -observe.common.vessel/label7= -observe.common.vessel/label8= -observe.common.vesselActivityLongline= +observe.common.vessel/label1=Bateau +observe.common.vessel/label2=Bateau +observe.common.vessel/label3=Bateau +observe.common.vessel/label4=Bateau +observe.common.vessel/label5=Bateau +observe.common.vessel/label6=Bateau +observe.common.vessel/label7=Bateau +observe.common.vessel/label8=Bateau +observe.common.vesselActivityLongline=Activité bateau observe.common.vesselActivitySeine=Activité bateau observe.common.vesselActivitySeine.comment=Seule l'activité %1$s permet de saisir une calée. -observe.common.vesselActivitySeine/label1= -observe.common.vesselActivitySeine/label2= -observe.common.vesselActivitySeine/label3= -observe.common.vesselActivitySeine/label4= -observe.common.vesselActivitySeine/label5= -observe.common.vesselActivitySeine/label6= -observe.common.vesselActivitySeine/label7= -observe.common.vesselActivitySeine/label8= +observe.common.vesselActivitySeine/label1=Activité bateau +observe.common.vesselActivitySeine/label2=Activité bateau +observe.common.vesselActivitySeine/label3=Activité bateau +observe.common.vesselActivitySeine/label4=Activité bateau +observe.common.vesselActivitySeine/label5=Activité bateau +observe.common.vesselActivitySeine/label6=Activité bateau +observe.common.vesselActivitySeine/label7=Activité bateau +observe.common.vesselActivitySeine/label8=Activité bateau observe.common.vesselSizeCategory=Catégorie de bateau observe.common.vesselSpeed=Vitesse bateau (nd) observe.common.vesselType=Type de pêcherie 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 cf32161..758ceb9 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 @@ -22,6 +22,7 @@ package fr.ird.observe.application.web.controller.v1; * #L% */ +import fr.ird.observe.services.dto.DtoMap; import fr.ird.observe.services.dto.FormDto; import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.ReferenceSetDto; @@ -88,4 +89,8 @@ public class ReferentialServiceController extends ObserveAuthenticatedServiceCon service.delete(type, ids); } + @Override + public <R extends ReferentialDto> DtoMap findAllUsages(R bean) throws DataNotFoundException { + return service.findAllUsages(bean); + } } 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 d673eeb..4e2bd25 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 @@ -23,12 +23,14 @@ package fr.ird.observe.services.service; */ import fr.ird.observe.services.ObserveService; +import fr.ird.observe.services.dto.DtoMap; import fr.ird.observe.services.dto.FormDto; import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.ReferenceSetDto; import fr.ird.observe.services.dto.referential.ReferentialDto; import fr.ird.observe.services.spi.DeleteRequest; import fr.ird.observe.services.spi.PostRequest; +import fr.ird.observe.services.spi.ReadDataPermission; import fr.ird.observe.services.spi.ReadReferentialPermission; import fr.ird.observe.services.spi.Write; import fr.ird.observe.services.spi.WriteReferentialPermission; @@ -76,4 +78,8 @@ public interface ReferentialService extends ObserveService { @DeleteRequest <R extends ReferentialDto> void delete(Class<R> type, Collection<String> ids) throws DataNotFoundException; + @ReadReferentialPermission + @ReadDataPermission + <R extends ReferentialDto> DtoMap findAllUsages(R bean) throws DataNotFoundException; + } diff --git a/observe-services-model/src/main/java/fr/ird/observe/services/dto/DtoMap.java b/observe-services-model/src/main/java/fr/ird/observe/services/dto/DtoMap.java new file mode 100644 index 0000000..3dd3487 --- /dev/null +++ b/observe-services-model/src/main/java/fr/ird/observe/services/dto/DtoMap.java @@ -0,0 +1,43 @@ +/* + * #%L + * ObServe :: Entities + * %% + * Copyright (C) 2008 - 2010 IRD, Codelutin, Tony Chemit + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package fr.ird.observe.services.dto; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * A Dictionary of dtos + * + * @author Kevin Morin (Code Lutin) + */ +public class DtoMap extends HashMap<Class<? extends IdDto>, List<? extends IdDto>> { + + private static final long serialVersionUID = 1L; + + public DtoMap() { + } + + public DtoMap(Map<? extends Class<? extends IdDto>, ? extends List<? extends IdDto>> m) { + super(m); + } +} diff --git a/observe-services-model/src/main/java/fr/ird/observe/services/dto/referential/ReferentialDtos.java b/observe-services-model/src/main/java/fr/ird/observe/services/dto/referential/ReferentialDtos.java index cc9b4b1..30ded33 100644 --- a/observe-services-model/src/main/java/fr/ird/observe/services/dto/referential/ReferentialDtos.java +++ b/observe-services-model/src/main/java/fr/ird/observe/services/dto/referential/ReferentialDtos.java @@ -2,7 +2,6 @@ package fr.ird.observe.services.dto.referential; import com.google.common.base.Predicate; import com.google.common.collect.ImmutableSet; -import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.constants.ReferenceStatus; import fr.ird.observe.services.dto.referential.longline.BaitHaulingStatusDto; import fr.ird.observe.services.dto.referential.longline.BaitSettingStatusDto; 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 ca4c003..e036e86 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 @@ -23,16 +23,22 @@ package fr.ird.observe.services.service; */ import com.google.common.base.Optional; +import fr.ird.observe.entities.EntityMap; import fr.ird.observe.services.ObserveServiceTopia; +import fr.ird.observe.services.dto.DtoMap; 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.ReferenceSetDto; import fr.ird.observe.services.dto.referential.ReferentialDto; +import org.nuiton.topia.persistence.TopiaDao; import org.nuiton.topia.persistence.TopiaEntity; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Date; +import java.util.List; /** * Created on 16/08/15. @@ -115,4 +121,38 @@ public class ReferentialServiceTopia extends ObserveServiceTopia implements Refe deleteEntity(dtoType, entityType, ids); } + @Override + public <R extends ReferentialDto> DtoMap findAllUsages(R bean) throws DataNotFoundException { + + Class<? extends IdDto> referentialDtoType = bean.getClass(); + Class<TopiaEntity> entityType = getEntityType(referentialDtoType); + TopiaEntity entity = loadEntity(referentialDtoType, entityType, bean.getId()); + + TopiaDao<TopiaEntity> dao = getTopiaPersistenceContext().getDao(entityType); + EntityMap allUsages = new EntityMap(dao.findAllUsages(entity)); + + DtoMap result = new DtoMap(); + + for (Class<? extends TopiaEntity> type : allUsages.keySet()) { + + Class<? extends IdDto> dtoType = getDtoType(type); + List<? extends IdDto> dtos = test(dtoType, type, allUsages); + result.put(dtoType, dtos); + + } + + return result; + } + + protected <E extends TopiaEntity, I extends IdDto> List<I> test(Class<I> dtoType, + Class<E> type, + EntityMap allUsages) { + List<I> dtos = new ArrayList<>(); + List<E> entities = (List<E>) allUsages.get(type); + for (E entity : entities) { + I idDto = entityToDto(dtoType, type, entity); + dtos.add(idDto); + } + return dtos; + } } -- 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/7610 in repository observe. See http://git.codelutin.com/observe.git commit 22cbd16809c9a23ad074ecc64b1ea3d3e54ebc2e Author: Kevin Morin <morin@codelutin.com> Date: Thu Oct 15 10:20:37 2015 +0200 trad --- .../observe-application-swing_fr_FR.properties | 156 ++++++++++----------- 1 file changed, 78 insertions(+), 78 deletions(-) diff --git a/observe-application-swing/src/main/resources/i18n/observe-application-swing_fr_FR.properties b/observe-application-swing/src/main/resources/i18n/observe-application-swing_fr_FR.properties index c83fcf8..6198a5f 100644 --- a/observe-application-swing/src/main/resources/i18n/observe-application-swing_fr_FR.properties +++ b/observe-application-swing/src/main/resources/i18n/observe-application-swing_fr_FR.properties @@ -732,19 +732,19 @@ observe.common.activities.list=Liste des activités observe.common.activity=Activité observe.common.activityLongline= observe.common.activitySeine=Activité -observe.common.baitHaulingStatus= +observe.common.baitHaulingStatus=Status de l'appât au virage +observe.common.baitSettingStatus=Status de l'appât au filage +observe.common.baitType=Type d'appât +observe.common.baitsComposition=Composition des appâts observe.common.baitObservation=Gleure -observe.common.baitSettingStatus= -observe.common.baitType= -observe.common.baitsComposition= -observe.common.basket= +observe.common.basket=Basket observe.common.birdsObservation=Oiseaux observe.common.boolean.false=Non observe.common.boolean.null=Indéterminé observe.common.boolean.true=Oui -observe.common.branchline= -observe.common.branchlineLength= -observe.common.branchlinesComposition= +observe.common.branchline=Avançon +observe.common.branchlineLength=Avançon (m) +observe.common.branchlinesComposition=Composition des avançons observe.common.brand=Marque observe.common.brandName=Marque observe.common.broughtOnDeck=Monté sur le pont @@ -752,8 +752,8 @@ observe.common.capacity=Capacité transport (m³) observe.common.capacityLabel=Libellé capacité observe.common.captain=Capitaine observe.common.caracteristics=Caractéristiques -observe.common.catchFateLongline= -observe.common.catchLongline= +observe.common.catchFateLongline=Devenir capture +observe.common.catchLongline=Capture observe.common.catchWeight=Poids estimé (en t) observe.common.catchWeightComputed.computed.tip=Le poids estimé a été calculé (%s) observe.common.catchWeightComputed.observed.tip=Le poids estimé a été observé @@ -781,53 +781,53 @@ observe.common.description=Description observe.common.detailledActivitiesObservation=Activités détaillées observe.common.detectionMode=Mode détection observe.common.directory=Répertoire -observe.common.encounter= -observe.common.encounterType= +observe.common.encounter=Rencontre +observe.common.encounterType=Type de rencontre observe.common.endDate=Fin de validité observe.common.endLogValue=Loch du soir (milles) observe.common.equation=Relation Taille-Poids observe.common.ersId=Id ERS -observe.common.faoCode= +observe.common.faoCode=Code FAO observe.common.file=Fichier observe.common.firstName=Prénom observe.common.flagCountry=Pavillon -observe.common.floatingObject= -observe.common.floatline1Length= -observe.common.floatline2Length= -observe.common.floatlineLengths= -observe.common.floatlinesComposition= +observe.common.floatingObject=Objet flottant +observe.common.floatline1Length=Orin 1 (m) +observe.common.floatline2Length=Orin 2 (m) +observe.common.floatlineLengths=Template +observe.common.floatlinesComposition=Composition des orins observe.common.formsUrl=URL des formulaires -observe.common.fpaZone= +observe.common.fpaZone=Zone FPA observe.common.gaugeLabel=Libellé jauge -observe.common.gear= -observe.common.gearCaracteristic= -observe.common.gearCaracteristicType= +observe.common.gear=Équipement +observe.common.gearCaracteristic=Caractéristique d'un équipement +observe.common.gearCaracteristicType=Type de caractéristique d'équipement observe.common.gearType=Type d'engin -observe.common.gearUseFeaturesLongline= -observe.common.gearUseFeaturesSeine= -observe.common.gender= +observe.common.gearUseFeaturesLongline=Équipement +observe.common.gearUseFeaturesSeine=Équipement +observe.common.gender=Sexe observe.common.generateReport=Générer un rapport de validation observe.common.global.progression.description=Progression globale -observe.common.gps.activity= -observe.common.gps.gpsPoint= -observe.common.gps.gpsPointInterval= -observe.common.gpsPointInterval= -observe.common.harbour= -observe.common.haulingIdentifier= -observe.common.healthness= +observe.common.gps.activity=Activité +observe.common.gps.gpsPoint=Point GPS +observe.common.gps.gpsPointInterval=Intervalle de points +observe.common.gpsPointInterval=Intervalle de points +observe.common.harbour=Port +observe.common.haulingIdentifier=Virage +observe.common.healthness=État de santé observe.common.heureobservation=Heure d'observation -observe.common.homeId= +observe.common.homeId=Identifiant observe.common.homeIdFAOWormsId=Code 3L / FAO / Worms -observe.common.hookPosition= -observe.common.hookSize= -observe.common.hookType= -observe.common.hooksComposition= -observe.common.id= -observe.common.inconnu= +observe.common.hookPosition=Position du hameçon +observe.common.hookSize=Taille +observe.common.hookType=Type d'hameçon +observe.common.hooksComposition=Composition des hameçons +observe.common.id=Identifiant +observe.common.inconnu=inconnu observe.common.iso2Code=code ISO-2 observe.common.iso3Code=Code ISO-3 -observe.common.itemHorizontalPosition= -observe.common.itemVerticalPosition= +observe.common.itemHorizontalPosition=Localisation de l'élément sur la ligne mère +observe.common.itemVerticalPosition=Localisation de l'élément sur l'avançon observe.common.keelCodeFlotte=Code quille /Code flotte observe.common.label1=Libellé anglais observe.common.label2=Libellé français @@ -846,16 +846,16 @@ observe.common.length.inf=Longueur (cm inf.) observe.common.length.observed.tip=La longueur a été observée observe.common.lengthMeasureType=Type de mensuration observe.common.lengthWeightFormula=Relation Poids -observe.common.lengthWeightParameter= +observe.common.lengthWeightParameter=Relation Taille-Poids observe.common.libelles=Libellés -observe.common.lightsticksColor= -observe.common.lightsticksType= -observe.common.lineType= -observe.common.locode= +observe.common.lightsticksColor=Couleur de baton lumineux +observe.common.lightsticksType=Type de baton lumineux +observe.common.lineType=Type de ligne +observe.common.locode=Locode observe.common.longitude=Longitude observe.common.lowerValueUpperValue=Borne min-max observe.common.mammalsObservation=Mammifères -observe.common.maturityStatus= +observe.common.maturityStatus=Maturité observe.common.meanLength=Taille moyenne (en cm) observe.common.meanLengthComputed.computed.tip=La taille moyenne a été calculée (%s) observe.common.meanLengthComputed.observed.tip=La taille moyenne a été observée @@ -869,28 +869,28 @@ observe.common.measureType.lf=LF observe.common.measureType.unknown=Inconnu observe.common.minLengthMax=Taille min-max (en cm) observe.common.minWeightMax=Poids min-max (en Kg) -observe.common.mitigationType= -observe.common.name= +observe.common.mitigationType=Type de mesure d'atténuation +observe.common.name=Nom observe.common.needComment=Nécessite un commentaire observe.common.nextFpaZone=Zone FPA pénétrée observe.common.no.balise=Aucune balise lue -observe.common.nocode= +observe.common.nocode=code absent observe.common.nonCoupSenne=Non coup de senne observe.common.nonTargetCatch=Faune accessoire conservée ou rejetée -observe.common.nonTargetLength= +observe.common.nonTargetLength=Longueur (cm inf.) observe.common.nonTargetObservation=Faune associée observe.common.nonTargetSample=Echantillon faune accessoire observe.common.none=Aucun observe.common.objectFate=Devenir de l'objet observe.common.objectObservedSpecies=Faune observée observe.common.objectOperation=Opération sur l'objet -observe.common.objectSchoolEstimate= +observe.common.objectSchoolEstimate=Estimation banc objet observe.common.objectType=Type d'objet observe.common.objectsObservation=Objet flottants observe.common.observedSystem=Système observé observe.common.observedSystemDistance=Distance système observé (en milles avec 1 décimale) observe.common.observer=Observateur -observe.common.observerLabel= +observe.common.observerLabel=Observateur observe.common.obsolete.entity=Le référentiel %1$s est désactivé. observe.common.ocean=Océan observe.common.ocean/label1=Océan @@ -922,8 +922,8 @@ observe.common.program.observation.value.7=valeur 7 non définie observe.common.program.observation.value.8=valeur 8 non définie observe.common.program.observation.value.9=valeur 9 non définie observe.common.reasonForDiscard=Raison rejet -observe.common.reasonForNoFishing= -observe.common.reasonForNullSet= +observe.common.reasonForNoFishing=Raison de non coup de Senne +observe.common.reasonForNullSet=Cause coup nul observe.common.reportsUrl=URL de rapport observe.common.resume=Résumé de la configuration observe.common.route=Route @@ -934,7 +934,7 @@ observe.common.schoolType=Type de banc observe.common.scientificLabel=Libellé scientifique observe.common.seaSurfaceTemperature=Température surface (°) observe.common.searchMaximum=Vitesse maximale -observe.common.section= +observe.common.section=Section observe.common.select.gps.import.file=Fichier à importer observe.common.select.gps.import.file.tip=Choisir le fichier de trace GPS à importer observe.common.select.gps.maxDelay=Temps maximum (mn) @@ -950,24 +950,24 @@ observe.common.select.validate.mode.tip=Choisir le type de données à valider observe.common.select.validate.scope=Niveau de validation observe.common.select.validate.scope.tip=Choisir le ou les niveaux de validation observe.common.selected.validators=Nombre de validateurs détectés \: %1$s -observe.common.sensorBrand= -observe.common.sensorDataFormat= -observe.common.sensorPosition= -observe.common.sensorType= -observe.common.sensorUsed= -observe.common.setLongline= -observe.common.setSeine= -observe.common.settingIdentifier= -observe.common.settingShape= +observe.common.sensorBrand=Marque de capteur +observe.common.sensorDataFormat=Format de données de capteur +observe.common.sensorPosition=Position de capteur +observe.common.sensorType=Type de capteur +observe.common.sensorUsed=Capteur utilisé +observe.common.setLongline=Opération de pêche +observe.common.setSeine=Calée +observe.common.settingIdentifier=Filage +observe.common.settingShape=Forme au filage observe.common.sex=Sexe -observe.common.sizeMeasure= -observe.common.sizeMeasureType= +observe.common.sizeMeasure=Mesure de taille +observe.common.sizeMeasureType=Type de mesure de taille observe.common.species=Espèce -observe.common.species/scientificLabel= +observe.common.species/scientificLabel=Espèce observe.common.speciesFate=Devenir espèce observe.common.speciesFaune=Espèce de faune observe.common.speciesGroup=Groupe espèce -observe.common.speciesList= +observe.common.speciesList=Liste d'espèces observe.common.speciesStatus=Statut faune observée observe.common.speciesThon=Espèce de thon observe.common.speedRange=Libellé vitesse vent @@ -977,7 +977,7 @@ observe.common.startDateFinValidite=Début - fin de validité observe.common.startLogValue=Loch du matin (milles) observe.common.status=Statut observe.common.step.description=Description de l'étape -observe.common.stomacFullness= +observe.common.stomacFullness=Niveau de remplissage de l'estomac observe.common.storage.not.valid=Source de données non configurée observe.common.supportVesselName=Nom supply observe.common.surroundingActivity=Activité environnante @@ -986,12 +986,12 @@ observe.common.taillePoids.caracteristics=Caractéristiques Taille-Poids observe.common.targetCatch=Capture cible observe.common.targetDiscarded=Rejet de thon observe.common.targetDiscardsObservation=Rejets thon -observe.common.targetLength= +observe.common.targetLength=Taille Thon observe.common.targetSample=Echantillon thon rejeté observe.common.targetSampleCapture=Echantillon thon capturé -observe.common.tdr= -observe.common.tdrRecord= -observe.common.time= +observe.common.tdr=Enregistreur de profondeur +observe.common.tdrRecord=Enregistrement de profondeur +observe.common.time=Heure observe.common.topiaCreateDate=Date de création observe.common.topiaId=Identifiant technique observe.common.topiaVersion=Version @@ -999,8 +999,8 @@ observe.common.totalCount=Nombre estimé observe.common.totalCountComputed.computed.tip=Le nombre estimé a été calculé (%s) observe.common.totalCountComputed.observed.tip=Le nombre estimé a été observé observe.common.totalWeight=Poids -observe.common.tracelineLength= -observe.common.transmittingBuoy= +observe.common.tracelineLength=Partie basse (m) +observe.common.transmittingBuoy=Balise lue observe.common.transmittingBuoyOperation=Opération balise observe.common.transmittingBuoyType=Type de balise observe.common.tripLongline=Marée @@ -1041,8 +1041,8 @@ observe.common.weight.ind=Poids ind. (en Kg) observe.common.weight.observed.tip=Le poids a été observé observe.common.weightCategory=Catégorie de poids observe.common.weightLengthFormula=Relation Taille -observe.common.weightMeasure= -observe.common.weightMeasureType= +observe.common.weightMeasure=Mesure de poids +observe.common.weightMeasureType=Type de mesure de poids observe.common.well=Cuve observe.common.wind=Vent Beaufort observe.common.yearService=Année de mise en service -- 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/7610 in repository observe. See http://git.codelutin.com/observe.git commit 63eaf8326979af4b08fab447104d10ea92f4e80f Author: Kevin Morin <morin@codelutin.com> Date: Thu Oct 15 10:32:32 2015 +0200 fix typo --- .../observe-application-swing_fr_FR.properties | 36 +++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/observe-application-swing/src/main/resources/i18n/observe-application-swing_fr_FR.properties b/observe-application-swing/src/main/resources/i18n/observe-application-swing_fr_FR.properties index 6198a5f..8006abf 100644 --- a/observe-application-swing/src/main/resources/i18n/observe-application-swing_fr_FR.properties +++ b/observe-application-swing/src/main/resources/i18n/observe-application-swing_fr_FR.properties @@ -29,16 +29,16 @@ observe.action.auto.copy.to.clipboard=Copie automatique dans le presse-papier observe.action.auto.copy.to.clipboard.tip=Mettre à jour automatiquement le contenu du presse-papier avec les résultats observe.action.back.to.list=Retour à la liste observe.action.back.to.list.tip=Retour à la liste des données -observe.action.baitHaulingStatus.create.tip=Créer un nouveau status de l'appât au virage -observe.action.baitHaulingStatus.delete.tip=Supprimer le status de l'appât au virage sélectionné -observe.action.baitHaulingStatus.detail.tip=Voir les détails du status de l'appât au virage sélectionné -observe.action.baitHaulingStatus.modify.tip=Modifier le status de l'appât au virage sélectionné -observe.action.baitHaulingStatus.save.tip=Sauver les modifications du status de l'appât au virage -observe.action.baitSettingStatus.create.tip=Créer un nouveau status de l'appât au filage -observe.action.baitSettingStatus.delete.tip=Supprimer le status de l'appât au filage sélectionné -observe.action.baitSettingStatus.detail.tip=Voir les détails du status de l'appât au filage sélectionné -observe.action.baitSettingStatus.modify.tip=Modifier le status de l'appât au filage sélectionné -observe.action.baitSettingStatus.save.tip=Sauver les modifications du status de l'appât au filage +observe.action.baitHaulingStatus.create.tip=Créer un nouveau statut de l'appât au virage +observe.action.baitHaulingStatus.delete.tip=Supprimer le statut de l'appât au virage sélectionné +observe.action.baitHaulingStatus.detail.tip=Voir les détails du statut de l'appât au virage sélectionné +observe.action.baitHaulingStatus.modify.tip=Modifier le statut de l'appât au virage sélectionné +observe.action.baitHaulingStatus.save.tip=Sauver les modifications du statuts de l'appât au virage +observe.action.baitSettingStatus.create.tip=Créer un nouveau statut de l'appât au filage +observe.action.baitSettingStatus.delete.tip=Supprimer le statut de l'appât au filage sélectionné +observe.action.baitSettingStatus.detail.tip=Voir les détails du statut de l'appât au filage sélectionné +observe.action.baitSettingStatus.modify.tip=Modifier le statut de l'appât au filage sélectionné +observe.action.baitSettingStatus.save.tip=Sauver les modifications du statut de l'appât au filage observe.action.baitType.create.tip=Créer un nouveau type d'appât observe.action.baitType.delete.tip=Supprimer le type d'appât sélectionné observe.action.baitType.detail.tip=Voir les détails du type d'appât sélectionné @@ -732,11 +732,11 @@ observe.common.activities.list=Liste des activités observe.common.activity=Activité observe.common.activityLongline= observe.common.activitySeine=Activité -observe.common.baitHaulingStatus=Status de l'appât au virage -observe.common.baitSettingStatus=Status de l'appât au filage +observe.common.baitHaulingStatus=Statut de l'appât au virage +observe.common.baitObservation=Gleure +observe.common.baitSettingStatus=Statut de l'appât au filage observe.common.baitType=Type d'appât observe.common.baitsComposition=Composition des appâts -observe.common.baitObservation=Gleure observe.common.basket=Basket observe.common.birdsObservation=Oiseaux observe.common.boolean.false=Non @@ -2159,8 +2159,8 @@ observe.title.consolidate=Consolider les données observateur observe.title.consolidate.tip=Consolider les données observateur observe.title.content.HookSizes= observe.title.content.HookTypes= -observe.title.content.baitHaulingStatuss=Gestion des status de l'appât au virage -observe.title.content.baitSettingStatuss=Gestion des status de l'appât au filage +observe.title.content.baitHaulingStatuss=Gestion des statuts de l'appât au virage +observe.title.content.baitSettingStatuss=Gestion des statuts de l'appât au filage observe.title.content.baitTypes=Gestion des types d'appât observe.title.content.catchFateLonglines=Gestion des devenirs capture observe.title.content.country=Gestion des pays @@ -2249,8 +2249,8 @@ observe.tree.activityLongline=Activités observe.tree.activityLonglineDto.unsaved=Nouvelle activité observe.tree.activitySeine=Activités observe.tree.activitySeineDto.unsaved=Nouvelle activité -observe.tree.baitHaulingStatus=Status de l'appât au virage -observe.tree.baitSettingStatus=Status de l'appât au filage +observe.tree.baitHaulingStatus=Statut de l'appât au virage +observe.tree.baitSettingStatus=Statut de l'appât au filage observe.tree.baitType=Type d'appât observe.tree.catchFateLongline=Devenir capture observe.tree.catchLongline=Captures @@ -2266,7 +2266,7 @@ observe.tree.gearCaracteristicType=Type de caractéristique d'équipement observe.tree.gearUseFeaturesLongline=Équipements observe.tree.gearUseFeaturesSeine=Équipements observe.tree.harbour=Port -observe.tree.healthness=Status de la capture +observe.tree.healthness=Statuts de la capture observe.tree.hookPosition=Position du hameçon observe.tree.hookSize=Taille d'hameçon observe.tree.hookType=Type d'hameçon -- 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/7610 in repository observe. See http://git.codelutin.com/observe.git commit d55451223ebafa6c5e8a7babb70a1373cb45751b Author: Kevin Morin <morin@codelutin.com> Date: Thu Oct 15 10:43:00 2015 +0200 correction du ReferentielListRenderer pour grises les lignes désactivées quand les objets sont des referencedto (refs #7610) --- .../observe/ui/content/ContentUIInitializer.java | 26 +++++++++++++--------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIInitializer.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIInitializer.java index 44d811d..579f276 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIInitializer.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIInitializer.java @@ -32,6 +32,7 @@ import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.ReferenceSetDto; import fr.ird.observe.services.dto.constants.ReferenceStatus; import fr.ird.observe.services.dto.referential.ReferentialDto; +import fr.ird.observe.services.dto.referential.ReferentialDtos; import fr.ird.observe.ui.UIHelper; import fr.ird.observe.ui.actions.shared.AbstractUIAction; import fr.ird.observe.ui.util.BooleanEditor; @@ -1011,27 +1012,32 @@ public class ContentUIInitializer<E extends IdDto, UI extends ObserveContentUI<E normalColor = comp.getForeground(); } - String tip = ((JLabel) comp).getText(); + String tip = null; // par defaut, on utilise la couleur normale Color col = normalColor; if (value != null && - value instanceof ReferentialDto) { + (value instanceof ReferentialDto || value instanceof ReferenceDto)) { - ReferentialDto e = (ReferentialDto) value; - ReferenceStatus status = e.getStatus(); + ReferenceStatus status = null; + + if (value instanceof ReferentialDto) { + ReferentialDto e = (ReferentialDto) value; + status = e.getStatus(); + + } else { + ReferenceDto e = (ReferenceDto) value; + if (e.getPropertyNames().contains(ReferentialDto.PROPERTY_STATUS)) { + status = (ReferenceStatus) e.getPropertyValue(ReferentialDto.PROPERTY_STATUS); + } + } if (status == ReferenceStatus.disabled) { // l'entite est desactivee // on la grise pour bien la differencier col = disableColor; - tip = t("observe.common.obsolete.entity", tip); - - } else { - tip = null; + tip = t("observe.common.obsolete.entity", ((JLabel) comp).getText()); } - } else { - tip = null; } comp.setForeground(col); comp.setToolTipText(tip); -- 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/7610 in repository observe. See http://git.codelutin.com/observe.git commit 43decc9d8e2dc6be17abe77c9e5e0caaf6324d92 Author: Kevin Morin <morin@codelutin.com> Date: Thu Oct 15 10:44:43 2015 +0200 filterReferentialListByStatus dans les combo --- .../src/main/java/fr/ird/observe/ui/content/ContentUIInitializer.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIInitializer.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIInitializer.java index 579f276..e699d43 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIInitializer.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIInitializer.java @@ -1079,8 +1079,7 @@ public class ContentUIInitializer<E extends IdDto, UI extends ObserveContentUI<E "], size : " + newValue.size()); } //TC-20100208 : on ne veut pas voir les elements du referentiel non actif - //FIXME -// ReferenceEntities.filterReferentielListByStatus(newValue); + ReferentialDtos.filterReferentialListByStatus(newValue); E selectedItem = (E) comboBox.getSelectedItem(); -- 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/7610 in repository observe. See http://git.codelutin.com/observe.git commit ee984be242987c6a65b1f66c42281b3bc64fda98 Author: Kevin Morin <morin@codelutin.com> Date: Thu Oct 15 11:17:06 2015 +0200 correction du decorateur de referencedto pour que le tri fonctionne (refs #7610) --- .../ui/util/decorator/ReferenceDecorator.java | 43 +++++++++++++++------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/ReferenceDecorator.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/ReferenceDecorator.java index 480a2e8..224e407 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/ReferenceDecorator.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/ReferenceDecorator.java @@ -1,11 +1,8 @@ package fr.ird.observe.ui.util.decorator; -import com.google.common.collect.ImmutableList; import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.referential.ReferentialDto; - -import java.util.HashMap; -import java.util.Map; +import org.apache.commons.jxpath.JXPathContext; import static org.nuiton.i18n.I18n.t; @@ -19,18 +16,36 @@ public class ReferenceDecorator extends ObserveDecorator<ReferenceDto> implement } @Override - public String toString(Object bean) { - if (bean instanceof ReferenceDto) { - ReferenceDto ref = (ReferenceDto) bean; - Map map = new HashMap<>(); - ImmutableList<String> propertyNames = ref.getPropertyNames(); - for (String propertyName : propertyNames) { - Object value = ((ReferenceDto) bean).getPropertyValue(propertyName); - map.put(propertyName, value); + protected Comparable<Comparable<?>> getTokenValue(JXPathContext jxcontext, String token) { + + // assume all values are comparable + Comparable<Comparable<?>> value; + + Object contextBean = jxcontext.getContextBean(); + + if (contextBean instanceof ReferenceDto) { + + ReferenceDto referenceBean = (ReferenceDto) contextBean; + + + if (referenceBean.getPropertyNames().contains(token)) { + + value = (Comparable<Comparable<?>>) referenceBean.getPropertyValue(token); + + if (value == null) { + value = (Comparable<Comparable<?>>) getDefaultNullValue(token); + } + + } else { + value = (Comparable<Comparable<?>>) getDefaultUndefinedValue(token); } - bean = map; + + } else { + value = super.getTokenValue(jxcontext, token); } - return super.toString(bean); + + return value; + } @Override -- 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/7610 in repository observe. See http://git.codelutin.com/observe.git commit 06f31303d6f789a479258c6ab850fbffd80174ac Author: Kevin Morin <morin@codelutin.com> Date: Thu Oct 15 14:06:25 2015 +0200 correction du decorateur de referencedto pour le cas où des tokens sont des referencedtos (refs #7610) --- .../java/fr/ird/observe/ui/DecoratorService.java | 2 +- .../ui/util/decorator/ReferenceDecorator.java | 31 +++++++++++++++++----- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/DecoratorService.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/DecoratorService.java index d63d690..997181a 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/DecoratorService.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/DecoratorService.java @@ -559,7 +559,7 @@ public class DecoratorService extends DecoratorProvider { // LengthWeightParameter decorator registerDecorator(new LengthWeightParameterDecorator(libelle)); registerReferenceDtoDecorator(LengthWeightParameterDto.class, - "${gender}$s##${ocean/" + libelle + "}$s##${species/scientificLabel}$s##" + + "${sex/label}$s##${ocean/label}$s##${species/scientificLabel}$s##" + t("observe.common.lengthWeightFormula") + " ${lengthWeightFormula}$s"); // gps decorators diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/ReferenceDecorator.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/ReferenceDecorator.java index 224e407..62926af 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/ReferenceDecorator.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/ReferenceDecorator.java @@ -4,6 +4,8 @@ import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.referential.ReferentialDto; import org.apache.commons.jxpath.JXPathContext; +import java.io.Serializable; + import static org.nuiton.i18n.I18n.t; /** @@ -19,7 +21,7 @@ public class ReferenceDecorator extends ObserveDecorator<ReferenceDto> implement protected Comparable<Comparable<?>> getTokenValue(JXPathContext jxcontext, String token) { // assume all values are comparable - Comparable<Comparable<?>> value; + Comparable<Comparable<?>> value = null; Object contextBean = jxcontext.getContextBean(); @@ -27,17 +29,32 @@ public class ReferenceDecorator extends ObserveDecorator<ReferenceDto> implement ReferenceDto referenceBean = (ReferenceDto) contextBean; + String[] tokens = token.split("/"); + + for (int i = 0 ; i < tokens.length - 1 ; i++) { + + if (referenceBean.getPropertyNames().contains(tokens[i])) { + + Serializable propertyValue = referenceBean.getPropertyValue(tokens[i]); + + if (propertyValue == null || !(propertyValue instanceof ReferenceDto)) { - if (referenceBean.getPropertyNames().contains(token)) { + return (Comparable<Comparable<?>>) getDefaultUndefinedValue(token); - value = (Comparable<Comparable<?>>) referenceBean.getPropertyValue(token); + } - if (value == null) { - value = (Comparable<Comparable<?>>) getDefaultNullValue(token); + referenceBean = (ReferenceDto) propertyValue; } + } + + String lastToken = tokens[tokens.length - 1]; + if (referenceBean.getPropertyNames().contains(lastToken)) { + value = (Comparable<Comparable<?>>) referenceBean.getPropertyValue(lastToken); + } + - } else { - value = (Comparable<Comparable<?>>) getDefaultUndefinedValue(token); + if (value == null) { + value = (Comparable<Comparable<?>>) getDefaultNullValue(tokens[0]); } } else { -- 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/7610 in repository observe. See http://git.codelutin.com/observe.git commit 49a44e8bc818b7d0214cf7a838b0e54687ca3f6b Author: Kevin Morin <morin@codelutin.com> Date: Thu Oct 15 14:45:07 2015 +0200 déplacement de la clé i18n de referencestatus dans le dto plutôt que dans l'entité (refs #7610) --- .../entities/constants/ReferenceStatus.java | 22 ++-------------------- .../services/dto/constants/ReferenceStatus.java | 22 ++++++++++++++++++++-- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/constants/ReferenceStatus.java b/observe-entities/src/main/java/fr/ird/observe/entities/constants/ReferenceStatus.java index b9898e6..37e1683 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/constants/ReferenceStatus.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/constants/ReferenceStatus.java @@ -21,9 +21,6 @@ */ package fr.ird.observe.entities.constants; -import static org.nuiton.i18n.I18n.n; -import static org.nuiton.i18n.I18n.t; - /** * Une énumération pour caractériser les valeurs des status d'une entité du * référentiel @@ -34,24 +31,9 @@ import static org.nuiton.i18n.I18n.t; public enum ReferenceStatus { /** status desactive */ - disabled(n("observe.common.reference.status.disabled")), + disabled, /** status active */ - enabled(n("observe.common.reference.status.enabled")); - - private String i18nKey; - - ReferenceStatus(String i18nKey) { - this.i18nKey = i18nKey; - } - - public String getI18nKey() { - return i18nKey; - } - - @Override - public String toString() { - return t(i18nKey); - } + enabled } diff --git a/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/ReferenceStatus.java b/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/ReferenceStatus.java index dbc6eef..166a458 100644 --- a/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/ReferenceStatus.java +++ b/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/ReferenceStatus.java @@ -22,6 +22,9 @@ package fr.ird.observe.services.dto.constants; * #L% */ +import static org.nuiton.i18n.I18n.n; +import static org.nuiton.i18n.I18n.t; + /** * Une énumération pour caractériser les valeurs des status d'une entité du * référentiel @@ -32,9 +35,24 @@ package fr.ird.observe.services.dto.constants; public enum ReferenceStatus { /** status desactive */ - disabled, + disabled(n("observe.common.reference.status.disabled")), /** status active */ - enabled; + enabled(n("observe.common.reference.status.enabled")); + + private String i18nKey; + + ReferenceStatus(String i18nKey) { + this.i18nKey = i18nKey; + } + + public String getI18nKey() { + return i18nKey; + } + + @Override + public String toString() { + return t(i18nKey); + } } -- 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/7610 in repository observe. See http://git.codelutin.com/observe.git commit e74f1f40bfbf149a49f741f58a05a3d3fb779f8d Author: Kevin Morin <morin@codelutin.com> Date: Thu Oct 15 17:44:21 2015 +0200 modification des decorateurs pour aller chercher en profondeur les attributs des referencedto qui sont eux même attributs (exemple de LengthWeightParameterDto : ocean est un attribut de type referencedto, il faut qu'on aille chercher le label) (refs #7610) --- .../java/fr/ird/observe/ui/DecoratorService.java | 297 +++++++++++---------- .../ui/content/ref/ContentReferenceUIHandler.java | 20 +- .../decorator/LengthWeightParameterDecorator.java | 14 +- .../ui/util/decorator/NonTargetCatchDecorator.java | 9 +- .../util/decorator/NonTargetLengthDecorator.java | 9 +- .../decorator/ObjectObservedSpeciesDecorator.java | 9 +- .../ui/util/decorator/ObserveDecorator.java | 56 +++- .../ui/util/decorator/ReferenceDecorator.java | 26 +- .../ui/util/decorator/SpeciesDecorator.java | 9 +- .../ui/util/decorator/TripLonglineDecorator.java | 4 +- .../ui/util/decorator/TripSeineDecorator.java | 4 +- 11 files changed, 246 insertions(+), 211 deletions(-) diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/DecoratorService.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/DecoratorService.java index 997181a..6e4d744 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/DecoratorService.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/DecoratorService.java @@ -46,6 +46,7 @@ import fr.ird.observe.services.dto.referential.OceanDto; import fr.ird.observe.services.dto.referential.OrganismDto; import fr.ird.observe.services.dto.referential.PersonDto; import fr.ird.observe.services.dto.referential.ProgramDto; +import fr.ird.observe.services.dto.referential.ReferentialDto; import fr.ird.observe.services.dto.referential.SexDto; import fr.ird.observe.services.dto.referential.SpeciesDto; import fr.ird.observe.services.dto.referential.SpeciesGroupDto; @@ -96,6 +97,7 @@ import fr.ird.observe.services.dto.referential.seine.WeightCategoryDto; import fr.ird.observe.services.dto.referential.seine.WindDto; import fr.ird.observe.services.dto.seine.ActivitySeineDto; import fr.ird.observe.services.dto.seine.FloatingObjectDto; +import fr.ird.observe.services.dto.seine.GearUseFeaturesMeasurementSeineDto; import fr.ird.observe.services.dto.seine.ObjectSchoolEstimateDto; import fr.ird.observe.services.dto.seine.RouteDto; import fr.ird.observe.services.dto.seine.SchoolEstimateDto; @@ -108,6 +110,7 @@ import fr.ird.observe.ui.util.decorator.LengthWeightParameterDecorator; import fr.ird.observe.ui.util.decorator.NonTargetCatchDecorator; import fr.ird.observe.ui.util.decorator.NonTargetLengthDecorator; import fr.ird.observe.ui.util.decorator.ObjectObservedSpeciesDecorator; +import fr.ird.observe.ui.util.decorator.ObserveDecorator; import fr.ird.observe.ui.util.decorator.ReferenceDecorator; import fr.ird.observe.ui.util.decorator.SpeciesDecorator; import fr.ird.observe.ui.util.decorator.TripLonglineDecorator; @@ -392,6 +395,8 @@ public class DecoratorService extends DecoratorProvider { n("observe.common.branchlineLength"); n("observe.common.tracelineLength"); + n("observe.common.gearUseFeaturesMeasurementSeine"); + } @Override @@ -405,191 +410,211 @@ public class DecoratorService extends DecoratorProvider { Locale locale = referentialLocale.getLocale(); String libelle = referentialLocale.getLibelle(); - registerJXPathDecorator(ProgramDto.class, - t("observe.common.program") + - " ${" + libelle + "}$s"); - registerReferenceDtoDecorator(ProgramDto.class, t("observe.common.program") + " ${label}$s"); - registerJXPathDecorator(RouteDto.class, - "${date}$td/%1$tm/%1$tY"); + registerReferenceDtoDecorator(ProgramDto.class, + t("observe.common.program") + " ${" + libelle + "}$s", + t("observe.common.program") + " ${label}$s"); registerReferenceDtoDecorator(RouteDto.class, "${date}$td/%1$tm/%1$tY"); - registerMultiJXPathDecorator( - ActivitySeineDto.class, - "${time}$tH:%1$tM##${vesselActivitySeine/" + libelle + "}$s", - "##", " - "); - registerReferenceDtoDecorator(ActivitySeineDto.class, "${time}$tH:%1$tM##${vesselActivitySeine}$s"); - registerMultiJXPathDecorator( - ActivityLonglineDto.class, - "${timeStamp}$td/%1$tm/%1$tY %1$tH:%1$tM##${vesselActivityLongline/" + libelle + "}$s", - "##", " - "); + registerReferenceDtoDecorator(ActivitySeineDto.class, + "${time}$tH:%1$tM##${vesselActivitySeine/label}$s", + "${time}$tH:%1$tM##${vesselActivitySeine}$s", + " - "); registerReferenceDtoDecorator(ActivityLonglineDto.class, - "${timeStamp}$td/%1$tm/%1$tY %1$tH:%1$tM##${vesselActivityLongline}$s"); - registerMultiJXPathDecorator(PersonDto.class, "${lastName}$s##${firstName}$s", "##", " "); + "${timeStamp}$td/%1$tm/%1$tY %1$tH:%1$tM##${vesselActivityLongline/label}$s", + "${timeStamp}$td/%1$tm/%1$tY %1$tH:%1$tM##${vesselActivityLongline}$s", + " - "); registerReferenceDtoDecorator(PersonDto.class, "${lastName}$s##${firstName}$s"); - registerDefaultReferenceDtoDecorator(SexDto.class); + registerReferentialReferenceDtoDecorator(SexDto.class, libelle); //FIXME Use startDate - endDate - registerDefaultReferenceDtoDecorator(FpaZoneDto.class); - registerDefaultReferenceDtoDecorator(OceanDto.class); - registerDefaultReferenceDtoDecorator(DetectionModeDto.class); - registerDefaultReferenceDtoDecorator(VesselDto.class); - registerDefaultReferenceDtoDecorator(CountryDto.class); + registerReferentialReferenceDtoDecorator(FpaZoneDto.class, libelle); + registerReferentialReferenceDtoDecorator(OceanDto.class, libelle); + registerReferentialReferenceDtoDecorator(DetectionModeDto.class, libelle); + registerReferentialReferenceDtoDecorator(VesselDto.class, libelle); + registerReferentialReferenceDtoDecorator(CountryDto.class, libelle); registerReferenceDtoDecorator(VesselSizeCategoryDto.class, "${code}$s##${gaugeLabel}$s##${capacityLabel}$s"); - registerDefaultReferenceDtoDecorator(VesselTypeDto.class); - registerDefaultReferenceDtoDecorator(VesselActivitySeineDto.class); - registerDefaultReferenceDtoDecorator(SurroundingActivityDto.class); - registerDefaultReferenceDtoDecorator(ObservedSystemDto.class); + registerReferentialReferenceDtoDecorator(VesselTypeDto.class, libelle); + registerReferentialReferenceDtoDecorator(VesselActivitySeineDto.class, libelle); + registerReferentialReferenceDtoDecorator(SurroundingActivityDto.class, libelle); + registerReferentialReferenceDtoDecorator(ObservedSystemDto.class, libelle); registerReferenceDtoDecorator(WindDto.class, "${code}$s##${label}$s##${speedRange}$s"); - registerMultiJXPathDecorator( - FloatingObjectDto.class, - "DCP ${objectType/" + libelle + "}$s", "##", " - "); - registerReferenceDtoDecorator(FloatingObjectDto.class, "DCP ${objectType}$s"); + registerReferenceDtoDecorator(FloatingObjectDto.class, "DCP ${objectType/" + libelle + "}$s", "DCP ${objectType}$s", " - "); //FIXME Remove this - registerJXPathDecorator(SetSeineDto.class, t("observe.common.setSeine")); + registerObserveDecorator(SetSeineDto.class, t("observe.common.setSeine")); //FIXME Remove this - registerJXPathDecorator(SetLonglineDto.class, t("observe.common.setLongline")); - registerDefaultReferenceDtoDecorator(ObjectFateDto.class); - registerDefaultReferenceDtoDecorator(OrganismDto.class); - registerDefaultReferenceDtoDecorator(ObjectTypeDto.class); - registerDefaultReferenceDtoDecorator(ObjectOperationDto.class); - registerDefaultReferenceDtoDecorator(SpeciesStatusDto.class); - registerDefaultReferenceDtoDecorator(TransmittingBuoyTypeDto.class); - registerDefaultReferenceDtoDecorator(TransmittingBuoyOperationDto.class); - registerDefaultReferenceDtoDecorator(ReasonForNullSetDto.class); - registerDefaultReferenceDtoDecorator(ReasonForNoFishingDto.class); - registerDefaultReferenceDtoDecorator(WeightCategoryDto.class); - registerDefaultReferenceDtoDecorator(ReasonForDiscardDto.class); - registerDefaultReferenceDtoDecorator(SpeciesFateDto.class); - registerDefaultReferenceDtoDecorator(SpeciesGroupDto.class); - registerDefaultReferenceDtoDecorator(SpeciesListDto.class); - - registerDefaultReferenceDtoDecorator(BaitHaulingStatusDto.class); - registerDefaultReferenceDtoDecorator(BaitSettingStatusDto.class); - registerDefaultReferenceDtoDecorator(BaitTypeDto.class); - registerDefaultReferenceDtoDecorator(CatchFateLonglineDto.class); - registerDefaultReferenceDtoDecorator(EncounterTypeDto.class); - registerDefaultReferenceDtoDecorator(HealthnessDto.class); - registerDefaultReferenceDtoDecorator(HookPositionDto.class); - registerDefaultReferenceDtoDecorator(HookSizeDto.class); - registerDefaultReferenceDtoDecorator(HookTypeDto.class); - registerDefaultReferenceDtoDecorator(ItemVerticalPositionDto.class); - registerDefaultReferenceDtoDecorator(ItemHorizontalPositionDto.class); - registerDefaultReferenceDtoDecorator(LightsticksColorDto.class); - registerDefaultReferenceDtoDecorator(LightsticksTypeDto.class); - registerDefaultReferenceDtoDecorator(LineTypeDto.class); - registerDefaultReferenceDtoDecorator(MaturityStatusDto.class); - registerDefaultReferenceDtoDecorator(MitigationTypeDto.class); + registerObserveDecorator(SetLonglineDto.class, t("observe.common.setLongline")); + registerReferentialReferenceDtoDecorator(ObjectFateDto.class, libelle); + registerReferentialReferenceDtoDecorator(OrganismDto.class, libelle); + registerReferentialReferenceDtoDecorator(ObjectTypeDto.class, libelle); + registerReferentialReferenceDtoDecorator(ObjectOperationDto.class, libelle); + registerReferentialReferenceDtoDecorator(SpeciesStatusDto.class, libelle); + registerReferentialReferenceDtoDecorator(TransmittingBuoyTypeDto.class, libelle); + registerReferentialReferenceDtoDecorator(TransmittingBuoyOperationDto.class, libelle); + registerReferentialReferenceDtoDecorator(ReasonForNullSetDto.class, libelle); + registerReferentialReferenceDtoDecorator(ReasonForNoFishingDto.class, libelle); + registerReferentialReferenceDtoDecorator(WeightCategoryDto.class, libelle); + registerReferentialReferenceDtoDecorator(ReasonForDiscardDto.class, libelle); + registerReferentialReferenceDtoDecorator(SpeciesFateDto.class, libelle); + registerReferentialReferenceDtoDecorator(SpeciesGroupDto.class, libelle); + registerReferentialReferenceDtoDecorator(SpeciesListDto.class, libelle); + + registerReferentialReferenceDtoDecorator(BaitHaulingStatusDto.class, libelle); + registerReferentialReferenceDtoDecorator(BaitSettingStatusDto.class, libelle); + registerReferentialReferenceDtoDecorator(BaitTypeDto.class, libelle); + registerReferentialReferenceDtoDecorator(CatchFateLonglineDto.class, libelle); + registerReferentialReferenceDtoDecorator(EncounterTypeDto.class, libelle); + registerReferentialReferenceDtoDecorator(HealthnessDto.class, libelle); + registerReferentialReferenceDtoDecorator(HookPositionDto.class, libelle); + registerReferentialReferenceDtoDecorator(HookSizeDto.class, libelle); + registerReferentialReferenceDtoDecorator(HookTypeDto.class, libelle); + registerReferentialReferenceDtoDecorator(ItemVerticalPositionDto.class, libelle); + registerReferentialReferenceDtoDecorator(ItemHorizontalPositionDto.class, libelle); + registerReferentialReferenceDtoDecorator(LightsticksColorDto.class, libelle); + registerReferentialReferenceDtoDecorator(LightsticksTypeDto.class, libelle); + registerReferentialReferenceDtoDecorator(LineTypeDto.class, libelle); + registerReferentialReferenceDtoDecorator(MaturityStatusDto.class, libelle); + registerReferentialReferenceDtoDecorator(MitigationTypeDto.class, libelle); registerReferenceDtoDecorator(SensorBrandDto.class, "${code}$s##${brandName}$s"); - registerDefaultReferenceDtoDecorator(SensorDataFormatDto.class); - registerDefaultReferenceDtoDecorator(SensorTypeDto.class); - registerDefaultReferenceDtoDecorator(SettingShapeDto.class); - registerDefaultReferenceDtoDecorator(SizeMeasureTypeDto.class); - registerDefaultReferenceDtoDecorator(StomacFullnessDto.class); - registerDefaultReferenceDtoDecorator(TripTypeDto.class); - registerDefaultReferenceDtoDecorator(VesselActivityLonglineDto.class); - registerDefaultReferenceDtoDecorator(WeightMeasureTypeDto.class); - registerDefaultReferenceDtoDecorator(GearCaracteristicTypeDto.class); - registerDefaultReferenceDtoDecorator(GearCaracteristicDto.class); - registerDefaultReferenceDtoDecorator(GearDto.class); + registerReferentialReferenceDtoDecorator(SensorDataFormatDto.class, libelle); + registerReferentialReferenceDtoDecorator(SensorTypeDto.class, libelle); + registerReferentialReferenceDtoDecorator(SettingShapeDto.class, libelle); + registerReferentialReferenceDtoDecorator(SizeMeasureTypeDto.class, libelle); + registerReferentialReferenceDtoDecorator(StomacFullnessDto.class, libelle); + registerReferentialReferenceDtoDecorator(TripTypeDto.class, libelle); + registerReferentialReferenceDtoDecorator(VesselActivityLonglineDto.class, libelle); + registerReferentialReferenceDtoDecorator(WeightMeasureTypeDto.class, libelle); + registerReferentialReferenceDtoDecorator(GearCaracteristicTypeDto.class, libelle); + registerReferentialReferenceDtoDecorator(GearCaracteristicDto.class, libelle); + registerReferentialReferenceDtoDecorator(GearDto.class, libelle); registerReferenceDtoDecorator(HarbourDto.class, "${code}$s##${name}$s##${locode}$s"); - registerMultiJXPathDecorator( - ObjectSchoolEstimateDto.class, - "${species/scientificLabel}$s##${weight}$d", "##", - " - "); - registerMultiJXPathDecorator( - SchoolEstimateDto.class, - "${species/scientificLabel}$s##${weight}$d##${meanWeight}$d", "##", " - "); - registerMultiJXPathDecorator( + registerObserveDecorator(ObjectSchoolEstimateDto.class, "${species/scientificLabel}$s##${weight}$d"); + registerObserveDecorator(SchoolEstimateDto.class, "${species/scientificLabel}$s##${weight}$d##${meanWeight}$d"); + registerObserveDecorator( TargetCatchDto.class, - "${weightCategory/species/scientificLabel}$s##${weightCategory/" + libelle + "}$s##${weight}$f", "##", " - "); - registerMultiJXPathDecorator( + "${weightCategory/species/scientificLabel}$s##${weightCategory/label}$s##${weight}$f"); + registerObserveDecorator( TargetLengthDto.class, - "${species/scientificLabel}$s##${length}$f##${count}$d", "##", " - "); + "${species/scientificLabel}$s##${length}$f##${count}$d"); - registerMultiJXPathDecorator( + registerObserveDecorator( TransmittingBuoyDto.class, - "${transmittingBuoyType/" + libelle + "}$s##${transmittingBuoyOperation/" + libelle + "}$s##${code}$s", "##", - " - "); + "${transmittingBuoyType/label}$s##${transmittingBuoyOperation/label}$s##${code}$s"); String settingIdentifier = l(locale, "observe.common.settingIdentifier"); String haulingIdentifier = l(locale, "observe.common.haulingIdentifier"); - registerMultiJXPathDecorator( + registerObserveDecorator( SectionDto.class, - " ${settingIdentifier}$s (" + settingIdentifier + ")##${haulingIdentifier}$s (" + haulingIdentifier + ")", "##", " - "); + " ${settingIdentifier}$s (" + settingIdentifier + ")##${haulingIdentifier}$s (" + haulingIdentifier + ")"); - registerMultiJXPathDecorator( + registerObserveDecorator( BasketDto.class, - " ${settingIdentifier}$s (" + settingIdentifier + ")##${haulingIdentifier}$s (" + haulingIdentifier + ")", "##", " - "); + " ${settingIdentifier}$s (" + settingIdentifier + ")##${haulingIdentifier}$s (" + haulingIdentifier + ")"); - registerMultiJXPathDecorator( + registerObserveDecorator( BranchlineDto.class, - " ${settingIdentifier}$s (" + settingIdentifier + ")##${haulingIdentifier}$s (" + haulingIdentifier + ")", "##", " - "); + " ${settingIdentifier}$s (" + settingIdentifier + ")##${haulingIdentifier}$s (" + haulingIdentifier + ")"); - registerJXPathDecorator(SectionDto.class, HAULING_IDENTIFIER, "${haulingIdentifier}$s"); - registerJXPathDecorator(BasketDto.class, HAULING_IDENTIFIER, "${haulingIdentifier}$s"); - registerJXPathDecorator(BranchlineDto.class, HAULING_IDENTIFIER, "${haulingIdentifier}$s"); + registerObserveDecorator(HAULING_IDENTIFIER, SectionDto.class, "${haulingIdentifier}$s"); + registerObserveDecorator(HAULING_IDENTIFIER, BasketDto.class, "${haulingIdentifier}$s"); + registerObserveDecorator(HAULING_IDENTIFIER, BranchlineDto.class, "${haulingIdentifier}$s"); // TripSeine decorator - registerDecorator(new TripSeineDecorator(libelle)); - registerReferenceDtoDecorator(TripSeineDto.class, - "${startDate}$td/%1$tm/%1$tY##${endDate}$td/%2$tm/%2$tY##${vessel}$s##${observer}$s"); - + registerDecorator(new TripSeineDecorator()); + registerDecorator(TripSeineDto.class.getSimpleName(), + new ReferenceDecorator("${startDate}$td/%1$tm/%1$tY##${endDate}$td/%2$tm/%2$tY##${vessel}$s##${observer}$s")); // TripLongline decorator - registerDecorator(new TripLonglineDecorator(libelle)); - registerReferenceDtoDecorator(TripLonglineDto.class, - "${startDate}$td/%1$tm/%1$tY##${endDate}$td/%2$tm/%2$tY##${vessel}$s##${observer}$s"); + registerDecorator(new TripLonglineDecorator()); + registerDecorator(TripLonglineDto.class.getSimpleName(), + new ReferenceDecorator("${startDate}$td/%1$tm/%1$tY##${endDate}$td/%2$tm/%2$tY##${vessel}$s##${observer}$s")); String oldCode = l(locale, "observe.common.oldCode3L"); // Species decorator - registerDecorator(new SpeciesDecorator(libelle, oldCode)); - registerReferenceDtoDecorator(SpeciesDto.class, - "${faoCode}$s##${scientificLabel}$s##" + oldCode + " ${homeId}$s"); + registerDecorator(new SpeciesDecorator( oldCode)); + registerDecorator(SpeciesDto.class.getSimpleName(), + new ReferenceDecorator("${faoCode}$s##${scientificLabel}$s##" + oldCode + " ${homeId}$s")); // ObjectObservedSpecies decorator - registerDecorator(new ObjectObservedSpeciesDecorator(libelle)); + registerDecorator(new ObjectObservedSpeciesDecorator()); // NonTargetCatch decorator - registerDecorator(new NonTargetCatchDecorator(libelle)); + registerDecorator(new NonTargetCatchDecorator()); // NonTargetLength decorator - registerDecorator(new NonTargetLengthDecorator(libelle)); + registerDecorator(new NonTargetLengthDecorator()); // LengthWeightParameter decorator - registerDecorator(new LengthWeightParameterDecorator(libelle)); - registerReferenceDtoDecorator(LengthWeightParameterDto.class, - "${sex/label}$s##${ocean/label}$s##${species/scientificLabel}$s##" + - t("observe.common.lengthWeightFormula") + " ${lengthWeightFormula}$s"); + registerDecorator(new LengthWeightParameterDecorator()); + registerDecorator(LengthWeightParameterDto.class.getSimpleName(), + new ReferenceDecorator("${sex/label}$s##${ocean/label}$s##${species/scientificLabel}$s##" + + t("observe.common.lengthWeightFormula") + " ${lengthWeightFormula}$s")); // gps decorators - registerJXPathDecorator(ActivitySeineDto.class, - "activity-gps", - t("observe.common.gps.activity")); - registerJXPathDecorator(GPSPoint.class, - "gpsPoint-gps", - t("observe.common.gps.gpsPoint")); - registerJXPathDecorator(GPSPointInterval.class, - "gpsPointInterval-gps", - t("observe.common.gps.gpsPointInterval")); - - registerMultiJXPathDecorator(GPSPoint.class, - "${time}$td/%1$tm/%1$tY %1$tH:%1$tM##${latitude}$s##${longitude}$s", - "##", " "); - - registerMultiJXPathDecorator(SectionTemplate.class, "${id}$s##${floatlineLengths}$s", "##", " "); - - registerJXPathDecorator(CatchLonglineDto.class, "${homeId}$s"); - registerJXPathDecorator(TdrDto.class, "${homeId}$s"); + registerObserveDecorator("activity-gps", + ActivitySeineDto.class, + t("observe.common.gps.activity")); + registerObserveDecorator("gpsPoint-gps", + GPSPoint.class, + t("observe.common.gps.gpsPoint")); + registerObserveDecorator(GPSPointInterval.class, + "gpsPointInterval-gps", + t("observe.common.gps.gpsPointInterval")); + + registerObserveDecorator(GPSPoint.class, + "${time}$td/%1$tm/%1$tY %1$tH:%1$tM##${latitude}$s##${longitude}$s", + " "); + + registerObserveDecorator(SectionTemplate.class, "${id}$s##${floatlineLengths}$s", " "); + + registerObserveDecorator(CatchLonglineDto.class, "${homeId}$s"); + registerObserveDecorator(TdrDto.class, "${homeId}$s"); + + //FIXME how to decorate ? + registerObserveDecorator(GearUseFeaturesMeasurementSeineDto.class, "${id}$s"); } - protected <T extends IdDto> void registerDefaultReferenceDtoDecorator(Class<T> referenceType) { - registerReferenceDtoDecorator(referenceType, "${code}$s##${label}$s"); + protected <T extends ReferentialDto> void registerReferentialReferenceDtoDecorator(Class<T> referenceType, + String libelle) { + registerDecorator(referenceType.getSimpleName(), new ReferenceDecorator("${code}$s##${label}$s")); + registerObserveDecorator(referenceType, "${code}$s##${" + libelle + "}$s", " "); } + protected <T extends IdDto> void registerReferenceDtoDecorator(Class<T> referenceType, String expression) { - registerDecorator(referenceType.getSimpleName(), new ReferenceDecorator(expression)); + registerReferenceDtoDecorator(referenceType, expression, expression); + } + + protected <T extends IdDto> void registerReferenceDtoDecorator(Class<T> referenceType, + String expression, + String referenceExpression) { + registerReferenceDtoDecorator(referenceType, expression, referenceExpression, " "); + } + + protected <T extends IdDto> void registerReferenceDtoDecorator(Class<T> referenceType, + String expression, + String referenceExpression, + String separator) { + registerDecorator(referenceType.getSimpleName(), new ReferenceDecorator(referenceExpression)); + registerObserveDecorator(referenceType, expression, separator); + } + + + protected <T> void registerObserveDecorator(Class<T> referenceType, String expression) { + registerDecorator(new ObserveDecorator<>(referenceType, expression)); + } + + protected <T> void registerObserveDecorator(Class<T> referenceType, String expression, String separator) { + registerDecorator(new ObserveDecorator<>(referenceType, expression, separator)); + } + + protected <T> void registerObserveDecorator(String context, Class<T> referenceType, String expression) { + registerDecorator(context, new ObserveDecorator<>(referenceType, expression)); + } + + protected <T> void registerObserveDecorator(String context, Class<T> referenceType, String expression, String separator) { + registerDecorator(context, new ObserveDecorator<>(referenceType, expression, separator)); } } 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 51ffcab..f09d0d9 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 @@ -52,6 +52,7 @@ import jaxx.runtime.swing.CardLayout2Ext; import jaxx.runtime.swing.ErrorDialogUI; import jaxx.runtime.swing.editor.bean.BeanListHeader; import jaxx.runtime.validator.swing.SwingValidatorUtil; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.decorator.Decorator; @@ -258,10 +259,10 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content String[] columns = new String[nbColumns]; System.arraycopy(naturalIds, 0, columns, 1, naturalIds.length); - columns[0] = Introspector.decapitalize(beanType.getSimpleName()); + columns[0] = StringUtils.removeEnd(Introspector.decapitalize(beanType.getSimpleName()), "Dto"); DecoratorService dService = getDecoratorService(); - Decorator<E> decorator = dService.getDecoratorByType(beanType); + Decorator<ReferenceDto> decorator = dService.getDecoratorByType(ReferenceDto.class, beanType.getSimpleName()); for (ReferenceDto<E> e : entities.getReference()) { @@ -270,7 +271,10 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content data[0] = decorator.toString(e); for (String property : naturalIds) { - Object o = e.getPropertyValue(property); + Object o = null; + if (e.getPropertyNames().contains(property)) { + o = e.getPropertyValue(property); + } if (ContentReferenceUIModel.DEFAULT_PROPERTIES[0].equals(property) && o == null) { // cas special du code à 0, le loador ne retourne pas // de valeur car c'est la valeur par defaut d'un type @@ -390,11 +394,11 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content content.add(new JLabel(bean.getId())); //FIXME -// content.add(new JLabel(t("observe.common.topiaCreateDate"))); -// content.add(new JLabel(bean.getTopiaCreateDate().toString())); -// -// content.add(new JLabel(t("observe.common.topiaVersion"))); -// content.add(new JLabel(bean.getTopiaVersion() + "")); + content.add(new JLabel(t("observe.common.topiaCreateDate"))); + content.add(new JLabel("test")); + + content.add(new JLabel(t("observe.common.topiaVersion"))); + content.add(new JLabel("test")); SpringUtilities.makeCompactGrid(content, 3, 2, 5, 5, 5, 5); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/LengthWeightParameterDecorator.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/LengthWeightParameterDecorator.java index 61916f2..08a5fcf 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/LengthWeightParameterDecorator.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/LengthWeightParameterDecorator.java @@ -36,14 +36,11 @@ public class LengthWeightParameterDecorator extends ObserveDecorator<LengthWeigh private static final long serialVersionUID = 1L; - private final String libelle; - - public LengthWeightParameterDecorator(String libelle) throws IllegalArgumentException, NullPointerException { + public LengthWeightParameterDecorator() throws IllegalArgumentException, NullPointerException { super(LengthWeightParameterDto.class, - "${gender}$s##${ocean/" + libelle + "}$s##${species/scientificLabel}$s##" + + "${sex}$s##${ocean/label}$s##${species/scientificLabel}$s##" + t("observe.common.lengthWeightFormula") + " ${lengthWeightFormula}$s" ); - this.libelle = libelle; } @SuppressWarnings({"unchecked"}) @@ -64,14 +61,11 @@ public class LengthWeightParameterDecorator extends ObserveDecorator<LengthWeigh value = super.getTokenValue(jxcontext, token); if (token.equals("species/scientificLabel") && "xx".equals(value)) { - value = super.getTokenValue(jxcontext, - "species/" + - libelle); + value = super.getTokenValue(jxcontext, "species/label"); } if (token.equals("sex")) { value = super.getTokenValue(jxcontext, - "sex/" + - libelle); + "sex/label"); value = t("observe.common.sex") + ' ' + value; } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/NonTargetCatchDecorator.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/NonTargetCatchDecorator.java index f7e9e4b..0fde90a 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/NonTargetCatchDecorator.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/NonTargetCatchDecorator.java @@ -34,13 +34,10 @@ public class NonTargetCatchDecorator extends ObserveDecorator<NonTargetCatchDto> private static final long serialVersionUID = 1L; - private final String libelle; - - public NonTargetCatchDecorator(String libelle) { + public NonTargetCatchDecorator() { super(NonTargetCatchDto.class, - "${species/scientificLabel}$s##${speciesFate/" + libelle + "}$s" + "${species/scientificLabel}$s##${speciesFate/label}$s" ); - this.libelle = libelle; } @Override @@ -49,7 +46,7 @@ public class NonTargetCatchDecorator extends ObserveDecorator<NonTargetCatchDto> Comparable<Comparable<?>> value = super.getTokenValue(jxcontext, token); if (token.equals("species/scientificLabel") && "xx".equals(String.valueOf(value))) { - value = super.getTokenValue(jxcontext, "species/" + libelle); + value = super.getTokenValue(jxcontext, "species/label"); } return value; } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/NonTargetLengthDecorator.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/NonTargetLengthDecorator.java index 77c753d..140b737 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/NonTargetLengthDecorator.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/NonTargetLengthDecorator.java @@ -34,13 +34,10 @@ public class NonTargetLengthDecorator extends ObserveDecorator<NonTargetLengthDt private static final long serialVersionUID = 1L; - private final String libelle; - - public NonTargetLengthDecorator(String libelle) throws IllegalArgumentException, NullPointerException { + public NonTargetLengthDecorator() throws IllegalArgumentException, NullPointerException { super(NonTargetLengthDto.class, "${species/scientificLabel}$s##${length}$f##${gender}$s" ); - this.libelle = libelle; } @SuppressWarnings({"unchecked"}) @@ -51,10 +48,10 @@ public class NonTargetLengthDecorator extends ObserveDecorator<NonTargetLengthDt super.getTokenValue(jxcontext, token); if (token.equals("species/scientificLabel") && "xx".equals(value)) { - value = super.getTokenValue(jxcontext, "species/" + libelle); + value = super.getTokenValue(jxcontext, "species/label"); } if ("sex".equals(token)) { - value = super.getTokenValue(jxcontext, "sex/" + libelle); + value = super.getTokenValue(jxcontext, "sex/label"); } return (Comparable<Comparable<?>>) value; } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/ObjectObservedSpeciesDecorator.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/ObjectObservedSpeciesDecorator.java index cba7594..0122e9f 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/ObjectObservedSpeciesDecorator.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/ObjectObservedSpeciesDecorator.java @@ -34,20 +34,17 @@ public class ObjectObservedSpeciesDecorator extends ObserveDecorator<ObjectObser private static final long serialVersionUID = 1L; - private final String libelle; - - public ObjectObservedSpeciesDecorator(String libelle) { + public ObjectObservedSpeciesDecorator() { super(ObjectObservedSpeciesDto.class, - "${species/scientificLabel}$s##${speciesStatus/" + libelle + "}$s##${count}$d" + "${species/scientificLabel}$s##${speciesStatus/label}$s##${count}$d" ); - this.libelle = libelle; } @Override protected Comparable<Comparable<?>> getTokenValue(JXPathContext jxcontext, String token) { Comparable<Comparable<?>> value = super.getTokenValue(jxcontext, token); if (token.equals("species/scientificLabel") && "xx".equals(String.valueOf(value))) { - value = super.getTokenValue(jxcontext, "species/" + libelle); + value = super.getTokenValue(jxcontext, "species/label"); } return value; } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/ObserveDecorator.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/ObserveDecorator.java index 887777f..401495d 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/ObserveDecorator.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/ObserveDecorator.java @@ -21,11 +21,15 @@ */ package fr.ird.observe.ui.util.decorator; +import fr.ird.observe.services.dto.ReferenceDto; import org.apache.commons.jxpath.JXPathContext; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.decorator.MultiJXPathDecorator; +import java.io.Serializable; + import static org.nuiton.i18n.I18n.t; /** @@ -34,7 +38,8 @@ import static org.nuiton.i18n.I18n.t; * @author Tony Chemit - chemit@codelutin.com * @since 2.4 */ -public abstract class ObserveDecorator<E> extends MultiJXPathDecorator<E> implements Cloneable { +public class ObserveDecorator<E> extends MultiJXPathDecorator<E> implements Cloneable { + private static final long serialVersionUID = 1L; /** Logger. */ @@ -44,11 +49,14 @@ public abstract class ObserveDecorator<E> extends MultiJXPathDecorator<E> implem public static final String DEFAULT_SEPARATOR_REPLACEMENT = " - "; - protected ObserveDecorator(Class<E> internalClass, String expression) { + public ObserveDecorator(Class<E> internalClass, String expression) { super(internalClass, expression, DEFAULT_SEPARATOR, DEFAULT_SEPARATOR_REPLACEMENT); } + public ObserveDecorator(Class<E> internalClass, String expression, String separator) { + super(internalClass, expression, DEFAULT_SEPARATOR, separator); + } @Override public final Object clone() throws CloneNotSupportedException { @@ -60,8 +68,22 @@ public abstract class ObserveDecorator<E> extends MultiJXPathDecorator<E> implem String token) { // assume all values are comparable Comparable<Comparable<?>> value; + try { - value = (Comparable<Comparable<?>>) jxcontext.getValue(token); + + String[] tokens = token.split("/"); + + Object value0 = jxcontext.getValue(tokens[0]); + + if (value0 instanceof ReferenceDto) { + + value = getValueFromReferenceDto(tokens, (ReferenceDto) value0, 1); + + } else { + + value = (Comparable<Comparable<?>>) jxcontext.getValue(token); + } + if (value == null) { value = (Comparable<Comparable<?>>) getDefaultNullValue(token); } @@ -73,6 +95,34 @@ public abstract class ObserveDecorator<E> extends MultiJXPathDecorator<E> implem return value; } + protected Comparable<Comparable<?>> getValueFromReferenceDto(String[] tokens, ReferenceDto referenceBean, int startIndex) { + + for (int i = startIndex, max = tokens.length - 1 ; i < max ; i++) { + + if (referenceBean.getPropertyNames().contains(tokens[i])) { + + Serializable propertyValue = referenceBean.getPropertyValue(tokens[i]); + + if (propertyValue == null || !(propertyValue instanceof ReferenceDto)) { + + return (Comparable<Comparable<?>>) getDefaultUndefinedValue(StringUtils.join(tokens, "/")); + + } + + referenceBean = (ReferenceDto) propertyValue; + } + } + + Comparable<Comparable<?>> value = null; + + String lastToken = tokens[tokens.length - 1]; + if (referenceBean.getPropertyNames().contains(lastToken)) { + value = (Comparable<Comparable<?>>) referenceBean.getPropertyValue(lastToken); + } + + return value; + } + protected Comparable<?> getDefaultUndefinedValue(String token) { if (log.isWarnEnabled()) { log.warn("No defined value for token [" + token + "]"); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/ReferenceDecorator.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/ReferenceDecorator.java index 62926af..84443a8 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/ReferenceDecorator.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/ReferenceDecorator.java @@ -4,8 +4,6 @@ import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.referential.ReferentialDto; import org.apache.commons.jxpath.JXPathContext; -import java.io.Serializable; - import static org.nuiton.i18n.I18n.t; /** @@ -27,31 +25,9 @@ public class ReferenceDecorator extends ObserveDecorator<ReferenceDto> implement if (contextBean instanceof ReferenceDto) { - ReferenceDto referenceBean = (ReferenceDto) contextBean; - String[] tokens = token.split("/"); - for (int i = 0 ; i < tokens.length - 1 ; i++) { - - if (referenceBean.getPropertyNames().contains(tokens[i])) { - - Serializable propertyValue = referenceBean.getPropertyValue(tokens[i]); - - if (propertyValue == null || !(propertyValue instanceof ReferenceDto)) { - - return (Comparable<Comparable<?>>) getDefaultUndefinedValue(token); - - } - - referenceBean = (ReferenceDto) propertyValue; - } - } - - String lastToken = tokens[tokens.length - 1]; - if (referenceBean.getPropertyNames().contains(lastToken)) { - value = (Comparable<Comparable<?>>) referenceBean.getPropertyValue(lastToken); - } - + value = getValueFromReferenceDto(tokens, (ReferenceDto) contextBean, 0); if (value == null) { value = (Comparable<Comparable<?>>) getDefaultNullValue(tokens[0]); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/SpeciesDecorator.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/SpeciesDecorator.java index 373bd1d..deaa492 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/SpeciesDecorator.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/SpeciesDecorator.java @@ -36,8 +36,6 @@ public class SpeciesDecorator extends ObserveDecorator<SpeciesDto> { private static final long serialVersionUID = 1L; - private final String libelle; - static { // pour avoir les traduction sur le nom de la propriété @@ -46,16 +44,13 @@ public class SpeciesDecorator extends ObserveDecorator<SpeciesDto> { n("observe.common.species/scientificLabel"); n("observe.common.scientificLabel"); n("observe.common.homeId"); - - } - public SpeciesDecorator(String libelle, String oldCode) { + public SpeciesDecorator(String oldCode) { super(SpeciesDto.class, "${faoCode}$s##${scientificLabel}$s##" + oldCode + " ${homeId}$s" ); - this.libelle = libelle; } @Override @@ -63,7 +58,7 @@ public class SpeciesDecorator extends ObserveDecorator<SpeciesDto> { Comparable<?> value; value = super.getTokenValue(jxcontext, token); if (token.equals(SpeciesDto.PROPERTY_SCIENTIFIC_LABEL) && "xx".equals(value)) { - value = super.getTokenValue(jxcontext, libelle); + value = super.getTokenValue(jxcontext, "label"); } return (Comparable<Comparable<?>>) value; } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/TripLonglineDecorator.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/TripLonglineDecorator.java index 3379b30..8a31565 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/TripLonglineDecorator.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/TripLonglineDecorator.java @@ -33,9 +33,9 @@ public class TripLonglineDecorator extends ObserveDecorator<TripLonglineDto> { private static final long serialVersionUID = 1L; - public TripLonglineDecorator(String libelle) throws IllegalArgumentException, NullPointerException { + public TripLonglineDecorator() throws IllegalArgumentException, NullPointerException { super(TripLonglineDto.class, - "${startDate}$td/%1$tm/%1$tY##${endDate}$td/%2$tm/%2$tY##${vessel/" + libelle + "}$s##${observerLabel}$s" + "${startDate}$td/%1$tm/%1$tY##${endDate}$td/%2$tm/%2$tY##${vessel/label}$s##${observerLabel}$s" ); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/TripSeineDecorator.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/TripSeineDecorator.java index 264ee96..5b61153 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/TripSeineDecorator.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/TripSeineDecorator.java @@ -34,9 +34,9 @@ public class TripSeineDecorator extends ObserveDecorator<TripSeineDto> { private static final long serialVersionUID = 1L; - public TripSeineDecorator(String libelle) throws IllegalArgumentException, NullPointerException { + public TripSeineDecorator() throws IllegalArgumentException, NullPointerException { super(TripSeineDto.class, - "${startDate}$td/%1$tm/%1$tY##${endDate}$td/%2$tm/%2$tY##${vessel/" + libelle + "}$s##${observerLabel}$s" + "${startDate}$td/%1$tm/%1$tY##${endDate}$td/%2$tm/%2$tY##${vessel/label}$s##${observerLabel}$s" ); } -- 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/7610 in repository observe. See http://git.codelutin.com/observe.git commit c9befdad82bb5ef0118896a7078df484b6f32d1d Author: Kevin Morin <morin@codelutin.com> Date: Fri Oct 16 10:50:52 2015 +0200 ajout du programme dans l'arbre après création (refs #7610) --- .../ui/content/ref/ContentReferenceUIHandler.java | 4 +- .../observe-application-swing_en_GB.properties | 1 + .../observe-application-swing_es_ES.properties | 1 + .../observe-application-swing_fr_FR.properties | 1 + .../fr/ird/observe/services/dto/ReferenceDtos.java | 45 ++++++++++++++++++++++ .../services/dto/referential/ProgramDtos.java | 36 +++++++++++++++++ 6 files changed, 86 insertions(+), 2 deletions(-) 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 f09d0d9..a007745 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 @@ -34,6 +34,7 @@ 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.ProgramDtos; import fr.ird.observe.services.dto.referential.ReferentialDto; import fr.ird.observe.services.dto.referential.ReferentialDtos; import fr.ird.observe.services.dto.referential.VesselSizeCategoryDto; @@ -663,8 +664,7 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content // add the program in tree ObserveTreeHelper treeHelper = getTreeHelper(getUi()); - //FIXME -// treeHelper.addProgram((ProgramDto) bean); + treeHelper.addProgram(ProgramDtos.newReferenceDto((ProgramDto) bean)); } return true; diff --git a/observe-application-swing/src/main/resources/i18n/observe-application-swing_en_GB.properties b/observe-application-swing/src/main/resources/i18n/observe-application-swing_en_GB.properties index 96bae25..7d4e572 100644 --- a/observe-application-swing/src/main/resources/i18n/observe-application-swing_en_GB.properties +++ b/observe-application-swing/src/main/resources/i18n/observe-application-swing_en_GB.properties @@ -804,6 +804,7 @@ observe.common.gearCaracteristic= observe.common.gearCaracteristicType= observe.common.gearType=Gear caracteristic type observe.common.gearUseFeaturesLongline= +observe.common.gearUseFeaturesMeasurementSeine= observe.common.gearUseFeaturesSeine= observe.common.gender= observe.common.generateReport= diff --git a/observe-application-swing/src/main/resources/i18n/observe-application-swing_es_ES.properties b/observe-application-swing/src/main/resources/i18n/observe-application-swing_es_ES.properties index 177eba8..9e9787e 100644 --- a/observe-application-swing/src/main/resources/i18n/observe-application-swing_es_ES.properties +++ b/observe-application-swing/src/main/resources/i18n/observe-application-swing_es_ES.properties @@ -804,6 +804,7 @@ observe.common.gearCaracteristic= observe.common.gearCaracteristicType= observe.common.gearType= observe.common.gearUseFeaturesLongline= +observe.common.gearUseFeaturesMeasurementSeine= observe.common.gearUseFeaturesSeine= observe.common.gender= observe.common.generateReport=Generar un informe de validación diff --git a/observe-application-swing/src/main/resources/i18n/observe-application-swing_fr_FR.properties b/observe-application-swing/src/main/resources/i18n/observe-application-swing_fr_FR.properties index 8006abf..8c2348d 100644 --- a/observe-application-swing/src/main/resources/i18n/observe-application-swing_fr_FR.properties +++ b/observe-application-swing/src/main/resources/i18n/observe-application-swing_fr_FR.properties @@ -804,6 +804,7 @@ observe.common.gearCaracteristic=Caractéristique d'un équipement observe.common.gearCaracteristicType=Type de caractéristique d'équipement observe.common.gearType=Type d'engin observe.common.gearUseFeaturesLongline=Équipement +observe.common.gearUseFeaturesMeasurementSeine= observe.common.gearUseFeaturesSeine=Équipement observe.common.gender=Sexe observe.common.generateReport=Générer un rapport de validation diff --git a/observe-services-model/src/main/java/fr/ird/observe/services/dto/ReferenceDtos.java b/observe-services-model/src/main/java/fr/ird/observe/services/dto/ReferenceDtos.java index fabafb4..b80d7a8 100644 --- a/observe-services-model/src/main/java/fr/ird/observe/services/dto/ReferenceDtos.java +++ b/observe-services-model/src/main/java/fr/ird/observe/services/dto/ReferenceDtos.java @@ -23,19 +23,64 @@ package fr.ird.observe.services.dto; */ import com.google.common.base.Function; +import com.google.common.base.Preconditions; import com.google.common.base.Predicate; import com.google.common.collect.Collections2; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.util.beans.BeanUtil; +import java.beans.PropertyDescriptor; +import java.io.Serializable; +import java.lang.reflect.InvocationTargetException; import java.util.Collection; +import java.util.Set; public class ReferenceDtos extends AbstractReferenceDtos { + /** + * Logger. + */ + private static final Log log = LogFactory.getLog(ReferenceDtos.class); + public static <R extends IdDto> ReferenceDto<R> newReferenceDto(Class<R> type, Iterable<String> propertyNames) { ReferenceDto<R> dto = new ReferenceDto<>(); dto.init(type, propertyNames); return dto; } + public static <R extends IdDto> ReferenceDto<R> newReferenceDto(R bean, final Collection<String> propertyNames) { + Preconditions.checkNotNull(bean); + + ReferenceDto<R> reference = (ReferenceDto<R>) newReferenceDto(bean.getClass(), propertyNames); + reference.setId(bean.getId()); + + Set<PropertyDescriptor> descriptors = BeanUtil.getDescriptors(bean.getClass(), + new Predicate<PropertyDescriptor>() { + @Override + public boolean apply(PropertyDescriptor input) { + return propertyNames.contains(input.getName()); + } + }); + + for (PropertyDescriptor descriptor : descriptors) { + + try { + Object o = descriptor.getReadMethod().invoke(bean); + if (o != null) { + reference.setPropertyValue(descriptor.getName(), (Serializable) o); + } + + } catch (IllegalAccessException | InvocationTargetException e) { + if (log.isErrorEnabled()) { + log.error("Error while retrieving the property value for " + descriptor.getName() + " of " + bean, e); + } + } + } + + return reference; + } + public static Predicate<ReferenceDto> newContainsIdPredicate(final Collection<String> ids) { return new Predicate<ReferenceDto>() { diff --git a/observe-services-model/src/main/java/fr/ird/observe/services/dto/referential/ProgramDtos.java b/observe-services-model/src/main/java/fr/ird/observe/services/dto/referential/ProgramDtos.java index ec2f720..70a4640 100644 --- a/observe-services-model/src/main/java/fr/ird/observe/services/dto/referential/ProgramDtos.java +++ b/observe-services-model/src/main/java/fr/ird/observe/services/dto/referential/ProgramDtos.java @@ -1,10 +1,15 @@ package fr.ird.observe.services.dto.referential; +import com.google.common.collect.Lists; import fr.ird.observe.services.dto.ReferenceDto; +import fr.ird.observe.services.dto.ReferenceDtos; import fr.ird.observe.services.dto.constants.GearType; +import java.util.ArrayList; + public class ProgramDtos extends AbstractProgramDtos { + public static boolean isProgramLongLine(ProgramDto programDto) { return GearType.longline.equals(programDto.getGearType()); } @@ -41,4 +46,35 @@ public class ProgramDtos extends AbstractProgramDtos { return result; } + public static ReferenceDto<ProgramDto> newReferenceDto(ProgramDto programDto) { + ArrayList<String> propertyNames = Lists.newArrayList(ProgramDto.PROPERTY_CODE, + ProgramDto.PROPERTY_URI, + ProgramDto.PROPERTY_STATUS, + ProgramDto.PROPERTY_NEED_COMMENT, + ProgramDto.PROPERTY_LAST_UPDATE, + ProgramDto.PROPERTY_LABEL1, + ProgramDto.PROPERTY_LABEL2, + ProgramDto.PROPERTY_LABEL3, + ProgramDto.PROPERTY_LABEL4, + ProgramDto.PROPERTY_LABEL5, + ProgramDto.PROPERTY_LABEL6, + ProgramDto.PROPERTY_LABEL7, + ProgramDto.PROPERTY_LABEL8, + ProgramDto.PROPERTY_ORGANISM, + ProgramDto.PROPERTY_START_DATE, + ProgramDto.PROPERTY_END_DATE, + ProgramDto.PROPERTY_DETAILLED_ACTIVITIES_OBSERVATION, + ProgramDto.PROPERTY_NON_TARGET_OBSERVATION, + ProgramDto.PROPERTY_BAIT_OBSERVATION, + ProgramDto.PROPERTY_MAMMALS_OBSERVATION, + ProgramDto.PROPERTY_SAMPLES_OBSERVATION, + ProgramDto.PROPERTY_OBJECTS_OBSERVATION, + ProgramDto.PROPERTY_BIRDS_OBSERVATION, + ProgramDto.PROPERTY_TARGET_DISCARDS_OBSERVATION, + ProgramDto.PROPERTY_GEAR_TYPE); + + ReferenceDto<ProgramDto> reference = ReferenceDtos.newReferenceDto(programDto, propertyNames); + return reference; + } + } -- 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