Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
24 changed files:
- client-core/src/main/java/fr/ird/observe/client/ObserveSwingApplicationContext.java
- client-core/src/main/java/fr/ird/observe/client/db/ObserveDataSourcesManager.java
- client-core/src/main/java/fr/ird/observe/client/db/ObserveSwingDataSource.java
- client-core/src/main/java/fr/ird/observe/client/ui/ObserveMainUIInitializer.java
- client-core/src/main/java/fr/ird/observe/client/ui/actions/UIActionSupport.java
- client-core/src/main/java/fr/ird/observe/client/ui/actions/content/tree/NavigationConfigUIActionSupport.java
- client-core/src/main/java/fr/ird/observe/client/ui/content/api/ContentUIHandler.java
- client-core/src/main/java/fr/ird/observe/client/ui/storage/StorageUIHandler.java
- client-core/src/main/java/fr/ird/observe/client/ui/tree/ObserveTreeNodeSupport.java
- client-core/src/main/java/fr/ird/observe/client/ui/tree/navigation/NavigationTreeModel.java
- client-core/src/main/java/fr/ird/observe/client/ui/tree/navigation/NavigationUIHandler.java
- client-core/src/main/java/fr/ird/observe/client/validation/ClientValidationContext.java
- dto/src/main/i18n/getters/java.getter
- dto/src/main/java/fr/ird/observe/dto/decoration/DecoratorService.java
- − dto/src/main/java/fr/ird/observe/dto/decoration/decorators/ObserveDecorator.java
- − dto/src/main/java/fr/ird/observe/dto/decoration/decorators/ReferentialReferenceDecorator.java
- observe-i18n/src/main/i18n/translations/observe_en_GB.properties
- observe-i18n/src/main/i18n/translations/observe_es_ES.properties
- observe-i18n/src/main/i18n/translations/observe_fr_FR.properties
- services-validation/src/main/java/fr/ird/observe/services/ObserveServicesProviderImpl.java
- dto/src/main/java/fr/ird/observe/dto/decoration/decorators/DataReferenceDecorator.java → services-validation/src/main/java/fr/ird/observe/services/ObserveServicesProviderSupport.java
- services-validation/src/main/java/fr/ird/observe/validation/validators/TripVesselDtoValidator.java
- validation/src/main/resources/fr/ird/observe/dto/data/ll/common/TripDto-create-error-validation.xml
- validation/src/main/resources/fr/ird/observe/dto/data/ll/common/TripDto-update-error-validation.xml
Changes:
| ... | ... | @@ -42,6 +42,7 @@ import fr.ird.observe.navigation.model.edit.ObserveEditModelManager; |
| 42 | 42 |
import fr.ird.observe.navigation.model.select.ObserveSelectModel;
|
| 43 | 43 |
import fr.ird.observe.services.ObserveDataSourceConfigurationMainFactory;
|
| 44 | 44 |
import fr.ird.observe.services.ObserveServiceMainFactory;
|
| 45 |
+import fr.ird.observe.services.ObserveServicesProvider;
|
|
| 45 | 46 |
import fr.ird.observe.spi.DtoModelHelper;
|
| 46 | 47 |
import fr.ird.observe.validation.ValidatorDto;
|
| 47 | 48 |
import fr.ird.observe.validation.ValidatorsManager;
|
| ... | ... | @@ -216,6 +217,10 @@ public class ObserveSwingApplicationContext extends DefaultApplicationContext im |
| 216 | 217 |
return ((ValidatorsManager) VALIDATORS_MANAGER.get()).getValidators();
|
| 217 | 218 |
}
|
| 218 | 219 |
|
| 220 |
+ public ObserveServicesProvider getServicesProvider() {
|
|
| 221 |
+ return getDataSourcesManager().getMainDataSource();
|
|
| 222 |
+ }
|
|
| 223 |
+ |
|
| 219 | 224 |
public ObserveMainUI getMainUI() {
|
| 220 | 225 |
return MAIN_UI.get();
|
| 221 | 226 |
}
|
| ... | ... | @@ -357,23 +362,23 @@ public class ObserveSwingApplicationContext extends DefaultApplicationContext im |
| 357 | 362 |
super.finalize();
|
| 358 | 363 |
}
|
| 359 | 364 |
|
| 360 |
- public void sanitizeIds(ProgressModel progressModel, DtoModelNavigationAggregateModel navigationSelectModel) {
|
|
| 361 |
- try {
|
|
| 362 |
- for (DtoModelNavigationModel<?> navigationModel : navigationSelectModel.getModels()) {
|
|
| 363 |
- for (DtoModelNavigationNode node : navigationModel.getNodesWithIds()) {
|
|
| 364 |
- if (node.isEnabled()) {
|
|
| 365 |
- ImmutableSet<String> safeIds = ObserveSwingDataSource.MAIN.getNavigationService().retainExistingIds(ImmutableSet.of(node.getId()));
|
|
| 366 |
- if (safeIds.isEmpty()) {
|
|
| 367 |
- node.setId(null);
|
|
| 368 |
- }
|
|
| 369 |
- }
|
|
| 370 |
- progressModel.incrementsCurrentStep();
|
|
| 371 |
- }
|
|
| 372 |
- }
|
|
| 373 |
- } catch (Exception e) {
|
|
| 374 |
- log.error("Could not sanitizeIds", e);
|
|
| 375 |
- }
|
|
| 376 |
- }
|
|
| 365 |
+// public void sanitizeIds(ProgressModel progressModel, DtoModelNavigationAggregateModel navigationSelectModel) {
|
|
| 366 |
+// try {
|
|
| 367 |
+// for (DtoModelNavigationModel<?> navigationModel : navigationSelectModel.getModels()) {
|
|
| 368 |
+// for (DtoModelNavigationNode node : navigationModel.getNodesWithIds()) {
|
|
| 369 |
+// if (node.isEnabled()) {
|
|
| 370 |
+// ImmutableSet<String> safeIds = ObserveSwingDataSource.MAIN.getNavigationService().retainExistingIds(ImmutableSet.of(node.getId()));
|
|
| 371 |
+// if (safeIds.isEmpty()) {
|
|
| 372 |
+// node.setId(null);
|
|
| 373 |
+// }
|
|
| 374 |
+// }
|
|
| 375 |
+// progressModel.incrementsCurrentStep();
|
|
| 376 |
+// }
|
|
| 377 |
+// }
|
|
| 378 |
+// } catch (Exception e) {
|
|
| 379 |
+// log.error("Could not sanitizeIds", e);
|
|
| 380 |
+// }
|
|
| 381 |
+// }
|
|
| 377 | 382 |
|
| 378 | 383 |
public void saveNavigationToConfig(boolean clearModels) {
|
| 379 | 384 |
|
| ... | ... | @@ -568,10 +568,10 @@ public class ObserveDataSourcesManager implements Closeable { |
| 568 | 568 |
boolean withSelectModel = navigationSelectModel != null;
|
| 569 | 569 |
boolean withEditModel = navigationEditModel != null;
|
| 570 | 570 |
if (source.canReadData() && withSelectModel) {
|
| 571 |
- applicationContext.sanitizeIds(progressModel, navigationSelectModel);
|
|
| 571 |
+ dataSource.sanitizeIds(progressModel, navigationSelectModel);
|
|
| 572 | 572 |
}
|
| 573 | 573 |
if (source.canWriteData() && withEditModel) {
|
| 574 |
- applicationContext.sanitizeIds(progressModel, navigationEditModel);
|
|
| 574 |
+ dataSource.sanitizeIds(progressModel, navigationEditModel);
|
|
| 575 | 575 |
}
|
| 576 | 576 |
if (source.canWriteData()) {
|
| 577 | 577 |
applicationContext.getFloatingObjectPresetsManager().sanitize(progressModel, source);
|
| ... | ... | @@ -583,7 +583,7 @@ public class ObserveDataSourcesManager implements Closeable { |
| 583 | 583 |
applicationContext.getNavigationEdit().load(navigationEditModel);
|
| 584 | 584 |
}
|
| 585 | 585 |
|
| 586 |
- mainUI.getInitializer().loadNavigationUI(progressModel);
|
|
| 586 |
+ mainUI.getInitializer().loadNavigationUI(dataSource,progressModel);
|
|
| 587 | 587 |
|
| 588 | 588 |
mainUI.getModel().setMode(ObserveUIMode.DB);
|
| 589 | 589 |
progressModel.incrementsCurrentStep();
|
| ... | ... | @@ -37,9 +37,13 @@ import fr.ird.observe.dto.reference.ReferentialDtoReference; |
| 37 | 37 |
import fr.ird.observe.dto.reference.ReferentialDtoReferenceSet;
|
| 38 | 38 |
import fr.ird.observe.dto.referential.ReferentialDto;
|
| 39 | 39 |
import fr.ird.observe.dto.referential.ReferentialLocale;
|
| 40 |
+import fr.ird.observe.navigation.model.DtoModelNavigationAggregateModel;
|
|
| 41 |
+import fr.ird.observe.navigation.model.DtoModelNavigationModel;
|
|
| 42 |
+import fr.ird.observe.navigation.model.DtoModelNavigationNode;
|
|
| 40 | 43 |
import fr.ird.observe.services.ObserveServiceInitializer;
|
| 41 | 44 |
import fr.ird.observe.services.ObserveServiceMainFactory;
|
| 42 | 45 |
import fr.ird.observe.services.ObserveServicesProvider;
|
| 46 |
+import fr.ird.observe.services.ObserveServicesProviderSupport;
|
|
| 43 | 47 |
import fr.ird.observe.services.configuration.DataSourceCreateConfigurationDto;
|
| 44 | 48 |
import fr.ird.observe.services.configuration.DataSourceCreateWithNoReferentialImportException;
|
| 45 | 49 |
import fr.ird.observe.services.configuration.IncompatibleDataSourceCreateConfigurationException;
|
| ... | ... | @@ -65,14 +69,14 @@ import fr.ird.observe.services.service.referential.ReferentialService; |
| 65 | 69 |
import fr.ird.observe.spi.map.ImmutableSetDtoMap;
|
| 66 | 70 |
import fr.ird.observe.spi.map.ImmutableSetStringMap;
|
| 67 | 71 |
import fr.ird.observe.spi.map.ImmutableTypedMap;
|
| 72 |
+import io.ultreia.java4all.bean.JavaBean;
|
|
| 73 |
+import io.ultreia.java4all.bean.spi.GenerateJavaBeanDefinition;
|
|
| 68 | 74 |
import org.apache.logging.log4j.LogManager;
|
| 69 | 75 |
import org.apache.logging.log4j.Logger;
|
| 70 |
-import org.jdesktop.beans.AbstractSerializableBean;
|
|
| 71 | 76 |
import org.nuiton.version.Version;
|
| 72 | 77 |
|
| 73 | 78 |
import javax.swing.JOptionPane;
|
| 74 | 79 |
import javax.swing.event.EventListenerList;
|
| 75 |
-import java.io.Closeable;
|
|
| 76 | 80 |
import java.io.File;
|
| 77 | 81 |
import java.io.IOException;
|
| 78 | 82 |
import java.util.Locale;
|
| ... | ... | @@ -84,49 +88,23 @@ import static io.ultreia.java4all.i18n.I18n.t; |
| 84 | 88 |
/**
|
| 85 | 89 |
* @author Tony Chemit - dev@tchemit.fr
|
| 86 | 90 |
*/
|
| 87 |
-public class ObserveSwingDataSource extends AbstractSerializableBean implements Closeable, ObserveServicesProvider {
|
|
| 91 |
+@GenerateJavaBeanDefinition
|
|
| 92 |
+public class ObserveSwingDataSource extends ObserveServicesProviderSupport implements JavaBean {
|
|
| 88 | 93 |
|
| 89 |
- public static final ObserveServicesProvider MAIN = new ObserveServicesProvider(){
|
|
| 90 |
- @Override
|
|
| 91 |
- public void close() {
|
|
| 92 |
- }
|
|
| 93 |
- |
|
| 94 |
- //FIXME If we do not set this, OGNL can't find it on default implementation on interface :(
|
|
| 95 |
- @Override
|
|
| 96 |
- public fr.ird.observe.services.service.data.ll.common.TripService getLlCommonTripService() {
|
|
| 97 |
- return getService(fr.ird.observe.services.service.data.ll.common.TripService.class);
|
|
| 98 |
- }
|
|
| 99 |
- |
|
| 100 |
- //FIXME If we do not set this, OGNL can't find it on default implementation on interface :(
|
|
| 101 |
- @Override
|
|
| 102 |
- public fr.ird.observe.services.service.data.ps.common.TripService getPsCommonTripService() {
|
|
| 103 |
- return getService(fr.ird.observe.services.service.data.ps.common.TripService.class);
|
|
| 104 |
- }
|
|
| 105 |
- |
|
| 106 |
- @Override
|
|
| 107 |
- public <S extends ObserveService> S getService(Class<S> serviceType) {
|
|
| 108 |
- return ObserveSwingApplicationContext.get().getDataSourcesManager().getMainDataSource().getService(serviceType);
|
|
| 109 |
- }
|
|
| 110 |
- };
|
|
| 111 |
- private static final long serialVersionUID = 1L;
|
|
| 112 | 94 |
private static final Logger log = LogManager.getLogger(ObserveSwingDataSource.class);
|
| 113 |
- private final EventListenerList listenerList;
|
|
| 114 | 95 |
|
| 96 |
+ private final EventListenerList listenerList;
|
|
| 115 | 97 |
private final ObserveDataSourceConfiguration configuration;
|
| 116 |
- |
|
| 117 | 98 |
private final ObserveReferentialCache referentialCache;
|
| 118 |
- |
|
| 119 | 99 |
private final ObserveServicesProvider servicesProvider;
|
| 120 |
- |
|
| 121 | 100 |
private ObserveDataSourceConnection connection;
|
| 122 |
- |
|
| 123 | 101 |
private ProgressModel progressModel;
|
| 124 | 102 |
|
| 125 | 103 |
// indique que la connexion a expiré mais que la source n'est pas complétement fermer
|
| 126 | 104 |
private boolean expired;
|
| 127 |
- |
|
| 128 | 105 |
// indique si une modification a été effectuéé sur la base depuis son ouverture
|
| 129 | 106 |
private boolean modified;
|
| 107 |
+ // indique si l'utilisateur connecté est le propriétaire de la base
|
|
| 130 | 108 |
private boolean owner;
|
| 131 | 109 |
|
| 132 | 110 |
public ObserveSwingDataSource(ObserveDataSourceConfiguration configuration) {
|
| ... | ... | @@ -582,4 +560,23 @@ public class ObserveSwingDataSource extends AbstractSerializableBean implements |
| 582 | 560 |
public boolean getOwner() {
|
| 583 | 561 |
return owner;
|
| 584 | 562 |
}
|
| 563 |
+ |
|
| 564 |
+ public void sanitizeIds(ProgressModel progressModel, DtoModelNavigationAggregateModel navigationSelectModel) {
|
|
| 565 |
+ try {
|
|
| 566 |
+ for (DtoModelNavigationModel<?> navigationModel : navigationSelectModel.getModels()) {
|
|
| 567 |
+ for (DtoModelNavigationNode node : navigationModel.getNodesWithIds()) {
|
|
| 568 |
+ if (node.isEnabled()) {
|
|
| 569 |
+ ImmutableSet<String> safeIds = getNavigationService().retainExistingIds(ImmutableSet.of(node.getId()));
|
|
| 570 |
+ if (safeIds.isEmpty()) {
|
|
| 571 |
+ node.setId(null);
|
|
| 572 |
+ }
|
|
| 573 |
+ }
|
|
| 574 |
+ progressModel.incrementsCurrentStep();
|
|
| 575 |
+ }
|
|
| 576 |
+ }
|
|
| 577 |
+ } catch (Exception e) {
|
|
| 578 |
+ log.error("Could not sanitizeIds", e);
|
|
| 579 |
+ }
|
|
| 580 |
+ }
|
|
| 581 |
+ |
|
| 585 | 582 |
}
|
| ... | ... | @@ -46,6 +46,7 @@ import fr.ird.observe.dto.decoration.ObserveI18nDecoratorHelper; |
| 46 | 46 |
import fr.ird.observe.navigation.model.edit.longline.ObserveLonglineEditModel;
|
| 47 | 47 |
import fr.ird.observe.navigation.model.edit.seine.ObserveSeineEditModel;
|
| 48 | 48 |
import fr.ird.observe.navigation.model.select.ObserveSelectModel;
|
| 49 |
+import fr.ird.observe.services.ObserveServicesProvider;
|
|
| 49 | 50 |
import io.ultreia.java4all.i18n.I18n;
|
| 50 | 51 |
import org.apache.logging.log4j.LogManager;
|
| 51 | 52 |
import org.apache.logging.log4j.Logger;
|
| ... | ... | @@ -356,7 +357,7 @@ public class ObserveMainUIInitializer { |
| 356 | 357 |
// on met à jour le modèle de navigation
|
| 357 | 358 |
NavigationTreeModel treeModel = ui.getNavigationUI().getTree().getTreeModel();
|
| 358 | 359 |
treeModel.load(config);
|
| 359 |
- treeModel.populate();
|
|
| 360 |
+ treeModel.populate(mainStorage);
|
|
| 360 | 361 |
|
| 361 | 362 |
// selection du noeud d'ouverture
|
| 362 | 363 |
ui.getNavigationUI().getTree().selectInitialNode();
|
| ... | ... | @@ -563,14 +564,15 @@ public class ObserveMainUIInitializer { |
| 563 | 564 |
*
|
| 564 | 565 |
* <b>Note:</b> cette méthode doit être appelée après tout rechargement de modèle de naivgation.
|
| 565 | 566 |
*
|
| 567 |
+ * @param servicesProvider
|
|
| 566 | 568 |
* @param progressModel the progress model to interact with ui
|
| 567 | 569 |
*/
|
| 568 |
- public void loadNavigationUI(ProgressModel progressModel) {
|
|
| 570 |
+ public void loadNavigationUI(ObserveServicesProvider servicesProvider, ProgressModel progressModel) {
|
|
| 569 | 571 |
|
| 570 | 572 |
NavigationTree tree = ui.getNavigationUI().getTree();
|
| 571 | 573 |
|
| 572 | 574 |
NavigationTreeModel treeModel = tree.getTreeModel();
|
| 573 |
- treeModel.populate();
|
|
| 575 |
+ treeModel.populate(servicesProvider);
|
|
| 574 | 576 |
progressModel.incrementsCurrentStep();
|
| 575 | 577 |
|
| 576 | 578 |
// select initial node
|
| ... | ... | @@ -22,12 +22,12 @@ |
| 22 | 22 |
package fr.ird.observe.client.ui.actions;
|
| 23 | 23 |
|
| 24 | 24 |
import fr.ird.observe.client.ObserveSwingApplicationContext;
|
| 25 |
-import fr.ird.observe.client.db.ObserveSwingDataSource;
|
|
| 26 | 25 |
import fr.ird.observe.client.ui.ObserveKeyStrokes;
|
| 27 | 26 |
import fr.ird.observe.client.ui.ObserveMainUI;
|
| 28 | 27 |
import fr.ird.observe.client.ui.content.api.ContentUI;
|
| 29 | 28 |
import fr.ird.observe.client.ui.util.UIHelper;
|
| 30 | 29 |
import fr.ird.observe.services.ObserveServicesProvider;
|
| 30 |
+import io.ultreia.java4all.util.SingletonSupplier;
|
|
| 31 | 31 |
import org.apache.logging.log4j.LogManager;
|
| 32 | 32 |
import org.apache.logging.log4j.Logger;
|
| 33 | 33 |
import org.jdesktop.jxlayer.JXLayer;
|
| ... | ... | @@ -61,6 +61,7 @@ public abstract class UIActionSupport extends AbstractAction { |
| 61 | 61 |
private static final long serialVersionUID = 1L;
|
| 62 | 62 |
public static final String DELEGATE_CONTENT_UI = "delegateContentUI";
|
| 63 | 63 |
private final ObserveMainUI mainUI;
|
| 64 |
+ private final SingletonSupplier<ObserveServicesProvider> servicesProviderSupplier = SingletonSupplier.of(ObserveSwingApplicationContext.get()::getServicesProvider);
|
|
| 64 | 65 |
|
| 65 | 66 |
public UIActionSupport(ObserveMainUI mainUI, String actionCommandKey, String label, String shortDescription, String actionIcon, KeyStroke acceleratorKey) {
|
| 66 | 67 |
this(mainUI, actionCommandKey, label, shortDescription, actionIcon, acceleratorKey, true);
|
| ... | ... | @@ -228,7 +229,7 @@ public abstract class UIActionSupport extends AbstractAction { |
| 228 | 229 |
}
|
| 229 | 230 |
|
| 230 | 231 |
protected ObserveServicesProvider getServicesProvider() {
|
| 231 |
- return ObserveSwingDataSource.MAIN;
|
|
| 232 |
+ return servicesProviderSupplier.get();
|
|
| 232 | 233 |
}
|
| 233 | 234 |
|
| 234 | 235 |
protected ContentUI getContentUI(ContentUI contentUI) {
|
| ... | ... | @@ -43,6 +43,6 @@ public abstract class NavigationConfigUIActionSupport extends MenuActionSupport |
| 43 | 43 |
|
| 44 | 44 |
@Override
|
| 45 | 45 |
protected void doActionPerformed(ActionEvent e) {
|
| 46 |
- getMainUI().getNavigationUI().getHandler().tryToUpdateNavigationTree();
|
|
| 46 |
+ getMainUI().getNavigationUI().getHandler().tryToUpdateNavigationTree(getServicesProvider());
|
|
| 47 | 47 |
}
|
| 48 | 48 |
}
|
| ... | ... | @@ -50,6 +50,7 @@ import fr.ird.observe.services.ObserveServicesProvider; |
| 50 | 50 |
import fr.ird.observe.services.service.ObserveService;
|
| 51 | 51 |
import fr.ird.observe.spi.DtoModelHelper;
|
| 52 | 52 |
import io.ultreia.java4all.bean.JavaBean;
|
| 53 |
+import io.ultreia.java4all.util.SingletonSupplier;
|
|
| 53 | 54 |
import org.apache.logging.log4j.LogManager;
|
| 54 | 55 |
import org.apache.logging.log4j.Logger;
|
| 55 | 56 |
import org.nuiton.jaxx.runtime.JAXXObject;
|
| ... | ... | @@ -83,7 +84,6 @@ import java.util.List; |
| 83 | 84 |
import java.util.Objects;
|
| 84 | 85 |
import java.util.Optional;
|
| 85 | 86 |
|
| 86 |
-import static fr.ird.observe.client.db.ObserveSwingDataSource.MAIN;
|
|
| 87 | 87 |
import static io.ultreia.java4all.i18n.I18n.t;
|
| 88 | 88 |
|
| 89 | 89 |
/**
|
| ... | ... | @@ -109,6 +109,8 @@ public abstract class ContentUIHandler<U extends ContentUI> implements ObserveSe |
| 109 | 109 |
private ImmutableList<TemperatureEditor> temperatureEditors;
|
| 110 | 110 |
private boolean toggleTimeEditorSliderIsChanging;
|
| 111 | 111 |
private boolean coordinateFormatChangedIsChanging;
|
| 112 |
+ protected boolean resetEdit;
|
|
| 113 |
+ private final SingletonSupplier<ObserveServicesProvider> servicesProviderSupplier;
|
|
| 112 | 114 |
|
| 113 | 115 |
protected ContentUIHandler() {
|
| 114 | 116 |
this.focusTraversalPolicy = createFocusTraversalPolicy();
|
| ... | ... | @@ -120,6 +122,7 @@ public abstract class ContentUIHandler<U extends ContentUI> implements ObserveSe |
| 120 | 122 |
CoordinateFormat newValue = (CoordinateFormat) evt.getNewValue();
|
| 121 | 123 |
onCoordinateFormatChanged(newValue);
|
| 122 | 124 |
};
|
| 125 |
+ this.servicesProviderSupplier = SingletonSupplier.of(ObserveSwingApplicationContext.get()::getServicesProvider);
|
|
| 123 | 126 |
}
|
| 124 | 127 |
|
| 125 | 128 |
public static NavigationTree getNavigationTree() {
|
| ... | ... | @@ -510,7 +513,6 @@ public abstract class ContentUIHandler<U extends ContentUI> implements ObserveSe |
| 510 | 513 |
protected void uninstallValidators() {
|
| 511 | 514 |
SwingValidatorUtil.setValidatorBean(ui, null);
|
| 512 | 515 |
}
|
| 513 |
- protected boolean resetEdit;
|
|
| 514 | 516 |
|
| 515 | 517 |
public boolean isResetEdit() {
|
| 516 | 518 |
return resetEdit;
|
| ... | ... | @@ -804,7 +806,7 @@ public abstract class ContentUIHandler<U extends ContentUI> implements ObserveSe |
| 804 | 806 |
|
| 805 | 807 |
@Override
|
| 806 | 808 |
public <S extends ObserveService> S getService(Class<S> serviceType) {
|
| 807 |
- return MAIN.getService(serviceType);
|
|
| 809 |
+ return servicesProviderSupplier.get().getService(serviceType);
|
|
| 808 | 810 |
}
|
| 809 | 811 |
|
| 810 | 812 |
//
|
| ... | ... | @@ -618,7 +618,7 @@ public class StorageUIHandler implements UIHandler<StorageUI> { |
| 618 | 618 |
log.info(">>> create initial dump with " + currentDataSource + " in " + f);
|
| 619 | 619 |
}
|
| 620 | 620 |
try {
|
| 621 |
- SqlScriptProducerService dumpProducerService = ObserveSwingDataSource.MAIN.getSqlScriptProducerService();
|
|
| 621 |
+ SqlScriptProducerService dumpProducerService = currentDataSource.getSqlScriptProducerService();
|
|
| 622 | 622 |
backupLocalDatabase(dumpProducerService, f);
|
| 623 | 623 |
config.setInitialDumpExist(true);
|
| 624 | 624 |
} catch (Exception e) {
|
| ... | ... | @@ -22,8 +22,10 @@ package fr.ird.observe.client.ui.tree; |
| 22 | 22 |
* #L%
|
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 |
+import fr.ird.observe.client.ObserveSwingApplicationContext;
|
|
| 25 | 26 |
import fr.ird.observe.client.db.ObserveSwingDataSource;
|
| 26 | 27 |
import fr.ird.observe.services.ObserveServicesProvider;
|
| 28 |
+import io.ultreia.java4all.util.SingletonSupplier;
|
|
| 27 | 29 |
|
| 28 | 30 |
import javax.swing.Icon;
|
| 29 | 31 |
import javax.swing.tree.DefaultMutableTreeNode;
|
| ... | ... | @@ -37,8 +39,11 @@ import java.awt.Color; |
| 37 | 39 |
*/
|
| 38 | 40 |
public abstract class ObserveTreeNodeSupport<O> extends DefaultMutableTreeNode {
|
| 39 | 41 |
|
| 42 |
+ private final SingletonSupplier<ObserveServicesProvider> servicesProviderSupplier;
|
|
| 43 |
+ |
|
| 40 | 44 |
public ObserveTreeNodeSupport(O userObject, boolean allowsChildren) {
|
| 41 | 45 |
super(userObject, allowsChildren);
|
| 46 |
+ this.servicesProviderSupplier = SingletonSupplier.of(ObserveSwingApplicationContext.get()::getServicesProvider);
|
|
| 42 | 47 |
}
|
| 43 | 48 |
|
| 44 | 49 |
public abstract boolean isOpen();
|
| ... | ... | @@ -60,7 +65,7 @@ public abstract class ObserveTreeNodeSupport<O> extends DefaultMutableTreeNode { |
| 60 | 65 |
}
|
| 61 | 66 |
|
| 62 | 67 |
protected ObserveServicesProvider getServicesProvider() {
|
| 63 |
- return ObserveSwingDataSource.MAIN;
|
|
| 68 |
+ return servicesProviderSupplier.get();
|
|
| 64 | 69 |
}
|
| 65 | 70 |
|
| 66 | 71 |
}
|
| ... | ... | @@ -42,6 +42,7 @@ import fr.ird.observe.dto.referential.common.ProgramHelper; |
| 42 | 42 |
import fr.ird.observe.dto.referential.common.ProgramReference;
|
| 43 | 43 |
import fr.ird.observe.navigation.model.DtoModelNavigationModel;
|
| 44 | 44 |
import fr.ird.observe.navigation.model.ObserveNavigationNode;
|
| 45 |
+import fr.ird.observe.services.ObserveServicesProvider;
|
|
| 45 | 46 |
import fr.ird.observe.services.service.data.NavigationRequest;
|
| 46 | 47 |
import fr.ird.observe.services.service.data.NavigationResult;
|
| 47 | 48 |
import fr.ird.observe.services.service.data.NavigationService;
|
| ... | ... | @@ -103,9 +104,9 @@ public class NavigationTreeModel extends DefaultTreeModel { |
| 103 | 104 |
this.config.load(config);
|
| 104 | 105 |
}
|
| 105 | 106 |
|
| 106 |
- public void populate() {
|
|
| 107 |
+ public void populate(ObserveServicesProvider servicesProvider) {
|
|
| 107 | 108 |
|
| 108 |
- NavigationService navigationService = ObserveSwingDataSource.MAIN.getNavigationService();
|
|
| 109 |
+ NavigationService navigationService = servicesProvider.getNavigationService();
|
|
| 109 | 110 |
|
| 110 | 111 |
NavigationRequest navigationRequest = config.toRequest();
|
| 111 | 112 |
NavigationResult navigationResult = navigationService.getNavigation(navigationRequest);
|
| ... | ... | @@ -28,6 +28,7 @@ import fr.ird.observe.client.configuration.NavigationTreeConfig; |
| 28 | 28 |
import fr.ird.observe.client.ui.actions.UIActionSupport;
|
| 29 | 29 |
import fr.ird.observe.client.ui.content.api.spi.ObserveActionMap;
|
| 30 | 30 |
import fr.ird.observe.client.ui.tree.navigation.nodes.NavigationTreeNodeSupport;
|
| 31 |
+import fr.ird.observe.services.ObserveServicesProvider;
|
|
| 31 | 32 |
import org.apache.logging.log4j.LogManager;
|
| 32 | 33 |
import org.apache.logging.log4j.Logger;
|
| 33 | 34 |
import org.jdesktop.swingx.decorator.ColorHighlighter;
|
| ... | ... | @@ -152,7 +153,7 @@ public class NavigationUIHandler implements UIHandler<NavigationUI> { |
| 152 | 153 |
|
| 153 | 154 |
}
|
| 154 | 155 |
|
| 155 |
- public void tryToUpdateNavigationTree() {
|
|
| 156 |
+ public void tryToUpdateNavigationTree(ObserveServicesProvider servicesProvider) {
|
|
| 156 | 157 |
|
| 157 | 158 |
boolean canContinue = ObserveSwingApplicationContext.get().getContentUIManager().closeSelectedContentUI();
|
| 158 | 159 |
|
| ... | ... | @@ -180,7 +181,7 @@ public class NavigationUIHandler implements UIHandler<NavigationUI> { |
| 180 | 181 |
navigationTreeConfig.setShowReferential(showReferential);
|
| 181 | 182 |
navigationTreeConfig.setShowEmptyProgram(showEmptyProgram);
|
| 182 | 183 |
treeModel.save(ObserveSwingApplicationContext.get().getConfig());
|
| 183 |
- treeModel.populate();
|
|
| 184 |
+ treeModel.populate(servicesProvider);
|
|
| 184 | 185 |
//FIXME repositionner le nœud sélectionné
|
| 185 | 186 |
if (!treeModel.getRoot().isLeaf()) {
|
| 186 | 187 |
tree.setSelectionRow(0);
|
| ... | ... | @@ -56,7 +56,7 @@ public class ClientValidationContext extends ValidationContext { |
| 56 | 56 |
}
|
| 57 | 57 |
|
| 58 | 58 |
public ObserveServicesProvider getServicesProvider() {
|
| 59 |
- return ObserveSwingDataSource.MAIN;
|
|
| 59 |
+ return ObserveSwingApplicationContext.get().getServicesProvider();
|
|
| 60 | 60 |
}
|
| 61 | 61 |
|
| 62 | 62 |
@Override
|
| ... | ... | @@ -17,8 +17,6 @@ observe.common.gps.activity |
| 17 | 17 |
observe.common.gps.gpsPoint
|
| 18 | 18 |
observe.common.inconnu
|
| 19 | 19 |
observe.common.no.unit
|
| 20 |
-observe.common.nocode
|
|
| 21 |
-observe.common.none
|
|
| 22 | 20 |
observe.data.Data.baitHaulingStatus
|
| 23 | 21 |
observe.data.Data.captain
|
| 24 | 22 |
observe.data.Data.dataQuality
|
| ... | ... | @@ -22,16 +22,8 @@ package fr.ird.observe.dto.decoration; |
| 22 | 22 |
* #L%
|
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 |
-import fr.ird.observe.dto.decoration.decorators.DataReferenceDecorator;
|
|
| 26 |
-import fr.ird.observe.dto.decoration.decorators.ReferentialReferenceDecorator;
|
|
| 27 |
-import fr.ird.observe.dto.reference.DataDtoReference;
|
|
| 28 |
-import fr.ird.observe.dto.reference.DtoReference;
|
|
| 29 |
-import fr.ird.observe.dto.reference.ReferentialDtoReference;
|
|
| 30 | 25 |
import fr.ird.observe.dto.referential.ReferentialLocale;
|
| 31 |
-import org.nuiton.decorator.Decorator;
|
|
| 32 |
-import org.nuiton.decorator.DecoratorProvider;
|
|
| 33 |
- |
|
| 34 |
-import java.util.Objects;
|
|
| 26 |
+import fr.ird.observe.spi.model.initializer.ObserveGlobalModelInitializer;
|
|
| 35 | 27 |
|
| 36 | 28 |
|
| 37 | 29 |
/**
|
| ... | ... | @@ -40,60 +32,23 @@ import java.util.Objects; |
| 40 | 32 |
* @author Tony Chemit - dev@tchemit.fr
|
| 41 | 33 |
* @since 1.3
|
| 42 | 34 |
*/
|
| 43 |
-public class DecoratorService extends DecoratorProvider {
|
|
| 35 |
+public class DecoratorService extends DecoratorServiceSupport<DecoratorServiceInitializer> {
|
|
| 44 | 36 |
|
| 45 | 37 |
public static final String HAULING_IDENTIFIER = "haulingIdentifier";
|
| 46 | 38 |
public static final String TRIP_CONTEXT = "Trip";
|
| 47 | 39 |
public static final String WITH_URL = "WithUrl";
|
| 48 | 40 |
|
| 49 |
- private final DecoratorServiceInitializer initializer;
|
|
| 50 |
- private ReferentialLocale referentialLocale;
|
|
| 51 |
- |
|
| 52 | 41 |
public DecoratorService(ReferentialLocale referentialLocale) {
|
| 53 |
- this.referentialLocale = Objects.requireNonNull(referentialLocale);
|
|
| 54 |
- this.initializer = new DecoratorServiceInitializer(this);
|
|
| 55 |
- loadDecorators();
|
|
| 56 |
- }
|
|
| 57 |
- |
|
| 58 |
- public ReferentialLocale getReferentialLocale() {
|
|
| 59 |
- return referentialLocale;
|
|
| 60 |
- }
|
|
| 61 |
- |
|
| 62 |
- public void setReferentialLocale(ReferentialLocale referentialLocale) {
|
|
| 63 |
- this.referentialLocale = referentialLocale;
|
|
| 42 |
+ super(referentialLocale);
|
|
| 64 | 43 |
}
|
| 65 | 44 |
|
| 66 | 45 |
@Override
|
| 67 |
- protected void loadDecorators() {
|
|
| 68 |
- if (referentialLocale == null) {
|
|
| 69 |
- // on n'enregistre pas les décorateur tant que la locale n'est pas
|
|
| 70 |
- // positionnée
|
|
| 71 |
- return;
|
|
| 72 |
- }
|
|
| 73 |
- DecoratorServiceInitializer.run(initializer);
|
|
| 74 |
- }
|
|
| 75 |
- |
|
| 76 |
- public <T extends ReferentialDtoReference> ReferentialReferenceDecorator<T> getReferentialReferenceDecorator(Class<T> referenceType) {
|
|
| 77 |
- return (ReferentialReferenceDecorator) getDecoratorByType(referenceType);
|
|
| 46 |
+ protected DecoratorServiceInitializer createDecoratorServiceInitializer() {
|
|
| 47 |
+ return new DecoratorServiceInitializer(this);
|
|
| 78 | 48 |
}
|
| 79 | 49 |
|
| 80 |
- public <R extends DataDtoReference> DataReferenceDecorator<R> getDataReferenceDecorator(Class<R> referenceType) {
|
|
| 81 |
- return (DataReferenceDecorator) getDecoratorByType(referenceType);
|
|
| 82 |
- }
|
|
| 83 |
- |
|
| 84 |
- public <R extends DataDtoReference> DataReferenceDecorator<R> getDataReferenceDecorator(Class<R> referenceType, String context) {
|
|
| 85 |
- return (DataReferenceDecorator) getDecoratorByType(referenceType, context);
|
|
| 86 |
- }
|
|
| 87 |
- |
|
| 88 |
- public <R extends DtoReference> Decorator<R> getReferenceDecorator(Class<R> referenceType) {
|
|
| 89 |
- Decorator<R> decorator;
|
|
| 90 |
- |
|
| 91 |
- if (DataDtoReference.class.isAssignableFrom(referenceType)) {
|
|
| 92 |
- decorator = getDataReferenceDecorator((Class) referenceType);
|
|
| 93 |
- } else {
|
|
| 94 |
- decorator = getReferentialReferenceDecorator((Class) referenceType);
|
|
| 95 |
- }
|
|
| 96 |
- |
|
| 97 |
- return decorator;
|
|
| 50 |
+ @Override
|
|
| 51 |
+ protected void init(DecoratorServiceInitializer initializer) {
|
|
| 52 |
+ ObserveGlobalModelInitializer.run(initializer);
|
|
| 98 | 53 |
}
|
| 99 | 54 |
}
|
| 1 |
-/*
|
|
| 2 |
- * #%L
|
|
| 3 |
- * ObServe :: Dto
|
|
| 4 |
- * %%
|
|
| 5 |
- * Copyright (C) 2008 - 2019 IRD, Code Lutin, Ultreia.io
|
|
| 6 |
- * %%
|
|
| 7 |
- * This program is free software: you can redistribute it and/or modify
|
|
| 8 |
- * it under the terms of the GNU General Public License as
|
|
| 9 |
- * published by the Free Software Foundation, either version 3 of the
|
|
| 10 |
- * License, or (at your option) any later version.
|
|
| 11 |
- *
|
|
| 12 |
- * This program is distributed in the hope that it will be useful,
|
|
| 13 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
| 14 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
| 15 |
- * GNU General Public License for more details.
|
|
| 16 |
- *
|
|
| 17 |
- * You should have received a copy of the GNU General Public
|
|
| 18 |
- * License along with this program. If not, see
|
|
| 19 |
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
|
|
| 20 |
- * #L%
|
|
| 21 |
- */
|
|
| 22 |
-package fr.ird.observe.dto.decoration.decorators;
|
|
| 23 |
- |
|
| 24 |
-import fr.ird.observe.dto.reference.DtoReference;
|
|
| 25 |
-import org.apache.commons.jxpath.JXPathContext;
|
|
| 26 |
-import org.apache.commons.lang3.StringUtils;
|
|
| 27 |
-import org.apache.logging.log4j.LogManager;
|
|
| 28 |
-import org.apache.logging.log4j.Logger;
|
|
| 29 |
-import org.nuiton.decorator.MultiJXPathDecorator;
|
|
| 30 |
- |
|
| 31 |
-import java.io.Serializable;
|
|
| 32 |
- |
|
| 33 |
-import static io.ultreia.java4all.i18n.I18n.t;
|
|
| 34 |
- |
|
| 35 |
-/**
|
|
| 36 |
- * Abstract decorator for any complex decorator.
|
|
| 37 |
- *
|
|
| 38 |
- * @author Tony Chemit - dev@tchemit.fr
|
|
| 39 |
- * @since 2.4
|
|
| 40 |
- */
|
|
| 41 |
-public class ObserveDecorator<E> extends MultiJXPathDecorator<E> implements Cloneable {
|
|
| 42 |
- |
|
| 43 |
- private static final long serialVersionUID = 1L;
|
|
| 44 |
- |
|
| 45 |
- /** Logger. */
|
|
| 46 |
- private static final Logger log = LogManager.getLogger(ObserveDecorator.class);
|
|
| 47 |
- |
|
| 48 |
- public static final String DEFAULT_SEPARATOR = "##";
|
|
| 49 |
- |
|
| 50 |
- public static final String DEFAULT_SEPARATOR_REPLACEMENT = " - ";
|
|
| 51 |
- |
|
| 52 |
- public ObserveDecorator(Class<E> internalClass, String expression) {
|
|
| 53 |
- super(internalClass, expression, DEFAULT_SEPARATOR, DEFAULT_SEPARATOR_REPLACEMENT);
|
|
| 54 |
- }
|
|
| 55 |
- |
|
| 56 |
- public ObserveDecorator(Class<E> internalClass, String expression, String separator) {
|
|
| 57 |
- super(internalClass, expression, DEFAULT_SEPARATOR, separator);
|
|
| 58 |
- }
|
|
| 59 |
- |
|
| 60 |
- @Override
|
|
| 61 |
- public final Object clone() throws CloneNotSupportedException {
|
|
| 62 |
- return super.clone();
|
|
| 63 |
- }
|
|
| 64 |
- |
|
| 65 |
- protected Comparable<Comparable<?>> getTokenValue(JXPathContext jxcontext, String token) {
|
|
| 66 |
- // assume all values are comparable
|
|
| 67 |
- Comparable<Comparable<?>> value;
|
|
| 68 |
- |
|
| 69 |
- try {
|
|
| 70 |
- |
|
| 71 |
- String[] tokens = token.split("/");
|
|
| 72 |
- |
|
| 73 |
- Object value0 = jxcontext.getValue(tokens[0]);
|
|
| 74 |
- |
|
| 75 |
- if (value0 instanceof DtoReference) {
|
|
| 76 |
- |
|
| 77 |
- value = getValueFromReference(tokens, (DtoReference<?, ?>) value0, 1);
|
|
| 78 |
- |
|
| 79 |
- } else {
|
|
| 80 |
- |
|
| 81 |
- value = (Comparable<Comparable<?>>) jxcontext.getValue(token);
|
|
| 82 |
- }
|
|
| 83 |
- |
|
| 84 |
- if (value == null) {
|
|
| 85 |
- value = (Comparable<Comparable<?>>) getDefaultNullValue(token);
|
|
| 86 |
- }
|
|
| 87 |
- |
|
| 88 |
- } catch (Exception e) {
|
|
| 89 |
- value = (Comparable<Comparable<?>>) getDefaultUndefinedValue(token);
|
|
| 90 |
- }
|
|
| 91 |
- |
|
| 92 |
- return value;
|
|
| 93 |
- }
|
|
| 94 |
- |
|
| 95 |
- protected Comparable<Comparable<?>> getValueFromReference(String[] tokens, DtoReference<?, ?> referenceBean, int startIndex) {
|
|
| 96 |
- |
|
| 97 |
- for (int i = startIndex, max = tokens.length - 1; i < max; i++) {
|
|
| 98 |
- |
|
| 99 |
- if (referenceBean.getPropertyNames().contains(tokens[i])) {
|
|
| 100 |
- |
|
| 101 |
- Serializable propertyValue = referenceBean.getPropertyValue(tokens[i]);
|
|
| 102 |
- |
|
| 103 |
- if (!(propertyValue instanceof DtoReference)) {
|
|
| 104 |
- |
|
| 105 |
- return (Comparable<Comparable<?>>) getDefaultUndefinedValue(StringUtils.join(tokens, "/"));
|
|
| 106 |
- |
|
| 107 |
- }
|
|
| 108 |
- |
|
| 109 |
- referenceBean = (DtoReference<?, ?>) propertyValue;
|
|
| 110 |
- }
|
|
| 111 |
- }
|
|
| 112 |
- |
|
| 113 |
- Comparable<Comparable<?>> value = null;
|
|
| 114 |
- |
|
| 115 |
- String lastToken = tokens[tokens.length - 1];
|
|
| 116 |
- if (referenceBean.getPropertyNames().contains(lastToken)) {
|
|
| 117 |
- value = referenceBean.getPropertyValue(lastToken);
|
|
| 118 |
- } else {
|
|
| 119 |
- value = referenceBean.get(lastToken);
|
|
| 120 |
- }
|
|
| 121 |
- |
|
| 122 |
- return value;
|
|
| 123 |
- }
|
|
| 124 |
- |
|
| 125 |
- protected Comparable<?> getDefaultUndefinedValue(String token) {
|
|
| 126 |
- if (log.isDebugEnabled()) {
|
|
| 127 |
- log.debug("No defined value for token [" + token + "]");
|
|
| 128 |
- }
|
|
| 129 |
- return t("observe.common.none");
|
|
| 130 |
- }
|
|
| 131 |
- |
|
| 132 |
- protected Comparable<?> getDefaultNullValue(String token) {
|
|
| 133 |
- if (log.isDebugEnabled()) {
|
|
| 134 |
- log.debug("Null value for token [" + token + "]");
|
|
| 135 |
- }
|
|
| 136 |
- return t("observe.common.none");
|
|
| 137 |
- }
|
|
| 138 |
- |
|
| 139 |
- |
|
| 140 |
-}
|
| 1 |
-package fr.ird.observe.dto.decoration.decorators;
|
|
| 2 |
- |
|
| 3 |
-/*-
|
|
| 4 |
- * #%L
|
|
| 5 |
- * ObServe :: Dto
|
|
| 6 |
- * %%
|
|
| 7 |
- * Copyright (C) 2008 - 2019 IRD, Code Lutin, Ultreia.io
|
|
| 8 |
- * %%
|
|
| 9 |
- * This program is free software: you can redistribute it and/or modify
|
|
| 10 |
- * it under the terms of the GNU General Public License as
|
|
| 11 |
- * published by the Free Software Foundation, either version 3 of the
|
|
| 12 |
- * License, or (at your option) any later version.
|
|
| 13 |
- *
|
|
| 14 |
- * This program is distributed in the hope that it will be useful,
|
|
| 15 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
| 16 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
| 17 |
- * GNU General Public License for more details.
|
|
| 18 |
- *
|
|
| 19 |
- * You should have received a copy of the GNU General Public
|
|
| 20 |
- * License along with this program. If not, see
|
|
| 21 |
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
|
|
| 22 |
- * #L%
|
|
| 23 |
- */
|
|
| 24 |
- |
|
| 25 |
-import fr.ird.observe.dto.reference.ReferentialDtoReference;
|
|
| 26 |
-import fr.ird.observe.dto.referential.ReferentialDto;
|
|
| 27 |
-import org.apache.commons.jxpath.JXPathContext;
|
|
| 28 |
-import org.apache.commons.lang3.StringUtils;
|
|
| 29 |
-import org.nuiton.decorator.JXPathDecorator;
|
|
| 30 |
- |
|
| 31 |
-import java.util.List;
|
|
| 32 |
- |
|
| 33 |
-import static io.ultreia.java4all.i18n.I18n.t;
|
|
| 34 |
- |
|
| 35 |
-/**
|
|
| 36 |
- * @author Kevin Morin (Code Lutin)
|
|
| 37 |
- */
|
|
| 38 |
-public class ReferentialReferenceDecorator<R extends ReferentialDtoReference> extends ObserveDecorator<R> implements Cloneable {
|
|
| 39 |
- |
|
| 40 |
- private static final long serialVersionUID = 1L;
|
|
| 41 |
- |
|
| 42 |
- public ReferentialReferenceDecorator(Class<R> type, String expression) {
|
|
| 43 |
- super(type, expression);
|
|
| 44 |
- for (int i = 0; i < nbToken; i++) {
|
|
| 45 |
- String property = getProperty(i);
|
|
| 46 |
- if (ReferentialDto.PROPERTY_CODE.equals(property)) {
|
|
| 47 |
- |
|
| 48 |
- // On change le comparateur pour simuler le tri numérique si possible.
|
|
| 49 |
- contexts[i].setComparator(new JXPathComparator<R>(property) {
|
|
| 50 |
- |
|
| 51 |
- @Override
|
|
| 52 |
- public void init(JXPathDecorator<R> decorator, List<R> datas) {
|
|
| 53 |
- clear();
|
|
| 54 |
- for (R data : datas) {
|
|
| 55 |
- JXPathContext jxcontext = JXPathContext.newContext(data);
|
|
| 56 |
- Comparable<Comparable<?>> key = getTokenValue(jxcontext, ReferentialDto.PROPERTY_CODE);
|
|
| 57 |
- // on passe en 000000x comme ça si on a des nombres, ils seront bien triés
|
|
| 58 |
- String value = key == null ? "" : StringUtils.leftPad(key.toString(), 6, "0");
|
|
| 59 |
- valueCache.put(data, (Comparable) value);
|
|
| 60 |
- }
|
|
| 61 |
- }
|
|
| 62 |
- });
|
|
| 63 |
- break;
|
|
| 64 |
- }
|
|
| 65 |
- }
|
|
| 66 |
- }
|
|
| 67 |
- |
|
| 68 |
- @Override
|
|
| 69 |
- protected Comparable<Comparable<?>> getTokenValue(JXPathContext jxcontext, String token) {
|
|
| 70 |
- |
|
| 71 |
- |
|
| 72 |
- // assume all values are comparable
|
|
| 73 |
- Comparable<Comparable<?>> value;
|
|
| 74 |
- |
|
| 75 |
- Object contextBean = jxcontext.getContextBean();
|
|
| 76 |
- |
|
| 77 |
- if (contextBean instanceof ReferentialDtoReference) {
|
|
| 78 |
- |
|
| 79 |
- String[] tokens = token.split("/");
|
|
| 80 |
- |
|
| 81 |
- value = getValueFromReference(tokens, (ReferentialDtoReference) contextBean, 0);
|
|
| 82 |
- |
|
| 83 |
- if (value == null) {
|
|
| 84 |
- value = (Comparable<Comparable<?>>) getDefaultNullValue(tokens[0]);
|
|
| 85 |
- }
|
|
| 86 |
- |
|
| 87 |
- } else {
|
|
| 88 |
- value = super.getTokenValue(jxcontext, token);
|
|
| 89 |
- }
|
|
| 90 |
- |
|
| 91 |
- return value;
|
|
| 92 |
- |
|
| 93 |
- }
|
|
| 94 |
- |
|
| 95 |
- @Override
|
|
| 96 |
- protected Comparable<?> getDefaultNullValue(String token) {
|
|
| 97 |
- if (token.equals("startDate") || token.equals("endDate")) {
|
|
| 98 |
- return null;
|
|
| 99 |
- }
|
|
| 100 |
- return ReferentialDto.PROPERTY_CODE.equals(token) ? t("observe.common.nocode") : super.getDefaultNullValue(token);
|
|
| 101 |
- }
|
|
| 102 |
-}
|
| ... | ... | @@ -426,8 +426,6 @@ observe.common.inconnu=Unknown |
| 426 | 426 |
observe.common.label=Label
|
| 427 | 427 |
observe.common.lengthWeightFormula=Length weight formula
|
| 428 | 428 |
observe.common.no.unit=No unit
|
| 429 |
-observe.common.nocode=Nocode
|
|
| 430 |
-observe.common.none=None
|
|
| 431 | 429 |
observe.common.operation.resume=Summary of operations
|
| 432 | 430 |
observe.common.resume=Summary
|
| 433 | 431 |
observe.common.saveFile.overwrite=file alreayd exists, would you like to overwrite it?
|
| ... | ... | @@ -426,8 +426,6 @@ observe.common.inconnu=desconocido |
| 426 | 426 |
observe.common.label=Texto
|
| 427 | 427 |
observe.common.lengthWeightFormula=Relación de peso
|
| 428 | 428 |
observe.common.no.unit=No unit \#TODO
|
| 429 |
-observe.common.nocode=codigo ausente
|
|
| 430 |
-observe.common.none=Ninguno
|
|
| 431 | 429 |
observe.common.operation.resume=Resumen de operaciones
|
| 432 | 430 |
observe.common.resume=Resumen de la configuración
|
| 433 | 431 |
observe.common.saveFile.overwrite=El archivo ya existe. Quiere reemplazar lo ?
|
| ... | ... | @@ -426,8 +426,6 @@ observe.common.inconnu=inconnu |
| 426 | 426 |
observe.common.label=Libellé
|
| 427 | 427 |
observe.common.lengthWeightFormula=Relation Poids
|
| 428 | 428 |
observe.common.no.unit=Pas d'unité
|
| 429 |
-observe.common.nocode=code absent
|
|
| 430 |
-observe.common.none=Aucun
|
|
| 431 | 429 |
observe.common.operation.resume=Résumé des opérations
|
| 432 | 430 |
observe.common.resume=Résumé de la configuration
|
| 433 | 431 |
observe.common.saveFile.overwrite=Le fichier existe déjà. Voulez-vous le remplacer ?
|
| ... | ... | @@ -23,7 +23,6 @@ package fr.ird.observe.services; |
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 | 25 |
import fr.ird.observe.services.service.ObserveService;
|
| 26 |
-import fr.ird.observe.services.service.data.ll.common.TripService;
|
|
| 27 | 26 |
|
| 28 | 27 |
import java.util.Objects;
|
| 29 | 28 |
|
| ... | ... | @@ -32,7 +31,7 @@ import java.util.Objects; |
| 32 | 31 |
*
|
| 33 | 32 |
* @author Tony Chemit - dev@tchemit.fr
|
| 34 | 33 |
*/
|
| 35 |
-public class ObserveServicesProviderImpl implements ObserveServicesProvider {
|
|
| 34 |
+public class ObserveServicesProviderImpl extends ObserveServicesProviderSupport {
|
|
| 36 | 35 |
|
| 37 | 36 |
private final ObserveServiceFactory serviceFactory;
|
| 38 | 37 |
private final ObserveServiceInitializer serviceInitializer;
|
| ... | ... | @@ -42,22 +41,6 @@ public class ObserveServicesProviderImpl implements ObserveServicesProvider { |
| 42 | 41 |
this.serviceInitializer = Objects.requireNonNull(serviceInitializer);
|
| 43 | 42 |
}
|
| 44 | 43 |
|
| 45 |
- @Override
|
|
| 46 |
- public void close() {
|
|
| 47 |
- }
|
|
| 48 |
- |
|
| 49 |
- //FIXME If we do not set this, OGNL can't find it on default implementation on interface :(
|
|
| 50 |
- @Override
|
|
| 51 |
- public TripService getLlCommonTripService() {
|
|
| 52 |
- return getService(TripService.class);
|
|
| 53 |
- }
|
|
| 54 |
- |
|
| 55 |
- //FIXME If we do not set this, OGNL can't find it on default implementation on interface :(
|
|
| 56 |
- @Override
|
|
| 57 |
- public fr.ird.observe.services.service.data.ps.common.TripService getPsCommonTripService() {
|
|
| 58 |
- return getService(fr.ird.observe.services.service.data.ps.common.TripService.class);
|
|
| 59 |
- }
|
|
| 60 |
- |
|
| 61 | 44 |
@Override
|
| 62 | 45 |
public <S extends ObserveService> S getService(Class<S> serviceType) {
|
| 63 | 46 |
return serviceFactory.newService(serviceInitializer, serviceType);
|
| 1 |
-package fr.ird.observe.dto.decoration.decorators;
|
|
| 1 |
+package fr.ird.observe.services;
|
|
| 2 | 2 |
|
| 3 | 3 |
/*-
|
| 4 | 4 |
* #%L
|
| 5 |
- * ObServe :: Dto
|
|
| 5 |
+ * ObServe :: Services Validation API
|
|
| 6 | 6 |
* %%
|
| 7 | 7 |
* Copyright (C) 2008 - 2019 IRD, Code Lutin, Ultreia.io
|
| 8 | 8 |
* %%
|
| ... | ... | @@ -22,50 +22,24 @@ package fr.ird.observe.dto.decoration.decorators; |
| 22 | 22 |
* #L%
|
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 |
-import fr.ird.observe.dto.reference.DataDtoReference;
|
|
| 26 |
-import fr.ird.observe.dto.reference.DtoReference;
|
|
| 27 |
-import org.apache.commons.jxpath.JXPathContext;
|
|
| 25 |
+import io.ultreia.java4all.bean.AbstractJavaBean;
|
|
| 28 | 26 |
|
| 29 |
-/**
|
|
| 30 |
- * @author Kevin Morin (Code Lutin)
|
|
| 31 |
- */
|
|
| 32 |
-public class DataReferenceDecorator<R extends DataDtoReference> extends ObserveDecorator<R> implements Cloneable {
|
|
| 33 |
- |
|
| 34 |
- private static final long serialVersionUID = 1L;
|
|
| 27 |
+public abstract class ObserveServicesProviderSupport extends AbstractJavaBean implements ObserveServicesProvider {
|
|
| 35 | 28 |
|
| 36 |
- public DataReferenceDecorator(Class<R> type, String expression) {
|
|
| 37 |
- super(type, expression);
|
|
| 29 |
+ @Override
|
|
| 30 |
+ public void close() {
|
|
| 31 |
+ // by default nothing to do on close
|
|
| 38 | 32 |
}
|
| 39 | 33 |
|
| 34 |
+ //FIXME If we do not set this, OGNL can't find it on default implementation on interface :(
|
|
| 40 | 35 |
@Override
|
| 41 |
- protected Comparable<Comparable<?>> getTokenValue(JXPathContext jxcontext, String token) {
|
|
| 42 |
- |
|
| 43 |
- // assume all values are comparable
|
|
| 44 |
- Comparable<Comparable<?>> value;
|
|
| 45 |
- |
|
| 46 |
- Object contextBean = jxcontext.getContextBean();
|
|
| 47 |
- |
|
| 48 |
- if (contextBean instanceof DtoReference) {
|
|
| 49 |
- |
|
| 50 |
- String[] tokens = token.split("/");
|
|
| 51 |
- |
|
| 52 |
- value = getValueFromReference(tokens, (DtoReference) contextBean, 0);
|
|
| 53 |
- |
|
| 54 |
- if (value == null) {
|
|
| 55 |
- value = (Comparable<Comparable<?>>) getDefaultNullValue(tokens[0]);
|
|
| 56 |
- }
|
|
| 57 |
- |
|
| 58 |
- } else {
|
|
| 59 |
- value = super.getTokenValue(jxcontext, token);
|
|
| 60 |
- }
|
|
| 61 |
- |
|
| 62 |
- return value;
|
|
| 63 |
- |
|
| 36 |
+ public fr.ird.observe.services.service.data.ll.common.TripService getLlCommonTripService() {
|
|
| 37 |
+ return getService(fr.ird.observe.services.service.data.ll.common.TripService.class);
|
|
| 64 | 38 |
}
|
| 65 | 39 |
|
| 40 |
+ //FIXME If we do not set this, OGNL can't find it on default implementation on interface :(
|
|
| 66 | 41 |
@Override
|
| 67 |
- public String toString(Object bean) {
|
|
| 68 |
- String result = super.toString(bean);
|
|
| 69 |
- return result == null ? null : result.trim();
|
|
| 42 |
+ public fr.ird.observe.services.service.data.ps.common.TripService getPsCommonTripService() {
|
|
| 43 |
+ return getService(fr.ird.observe.services.service.data.ps.common.TripService.class);
|
|
| 70 | 44 |
}
|
| 71 | 45 |
}
|
| ... | ... | @@ -75,7 +75,7 @@ public class TripVesselDtoValidator extends FieldValidatorSupport { |
| 75 | 75 |
|
| 76 | 76 |
private void validate(Object object, String id, VesselReference vessel, Date startDate, Date endDate) throws ValidationException {
|
| 77 | 77 |
|
| 78 |
- TripService tripService = (TripService) getFieldValue(serviceName, object);
|
|
| 78 |
+ TripService tripService = (TripService) Objects.requireNonNull(getFieldValue(serviceName, object),"Can't find "+serviceName);
|
|
| 79 | 79 |
Set<? extends TripReference> matchingTrips = tripService.getMatchingTripsVesselWithinDateRange(id,
|
| 80 | 80 |
vessel.getId(),
|
| 81 | 81 |
startDate,
|
| ... | ... | @@ -39,7 +39,7 @@ |
| 39 | 39 |
<message/>
|
| 40 | 40 |
</field-validator>
|
| 41 | 41 |
<field-validator type="tripVessel" short-circuit="true">
|
| 42 |
- <param name="serviceName">servicesProvider.llCommonTripLonglineService</param>
|
|
| 42 |
+ <param name="serviceName">servicesProvider.llCommonTripService</param>
|
|
| 43 | 43 |
<message/>
|
| 44 | 44 |
</field-validator>
|
| 45 | 45 |
</field>
|
| ... | ... | @@ -41,7 +41,7 @@ |
| 41 | 41 |
<message/>
|
| 42 | 42 |
</field-validator>
|
| 43 | 43 |
<field-validator type="tripVessel" short-circuit="true">
|
| 44 |
- <param name="serviceName">servicesProvider.llCommonTripLonglineService</param>
|
|
| 44 |
+ <param name="serviceName">servicesProvider.llCommonTripService</param>
|
|
| 45 | 45 |
<message/>
|
| 46 | 46 |
</field-validator>
|
| 47 | 47 |
</field>
|