This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository observe. See http://git.codelutin.com/observe.git commit ee1713991d71cbc5df753f1f1c4f5e24131ec3cf Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Wed Nov 4 09:56:33 2015 +0100 migration de l'action de validation (refs #7676) --- .../observe/ObserveSwingApplicationContext.java | 24 + .../java/fr/ird/observe/ui/DecoratorService.java | 43 +- .../java/fr/ird/observe/ui/admin/AdminStep.java | 3 +- .../fr/ird/observe/ui/admin/AdminTabUIHandler.java | 141 +- .../java/fr/ird/observe/ui/admin/AdminUIModel.java | 433 +++--- .../observe/ui/admin/config/ConfigUIHandler.java | 4 +- .../ird/observe/ui/admin/config/SelectDataUI.css | 2 +- .../ird/observe/ui/admin/config/SelectDataUI.jaxx | 6 +- .../ird/observe/ui/admin/export/ExportModel.java | 17 +- .../observe/ui/admin/export/ExportUIHandler.java | 3 +- .../observe/ui/admin/gps/ImportGPSUIHandler.java | 12 +- .../observe/ui/admin/report/ReportUIHandler.java | 2 +- .../validate/ValidateEntityListCellRenderer.java | 122 +- .../observe/ui/admin/validate/ValidateModel.java | 193 +-- .../ird/observe/ui/admin/validate/ValidateUI.jaxx | 3 +- .../ui/admin/validate/ValidateUIHandler.java | 402 +++--- .../validate/ValidationMessageTableModel.java | 90 ++ .../ref/ReferentialContentUIInitializer.java | 2 +- .../ui/storage/StorageBackupUILauncher.java | 3 +- .../ird/observe/ui/storage/StorageUIHandler.java | 4 +- .../fr/ird/observe/ui/storage/StorageUIModel.java | 11 +- .../ui/storage/tabs/DataSelectionModel.java | 101 +- .../ui/tree/DataSelectionTreeSelectionModel.java | 83 +- .../ird/observe/ui/tree/ObserveDataProvider.java | 16 +- .../fr/ird/observe/ui/tree/ObserveTreeHelper.java | 2 +- .../ui/tree/loadors/AbstractNodeChildLoador.java | 2 +- .../loadors/ProgramLonglineNodeChildLoador.java | 51 +- .../tree/loadors/ProgramSeineNodeChildLoador.java | 50 +- .../ui/tree/loadors/RootNodeChildLoador.java | 34 +- ...ObserveSimpleValidatorMessageTableRenderer.java | 79 -- .../ObserveValidationMessageTableRenderer.java | 147 ++ .../observe/validation/ValidationModelMode.java | 42 +- .../observe-application-swing_en_GB.properties | 10 + .../observe-application-swing_es_ES.properties | 22 +- .../observe-application-swing_fr_FR.properties | 22 +- .../v1/ReferentialServiceController.java | 4 +- .../validate/ValidateServiceController.java | 6 - .../v1/longline/TripLonglineServiceController.java | 5 + .../v1/seine/TripSeineServiceController.java | 5 + .../services/service/ReferentialService.java | 2 +- .../actions/validate/ValidateResultForDtoType.java | 15 + .../actions/validate/ValidateResultForDtos.java | 80 ++ .../service/actions/validate/ValidateService.java | 4 - .../actions/validate/ValidateServiceUtils.java | 40 + .../service/actions/validate/ValidatorDto.java | 51 + .../service/actions/validate/ValidatorDtos.java | 37 + .../service/longline/TripLonglineService.java | 4 +- .../services/service/seine/TripSeineService.java | 2 + .../service/actions/validate/validators.json | 1492 ++++++++++++++++++++ .../ObserveDataSourceConfiguration.java | 4 +- .../ObserveDataSourceConfigurationRest.java | 2 +- .../ObserveDataSourceConfigurationTopiaH2.java | 2 +- .../ObserveDataSourceConfigurationTopiaPG.java | 2 +- ...ObserveDataSourceConfigurationTopiaSupport.java | 5 + .../java/fr/ird/observe/services/dto/IdDtos.java | 20 + .../services/dto/gson/ReferenceDtoAdapter.java | 10 +- .../ird/observe/services/ObserveServiceTopia.java | 222 +++ .../services/dto/ObserveDtosInitializer.java | 11 +- .../services/service/DataSourceServiceTopia.java | 3 + .../services/service/ReferentialServiceTopia.java | 4 +- .../actions/validate/ValidateServiceTopia.java | 76 +- .../validate/ValidationMessageDetector.java | 3 +- .../longline/ActivityLonglineServiceTopia.java | 14 +- .../service/longline/TripLonglineServiceTopia.java | 41 +- .../service/seine/TripSeineServiceTopia.java | 35 +- 65 files changed, 3323 insertions(+), 1059 deletions(-) diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ObserveSwingApplicationContext.java b/observe-application-swing/src/main/java/fr/ird/observe/ObserveSwingApplicationContext.java index c221a29..addd830 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ObserveSwingApplicationContext.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ObserveSwingApplicationContext.java @@ -22,6 +22,8 @@ package fr.ird.observe; import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; import fr.ird.observe.business.db.DataContext; import fr.ird.observe.business.gps.GPSService; import fr.ird.observe.configuration.ObserveSwingApplicationConfig; @@ -38,6 +40,8 @@ import fr.ird.observe.services.dto.constants.ReferentialLocale; import fr.ird.observe.services.service.BabModelVersionException; import fr.ird.observe.services.service.DatabaseConnexionNotAuthorizedException; import fr.ird.observe.services.service.DatabaseNotFoundException; +import fr.ird.observe.services.service.actions.validate.ValidateServiceUtils; +import fr.ird.observe.services.service.actions.validate.ValidatorDto; import fr.ird.observe.ui.DecoratorService; import fr.ird.observe.ui.ObserveMainUI; import fr.ird.observe.ui.ObserveMainUIHandler; @@ -76,6 +80,7 @@ import javax.swing.JPanel; import java.awt.Component; import java.io.Closeable; import java.io.File; +import java.io.IOException; import java.util.Arrays; import java.util.List; import java.util.Locale; @@ -159,6 +164,9 @@ public class ObserveSwingApplicationContext extends DefaultApplicationContext im public static final JAXXContextEntryDef<ValidationContext> VALIDATION_CONTEXT_ENTRY_DEF = JAXXUtil.newContextEntryDef(ValidationContext.class); + public static final JAXXContextEntryDef<List<ValidatorDto>> VALIDATORS_ENTRY_DEF = + JAXXUtil.newListContextEntryDef(); + /** the jaxx context entry to store the main ui */ private static final JAXXContextEntryDef<ObserveMainUI> MAIN_UI_ENTRY_DEF = UIHelper.newContextEntryDef("mainui", ObserveMainUI.class); @@ -349,6 +357,22 @@ public class ObserveSwingApplicationContext extends DefaultApplicationContext im return result; } + public final ImmutableSet<ValidatorDto> getValidators() { + List<ValidatorDto> result = + VALIDATORS_ENTRY_DEF.getContextValue(this); + if (result == null) { + try { + result = Lists.newArrayList(ValidateServiceUtils.getValidators()); + VALIDATORS_ENTRY_DEF.setContextValue(this, result); + + } catch (IOException e) { + throw new ObserveSwingTechnicalException("unable to load validators", e); + } + + } + return ImmutableSet.copyOf(result); + } + @Override public void close() { if (log.isInfoEnabled()) { 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 ecbd4b0..492f6c0 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 @@ -21,6 +21,7 @@ */ package fr.ird.observe.ui; +import com.google.common.collect.Lists; import fr.ird.observe.business.gps.GPSPoint; import fr.ird.observe.business.gps.GPSPointInterval; import fr.ird.observe.entities.longline.SectionTemplate; @@ -31,6 +32,7 @@ import fr.ird.observe.services.dto.longline.ActivityLonglineDto; import fr.ird.observe.services.dto.longline.BasketDto; import fr.ird.observe.services.dto.longline.BranchlineDto; import fr.ird.observe.services.dto.longline.CatchLonglineDto; +import fr.ird.observe.services.dto.longline.EncounterDto; import fr.ird.observe.services.dto.longline.SectionDto; import fr.ird.observe.services.dto.longline.SetLonglineDto; import fr.ird.observe.services.dto.longline.TdrDto; @@ -98,6 +100,7 @@ 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.NonTargetCatchDto; import fr.ird.observe.services.dto.seine.ObjectSchoolEstimateDto; import fr.ird.observe.services.dto.seine.RouteDto; import fr.ird.observe.services.dto.seine.SchoolEstimateDto; @@ -122,7 +125,7 @@ import org.nuiton.decorator.Decorator; import org.nuiton.decorator.DecoratorProvider; import java.beans.Introspector; -import java.util.Arrays; +import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; @@ -200,10 +203,11 @@ public class DecoratorService extends DecoratorProvider { return type; } - public Class<?>[] sortTypes(Class<?>... types) { - List<Class<?>> list = Arrays.asList(types); + public List<Class<? extends IdDto>> sortTypes(Collection<Class<? extends IdDto>> types) { final Map<Class<?>, String> cache = new HashMap<Class<?>, String>(); + List<Class<? extends IdDto>> list = Lists.newArrayList(types); + Comparator<Class<?>> result = new Comparator<Class<?>>() { @Override @@ -225,7 +229,7 @@ public class DecoratorService extends DecoratorProvider { }; Collections.sort(list, result); cache.clear(); - return list.toArray(new Class<?>[list.size()]); + return list; } public String decorate(Object o) { @@ -489,14 +493,20 @@ public class DecoratorService extends DecoratorProvider { registerReferenceDtoDecorator(HarbourDto.class, "${code}$s##${name}$s##${locode}$s"); - registerObserveDecorator(ObjectSchoolEstimateDto.class, "${species/scientificLabel}$s##${weight}$d"); - registerObserveDecorator(SchoolEstimateDto.class, "${species/scientificLabel}$s##${weight}$d##${meanWeight}$d"); + registerReferenceDtoDecorator(ObjectSchoolEstimateDto.class, + "${species/scientificLabel}$s##${weight}$d", + "${species}$s##${weight}$d"); + registerReferenceDtoDecorator(SchoolEstimateDto.class, + "${species/scientificLabel}$s##${totalWeight}$d##${meanWeight}$d", + "${species}$s##${totalWeight}$d##${meanWeight}$d"); + registerObserveDecorator( TargetCatchDto.class, "${weightCategory/species/scientificLabel}$s##${weightCategory/label}$s##${weight}$f"); - registerObserveDecorator( + registerReferenceDtoDecorator( TargetLengthDto.class, - "${species/scientificLabel}$s##${length}$f##${count}$d"); + "${species/scientificLabel}$s##${length}$f##${count}$d", + "${species}$s##${length}$f##${count}$d"); registerObserveDecorator( TransmittingBuoyDto.class, @@ -542,6 +552,8 @@ public class DecoratorService extends DecoratorProvider { // NonTargetCatch decorator registerDecorator(new NonTargetCatchDecorator()); + registerDecorator(NonTargetCatchDto.class.getSimpleName(), + new ReferenceDecorator("${species}$s##${speciesFate}$s")); // NonTargetLength decorator registerDecorator(new NonTargetLengthDecorator()); @@ -570,10 +582,25 @@ public class DecoratorService extends DecoratorProvider { registerObserveDecorator(SectionTemplate.class, "${id}$s##${floatlineLengths}$s", " "); registerObserveDecorator(CatchLonglineDto.class, "${homeId}$s"); + registerDecorator(CatchLonglineDto.class.getSimpleName(), + new ReferenceDecorator("${homeId}$s")); + registerObserveDecorator(TdrDto.class, "${homeId}$s"); //FIXME how to decorate ? registerObserveDecorator(GearUseFeaturesMeasurementSeineDto.class, "${id}$s"); + + registerReferenceDtoDecorator(EncounterDto.class, + "${encounterType/label}$s##${species/label}$s", + "${encounterType}$s##${species}$s", + " - "); + + registerDecorator(SetSeineDto.class.getSimpleName(), + new ReferenceDecorator(t("observe.common.setSeine"))); + + + registerDecorator(SetLonglineDto.class.getSimpleName(), + new ReferenceDecorator(t("observe.common.setLongline"))); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminStep.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminStep.java index 395f0bf..5c233bf 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminStep.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminStep.java @@ -117,7 +117,8 @@ public enum AdminStep implements WizardExtStep { false, false, DbMode.USE_LOCAL, - DbMode.USE_REMOTE + DbMode.USE_REMOTE, + DbMode.USE_SERVER ), /** pour lancer la consolidation des données (mesure taille-poids...) */ diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminTabUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminTabUIHandler.java index 46319cc..6c7afed 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminTabUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminTabUIHandler.java @@ -23,12 +23,7 @@ package fr.ird.observe.ui.admin; import fr.ird.observe.ObserveRunner; import fr.ird.observe.ObserveSwingApplicationContext; -import fr.ird.observe.ObserveSwingBinderService; import fr.ird.observe.business.SendMessageAble; - - -import fr.ird.observe.business.gps.GPSService; -import fr.ird.observe.validation.ValidationService; import fr.ird.observe.db.ObserveSwingDataSource; import fr.ird.observe.services.service.BabModelVersionException; import fr.ird.observe.services.service.DatabaseConnexionNotAuthorizedException; @@ -36,6 +31,7 @@ import fr.ird.observe.services.service.DatabaseNotFoundException; import fr.ird.observe.ui.DecoratorService; import fr.ird.observe.ui.admin.config.SelectDataUI; import fr.ird.observe.ui.admin.resume.ShowResumeUI; +import fr.ird.observe.ui.storage.tabs.DataSelectionModel; import fr.ird.observe.ui.tree.DataSelectionTreeSelectionModel; import fr.ird.observe.ui.tree.ObserveTreeHelper; import jaxx.runtime.swing.wizard.ext.WizardState; @@ -43,6 +39,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import javax.swing.JTree; +import javax.swing.tree.TreeModel; import java.io.PrintWriter; import java.io.StringWriter; import java.util.concurrent.Callable; @@ -65,51 +62,11 @@ public class AdminTabUIHandler implements SendMessageAble { protected final AdminUIModel model; - //FIXME -// protected final DataSourceListener serviceLogger = -// new DataSourceListenerAdapter() { -// -// @Override -// public void onNewMessage(DataSourceEvent event) { -// DataSource service = event.getSource(); -// -// if (event.getMessageLevel() == DataSourceEvent.MessageLevel.INFO) { -// sendMessage(service.getShortLabel() + " : " + -// event.getMessage()); -// } -// } -// }; - protected AdminUI parentUI; - /** - * Service de replication. - * <p/> - * Note: le service est sans état et donc peut rester en état du handler. - */ - //FIXME -// private ReplicationService replicationService; - - /** - * Service de replication. - * <p/> - * Note: le service est sans état et donc peut rester en état du handler. - */ - private ValidationService validationService; - - /** - * Service de gps. - * <p/> - * Note: le service est sans état et donc peut rester en état du handler. - */ - private GPSService gpsService; - /** Service de decoration. */ private DecoratorService decoratorService; - /** Service de binders. */ - private ObserveSwingBinderService binderService; - public AdminTabUIHandler(AdminTabUI ui) { this.ui = ui; model = ui.getModel(); @@ -123,22 +80,6 @@ public class AdminTabUIHandler implements SendMessageAble { return model; } - //FIXME -// public final ReplicationService getReplicationService() { -// if (replicationService == null) { -// replicationService = ObserveServiceHelper.newReplicationService(); -// } -// return replicationService; -// } - - public final ValidationService getValidationService() { - //FIXME -// if (validationService == null) { -// validationService = ObserveServiceHelper.newValidationService(); -// } - return validationService; - } - public final DecoratorService getDecoratorService() { if (decoratorService == null) { decoratorService = ObserveSwingApplicationContext.get().getDecoratorService(); @@ -146,20 +87,6 @@ public class AdminTabUIHandler implements SendMessageAble { return decoratorService; } - public final ObserveSwingBinderService getBinderService() { - if (binderService == null) { - binderService = ObserveSwingApplicationContext.get().getBinderService(); - } - return binderService; - } - - public final GPSService getGpsService() { - if (gpsService == null) { - gpsService = ObserveSwingApplicationContext.get().getGPSService(); - } - return gpsService; - } - protected ObserveSwingDataSource getSource() { ObserveSwingDataSource source = model.getTmpSource(); @@ -209,34 +136,6 @@ public class AdminTabUIHandler implements SendMessageAble { // getReplicationService().replicateReferentiel(source, target); } - //FIXME -// protected TopiaContext beginTransaction(DataSource source, String methodName) { -// TopiaContext ctxt = source.beginTransaction(methodName); -// return ctxt; -// } - - //FIXME -// protected void commitTransaction(DataSource source, TopiaContext tx, String methodName) { -// source.commitTransaction(tx, methodName); -// } - - //FIXME -// protected void closeTransaction(DataSource source, TopiaContext tx, String methodName) { -// source.closeTransaction(tx, methodName); -// } - - //FIXME -// protected void rollbackTransaction(DataSource source, TopiaContext tx, String methodName) { -// source.rollbackTransaction(tx, methodName); -// } - - //FIXME -// protected TopiaDAO<TopiaEntity> getDAO(TopiaContext tx, TopiaEntity entity) throws TopiaException { -// TopiaDAO<TopiaEntity> dao = -// ObserveDAOHelper.<TopiaEntity, TopiaDAO<TopiaEntity>>getDAO(tx, entity); -// return dao; -// } - public void initTabUI(AdminUI ui, AdminTabUI tabUI) { parentUI = ui; @@ -318,31 +217,27 @@ public class AdminTabUIHandler implements SendMessageAble { public void updateSelectionModel(SelectDataUI tabUI) { JTree selectTree = tabUI.getSelectTree(); - //FIXME -// DataSelectionModel selectDataModel = tabUI.getSelectDataModel(); + DataSelectionModel selectDataModel = tabUI.getSelectDataModel(); DataSelectionTreeSelectionModel selectionModel = tabUI.getSelectionModel(); ObserveTreeHelper helper = tabUI.getTreeHelper(); - //FIXME -// if (log.isDebugEnabled()) { -// log.debug("reload model " + selectDataModel); -// } + if (log.isDebugEnabled()) { + log.debug("reload model " + selectDataModel); + } selectionModel.clearSelection(); ObserveSwingDataSource source = tabUI.getModel().getSafeLocalSource(true); if (log.isDebugEnabled()) { log.debug("Will treeHelper : " + helper); - //FIXME -// log.debug("selection model : " + selectDataModel); -// log.debug("use referentiel : " + selectDataModel.isUseReferentiel()); -// log.debug("use data : " + selectDataModel.isUseData()); + log.debug("selection model : " + selectDataModel); + log.debug("use referentiel : " + selectDataModel.isUseReferentiel()); + log.debug("use data : " + selectDataModel.isUseData()); } - //FIXME -// TreeModel model = helper.createModel(tabUI, selectDataModel, source); + TreeModel model = helper.createModel(tabUI, selectDataModel, source); -// selectTree.setModel(model); + selectTree.setModel(model); selectionModel.initUI(selectTree); } @@ -364,21 +259,7 @@ public class AdminTabUIHandler implements SendMessageAble { return source; } - protected void addStorageServiceLogger(ObserveSwingDataSource service) { - //FIXME -// if (!service.containsObserveSwingDataSourceListener(serviceLogger)) { -// service.addObserveSwingDataSourceListener(serviceLogger); -// } - } - - protected void removeStorageServiceLogger(ObserveSwingDataSource service) { -// if (service.containsDataSourceListener(serviceLogger)) { -// service.removeDataSourceListener(serviceLogger); -// } - } - protected void openSource(ObserveSwingDataSource service) throws DatabaseConnexionNotAuthorizedException, DatabaseNotFoundException, BabModelVersionException { - addStorageServiceLogger(service); if (!service.isOpen()) { service.open(); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminUIModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminUIModel.java index 1316db6..a53212f 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminUIModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminUIModel.java @@ -21,16 +21,27 @@ */ package fr.ird.observe.ui.admin; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; +import fr.ird.observe.ObserveSwingApplicationContext; import fr.ird.observe.business.report.model.Report; -import fr.ird.observe.validation.ValidationModelMode; -import fr.ird.observe.validation.ValidatorsMap; import fr.ird.observe.configuration.ObserveSwingApplicationConfig; import fr.ird.observe.db.ObserveSwingDataSource; import fr.ird.observe.db.constantes.DbMode; import fr.ird.observe.services.configuration.ObserveDataSourceConfiguration; +import fr.ird.observe.services.configuration.ObserveDataSourceInformation; +import fr.ird.observe.services.dto.IdDtos; +import fr.ird.observe.services.dto.ReferenceDto; +import fr.ird.observe.services.dto.ReferenceSetDto; +import fr.ird.observe.services.dto.longline.TripLonglineDto; +import fr.ird.observe.services.dto.seine.TripSeineDto; import fr.ird.observe.services.service.BabModelVersionException; import fr.ird.observe.services.service.DatabaseConnexionNotAuthorizedException; import fr.ird.observe.services.service.DatabaseNotFoundException; +import fr.ird.observe.services.service.actions.validate.ValidateService; +import fr.ird.observe.services.service.actions.validate.ValidateServiceUtils; +import fr.ird.observe.services.service.longline.TripLonglineService; +import fr.ird.observe.services.service.seine.TripSeineService; import fr.ird.observe.ui.admin.consolidate.ConsolidateModel; import fr.ird.observe.ui.admin.export.ExportModel; import fr.ird.observe.ui.admin.gps.ImportGPSModel; @@ -41,6 +52,7 @@ import fr.ird.observe.ui.admin.validate.ValidateModel; import fr.ird.observe.ui.storage.StorageUIHandler; import fr.ird.observe.ui.storage.StorageUIModel; import fr.ird.observe.ui.storage.tabs.DataSelectionModel; +import fr.ird.observe.validation.ValidationModelMode; import jaxx.runtime.swing.wizard.ext.WizardExtModel; import jaxx.runtime.swing.wizard.ext.WizardState; import org.apache.commons.lang3.StringUtils; @@ -86,6 +98,9 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { /** la source de données sur laquel on veut travailler */ protected ObserveSwingDataSource localSource; + /** la source de données sur laquel on veut travailler */ + protected ObserveDataSourceInformation localSourceInformation; + /** la source de données dite central (contenant le référentiel valide) */ protected ObserveSwingDataSource centralSource; @@ -167,14 +182,12 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { return; } - //FIXME -// DataSelectionModel selectModel = getSelectionDataModel(); + DataSelectionModel selectModel = getSelectionDataModel(); if (containsOperation(AdminStep.EXPORT_DATA)) { // on doit aussi calculer les ids des marées distantes - //FIXME -// computeExistingTrips(dataService, getSafeCentralSource(true)); + computeExistingTrips(getSafeCentralSource(true)); } @@ -183,8 +196,7 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { // log.debug("Will refill selectionModel [" + newStep + "] : " + selectModel); // } ObserveSwingDataSource dataSource = getSafeLocalSource(true); - //FIXME -// populateSelectionModel(dataService, dataSource); + populateSelectionModel(dataSource); } }; @@ -192,21 +204,20 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { @Override public void propertyChange(PropertyChangeEvent evt) { - //FIXME -// DataSelectionModel source = (DataSelectionModel) evt.getSource(); -// if (log.isDebugEnabled()) { -// log.debug("selection data model [" + source + "] changed on " + -// evt.getPropertyName() + ", new value = " + -// evt.getNewValue()); -// } -// validate(); -// if (log.isDebugEnabled()) { -// log.debug("nb selected export datas = " + -// source.getSelectedData().size()); -// } -// -// // on declanche la revalidation du modèle -// firePropertyChange(VALID_STEP_PROPERTY_NAME, validStep); + DataSelectionModel source = (DataSelectionModel) evt.getSource(); + if (log.isDebugEnabled()) { + log.debug("selection data model [" + source + "] changed on " + + evt.getPropertyName() + ", new value = " + + evt.getNewValue()); + } + validate(); + if (log.isDebugEnabled()) { + log.debug("nb selected export datas = " + + source.getSelectedData().size()); + } + + // on declanche la revalidation du modèle + firePropertyChange(VALID_STEP_PROPERTY_NAME, validStep); } }; @@ -320,12 +331,13 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { public String getLabel() { String txt = n("observe.storage.label.synchro.incoming"); String params; - if (getDbMode() == DbMode.USE_REMOTE) { + + if (getDbMode() == DbMode.USE_SERVER) { + params = t("observe.storage.server.db") + " " + getRemoteUrl(); + } else if (getDbMode() == DbMode.USE_REMOTE) { params = t("observe.storage.remote.db") + " " + getRemoteUrl(); } else { - //FIXME -// params = t("observe.storage.locale.db") + " " + getH2Config().getDataDirectory().getAbsolutePath(); - params = null; + params = t("observe.storage.locale.db") + " " + getH2Config().getDirectory().getAbsolutePath(); } txt = t(txt, params); return txt; @@ -348,12 +360,11 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { String txt; String params; txt = n("observe.storage.label.synchro.referentiel"); - //FIXME -// if (getDbMode() == DbMode.CREATE_LOCAL) { -// params = getH2Config().getDataDirectory().getAbsolutePath(); -// } else { + if (getDbMode() == DbMode.CREATE_LOCAL) { + params = getH2Config().getDirectory().getAbsolutePath(); + } else { params = getRemoteUrl(); -// } + } txt = t(txt, params); return txt; } @@ -367,8 +378,7 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { } }; - //FIXME -// selectionDataModel = new DataSelectionModel(); + selectionDataModel = new DataSelectionModel(); availableIncomingModes = EnumSet.noneOf(DbMode.class); @@ -377,10 +387,9 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { } } - //FIXME -// public DataSelectionModel getSelectionDataModel() { -// return selectionDataModel; -// } + public DataSelectionModel getSelectionDataModel() { + return selectionDataModel; + } public boolean needSelect() { if (WizardState.CANCELED == getModelState()) { @@ -395,18 +404,17 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { return false; } - public String getSelectedTrip() { - //FIXME -// Set<String> data = getSelectionDataModel().getSelectedData(); -// if (data.isEmpty()) { -// -// // pas de Trip selectionne -// return null; -// } -// String id = data.iterator().next(); -// if (Trips.isTripId(id)) { -// return id; -// } + public ReferenceDto getSelectedTrip() { + Set<ReferenceDto> data = getSelectionDataModel().getSelectedData(); + if (data.isEmpty()) { + + // pas de Trip selectionne + return null; + } + ReferenceDto dto = data.iterator().next(); + if (IdDtos.isTrip(dto)) { + return dto; + } // la donnée n'est pas une marée return null; @@ -417,11 +425,6 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { return (AdminActionModel) super.getStepModel(operation); } - //FIXME -// public DataService getDataService() { -// return dataService; -// } - public ObserveSwingApplicationConfig getConfig() { return config; } @@ -491,8 +494,7 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { availableIncomingModes.clear(); storageHandler = ui.getContextValue(StorageUIHandler.class); - //FIXME -// dataService = ui.getContextValue(DataService.class); + config = ui.getContextValue(ObserveSwingApplicationConfig.class); // demarrage du modèle : on fixe ici une fois pour toute les liste @@ -553,8 +555,9 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { getValidateModel().addPropertyChangeListener(listenValidationModified); getValidateModel().addScope(NuitonValidatorScope.ERROR); getValidateModel().setModelMode(ValidationModelMode.DATA); - getValidateModel().setAllContextNames(new String[]{"n1-update", "n1-create"}); - getValidateModel().setContextName("n1-update"); + ImmutableSet<String> availableContextNames = ValidateServiceUtils.getAvailableContextNames(); + getValidateModel().setAllContextNames(availableContextNames.toArray(new String[availableContextNames.size()])); + getValidateModel().setContextName(ValidateService.N1_UPDATE_CONTEXT); getValidateModel().setGenerateReport(true); if (!config.getValidationReportDirectory().exists()) { boolean b = config.getValidationReportDirectory().mkdirs(); @@ -588,8 +591,7 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { getReportModel().addPropertyChangeListener(listenReportModified); // on ecoute la modification de la sélection - //FIXME -// getSelectionDataModel().addPropertyChangeListener(DataSelectionModel.PROPERTY_SELECTED_DATA, listenerSelectedDataForReport); + getSelectionDataModel().addPropertyChangeListener(DataSelectionModel.PROPERTY_SELECTED_DATA, listenerSelectedDataForReport); if (log.isInfoEnabled()) { log.info("Detects " + reports.size() + " report(s)."); @@ -680,34 +682,53 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { modes.add(DbMode.USE_REMOTE); } + if (authorizedModes.contains(DbMode.USE_SERVER)) { + + modes.add(DbMode.USE_SERVER); + } + if (authorizedModes.contains(DbMode.CREATE_LOCAL)) { modes.add(DbMode.CREATE_LOCAL); } - //FIXME -// if (previousSource != null) { -// -// previousSourceConfig = previousSource.getConfig().clone(); -// -// if (previousSource instanceof PGDataSource) { -// -// if (!modes.contains(DbMode.USE_REMOTE)) { -// -// // pas autorise a utiliser cette source en entree -// previousSource = null; -// } -// } -// -// if (previousSource instanceof H2DataSource) { -// -// if (!modes.contains(DbMode.USE_LOCAL)) { -// -// // pas autorise a utiliser cette source en entree -// previousSource = null; -// } -// } -// } + if (previousSource != null) { + + try { + previousSourceConfig = previousSource.getConfiguration().clone(); + } catch (CloneNotSupportedException e) { + if (log.isErrorEnabled()) { + log.error("con not clone previous data configuration", e); + } + } + + if (previousSource.isRemote()) { + + if (!modes.contains(DbMode.USE_REMOTE)) { + + // pas autorise a utiliser cette source en entree + previousSource = null; + } + } + + if (previousSource.isServer()) { + + if (!modes.contains(DbMode.USE_SERVER)) { + + // pas autorise a utiliser cette source en entree + previousSource = null; + } + } + + if (previousSource.isLocal()) { + + if (!modes.contains(DbMode.USE_LOCAL)) { + + // pas autorise a utiliser cette source en entree + previousSource = null; + } + } + } availableIncomingModes.addAll(modes); @@ -756,44 +777,42 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { return; } - //FIXME -// DataSelectionModel selectionModel = getSelectionDataModel(); -// -// if (containsOperation(AdminStep.EXPORT_DATA)) { -// -// selectionModel.setUseData(true); -// selectionModel.setUseOpenData(false); -// selectionModel.setUseReferentiel(false); -// } -// -// if (containsOperation(AdminStep.REPORT)) { -// -// selectionModel.setUseData(true); -// selectionModel.setUseOpenData(true); -// selectionModel.setUseReferentiel(false); -// } -// -// if (containsOperation(AdminStep.VALIDATE)) { -// -// selectionModel.setUseOpenData(true); -// } -// -// if (containsOperation(AdminStep.CONSOLIDATE)) { -// -// selectionModel.setUseOpenData(true); -// selectionModel.setUseData(true); -// selectionModel.setUseReferentiel(false); -// } -// -// selectionModel.addPropertyChangeListener(listenSelectModified); + DataSelectionModel selectionModel = getSelectionDataModel(); + + if (containsOperation(AdminStep.EXPORT_DATA)) { + + selectionModel.setUseData(true); + selectionModel.setUseOpenData(false); + selectionModel.setUseReferentiel(false); + } + + if (containsOperation(AdminStep.REPORT)) { + + selectionModel.setUseData(true); + selectionModel.setUseOpenData(true); + selectionModel.setUseReferentiel(false); + } + + if (containsOperation(AdminStep.VALIDATE)) { + + selectionModel.setUseOpenData(true); + } + + if (containsOperation(AdminStep.CONSOLIDATE)) { + + selectionModel.setUseOpenData(true); + selectionModel.setUseData(true); + selectionModel.setUseReferentiel(false); + } + + selectionModel.addPropertyChangeListener(listenSelectModified); } @Override public void destroy() { localSourceModel.destroy(); centralSourceModel.destroy(); - //FIXME -// selectionDataModel.destroy(); + selectionDataModel.destroy(); super.destroy(); } @@ -809,6 +828,26 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { return localSource; } + public ObserveDataSourceInformation getLocalSourceInformation() { + if (localSourceInformation == null) { + + ObserveSwingDataSource localSource = getSafeLocalSource(false); + + try { + + localSourceInformation = localSource.checkCanConnect(); + + } catch (Exception e) { + if (log.isErrorEnabled()) { + log.error("unable to find local source information", e); + } + } + + } + + return localSourceInformation; + } + public ObserveSwingDataSource getCentralSource() { return centralSource; } @@ -842,16 +881,7 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { public ObserveSwingDataSource getSafeTmpSource(boolean open) { if (tmpSource == null) { - //FIXME -// try { -// tmpSource = ObserveServiceHelper.newEmptyTempStorage( -// config, -// n("observe.storage.label.synchro"), -// "synchrodb" -// ); -// } catch (IOException e) { -// throw new IllegalStateException("Could not create temporary database", e); -// } + tmpSource = ObserveSwingApplicationContext.get().createDataSourceH2Temp(n("observe.storage.label.synchro")); if (open) { doOpenSource(tmpSource); } @@ -957,8 +987,7 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { return false; } - //FIXME -// DataSelectionModel selectionModel = getSelectionDataModel(); + DataSelectionModel selectionModel = getSelectionDataModel(); switch (s) { case CONFIG: @@ -1019,8 +1048,7 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { return false; } } - ValidatorsMap validators = getValidateModel().getValidators(); - if (validators.isEmpty()) { + if (getValidateModel().getValidators().isEmpty()) { if (log.isDebugEnabled()) { log.debug("no validators detected"); } @@ -1028,30 +1056,38 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { } // la base precedente doit etre ouverte - ObserveSwingDataSource source = getSafeLocalSource(true); + ObserveDataSourceInformation dataSourceInformation = getLocalSourceInformation(); + + // si le test de connection a echoue + if (dataSourceInformation == null) { + if (log.isDebugEnabled()) { + log.debug("can not connect to data source "); + } + return false; + } + // pour valider une base il faut les droits - //FIXME -// if (selectionModel.isUseData()) { -// -// // il faut les droits en Lecture sur les donnes -// if (!(source.canReadData() && source.canWriteData())) { -// if (log.isDebugEnabled()) { -// log.debug("can not read and write data"); -// } -// return false; -// } -// } -// if (selectionModel.isUseReferentiel()) { -// -// // il faut les droits en L/E sur le referentiel -// if (!(source.canReadReferentiel() && source.canWriteReferentiel())) { -// if (log.isDebugEnabled()) { -// log.debug("can not read and write referentiel"); -// } -// return false; -// } -// } + if (selectionModel.isUseData()) { + + // il faut les droits en Lecture sur les donnes + if (!(dataSourceInformation.canReadData() && dataSourceInformation.canWriteData())) { + if (log.isDebugEnabled()) { + log.debug("can not read and write data"); + } + return false; + } + } + if (selectionModel.isUseReferentiel()) { + + // il faut les droits en L/E sur le referentiel + if (!(dataSourceInformation.canReadReferential() && dataSourceInformation.canWriteReferential())) { + if (log.isDebugEnabled()) { + log.debug("can not read and write referentiel"); + } + return false; + } + } } if (containsOperation(AdminStep.SYNCHRONIZE)) { @@ -1059,8 +1095,7 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { DbMode dbMode = localSourceModel.getDbMode(); if (dbMode == centralSourceModel.getDbMode()) { if (dbMode == DbMode.USE_REMOTE) { - //FIXME -// validate &= !localSourceModel.getPgConfig().getUrl().equals(centralSourceModel.getPgConfig().getUrl()); + validate &= !localSourceModel.getPgConfig().getJdbcUrl().equals(centralSourceModel.getPgConfig().getJdbcUrl()); } else { // pour le moment ce cas n'est pas possible @@ -1075,8 +1110,7 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { // avec des droits d'écriture de données // validate &= centralSourceModel.isValid() && // centralSourceModel.getPgConfig().isCanWriteData(); - //FIXME -// validate &= centralSourceModel.getPgConfig().isCanWriteData(); + validate &= centralSourceModel.getDataSourceInformation().canWriteData(); } if (containsOperation(AdminStep.IMPORT_GPS)) { @@ -1103,9 +1137,8 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { if (validate) { // il faut au moins une donnee de selectionnee - //FIXME -// boolean empty = selectionModel.isEmpty(); -// validate &= !empty; + boolean empty = selectionModel.isEmpty(); + validate &= !empty; } } if (containsOperation(AdminStep.EXPORT_DATA)) { @@ -1115,9 +1148,8 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { if (validate) { // il faut au moins une donnee de selectionnee - //FIXME -// boolean empty = selectionModel.isDataEmpty(); -// validate &= !empty; + boolean empty = selectionModel.isDataEmpty(); + validate &= !empty; } } if (containsOperation(AdminStep.CONSOLIDATE)) { @@ -1127,9 +1159,8 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { if (validate) { // il faut au moins une donnee de selectionnee - //FIXME -// boolean empty = selectionModel.isDataEmpty(); -// validate &= !empty; + boolean empty = selectionModel.isDataEmpty(); + validate &= !empty; } } if (containsOperation(AdminStep.REPORT)) { @@ -1139,10 +1170,9 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { if (validate) { // il faut exactement une Trip de selectionnee - //FIXME -// boolean empty = selectionModel.isDataEmpty(); -// validate &= !empty && -// selectionModel.getSelectedData().size() == 1; + boolean empty = selectionModel.isDataEmpty(); + validate &= !empty && + selectionModel.getSelectedData().size() == 1; } } break; @@ -1256,6 +1286,7 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { if (localSource != null) { doCloseSource(localSource, false); localSource = null; + localSourceInformation = null; } } @@ -1266,38 +1297,38 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { } } - //FIXME -// public void populateSelectionModel(DataService dataService, DataSource source) { -// try { -// DataSelectionModel.populate(getSelectionDataModel(), dataService, source); -// } catch (Exception e) { -// if (log.isErrorEnabled()) { -// log.error("could not populate selected model", e); -// } -// } finally { -// -// // on notifie que le modèle de sélection a changé -// // (il faut donc recalculé l'arbre de sélection) -// firePropertyChange(SELECTION_MODEL_CHANGED_PROPERTY_NAME, getSelectionDataModel()); -// } -// } - - //FIXME -// protected void computeExistingTrips(DataService dataService, DataSource source) { -// -// List<String> existingTripIds = new ArrayList<String>(); -// try { -// List<String> tripSeineIds = dataService.getEntityIds(source, TripSeine.class); -// existingTripIds.addAll(tripSeineIds); -// List<String> tripLonglineIds = dataService.getEntityIds(source, TripLongline.class); -// existingTripIds.addAll(tripLonglineIds); -// } catch (DataSourceException e) { -// throw new ObserveTechnicalException("Coould not get trip ids",e); -// } -// -// getExportModel().setExistingTripIds(existingTripIds); -// -// } + public void populateSelectionModel(ObserveSwingDataSource source) { + try { + DataSelectionModel.populate(getSelectionDataModel(), source); + + } catch (Exception e) { + if (log.isErrorEnabled()) { + log.error("could not populate selected model", e); + } + } finally { + + // on notifie que le modèle de sélection a changé + // (il faut donc recalculé l'arbre de sélection) + firePropertyChange(SELECTION_MODEL_CHANGED_PROPERTY_NAME, getSelectionDataModel()); + } + } + + protected void computeExistingTrips(ObserveSwingDataSource source) { + + List<ReferenceDto> existingTrip = Lists.newArrayList(); + + TripSeineService tripSeineService = source.newService(TripSeineService.class); + ReferenceSetDto<TripSeineDto> tripSeineSet = tripSeineService.getAllTripSeine(); + existingTrip.addAll(tripSeineSet.getReference()); + + TripLonglineService tripLonglineService = source.newService(TripLonglineService.class); + ReferenceSetDto<TripLonglineDto> tripLonglineSet = tripLonglineService.getAllTripLongline(); + existingTrip.addAll(tripLonglineSet.getReference()); + + + getExportModel().setExistingTripIds(existingTrip); + + } protected void updateSaveLocalOperation() { boolean shouldAdd = false; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/config/ConfigUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/config/ConfigUIHandler.java index 5a00e47..8e2d1d4 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/config/ConfigUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/config/ConfigUIHandler.java @@ -145,13 +145,13 @@ public class ConfigUIHandler extends AdminTabUIHandler { sourceModel.isValid() + " / " + sourceModel.isValidStep()); } model.removeLocalSource(); - model.getLocalSourceModel().validate(StorageStep.CONFIG); + model.getLocalSourceModel().validate(); model.validate(); } public void obtainRemoteConnexion() { StorageUIModel sourceModel = ui.getCentralSourceModel(); - StorageUILauncher.obtainRemoteConnexion( + StorageUILauncher.obtainConnexion( ui, ui.getParentContainer(Window.class), sourceModel diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/config/SelectDataUI.css b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/config/SelectDataUI.css index 8b1dde3..9aef87d 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/config/SelectDataUI.css +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/config/SelectDataUI.css @@ -35,7 +35,7 @@ #selectionModel { selectionMode: {TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION}; - //dataModel:{selectDataModel}; + dataModel:{selectDataModel}; } #selectTreePane { diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/config/SelectDataUI.jaxx b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/config/SelectDataUI.jaxx index 5da08ec..d6e5b71 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/config/SelectDataUI.jaxx +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/config/SelectDataUI.jaxx @@ -33,6 +33,7 @@ fr.ird.observe.ui.tree.ObserveTreeHelper fr.ird.observe.ui.tree.DataSelectionTreeCellRenderer fr.ird.observe.ui.tree.DataSelectionTreeSelectionModel + fr.ird.observe.ui.storage.tabs.DataSelectionModel jaxx.runtime.SwingUtil @@ -46,9 +47,8 @@ <fr.ird.observe.ui.admin.AdminActionModel id='stepModel' initializer='null'/> - <!--FIXME--> - <!--<DataSelectionModel id='selectDataModel'--> - <!--initializer='getModel().getSelectionDataModel()'/>--> + <DataSelectionModel id='selectDataModel' + initializer='getModel().getSelectionDataModel()'/> <DataSelectionTreeSelectionModel id='selectionModel'/> diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/export/ExportModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/export/ExportModel.java index 8fa085f..5964f15 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/export/ExportModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/export/ExportModel.java @@ -22,6 +22,7 @@ package fr.ird.observe.ui.admin.export; import fr.ird.observe.db.ObserveSwingDataSource; +import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.longline.TripLonglineDto; import fr.ird.observe.services.dto.referential.ProgramDto; import fr.ird.observe.services.dto.seine.TripSeineDto; @@ -44,7 +45,7 @@ public class ExportModel extends AdminActionModel { protected int[] exportDataSelectedIndex; /** les ids des marées déjà existante sur la base distante lors d'un export */ - protected List<String> existingTripIds; + protected List<ReferenceDto> existingTrips; /** les données exportables */ protected List<TripEntry> data; @@ -67,20 +68,20 @@ public class ExportModel extends AdminActionModel { this.exportDataSelectedIndex = exportDataSelectedIndex; } - public List<String> getExistingTripIds() { - return existingTripIds; + public List<ReferenceDto> getExistingTrips() { + return existingTrips; } - public void setExistingTripIds(List<String> existingTripIds) { - this.existingTripIds = existingTripIds; + public void setExistingTripIds(List<ReferenceDto> existingTrips) { + this.existingTrips = existingTrips; } @Override public void destroy() { super.destroy(); - if (existingTripIds != null) { - existingTripIds.clear(); - existingTripIds = null; + if (existingTrips != null) { + existingTrips.clear(); + existingTrips = null; } exportDataSelectedIndex = null; tripSeineDecorator = null; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/export/ExportUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/export/ExportUIHandler.java index c4f72f2..806b023 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/export/ExportUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/export/ExportUIHandler.java @@ -95,7 +95,8 @@ public class ExportUIHandler extends AdminTabUIHandler { // } selectTabUI.getSelectionModel().clearSelection(); - selectTabUI.getSelectionRenderer().setExistingTripIds(model.getExportModel().getExistingTripIds()); + // FIXME +// selectTabUI.getSelectionRenderer().setExistingTripIds(model.getExportModel().getExistingTripIds()); updateSelectionModel(selectTabUI); } }); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/gps/ImportGPSUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/gps/ImportGPSUIHandler.java index c127444..d1ac289 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/gps/ImportGPSUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/gps/ImportGPSUIHandler.java @@ -21,14 +21,13 @@ */ package fr.ird.observe.ui.admin.gps; -import fr.ird.observe.ui.DecoratorService; import fr.ird.observe.business.gps.GPSPoint; import fr.ird.observe.business.gps.GPSPointInterval; import fr.ird.observe.business.gps.GPSRoute; import fr.ird.observe.db.ObserveSwingDataSource; import fr.ird.observe.services.dto.seine.ActivitySeineDto; -import fr.ird.observe.services.dto.seine.RouteDto; import fr.ird.observe.services.dto.seine.TripSeineDto; +import fr.ird.observe.ui.DecoratorService; import fr.ird.observe.ui.UIHelper; import fr.ird.observe.ui.admin.AdminStep; import fr.ird.observe.ui.admin.AdminTabUIHandler; @@ -419,10 +418,11 @@ public class ImportGPSUIHandler extends AdminTabUIHandler { gpsModel.getImportGPSMaxDelay(), gpsModel.getImportGPSMaxSpeed())); - route = getGpsService().buildRoute( - gpsModel.getImportGPSFile(), - gpsModel.getImportGPSMaxDelay(), - gpsModel.getImportGPSMaxSpeed()); + // FIXME +// route = getGpsService().buildRoute( +// gpsModel.getImportGPSFile(), +// gpsModel.getImportGPSMaxDelay(), +// gpsModel.getImportGPSMaxSpeed()); List<GPSPointInterval> acceptedInterval = route.getAcceptedInterval(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/report/ReportUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/report/ReportUIHandler.java index be16b95..ae42d5e 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/report/ReportUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/report/ReportUIHandler.java @@ -431,7 +431,7 @@ public class ReportUIHandler extends AdminTabUIHandler { DataMatrix data; try { - String mareeId = getModel().getSelectedTrip(); + IdDto mareeId = getModel().getSelectedTrip(); //FIXME // report = execute.getReport(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/validate/ValidateEntityListCellRenderer.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/validate/ValidateEntityListCellRenderer.java index b3c29f0..ae4cf28 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/validate/ValidateEntityListCellRenderer.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/validate/ValidateEntityListCellRenderer.java @@ -22,17 +22,27 @@ package fr.ird.observe.ui.admin.validate; import fr.ird.observe.ObserveSwingApplicationContext; +import fr.ird.observe.services.dto.ReferenceDto; +import fr.ird.observe.services.service.actions.validate.ValidateResultForDto; +import fr.ird.observe.services.service.actions.validate.ValidateResultForDtos; import fr.ird.observe.ui.DecoratorService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.nuiton.decorator.Decorator; +import org.nuiton.validator.NuitonValidatorScope; -import javax.swing.*; -import java.awt.*; +import javax.swing.DefaultListCellRenderer; +import javax.swing.JList; +import java.awt.Component; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; +import java.util.EnumMap; import java.util.HashMap; +import java.util.Iterator; import java.util.Map; +import static org.nuiton.i18n.I18n.t; + public class ValidateEntityListCellRenderer extends DefaultListCellRenderer implements PropertyChangeListener { private static final long serialVersionUID = 1L; @@ -66,15 +76,14 @@ public class ValidateEntityListCellRenderer extends DefaultListCellRenderer impl } synchronized (renderCache) { renderCache.clear(); - //FIXME -// if (model.getMessages() == null) { -// return; -// } - //FIXME -// for (Class<?> klass : model.getMessageTypes()) { -// String type = t(DecoratorService.getEntityLabel(klass)); -// renderCache.put(klass, type); -// } + if (model.getMessages() == null) { + return; + } + + for (Class<?> klass : model.getMessageTypes()) { + String type = t(DecoratorService.getEntityLabel(klass)); + renderCache.put(klass, type); + } } } @@ -92,54 +101,55 @@ public class ValidateEntityListCellRenderer extends DefaultListCellRenderer impl int index, boolean isSelected, boolean cellHasFocus) { - //FIXME -// if (value != null) { -// DecoratorService decoratorService = getService(); -// if (value instanceof Class<?>) { -// value = renderCache.get(value); -// } else { -// value = valueFromEntityRef(decoratorService, (TopiaEntityRef) value); -// } -// } + if (value != null) { + DecoratorService decoratorService = getService(); + if (value instanceof Class<?>) { + value = renderCache.get(value); + } else { + value = valueFromRefDto(decoratorService, (ReferenceDto) value); + } + } return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); } - //FIXME -// public Object valueFromEntityRef(DecoratorService decoratorService, -// TopiaEntityRef value) { -// String s = renderCache.get(value); -// if (s != null) { -// return s; -// } -// if (log.isDebugEnabled()) { -// log.debug("compute render cache for " + value.getRef().getTopiaId()); -// } -// List<SimpleBeanValidatorMessage<?>> messages = model.getMessages(value); -// EnumMap<NuitonValidatorScope, Integer> scopes = -// SimpleBeanValidators.getScopesCount(messages); -// StringBuilder buffer = new StringBuilder(); -// TopiaEntity entity = value.getRef(); -// Class<? extends TopiaEntity> type = -// ObserveDAOHelper.getContractClass(entity.getClass()); -// Decorator<?> decorator = decoratorService.getDecoratorByType(type); -// buffer.append(decorator.toString(entity)); -// buffer.append(" ("); -// -// Iterator<NuitonValidatorScope> itr = scopes.keySet().iterator(); -// while (itr.hasNext()) { -// NuitonValidatorScope scope = itr.next(); -// int nb = scopes.get(scope); -// String t = t(scope.getLabel()); -// buffer.append(t).append(" : ").append(nb); -// if (itr.hasNext()) { -// buffer.append(", "); -// } -// } -// buffer.append(")"); -// s = buffer.toString(); -// renderCache.put(value, s); -// return s; -// } + public Object valueFromRefDto(DecoratorService decoratorService, + ReferenceDto value) { + String s = renderCache.get(value); + if (s != null) { + return s; + } + + if (log.isDebugEnabled()) { + log.debug("compute render cache for " + value.getId()); + } + + ValidateResultForDto validateResultForDto = model.getMessages(value); + + EnumMap<NuitonValidatorScope, Integer> scopes = + ValidateResultForDtos.getScopesCount(validateResultForDto); + + StringBuilder buffer = new StringBuilder(); + + Decorator<?> decorator = decoratorService.getDecoratorByType(ReferenceDto.class, value.getType().getSimpleName()); + + buffer.append(decorator.toString(value)); + buffer.append(" ("); + + Iterator<NuitonValidatorScope> itr = scopes.keySet().iterator(); + while (itr.hasNext()) { + NuitonValidatorScope scope = itr.next(); + int nb = scopes.get(scope); + String t = t(scope.getLabel()); + buffer.append(t).append(" : ").append(nb); + if (itr.hasNext()) { + buffer.append(", "); + } + } + buffer.append(")"); + s = buffer.toString(); + renderCache.put(value, s); + return s; + } } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/validate/ValidateModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/validate/ValidateModel.java index 787b1cf..d945487 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/validate/ValidateModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/validate/ValidateModel.java @@ -21,12 +21,19 @@ */ package fr.ird.observe.ui.admin.validate; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; import fr.ird.observe.configuration.ObserveSwingApplicationConfig; -import fr.ird.observe.validation.ValidationModelMode; -import fr.ird.observe.validation.ValidationService; -import fr.ird.observe.validation.ValidatorsMap; +import fr.ird.observe.services.dto.IdDto; +import fr.ird.observe.services.dto.ReferenceDto; +import fr.ird.observe.services.service.actions.validate.ValidateResultForDto; +import fr.ird.observe.services.service.actions.validate.ValidateResultForDtoType; +import fr.ird.observe.services.service.actions.validate.ValidatorDto; +import fr.ird.observe.services.service.actions.validate.ValidatorDtos; import fr.ird.observe.ui.admin.AdminActionModel; import fr.ird.observe.ui.admin.AdminStep; +import fr.ird.observe.validation.ValidationModelMode; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.validator.NuitonValidatorScope; @@ -34,6 +41,10 @@ import org.nuiton.validator.NuitonValidatorScope; import java.io.File; import java.util.Date; import java.util.EnumSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; /** * Modele pour preparer une validation de donnees d'une base. @@ -60,8 +71,6 @@ public class ValidateModel extends AdminActionModel { /** Logger */ private static final Log log = LogFactory.getLog(ValidateModel.class); - private static final Class<?>[] EMPTY_CLASS_ARRAY = new Class<?>[0]; - /** les scopes a utiliser */ protected final EnumSet<NuitonValidatorScope> scopes; @@ -80,18 +89,19 @@ public class ValidateModel extends AdminActionModel { /** le fichier où sauvegarder les résultats de la validation */ protected File reportFile = new File(""); - /** les validateurs recuperees */ - protected ValidatorsMap validators; + /** tout les validateur de la base */ + protected ImmutableSet<ValidatorDto> allValidators; + + /** les validateurs selectionnées */ + protected Set<ValidatorDto> validators; /** le dictionnaire des paths d'entites detectees */ - //FIXME -// protected SortedMap<TopiaEntityRef, List<SimpleBeanValidatorMessage<?>>> messages; + protected Map<Class<? extends IdDto>, ValidateResultForDtoType> messages; public ValidateModel() { super(AdminStep.VALIDATE); scopes = EnumSet.noneOf(NuitonValidatorScope.class); - //FIXME -// messages = new TreeMap<TopiaEntityRef, List<SimpleBeanValidatorMessage<?>>>(); + messages = new TreeMap<Class<? extends IdDto>, ValidateResultForDtoType>(); } /** @@ -114,12 +124,6 @@ public class ValidateModel extends AdminActionModel { firePropertyChange(PROPERTY_CONTEXT_NAME, oldvalue, contextName); } - public Class<?>[] getBeanTypes() { - //FIXME -// return modelMode == null ? EMPTY_CLASS_ARRAY : modelMode.getContracts(); - return EMPTY_CLASS_ARRAY; - } - public ValidationModelMode getModelMode() { return modelMode; } @@ -166,68 +170,82 @@ public class ValidateModel extends AdminActionModel { firePropertyChange(PROPERTY_REPORT_FILE, oldValue, reportFile); } - public ValidatorsMap getValidators() { + public void setAllValidators(ImmutableSet<ValidatorDto> allValidators) { + this.allValidators = allValidators; + } + + public Set<ValidatorDto> getValidators() { if (validators == null) { - ValidationService service = new ValidationService(); - validators = populateValidators(service); + if (allValidators != null && getContextName() != null) { + validators = ValidatorDtos.filter( + allValidators, + getModelMode().isData(), + getModelMode().isReferential(), + getScopes(), + getContextName()); + } else { + validators = Sets.newHashSet(); + } + } return validators; } - //FIXME -// public SortedMap<TopiaEntityRef, List<SimpleBeanValidatorMessage<?>>> getMessages() { -// return messages; -// } - - //FIXME -// public void setMessages(SortedMap<TopiaEntityRef, List<SimpleBeanValidatorMessage<?>>> messages) { -// Object oldValue = this.messages; -// this.messages = messages; -// firePropertyChange(PROPERTY_MESSAGES, oldValue, messages); -// } - - //FIXME -// public Class<?>[] getMessageTypes() { -// if (messages == null || messages.isEmpty()) { -// return EMPTY_CLASS_ARRAY; -// } -// Set<Class<? extends TopiaEntity>> tmp = new HashSet<Class<? extends TopiaEntity>>(); -// for (TopiaEntityRef ref : messages.keySet()) { -// tmp.add(ref.getRef().getClass()); -// } -// Set<Class<? extends TopiaEntity>> result; -// result = TopiaEntityHelper.getContractClasses( -// ObserveEntityEnum.values(), -// tmp -// ); -// tmp.clear(); -// if (log.isDebugEnabled()) { -// log.debug(" = " + result); -// } -// return result.toArray(new Class<?>[result.size()]); -// } - - //FIXME -// public List<TopiaEntityRef> getMessagesEntities(Class<?> klass) { -// List<TopiaEntityRef> tmp = new ArrayList<TopiaEntityRef>(); -// if (messages != null) { -// for (TopiaEntityRef ref : messages.keySet()) { -// if (klass.isAssignableFrom(ref.getRef().getClass())) { -// tmp.add(ref); -// } -// } -// } -// return tmp; -// } - - //FIXME -// public List<SimpleBeanValidatorMessage<?>> getMessages(TopiaEntityRef ref) { -// List<SimpleBeanValidatorMessage<?>> result = null; -// if (messages != null) { -// result = messages.get(ref); -// } -// return result; -// } + public Map<Class<? extends IdDto>, ValidateResultForDtoType> getMessages() { + return messages; + } + + + public void setMessages(Map<Class<? extends IdDto>, ValidateResultForDtoType> messages) { + Object oldValue = this.messages; + this.messages = messages; + firePropertyChange(PROPERTY_MESSAGES, oldValue, messages); + } + + public Set<Class<? extends IdDto>> getMessageTypes() { + Set<Class<? extends IdDto>> result; + + if (messages != null && ! messages.isEmpty()) { + result = messages.keySet(); + } else { + result = Sets.newHashSet(); + } + + return result; + } + + public List<ReferenceDto> getMessagesDto(Class dtoType) { + + List<ReferenceDto> result = Lists.newArrayList(); + + if (messages != null) { + + ValidateResultForDtoType resultForDtoType = messages.get(dtoType); + + ImmutableSet<ValidateResultForDto> validateResultForDto = resultForDtoType.getValidateResultForDto(); + + for (ValidateResultForDto resultForDto : validateResultForDto) { + + result.add(resultForDto.getDto()); + } + } + return result; + } + + public ValidateResultForDto getMessages(ReferenceDto referenceDto) { + + ValidateResultForDto result = null; + + if (messages != null) { + + ValidateResultForDtoType resultForDtoType = messages.get(referenceDto.getType()); + + result = resultForDtoType.getValidateResult(referenceDto); + + } + + return result; + } public void addScope(NuitonValidatorScope scope) { scopes.add(scope); @@ -241,31 +259,18 @@ public class ValidateModel extends AdminActionModel { firePropertyChange(PROPERTY_SCOPES, null, scopes); } - protected ValidatorsMap populateValidators(ValidationService service) { - Class<?>[] beanclass = getBeanTypes(); - NuitonValidatorScope[] filterScopes = - scopes.toArray(new NuitonValidatorScope[scopes.size()]); - if (scopes.isEmpty()) { - // pas de scope selectionne, donc pas de validateur disponilbe - return new ValidatorsMap(); - } - - ValidatorsMap validators = service.getValidators(contextName, - filterScopes, - beanclass); - return validators; - } - @Override public void destroy() { super.destroy(); - //FIXME -// if (messages != null) { -// setMessages(null); -// } + if (messages != null) { + setMessages(null); + } if (validators != null) { - validators.clear(); validators = null; } } + + public ImmutableSet<ValidatorDto> getAllValidators() { + return allValidators; + } } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/validate/ValidateUI.jaxx b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/validate/ValidateUI.jaxx index 3783cb4..a41f85c 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/validate/ValidateUI.jaxx +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/validate/ValidateUI.jaxx @@ -31,6 +31,7 @@ fr.ird.observe.ui.admin.AdminStep fr.ird.observe.ui.admin.AdminTabUI fr.ird.observe.ui.admin.AdminUI + fr.ird.observe.ui.admin.validate.ValidationMessageTableModel jaxx.runtime.swing.wizard.ext.WizardState @@ -50,7 +51,7 @@ <DefaultListModel id='refModel'/> - <SimpleBeanValidatorMessageTableModel id='messagesModel'/> + <ValidationMessageTableModel id='messagesModel'/> <DefaultListSelectionModel id='typeSelectionModel' onValueChanged='if (!event.getValueIsAdjusting() && !typeSelectionModel.isSelectionEmpty()) { getHandler().updateSelectedType(); }'/> diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/validate/ValidateUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/validate/ValidateUIHandler.java index f9ca188..b817496 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/validate/ValidateUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/validate/ValidateUIHandler.java @@ -22,10 +22,26 @@ package fr.ird.observe.ui.admin.validate; import com.google.common.base.Charsets; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; +import com.google.common.collect.Maps; import fr.ird.observe.ObserveSwingApplicationContext; import fr.ird.observe.db.ObserveSwingDataSource; +import fr.ird.observe.services.dto.IdDto; +import fr.ird.observe.services.dto.IdDtos; +import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.referential.ProgramDto; import fr.ird.observe.services.dto.seine.TripSeineDto; +import fr.ird.observe.services.service.actions.validate.ValidateDataRequest; +import fr.ird.observe.services.service.actions.validate.ValidateDataResult; +import fr.ird.observe.services.service.actions.validate.ValidateReferentialsRequest; +import fr.ird.observe.services.service.actions.validate.ValidateReferentialsResult; +import fr.ird.observe.services.service.actions.validate.ValidateResultForDto; +import fr.ird.observe.services.service.actions.validate.ValidateResultForDtoType; +import fr.ird.observe.services.service.actions.validate.ValidateResultForDtos; +import fr.ird.observe.services.service.actions.validate.ValidateService; +import fr.ird.observe.services.service.actions.validate.ValidationMessage; +import fr.ird.observe.services.service.actions.validate.ValidatorDto; import fr.ird.observe.ui.DecoratorService; import fr.ird.observe.ui.UIHelper; import fr.ird.observe.ui.admin.AdminStep; @@ -35,36 +51,38 @@ import fr.ird.observe.ui.admin.AdminUI; import fr.ird.observe.ui.admin.AdminUIModel; import fr.ird.observe.ui.admin.config.ConfigUI; import fr.ird.observe.ui.admin.config.SelectDataUI; -import fr.ird.observe.ui.util.ObserveSimpleValidatorMessageTableRenderer; -import fr.ird.observe.validation.ValidationContext; -import fr.ird.observe.validation.ValidationMessageDetector; +import fr.ird.observe.ui.storage.tabs.DataSelectionModel; +import fr.ird.observe.ui.util.ObserveValidationMessageTableRenderer; import fr.ird.observe.validation.ValidationModelMode; -import fr.ird.observe.validation.ValidatorsMap; +import jaxx.runtime.SwingUtil; import jaxx.runtime.context.JAXXInitialContext; import jaxx.runtime.swing.wizard.ext.WizardState; -import jaxx.runtime.validator.swing.SwingValidatorUtil; import org.apache.commons.io.FileUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.decorator.Decorator; import org.nuiton.validator.NuitonValidatorScope; -import org.nuiton.validator.bean.simple.SimpleBeanValidator; -import org.nuiton.validator.bean.simple.SimpleBeanValidatorMessage; import javax.swing.ComboBoxModel; import javax.swing.DefaultComboBoxModel; import javax.swing.DefaultListModel; import javax.swing.JCheckBox; +import javax.swing.JTable; +import javax.swing.RowSorter; +import javax.swing.SortOrder; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.File; import java.io.IOException; -import java.util.ArrayList; +import java.util.Arrays; import java.util.Date; +import java.util.EnumSet; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.concurrent.Callable; +import static org.nuiton.i18n.I18n.n; import static org.nuiton.i18n.I18n.t; //import jaxx.runtime.validator.swing.SwingValidator; @@ -103,7 +121,20 @@ public class ValidateUIHandler extends AdminTabUIHandler { log.debug(" specialized for [" + tabUI.getStep() + "] for main ui " + ui.getClass().getName() + "@" + System.identityHashCode(ui)); } - SwingValidatorUtil.installUI(tabUI.getMessageTable(), new ObserveSimpleValidatorMessageTableRenderer()); + JTable messageTable = tabUI.getMessageTable(); + + messageTable.setDefaultRenderer(Object.class, new ObserveValidationMessageTableRenderer()); + messageTable.getRowSorter().setSortKeys( + Arrays.asList(new RowSorter.SortKey(0, SortOrder.ASCENDING))); + SwingUtil.setI18nTableHeaderRenderer( + messageTable, + n("validator.scope.header"), + n("validator.scope.header.tip"), + n("validator.field.header"), + n("validator.field.header.tip"), + n("validator.message.header"), + n("validator.message.header.tip")); + SwingUtil.fixTableColumnWidth(messageTable, 0, 25); ValidateEntityListCellRenderer listRenderer = new ValidateEntityListCellRenderer(tabUI.getStepModel()); @@ -132,28 +163,24 @@ public class ValidateUIHandler extends AdminTabUIHandler { // rien a faire pour le moment... return; } - //FIXME -// DataSelectionModel selectDataModel; -// selectDataModel = selectTabUI.getSelectDataModel(); + DataSelectionModel selectDataModel; + selectDataModel = selectTabUI.getSelectDataModel(); if (log.isDebugEnabled()) { log.debug("validation model changed to " + value); } switch (value) { case REFERENTIEL: - //FIXME -// selectDataModel.setUseData(false); -// selectDataModel.setUseReferentiel(true); + selectDataModel.setUseData(false); + selectDataModel.setUseReferentiel(true); break; case DATA: - //FIXME -// selectDataModel.setUseData(true); -// selectDataModel.setUseReferentiel(false); + selectDataModel.setUseData(true); + selectDataModel.setUseReferentiel(false); break; case ALL: - //FIXME -// selectDataModel.setUseData(true); -// selectDataModel.setUseReferentiel(true); + selectDataModel.setUseData(true); + selectDataModel.setUseReferentiel(true); break; } //updateModel(); @@ -168,14 +195,19 @@ public class ValidateUIHandler extends AdminTabUIHandler { // avoid multi-cast return; } - //FIXME -// DataSelectionModel value = (DataSelectionModel) evt.getNewValue(); -// if (log.isInfoEnabled()) { -// log.info("selection model changed to " + value); -// } + DataSelectionModel value = (DataSelectionModel) evt.getNewValue(); + if (log.isInfoEnabled()) { + log.info("selection model changed to " + value); + } updateSelectionModel(selectTabUI); } }); + + ImmutableSet<ValidatorDto> validators = ObserveSwingApplicationContext.get().getValidators(); + + ValidateModel stepModel = model.getValidateModel(); + + stepModel.setAllValidators(validators); } public void updateState(ValidateUI tabUI, WizardState newState) { @@ -201,10 +233,6 @@ public class ValidateUIHandler extends AdminTabUIHandler { tabUI.typeModel.clear(); tabUI.refModel.clear(); tabUI.messagesModel.clear(); - tabUI.messagesModel.clearValidators(); - for (SimpleBeanValidator<?> v : tabUI.getStepModel().getValidators().values()) { - tabUI.messagesModel.registerValidator((SimpleBeanValidator<?>) v); - } } if (newState == WizardState.SUCCESSED) { } @@ -217,12 +245,17 @@ public class ValidateUIHandler extends AdminTabUIHandler { DefaultListModel typeModel = tabUI.typeModel; tabUI.typeSelectionModel.clearSelection(); typeModel.clear(); - //FIXME -// Class<?>[] classes = tabUI.getStepModel().getMessageTypes(); -// classes = getDecoratorService().sortTypes(classes); -// for (Class<?> e : classes) { -// typeModel.addElement(e); -// } + + Set<Class<? extends IdDto>> messageTypes = tabUI.getStepModel().getMessageTypes(); + + List<Class<? extends IdDto>> classes = getDecoratorService().sortTypes(messageTypes); + + for (Class<? extends IdDto> e : classes) { + + typeModel.addElement(e); + + } + tabUI.typeList.setSelectedIndex(0); } @@ -233,29 +266,32 @@ public class ValidateUIHandler extends AdminTabUIHandler { getModel().setBusy(true); // on nettoye le modele des refs - tabUI.refSelectionModel.clearSelection(); - tabUI.refModel.clear(); + try { + tabUI.refSelectionModel.clearSelection(); + tabUI.refModel.clear(); - Object o = tabUI.typeList.getSelectedValue(); - if (log.isInfoEnabled()) { - log.info("new selected type = " + o); - } - if (o == null) { - return; + Object o = tabUI.typeList.getSelectedValue(); + if (log.isInfoEnabled()) { + log.info("new selected type = " + o); + } + if (o == null) { + return; + } + + Class<?> type = (Class<?>) o; + + List<ReferenceDto> refs = tabUI.getStepModel().getMessagesDto(type); + for (ReferenceDto ref : Iterables.limit(refs, 100)) { + if (log.isDebugEnabled()) { + log.debug("add ref = " + ref); + } + tabUI.refModel.addElement(ref); + } + tabUI.refList.setSelectedIndex(0); + } finally { + getModel().setBusy(false); } - Class<?> type = (Class<?>) o; - - //FIXME -// List<TopiaEntityRef> refs = tabUI.getStepModel().getMessagesEntities(type); -// for (TopiaEntityRef ref : refs) { -// if (log.isDebugEnabled()) { -// log.debug("add ref = " + ref); -// } -// tabUI.refModel.addElement(ref); -// } - tabUI.refList.setSelectedIndex(0); - getModel().setBusy(false); } public void updateSelectedRef() { @@ -277,23 +313,19 @@ public class ValidateUIHandler extends AdminTabUIHandler { return; } - //FIXME -// TopiaEntityRef ref = (TopiaEntityRef) o; -// -// if (log.isDebugEnabled()) { -// log.debug(ref.getAccessorExpression()); -// } -// -// for (SimpleBeanValidatorMessage<?> m : tabUI.getStepModel().getMessages(ref)) { -// SimpleBeanValidatorEvent evt = new SimpleBeanValidatorEvent( -// m.getValidator(), -// m.getField(), -// m.getScope(), -// new String[]{m.getMessage()}, -// EMPTY_STRING_ARRAY -// ); -// tabUI.messagesModel.onFieldChanged(evt); -// } + ReferenceDto ref = (ReferenceDto) o; + + if (log.isDebugEnabled()) { + log.debug(ref); + } + + ValidateResultForDto resultForDto = tabUI.getStepModel().getMessages(ref); + + ImmutableSet<ValidationMessage> messages = resultForDto.getMessages(); + + tabUI.messagesModel.setMessages(messages); + + } public void startAction() { @@ -323,19 +355,17 @@ public class ValidateUIHandler extends AdminTabUIHandler { launchValidation(); - //FIXME -// SortedMap<TopiaEntityRef, List<SimpleBeanValidatorMessage<?>>> refs = -// model.getValidateModel().getMessages(); -// if (refs == null || refs.isEmpty()) { -// -// // pas de validation ou bien pas d'erreurs rencontrées -// -// sendMessage(t("observe.message.validation.nothing.to.do")); -// sendMessage( -// t("observe.message.validation.operation.done", new Date())); -// -// return WizardState.SUCCESSED; -// } + Map<Class<? extends IdDto>, ValidateResultForDtoType> messages = model.getValidateModel().getMessages(); + if (messages == null || messages.isEmpty()) { + + // pas de validation ou bien pas d'erreurs rencontrées + + sendMessage(t("observe.message.validation.nothing.to.do")); + sendMessage( + t("observe.message.validation.operation.done", new Date())); + + return WizardState.SUCCESSED; + } sendMessage( t("observe.message.validation.operation.needFix", new Date())); @@ -360,7 +390,7 @@ public class ValidateUIHandler extends AdminTabUIHandler { // recuperation des validateurs du modele ValidateModel validationModel = model.getValidateModel(); - ValidatorsMap validators = validationModel.getValidators(); + Set<ValidatorDto> validators = validationModel.getValidators(); sendMessage(t("observe.message.validation.use.storage", source.getLabel())); @@ -371,8 +401,8 @@ public class ValidateUIHandler extends AdminTabUIHandler { // des validateurs ont été trouvés - for (SimpleBeanValidator<?> v : validators.values()) { - String label = t(DecoratorService.getEntityLabel(v.getType())); + for (ValidatorDto v : validators) { + String label = t(DecoratorService.getEntityLabel(v.getDtoType())); sendMessage(t("observe.message.validation.detected", label)); } } else { @@ -386,85 +416,53 @@ public class ValidateUIHandler extends AdminTabUIHandler { // on vide les anciens messages ValidateModel stepModel = model.getValidateModel(); - //FIXME -// stepModel.setMessages(null); - - ValidatorsMap validators = stepModel.getValidators(); - - ValidationMessageDetector detector = - new ValidationMessageDetector(validators); - - //FIXME -// DataSelectionModel dataModel = model.getSelectionDataModel(); - ObserveSwingApplicationContext applicationContext = ObserveSwingApplicationContext.get(); - ValidationContext context = applicationContext.getValidationContext(); - //FIXME -// context.setDataSource(model.getLocalSource()); -// context.setDataContext(model.getDataService().getDataContext()); - - //FIXME -// TopiaContext ctxt = beginTransaction(source, "launchValidation"); -// try { -// -// -// if (dataModel.isUseReferentiel()) { -// -// // validation des referentiels selectionnes -// -// validateReferentiel(detector, ctxt, dataModel); -// } -// -// if (dataModel.isUseData()) { -// -// // validation des donnees observateur selectionnee -// -// validateData(detector, ctxt, dataModel); -// } -// -// } finally { -// context.setDataSource(null); -// SortedMap<TopiaEntityRef, List<SimpleBeanValidatorMessage<?>>> refs = detector.getRefs(); -// stepModel.setMessages(refs); -// detector.clear(); -// closeTransaction(source, ctxt, "launchValidation"); -// } - } + stepModel.setMessages(null); + + DataSelectionModel dataModel = model.getSelectionDataModel(); - //FIXME -// private void validateData(ValidationMessageDetector detector, -// TopiaContext ctxt, -// DataSelectionModel dataModel) throws TopiaException { -// Set<String> data = dataModel.getSelectedData(); -// -// for (String id : data) { -// Trip e = (Trip) ctxt.findByTopiaId(id); -// Program p = e.getProgram(); -// sendMessage(t("observe.message.validation.start.maree", dTrip.toString(e), dProgram.toString(p))); -// detector.detectMessages(e); -// } -// } - - //FIXME -// protected void validateReferentiel(ValidationMessageDetector detector, -// TopiaContext ctxt, -// DataSelectionModel dataModel), TopiaException { -// -// DataService dataService = getDataService(); -// Set<Class<?>> classes = dataModel.getSelectedReferentiel(); -// -// for (Class<?> klass : classes) { -// // on recupere la liste des ids a valider -// Class<? extends TopiaEntity> refClass = (Class<? extends TopiaEntity>) klass; -// List<String> ids = dataService.getEntityIds(source, refClass); -// String entityLabel = t(DecoratorService.getEntityLabel(klass)); -// sendMessage(t("observe.message.validation.start.referentiel", entityLabel, ids.size())); -// for (String id : ids) { -// TopiaEntity e = ctxt.findByTopiaId(id); -// detector.detectMessages(e); -// } -// ids.clear(); -// } -// } + ObserveSwingDataSource dataSourceToValidate = model.getLocalSource(); + + if (! dataSourceToValidate.isOpen()) { + dataSourceToValidate.open(); + } + + ValidateService validateService = dataSourceToValidate.newService(ValidateService.class); + + Map<Class<? extends IdDto>, ValidateResultForDtoType> messages = Maps.newHashMap(); + + if (dataModel.isUseReferentiel()) { + + // validation des referentiels selectionnes + ValidateReferentialsRequest request = new ValidateReferentialsRequest(); + + request.setReferentialTypes(ImmutableSet.copyOf(dataModel.getSelectedReferentiel())); + request.setScopes(ImmutableSet.copyOf(stepModel.getScopes())); + request.setValidationContext(stepModel.getContextName()); + + ValidateReferentialsResult result = validateService.validateReferentials(request); + + messages.putAll(result.getResultByType()); + } + + if (dataModel.isUseData()) { + + // validation des donnees observateur selectionnee + ValidateDataRequest request = new ValidateDataRequest(); + + request.setDataIds(ImmutableSet.copyOf(Iterables.transform(dataModel.getSelectedData(), IdDtos.getIdFunction()))); + request.setScopes(ImmutableSet.copyOf(stepModel.getScopes())); + request.setValidationContext(stepModel.getContextName()); + + ValidateDataResult result = validateService.validateData(request); + + messages.putAll(result.getResultByType()); + } + + dataSourceToValidate.close(); + + stepModel.setMessages(messages); + + } public void saveReport() { WizardState finalState = null; @@ -498,30 +496,46 @@ public class ValidateUIHandler extends AdminTabUIHandler { DecoratorService service = getDecoratorService(); StringBuilder builder = new StringBuilder(); builder.append(LINE).append('\n'); + builder.append(t("observe.validation.report.title", new Date())).append('\n'); builder.append(t("observe.validation.report.scopes", validationModel.getScopes())).append('\n'); builder.append(t("observe.validation.report.contextName", validationModel.getContextName())).append('\n'); - //FIXME -// SortedMap<TopiaEntityRef, List<SimpleBeanValidatorMessage<?>>> messages = -// validationModel.getMessages(); -// builder.append(t("observe.validation.report.entities.with.messages", messages.size())).append('\n'); -// builder.append(LINE).append('\n').append('\n'); -// for (Map.Entry<TopiaEntityRef, List<SimpleBeanValidatorMessage<?>>> entry : messages.entrySet()) { -// TopiaEntityRef ref = entry.getKey(); -// String refStr = service.decorate(ref.getRef()); -// List<SimpleBeanValidatorMessage<?>> refMessages = entry.getValue(); -// EnumSet<NuitonValidatorScope> scopes = -// SimpleBeanValidators.getScopes(refMessages); -// builder.append(t("observe.validation.report.entity", ref.getRef().getTopiaId(), refStr, refMessages.size(), scopes)).append('\n'); -// for (NuitonValidatorScope scope : scopes) { -// List<SimpleBeanValidatorMessage<?>> messagesByScope = filterMessages(scope, refMessages); -// for (SimpleBeanValidatorMessage<?> message : messagesByScope) { -// builder.append(message).append('\n'); -// } -// builder.append('\n'); -// } -// builder.append(LINE).append('\n').append('\n'); -// } + + Map<Class<? extends IdDto>, ValidateResultForDtoType> messages = validationModel.getMessages(); + + builder.append(t("observe.validation.report.entities.with.messages", messages.size())).append('\n'); + builder.append(LINE).append('\n').append('\n'); + + for (ValidateResultForDtoType validateResultForDtoType : messages.values()) { + + ImmutableSet<ValidateResultForDto> validateResultForDtos = validateResultForDtoType.getValidateResultForDto(); + for (ValidateResultForDto validateResultForDto : validateResultForDtos) { + + ReferenceDto referenceDto = validateResultForDto.getDto(); + + String refStr = service.decorate(referenceDto); + + Set<ValidationMessage> refMessages = validateResultForDto.getMessages(); + + EnumSet<NuitonValidatorScope> scopes = ValidateResultForDtos.getScopes(validateResultForDto); + + builder.append(t("observe.validation.report.entity", referenceDto.getId(), refStr, refMessages.size(), scopes)).append('\n'); + for (NuitonValidatorScope scope : scopes) { + + List<ValidationMessage> messagesByScope = ValidateResultForDtos.scopeMessageFilter(scope, validateResultForDto); + + for (ValidationMessage message : messagesByScope) { + + builder.append(message).append('\n'); + + } + + builder.append('\n'); + } + + } + builder.append(LINE).append('\n').append('\n'); + } String content = builder.toString(); if (log.isInfoEnabled()) { @@ -530,15 +544,7 @@ public class ValidateUIHandler extends AdminTabUIHandler { FileUtils.write(reportFile, content, Charsets.UTF_8.name()); } - private List<SimpleBeanValidatorMessage<?>> filterMessages(NuitonValidatorScope scope, List<SimpleBeanValidatorMessage<?>> refMessages) { - List<SimpleBeanValidatorMessage<?>> result = new ArrayList<SimpleBeanValidatorMessage<?>>(); - for (SimpleBeanValidatorMessage<?> message : refMessages) { - if (message.getScope().equals(scope)) { - result.add(message); - } - } - return result; - } + // ------------------------------------------------------------------------ // -- ValidateConfgUI methods @@ -567,7 +573,7 @@ public class ValidateUIHandler extends AdminTabUIHandler { ValidateModel validateModel = getModel().getValidateModel(); - if (validateModel == null || validateModel.getValidators() == null) { + if (validateModel == null) { return null; } return t("observe.common.selected.validators", validateModel.getValidators().size()); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/validate/ValidationMessageTableModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/validate/ValidationMessageTableModel.java new file mode 100644 index 0000000..59904b1 --- /dev/null +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/validate/ValidationMessageTableModel.java @@ -0,0 +1,90 @@ +package fr.ird.observe.ui.admin.validate; + +import com.google.common.collect.Lists; +import fr.ird.observe.services.service.actions.validate.ValidationMessage; +import jaxx.runtime.SwingUtil; +import org.nuiton.validator.NuitonValidatorScope; + +import javax.swing.table.AbstractTableModel; +import java.util.Collection; +import java.util.List; + +/** + * @author Sylvain Bavencoff - bavencoff@codelutin.com + */ +public class ValidationMessageTableModel extends AbstractTableModel { + + public static final String[] columnNames = + {"validator.scope", "validator.field", "validator.message"}; + + public static final Class<?>[] columnClasses = + {NuitonValidatorScope.class, String.class, String.class}; + + protected List<ValidationMessage> messages = Lists.newArrayList(); + + @Override + public int getRowCount() { + return messages.size(); + } + + @Override + public int getColumnCount() { + return columnNames.length; + } + + @Override + public boolean isCellEditable(int row, int column) { + // cells are never editable in this model + return false; + } + + @Override + public Class<?> getColumnClass(int columnIndex) { + SwingUtil.ensureColumnIndex(this, columnIndex); + return columnClasses[columnIndex]; + } + + @Override + public String getColumnName(int column) { + SwingUtil.ensureColumnIndex(this, column); + return columnNames[column]; + } + + @Override + public Object getValueAt(int rowIndex, int columnIndex) { + + ValidationMessage message = messages.get(rowIndex); + + Object value; + + switch (columnIndex) { + case 0: + value = message.getScope(); + break; + case 1: + value = message.getFieldName(); + break; + case 2: + value = message.getMessage(); + default: + value = null; + } + + return value; + } + + public void setMessages(Collection<ValidationMessage> messages) { + this.messages.clear(); + this.messages.addAll(messages); + fireTableDataChanged(); + } + + public void clear() { + messages.clear(); + fireTableDataChanged(); + } + + public ValidationMessage getRow(int row) { + return messages.get(row); + } +} diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/ReferentialContentUIInitializer.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/ReferentialContentUIInitializer.java index 1c43310..9e835ba 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/ReferentialContentUIInitializer.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/ReferentialContentUIInitializer.java @@ -111,7 +111,7 @@ public class ReferentialContentUIInitializer<E extends ReferentialDto, UI extend // Attention ici on charge les references avec aussi les données techniques // On en a besoin pour l'écran justement des informations techniques d'une entité en cours d'édition - ReferenceSetDto referentialReferenceSet = getReferentialService().getReferentialReferenceSet(dtoClass, true); + ReferenceSetDto referentialReferenceSet = getReferentialService().getReferentialReferenceSetWithTechnicalInformations(dtoClass); List<ReferenceDto> data = new ArrayList<>(referentialReferenceSet.getReference()); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageBackupUILauncher.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageBackupUILauncher.java index 2d9bbab..6b7a30d 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageBackupUILauncher.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageBackupUILauncher.java @@ -25,6 +25,7 @@ import fr.ird.observe.ObserveSwingApplicationContext; import fr.ird.observe.db.ObserveSwingDataSource; import fr.ird.observe.db.constantes.DbMode; import fr.ird.observe.services.dto.IdDto; +import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.ui.storage.tabs.DataSelectionModel; import jaxx.runtime.JAXXContext; import org.apache.commons.logging.Log; @@ -106,7 +107,7 @@ public class StorageBackupUILauncher extends StorageUILauncher { File backupFile = storageModel.getBackupFile(); DataSelectionModel dataModel = storageModel.getSelectDataModel(); - Set<IdDto> marees = null; + Set<ReferenceDto> marees = null; if (dataModel != null && !dataModel.isDataFull()) { // on renseigne les marees a exporter uniquement si // on en a selectionner, de plus si on a selectionne diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIHandler.java index 60fbf74..923eaa3 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIHandler.java @@ -41,9 +41,9 @@ import fr.ird.observe.services.configuration.ObserveDataSourceConfigurationTopia import fr.ird.observe.services.configuration.ObserveDataSourceConfigurationTopiaPG; import fr.ird.observe.services.configuration.ObserveDataSourceInformation; import fr.ird.observe.services.dto.DataSourceCreateConfigurationDto; -import fr.ird.observe.services.dto.IdDto; import fr.ird.observe.services.dto.IdDtos; import fr.ird.observe.services.dto.ObserveDbUserDto; +import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.service.BabModelVersionException; import fr.ird.observe.services.service.DataSourceDumpProducerService; import fr.ird.observe.services.service.DatabaseConnexionNotAuthorizedException; @@ -633,7 +633,7 @@ public class StorageUIHandler { */ public void backupLocalDatabase(ObserveSwingDataSource dataSource, File dst, - Set<IdDto> trips) { + Set<ReferenceDto> trips) { DataSourceDumpProducerService dumpService = dataSource.newService(DataSourceDumpProducerService.class); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIModel.java index b82e454..6e89831 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIModel.java @@ -249,6 +249,8 @@ public class StorageUIModel extends WizardModel<StorageStep> { ObserveSwingApplicationContext applicationContext = ObserveSwingApplicationContext.get(); ObserveDataSourceConfigurationMainFactory configurationMainFactory = applicationContext.getObserveDataSourceConfigurationMainFactory(); + Version modelVersion = applicationContext.getConfig().getModelVersion(); + h2Config = configurationMainFactory.createObserveDataSourceConfigurationTopiaH2( t("observe.storage.label.local"), null, @@ -257,7 +259,7 @@ public class StorageUIModel extends WizardModel<StorageStep> { EMPTY_PASSWORD, false, false, - null + modelVersion ); pgConfig = configurationMainFactory.createObserveDataSourceConfigurationTopiaPG( @@ -268,7 +270,7 @@ public class StorageUIModel extends WizardModel<StorageStep> { false, false, false, - null + modelVersion ); restConfig = configurationMainFactory.createObserveDataSourceConfigurationRest( @@ -277,7 +279,7 @@ public class StorageUIModel extends WizardModel<StorageStep> { "", EMPTY_PASSWORD, null, - null + modelVersion ); PropertyChangeListener clearStatus = new PropertyChangeListener() { @@ -1611,7 +1613,6 @@ public class StorageUIModel extends WizardModel<StorageStep> { protected void copyTo(StorageUIModel dst) { dst.setLocalStorageExist(isLocalStorageExist()); - dst.setDbMode(getDbMode()); dst.setBackupFile(getBackupFile()); dst.setDoBackup(isDoBackup()); dst.setStoreRemoteConfig(isStoreRemoteConfig()); @@ -1623,9 +1624,11 @@ public class StorageUIModel extends WizardModel<StorageStep> { dst.fromStorageConfig(h2Config); dst.fromStorageConfig(pgConfig); dst.fromStorageConfig(restConfig); + dst.setDbMode(getDbMode()); dst.setSelectDataModel(getSelectDataModel()); dst.setSecurityModel(getSecurityModel()); dst.setAdminAction(getAdminAction()); + dst.setConnexionStatus(getConnexionStatus()); } public void firePgConfigChanged(String propertyName, diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/tabs/DataSelectionModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/tabs/DataSelectionModel.java index 354003c..4035f41 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/tabs/DataSelectionModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/tabs/DataSelectionModel.java @@ -21,18 +21,22 @@ */ package fr.ird.observe.ui.storage.tabs; +import com.google.common.base.Optional; import com.google.common.base.Preconditions; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import fr.ird.observe.db.ObserveSwingDataSource; -import fr.ird.observe.services.dto.IdDto; +import fr.ird.observe.services.dto.IdDtos; import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.ReferenceSetDto; +import fr.ird.observe.services.dto.longline.TripLonglineDto; 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.seine.TripSeineDto; import fr.ird.observe.services.service.ReferentialService; import fr.ird.observe.services.service.longline.TripLonglineService; import fr.ird.observe.services.service.seine.TripSeineService; @@ -43,6 +47,7 @@ import org.apache.commons.logging.LogFactory; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import java.io.Serializable; +import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; @@ -77,11 +82,13 @@ public class DataSelectionModel implements Serializable { if (ProgramDtos.isProgramSeine(program)) { - referenceDtos.addAll(tripSeineService.getTripSeineByProgram(program.getId()).getReference()); + ReferenceSetDto<TripSeineDto> tripSeineRef = tripSeineService.getTripSeineByProgram(program.getId()); + referenceDtos.addAll(tripSeineRef.getReference()); } else if (ProgramDtos.isProgramLongline(program)) { - referenceDtos.addAll(tripLonglineService.getTripLonglineByProgram(program.getId()).getReference()); + ReferenceSetDto<TripLonglineDto> tripLonglineRef = tripLonglineService.getTripLonglineByProgram(program.getId()); + referenceDtos.addAll(tripLonglineRef.getReference()); } @@ -139,7 +146,7 @@ public class DataSelectionModel implements Serializable { protected transient Map<ReferenceDto<ProgramDto>, List<ReferenceDto>> datas; /** la liste des marees selectionnee */ - protected transient Set<IdDto> selectedData; + protected transient Set<ReferenceDto> selectedData; /** la liste des referentiels possibles */ protected final Set<Class<? extends ReferentialDto>> referentiel; @@ -220,30 +227,30 @@ public class DataSelectionModel implements Serializable { return datas; } - public Set<IdDto> getSelectedData() { + public Set<ReferenceDto> getSelectedData() { if (selectedData == null) { selectedData = Sets.newHashSet(); } return selectedData; } - public Map<ReferenceDto<ProgramDto>, List<IdDto>> getSelectedDataByProgram() { + public Map<ReferenceDto<ProgramDto>, List<ReferenceDto>> getSelectedDataByProgram() { if (datas == null || selectedData == null || selectedData.isEmpty()) { return Collections.emptyMap(); } - Map<ReferenceDto<ProgramDto>, List<IdDto>> result = Maps.newHashMap(); + Map<ReferenceDto<ProgramDto>, List<ReferenceDto>> result = Maps.newHashMap(); - for (IdDto idDto : selectedData) { + for (ReferenceDto referenceDto : selectedData) { // on recherche son program for (ReferenceDto<ProgramDto> p : datas.keySet()) { - if (datas.get(p).contains(idDto)) { - List<IdDto> idDtos = result.get(p); - if (idDtos == null) { - idDtos = Lists.newArrayList(); - result.put(p, idDtos); + if (datas.get(p).contains(referenceDto)) { + List<ReferenceDto> referenceDtos = result.get(p); + if (referenceDtos == null) { + referenceDtos = Lists.newArrayList(); + result.put(p, referenceDtos); } - idDtos.add(idDto); + referenceDtos.add(referenceDto); break; } } @@ -251,16 +258,16 @@ public class DataSelectionModel implements Serializable { return result; } - public boolean isSelectedData(IdDto idDto) { + public boolean isSelectedData(ReferenceDto referenceDto) { boolean result; - if (idDto instanceof ReferenceDto) { + if (ProgramDto.class.isAssignableFrom(referenceDto.getType())) { - List<ReferenceDto> trips = datas.get(idDto); + List<ReferenceDto> trips = datas.get(referenceDto); result = ! CollectionUtils.isEmpty(trips); - for (IdDto trip : trips) { + for (ReferenceDto trip : trips) { if (!getSelectedData().contains(trip)) { // au moins une marée non sélectionnée @@ -271,7 +278,7 @@ public class DataSelectionModel implements Serializable { } else { // recherche directe sur les ids de marees - result = getSelectedData().contains(idDto); + result = getSelectedData().contains(referenceDto); } @@ -335,6 +342,20 @@ public class DataSelectionModel implements Serializable { firePropertyChange(PROPERTY_SELECTED_REFERENTIEL, selectedReferentiel); } + public boolean isReferentielSelectAll(Collection<Class<? extends ReferentialDto>> classes) { + return selectedReferentiel.containsAll(classes); + } + + public void removeAllReferentiel(Collection<Class<? extends ReferentialDto>> classes) { + selectedReferentiel.removeAll(classes); + firePropertyChange(PROPERTY_SELECTED_REFERENTIEL, selectedReferentiel); + } + + public void addAllReferentiel(Collection<Class<? extends ReferentialDto>> classes) { + selectedReferentiel.addAll(classes); + firePropertyChange(PROPERTY_SELECTED_REFERENTIEL, selectedReferentiel); + } + public void setDatas(Map<ReferenceDto<ProgramDto>, List<ReferenceDto>> datas) { this.datas = datas; @@ -354,23 +375,23 @@ public class DataSelectionModel implements Serializable { firePropertyChange(PROPERTY_DATAS, datas); } - public void addSelectedData(IdDto idDto) { + public void addSelectedData(ReferenceDto referenceDto) { - if (idDto instanceof ReferenceDto) { + if (ProgramDto.class.isAssignableFrom(referenceDto.getType())) { // ajout de toutes les marées du program if (log.isDebugEnabled()) { - log.debug("Add all trips of program " + idDto.getId()); + log.debug("Add all trips of program " + referenceDto.getId()); } - getSelectedData().addAll(datas.get(idDto)); + getSelectedData().addAll(datas.get(referenceDto)); } else { // ajout d'une marée if (log.isDebugEnabled()) { - log.debug("Add Trip " + idDto.getId()); + log.debug("Add Trip " + referenceDto.getId()); } - getSelectedData().add(idDto); + getSelectedData().add(referenceDto); } firePropertyChange(PROPERTY_SELECTED_DATA, selectedData); } @@ -385,23 +406,23 @@ public class DataSelectionModel implements Serializable { firePropertyChange(PROPERTY_SELECTED_DATA, selectedData); } - public void removeSelectedData(IdDto idDto) { + public void removeSelectedData(ReferenceDto referenceDto) { - if (idDto instanceof ReferenceDto) { + if (ProgramDto.class.isAssignableFrom(referenceDto.getType())) { // ajout de toutes les marées du program if (log.isDebugEnabled()) { - log.debug("Remove all marees of program " + idDto); + log.debug("Remove all marees of program " + referenceDto); } - getSelectedData().removeAll(datas.get(idDto)); + getSelectedData().removeAll(datas.get(referenceDto)); } else { // ajout d'une marée if (log.isDebugEnabled()) { - log.debug("Remove maree " + idDto); + log.debug("Remove maree " + referenceDto); } - getSelectedData().remove(idDto); + getSelectedData().remove(referenceDto); } firePropertyChange(PROPERTY_SELECTED_DATA, selectedData); } @@ -463,4 +484,22 @@ public class DataSelectionModel implements Serializable { super.finalize(); destroy(); } + + public List<ReferenceDto> getDatas(String programId) { + Optional<ReferenceDto<ProgramDto>> programRefOptional = Iterables.tryFind(getDatas().keySet(), IdDtos.newIdPredicate(programId)); + + List<ReferenceDto> result; + + if (programRefOptional.isPresent()) { + + result = getDatas().get(programRefOptional.get()); + + } else { + + result = Collections.emptyList(); + + } + + return result; + } } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/DataSelectionTreeSelectionModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/DataSelectionTreeSelectionModel.java index 182a665..939df02 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/DataSelectionTreeSelectionModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/DataSelectionTreeSelectionModel.java @@ -21,14 +21,16 @@ */ package fr.ird.observe.ui.tree; -import fr.ird.observe.business.db.model.DataSelectionModel; +import com.google.common.collect.Sets; +import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.referential.ProgramDto; import fr.ird.observe.services.dto.referential.ReferentialDto; import fr.ird.observe.services.dto.seine.TripSeineDto; +import fr.ird.observe.ui.storage.tabs.DataSelectionModel; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import javax.swing.*; +import javax.swing.JTree; import javax.swing.event.EventListenerList; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; @@ -171,12 +173,12 @@ public class DataSelectionTreeSelectionModel implements TreeSelectionModel, Prop universe.add(path); if (log.isDebugEnabled()) { log.debug("add new path to universe " + - path.getLastPathComponent()); + path.getLastPathComponent()); } if (!referentiel && ProgramDto.class.equals(internalClass)) { if (log.isDebugEnabled()) { log.debug("Adding program childs path (" + - node.getChildCount() + ")"); + node.getChildCount() + ")"); } // on ajoute toutes les marees du program Enumeration<?> childs = node.children(); @@ -200,7 +202,7 @@ public class DataSelectionTreeSelectionModel implements TreeSelectionModel, Prop ObserveNode parentNode = node.getParent(); if (log.isDebugEnabled()) { log.debug("Adding program with his childs (" + - parentNode.getChildCount() + ")"); + parentNode.getChildCount() + ")"); } Enumeration<?> childs = parentNode.children(); while (childs.hasMoreElements()) { @@ -224,16 +226,23 @@ public class DataSelectionTreeSelectionModel implements TreeSelectionModel, Prop } if (referentiel && node.isStringNode()) { + + Set<Class<? extends ReferentialDto>> subClasses = Sets.newHashSet(); + + for (Enumeration<ObserveNode> children = node.children(); children.hasMoreElements();) { + subClasses.add((Class<? extends ReferentialDto>) children.nextElement().getInternalClass()); + } + if (pathSelected) { if (log.isDebugEnabled()) { - log.debug("Will remove all referentiels"); + log.debug("Will remove all referentiels on " + node); } - dataModel.removeAllSelectedReferentiel(); + dataModel.removeAllReferentiel(subClasses); } else { if (log.isDebugEnabled()) { - log.debug("Will add all referentiels"); + log.debug("Will add all referentiels on " + node); } - dataModel.addAllSelectedReferentiel(); + dataModel.addAllReferentiel(subClasses); } return; } @@ -254,20 +263,22 @@ public class DataSelectionTreeSelectionModel implements TreeSelectionModel, Prop return; } - String id = node.getId(); - if (log.isDebugEnabled()) { - log.debug("bean " + id); - } - if (pathSelected) { + if (node instanceof DtoNodeSupport) { + ReferenceDto dto = ((DtoNodeSupport) node).getEntity(); if (log.isDebugEnabled()) { - log.debug("Already add ? remove it."); + log.debug("bean " + dto.getId()); } - removeFromDataModel(id); - } else { - if (log.isDebugEnabled()) { - log.debug("Will add selection to model"); + if (pathSelected) { + if (log.isDebugEnabled()) { + log.debug("Already add ? remove it."); + } + removeFromDataModel(dto); + } else { + if (log.isDebugEnabled()) { + log.debug("Will add selection to model"); + } + addToDataModel(dto); } - addToDataModel(id); } } @@ -322,7 +333,13 @@ public class DataSelectionTreeSelectionModel implements TreeSelectionModel, Prop Class<?> internalClass = node.getInternalClass(); if (node.isReferentielNode() && node.isStringNode()) { - boolean result = dataModel.isReferentielFull(); + Set<Class<? extends ReferentialDto>> subClasses = Sets.newHashSet(); + + for (Enumeration<ObserveNode> children = node.children(); children.hasMoreElements();) { + subClasses.add((Class<? extends ReferentialDto>) children.nextElement().getInternalClass()); + } + + boolean result = dataModel.isReferentielSelectAll(subClasses); if (log.isTraceEnabled()) { log.trace("selectModel use full referentiel " + internalClass + " ? " + result); @@ -342,11 +359,15 @@ public class DataSelectionTreeSelectionModel implements TreeSelectionModel, Prop log.trace("begin data node " + node); } - boolean result = dataModel.isSelectedData(node.getId()); - if (log.isTraceEnabled()) { - log.trace("selectModel contains the program ? " + result); + if (node instanceof DtoNodeSupport) { + boolean result = dataModel.isSelectedData(((DtoNodeSupport) node).getEntity()); + if (log.isTraceEnabled()) { + log.trace("selectModel contains the program ? " + result); + } + return result; } - return result; + + } return false; @@ -583,20 +604,20 @@ public class DataSelectionTreeSelectionModel implements TreeSelectionModel, Prop } } - protected void addToDataModel(String id) { + protected void addToDataModel(ReferenceDto dto) { if (log.isTraceEnabled()) { - log.trace("selectModel add " + id); + log.trace("selectModel add " + dto.getId()); } - dataModel.addSelectedData(id); + dataModel.addSelectedData(dto); } - protected void removeFromDataModel(String id) { + protected void removeFromDataModel(ReferenceDto dto) { if (log.isTraceEnabled()) { - log.trace("selectModel remove " + id); + log.trace("selectModel remove " + dto.getId()); } - dataModel.removeSelectedData(id); + dataModel.removeSelectedData(dto); } @Override diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/ObserveDataProvider.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/ObserveDataProvider.java index 96d76f2..9a21479 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/ObserveDataProvider.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/ObserveDataProvider.java @@ -21,8 +21,8 @@ */ package fr.ird.observe.ui.tree; -import fr.ird.observe.business.db.model.DataSelectionModel; import fr.ird.observe.db.ObserveSwingDataSource; +import fr.ird.observe.ui.storage.tabs.DataSelectionModel; import jaxx.runtime.swing.nav.NavDataProvider; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -40,9 +40,6 @@ public class ObserveDataProvider implements NavDataProvider { protected ObserveSwingDataSource dataSource; - //FIXME -// protected DataService dataService; - protected DataSelectionModel selectionModel; private boolean creating; @@ -64,8 +61,7 @@ public class ObserveDataProvider implements NavDataProvider { @Override public boolean isEnabled() { - //FIXME - return dataSource != null && dataSource.isOpen();// || selectionModel != null; + return dataSource != null && dataSource.isOpen() || selectionModel != null; } public ObserveSwingDataSource getDataSource() { @@ -76,14 +72,6 @@ public class ObserveDataProvider implements NavDataProvider { return selectionModel; } - //FIXME -// protected DataService getDataService() { -// if (dataService == null) { -// dataService = ObserveServiceHelper.getDataService(); -// } -// return dataService; -// } - public boolean isCreating() { return creating; } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/ObserveTreeHelper.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/ObserveTreeHelper.java index 660ec55..7a10106 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/ObserveTreeHelper.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/ObserveTreeHelper.java @@ -24,7 +24,6 @@ package fr.ird.observe.ui.tree; import com.google.common.base.Preconditions; import fr.ird.observe.ObserveSwingApplicationContext; import fr.ird.observe.business.db.DataContext; -import fr.ird.observe.business.db.model.DataSelectionModel; import fr.ird.observe.db.ObserveSwingDataSource; import fr.ird.observe.services.dto.IdDto; import fr.ird.observe.services.dto.ReferenceDto; @@ -41,6 +40,7 @@ import fr.ird.observe.services.dto.seine.TripSeineDto; import fr.ird.observe.services.service.ReferentialService; import fr.ird.observe.ui.DecoratorService; import fr.ird.observe.ui.ObserveMainUI; +import fr.ird.observe.ui.storage.tabs.DataSelectionModel; import fr.ird.observe.ui.tree.loadors.AbstractNodeChildLoador; import fr.ird.observe.ui.tree.loadors.ActivityLonglineNodeChildLoador; import fr.ird.observe.ui.tree.loadors.ActivityLonglinesNodeChildLoador; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/loadors/AbstractNodeChildLoador.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/loadors/AbstractNodeChildLoador.java index a508056..2d0ae76 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/loadors/AbstractNodeChildLoador.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/loadors/AbstractNodeChildLoador.java @@ -21,8 +21,8 @@ */ package fr.ird.observe.ui.tree.loadors; -import fr.ird.observe.business.db.model.DataSelectionModel; import fr.ird.observe.db.ObserveSwingDataSource; +import fr.ird.observe.ui.storage.tabs.DataSelectionModel; import fr.ird.observe.ui.tree.ObserveDataProvider; import fr.ird.observe.ui.tree.ObserveNode; import jaxx.runtime.swing.nav.NavDataProvider; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/loadors/ProgramLonglineNodeChildLoador.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/loadors/ProgramLonglineNodeChildLoador.java index 58ffcee..8b732dd 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/loadors/ProgramLonglineNodeChildLoador.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/loadors/ProgramLonglineNodeChildLoador.java @@ -22,21 +22,20 @@ package fr.ird.observe.ui.tree.loadors; * #L% */ +import com.google.common.collect.Lists; import fr.ird.observe.ObserveSwingApplicationContext; -import fr.ird.observe.business.db.model.DataSelectionModel; -import fr.ird.observe.db.ObserveSwingDataSource; import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.ReferenceDtos; import fr.ird.observe.services.dto.ReferenceSetDto; import fr.ird.observe.services.dto.longline.TripLonglineDto; import fr.ird.observe.services.service.longline.TripLonglineService; +import fr.ird.observe.ui.storage.tabs.DataSelectionModel; import fr.ird.observe.ui.tree.ObserveNode; import fr.ird.observe.ui.tree.ObserveTreeHelper; import fr.ird.observe.ui.tree.TripLonglineNode; import jaxx.runtime.swing.nav.NavDataProvider; import jaxx.runtime.swing.nav.tree.NavTreeBridge; -import java.util.ArrayList; import java.util.List; import static org.nuiton.i18n.I18n.n; @@ -83,33 +82,25 @@ public class ProgramLonglineNodeChildLoador extends AbstractReferenceDtoChildLoa String parentId, NavDataProvider dataProvider) throws Exception { - ObserveSwingDataSource dataSource = getDataSource(dataProvider); - //FIXME -// DataService service = getDataService(); -// DataSelectionModel selectionModel = getSelectionModel(dataProvider); - - List<TripLonglineDto> result; - - //FIXME -// if (selectionModel != null) { -// -// result = new ArrayList<TripLongline>(); -// List<String> tripIds = selectionModel.getDatas().get(parentId); -// if (!CollectionUtils.isEmpty(tripIds)) { -// for (String tripId : tripIds) { -// result.add((TripLongline) selectionModel.getEntityCache(tripId)); -// } -// } -// -// } else { -// -// result = service.getTripLonglineStubByProgram(dataSource, parentId); -// -// } - TripLonglineService tripLonglineService = ObserveSwingApplicationContext.get().newService(TripLonglineService.class); - ReferenceSetDto<TripLonglineDto> tripLonglineByProgram = tripLonglineService.getTripLonglineByProgram(parentId); - - return new ArrayList<>(ReferenceDtos.castToCollectionOfReferenceDto(tripLonglineByProgram.getReference())); + DataSelectionModel selectionModel = getSelectionModel(dataProvider); + + List<ReferenceDto<TripLonglineDto>> result; + + if (selectionModel != null) { + + result = Lists.newArrayList(ReferenceDtos.castToCollectionOfReferenceDto(selectionModel.getDatas(parentId))); + + } else { + + TripLonglineService tripLonglineService = ObserveSwingApplicationContext.get().newService(TripLonglineService.class); + ReferenceSetDto<TripLonglineDto> tripLonglineByProgram = tripLonglineService.getTripLonglineByProgram(parentId); + + result = Lists.newArrayList(ReferenceDtos.castToCollectionOfReferenceDto(tripLonglineByProgram.getReference())); + + } + + + return result; } @Override diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/loadors/ProgramSeineNodeChildLoador.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/loadors/ProgramSeineNodeChildLoador.java index 5e70c2d..3e2bdbf 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/loadors/ProgramSeineNodeChildLoador.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/loadors/ProgramSeineNodeChildLoador.java @@ -21,13 +21,14 @@ */ package fr.ird.observe.ui.tree.loadors; +import com.google.common.collect.Lists; import fr.ird.observe.ObserveSwingApplicationContext; -import fr.ird.observe.db.ObserveSwingDataSource; import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.ReferenceDtos; import fr.ird.observe.services.dto.ReferenceSetDto; import fr.ird.observe.services.dto.seine.TripSeineDto; import fr.ird.observe.services.service.seine.TripSeineService; +import fr.ird.observe.ui.storage.tabs.DataSelectionModel; import fr.ird.observe.ui.tree.ObserveNode; import fr.ird.observe.ui.tree.ObserveTreeHelper; import fr.ird.observe.ui.tree.TripSeineNode; @@ -64,9 +65,8 @@ public class ProgramSeineNodeChildLoador extends AbstractReferenceDtoChildLoador public void loadChilds(NavTreeBridge<ObserveNode> model, ObserveNode parentNode, NavDataProvider dataProvider) throws Exception { - //FIXME -// DataSelectionModel selectionModel = getSelectionModel(dataProvider); -// addChilds = selectionModel == null; + DataSelectionModel selectionModel = getSelectionModel(dataProvider); + addChilds = selectionModel == null; try { super.loadChilds(model, parentNode, dataProvider); @@ -80,31 +80,23 @@ public class ProgramSeineNodeChildLoador extends AbstractReferenceDtoChildLoador String parentId, NavDataProvider dataProvider) throws Exception { - ObserveSwingDataSource dataSource = getDataSource(dataProvider); - //FIXME -// DataService service = getDataService(); -// DataSelectionModel selectionModel = getSelectionModel(dataProvider); - - //FIXME -// if (selectionModel != null) { -// result = new ArrayList<TripSeine>(); -// List<String> tripIds = selectionModel.getDatas().get(parentId); -// if (!CollectionUtils.isEmpty(tripIds)) { -// for (String tripId : tripIds) { -// result.add((TripSeine) selectionModel.getEntityCache(tripId)); -// } -// } -// } else { -// -// result = service.getTripSeineStubByProgram(dataSource, parentId); - -// } -// return result; - - TripSeineService tripSeineService = ObserveSwingApplicationContext.get().newService(TripSeineService.class); - ReferenceSetDto<TripSeineDto> tripSeineByProgram = tripSeineService.getTripSeineByProgram(parentId); - - return new ArrayList<>(ReferenceDtos.castToCollectionOfReferenceDto(tripSeineByProgram.getReference())); + DataSelectionModel selectionModel = getSelectionModel(dataProvider); + + List<ReferenceDto<TripSeineDto>> result; + + if (selectionModel != null) { + + result = Lists.newArrayList(ReferenceDtos.castToCollectionOfReferenceDto(selectionModel.getDatas(parentId))); + + } else { + + TripSeineService tripSeineService = ObserveSwingApplicationContext.get().newService(TripSeineService.class); + ReferenceSetDto<TripSeineDto> tripSeineByProgram = tripSeineService.getTripSeineByProgram(parentId); + + result = new ArrayList<>(ReferenceDtos.castToCollectionOfReferenceDto(tripSeineByProgram.getReference())); + + } + return result; } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/loadors/RootNodeChildLoador.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/loadors/RootNodeChildLoador.java index 3f3c48c..a9aa0e3 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/loadors/RootNodeChildLoador.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/loadors/RootNodeChildLoador.java @@ -21,14 +21,15 @@ */ package fr.ird.observe.ui.tree.loadors; +import com.google.common.collect.Lists; import fr.ird.observe.ObserveSwingApplicationContext; -import fr.ird.observe.db.ObserveSwingDataSource; import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.ReferenceDtos; import fr.ird.observe.services.dto.ReferenceSetDto; import fr.ird.observe.services.dto.constants.GearType; import fr.ird.observe.services.dto.referential.ProgramDto; import fr.ird.observe.services.service.ReferentialService; +import fr.ird.observe.ui.storage.tabs.DataSelectionModel; import fr.ird.observe.ui.tree.ObserveNode; import fr.ird.observe.ui.tree.ObserveTreeHelper; import fr.ird.observe.ui.tree.ProgramLonglineNode; @@ -78,29 +79,20 @@ public class RootNodeChildLoador extends AbstractReferenceDtoChildLoador<Program String parentId, NavDataProvider dataProvider) throws Exception { - ObserveSwingDataSource dataSource = getDataSource(dataProvider); - //FIXME -// DataService service = getDataService(); -// DataSelectionModel selectionModel = getSelectionModel(dataProvider); + DataSelectionModel selectionModel = getSelectionModel(dataProvider); + + List<ReferenceDto<ProgramDto>> data = Collections.emptyList(); - List<ReferenceDto<ProgramDto>> data; if (addData) { -// if (selectionModel != null) { -// data = new ArrayList<Program>(); -// for (String programId : selectionModel.getDatas().keySet()) { -// data.add((Program) selectionModel.getEntityCache(programId)); -// } -// } else { -// data = service.getAllProgramStub(dataSource); -// } - ReferentialService service = ObserveSwingApplicationContext.get().newService(ReferentialService.class); - ReferenceSetDto<ProgramDto> referentialReferenceSet = service.getReferentialReferenceSet(ProgramDto.class); - data = new ArrayList<>(ReferenceDtos.castToCollectionOfReferenceDto(referentialReferenceSet.getReference())); - - } else { - - data = Collections.emptyList(); + if (selectionModel != null) { + data = Lists.newArrayList(selectionModel.getDatas().keySet()); + } else { + ReferentialService service = ObserveSwingApplicationContext.get().newService(ReferentialService.class); + ReferenceSetDto<ProgramDto> referentialReferenceSet = service.getReferentialReferenceSet(ProgramDto.class); + data = new ArrayList<>(ReferenceDtos.castToCollectionOfReferenceDto(referentialReferenceSet.getReference())); + } + } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/ObserveSimpleValidatorMessageTableRenderer.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/ObserveSimpleValidatorMessageTableRenderer.java deleted file mode 100644 index 21e81ed..0000000 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/ObserveSimpleValidatorMessageTableRenderer.java +++ /dev/null @@ -1,79 +0,0 @@ -package fr.ird.observe.ui.util; - -/* - * #%L - * ObServe :: Swing - * %% - * Copyright (C) 2008 - 2014 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% - */ - -import fr.ird.observe.ui.DecoratorService; -import fr.ird.observe.ObserveSwingApplicationContext; -import jaxx.runtime.validator.swing.SimpleBeanValidatorMessageTableModel; -import jaxx.runtime.validator.swing.SimpleBeanValidatorMessageTableRenderer; -import org.nuiton.validator.NuitonValidatorScope; - -import javax.swing.JTable; -import java.awt.Color; -import java.awt.Component; - -import static org.nuiton.i18n.I18n.t; - -/** -* Created on 12/13/14. -* -* @author Tony Chemit - chemit@codelutin.com -* @since XXX -*/ -public class ObserveSimpleValidatorMessageTableRenderer extends SimpleBeanValidatorMessageTableRenderer { - - private static final long serialVersionUID = 1L; - - protected transient DecoratorService decoratorService; - - public DecoratorService getDecoratorService() { - if (decoratorService == null) { - decoratorService = ObserveSwingApplicationContext.get().getDecoratorService(); - } - return decoratorService; - } - - @Override - public String getFieldName(JTable table, String value, int row) { - String fieldName = super.getFieldName(table, value, row); - DecoratorService dService = getDecoratorService(); - if (!dService.getPropertyMatch(fieldName).matches()) { - fieldName = DecoratorService.getPropertyLabel(fieldName); - } - return t(fieldName); - } - - @Override - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { - Component result = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); - - SimpleBeanValidatorMessageTableModel model = (SimpleBeanValidatorMessageTableModel) table.getModel(); - - NuitonValidatorScope scope = (NuitonValidatorScope) ( - column == 0 ? value : model.getValueAt(row, 0)); - - Color textColor = scope == NuitonValidatorScope.WARNING ? Color.RED : Color.BLACK; - result.setForeground(textColor); - return result; - } -} diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/ObserveValidationMessageTableRenderer.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/ObserveValidationMessageTableRenderer.java new file mode 100644 index 0000000..3151623 --- /dev/null +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/ObserveValidationMessageTableRenderer.java @@ -0,0 +1,147 @@ +package fr.ird.observe.ui.util; + +/* + * #%L + * ObServe :: Swing + * %% + * Copyright (C) 2008 - 2014 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% + */ + +import fr.ird.observe.ObserveSwingApplicationContext; +import fr.ird.observe.services.service.actions.validate.ValidationMessage; +import fr.ird.observe.ui.DecoratorService; +import fr.ird.observe.ui.admin.validate.ValidationMessageTableModel; +import jaxx.runtime.validator.swing.SwingValidatorUtil; +import org.nuiton.validator.NuitonValidatorScope; + +import javax.swing.ImageIcon; +import javax.swing.JLabel; +import javax.swing.JTable; +import javax.swing.table.DefaultTableCellRenderer; +import java.awt.Color; +import java.awt.Component; + +import static org.nuiton.i18n.I18n.t; + +/** +* Created on 12/13/14. +* +* @author Tony Chemit - chemit@codelutin.com +* @since XXX +*/ +public class ObserveValidationMessageTableRenderer extends DefaultTableCellRenderer { + + private static final long serialVersionUID = 1L; + + protected transient DecoratorService decoratorService; + + public DecoratorService getDecoratorService() { + if (decoratorService == null) { + decoratorService = ObserveSwingApplicationContext.get().getDecoratorService(); + } + return decoratorService; + } + + public String getFieldName(JTable table, String value, int row) { + + String fieldName = value; + DecoratorService dService = getDecoratorService(); + if (!dService.getPropertyMatch(fieldName).matches()) { + fieldName = DecoratorService.getPropertyLabel(fieldName); + } + return t(fieldName); + } + + @Override + public Component getTableCellRendererComponent(JTable table, + Object value, + boolean isSelected, + boolean hasFocus, + int row, + int column) { + JLabel rendererComponent = (JLabel) + super.getTableCellRendererComponent( + table, + value, + isSelected, + hasFocus, + row, + column + ); + + ImageIcon icon = null; + String text = null; + String toolTipText = null; + + column = table.convertColumnIndexToModel(column); + if (table.getRowSorter() != null) { + row = table.getRowSorter().convertRowIndexToModel(row); + } + + switch (column) { + case 0: + // scope + NuitonValidatorScope scope = (NuitonValidatorScope) value; + icon = SwingValidatorUtil.getIcon(scope); + String label = t(scope.getLabel()); + toolTipText = t("validator.scope.tip", label); + break; + + case 1: + // field name + text = getFieldName(table, (String) value, row); + toolTipText = t("validator.field.tip", text); + break; + + case 2: + // message + text = getMessage(table, (String) value, row); + toolTipText = t("validator.message.tip", text); + break; + } + + rendererComponent.setText(text); + rendererComponent.setToolTipText(toolTipText); + rendererComponent.setIcon(icon); + + ValidationMessageTableModel model = (ValidationMessageTableModel) table.getModel(); + + NuitonValidatorScope scope = (NuitonValidatorScope) ( + column == 0 ? value : model.getValueAt(row, 0)); + + Color textColor = scope == NuitonValidatorScope.WARNING ? Color.RED : Color.BLACK; + rendererComponent.setForeground(textColor); + + return rendererComponent; + } + + public ImageIcon getIcon(NuitonValidatorScope scope) { + ImageIcon icon = SwingValidatorUtil.getIcon(scope); + return icon; + } + + public String getMessage(JTable table, String value, int row) { + ValidationMessageTableModel tableModel = + (ValidationMessageTableModel) table.getModel(); + ValidationMessage validationMessage = tableModel.getRow(row); + String text = validationMessage.getMessage(); + return text; + + } + +} diff --git a/observe-application-swing/src/main/java/fr/ird/observe/validation/ValidationModelMode.java b/observe-application-swing/src/main/java/fr/ird/observe/validation/ValidationModelMode.java index a256abe..df7ff87 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/validation/ValidationModelMode.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/validation/ValidationModelMode.java @@ -34,41 +34,37 @@ public enum ValidationModelMode { /** validation du referentiel */ REFERENTIEL( n("observe.validation.model.type.referentiel"), - n("observe.validation.model.type.referentiel.description") - //FIXME -// Entities.REFERENCE_ENTITIES - ), + n("observe.validation.model.type.referentiel.description"), + true, false), /** validation de donnees observer */ DATA( n("observe.validation.model.type.data"), - n("observe.validation.model.type.data.description") - //FIXME -// Entities.DATA_ENTITIES - ), + n("observe.validation.model.type.data.description"), + false, true), /** validation du referentiel et de donnees observer */ ALL( n("observe.validation.model.type.all"), - n("observe.validation.model.type.all.description") - //FIXME -// Entities.ALL_ENTITIES - ); + n("observe.validation.model.type.all.description"), + true, false); private final String label; private final String description; -// private final Class<? extends TopiaEntity>[] contracts; + private final boolean referential; + + private final boolean data; ValidationModelMode(String label, - String description - //FIXME -// ObserveEntityEnum... contracts - ) { + String description, + boolean referential, + boolean data) { this.label = label; this.description = description; -// this.contracts = TopiaEntityHelper.getContracts(contracts); + this.referential = referential; + this.data = data; } public String getLabel() { @@ -79,7 +75,11 @@ public enum ValidationModelMode { return description; } -// public Class<? extends TopiaEntity>[] getContracts() { -// return contracts; -// } + public boolean isReferential() { + return referential; + } + + public boolean isData() { + return data; + } } 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 108bca2..7f292b5 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 @@ -1884,6 +1884,7 @@ observe.storage.security.administrateur= observe.storage.selected.dbMode= observe.storage.selectedCreationMode= observe.storage.server.dataBase= +observe.storage.server.db= observe.storage.showMigrationProgression= observe.storage.showMigrationSql= observe.storage.step.backup= @@ -2377,3 +2378,12 @@ observe.warning.nimbus.landf=Could not use Look and Fell Nimbus, need at least v observe.warning.no.ui=No gui environment found observeweb.configuration.description= ui.main.body.synchro.action.copy.to.clipBoard= +validator.field.header= +validator.field.header.tip= +validator.field.tip= +validator.message.header= +validator.message.header.tip= +validator.message.tip= +validator.scope.header= +validator.scope.header.tip= +validator.scope.tip= 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 faa9f19..ec40c79 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 @@ -1886,6 +1886,7 @@ observe.storage.security.administrateur=Propietario de la base observe.storage.selected.dbMode=Tipo de origen de datos seleccionado observe.storage.selectedCreationMode=Modo de creación seleccionada observe.storage.server.dataBase= +observe.storage.server.db= observe.storage.showMigrationProgression=Mostrar el progreso de las actualizaciones observe.storage.showMigrationSql=Mostrar las consultas sql de las actualizaciones observe.storage.step.backup=Copia de seguridad @@ -2359,12 +2360,12 @@ observe.tripSeine.message.updating= observe.tripSeine.tab.general= observe.tripSeine.tab.map=Mapa observe.tripSeine.title= -observe.validation.model.type.all= -observe.validation.model.type.all.description= -observe.validation.model.type.data= -observe.validation.model.type.data.description= -observe.validation.model.type.referentiel= -observe.validation.model.type.referentiel.description= +observe.validation.model.type.all=Datos y referenciales +observe.validation.model.type.all.description=Datos y referenciales +observe.validation.model.type.data=Datos del observador +observe.validation.model.type.data.description=Datos del observador +observe.validation.model.type.referentiel=Referencial +observe.validation.model.type.referentiel.description=Todos los referenciales observe.validation.report.contextName= observe.validation.report.entities.with.messages= observe.validation.report.entity= @@ -2379,3 +2380,12 @@ observe.warning.nimbus.landf= observe.warning.no.ui= observeweb.configuration.description= ui.main.body.synchro.action.copy.to.clipBoard= +validator.field.header= +validator.field.header.tip= +validator.field.tip= +validator.message.header= +validator.message.header.tip= +validator.message.tip= +validator.scope.header= +validator.scope.header.tip= +validator.scope.tip= 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 24b6ff0..5932c0f 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 @@ -1884,6 +1884,7 @@ observe.storage.security.administrateur=Propriétaire de la base observe.storage.selected.dbMode=Type de source de données sélectionné observe.storage.selectedCreationMode=Mode de création sélectionné observe.storage.server.dataBase=Base de données +observe.storage.server.db= observe.storage.showMigrationProgression=Afficher la progression lors des mises à jour observe.storage.showMigrationSql=Afficher les requêtes sql lors des mises à jour observe.storage.step.backup=Sauvegarde @@ -2357,12 +2358,12 @@ observe.tripSeine.message.updating=La maréee est en cours de modification. observe.tripSeine.tab.general=Caractéristiques observe.tripSeine.tab.map=Carte observe.tripSeine.title=Marée -observe.validation.model.type.all= -observe.validation.model.type.all.description= -observe.validation.model.type.data= -observe.validation.model.type.data.description= -observe.validation.model.type.referentiel= -observe.validation.model.type.referentiel.description= +observe.validation.model.type.all=Données et référentiels +observe.validation.model.type.all.description=Données et référentiels +observe.validation.model.type.data=Données observées +observe.validation.model.type.data.description=Données observées +observe.validation.model.type.referentiel=Référentiel +observe.validation.model.type.referentiel.description=Tous les référentiels observe.validation.report.contextName=Context de validation utilisé \: %1$s observe.validation.report.entities.with.messages=Nombre d'entités avec des messages \: %1$s observe.validation.report.entity=Entité %1$s '%2$s' Nombre de messages %3$s (sur %4$s scope(s)). @@ -2377,3 +2378,12 @@ observe.warning.nimbus.landf=Le look and Feel Nimbus n'a pas été trouvé, il f observe.warning.no.ui=Aucun environnement graphique détecté observeweb.configuration.description= ui.main.body.synchro.action.copy.to.clipBoard=Copier le contenu dans le presse-papier +validator.field.header= +validator.field.header.tip= +validator.field.tip= +validator.message.header= +validator.message.header.tip= +validator.message.tip= +validator.scope.header= +validator.scope.header.tip= +validator.scope.tip= 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 03cbf95..b7168f5 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 @@ -45,8 +45,8 @@ public class ReferentialServiceController extends ObserveAuthenticatedServiceCon } @Override - public <R extends ReferentialDto> ReferenceSetDto<R> getReferentialReferenceSet(Class<R> type, boolean loadTechnicalInformations) { - return service.getReferentialReferenceSet(type, loadTechnicalInformations); + public <R extends ReferentialDto> ReferenceSetDto<R> getReferentialReferenceSetWithTechnicalInformations(Class<R> type) { + return service.getReferentialReferenceSetWithTechnicalInformations(type); } @Override diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/actions/validate/ValidateServiceController.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/actions/validate/ValidateServiceController.java index 0978245..3b6c9e2 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/actions/validate/ValidateServiceController.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/actions/validate/ValidateServiceController.java @@ -22,7 +22,6 @@ package fr.ird.observe.application.web.controller.v1.actions.validate; * #L% */ -import com.google.common.collect.ImmutableSet; import fr.ird.observe.application.web.controller.v1.ObserveAuthenticatedServiceControllerSupport; import fr.ird.observe.services.service.actions.validate.ValidateDataRequest; import fr.ird.observe.services.service.actions.validate.ValidateDataResult; @@ -40,11 +39,6 @@ public class ValidateServiceController extends ObserveAuthenticatedServiceContro } @Override - public ImmutableSet<String> getAvailableContextNames() { - return service.getAvailableContextNames(); - } - - @Override public ValidateReferentialsResult validateReferentials(ValidateReferentialsRequest request) { return service.validateReferentials(request); } diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/longline/TripLonglineServiceController.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/longline/TripLonglineServiceController.java index 77b4f40..1d66e21 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/longline/TripLonglineServiceController.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/longline/TripLonglineServiceController.java @@ -41,6 +41,11 @@ public class TripLonglineServiceController extends ObserveAuthenticatedServiceCo } @Override + public ReferenceSetDto<TripLonglineDto> getAllTripLongline() { + return service.getAllTripLongline(); + } + + @Override public ReferenceSetDto<TripLonglineDto> getTripLonglineByProgram(String programId) { return service.getTripLonglineByProgram(programId); } diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/seine/TripSeineServiceController.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/seine/TripSeineServiceController.java index 8c976db..10b95ce 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/seine/TripSeineServiceController.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/seine/TripSeineServiceController.java @@ -41,6 +41,11 @@ public class TripSeineServiceController extends ObserveAuthenticatedServiceContr } @Override + public ReferenceSetDto<TripSeineDto> getAllTripSeine() { + return service.getAllTripSeine(); + } + + @Override public ReferenceSetDto<TripSeineDto> getTripSeineByProgram(String programId) { return service.getTripSeineByProgram(programId); } 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 c283b5e..70cda2c 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 @@ -46,7 +46,7 @@ import java.util.Date; public interface ReferentialService extends ObserveService { @ReadReferentialPermission - <R extends ReferentialDto> ReferenceSetDto<R> getReferentialReferenceSet(Class<R> type, boolean loadTechnicalInformations); + <R extends ReferentialDto> ReferenceSetDto<R> getReferentialReferenceSetWithTechnicalInformations(Class<R> type); @ReadReferentialPermission <R extends ReferentialDto> ReferenceSetDto<R> getReferentialReferenceSet(Class<R> type); diff --git a/observe-services-api/src/main/java/fr/ird/observe/services/service/actions/validate/ValidateResultForDtoType.java b/observe-services-api/src/main/java/fr/ird/observe/services/service/actions/validate/ValidateResultForDtoType.java index 7cd7241..ce86dd3 100644 --- a/observe-services-api/src/main/java/fr/ird/observe/services/service/actions/validate/ValidateResultForDtoType.java +++ b/observe-services-api/src/main/java/fr/ird/observe/services/service/actions/validate/ValidateResultForDtoType.java @@ -22,9 +22,13 @@ package fr.ird.observe.services.service.actions.validate; * #L% */ +import com.google.common.base.Optional; +import com.google.common.base.Predicate; import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; import fr.ird.observe.services.dto.IdDto; import fr.ird.observe.services.dto.ObserveDto; +import fr.ird.observe.services.dto.ReferenceDto; /** * Le résultat d'une validation d'un type de dto donné. @@ -48,4 +52,15 @@ public class ValidateResultForDtoType<D extends IdDto> implements ObserveDto { return validateResultForDto; } + public ValidateResultForDto<D> getValidateResult(final ReferenceDto<D> referenceDto) { + Optional<ValidateResultForDto<D>> resultForDtoOptional = Iterables.tryFind(validateResultForDto, new Predicate<ValidateResultForDto<D>>() { + @Override + public boolean apply(ValidateResultForDto<D> input) { + return referenceDto.equals(input.getDto()); + } + }); + + return resultForDtoOptional.orNull(); + } + } diff --git a/observe-services-api/src/main/java/fr/ird/observe/services/service/actions/validate/ValidateResultForDtos.java b/observe-services-api/src/main/java/fr/ird/observe/services/service/actions/validate/ValidateResultForDtos.java new file mode 100644 index 0000000..68cc125 --- /dev/null +++ b/observe-services-api/src/main/java/fr/ird/observe/services/service/actions/validate/ValidateResultForDtos.java @@ -0,0 +1,80 @@ +package fr.ird.observe.services.service.actions.validate; + +import com.google.common.base.Function; +import com.google.common.base.Predicate; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; +import org.nuiton.validator.NuitonValidatorScope; + +import java.util.EnumMap; +import java.util.EnumSet; +import java.util.List; + +/** + * @author Sylvain Bavencoff - bavencoff@codelutin.com + */ +public class ValidateResultForDtos { + + public static EnumMap<NuitonValidatorScope, Integer> getScopesCount( + ValidateResultForDto validateResultForDto) { + + EnumMap<NuitonValidatorScope, Integer> result = Maps.newEnumMap(NuitonValidatorScope.class); + + for (NuitonValidatorScope s : NuitonValidatorScope.values()) { + result.put(s, 0); + } + + ImmutableSet<ValidationMessage> messages = validateResultForDto.getMessages(); + + for (ValidationMessage validationMessage : messages) { + + NuitonValidatorScope scope = validationMessage.getScope(); + + result.put(scope, result.get(scope) + 1); + } + + for (NuitonValidatorScope s : NuitonValidatorScope.values()) { + + if (result.get(s) == 0) { + + result.remove(s); + + } + + } + + return result; + } + + public static EnumSet<NuitonValidatorScope> getScopes( + ValidateResultForDto validateResultForDto) { + + EnumSet<NuitonValidatorScope> result = Sets.newEnumSet(Iterables.transform(validateResultForDto.getMessages(), new Function<ValidationMessage, NuitonValidatorScope>() { + @Override + public NuitonValidatorScope apply(ValidationMessage input) { + return input.getScope(); + } + }), NuitonValidatorScope.class); + + return result; + } + + public static List<ValidationMessage> scopeMessageFilter(final NuitonValidatorScope scope, ValidateResultForDto validateResultForDto) { + + List<ValidationMessage> result = Lists.newLinkedList(Iterables.filter( + validateResultForDto.getMessages(), + new Predicate<ValidationMessage>() { + @Override + public boolean apply(ValidationMessage input) { + return scope.equals(input.getScope()); + } + } + )); + + return result; + } + +} diff --git a/observe-services-api/src/main/java/fr/ird/observe/services/service/actions/validate/ValidateService.java b/observe-services-api/src/main/java/fr/ird/observe/services/service/actions/validate/ValidateService.java index f6e8101..9219822 100644 --- a/observe-services-api/src/main/java/fr/ird/observe/services/service/actions/validate/ValidateService.java +++ b/observe-services-api/src/main/java/fr/ird/observe/services/service/actions/validate/ValidateService.java @@ -24,7 +24,6 @@ package fr.ird.observe.services.service.actions.validate; import com.google.common.collect.ImmutableSet; import fr.ird.observe.services.ObserveService; -import fr.ird.observe.services.spi.NoDataAccess; import fr.ird.observe.services.spi.PostRequest; import fr.ird.observe.services.spi.ReadDataPermission; import fr.ird.observe.services.spi.ReadReferentialPermission; @@ -40,9 +39,6 @@ public interface ValidateService extends ObserveService { ImmutableSet<String> AVAILABLE_CONTEXT_NAMES = ImmutableSet.of(N1_CREATE_CONTEXT, N1_UPDATE_CONTEXT); - @NoDataAccess - ImmutableSet<String> getAvailableContextNames(); - @ReadReferentialPermission @PostRequest ValidateReferentialsResult validateReferentials(ValidateReferentialsRequest request); diff --git a/observe-services-api/src/main/java/fr/ird/observe/services/service/actions/validate/ValidateServiceUtils.java b/observe-services-api/src/main/java/fr/ird/observe/services/service/actions/validate/ValidateServiceUtils.java new file mode 100644 index 0000000..070108b --- /dev/null +++ b/observe-services-api/src/main/java/fr/ird/observe/services/service/actions/validate/ValidateServiceUtils.java @@ -0,0 +1,40 @@ +package fr.ird.observe.services.service.actions.validate; + +import com.google.common.collect.ImmutableSet; +import com.google.gson.Gson; +import fr.ird.observe.services.dto.gson.ObserveDtoGsonSupplier; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; + +/** + * @author Sylvain Bavencoff - bavencoff@codelutin.com + */ +public class ValidateServiceUtils { + + protected static final String RESOURCE_VALIDATORS = "validators.json"; + + public static ImmutableSet<String> getAvailableContextNames() { + return ValidateService.AVAILABLE_CONTEXT_NAMES; + } + + public static ImmutableSet<ValidatorDto> getValidators() throws IOException { + + ObserveDtoGsonSupplier gsonSupplier = new ObserveDtoGsonSupplier(false); + + Gson gson = gsonSupplier.get(); + + InputStream inputStream = ValidateServiceUtils.class.getResourceAsStream(RESOURCE_VALIDATORS); + + try (Reader reader = new InputStreamReader(inputStream)) { + + ValidatorDto[] validators = gson.fromJson(reader, ValidatorDto[].class); + + return ImmutableSet.copyOf(validators); + } + + } + +} diff --git a/observe-services-api/src/main/java/fr/ird/observe/services/service/actions/validate/ValidatorDto.java b/observe-services-api/src/main/java/fr/ird/observe/services/service/actions/validate/ValidatorDto.java new file mode 100644 index 0000000..57d69c0 --- /dev/null +++ b/observe-services-api/src/main/java/fr/ird/observe/services/service/actions/validate/ValidatorDto.java @@ -0,0 +1,51 @@ +package fr.ird.observe.services.service.actions.validate; + +import fr.ird.observe.services.dto.IdDto; +import org.nuiton.validator.NuitonValidatorScope; + +import java.util.Objects; + +/** + * @author Sylvain Bavencoff - bavencoff@codelutin.com + */ +public class ValidatorDto { + + protected final Class<? extends IdDto> dtoType; + + protected final NuitonValidatorScope scope; + + protected final String context; + + public ValidatorDto(Class<? extends IdDto> dtoType, NuitonValidatorScope scope, String context) { + this.dtoType = dtoType; + this.scope = scope; + this.context = context; + } + + public Class<? extends IdDto> getDtoType() { + return dtoType; + } + + public NuitonValidatorScope getScope() { + return scope; + } + + public String getContext() { + return context; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ValidatorDto that = (ValidatorDto) o; + return Objects.equals(dtoType, that.dtoType) && + Objects.equals(scope, that.scope) && + Objects.equals(context, that.context); + } + + @Override + public int hashCode() { + return Objects.hash(dtoType, scope, context); + } +} diff --git a/observe-services-api/src/main/java/fr/ird/observe/services/service/actions/validate/ValidatorDtos.java b/observe-services-api/src/main/java/fr/ird/observe/services/service/actions/validate/ValidatorDtos.java new file mode 100644 index 0000000..68d86a4 --- /dev/null +++ b/observe-services-api/src/main/java/fr/ird/observe/services/service/actions/validate/ValidatorDtos.java @@ -0,0 +1,37 @@ +package fr.ird.observe.services.service.actions.validate; + +import com.google.common.base.Predicate; +import com.google.common.collect.Iterables; +import com.google.common.collect.Sets; +import fr.ird.observe.services.dto.referential.ReferentialDto; +import org.nuiton.validator.NuitonValidatorScope; + +import java.util.EnumSet; +import java.util.Set; + +/** + * @author Sylvain Bavencoff - bavencoff@codelutin.com + */ +public class ValidatorDtos { + + public static Set<ValidatorDto> filter(Set<ValidatorDto> validators, + final boolean validateData, + final boolean validateReferential, + final EnumSet<NuitonValidatorScope> scopes, + final String context) { + + return Sets.newHashSet(Iterables.filter(validators, new Predicate<ValidatorDto>() { + @Override + public boolean apply(ValidatorDto input) { + return + (validateData && ! ReferentialDto.class.isAssignableFrom(input.getDtoType()) + || validateReferential && ReferentialDto.class.isAssignableFrom(input.getDtoType())) + && scopes.contains(input.getScope()) + && context.equals(input.getContext()); + } + })); + + } + + +} diff --git a/observe-services-api/src/main/java/fr/ird/observe/services/service/longline/TripLonglineService.java b/observe-services-api/src/main/java/fr/ird/observe/services/service/longline/TripLonglineService.java index 3cafbdd..006635a 100644 --- a/observe-services-api/src/main/java/fr/ird/observe/services/service/longline/TripLonglineService.java +++ b/observe-services-api/src/main/java/fr/ird/observe/services/service/longline/TripLonglineService.java @@ -41,6 +41,9 @@ import fr.ird.observe.services.spi.WriteDataPermission; public interface TripLonglineService extends ObserveService { @ReadDataPermission + ReferenceSetDto<TripLonglineDto> getAllTripLongline(); + + @ReadDataPermission ReferenceSetDto<TripLonglineDto> getTripLonglineByProgram(String programId); @ReadDataPermission @@ -70,5 +73,4 @@ public interface TripLonglineService extends ObserveService { @WriteDataPermission @DeleteRequest void delete(String tripLonglineId); - } \ No newline at end of file diff --git a/observe-services-api/src/main/java/fr/ird/observe/services/service/seine/TripSeineService.java b/observe-services-api/src/main/java/fr/ird/observe/services/service/seine/TripSeineService.java index 375057f..8617d42 100644 --- a/observe-services-api/src/main/java/fr/ird/observe/services/service/seine/TripSeineService.java +++ b/observe-services-api/src/main/java/fr/ird/observe/services/service/seine/TripSeineService.java @@ -40,6 +40,8 @@ import fr.ird.observe.services.spi.WriteDataPermission; */ public interface TripSeineService extends ObserveService { + ReferenceSetDto<TripSeineDto> getAllTripSeine(); + @ReadDataPermission ReferenceSetDto<TripSeineDto> getTripSeineByProgram(String programId); diff --git a/observe-services-api/src/main/resources/fr/ird/observe/services/service/actions/validate/validators.json b/observe-services-api/src/main/resources/fr/ird/observe/services/service/actions/validate/validators.json new file mode 100644 index 0000000..6a500e7 --- /dev/null +++ b/observe-services-api/src/main/resources/fr/ird/observe/services/service/actions/validate/validators.json @@ -0,0 +1,1492 @@ +[ + { + "dtoType": "fr.ird.observe.services.dto.longline.ActivityLonglineDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.longline.ActivityLonglineDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.longline.ActivityLonglineDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.longline.ActivityLonglineDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.longline.BaitsCompositionDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.longline.BranchlineDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.longline.BranchlineDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.longline.BranchlinesCompositionDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.longline.CatchLonglineDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.longline.CatchLonglineDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.longline.EncounterDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.longline.EncounterDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.longline.FloatlinesCompositionDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.longline.GearUseFeaturesLonglineDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.longline.HooksCompositionDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.longline.SensorUsedDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.longline.SensorUsedDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.longline.SetLonglineDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.longline.SetLonglineDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.longline.SetLonglineDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.longline.SetLonglineDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.longline.TdrDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.longline.TdrDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.longline.TripLonglineDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.longline.TripLonglineDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.longline.TripLonglineDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.longline.TripLonglineDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.CountryDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.CountryDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.CountryDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.CountryDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.FpaZoneDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.FpaZoneDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.FpaZoneDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.FpaZoneDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.GearDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.GearDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.GearDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.GearDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.GearCaracteristicDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.GearCaracteristicDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.GearCaracteristicDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.GearCaracteristicDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.GearCaracteristicTypeDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.GearCaracteristicTypeDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.GearCaracteristicTypeDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.GearCaracteristicTypeDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.HarbourDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.HarbourDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.HarbourDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.HarbourDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.LengthWeightParameterDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.LengthWeightParameterDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.LengthWeightParameterDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.LengthWeightParameterDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.OceanDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.OceanDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.OceanDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.OceanDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.OrganismDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.OrganismDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.OrganismDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.OrganismDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.PersonDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.PersonDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.PersonDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.PersonDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.ProgramDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.ProgramDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.ProgramDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.ProgramDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.SexDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.SexDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.SexDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.SexDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.SpeciesDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.SpeciesDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.SpeciesDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.SpeciesDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.SpeciesGroupDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.SpeciesGroupDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.SpeciesGroupDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.SpeciesGroupDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.SpeciesListDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.SpeciesListDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.SpeciesListDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.SpeciesListDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.VesselDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.VesselDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.VesselDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.VesselDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.VesselSizeCategoryDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.VesselSizeCategoryDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.VesselSizeCategoryDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.VesselSizeCategoryDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.VesselTypeDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.VesselTypeDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.VesselTypeDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.VesselTypeDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.BaitHaulingStatusDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.BaitHaulingStatusDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.BaitHaulingStatusDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.BaitHaulingStatusDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.BaitSettingStatusDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.BaitSettingStatusDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.BaitSettingStatusDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.BaitSettingStatusDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.BaitTypeDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.BaitTypeDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.BaitTypeDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.BaitTypeDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.CatchFateLonglineDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.CatchFateLonglineDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.CatchFateLonglineDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.CatchFateLonglineDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.EncounterTypeDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.EncounterTypeDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.EncounterTypeDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.EncounterTypeDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.HealthnessDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.HealthnessDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.HealthnessDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.HealthnessDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.HookPositionDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.HookPositionDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.HookPositionDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.HookPositionDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.HookSizeDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.HookSizeDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.HookSizeDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.HookSizeDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.HookTypeDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.HookTypeDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.HookTypeDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.HookTypeDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.ItemHorizontalPositionDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.ItemHorizontalPositionDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.ItemHorizontalPositionDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.ItemHorizontalPositionDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.ItemVerticalPositionDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.ItemVerticalPositionDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.ItemVerticalPositionDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.ItemVerticalPositionDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.LightsticksColorDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.LightsticksColorDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.LightsticksColorDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.LightsticksColorDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.LightsticksTypeDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.LightsticksTypeDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.LightsticksTypeDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.LightsticksTypeDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.LineTypeDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.LineTypeDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.LineTypeDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.LineTypeDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.MaturityStatusDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.MaturityStatusDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.MaturityStatusDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.MaturityStatusDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.MitigationTypeDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.MitigationTypeDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.MitigationTypeDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.MitigationTypeDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.SensorBrandDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.SensorBrandDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.SensorBrandDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.SensorBrandDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.SensorDataFormatDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.SensorDataFormatDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.SensorDataFormatDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.SensorDataFormatDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.SensorTypeDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.SensorTypeDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.SensorTypeDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.SensorTypeDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.SettingShapeDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.SettingShapeDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.SettingShapeDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.SettingShapeDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.SizeMeasureTypeDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.SizeMeasureTypeDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.SizeMeasureTypeDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.SizeMeasureTypeDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.StomacFullnessDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.StomacFullnessDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.StomacFullnessDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.StomacFullnessDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.TripTypeDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.TripTypeDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.TripTypeDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.TripTypeDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.VesselActivityLonglineDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.VesselActivityLonglineDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.VesselActivityLonglineDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.VesselActivityLonglineDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.WeightMeasureTypeDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.WeightMeasureTypeDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.WeightMeasureTypeDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.longline.WeightMeasureTypeDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.DetectionModeDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.DetectionModeDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.DetectionModeDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.DetectionModeDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.ObjectFateDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.ObjectFateDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.ObjectFateDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.ObjectFateDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.ObjectOperationDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.ObjectOperationDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.ObjectOperationDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.ObjectOperationDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.ObjectTypeDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.ObjectTypeDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.ObjectTypeDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.ObjectTypeDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.ObservedSystemDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.ObservedSystemDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.ObservedSystemDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.ObservedSystemDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.ReasonForDiscardDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.ReasonForDiscardDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.ReasonForDiscardDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.ReasonForDiscardDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.ReasonForNoFishingDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.ReasonForNoFishingDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.ReasonForNoFishingDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.ReasonForNoFishingDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.ReasonForNullSetDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.ReasonForNullSetDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.ReasonForNullSetDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.ReasonForNullSetDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.SpeciesFateDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.SpeciesFateDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.SpeciesFateDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.SpeciesFateDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.SpeciesStatusDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.SpeciesStatusDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.SpeciesStatusDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.SpeciesStatusDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.SurroundingActivityDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.SurroundingActivityDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.SurroundingActivityDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.SurroundingActivityDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.TransmittingBuoyOperationDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.TransmittingBuoyOperationDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.TransmittingBuoyOperationDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.TransmittingBuoyOperationDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.TransmittingBuoyTypeDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.TransmittingBuoyTypeDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.TransmittingBuoyTypeDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.TransmittingBuoyTypeDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.VesselActivitySeineDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.VesselActivitySeineDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.VesselActivitySeineDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.VesselActivitySeineDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.WeightCategoryDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.WeightCategoryDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.WeightCategoryDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.WeightCategoryDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.WindDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.WindDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.WindDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.referential.seine.WindDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.seine.ActivitySeineDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.seine.ActivitySeineDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.seine.ActivitySeineDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.seine.ActivitySeineDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.seine.FloatingObjectDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.seine.FloatingObjectDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.seine.FloatingObjectDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.seine.FloatingObjectDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.seine.GearUseFeaturesSeineDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.seine.NonTargetCatchDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.seine.NonTargetCatchDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.seine.NonTargetLengthDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.seine.NonTargetLengthDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.seine.NonTargetSampleDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.seine.ObjectObservedSpeciesDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.seine.ObjectSchoolEstimateDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.seine.ObjectSchoolEstimateDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.seine.RouteDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.seine.RouteDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.seine.RouteDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.seine.RouteDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.seine.SchoolEstimateDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.seine.SetSeineDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.seine.SetSeineDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.seine.SetSeineDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.seine.SetSeineDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.seine.TargetLengthDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.seine.TargetLengthDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.seine.TargetSampleDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.seine.TransmittingBuoyDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.seine.TransmittingBuoyDto", + "scope": "WARNING", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.seine.TripSeineDto", + "scope": "WARNING", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.seine.TripSeineDto", + "scope": "ERROR", + "context": "n1-create" + }, + { + "dtoType": "fr.ird.observe.services.dto.seine.TripSeineDto", + "scope": "ERROR", + "context": "n1-update" + }, + { + "dtoType": "fr.ird.observe.services.dto.seine.TripSeineDto", + "scope": "WARNING", + "context": "n1-update" + } +] diff --git a/observe-services-configuration-api/src/main/java/fr/ird/observe/services/configuration/ObserveDataSourceConfiguration.java b/observe-services-configuration-api/src/main/java/fr/ird/observe/services/configuration/ObserveDataSourceConfiguration.java index 866e32d..7a78397 100644 --- a/observe-services-configuration-api/src/main/java/fr/ird/observe/services/configuration/ObserveDataSourceConfiguration.java +++ b/observe-services-configuration-api/src/main/java/fr/ird/observe/services/configuration/ObserveDataSourceConfiguration.java @@ -31,10 +31,12 @@ import java.io.Serializable; * * @author Tony Chemit - chemit@codelutin.com */ -public interface ObserveDataSourceConfiguration extends Serializable { +public interface ObserveDataSourceConfiguration extends Serializable, Cloneable { String getLabel(); Version getModelVersion(); + ObserveDataSourceConfiguration clone() throws CloneNotSupportedException; + } diff --git a/observe-services-configuration-rest/src/main/java/fr/ird/observe/services/configuration/ObserveDataSourceConfigurationRest.java b/observe-services-configuration-rest/src/main/java/fr/ird/observe/services/configuration/ObserveDataSourceConfigurationRest.java index 38af297..5782816 100644 --- a/observe-services-configuration-rest/src/main/java/fr/ird/observe/services/configuration/ObserveDataSourceConfigurationRest.java +++ b/observe-services-configuration-rest/src/main/java/fr/ird/observe/services/configuration/ObserveDataSourceConfigurationRest.java @@ -35,7 +35,7 @@ import java.net.URL; * * @author Tony Chemit - chemit@codelutin.com */ -public class ObserveDataSourceConfigurationRest implements ObserveDataSourceConfiguration, Cloneable { +public class ObserveDataSourceConfigurationRest implements ObserveDataSourceConfiguration { private static final long serialVersionUID = 1L; diff --git a/observe-services-configuration-topia/src/main/java/fr/ird/observe/services/configuration/ObserveDataSourceConfigurationTopiaH2.java b/observe-services-configuration-topia/src/main/java/fr/ird/observe/services/configuration/ObserveDataSourceConfigurationTopiaH2.java index 53958d2..955f67f 100644 --- a/observe-services-configuration-topia/src/main/java/fr/ird/observe/services/configuration/ObserveDataSourceConfigurationTopiaH2.java +++ b/observe-services-configuration-topia/src/main/java/fr/ird/observe/services/configuration/ObserveDataSourceConfigurationTopiaH2.java @@ -32,7 +32,7 @@ import java.util.Objects; * * @author Tony Chemit - chemit@codelutin.com */ -public class ObserveDataSourceConfigurationTopiaH2 extends ObserveDataSourceConfigurationTopiaSupport implements Cloneable { +public class ObserveDataSourceConfigurationTopiaH2 extends ObserveDataSourceConfigurationTopiaSupport { private static final long serialVersionUID = 1L; diff --git a/observe-services-configuration-topia/src/main/java/fr/ird/observe/services/configuration/ObserveDataSourceConfigurationTopiaPG.java b/observe-services-configuration-topia/src/main/java/fr/ird/observe/services/configuration/ObserveDataSourceConfigurationTopiaPG.java index fd1219b..ae9af6e 100644 --- a/observe-services-configuration-topia/src/main/java/fr/ird/observe/services/configuration/ObserveDataSourceConfigurationTopiaPG.java +++ b/observe-services-configuration-topia/src/main/java/fr/ird/observe/services/configuration/ObserveDataSourceConfigurationTopiaPG.java @@ -31,7 +31,7 @@ import java.util.Objects; * * @author Tony Chemit - chemit@codelutin.com */ -public class ObserveDataSourceConfigurationTopiaPG extends ObserveDataSourceConfigurationTopiaSupport implements Cloneable { +public class ObserveDataSourceConfigurationTopiaPG extends ObserveDataSourceConfigurationTopiaSupport { private static final long serialVersionUID = 1L; diff --git a/observe-services-configuration-topia/src/main/java/fr/ird/observe/services/configuration/ObserveDataSourceConfigurationTopiaSupport.java b/observe-services-configuration-topia/src/main/java/fr/ird/observe/services/configuration/ObserveDataSourceConfigurationTopiaSupport.java index cc0a649..042923a 100644 --- a/observe-services-configuration-topia/src/main/java/fr/ird/observe/services/configuration/ObserveDataSourceConfigurationTopiaSupport.java +++ b/observe-services-configuration-topia/src/main/java/fr/ird/observe/services/configuration/ObserveDataSourceConfigurationTopiaSupport.java @@ -139,4 +139,9 @@ public abstract class ObserveDataSourceConfigurationTopiaSupport implements Obse public void setModelVersion(Version modelVersion) { this.modelVersion = modelVersion; } + + @Override + public ObserveDataSourceConfigurationTopiaSupport clone() throws CloneNotSupportedException { + return (ObserveDataSourceConfigurationTopiaSupport) super.clone(); + } } diff --git a/observe-services-model/src/main/java/fr/ird/observe/services/dto/IdDtos.java b/observe-services-model/src/main/java/fr/ird/observe/services/dto/IdDtos.java index dbe5376..5a3dc17 100644 --- a/observe-services-model/src/main/java/fr/ird/observe/services/dto/IdDtos.java +++ b/observe-services-model/src/main/java/fr/ird/observe/services/dto/IdDtos.java @@ -33,6 +33,26 @@ public class IdDtos extends AbstractIdDtos { return Iterables.find(source, newIdPredicate(id)); } + public static boolean isTrip(IdDto dto) { + return isTripSeine(dto) || isTripLongline(dto); + } + + private static boolean isTripLongline(IdDto dto) { + return isTripLonglineId(dto.getId()); + } + + private static boolean isTripLonglineId(String id) { + return id.contains("TripLongline"); + } + + private static boolean isTripSeine(IdDto dto) { + return isTripSeineId(dto.getId()); + } + + private static boolean isTripSeineId(String id) { + return id.contains("TripSeine"); + } + public static boolean isSeineId(String id) { return id.contains("Seine"); } diff --git a/observe-services-model/src/main/java/fr/ird/observe/services/dto/gson/ReferenceDtoAdapter.java b/observe-services-model/src/main/java/fr/ird/observe/services/dto/gson/ReferenceDtoAdapter.java index e452eaf..58def1b 100644 --- a/observe-services-model/src/main/java/fr/ird/observe/services/dto/gson/ReferenceDtoAdapter.java +++ b/observe-services-model/src/main/java/fr/ird/observe/services/dto/gson/ReferenceDtoAdapter.java @@ -65,10 +65,12 @@ public class ReferenceDtoAdapter implements JsonDeserializer<ReferenceDto<?>>, J for (int i = 0; i < jsonLabelPropertyNames.size(); i++) { String name = jsonLabelPropertyNames.get(i).getAsString(); Class type = context.deserialize(JsonLabelPropertyTypes.get(i), Class.class); - Serializable value = context.deserialize(jsonLabelPropertyValues.get(i), type); - - labelPropertyNames.add(name); - valuesByName.put(name, value); + JsonElement jsonValue = jsonLabelPropertyValues.get(i); + if (jsonValue != null && type != null) { + Serializable value = context.deserialize(jsonValue, type); + labelPropertyNames.add(name); + valuesByName.put(name, value); + } } ReferenceDto<?> referenceDto; diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/ObserveServiceTopia.java b/observe-services-topia/src/main/java/fr/ird/observe/services/ObserveServiceTopia.java index dfc092d..2b35329 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/ObserveServiceTopia.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/ObserveServiceTopia.java @@ -26,6 +26,7 @@ import com.google.common.base.Optional; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; import com.google.common.collect.Multimap; import fr.ird.observe.ObserveTopiaApplicationContext; import fr.ird.observe.ObserveTopiaPersistenceContext; @@ -34,8 +35,16 @@ import fr.ird.observe.entities.FollowedUpdateEntity; import fr.ird.observe.entities.LastUpdateType; import fr.ird.observe.entities.LastUpdateTypeTopiaDao; import fr.ird.observe.entities.constants.ReferenceLocale; +import fr.ird.observe.entities.longline.ActivityLongline; +import fr.ird.observe.entities.longline.Encounter; import fr.ird.observe.entities.longline.TripLongline; import fr.ird.observe.entities.referentiel.ReferenceEntity; +import fr.ird.observe.entities.seine.ActivitySeine; +import fr.ird.observe.entities.seine.FloatingObject; +import fr.ird.observe.entities.seine.NonTargetCatch; +import fr.ird.observe.entities.seine.SchoolEstimate; +import fr.ird.observe.entities.seine.TargetLength; +import fr.ird.observe.entities.seine.TripSeine; import fr.ird.observe.services.builder.DtoToEntityBuilder; import fr.ird.observe.services.builder.EntityToDtoBuilder; import fr.ird.observe.services.builder.EntityToReferenceDtoBuilder; @@ -51,11 +60,23 @@ import fr.ird.observe.services.dto.IncompatibleDataSourceCreateConfigurationExce import fr.ird.observe.services.dto.ObserveDtosInitializer; import fr.ird.observe.services.dto.ObserveModelInitializerRunner; import fr.ird.observe.services.dto.ReferenceDto; +import fr.ird.observe.services.dto.ReferenceDtos; import fr.ird.observe.services.dto.ReferenceSetDto; import fr.ird.observe.services.dto.ReferenceSetDtos; import fr.ird.observe.services.dto.ReferenceTypeName; import fr.ird.observe.services.dto.constants.ReferentialLocale; +import fr.ird.observe.services.dto.longline.ActivityLonglineDto; +import fr.ird.observe.services.dto.longline.EncounterDto; +import fr.ird.observe.services.dto.longline.SetLonglineDto; +import fr.ird.observe.services.dto.longline.TripLonglineDto; import fr.ird.observe.services.dto.referential.ReferentialDto; +import fr.ird.observe.services.dto.seine.ActivitySeineDto; +import fr.ird.observe.services.dto.seine.FloatingObjectDto; +import fr.ird.observe.services.dto.seine.NonTargetCatchDto; +import fr.ird.observe.services.dto.seine.SchoolEstimateDto; +import fr.ird.observe.services.dto.seine.SetSeineDto; +import fr.ird.observe.services.dto.seine.TargetLengthDto; +import fr.ird.observe.services.dto.seine.TripSeineDto; import fr.ird.observe.services.entity.EntitiesExtractor; import fr.ird.observe.services.entity.EntitiesSetFactory; import fr.ird.observe.services.service.ConcurrentModificationException; @@ -414,6 +435,42 @@ public abstract class ObserveServiceTopia implements ObserveService { referenceDto = EntityToReferentialReferenceDtoBuilder.build((Class) dtoType, serviceContext.getReferentialLocale(), (ReferenceEntity) entity); + } else if (TripLonglineDto.class.isAssignableFrom(dtoType) && entity instanceof TripLongline) { + + referenceDto = (ReferenceDto<D>) entityToReferenceDto((TripLongline) entity); + + } else if (ActivityLonglineDto.class.isAssignableFrom(dtoType) && entity instanceof ActivityLongline) { + + referenceDto = (ReferenceDto<D>) entityToReferenceDto((ActivityLongline) entity); + + } else if (TripSeineDto.class.isAssignableFrom(dtoType) && entity instanceof TripSeine) { + + referenceDto = (ReferenceDto<D>) entityToReferenceDto((TripSeine) entity); + + } else if (ActivitySeineDto.class.isAssignableFrom(dtoType) && entity instanceof ActivitySeine) { + + referenceDto = (ReferenceDto<D>) entityToReferenceDto((ActivitySeine) entity); + + } else if (EncounterDto.class.isAssignableFrom(dtoType) && entity instanceof Encounter) { + + referenceDto = (ReferenceDto<D>) entityToReferenceDto((Encounter) entity); + + } else if (NonTargetCatchDto.class.isAssignableFrom(dtoType) && entity instanceof NonTargetCatch) { + + referenceDto = (ReferenceDto<D>) entityToReferenceDto((NonTargetCatch) entity); + + } else if (FloatingObjectDto.class.isAssignableFrom(dtoType) && entity instanceof FloatingObject) { + + referenceDto = (ReferenceDto<D>) entityToReferenceDto((FloatingObject) entity); + + } else if (SchoolEstimateDto.class.isAssignableFrom(dtoType) && entity instanceof SchoolEstimate) { + + referenceDto = (ReferenceDto<D>) entityToReferenceDto((SchoolEstimate) entity); + + } else if (TargetLengthDto.class.isAssignableFrom(dtoType) && entity instanceof TargetLength) { + + referenceDto = (ReferenceDto<D>) entityToReferenceDto((TargetLength) entity); + } else { referenceDto = EntityToReferenceDtoBuilder.build(dtoType, serviceContext.getReferentialLocale(), entity); @@ -425,6 +482,171 @@ public abstract class ObserveServiceTopia implements ObserveService { } + protected ReferenceDto<NonTargetCatchDto> entityToReferenceDto(NonTargetCatch entity) { + + ReferenceLocale referenceLocale = getReferenceLocale(); + + ReferenceDto<NonTargetCatchDto> referenceDto = + ReferenceDtos.newReferenceDto(NonTargetCatchDto.class, + Lists.newArrayList(NonTargetCatchDto.PROPERTY_SPECIES, + NonTargetCatchDto.PROPERTY_SPECIES_FATE)); + + referenceDto.setId(entity.getTopiaId()); + referenceDto.setPropertyValue(NonTargetCatchDto.PROPERTY_SPECIES, entity.getSpecies().getScientificLabel()); + referenceDto.setPropertyValue(NonTargetCatchDto.PROPERTY_SPECIES_FATE, referenceLocale.getLabel(entity.getSpeciesFate())); + + return referenceDto; + } + + protected ReferenceDto<FloatingObjectDto> entityToReferenceDto(FloatingObject entity) { + + ReferenceLocale referenceLocale = getReferenceLocale(); + + ReferenceDto<FloatingObjectDto> referenceDto = + ReferenceDtos.newReferenceDto(FloatingObjectDto.class, + Lists.newArrayList(FloatingObjectDto.PROPERTY_OBJECT_TYPE)); + + referenceDto.setId(entity.getTopiaId()); + referenceDto.setPropertyValue(FloatingObjectDto.PROPERTY_OBJECT_TYPE, referenceLocale.getLabel(entity.getObjectType())); + + return referenceDto; + } + + protected ReferenceDto<SchoolEstimateDto> entityToReferenceDto(SchoolEstimate entity) { + + ReferenceLocale referenceLocale = getReferenceLocale(); + + ReferenceDto<SchoolEstimateDto> referenceDto = + ReferenceDtos.newReferenceDto(SchoolEstimateDto.class, + Lists.newArrayList(SchoolEstimateDto.PROPERTY_SPECIES, + SchoolEstimateDto.PROPERTY_MEAN_WEIGHT, + SchoolEstimateDto.PROPERTY_TOTAL_WEIGHT)); + + referenceDto.setId(entity.getTopiaId()); + referenceDto.setPropertyValue(SchoolEstimateDto.PROPERTY_SPECIES, referenceLocale.getLabel(entity.getSpecies())); + if (entity.getMeanWeight() != null) { + referenceDto.setPropertyValue(SchoolEstimateDto.PROPERTY_MEAN_WEIGHT, entity.getMeanWeight()); + } + if (entity.getTotalWeight() != null) { + referenceDto.setPropertyValue(SchoolEstimateDto.PROPERTY_TOTAL_WEIGHT, entity.getTotalWeight()); + } + + return referenceDto; + } + + protected ReferenceDto<TargetLengthDto> entityToReferenceDto(TargetLength entity) { + + ReferenceLocale referenceLocale = getReferenceLocale(); + + ReferenceDto<TargetLengthDto> referenceDto = + ReferenceDtos.newReferenceDto(TargetLengthDto.class, + Lists.newArrayList(TargetLengthDto.PROPERTY_SPECIES, + TargetLengthDto.PROPERTY_LENGTH, + TargetLengthDto.PROPERTY_COUNT)); + + referenceDto.setId(entity.getTopiaId()); + referenceDto.setPropertyValue(TargetLengthDto.PROPERTY_SPECIES, referenceLocale.getLabel(entity.getSpecies())); + if (entity.getLength() != null) { + referenceDto.setPropertyValue(TargetLengthDto.PROPERTY_LENGTH, entity.getLength()); + } + if (entity.getCount() != null) { + referenceDto.setPropertyValue(TargetLengthDto.PROPERTY_COUNT, entity.getCount()); + } + + return referenceDto; + } + + protected ReferenceDto<TripLonglineDto> entityToReferenceDto(TripLongline entity) { + + ReferenceLocale referenceLocale = getReferenceLocale(); + + ReferenceDto<TripLonglineDto> referenceDto = + ReferenceDtos.newReferenceDto(TripLonglineDto.class, + Lists.newArrayList(TripLonglineDto.PROPERTY_START_DATE, + TripLonglineDto.PROPERTY_END_DATE, + TripLonglineDto.PROPERTY_VESSEL, + TripLonglineDto.PROPERTY_OBSERVER)); + + referenceDto.setId(entity.getTopiaId()); + referenceDto.setPropertyValue(TripLonglineDto.PROPERTY_START_DATE, entity.getStartDate()); + referenceDto.setPropertyValue(TripLonglineDto.PROPERTY_END_DATE, entity.getEndDate()); + referenceDto.setPropertyValue(TripLonglineDto.PROPERTY_VESSEL, referenceLocale.getLabel(entity.getVessel())); + referenceDto.setPropertyValue(TripLonglineDto.PROPERTY_OBSERVER, entity.getObserverLabel()); + + return referenceDto; + } + + protected ReferenceDto<ActivityLonglineDto> entityToReferenceDto(ActivityLongline entity) { + + ReferenceLocale referenceLocale = getReferenceLocale(); + + ReferenceDto<ActivityLonglineDto> referenceDto = ReferenceDtos.newReferenceDto( + ActivityLonglineDto.class, + Lists.newArrayList(ActivityLonglineDto.PROPERTY_TIME_STAMP, + ActivityLonglineDto.PROPERTY_VESSEL_ACTIVITY_LONGLINE, + ActivityLonglineDto.PROPERTY_SET_LONGLINE)); + + referenceDto.setId(entity.getTopiaId()); + referenceDto.setPropertyValue(ActivityLonglineDto.PROPERTY_TIME_STAMP, entity.getTimeStamp()); + referenceDto.setPropertyValue(ActivityLonglineDto.PROPERTY_VESSEL_ACTIVITY_LONGLINE, referenceLocale.getLabel(entity.getVesselActivityLongline())); + if (entity.getSetLongline() != null) { + referenceDto.setPropertyValue(ActivityLonglineDto.PROPERTY_SET_LONGLINE, entityToReferenceDto(SetLonglineDto.class, entity.getSetLongline())); + } + + return referenceDto; + } + + protected ReferenceDto<TripSeineDto> entityToReferenceDto(TripSeine entity) { + + ReferenceLocale referenceLocale = getReferenceLocale(); + + ReferenceDto<TripSeineDto> referenceDto = ReferenceDtos.newReferenceDto(TripSeineDto.class, + Lists.newArrayList(TripSeineDto.PROPERTY_ID, + TripSeineDto.PROPERTY_START_DATE, + TripSeineDto.PROPERTY_END_DATE, + TripSeineDto.PROPERTY_VESSEL, + TripSeineDto.PROPERTY_OBSERVER)); + referenceDto.setId(entity.getTopiaId()); + referenceDto.setPropertyValue(TripSeineDto.PROPERTY_START_DATE, entity.getStartDate()); + referenceDto.setPropertyValue(TripSeineDto.PROPERTY_END_DATE, entity.getEndDate()); + referenceDto.setPropertyValue(TripSeineDto.PROPERTY_VESSEL, referenceLocale.getLabel(entity.getVessel())); + referenceDto.setPropertyValue(TripSeineDto.PROPERTY_OBSERVER, entity.getObserverLabel()); + + return referenceDto; + } + + protected ReferenceDto<ActivitySeineDto> entityToReferenceDto(ActivitySeine entity) { + + ReferenceLocale referenceLocale = getReferenceLocale(); + + ReferenceDto<ActivitySeineDto> referenceDto = ReferenceDtos.newReferenceDto(ActivitySeineDto.class, + Lists.newArrayList(ActivitySeineDto.PROPERTY_TIME, + ActivitySeineDto.PROPERTY_VESSEL_ACTIVITY_SEINE, + ActivitySeineDto.PROPERTY_SET_SEINE)); + referenceDto.setId(entity.getTopiaId()); + referenceDto.setPropertyValue(ActivitySeineDto.PROPERTY_TIME, entity.getTime()); + referenceDto.setPropertyValue(ActivitySeineDto.PROPERTY_VESSEL_ACTIVITY_SEINE, referenceLocale.getLabel(entity.getVesselActivitySeine())); + if (entity.getSetSeine() != null) { + referenceDto.setPropertyValue(ActivitySeineDto.PROPERTY_SET_SEINE, entityToReferenceDto(SetSeineDto.class, entity.getSetSeine())); + } + + return referenceDto; + } + + protected ReferenceDto<EncounterDto> entityToReferenceDto(Encounter entity) { + + ReferenceLocale referenceLocale = getReferenceLocale(); + + ReferenceDto<EncounterDto> referenceDto = ReferenceDtos.newReferenceDto(EncounterDto.class, + Lists.newArrayList(EncounterDto.PROPERTY_ENCOUNTER_TYPE, + EncounterDto.PROPERTY_SPECIES)); + referenceDto.setId(entity.getTopiaId()); + referenceDto.setPropertyValue(EncounterDto.PROPERTY_ENCOUNTER_TYPE, referenceLocale.getLabel(entity.getEncounterType())); + referenceDto.setPropertyValue(EncounterDto.PROPERTY_SPECIES, referenceLocale.getLabel(entity.getSpecies())); + + return referenceDto; + } + protected <D extends IdDto> ReferenceSetDto<D> getReferenceSet(Class<D> dtoType) { Class<TopiaEntity> entityType = getEntityType(dtoType); return getReferenceSet(dtoType, null, entityType, null, ImmutableMap.<String, Object>of()); diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/dto/ObserveDtosInitializer.java b/observe-services-topia/src/main/java/fr/ird/observe/services/dto/ObserveDtosInitializer.java index 3ac43af..56ad764 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/dto/ObserveDtosInitializer.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/dto/ObserveDtosInitializer.java @@ -395,8 +395,6 @@ public class ObserveDtosInitializer implements ObserveModelInitializer { ActivityLonglineDto.PROPERTY_LAST_UPDATE ); - registerReferenceBinder(ActivityLonglineDto.class, ActivityLongline.class, - ActivityLonglineDto.PROPERTY_TIME_STAMP); } @Override @@ -522,6 +520,9 @@ public class ObserveDtosInitializer implements ObserveModelInitializer { CatchLonglineDto.PROPERTY_BASKET, CatchLonglineDto.PROPERTY_BRANCHLINE ); + + registerReferenceBinder(CatchLonglineDto.class, CatchLongline.class, + CatchLonglineDto.PROPERTY_HOME_ID); } @Override @@ -1529,6 +1530,10 @@ public class ObserveDtosInitializer implements ObserveModelInitializer { RouteDto.PROPERTY_LAST_UPDATE, RouteDto.PROPERTY_ACTIVITY_SEINE ); + registerReferenceBinder(RouteDto.class, Route.class, + RouteDto.PROPERTY_COMMENT, + RouteDto.PROPERTY_DATE + ); } @Override @@ -1569,6 +1574,7 @@ public class ObserveDtosInitializer implements ObserveModelInitializer { SetSeineDto.PROPERTY_REASON_FOR_NULL_SET, SetSeineDto.PROPERTY_LAST_UPDATE ); + registerReferenceBinder(SetSeineDto.class, SetSeine.class); } @Override @@ -1631,6 +1637,7 @@ public class ObserveDtosInitializer implements ObserveModelInitializer { TargetSampleDto.PROPERTY_NATURE, TargetSampleDto.PROPERTY_DISCARDED, TargetSampleDto.PROPERTY_TARGET_LENGTH); + registerReferenceBinder(TargetSampleDto.class, TargetSample.class); } @Override diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/service/DataSourceServiceTopia.java b/observe-services-topia/src/main/java/fr/ird/observe/services/service/DataSourceServiceTopia.java index 4fbe103..d32d557 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/service/DataSourceServiceTopia.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/service/DataSourceServiceTopia.java @@ -147,6 +147,9 @@ public class DataSourceServiceTopia extends ObserveServiceTopia implements DataS } + // FIXME A utiliser pour generé le contenu du fichier fr/ird/observe/services/service/actions/validate/validators.json + // ValidateServiceTopia.showValidators(); + return dataSourceInformation; } 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 09fef71..4706629 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 @@ -58,8 +58,8 @@ public class ReferentialServiceTopia extends ObserveServiceTopia implements Refe } @Override - public <D extends ReferentialDto> ReferenceSetDto<D> getReferentialReferenceSet(Class<D> dtoType, boolean loadTechnicalInformations) { - return getReferenceSet(dtoType, loadTechnicalInformations); + public <D extends ReferentialDto> ReferenceSetDto<D> getReferentialReferenceSetWithTechnicalInformations(Class<D> dtoType) { + return getReferenceSet(dtoType, true); } @Override diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/service/actions/validate/ValidateServiceTopia.java b/observe-services-topia/src/main/java/fr/ird/observe/services/service/actions/validate/ValidateServiceTopia.java index a85c44d..45240f3 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/service/actions/validate/ValidateServiceTopia.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/service/actions/validate/ValidateServiceTopia.java @@ -25,6 +25,8 @@ package fr.ird.observe.services.service.actions.validate; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; +import com.google.common.collect.Sets; +import com.google.gson.Gson; import fr.ird.observe.ObserveEntityEnum; import fr.ird.observe.entities.Entities; import fr.ird.observe.entities.Trip; @@ -34,6 +36,7 @@ import fr.ird.observe.entities.seine.TripSeine; import fr.ird.observe.services.ObserveServiceTopia; import fr.ird.observe.services.dto.IdDto; import fr.ird.observe.services.dto.ReferenceDto; +import fr.ird.observe.services.dto.gson.ObserveDtoGsonSupplier; import fr.ird.observe.services.dto.longline.TripLonglineDto; import fr.ird.observe.services.dto.referential.ReferentialDto; import fr.ird.observe.services.dto.seine.TripSeineDto; @@ -41,6 +44,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.topia.persistence.TopiaEntity; import org.nuiton.validator.NuitonValidatorScope; +import org.nuiton.validator.bean.simple.SimpleBeanValidator; import java.util.Collection; import java.util.Map; @@ -53,11 +57,77 @@ public class ValidateServiceTopia extends ObserveServiceTopia implements Validat private static final Log log = LogFactory.getLog(ValidateServiceTopia.class); - @Override - public ImmutableSet<String> getAvailableContextNames() { - return AVAILABLE_CONTEXT_NAMES; + + // FIXME Bavencoff + // cette entré permet de générer dans la sortie courante le JSON a utilisé dans le fichier fr/ird/observe/services/service/actions/validate/validators.json + public static void showValidators() { + + ImmutableSet<ValidatorDto> validators = getValidators(); + + ObserveDtoGsonSupplier gsonSupplier = new ObserveDtoGsonSupplier(true); + + Gson gson = gsonSupplier.get(); + + String validatorsJson = gson.toJson(validators); + + System.out.print(validatorsJson); + + } + + public static ImmutableSet<ValidatorDto> getValidators() { + + ImmutableSet.Builder<ValidatorDto> setBuilder = ImmutableSet.builder(); + + NuitonValidatorScope[] scopes = NuitonValidatorScope.values(); + + for (Map.Entry<Class<?>, Class<?>> entry : ENTITY_TO_DTO_TYPES.entrySet()) { + + Class<? extends TopiaEntity> entityType = (Class<? extends TopiaEntity>) entry.getKey(); + Class<? extends IdDto> dtoType = (Class<? extends IdDto>) entry.getValue(); + + for (String context : AVAILABLE_CONTEXT_NAMES) { + Set<ValidatorDto> validatorDtos = getValidatorDtos(context, scopes, entityType, dtoType); + setBuilder.addAll(validatorDtos); + } + + } + + return setBuilder.build(); } + /** + * Obtenir le validateur d'un type objet + * + * @param context le lastName du context de validation + * @param scopes les scopes autorisés + * @param entityType type de l'entité à valider + * @param dtoType type de Dto associé au type d'entité à valider + * @return l'esemble de validateur trouvé + */ + protected static Set<ValidatorDto> getValidatorDtos(String context, + NuitonValidatorScope[] scopes, + Class<? extends TopiaEntity> entityType, + Class<? extends IdDto> dtoType) { + + SimpleBeanValidator valitator = SimpleBeanValidator.newValidator( + entityType, + context, + scopes + ); + + Set<NuitonValidatorScope> resultScopes = valitator.getEffectiveScopes(); + + Set<ValidatorDto> validators = Sets.newHashSet(); + + for (NuitonValidatorScope scope : resultScopes) { + validators.add(new ValidatorDto(dtoType, scope, context)); + } + + + return validators; + } + + @Override public ValidateReferentialsResult validateReferentials(ValidateReferentialsRequest request) { diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/service/actions/validate/ValidationMessageDetector.java b/observe-services-topia/src/main/java/fr/ird/observe/services/service/actions/validate/ValidationMessageDetector.java index 30d42de..af1d24b 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/service/actions/validate/ValidationMessageDetector.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/service/actions/validate/ValidationMessageDetector.java @@ -29,6 +29,7 @@ import fr.ird.observe.ObserveEntityEnum; import fr.ird.observe.entities.constants.ReferenceLocale; import fr.ird.observe.entities.longline.ActivityLongline; import fr.ird.observe.entities.longline.SetLongline; +import fr.ird.observe.entities.longline.TripLongline; import fr.ird.observe.entities.seine.ActivitySeine; import fr.ird.observe.entities.seine.FloatingObject; import fr.ird.observe.entities.seine.Route; @@ -318,7 +319,7 @@ public class ValidationMessageDetector { validationDataContext.setSetSeineEntity((SetSeine) entity); break; case TripLongline: - validationDataContext.setTripSeineEntity((TripSeine) entity); + validationDataContext.setTripLonglineEntity((TripLongline) entity); break; case ActivityLongline: validationDataContext.setActivityLonglineEntity((ActivityLongline) entity); diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/service/longline/ActivityLonglineServiceTopia.java b/observe-services-topia/src/main/java/fr/ird/observe/services/service/longline/ActivityLonglineServiceTopia.java index bfcc5a8..b6da2ab 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/service/longline/ActivityLonglineServiceTopia.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/service/longline/ActivityLonglineServiceTopia.java @@ -24,7 +24,6 @@ package fr.ird.observe.services.service.longline; import com.google.common.base.Optional; import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; import com.google.common.collect.Sets; import fr.ird.observe.entities.constants.ReferenceLocale; import fr.ird.observe.entities.longline.ActivityLongline; @@ -36,11 +35,9 @@ import fr.ird.observe.entities.seine.ActivitySeine; import fr.ird.observe.services.ObserveServiceTopia; import fr.ird.observe.services.dto.FormDto; import fr.ird.observe.services.dto.ReferenceDto; -import fr.ird.observe.services.dto.ReferenceDtos; import fr.ird.observe.services.dto.ReferenceSetDto; import fr.ird.observe.services.dto.ReferenceSetDtos; import fr.ird.observe.services.dto.longline.ActivityLonglineDto; -import fr.ird.observe.services.dto.longline.SetLonglineDto; import fr.ird.observe.services.dto.longline.TripLonglineDto; import fr.ird.observe.services.dto.result.TripChildSaveResultDto; import fr.ird.observe.services.service.DataNotFoundException; @@ -68,16 +65,7 @@ public class ActivityLonglineServiceTopia extends ObserveServiceTopia implements for (ActivityLongline activityLongline : allStubByTripId) { - ReferenceDto<ActivityLonglineDto> stub = ReferenceDtos.newReferenceDto(ActivityLonglineDto.class, - Lists.newArrayList(ActivityLonglineDto.PROPERTY_TIME_STAMP, - ActivityLonglineDto.PROPERTY_VESSEL_ACTIVITY_LONGLINE, - ActivityLonglineDto.PROPERTY_SET_LONGLINE)); - stub.setId(activityLongline.getTopiaId()); - stub.setPropertyValue(ActivityLonglineDto.PROPERTY_TIME_STAMP, activityLongline.getTimeStamp()); - stub.setPropertyValue(ActivityLonglineDto.PROPERTY_VESSEL_ACTIVITY_LONGLINE, referenceLocale.getLabel(activityLongline.getVesselActivityLongline())); - if (activityLongline.getSetLongline() != null) { - stub.setPropertyValue(ActivityLonglineDto.PROPERTY_SET_LONGLINE, entityToReferenceDto(SetLonglineDto.class, activityLongline.getSetLongline())); - } + ReferenceDto<ActivityLonglineDto> stub = entityToReferenceDto(ActivityLonglineDto.class, activityLongline); stubs.add(stub); } diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/service/longline/TripLonglineServiceTopia.java b/observe-services-topia/src/main/java/fr/ird/observe/services/service/longline/TripLonglineServiceTopia.java index b8b859e..1aeb523 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/service/longline/TripLonglineServiceTopia.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/service/longline/TripLonglineServiceTopia.java @@ -23,7 +23,6 @@ package fr.ird.observe.services.service.longline; */ import com.google.common.base.Optional; -import com.google.common.collect.Lists; import com.google.common.collect.Sets; import fr.ird.observe.entities.constants.ReferenceLocale; import fr.ird.observe.entities.longline.TripLongline; @@ -32,7 +31,6 @@ import fr.ird.observe.entities.referentiel.Program; import fr.ird.observe.services.ObserveServiceTopia; import fr.ird.observe.services.dto.FormDto; import fr.ird.observe.services.dto.ReferenceDto; -import fr.ird.observe.services.dto.ReferenceDtos; import fr.ird.observe.services.dto.ReferenceSetDto; import fr.ird.observe.services.dto.ReferenceSetDtos; import fr.ird.observe.services.dto.TripMapDto; @@ -58,6 +56,32 @@ public class TripLonglineServiceTopia extends ObserveServiceTopia implements Tri } @Override + public ReferenceSetDto<TripLonglineDto> getAllTripLongline() { + + + List<TripLongline> tripLonglines = loadEntities(TripLongline.class); + + LinkedHashSet<ReferenceDto<TripLonglineDto>> stubs = Sets.newLinkedHashSet(); + + for (TripLongline tripLongline : tripLonglines) { + + ReferenceDto<TripLonglineDto> stub = entityToReferenceDto(TripLonglineDto.class, tripLongline); + + stubs.add(stub); + + } + + Optional<Date> lastUpdateOptional = getLastUpdate(TripLongline.class); + ReferenceSetDto<TripLonglineDto> stubReferences = + ReferenceSetDtos.newReferenceSetDto(TripLonglineDto.class, stubs, lastUpdateOptional.orNull()); + + return stubReferences; + } + + + + + @Override public ReferenceSetDto<TripLonglineDto> getTripLonglineByProgram(String programId) { ReferenceLocale referenceLocale = getReferenceLocale(); @@ -68,18 +92,7 @@ public class TripLonglineServiceTopia extends ObserveServiceTopia implements Tri for (TripLongline tripLongline : tripLonglines) { - ReferenceDto<TripLonglineDto> stub = - ReferenceDtos.newReferenceDto(TripLonglineDto.class, - Lists.newArrayList(TripLonglineDto.PROPERTY_START_DATE, - TripLonglineDto.PROPERTY_END_DATE, - TripLonglineDto.PROPERTY_VESSEL, - TripLonglineDto.PROPERTY_OBSERVER)); - - stub.setId(tripLongline.getTopiaId()); - stub.setPropertyValue(TripLonglineDto.PROPERTY_START_DATE, tripLongline.getStartDate()); - stub.setPropertyValue(TripLonglineDto.PROPERTY_END_DATE, tripLongline.getEndDate()); - stub.setPropertyValue(TripLonglineDto.PROPERTY_VESSEL, referenceLocale.getLabel(tripLongline.getVessel())); - stub.setPropertyValue(TripLonglineDto.PROPERTY_OBSERVER, tripLongline.getObserverLabel()); + ReferenceDto<TripLonglineDto> stub = entityToReferenceDto(TripLonglineDto.class, tripLongline); stubs.add(stub); diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/TripSeineServiceTopia.java b/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/TripSeineServiceTopia.java index 6bc7397..ee5a438 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/TripSeineServiceTopia.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/TripSeineServiceTopia.java @@ -22,7 +22,6 @@ package fr.ird.observe.services.service.seine; * #L% */ -import com.google.common.collect.Lists; import com.google.common.collect.Sets; import fr.ird.observe.entities.constants.ReferenceLocale; import fr.ird.observe.entities.referentiel.Program; @@ -31,7 +30,6 @@ import fr.ird.observe.entities.seine.TripSeineTopiaDao; import fr.ird.observe.services.ObserveServiceTopia; import fr.ird.observe.services.dto.FormDto; import fr.ird.observe.services.dto.ReferenceDto; -import fr.ird.observe.services.dto.ReferenceDtos; import fr.ird.observe.services.dto.ReferenceSetDto; import fr.ird.observe.services.dto.ReferenceSetDtos; import fr.ird.observe.services.dto.TripMapDto; @@ -57,6 +55,27 @@ public class TripSeineServiceTopia extends ObserveServiceTopia implements TripSe } @Override + public ReferenceSetDto<TripSeineDto> getAllTripSeine() { + ReferenceLocale referenceLocale = getReferenceLocale(); + + List<TripSeine> tripSeines = loadEntities(TripSeine.class); + + LinkedHashSet<ReferenceDto<TripSeineDto>> stubs = Sets.newLinkedHashSet(); + + for (TripSeine tripSeine : tripSeines) { + + ReferenceDto<TripSeineDto> stub = entityToReferenceDto(TripSeineDto.class, tripSeine); + + stubs.add(stub); + + } + + ReferenceSetDto<TripSeineDto> result = ReferenceSetDtos.newReferenceSetDto(TripSeineDto.class, stubs, null); + + return result; + } + + @Override public ReferenceSetDto<TripSeineDto> getTripSeineByProgram(String programId) { ReferenceLocale referenceLocale = getReferenceLocale(); @@ -70,17 +89,7 @@ public class TripSeineServiceTopia extends ObserveServiceTopia implements TripSe for (TripSeine tripSeine : tripSeines) { - ReferenceDto<TripSeineDto> stub = ReferenceDtos.newReferenceDto(TripSeineDto.class, - Lists.newArrayList(TripSeineDto.PROPERTY_ID, - TripSeineDto.PROPERTY_START_DATE, - TripSeineDto.PROPERTY_END_DATE, - TripSeineDto.PROPERTY_VESSEL, - TripSeineDto.PROPERTY_OBSERVER)); - stub.setId(tripSeine.getTopiaId()); - stub.setPropertyValue(TripSeineDto.PROPERTY_START_DATE, tripSeine.getStartDate()); - stub.setPropertyValue(TripSeineDto.PROPERTY_END_DATE, tripSeine.getEndDate()); - stub.setPropertyValue(TripSeineDto.PROPERTY_VESSEL, referenceLocale.getLabel(tripSeine.getVessel())); - stub.setPropertyValue(TripSeineDto.PROPERTY_OBSERVER, tripSeine.getObserverLabel()); + ReferenceDto<TripSeineDto> stub = entityToReferenceDto(TripSeineDto.class, tripSeine); stubs.add(stub); -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.