Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe Commits: 659321ef by Tony Chemit at 2020-12-13T15:44:05+01:00 Revoir les clefs d'unicité sur la base - Closes #1658 - - - - - 9b8d3ab8 by Tony Chemit at 2020-12-13T19:21:47+01:00 Suppression d'entrée en synchro avancée - Closes #1639 - - - - - 65c3d6df by Tony Chemit at 2020-12-13T20:30:05+01:00 Revoir les clefs d'unicité sur la base (correction dans la migration) - closes #1658 - - - - - 7f3e8dc7 by Tony Chemit at 2020-12-13T20:30:46+01:00 Fix i18n key - - - - - 575a645f by Tony Chemit at 2020-12-13T20:31:11+01:00 Fix some init issues with new Jaxx API - - - - - 29 changed files: - client/core/src/main/java/fr/ird/observe/client/util/init/DefaultUIInitializer.java - client/datasource/actions/src/main/i18n/getters/java.getter - client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/synchronize/referential/ng/ReferentialSynchroModel.java - client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/synchronize/referential/ng/ReferentialSynchronizeResources.java - client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/synchronize/referential/ng/actions/ReferentialSynchroUIActionSupport.java - client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/synchronize/referential/ng/actions/Start.java - client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/synchronize/referential/ng/task/SwingReferentialSynchronizeTask.java - client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/synchronize/referential/ng/task/SwingWithReplaceDataTask.java - client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/synchronize/referential/ng/tree/ReferentialSelectionTreePaneHandler.java - client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/synchronize/referential/ng/tree/ReferentialSynchronizeTreeModel.java - client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/synchronize/referential/ng/tree/actions/RegisterDeactivateWithReplacement.java - client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/synchronize/referential/ng/tree/actions/RegisterDelete.java - client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/synchronize/referential/ng/tree/actions/RegisterTaskActionSupport.java - client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/ContentUIInitializer.java - client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/list/actions/GotoSelectedData.java - client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/navigation/NavigationUIHandler.java - client/datasource/editor/api/src/main/resources/fr/ird/observe/client/datasource/editor/api/content/data/list/ContentListUI.keys - client/i18n/src/main/i18n/translations/observe_en_GB.properties - client/i18n/src/main/i18n/translations/observe_es_ES.properties - client/i18n/src/main/i18n/translations/observe_fr_FR.properties - models/persistence/src/main/java/fr/ird/observe/entities/data/ps/observation/SetImpl.java - models/persistence/src/main/models/Observe-20-data-ps-observation.model - models/persistence/src/main/resources/db/migration/8.0/50_ps_observation_create-common.sql - services/api/src/main/java/fr/ird/observe/services/service/actions/synchro/referential/ng/task/ReferentialSynchronizeTaskType.java - tests/test/src/main/resources/db/8.0/dataForTestLongline.sql.gz - tests/test/src/main/resources/db/8.0/dataForTestSeine.sql.gz - tests/test/src/main/resources/db/8.0/empty_h2.sql.gz - tests/test/src/main/resources/db/8.0/empty_pg.sql.gz - tests/test/src/main/resources/db/8.0/referentiel.sql.gz Changes: ===================================== client/core/src/main/java/fr/ird/observe/client/util/init/DefaultUIInitializer.java ===================================== @@ -46,6 +46,7 @@ import org.nuiton.jaxx.widgets.text.BigTextEditor; import javax.swing.AbstractButton; import javax.swing.JComponent; import javax.swing.JLabel; +import javax.swing.JSplitPane; import javax.swing.JTree; import javax.swing.KeyStroke; import java.awt.Component; @@ -55,7 +56,6 @@ import java.util.Objects; public class DefaultUIInitializer<UI extends JComponent & JAXXObject> extends UIInitializerSupport<UI, DefaultUIInitializerContext<UI>> implements WithClientConfig, WithClientUIContext { - public static final String OBSERVE_ACTION = "observeAction"; public static final String CLIENT_PROPERTY_FORCE_LOAD = "forceLoad"; public static final String CLIENT_PROPERTY_LIST_NO_LOAD = "listNoLoad"; // public static final String DELEGATE_CONTENT_UI = "delegateContentUI"; @@ -113,6 +113,7 @@ public class DefaultUIInitializer<UI extends JComponent & JAXXObject> extends UI .onComponents(CoordinatesEditor.class, this::init) .onComponents(BeanEnumEditor.class, this::init) .onComponents(JLabel.class, this::init) + .onComponents(JSplitPane.class, this::init) .onComponents(JTree.class, this::init) .startSecondPass(); } @@ -131,12 +132,13 @@ public class DefaultUIInitializer<UI extends JComponent & JAXXObject> extends UI } } + private void init(JSplitPane editor) { + initializerContext.checkFirstPass(); + UIInitHelper.init(editor); + } + protected void init(AbstractButton editor) { initializerContext.checkFirstPass(); - String actionId = (String) editor.getClientProperty(OBSERVE_ACTION); - if (actionId != null) { - throw new IllegalStateException(String.format("Can't use observeAction... on ui:%s - %s", ui.getClass().getName(), actionId)); - } } protected void init(BeanCheckBox editor) { ===================================== client/datasource/actions/src/main/i18n/getters/java.getter ===================================== @@ -143,7 +143,9 @@ observe.ui.datasource.editor.actions.synchro.referential.task.deactivateFromLeft observe.ui.datasource.editor.actions.synchro.referential.task.deactivateFromRight observe.ui.datasource.editor.actions.synchro.referential.task.deactivateFromRightWithReplacement observe.ui.datasource.editor.actions.synchro.referential.task.deleteFromLeft +observe.ui.datasource.editor.actions.synchro.referential.task.deleteFromLeftWithReplacement observe.ui.datasource.editor.actions.synchro.referential.task.deleteFromRight +observe.ui.datasource.editor.actions.synchro.referential.task.deleteFromRightWithReplacement observe.ui.datasource.editor.actions.synchro.referential.task.include.properties observe.ui.datasource.editor.actions.synchro.referential.task.prepare observe.ui.datasource.editor.actions.synchro.referential.task.revertFromLeft ===================================== client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/synchronize/referential/ng/ReferentialSynchroModel.java ===================================== @@ -45,6 +45,8 @@ import fr.ird.observe.services.service.actions.synchro.referential.ng.Referentia import fr.ird.observe.services.service.actions.synchro.referential.ng.ReferentialSynchronizeServiceEngine; import fr.ird.observe.services.service.actions.synchro.referential.ng.task.ReferentialSynchronizeTaskType; import fr.ird.observe.services.service.referential.differential.DifferentialEngine; +import fr.ird.observe.services.service.usage.DtoUsageCountRequest; +import fr.ird.observe.services.service.usage.DtoUsageCountResult; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.nuiton.jaxx.runtime.swing.wizard.ext.WizardState; @@ -422,4 +424,8 @@ public class ReferentialSynchroModel extends AdminActionModel implements WithDec } return ImmutableList.copyOf(references.values()); } + + public <R extends ReferentialDtoReference> DtoUsageCountResult<?> getUsageCount(boolean left, R reference) { + return (left ? getLeftSource() : getRightSource()).getUsageService().count(new DtoUsageCountRequest<>(reference.getDtoType(), reference.getId())); + } } ===================================== client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/synchronize/referential/ng/ReferentialSynchronizeResources.java ===================================== @@ -22,15 +22,8 @@ package fr.ird.observe.client.datasource.actions.synchronize.referential.ng; * #L% */ -import com.google.common.collect.ImmutableSet; -import fr.ird.observe.client.datasource.actions.synchronize.referential.ng.task.SwingReferentialSynchronizeTask; -import fr.ird.observe.client.datasource.actions.synchronize.referential.ng.task.SwingWithIncludedPropertyNamesTask; -import fr.ird.observe.client.datasource.actions.synchronize.referential.ng.task.SwingWithReplaceDataTask; import fr.ird.observe.client.datasource.actions.synchronize.referential.ng.tree.node.ReferentialSynchroNodeSupport; import fr.ird.observe.client.util.UIHelper; -import fr.ird.observe.dto.reference.ReferentialDtoReference; -import fr.ird.observe.dto.referential.differential.Differential; -import fr.ird.observe.dto.referential.differential.DifferentialPropertyList; import fr.ird.observe.services.service.actions.synchro.referential.ng.task.ReferentialSynchronizeTaskType; import javax.swing.Icon; @@ -72,10 +65,6 @@ public enum ReferentialSynchronizeResources { null, ReferentialSynchronizeTaskType.UPDATE, ReferentialSynchroNodeSupport::isCanUpdate) { - @Override - public SwingReferentialSynchronizeTask createTask(boolean left, Differential differential, ReferentialDtoReference replaceReference, ImmutableSet<String> includedPropertyNames, DifferentialPropertyList includedProperties) { - return new SwingWithIncludedPropertyNamesTask(this, left, differential, includedPropertyNames, includedProperties); - } }, COPY( "copyToRight", @@ -99,13 +88,16 @@ public enum ReferentialSynchronizeResources { n("observe.ui.datasource.editor.actions.synchro.referential.action.deleteFromRight.tip"), ReferentialSynchroModel.DELETE_LEFT_PROPERTY_NAME, ReferentialSynchroModel.DELETE_RIGHT_PROPERTY_NAME, - KeyStroke.getKeyStroke("pressed F6"), - KeyStroke.getKeyStroke("shift pressed F6"), + KeyStroke.getKeyStroke("pressed F5"), + KeyStroke.getKeyStroke("shift pressed F5"), ReferentialSynchronizeTaskType.DELETE, ReferentialSynchroNodeSupport::isCanDelete) { @Override - public SwingReferentialSynchronizeTask createTask(boolean left, Differential differential, ReferentialDtoReference replaceReference, ImmutableSet<String> includedPropertyNames, DifferentialPropertyList includedProperties) { - return new SwingWithReplaceDataTask(this, left, differential, replaceReference); + public String getTaskReplaceLabel(boolean left) { + if (left) { + return n("observe.ui.datasource.editor.actions.synchro.referential.task.deleteFromLeftWithReplacement"); + } + return n("observe.ui.datasource.editor.actions.synchro.referential.task.deleteFromRightWithReplacement"); } }, REVERT( @@ -120,12 +112,7 @@ public enum ReferentialSynchronizeResources { KeyStroke.getKeyStroke("pressed F2"), KeyStroke.getKeyStroke("shift pressed F2"), ReferentialSynchronizeTaskType.REVERT, - ReferentialSynchroNodeSupport::isCanRevert) { - @Override - public SwingReferentialSynchronizeTask createTask(boolean left, Differential differential, ReferentialDtoReference replaceReference, ImmutableSet<String> includedPropertyNames, DifferentialPropertyList includedProperties) { - return new SwingWithIncludedPropertyNamesTask(this, left, differential, includedPropertyNames, includedProperties); - } - }, + ReferentialSynchroNodeSupport::isCanRevert), DEACTIVATE( "deactivateFromLeft", "deactivateFromRight", @@ -151,12 +138,7 @@ public enum ReferentialSynchronizeResources { KeyStroke.getKeyStroke("pressed F4"), KeyStroke.getKeyStroke("shift pressed F4"), ReferentialSynchronizeTaskType.DEACTIVATE_WITH_REPLACEMENT, - ReferentialSynchroNodeSupport::isCanDelete) { - @Override - public SwingReferentialSynchronizeTask createTask(boolean left, Differential differential, ReferentialDtoReference replaceReference, ImmutableSet<String> includedPropertyNames, DifferentialPropertyList includedProperties) { - return new SwingWithReplaceDataTask(this, left, differential, replaceReference); - } - }; + ReferentialSynchroNodeSupport::isCanDelete); private final String leftActionName; private final String leftTaskI18nKey; @@ -215,6 +197,10 @@ public enum ReferentialSynchronizeResources { return left ? leftTaskI18nKey : rightTaskI18nKey; } + public String getTaskReplaceLabel(boolean left) { + return getTaskLabel(left); + } + public String getActionTip(boolean left) { return left ? leftActionTipI18nKey : rightActionTipI18nKey; } @@ -235,14 +221,6 @@ public enum ReferentialSynchronizeResources { return taskType != null && taskType.withProperties(); } - public boolean withReplace() { - return taskType != null && taskType.withReplace(); - } - - public SwingReferentialSynchronizeTask createTask(boolean left, Differential differential, ReferentialDtoReference replaceReference, ImmutableSet<String> includedPropertyNames, DifferentialPropertyList includedProperties) { - return new SwingReferentialSynchronizeTask(this, left, differential); - } - public KeyStroke getKeyStroke(boolean left) { return left ? leftKeyStroke : rightKeyStroke; } ===================================== client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/synchronize/referential/ng/actions/ReferentialSynchroUIActionSupport.java ===================================== @@ -23,56 +23,12 @@ package fr.ird.observe.client.datasource.actions.synchronize.referential.ng.acti */ import fr.ird.observe.client.datasource.actions.actions.AdminTabUIActionSupport; -import fr.ird.observe.client.datasource.actions.synchronize.referential.ng.ReferentialSynchroModel; import fr.ird.observe.client.datasource.actions.synchronize.referential.ng.ReferentialSynchroUI; -import fr.ird.observe.client.datasource.actions.synchronize.referential.ng.tree.ReferentialSynchronizeTreeModel; - -import javax.swing.KeyStroke; abstract class ReferentialSynchroUIActionSupport extends AdminTabUIActionSupport<ReferentialSynchroUI> { - ReferentialSynchroUIActionSupport(String label, String shortDescription, String actionIcon, KeyStroke acceleratorKey) { - super(label, shortDescription, actionIcon, acceleratorKey); - } - ReferentialSynchroUIActionSupport(String label, String shortDescription, String actionIcon, char acceleratorKey) { super(label, shortDescription, actionIcon, acceleratorKey); } - - protected void updateLeftEnableActions(ReferentialSynchronizeTreeModel treeModel) { - - ReferentialSynchroModel stepModel = ui.getStepModel(); - - treeModel.updateSelectedActions(); - stepModel.setCopyLeft(treeModel.isCanAdd() || treeModel.isCanUpdate()); - stepModel.setDeleteLeft(treeModel.isCanDelete()); - stepModel.setDeactivateLeft(treeModel.isCanDelete()); - stepModel.setDeactivateWithReplaceLeft(treeModel.isCanDelete()); - stepModel.setRevertLeft(treeModel.isCanRevert()); - stepModel.setSkipLeft(treeModel.isCanSkip()); - } - - protected void updateRightEnableActions(ReferentialSynchronizeTreeModel treeModel) { - - ReferentialSynchroModel stepModel = ui.getStepModel(); - - treeModel.updateSelectedActions(); - stepModel.setCopyRight(treeModel.isCanAdd() || treeModel.isCanUpdate()); - stepModel.setDeleteRight(treeModel.isCanDelete()); - stepModel.setDeactivateRight(treeModel.isCanDelete()); - stepModel.setDeactivateWithReplaceRight(treeModel.isCanDelete()); - stepModel.setRevertRight(treeModel.isCanRevert()); - stepModel.setSkipRight(treeModel.isCanSkip()); - } - - - protected void updateActions(ReferentialSynchronizeTreeModel treeModel) { - if (treeModel.isLeft()) { - updateLeftEnableActions(treeModel); - } else { - updateRightEnableActions(treeModel); - } - } - } ===================================== client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/synchronize/referential/ng/actions/Start.java ===================================== @@ -30,6 +30,7 @@ import fr.ird.observe.client.datasource.actions.synchronize.referential.ng.tree. import fr.ird.observe.client.datasource.actions.synchronize.referential.ng.tree.ReferentialSelectionTreePane; import fr.ird.observe.client.datasource.actions.synchronize.referential.ng.tree.ReferentialSynchronizeTreeModel; import fr.ird.observe.client.datasource.actions.synchronize.referential.ng.tree.ReferentialSynchronizeTreeModelsBuilder; +import fr.ird.observe.client.datasource.actions.synchronize.referential.ng.tree.actions.RegisterTaskActionSupport; import fr.ird.observe.client.datasource.api.ObserveSwingDataSource; import fr.ird.observe.client.datasource.editor.api.wizard.connexion.DataSourceSelectorModel; import fr.ird.observe.dto.ProgressionModel; @@ -93,13 +94,13 @@ public class Start extends ReferentialSynchroUIActionSupport { stepModel.getLeftTreeModel(), model.getConfigModel().getLeftSourceModel(), t("observe.ui.datasource.editor.actions.synchro.referential.message.referential.leftData.loaded"), - evt -> updateLeftEnableActions(stepModel.getLeftTreeModel())); + evt -> RegisterTaskActionSupport.updateActions(stepModel, stepModel.getLeftTreeModel())); initTree(ui.getRightTreePane(), stepModel.getRightTreeModel(), model.getConfigModel().getRightSourceModel(), t("observe.ui.datasource.editor.actions.synchro.referential.message.referential.rightData.loaded"), - evt -> updateRightEnableActions(stepModel.getRightTreeModel())); + evt -> RegisterTaskActionSupport.updateActions(stepModel, stepModel.getRightTreeModel())); return WizardState.NEED_FIX; } ===================================== client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/synchronize/referential/ng/task/SwingReferentialSynchronizeTask.java ===================================== @@ -49,21 +49,23 @@ public class SwingReferentialSynchronizeTask implements WithDecoratorService { private final String i18nKey; private final Differential differential; private final Icon icon; - // private final ReferentialSynchronizeResources resource; private final boolean left; private final ReferentialSynchronizeTaskType taskType; - public SwingReferentialSynchronizeTask(ReferentialSynchronizeResources resource, boolean left, Differential differential) { -// this.resource = resource; - this.left = left; + public SwingReferentialSynchronizeTask(String i18nKey, Differential differential, Icon icon, boolean left, ReferentialSynchronizeTaskType taskType) { + this.i18nKey = i18nKey; this.differential = differential; - this.icon = resource.getIcon(left); - this.i18nKey = resource.getTaskLabel(left); - this.taskType = resource.getTaskType(); + this.icon = icon; + this.left = left; + this.taskType = taskType; this.dataStr = differential.getLabel(getDecoratorService()); this.typeStr = t(ContentReferentialUII18nHelper.getType(differential.getDtoType())); } + public SwingReferentialSynchronizeTask(ReferentialSynchronizeResources resource, boolean left, Differential differential) { + this(resource.getTaskLabel(left), differential, resource.getIcon(left), left, resource.getTaskType()); + } + public final Differential getDifferential() { return differential; } ===================================== client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/synchronize/referential/ng/task/SwingWithReplaceDataTask.java ===================================== @@ -28,7 +28,6 @@ import fr.ird.observe.dto.referential.differential.Differential; import fr.ird.observe.services.service.actions.synchro.referential.ng.task.ReferentialSynchronizeTask; import java.util.Date; -import java.util.Objects; import static io.ultreia.java4all.i18n.I18n.t; @@ -42,8 +41,8 @@ public class SwingWithReplaceDataTask extends SwingReferentialSynchronizeTask { private final String replaceDataStr; public SwingWithReplaceDataTask(ReferentialSynchronizeResources resource, boolean left, Differential differential, ReferentialDtoReference replaceData) { - super(resource, left, differential); - this.replaceData = Objects.requireNonNull(replaceData); + super(resource.getTaskReplaceLabel(left), differential, resource.getIcon(left), left, resource.getTaskType()); + this.replaceData = replaceData; this.replaceDataStr = getDecoratorService().getReferentialReferenceDecorator(replaceData.getClass()).toString(replaceData); } ===================================== client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/synchronize/referential/ng/tree/ReferentialSelectionTreePaneHandler.java ===================================== @@ -32,6 +32,7 @@ import fr.ird.observe.client.datasource.actions.synchronize.referential.ng.tree. import fr.ird.observe.client.datasource.actions.synchronize.referential.ng.tree.actions.RegisterDelete; import fr.ird.observe.client.datasource.actions.synchronize.referential.ng.tree.actions.RegisterRevert; import fr.ird.observe.client.datasource.actions.synchronize.referential.ng.tree.actions.SelectUnselect; +import fr.ird.observe.client.util.init.DefaultUIInitializer; import org.nuiton.jaxx.runtime.spi.UIHandler; import java.awt.BorderLayout; @@ -42,6 +43,11 @@ import java.awt.BorderLayout; */ public class ReferentialSelectionTreePaneHandler implements UIHandler<ReferentialSelectionTreePane> { + @Override + public void afterInit(ReferentialSelectionTreePane ui) { + DefaultUIInitializer.doInit(ui); + } + void init(ReferentialSelectionTreePane ui) { ReferentialSynchroUI parent = ui.getContextValue(ReferentialSynchroUI.class, ReferentialSynchroUIHandler.ADMIN_TAB_UI); ReferentialSynchroModel stepModel = parent.getStepModel(); ===================================== client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/synchronize/referential/ng/tree/ReferentialSynchronizeTreeModel.java ===================================== @@ -33,7 +33,6 @@ import fr.ird.observe.client.datasource.actions.synchronize.referential.ng.tree. import fr.ird.observe.dto.referential.ReferentialDto; import javax.swing.tree.DefaultTreeModel; -import javax.swing.tree.TreeNode; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import java.util.Collection; @@ -87,7 +86,7 @@ public class ReferentialSynchronizeTreeModel extends DefaultTreeModel { if (node instanceof ReferentialTypeSynchroNode) { ReferentialTypeSynchroNode node1 = (ReferentialTypeSynchroNode) node; node1.updateSelect(value); - Enumeration<? extends TreeNode> children = node1.children(); + Enumeration<?> children = node1.children(); while (children.hasMoreElements()) { ReferentialSynchroNodeSupport childNode = (ReferentialSynchroNodeSupport) children.nextElement(); updateSelected(value, childNode); ===================================== client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/synchronize/referential/ng/tree/actions/RegisterDeactivateWithReplacement.java ===================================== @@ -37,6 +37,11 @@ public class RegisterDeactivateWithReplacement extends RegisterTaskActionSupport super(ui, ReferentialSynchronizeResources.DEACTIVATE_WITH_REPLACEMENT, left); } + protected <R extends ReferentialDtoReference> boolean shouldReplace(R reference) { + // always ask a replacement for this task + return true; + } + @Override protected String getReplaceTitle(ReferentialDtoReference reference) { return t("observe.ui.datasource.editor.actions.synchro.referential.replaceBeforeDeactivate.title", typeStr, referenceStr); ===================================== client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/synchronize/referential/ng/tree/actions/RegisterDelete.java ===================================== @@ -22,9 +22,11 @@ package fr.ird.observe.client.datasource.actions.synchronize.referential.ng.tree * #L% */ +import fr.ird.observe.client.datasource.actions.synchronize.referential.ng.ReferentialSynchroModel; import fr.ird.observe.client.datasource.actions.synchronize.referential.ng.ReferentialSynchronizeResources; import fr.ird.observe.client.datasource.actions.synchronize.referential.ng.tree.ReferentialSelectionTreePane; import fr.ird.observe.dto.reference.ReferentialDtoReference; +import fr.ird.observe.services.service.usage.DtoUsageCountResult; import static io.ultreia.java4all.i18n.I18n.t; @@ -42,4 +44,11 @@ public class RegisterDelete extends RegisterTaskActionSupport { return t("observe.ui.datasource.editor.actions.synchro.referential.replaceBeforeDelete.title", typeStr, referenceStr); } + @Override + protected <R extends ReferentialDtoReference> boolean shouldReplace(R reference) { + // check if there is some data using it + ReferentialSynchroModel stepModel = parentUI.getStepModel(); + DtoUsageCountResult<?> usages = stepModel.getUsageCount(isLeft(), reference); + return !usages.isEmpty(); + } } ===================================== client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/synchronize/referential/ng/tree/actions/RegisterTaskActionSupport.java ===================================== @@ -24,9 +24,6 @@ package fr.ird.observe.client.datasource.actions.synchronize.referential.ng.tree import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; -import fr.ird.observe.client.datasource.actions.AdminStep; -import fr.ird.observe.client.datasource.actions.AdminTabUI; -import fr.ird.observe.client.datasource.actions.AdminUI; import fr.ird.observe.client.datasource.actions.synchronize.referential.ng.ReferentialReplaceUI; import fr.ird.observe.client.datasource.actions.synchronize.referential.ng.ReferentialReplaceUIHandler; import fr.ird.observe.client.datasource.actions.synchronize.referential.ng.ReferentialSynchroModel; @@ -34,6 +31,7 @@ import fr.ird.observe.client.datasource.actions.synchronize.referential.ng.Refer import fr.ird.observe.client.datasource.actions.synchronize.referential.ng.ReferentialSynchronizeResources; import fr.ird.observe.client.datasource.actions.synchronize.referential.ng.task.SwingReferentialSynchronizeTask; import fr.ird.observe.client.datasource.actions.synchronize.referential.ng.task.SwingWithIncludedPropertyNamesTask; +import fr.ird.observe.client.datasource.actions.synchronize.referential.ng.task.SwingWithReplaceDataTask; import fr.ird.observe.client.datasource.actions.synchronize.referential.ng.tree.ReferentialSelectionTree; import fr.ird.observe.client.datasource.actions.synchronize.referential.ng.tree.ReferentialSelectionTreePane; import fr.ird.observe.client.datasource.actions.synchronize.referential.ng.tree.ReferentialSynchronizeTreeModel; @@ -80,16 +78,32 @@ import static io.ultreia.java4all.i18n.I18n.t; public abstract class RegisterTaskActionSupport extends ReferentialSelectionTreePaneActionSupport implements WithDecoratorService { private static final Logger log = LogManager.getLogger(RegisterTaskActionSupport.class); + protected final ReferentialSynchroUI parentUI; final Predicate<ReferentialSynchroNodeSupport> predicate; final ReferentialSelectionTreePane ui; private final boolean left; - private final boolean needReplace; private final ReferentialSynchronizeTaskType taskType; private final ReferentialSynchronizeResources resource; - private final ReferentialSynchroUI parentUI; String typeStr; String referenceStr; + public static void updateActions(ReferentialSynchroModel stepModel, ReferentialSynchronizeTreeModel treeModel) { + treeModel.updateSelectedActions(); + if (treeModel.isLeft()) { + stepModel.setCopyLeft(treeModel.isCanAdd() || treeModel.isCanUpdate()); + stepModel.setDeleteLeft(treeModel.isCanDelete()); + stepModel.setDeactivateLeft(treeModel.isCanDelete()); + stepModel.setDeactivateWithReplaceLeft(treeModel.isCanDelete()); + stepModel.setRevertLeft(treeModel.isCanRevert()); + } else { + stepModel.setCopyRight(treeModel.isCanAdd() || treeModel.isCanUpdate()); + stepModel.setDeleteRight(treeModel.isCanDelete()); + stepModel.setDeactivateRight(treeModel.isCanDelete()); + stepModel.setDeactivateWithReplaceRight(treeModel.isCanDelete()); + stepModel.setRevertRight(treeModel.isCanRevert()); + } + } + RegisterTaskActionSupport(ReferentialSelectionTreePane ui, ReferentialSynchronizeResources resource, boolean left) { super("", null, null, Objects.requireNonNull(resource).getKeyStroke(left)); this.resource = resource; @@ -104,7 +118,7 @@ public abstract class RegisterTaskActionSupport extends ReferentialSelectionTree this.ui = ui; this.left = left; this.taskType = resource.getTaskType(); - this.needReplace = resource.withReplace(); +// this.needReplace = resource.withReplace(); parentUI = ui.getContextValue(ReferentialSynchroUI.class, "synchroParent"); Predicate<ReferentialSynchroNodeSupport> predicate = resource.getPredicate(); @@ -127,7 +141,15 @@ public abstract class RegisterTaskActionSupport extends ReferentialSelectionTree } protected final SwingReferentialSynchronizeTask createTask(boolean left, Differential differential, ReferentialDtoReference replaceReference, ImmutableSet<String> includedPropertyNames, DifferentialPropertyList includedModifiedProperties) { - return getResource().createTask(left, differential, replaceReference, includedPropertyNames, includedModifiedProperties); + ReferentialSynchronizeResources resource = getResource(); + if (replaceReference != null) { + return new SwingWithReplaceDataTask(resource, left, differential, replaceReference); + } + if (resource.withProperties()) { + return new SwingWithIncludedPropertyNamesTask(resource, left, differential, includedPropertyNames, includedModifiedProperties); + + } + return new SwingReferentialSynchronizeTask(resource, left, differential); } public ReferentialSynchronizeResources getResource() { @@ -147,7 +169,7 @@ public abstract class RegisterTaskActionSupport extends ReferentialSelectionTree ReferentialSynchronizeTreeModel treeModel = getTreeModel(); createTasks(); treeModel.clearSelection(); - updateActions(treeModel); + updateActions(parentUI.getStepModel(), treeModel); SwingUtilities.invokeLater(getTree()::repaint); } @@ -189,6 +211,11 @@ public abstract class RegisterTaskActionSupport extends ReferentialSelectionTree } } + protected <R extends ReferentialDtoReference> boolean shouldReplace(R reference) { + // by default never ask for a replacement + return false; + } + @SuppressWarnings("unchecked") public <R extends ReferentialDtoReference> void process(ReferentialSynchroNodeSupport node, Collection<SwingReferentialSynchronizeTask> addedTasks, @@ -198,7 +225,7 @@ public abstract class RegisterTaskActionSupport extends ReferentialSelectionTree R reference = (R) node.getReferentialReference(); R replaceReference = null; - if (needReplace) { + if (shouldReplace(reference)) { Class<R> type = (Class<R>) reference.getReferenceType(); List<R> references = new LinkedList<>(parentUI.getStepModel().getPossibleReplaceUniverse(left, reference)); @@ -301,63 +328,14 @@ public abstract class RegisterTaskActionSupport extends ReferentialSelectionTree } public String sendMessage(String message) { - AdminStep step = parentUI.getStep(); - addMessage(step, message); + addMessage(message); return message; } - - public void addMessage(AdminStep step, String text) { + public void addMessage(String text) { JTextArea progression = parentUI.getProgression(); progression.append(text + "\n"); progression.setCaretPosition(progression.getDocument().getLength()); } - public void addMessage(AdminTabUI ui, AdminStep step, String text) { - JTextArea progression = ui.getProgression(); - progression.append(text + "\n"); - progression.setCaretPosition(progression.getDocument().getLength()); - } - - - protected AdminUI getParentUI() { - return parentUI.getContextValue(AdminUI.class, "parent"); - } - - - protected void updateLeftEnableActions(ReferentialSynchronizeTreeModel treeModel) { - - ReferentialSynchroModel stepModel = parentUI.getStepModel(); - - treeModel.updateSelectedActions(); - stepModel.setCopyLeft(treeModel.isCanAdd() || treeModel.isCanUpdate()); - stepModel.setDeleteLeft(treeModel.isCanDelete()); - stepModel.setDeactivateLeft(treeModel.isCanDelete()); - stepModel.setDeactivateWithReplaceLeft(treeModel.isCanDelete()); - stepModel.setRevertLeft(treeModel.isCanRevert()); - stepModel.setSkipLeft(treeModel.isCanSkip()); - } - - protected void updateRightEnableActions(ReferentialSynchronizeTreeModel treeModel) { - - ReferentialSynchroModel stepModel = parentUI.getStepModel(); - - treeModel.updateSelectedActions(); - stepModel.setCopyRight(treeModel.isCanAdd() || treeModel.isCanUpdate()); - stepModel.setDeleteRight(treeModel.isCanDelete()); - stepModel.setDeactivateRight(treeModel.isCanDelete()); - stepModel.setDeactivateWithReplaceRight(treeModel.isCanDelete()); - stepModel.setRevertRight(treeModel.isCanRevert()); - stepModel.setSkipRight(treeModel.isCanSkip()); - } - - - protected void updateActions(ReferentialSynchronizeTreeModel treeModel) { - if (treeModel.isLeft()) { - updateLeftEnableActions(treeModel); - } else { - updateRightEnableActions(treeModel); - } - } - } ===================================== client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/ContentUIInitializer.java ===================================== @@ -74,6 +74,7 @@ import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JScrollBar; +import javax.swing.JSplitPane; import javax.swing.JTabbedPane; import javax.swing.JToolBar; import javax.swing.KeyStroke; @@ -193,6 +194,7 @@ public class ContentUIInitializer<UI extends ContentUI> extends UIInitializerSup .onComponents(BeanEnumEditor.class, this::init) .onComponents(ObserveSwingValidator.class, this::init) .onComponents(JLabel.class, this::init) + .onComponents(JSplitPane.class, this::init) .onComponents(BigTextEditor.class, this::init) .onComponents(UrlEditor.class, this::init) .onComponents(NormalTextEditor.class, this::init) ===================================== client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/list/actions/GotoSelectedData.java ===================================== @@ -44,7 +44,7 @@ public final class GotoSelectedData<D extends DataDto, R extends DataDtoReferenc public GotoSelectedData(Class<D> dataType) { super(dataType, null, null, "go-down", ObserveKeyStrokesEditorApi.KEY_STROKE_ALT_ENTER); - setText(ContentListUII18nHelper.getListActionGoToSelected(getDataType())); + setText(ContentListUII18nHelper.getActionGoToSelected(getDataType())); } @Override ===================================== client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/navigation/NavigationUIHandler.java ===================================== @@ -93,7 +93,7 @@ public class NavigationUIHandler implements UIHandler<NavigationUI> { @Override public void afterInit(NavigationUI ui) { UIInitializerResult initializerResult = new Init(ui).initUI(); - actionsToReload = ReloadAction.collect(initializerResult.getComponents(AbstractButton.class)); + actionsToReload = ReloadAction.collect(initializerResult.getSubComponents(AbstractButton.class)); } public void updateActions(NavigationNode selectedNode) { ===================================== client/datasource/editor/api/src/main/resources/fr/ird/observe/client/datasource/editor/api/content/data/list/ContentListUI.keys ===================================== @@ -1,12 +1,12 @@ type list.title list.message.none -list.action.goToSelected list.navigation.node action.create action.create.tip action.goToOpen action.goToOpen.short +action.goToSelected action.move.tip action.move action.move.choose.parent.title ===================================== client/i18n/src/main/i18n/translations/observe_en_GB.properties ===================================== @@ -1405,8 +1405,10 @@ observe.ui.datasource.editor.actions.synchro.referential.task.deactivateFromLeft observe.ui.datasource.editor.actions.synchro.referential.task.deactivateFromLeftWithReplacement=Disable in left database\: <i>%s</i> - «<b>%s</b>» to replace by «<b>%s</b>» observe.ui.datasource.editor.actions.synchro.referential.task.deactivateFromRight=Disable in right database\: <i>%s</i> - «<b>%s</b>» observe.ui.datasource.editor.actions.synchro.referential.task.deactivateFromRightWithReplacement=Disable in right database\: <i>%s</i> - «<b>%s</b>» to replace by «<b>%s</b>» -observe.ui.datasource.editor.actions.synchro.referential.task.deleteFromLeft=Delete in left database\: <i>%s</i> - «<b>%s</b>» to replace by «<b>%s</b>» -observe.ui.datasource.editor.actions.synchro.referential.task.deleteFromRight=Delete in right database\: <i>%s</i> - «<b>%s</b>» to replace by «<b>%s</b>» +observe.ui.datasource.editor.actions.synchro.referential.task.deleteFromLeft=Delete in left database\: <i>%s</i> - «<b>%s</b>» with no replacement +observe.ui.datasource.editor.actions.synchro.referential.task.deleteFromLeftWithReplacement=Delete in left database\: <i>%s</i> - «<b>%s</b>» to replace by «<b>%s</b>» +observe.ui.datasource.editor.actions.synchro.referential.task.deleteFromRight=Delete in right database\: <i>%s</i> - «<b>%s</b>» with no replacement +observe.ui.datasource.editor.actions.synchro.referential.task.deleteFromRightWithReplacement=Delete in right database\: <i>%s</i> - «<b>%s</b>» to replace by «<b>%s</b>» observe.ui.datasource.editor.actions.synchro.referential.task.include.properties=Included properties\: %s observe.ui.datasource.editor.actions.synchro.referential.task.prepare=Register action %s\n * old left last update date \: %s\n * old right last update date \: %s\n * new last update date \: %s observe.ui.datasource.editor.actions.synchro.referential.task.revertFromLeft=Revert in left database\: <i>%s</i> - «<b>%s</b>» ===================================== client/i18n/src/main/i18n/translations/observe_es_ES.properties ===================================== @@ -1405,8 +1405,10 @@ observe.ui.datasource.editor.actions.synchro.referential.task.deactivateFromLeft observe.ui.datasource.editor.actions.synchro.referential.task.deactivateFromLeftWithReplacement=Desactivar en la base de la iquierda \: <i>%s</i> - «<b>%s</b>» debe ser reemplazado por «<b>%s</b>» observe.ui.datasource.editor.actions.synchro.referential.task.deactivateFromRight=Desactivar en la base de la derecha \: <i>%s</i> - «<b>%s</b>» observe.ui.datasource.editor.actions.synchro.referential.task.deactivateFromRightWithReplacement=Desactivar en la base de la derecha \: <i>%s</i> - «<b>%s</b>» debe ser reemplazado por «<b>%s</b>» -observe.ui.datasource.editor.actions.synchro.referential.task.deleteFromLeft=Eliminar en la base de la izquierda\: <i>%s</i> - «<b>%s</b>» debe ser reemplazado por «<b>%s</b>» -observe.ui.datasource.editor.actions.synchro.referential.task.deleteFromRight=Eliminar en la base de la izquierda \: <i>%s</i> - «<b>%s</b>» debe ser reemplazado por «<b>%s</b>» +observe.ui.datasource.editor.actions.synchro.referential.task.deleteFromLeft=Eliminar en la base de la izquierda\: <i>%s</i> - «<b>%s</b>» +observe.ui.datasource.editor.actions.synchro.referential.task.deleteFromLeftWithReplacement=Eliminar en la base de la izquierda\: <i>%s</i> - «<b>%s</b>» debe ser reemplazado por «<b>%s</b>» +observe.ui.datasource.editor.actions.synchro.referential.task.deleteFromRight=Eliminar en la base de la izquierda \: <i>%s</i> - «<b>%s</b>» +observe.ui.datasource.editor.actions.synchro.referential.task.deleteFromRightWithReplacement=Eliminar en la base de la izquierda \: <i>%s</i> - «<b>%s</b>» debe ser reemplazado por «<b>%s</b>» observe.ui.datasource.editor.actions.synchro.referential.task.include.properties=Included properties\: %s \#TODO observe.ui.datasource.editor.actions.synchro.referential.task.prepare=Registro de la acción %s\n * old left last update date \: %s\n * old right last update date \: %s\n * new last update date \: %s \#TODO observe.ui.datasource.editor.actions.synchro.referential.task.revertFromLeft=Volver atrás en la base de la izquierda \: <i>%s</i> - «<b>%s</b>» ===================================== client/i18n/src/main/i18n/translations/observe_fr_FR.properties ===================================== @@ -1405,8 +1405,10 @@ observe.ui.datasource.editor.actions.synchro.referential.task.deactivateFromLeft observe.ui.datasource.editor.actions.synchro.referential.task.deactivateFromLeftWithReplacement=Désactiver dans la base de gauche \: <i>%s</i> - «<b>%s</b>» à remplacer par «<b>%s</b>» observe.ui.datasource.editor.actions.synchro.referential.task.deactivateFromRight=Désactiver dans la base de droite \: <i>%s</i> - «<b>%s</b>» observe.ui.datasource.editor.actions.synchro.referential.task.deactivateFromRightWithReplacement=Désactiver dans la base de droite \: <i>%s</i> - «<b>%s</b>» à remplacer par «<b>%s</b>» -observe.ui.datasource.editor.actions.synchro.referential.task.deleteFromLeft=Supprimer dans la base de gauche \: <i>%s</i> - «<b>%s</b>» à remplacer par «<b>%s</b>» -observe.ui.datasource.editor.actions.synchro.referential.task.deleteFromRight=Supprimer dans la base de droite \: <i>%s</i> - «<b>%s</b>» à remplacer par «<b>%s</b>» +observe.ui.datasource.editor.actions.synchro.referential.task.deleteFromLeft=Supprimer dans la base de gauche \: <i>%s</i> - «<b>%s</b>» sans remplacement +observe.ui.datasource.editor.actions.synchro.referential.task.deleteFromLeftWithReplacement=Supprimer dans la base de gauche \: <i>%s</i> - «<b>%s</b>» à remplacer par «<b>%s</b>» +observe.ui.datasource.editor.actions.synchro.referential.task.deleteFromRight=Supprimer dans la base de droite \: <i>%s</i> - «<b>%s</b>» sans remplacement +observe.ui.datasource.editor.actions.synchro.referential.task.deleteFromRightWithReplacement=Supprimer dans la base de droite \: <i>%s</i> - «<b>%s</b>» à remplacer par «<b>%s</b>» observe.ui.datasource.editor.actions.synchro.referential.task.include.properties=Propriétés incluses \: %s observe.ui.datasource.editor.actions.synchro.referential.task.prepare=Enregistrement de l'action %s\n * ancienne date de mise à jour à gauche \: %s\n * ancienne date de mise à jourà droite \: %s\n * nouvelle date de mise à jour \: %s observe.ui.datasource.editor.actions.synchro.referential.task.revertFromLeft=Revenir en arrière dans la base de gauche \: <i>%s</i> - «<b>%s</b>» ===================================== models/persistence/src/main/java/fr/ird/observe/entities/data/ps/observation/SetImpl.java ===================================== @@ -22,7 +22,6 @@ package fr.ird.observe.entities.data.ps.observation; import com.google.common.collect.ImmutableSet; -import fr.ird.observe.dto.IdDto; import fr.ird.observe.dto.ProtectedIdsPs; import fr.ird.observe.dto.data.DataDto; import fr.ird.observe.dto.data.ps.observation.DiscardedTargetCatchDto; @@ -44,7 +43,6 @@ import fr.ird.observe.entities.referential.ps.common.SpeciesFate; import org.nuiton.util.DateUtil; import org.nuiton.util.NumberUtil; -import java.util.Collection; import java.util.Date; import java.util.List; import java.util.Objects; @@ -185,11 +183,11 @@ public class SetImpl extends SetAbstract { @Override public <D extends DataDto> void toDto(ReferentialLocale referentialLocale, D dto) { if (dto instanceof SetDiscardedTargetCatchDto) { - toSetTargetCatchDto(true, referentialLocale, dto, DiscardedTargetCatchDto.class); + toSetDiscardedTargetCatchDto(referentialLocale, (SetDiscardedTargetCatchDto) dto); return; } if (dto instanceof SetKeptTargetCatchDto) { - toSetTargetCatchDto(false, referentialLocale, dto, KeptTargetCatchDto.class); + toSetKeptTargetCatchDto(referentialLocale, (SetKeptTargetCatchDto) dto); return; } if (dto instanceof SetNonTargetCatchDto) { @@ -221,11 +219,11 @@ public class SetImpl extends SetAbstract { @Override public <D extends DataDto> void fromDto(ReferentialLocale referentialLocale, D dto) { if (dto instanceof SetDiscardedTargetCatchDto) { - fromSetTargetCatchDto(true, referentialLocale, dto); + fromSetDiscardedTargetCatchDto(referentialLocale, (SetDiscardedTargetCatchDto) dto); return; } if (dto instanceof SetKeptTargetCatchDto) { - fromSetTargetCatchDto(false, referentialLocale, dto); + fromSetKeptTargetCatchDto(referentialLocale, (SetKeptTargetCatchDto) dto); return; } if (dto instanceof SetNonTargetCatchDto) { @@ -253,18 +251,36 @@ public class SetImpl extends SetAbstract { } } - private <D extends DataDto, C extends DataDto> void toSetTargetCatchDto(boolean discarded, ReferentialLocale referentialLocale, D dto, Class<C> dtoCatchType) { + private void toSetKeptTargetCatchDto(ReferentialLocale referentialLocale, SetKeptTargetCatchDto dto) { super.toDto(referentialLocale, dto); - List<C> dtoList = EntityHelper.toDataDtoList(referentialLocale, getTargetCatch(discarded), dtoCatchType); - dto.set(SetKeptTargetCatchDto.PROPERTY_TARGET_CATCH, dtoList); + List<KeptTargetCatchDto> dtoList = EntityHelper.toDataDtoList(referentialLocale, getTargetCatch(false), KeptTargetCatchDto.class); + dto.setTargetCatch(dtoList); // is there some sample? - TargetSample targetSample = getTargetSample(discarded); + TargetSample targetSample = getTargetSample(false); if (targetSample != null) { // get usable species ids java.util.Set<String> speciesId = DtoReferenceAware.ids(targetSample.getTargetLength().stream().map(TargetLength::getSpecies)); // mark catch if there is associated samples to it dtoList.forEach(catchDto -> { - SpeciesReference species = catchDto.get(KeptTargetCatchDto.PROPERTY_SPECIES); + SpeciesReference species = catchDto.getSpecies(); + boolean hasSample = speciesId.contains(species.getId()); + catchDto.set(KeptTargetCatchDto.PROPERTY_HAS_SAMPLE, hasSample); + }); + } + } + + private void toSetDiscardedTargetCatchDto(ReferentialLocale referentialLocale, SetDiscardedTargetCatchDto dto) { + super.toDto(referentialLocale, dto); + List<DiscardedTargetCatchDto> dtoList = EntityHelper.toDataDtoList(referentialLocale, getTargetCatch(true), DiscardedTargetCatchDto.class); + dto.setTargetCatch(dtoList); + // is there some sample? + TargetSample targetSample = getTargetSample(true); + if (targetSample != null) { + // get usable species ids + java.util.Set<String> speciesId = DtoReferenceAware.ids(targetSample.getTargetLength().stream().map(TargetLength::getSpecies)); + // mark catch if there is associated samples to it + dtoList.forEach(catchDto -> { + SpeciesReference species = catchDto.getSpecies(); boolean hasSample = speciesId.contains(species.getId()); catchDto.set(KeptTargetCatchDto.PROPERTY_HAS_SAMPLE, hasSample); }); @@ -297,19 +313,33 @@ public class SetImpl extends SetAbstract { } } - private <D extends DataDto> void fromSetTargetCatchDto(boolean discarded, ReferentialLocale referentialLocale, D dto) { + private void fromSetKeptTargetCatchDto(ReferentialLocale referentialLocale, SetKeptTargetCatchDto dto) { + // keep other catches + List<TargetCatch> otherTargetCatches = getTargetCatch(true); + // do normal copy + super.fromDto(referentialLocale, dto); + // delete any sample which not using the given species ids + TargetSample targetSample = getTargetSample(false); + if (targetSample != null) { + List<KeptTargetCatchDto> targetCatch = dto.getTargetCatch(); + Set<String> speciesIds = DtoReferenceAware.ids(targetCatch.stream().map(KeptTargetCatchDto::getSpecies)); + // remove sample from species ids + targetSample.getTargetLength().removeIf(targetLength -> !speciesIds.contains(targetLength.getSpecies().getTopiaId())); + } + // push back other catches + otherTargetCatches.forEach(this::addTargetCatch); + } + + private void fromSetDiscardedTargetCatchDto(ReferentialLocale referentialLocale, SetDiscardedTargetCatchDto dto) { // keep other catches - List<TargetCatch> otherTargetCatches = getTargetCatch(!discarded); + List<TargetCatch> otherTargetCatches = getTargetCatch(false); // do normal copy super.fromDto(referentialLocale, dto); - List<TargetCatch> newCatches = getTargetCatch(discarded); - // set back set in any catches - newCatches.forEach(t -> t.setSet(this)); // delete any sample which not using the given species ids - TargetSample targetSample = getTargetSample(discarded); + TargetSample targetSample = getTargetSample(true); if (targetSample != null) { - Collection<? extends IdDto> targetCatch = dto.get("targetCatch"); - Set<String> speciesIds = DtoReferenceAware.ids(targetCatch.stream().map(t -> t.get("species"))); + List<DiscardedTargetCatchDto> targetCatch = dto.getTargetCatch(); + Set<String> speciesIds = DtoReferenceAware.ids(targetCatch.stream().map(DiscardedTargetCatchDto::getSpecies)); // remove sample from species ids targetSample.getTargetLength().removeIf(targetLength -> !speciesIds.contains(targetLength.getSpecies().getTopiaId())); } ===================================== models/persistence/src/main/models/Observe-20-data-ps-observation.model ===================================== @@ -181,22 +181,20 @@ setEndSetTime(endSetTime Date) getEndPursingTime() Date setEndPursingTime(endPursingTime Date) -data.ps.observation.TargetCatch > data.DataEntity | naturalIdMutable entity +data.ps.observation.TargetCatch > data.DataEntity | entity comment + {*:1} String | hibernateAttributeType=text catchWeight + {*:1} Float | sqlType=numeric -well + {*:1} String | naturalId notNull=false +well + {*:1} String broughtOnDeck + {*:1} Boolean -discarded + {*:1} boolean | naturalId -set {*:1} data.ps.observation.Set | naturalId inverse skipModelNavigation -weightCategory {*:1} referential.ps.observation.WeightCategory | naturalId -reasonForDiscard {*:0..1} referential.ps.observation.ReasonForDiscard | naturalId notNull=false +discarded + {*:1} boolean +weightCategory {*:1} referential.ps.observation.WeightCategory +reasonForDiscard {*:0..1} referential.ps.observation.ReasonForDiscard weightMeasureMethod {*:0..1} referential.common.WeightMeasureMethod getSpecies() referential.common.Species setSpecies(species referential.common.Species) isKept() boolean isUsableForSample() boolean - data.ps.observation.TargetLength > data.DataEntity >> data.ps.observation.LengthWeightComputableAware | entity constants=totalWeight length + {*:1} Float | sqlType=numeric isLengthComputed + {*:1} boolean ===================================== models/persistence/src/main/resources/db/migration/8.0/50_ps_observation_create-common.sql ===================================== @@ -33,7 +33,7 @@ CREATE TABLE ps_observation.reasonfornullset(topiaId VARCHAR(255) NOT NULL CONST CREATE TABLE ps_observation.set(topiaId VARCHAR(255) NOT NULL CONSTRAINT pk_ps_observation_set PRIMARY KEY, topiaVersion BIGINT NOT NULL, topiaCreateDate TIMESTAMP NOT NULL, starttime TIME, endpursingtimestamp TIMESTAMP, endsettimestamp TIMESTAMP, maxgeardepth INTEGER, currentspeed NUMERIC, currentdirection INTEGER, schooltopdepth INTEGER, schoolmeandepth INTEGER, schoolthickness INTEGER, supportvesselname VARCHAR(255), comment VARCHAR(1025), schooltype VARCHAR(255), currentmeasuredepth INTEGER, reasonfornullset VARCHAR(255), lastUpdateDate TIMESTAMP DEFAULT now() NOT NULL, targetcatchcompositionestimatedbyobserver BOOLEAN DEFAULT FALSE, targetdiscardcatchcompositionestimatedbyobserver BOOLEAN DEFAULT FALSE, homeId VARCHAR(255)); CREATE TABLE ps_observation.nontargetcatchrelease(topiaId VARCHAR(255) NOT NULL CONSTRAINT pk_ps_observation_non_target_catch_release PRIMARY KEY, topiaVersion BIGINT NOT NULL, topiaCreateDate TIMESTAMP NOT NULL, lastUpdateDate TIMESTAMP NOT NULL, length NUMERIC, count INTEGER, acquisitionmode INTEGER, comment VARCHAR(1025), species VARCHAR(255), sex VARCHAR(255), speciesgroupreleasemode VARCHAR(255), set VARCHAR(255), set_idx INTEGER, status VARCHAR(255) NOT NULL, conformity VARCHAR(255), releasingtime VARCHAR(255), lengthmeasuremethod VARCHAR(255), homeId VARCHAR(255)); CREATE TABLE ps_observation.nontargetsample(topiaId VARCHAR(255) NOT NULL CONSTRAINT pk_ps_observation_nontargetsample PRIMARY KEY, topiaVersion BIGINT NOT NULL, topiaCreateDate TIMESTAMP NOT NULL, comment VARCHAR(1025), set VARCHAR(255), lastUpdateDate TIMESTAMP DEFAULT now() NOT NULL, homeId VARCHAR(255)); -CREATE TABLE ps_observation.schoolestimate(topiaId VARCHAR(255) NOT NULL CONSTRAINT pk_ps_observation_schoolestimate PRIMARY KEY, topiaVersion BIGINT NOT NULL, set VARCHAR(255) NOT NULL, species VARCHAR(255) NOT NULL, topiaCreateDate TIMESTAMP NOT NULL, totalweight INTEGER, meanweight INTEGER, lastUpdateDate TIMESTAMP DEFAULT now() NOT NULL, weightmeasuremethod VARCHAR(255), CONSTRAINT uk_schoolestimate_species_set unique(species, set), homeId VARCHAR(255)); +CREATE TABLE ps_observation.schoolestimate(topiaId VARCHAR(255) NOT NULL CONSTRAINT pk_ps_observation_schoolestimate PRIMARY KEY, topiaVersion BIGINT NOT NULL, set VARCHAR(255), species VARCHAR(255) NOT NULL, topiaCreateDate TIMESTAMP NOT NULL, totalweight INTEGER, meanweight INTEGER, lastUpdateDate TIMESTAMP DEFAULT now() NOT NULL, weightmeasuremethod VARCHAR(255), CONSTRAINT uk_schoolestimate_species_set unique(species, set), homeId VARCHAR(255)); CREATE TABLE ps_observation.nontargetcatch(topiaId VARCHAR(255) NOT NULL CONSTRAINT pk_ps_observation_nontargetcatch PRIMARY KEY, topiaVersion BIGINT NOT NULL, topiaCreateDate TIMESTAMP NOT NULL, catchweight NUMERIC, catchweightcomputedsource INTEGER, meanweight NUMERIC, meanweightcomputedsource INTEGER, meanlength NUMERIC, meanlengthcomputedsource INTEGER, totalcount INTEGER, totalcountcomputedsource INTEGER, comment VARCHAR(1025), reasonfordiscard VARCHAR(255), species VARCHAR(255), speciesfate VARCHAR(255), set VARCHAR(255), lastUpdateDate TIMESTAMP DEFAULT now() NOT NULL, well VARCHAR(255), set_idx INTEGER, lengthmeasuremethod VARCHAR(255), weightmeasuremethod VARCHAR(255), homeId VARCHAR(255)); CREATE TABLE ps_observation.nontargetlength(topiaId VARCHAR(255) NOT NULL CONSTRAINT pk_ps_observation_nontargetlength PRIMARY KEY, topiaVersion BIGINT NOT NULL, topiaCreateDate TIMESTAMP NOT NULL, length NUMERIC, islengthcomputed BOOLEAN, picturesreferences VARCHAR(255), weight NUMERIC, isweightcomputed BOOLEAN, count INTEGER, acquisitionmode INTEGER, species VARCHAR(255), nontargetsample VARCHAR(255), sex VARCHAR(255), lastUpdateDate TIMESTAMP DEFAULT now() NOT NULL, sizemeasuretype VARCHAR(255), weightmeasuretype VARCHAR(255), tagnumber VARCHAR(255), speciesfate VARCHAR(255), nontargetsample_idx INTEGER, lengthmeasuremethod VARCHAR(255), weightmeasuremethod VARCHAR(255), homeId VARCHAR(255)); CREATE TABLE ps_observation.speciesstatus(topiaId VARCHAR(255) NOT NULL CONSTRAINT pk_ps_observation_speciesstatus PRIMARY KEY, topiaVersion BIGINT NOT NULL, topiaCreateDate TIMESTAMP NOT NULL, code VARCHAR(255), uri VARCHAR(255), status INTEGER DEFAULT 1, label1 VARCHAR(255), label2 VARCHAR(255), label3 VARCHAR(255), label4 VARCHAR(255), label5 VARCHAR(255), label6 VARCHAR(255), label7 VARCHAR(255), label8 VARCHAR(255), needComment BOOLEAN DEFAULT FALSE, lastUpdateDate TIMESTAMP DEFAULT now() NOT NULL, homeId VARCHAR(255)); @@ -48,5 +48,5 @@ CREATE TABLE ps_observation.objectobservedspecies(topiaId VARCHAR(255) NOT NULL CREATE TABLE ps_observation.objectschoolestimate(topiaId VARCHAR(255) NOT NULL CONSTRAINT pk_ps_observation_objectschoolestimate PRIMARY KEY, topiaVersion BIGINT NOT NULL, topiaCreateDate TIMESTAMP NOT NULL, totalweight INTEGER, species VARCHAR(255), floatingobject VARCHAR(255), lastUpdateDate TIMESTAMP DEFAULT now() NOT NULL, weightmeasuremethod VARCHAR(255), homeId VARCHAR(255)); CREATE TABLE ps_observation.transmittingbuoy(topiaId VARCHAR(255) NOT NULL CONSTRAINT pk_ps_observation_transmittingbuoy PRIMARY KEY, topiaVersion BIGINT NOT NULL, topiaCreateDate TIMESTAMP NOT NULL, code VARCHAR(255), comment VARCHAR(1024), transmittingBuoyOwnership VARCHAR(255), transmittingbuoytype VARCHAR(255), transmittingbuoyoperation VARCHAR(255), floatingobject VARCHAR(255), country VARCHAR(255), vessel VARCHAR(255), lastUpdateDate TIMESTAMP DEFAULT now() NOT NULL, homeId VARCHAR(255)); CREATE TABLE ps_observation.weightcategory(topiaId VARCHAR(255) NOT NULL CONSTRAINT pk_ps_observation_weightcategory PRIMARY KEY, topiaVersion BIGINT NOT NULL, topiaCreateDate TIMESTAMP NOT NULL, code VARCHAR(255), uri VARCHAR(255), status INTEGER DEFAULT 1, label1 VARCHAR(255), label2 VARCHAR(255), label3 VARCHAR(255), label4 VARCHAR(255), label5 VARCHAR(255), label6 VARCHAR(255), label7 VARCHAR(255), label8 VARCHAR(255), species VARCHAR(255), needComment BOOLEAN DEFAULT FALSE, lastUpdateDate TIMESTAMP DEFAULT now() NOT NULL, homeId VARCHAR(255)); -CREATE TABLE ps_observation.targetcatch(topiaId VARCHAR(255) NOT NULL CONSTRAINT pk_ps_observation_targetcatch PRIMARY KEY, topiaVersion BIGINT NOT NULL, well VARCHAR(255), discarded BOOLEAN NOT NULL, set VARCHAR(255) NOT NULL, weightcategory VARCHAR(255) NOT NULL, reasonfordiscard VARCHAR(255), topiaCreateDate TIMESTAMP NOT NULL, catchweight NUMERIC, broughtondeck BOOLEAN, comment VARCHAR(1025), lastUpdateDate TIMESTAMP DEFAULT now() NOT NULL, set_idx INTEGER, weightmeasuremethod VARCHAR(255), CONSTRAINT uk_targetcatch_well_reasonfordiscard_weightcategory_discarded_s unique(well, reasonfordiscard, weightcategory, discarded, set), homeId VARCHAR(255)); +CREATE TABLE ps_observation.targetcatch(topiaId VARCHAR(255) NOT NULL CONSTRAINT pk_ps_observation_targetcatch PRIMARY KEY, topiaVersion BIGINT NOT NULL, well VARCHAR(255), discarded BOOLEAN NOT NULL, set VARCHAR(255), weightcategory VARCHAR(255) NOT NULL, reasonfordiscard VARCHAR(255), topiaCreateDate TIMESTAMP NOT NULL, catchweight NUMERIC, broughtondeck BOOLEAN, comment VARCHAR(1025), lastUpdateDate TIMESTAMP DEFAULT now() NOT NULL, set_idx INTEGER, weightmeasuremethod VARCHAR(255), CONSTRAINT uk_targetcatch_well_reasonfordiscard_weightcategory_discarded_s unique(well, reasonfordiscard, weightcategory, discarded, set), homeId VARCHAR(255)); CREATE TABLE ps_observation.activity_observedsystem(activity VARCHAR(255) NOT NULL, observedsystem VARCHAR(255) NOT NULL, CONSTRAINT pk_ps_observation_activity_observedsystem PRIMARY KEY(activity, observedsystem)); ===================================== services/api/src/main/java/fr/ird/observe/services/service/actions/synchro/referential/ng/task/ReferentialSynchronizeTaskType.java ===================================== @@ -30,27 +30,21 @@ package fr.ird.observe.services.service.actions.synchro.referential.ng.task; */ public enum ReferentialSynchronizeTaskType { - ADD(false, false, true), - UPDATE(false, true, true), - REVERT(false, true, false), - DELETE(true, false, false), - DEACTIVATE(false, false, false), - DEACTIVATE_WITH_REPLACEMENT(true, false, false); + ADD(false, true), + UPDATE(true, true), + REVERT(true, false), + DELETE(false, false), + DEACTIVATE(false, false), + DEACTIVATE_WITH_REPLACEMENT(false, false); - private final boolean withReplace; private final boolean withProperties; private final boolean toOtherSide; - ReferentialSynchronizeTaskType(boolean withReplace, boolean withProperties, boolean toOtherSide) { - this.withReplace = withReplace; + ReferentialSynchronizeTaskType(boolean withProperties, boolean toOtherSide) { this.withProperties = withProperties; this.toOtherSide = toOtherSide; } - public boolean withReplace() { - return withReplace; - } - public boolean withProperties() { return withProperties; } ===================================== tests/test/src/main/resources/db/8.0/dataForTestLongline.sql.gz ===================================== Binary files a/tests/test/src/main/resources/db/8.0/dataForTestLongline.sql.gz and b/tests/test/src/main/resources/db/8.0/dataForTestLongline.sql.gz differ ===================================== tests/test/src/main/resources/db/8.0/dataForTestSeine.sql.gz ===================================== Binary files a/tests/test/src/main/resources/db/8.0/dataForTestSeine.sql.gz and b/tests/test/src/main/resources/db/8.0/dataForTestSeine.sql.gz differ ===================================== tests/test/src/main/resources/db/8.0/empty_h2.sql.gz ===================================== Binary files a/tests/test/src/main/resources/db/8.0/empty_h2.sql.gz and b/tests/test/src/main/resources/db/8.0/empty_h2.sql.gz differ ===================================== tests/test/src/main/resources/db/8.0/empty_pg.sql.gz ===================================== Binary files a/tests/test/src/main/resources/db/8.0/empty_pg.sql.gz and b/tests/test/src/main/resources/db/8.0/empty_pg.sql.gz differ ===================================== tests/test/src/main/resources/db/8.0/referentiel.sql.gz ===================================== Binary files a/tests/test/src/main/resources/db/8.0/referentiel.sql.gz and b/tests/test/src/main/resources/db/8.0/referentiel.sql.gz differ View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/41b33c60a9516846f415c155d... -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/41b33c60a9516846f415c155d... You're receiving this email because of your account on gitlab.com.
participants (1)
-
Tony CHEMIT