Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
312eba06
by Tony Chemit at 2022-03-01T17:42:55+01:00
-
7cfc0e6e
by Tony Chemit at 2022-03-02T08:51:34+01:00
-
faffe51b
by Tony Chemit at 2022-03-02T09:05:17+01:00
-
71e82f1c
by Tony Chemit at 2022-03-02T10:09:10+01:00
-
0508f6fb
by Tony Chemit at 2022-03-02T10:09:38+01:00
-
93eaf835
by Tony Chemit at 2022-03-02T10:36:31+01:00
-
4e494512
by Tony Chemit at 2022-03-02T11:15:53+01:00
25 changed files:
- client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/config/SelectDataModel.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/config/TreeConfigUI.jaxx
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/config/TreeConfigUI.jcss
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/config/TreeConfigUIModel.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/config/actions/ApplyConfigurationSupport.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/config/actions/ApplyNavigationConfiguration.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/config/actions/ApplySelectionConfiguration.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/navigation/NavigationUIHandler.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/navigation/tree/root/RootNavigationNode.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/navigation/tree/select/SelectNodesByModelNode.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/navigation/tree/select/SelectNodesByPath.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/wizard/tabs/SelectDataUIHandler.java
- client/runner/src/main/i18n/translations/client-runner_en_GB.properties
- client/runner/src/main/i18n/translations/client-runner_es_ES.properties
- client/runner/src/main/i18n/translations/client-runner_fr_FR.properties
- core/api/tree/src/test/resources/navigationTree.json
- core/persistence/resources/src/main/java/fr/ird/observe/spi/migration/v8/DataSourceMigrationForVersion_8_0.java
- − core/persistence/resources/src/main/resources/db/migration/v8/8.0/30_add_referential_common_Program_50-common.sql
- core/persistence/test/src/test/java/fr/ird/observe/persistence/test/SqlServiceTest.java
- core/persistence/test/src/test/resources/fixtures/persistence/table_count/referential.properties
- core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/NavigationService.properties
- core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReferenceService.properties
- core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ValidateService-referentialResult.json
- core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/referential/ReferentialService.properties
- model/src/main/resources/fixtures/global.properties
Changes:
| ... | ... | @@ -29,6 +29,7 @@ import fr.ird.observe.client.datasource.actions.validate.ValidateModel; |
| 29 | 29 | import fr.ird.observe.client.datasource.api.ObserveSwingDataSource;
|
| 30 | 30 | import fr.ird.observe.client.datasource.editor.api.selection.SelectionTreePane;
|
| 31 | 31 | import fr.ird.observe.client.datasource.editor.api.selection.SelectionTreePaneHandler;
|
| 32 | +import fr.ird.observe.navigation.id.Project;
|
|
| 32 | 33 | import fr.ird.observe.navigation.tree.selection.SelectionTreeConfig;
|
| 33 | 34 | import fr.ird.observe.navigation.tree.selection.SelectionTreeModel;
|
| 34 | 35 | import org.apache.logging.log4j.LogManager;
|
| ... | ... | @@ -157,8 +158,11 @@ public class SelectDataModel extends AdminActionModel { |
| 157 | 158 | newConfig.setLoadDisabledGroupBy(true);
|
| 158 | 159 | |
| 159 | 160 | config.init(newConfig);
|
| 160 | - List<String> openIds = getClientConfig().getNavigationEditModel().getIds();
|
|
| 161 | - selectionDataModel.setEditIds(openIds);
|
|
| 161 | + Project navigationEditModel = getClientConfig().getNavigationEditModel();
|
|
| 162 | + if (navigationEditModel!=null) {
|
|
| 163 | + List<String> openIds = navigationEditModel.getIds();
|
|
| 164 | + selectionDataModel.setEditIds(openIds);
|
|
| 165 | + }
|
|
| 162 | 166 | } else {
|
| 163 | 167 | config.setLoadData(loadData);
|
| 164 | 168 | config.setLoadReferential(loadReferential);
|
| ... | ... | @@ -66,25 +66,12 @@ |
| 66 | 66 | </JPanel>
|
| 67 | 67 | <JPanel id='actionsPane' layout="{new BoxLayout(actionsPane, BoxLayout.LINE_AXIS)}">
|
| 68 | 68 | <Component initializer="Box.createHorizontalGlue()"/>
|
| 69 | - <JButton id="resetConfiguration" styleClass="enabledIfModified"/>
|
|
| 69 | + <JButton id="resetConfiguration"/>
|
|
| 70 | 70 | <Component initializer="Box.createRigidArea(new Dimension(10, 0))"/>
|
| 71 | - <JButton id="applyConfiguration" styleClass="enabledIfModified"/>
|
|
| 71 | + <JButton id="applyConfiguration"/>
|
|
| 72 | 72 | </JPanel>
|
| 73 | 73 | </JPanel>
|
| 74 | 74 | </cell>
|
| 75 | 75 | </row>
|
| 76 | 76 | </Table>
|
| 77 | -<!-- <JPanel id='actions' constraints='BorderLayout.SOUTH' layout="{new BoxLayout(actions, BoxLayout.Y_AXIS)}">-->
|
|
| 78 | -<!-- <JPanel id="cancelMessagePanel" layout="{new GridLayout(0, 1)}">-->
|
|
| 79 | -<!-- <JSeparator constructorParams="JSeparator.HORIZONTAL"/>-->
|
|
| 80 | -<!-- <JLabel id="cancelMessage" styleClass="information italic"/>-->
|
|
| 81 | -<!-- <Component initializer="Box.createRigidArea(new Dimension(10, 5))"/>-->
|
|
| 82 | -<!-- </JPanel>-->
|
|
| 83 | -<!-- <JPanel id='actionsPane' layout="{new BoxLayout(actionsPane, BoxLayout.LINE_AXIS)}">-->
|
|
| 84 | -<!-- <Component initializer="Box.createHorizontalGlue()"/>-->
|
|
| 85 | -<!-- <JButton id="resetConfiguration" styleClass="enabledIfModified"/>-->
|
|
| 86 | -<!-- <Component initializer="Box.createRigidArea(new Dimension(10, 0))"/>-->
|
|
| 87 | -<!-- <JButton id="applyConfiguration" styleClass="enabledIfModified"/>-->
|
|
| 88 | -<!-- </JPanel>-->
|
|
| 89 | -<!-- </JPanel>-->
|
|
| 90 | 77 | </JPanel> |
| ... | ... | @@ -30,28 +30,28 @@ |
| 30 | 30 | |
| 31 | 31 | #optionPanel {
|
| 32 | 32 | border:{BorderFactory.createTitledBorder(BorderFactory.createLoweredBevelBorder(), I18n.t("observe.ui.datasource.tree.config.option") + " ")};
|
| 33 | - /*border:{BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.BLACK, 1, true), I18n.t("observe.ui.datasource.tree.config.option") + " ")};*/
|
|
| 34 | 33 | }
|
| 35 | 34 | |
| 36 | 35 | #moduleChoose {
|
| 37 | 36 | border:{BorderFactory.createTitledBorder(BorderFactory.createLoweredBevelBorder(), I18n.t("observe.Common.navigation.config.moduleName") + " ")};
|
| 38 | - /*border:{BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.BLACK, 1, true), I18n.t("observe.Common.navigation.config.moduleName") + " ")};*/
|
|
| 39 | 37 | }
|
| 40 | 38 | |
| 41 | 39 | #groupByChoose {
|
| 42 | 40 | border:{BorderFactory.createTitledBorder(BorderFactory.createLoweredBevelBorder(), I18n.t("observe.Common.navigation.config.groupByName") + " ")};
|
| 43 | - /*border:{BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.BLACK, 1, true), I18n.t("observe.Common.navigation.config.groupByName") + " ")};*/
|
|
| 44 | 41 | }
|
| 45 | 42 | |
| 46 | 43 | #groupByOptionsChoose {
|
| 47 | 44 | border:{BorderFactory.createTitledBorder(BorderFactory.createLoweredBevelBorder(), I18n.t("observe.Common.navigation.config.groupByOption") + " ")};
|
| 48 | - /*border:{BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.BLACK, 1, true), I18n.t("observe.Common.navigation.config.groupByOption") + " ")};*/
|
|
| 49 | 45 | }
|
| 50 | 46 | |
| 51 | -.enabledIfModified {
|
|
| 47 | +#resetConfiguration {
|
|
| 52 | 48 | enabled:{model.isModified()};
|
| 53 | 49 | }
|
| 54 | 50 | |
| 51 | +#applyConfiguration {
|
|
| 52 | + enabled:{model.isModified() && !model.isEmpty()};
|
|
| 53 | +}
|
|
| 54 | + |
|
| 55 | 55 | #actionsPane {
|
| 56 | 56 | border:{BorderFactory.createEmptyBorder(0, 5, 5, 5)};
|
| 57 | 57 | }
|
| ... | ... | @@ -42,8 +42,9 @@ import java.util.List; |
| 42 | 42 | @GenerateJavaBeanDefinition
|
| 43 | 43 | public class TreeConfigUIModel extends AbstractJavaBean implements PropertyChangeListener {
|
| 44 | 44 | public static final String MODIFIED = "modified";
|
| 45 | + public static final String EMPTY = "empty";
|
|
| 45 | 46 | /**
|
| 46 | - * Properties to monitor on application tree config.
|
|
| 47 | + * Properties to monitor on application tree config to fire modified property..
|
|
| 47 | 48 | */
|
| 48 | 49 | private static final List<String> MONITORED_PROPERTIES = List.of(
|
| 49 | 50 | TreeConfig.LOAD_DATA,
|
| ... | ... | @@ -55,12 +56,27 @@ public class TreeConfigUIModel extends AbstractJavaBean implements PropertyChang |
| 55 | 56 | TreeConfig.GROUP_BY_NAME,
|
| 56 | 57 | TreeConfig.GROUP_BY_FLAVOR,
|
| 57 | 58 | TreeConfig.MODULE_NAME);
|
| 58 | - private final TreeConfig originalBean;
|
|
| 59 | - private final TreeConfig bean;
|
|
| 59 | + /**
|
|
| 60 | + * Properties to monitor to fire empty property.
|
|
| 61 | + */
|
|
| 62 | + private static final List<String> EMPTY_PROPERTIES = List.of(
|
|
| 63 | + TreeConfig.LOAD_DATA,
|
|
| 64 | + TreeConfig.LOAD_REFERENTIAL);
|
|
| 60 | 65 | /**
|
| 61 | 66 | * Monitor to see if there is something modified in application config.
|
| 62 | 67 | */
|
| 63 | 68 | private final BeanMonitor monitor;
|
| 69 | + /**
|
|
| 70 | + * Original bean (will never modify it).
|
|
| 71 | + */
|
|
| 72 | + private final TreeConfig originalBean;
|
|
| 73 | + /**
|
|
| 74 | + * Then bean used in ui.
|
|
| 75 | + */
|
|
| 76 | + private final TreeConfig bean;
|
|
| 77 | + /**
|
|
| 78 | + * GroupBy helper.
|
|
| 79 | + */
|
|
| 64 | 80 | private final GroupByHelper groupByHelper;
|
| 65 | 81 | |
| 66 | 82 | protected TreeConfigUIModel(GroupByHelper groupByHelper, TreeConfig originalBean) {
|
| ... | ... | @@ -80,17 +96,21 @@ public class TreeConfigUIModel extends AbstractJavaBean implements PropertyChang |
| 80 | 96 | |
| 81 | 97 | @Override
|
| 82 | 98 | public void propertyChange(PropertyChangeEvent evt) {
|
| 83 | - if (MONITORED_PROPERTIES.contains(evt.getPropertyName())) {
|
|
| 99 | + String propertyName = evt.getPropertyName();
|
|
| 100 | + if (MONITORED_PROPERTIES.contains(propertyName)) {
|
|
| 84 | 101 | fireModified();
|
| 102 | + if (EMPTY_PROPERTIES.contains(propertyName)) {
|
|
| 103 | + fireEmpty();
|
|
| 104 | + }
|
|
| 85 | 105 | }
|
| 86 | 106 | }
|
| 87 | 107 | |
| 88 | - public List<String> getModifiedProperties() {
|
|
| 89 | - return List.of(monitor.getModifiedProperties());
|
|
| 108 | + public boolean isEmpty() {
|
|
| 109 | + return !bean.isLoadData() && !bean.isLoadReferential();
|
|
| 90 | 110 | }
|
| 91 | 111 | |
| 92 | - private void fireModified() {
|
|
| 93 | - firePropertyChange(MODIFIED, isModified());
|
|
| 112 | + public boolean isModified() {
|
|
| 113 | + return monitor.wasModified();
|
|
| 94 | 114 | }
|
| 95 | 115 | |
| 96 | 116 | public void reset() {
|
| ... | ... | @@ -108,6 +128,27 @@ public class TreeConfigUIModel extends AbstractJavaBean implements PropertyChang |
| 108 | 128 | bean.addPropertyChangeListener(this);
|
| 109 | 129 | }
|
| 110 | 130 | |
| 131 | + /**
|
|
| 132 | + * @return {@code true} if structure changed, means we won't be able to reselect previous node, {@code false} otherwise.
|
|
| 133 | + */
|
|
| 134 | + public boolean isStructureChanged() {
|
|
| 135 | + List<String> modifiedProperties = List.of(monitor.getModifiedProperties());
|
|
| 136 | + if( modifiedProperties.contains(TreeConfig.LOAD_DATA)) {
|
|
| 137 | + // loadData is now off
|
|
| 138 | + return !bean.isLoadData();
|
|
| 139 | + }
|
|
| 140 | + if( modifiedProperties.contains(TreeConfig.LOAD_REFERENTIAL)) {
|
|
| 141 | + // loadReferential is now off
|
|
| 142 | + return !bean.isLoadReferential();
|
|
| 143 | + }
|
|
| 144 | + if( modifiedProperties.contains(TreeConfig.MODULE_NAME)) {
|
|
| 145 | + // previous module name is off
|
|
| 146 | + return true;
|
|
| 147 | + }
|
|
| 148 | + // changing any other property won't affect structure
|
|
| 149 | + return false;
|
|
| 150 | + }
|
|
| 151 | + |
|
| 111 | 152 | public void close(boolean flush) {
|
| 112 | 153 | if (flush) {
|
| 113 | 154 | for (PropertyDiff propertyDiff : monitor.getPropertyDiffs()) {
|
| ... | ... | @@ -118,15 +159,15 @@ public class TreeConfigUIModel extends AbstractJavaBean implements PropertyChang |
| 118 | 159 | bean.removePropertyChangeListener(this);
|
| 119 | 160 | }
|
| 120 | 161 | |
| 121 | - public boolean isModified() {
|
|
| 122 | - return monitor.wasModified();
|
|
| 162 | + public List<String> getGroupByOptionNames(String groupByName) {
|
|
| 163 | + return groupByHelper.getGroupByOptionNames(groupByName);
|
|
| 123 | 164 | }
|
| 124 | 165 | |
| 125 | - public List<String> getGroupByNames(String moduleName) {
|
|
| 126 | - return groupByHelper.getGroupByNames(moduleName);
|
|
| 166 | + private void fireModified() {
|
|
| 167 | + firePropertyChange(MODIFIED, isModified());
|
|
| 127 | 168 | }
|
| 128 | 169 | |
| 129 | - public List<String> getGroupByOptionNames(String groupByName) {
|
|
| 130 | - return groupByHelper.getGroupByOptionNames(groupByName);
|
|
| 170 | + private void fireEmpty() {
|
|
| 171 | + firePropertyChange(EMPTY, isEmpty());
|
|
| 131 | 172 | }
|
| 132 | 173 | } |
| ... | ... | @@ -65,11 +65,12 @@ public abstract class ApplyConfigurationSupport extends TreeConfigUIActionSuppor |
| 65 | 65 | |
| 66 | 66 | protected final void doActionPerformed(TreeConfigUI ui) {
|
| 67 | 67 | TreeConfigUIModel model = ui.getModel();
|
| 68 | + boolean canReselectNode = !model.isStructureChanged();
|
|
| 68 | 69 | model.close(true);
|
| 69 | 70 | saveConfiguration(model.getOriginalBean());
|
| 70 | 71 | addSimpleAction(t("observe.ui.tree.reload"), () -> {
|
| 71 | 72 | long t0 = System.nanoTime();
|
| 72 | - applyConsumer(ui);
|
|
| 73 | + applyConsumer(ui, canReselectNode);
|
|
| 73 | 74 | setUiStatus(t("observe.ui.tree.loaded", Strings.convertTime(System.nanoTime() - t0)));
|
| 74 | 75 | });
|
| 75 | 76 | }
|
| ... | ... | @@ -80,7 +81,7 @@ public abstract class ApplyConfigurationSupport extends TreeConfigUIActionSuppor |
| 80 | 81 | |
| 81 | 82 | protected abstract void saveConfiguration(TreeConfig originalConfig);
|
| 82 | 83 | |
| 83 | - protected abstract void applyConsumer(TreeConfigUI ui);
|
|
| 84 | + protected abstract void applyConsumer(TreeConfigUI ui, boolean canReselectNode);
|
|
| 84 | 85 | |
| 85 | 86 | private void atTheEnd(TreeConfigUI ui) {
|
| 86 | 87 | ui.getComponentPopupMenu().setVisible(false);
|
| ... | ... | @@ -93,7 +93,7 @@ public class ApplyNavigationConfiguration extends ApplyConfigurationSupport { |
| 93 | 93 | }
|
| 94 | 94 | |
| 95 | 95 | @Override
|
| 96 | - protected void applyConsumer(TreeConfigUI ui) {
|
|
| 96 | + protected void applyConsumer(TreeConfigUI ui, boolean canReselectNode) {
|
|
| 97 | 97 | NavigationTree tree = tree(ui);
|
| 98 | 98 | NavigationNode selectedNode = selectedNode(ui);
|
| 99 | 99 | String[] paths = selectedNode == null ? null : selectedNode.toPaths();
|
| ... | ... | @@ -101,7 +101,12 @@ public class ApplyNavigationConfiguration extends ApplyConfigurationSupport { |
| 101 | 101 | tree.populate(null);
|
| 102 | 102 | NavigationUIHandler.updateStatistics(navigationUI(ui));
|
| 103 | 103 | } finally {
|
| 104 | - SwingUtilities.invokeLater(() -> tree.reselectInitialNode(paths));
|
|
| 104 | + if (canReselectNode) {
|
|
| 105 | + SwingUtilities.invokeLater(() -> tree.reselectInitialNode(paths));
|
|
| 106 | + } else {
|
|
| 107 | + //FIXME We could find out if we can still select something, meanwhile first node is also fair
|
|
| 108 | + SwingUtilities.invokeLater(tree::selectFirstNode);
|
|
| 109 | + }
|
|
| 105 | 110 | }
|
| 106 | 111 | }
|
| 107 | 112 | } |
| ... | ... | @@ -49,7 +49,7 @@ public class ApplySelectionConfiguration extends ApplyConfigurationSupport { |
| 49 | 49 | }
|
| 50 | 50 | |
| 51 | 51 | @Override
|
| 52 | - protected void applyConsumer(TreeConfigUI ui) {
|
|
| 52 | + protected void applyConsumer(TreeConfigUI ui, boolean canReselectNode) {
|
|
| 53 | 53 | consumer.accept(ui);
|
| 54 | 54 | }
|
| 55 | 55 |
| ... | ... | @@ -23,6 +23,7 @@ package fr.ird.observe.client.datasource.editor.api.navigation; |
| 23 | 23 | */
|
| 24 | 24 | |
| 25 | 25 | import fr.ird.observe.client.WithClientUIContextApi;
|
| 26 | +import fr.ird.observe.client.datasource.api.ObserveSwingDataSource;
|
|
| 26 | 27 | import fr.ird.observe.client.datasource.editor.api.DataSourceEditorModel;
|
| 27 | 28 | import fr.ird.observe.client.datasource.editor.api.config.TreeConfigUIHandler;
|
| 28 | 29 | import fr.ird.observe.client.datasource.editor.api.menu.DataSourceEditorMenuModel;
|
| ... | ... | @@ -80,6 +81,11 @@ public class NavigationUIHandler implements UIHandler<NavigationUI>, WithClientU |
| 80 | 81 | ui.getLabel().setText(menuModel.getStorageStatusText());
|
| 81 | 82 | ui.getLabel().setToolTipText(menuModel.getStorageStatusTip());
|
| 82 | 83 | ui.getLabel().setIcon(menuModel.getStorageStatusIcon());
|
| 84 | + ObserveSwingDataSource mainDataSource = getDataSourcesManager().getMainDataSource();
|
|
| 85 | + boolean mainStorageOpened = mainDataSource != null;
|
|
| 86 | + boolean mainStorageLocal = mainStorageOpened && mainDataSource.isLocal();
|
|
| 87 | + boolean mainStorageRemote = mainStorageOpened && mainDataSource.isRemote();
|
|
| 88 | + ui.getImportAvdthFile().setEnabled(mainStorageLocal || mainStorageRemote);
|
|
| 83 | 89 | }
|
| 84 | 90 | |
| 85 | 91 | public void updateActions(NavigationNode selectedNode) {
|
| ... | ... | @@ -33,6 +33,7 @@ import org.apache.logging.log4j.Logger; |
| 33 | 33 | |
| 34 | 34 | import java.awt.Font;
|
| 35 | 35 | import java.util.Objects;
|
| 36 | +import java.util.Set;
|
|
| 36 | 37 | |
| 37 | 38 | @AutoService(NavigationNode.class)
|
| 38 | 39 | public class RootNavigationNode extends NavigationNode {
|
| ... | ... | @@ -107,6 +108,10 @@ public class RootNavigationNode extends NavigationNode { |
| 107 | 108 | return getDataSourcesManager().getMainDataSource().getRootOpenableService().getGroupByValue(request.getGroupByName(), request.getGroupByFlavor(), dataId);
|
| 108 | 109 | }
|
| 109 | 110 | |
| 111 | + public boolean dataExists(String dataId) {
|
|
| 112 | + return !getDataSourcesManager().getMainDataSource().getDataSourceService().retainExistingIds(Set.of(dataId)).isEmpty();
|
|
| 113 | + }
|
|
| 114 | + |
|
| 110 | 115 | public NavigationNode findChildById(String id, boolean createIfEmpty) {
|
| 111 | 116 | NavigationNode result = super.findChildById(id);
|
| 112 | 117 | if (result == null && createIfEmpty) {
|
| ... | ... | @@ -142,30 +147,6 @@ public class RootNavigationNode extends NavigationNode { |
| 142 | 147 | return result;
|
| 143 | 148 | }
|
| 144 | 149 | |
| 145 | -// public NavigationNode findNodeFromPreviousSelectedNode(NavigationNode oldSelectedNode) {
|
|
| 146 | -// NavigationNode result = this;
|
|
| 147 | -// TreeNode[] pathToRoot = oldSelectedNode.getPath();
|
|
| 148 | -// for (TreeNode treeNode : pathToRoot) {
|
|
| 149 | -// NavigationNode next;
|
|
| 150 | -// NavigationNode oldNode = (NavigationNode) treeNode;
|
|
| 151 | -// if (oldNode.getLevel() == 0) {
|
|
| 152 | -// next = result;
|
|
| 153 | -// } else if (oldNode.getLevel() == 1) {
|
|
| 154 | -// // use the method which will not create node
|
|
| 155 | -// next = ((RootNavigationNode) result).findChildByTypeWithNoCreate(oldNode.getClass(), oldNode.getInitializer().getSelectNodeId());
|
|
| 156 | -// } else if (oldNode.getScope().isSelectNode()) {
|
|
| 157 | -// next = result.findChildByType(oldNode.getClass(), oldNode.getInitializer().getSelectNodeId());
|
|
| 158 | -// } else {
|
|
| 159 | -// next = result.findChildByType(oldNode.getClass());
|
|
| 160 | -// }
|
|
| 161 | -// if (next == null) {
|
|
| 162 | -// break;
|
|
| 163 | -// }
|
|
| 164 | -// result = next;
|
|
| 165 | -// }
|
|
| 166 | -// return result;
|
|
| 167 | -// }
|
|
| 168 | - |
|
| 169 | 150 | public void clear() {
|
| 170 | 151 | RootNavigationInitializer initializer = getInitializer();
|
| 171 | 152 | if (initializer == null) {
|
| ... | ... | @@ -47,7 +47,12 @@ public class SelectNodesByModelNode implements SelectNodeStrategy { |
| 47 | 47 | public static NavigationNode findFromRootNode(RootNavigationNode rootNode, IdNode<?> editNode) {
|
| 48 | 48 | // get root edit node
|
| 49 | 49 | IdNode<?> root = editNode.getRoot();
|
| 50 | - String groupByValue = rootNode.computeGroupByValue(root.getId());
|
|
| 50 | + String dataId = root.getId();
|
|
| 51 | + // check if data id exists on this source
|
|
| 52 | + if (!rootNode.dataExists(dataId)) {
|
|
| 53 | + return null;
|
|
| 54 | + }
|
|
| 55 | + String groupByValue = rootNode.computeGroupByValue(dataId);
|
|
| 51 | 56 | NavigationNode groupByNode = SelectNodesByPath.findChildByPath(rootNode, groupByValue);
|
| 52 | 57 | if (groupByNode == null || root.equals(editNode)) {
|
| 53 | 58 | return groupByNode;
|
| ... | ... | @@ -58,11 +58,18 @@ public class SelectNodesByPath implements SelectNodeStrategy { |
| 58 | 58 | // just try with given groupBy value
|
| 59 | 59 | return getNavigationNode(result, 0, path);
|
| 60 | 60 | }
|
| 61 | - |
|
| 61 | + if (!rootNode.getInitializer().getRequest().isLoadData()) {
|
|
| 62 | + // asking for a data node, but no data on this tree
|
|
| 63 | + return Optional.empty();
|
|
| 64 | + }
|
|
| 62 | 65 | if (checkGroupBy) {
|
| 63 | 66 | // need at least two entries in path (the groupBy value + data id)
|
| 64 | 67 | // if no data id can no find out new groupBy value...
|
| 65 | 68 | String dataId = path[1];
|
| 69 | + // check if data id exists on this source
|
|
| 70 | + if (!rootNode.dataExists(dataId)) {
|
|
| 71 | + return Optional.empty();
|
|
| 72 | + }
|
|
| 66 | 73 | String groupByValue = rootNode.computeGroupByValue(dataId);
|
| 67 | 74 | NavigationNode groupByNode = findChildByPath(result, groupByValue);
|
| 68 | 75 | if (groupByNode != null) {
|
| ... | ... | @@ -34,6 +34,7 @@ import fr.ird.observe.client.datasource.editor.api.wizard.ObstunaAdminAction; |
| 34 | 34 | import fr.ird.observe.client.datasource.editor.api.wizard.StorageUIModel;
|
| 35 | 35 | import fr.ird.observe.client.util.ObserveKeyStrokesSupport;
|
| 36 | 36 | import fr.ird.observe.client.util.ObserveSwingTechnicalException;
|
| 37 | +import fr.ird.observe.navigation.id.Project;
|
|
| 37 | 38 | import fr.ird.observe.navigation.tree.selection.SelectionTree;
|
| 38 | 39 | import fr.ird.observe.navigation.tree.selection.SelectionTreeConfig;
|
| 39 | 40 | import fr.ird.observe.navigation.tree.selection.SelectionTreeModel;
|
| ... | ... | @@ -66,8 +67,11 @@ public class SelectDataUIHandler extends StorageTabUIHandler<SelectDataUI> imple |
| 66 | 67 | SelectionTree tree = treePane.getTree();
|
| 67 | 68 | SelectionTreeModel treeModel = tree.getModel();
|
| 68 | 69 | if (init) {
|
| 69 | - List<String> openIds = context.getClientConfig().getNavigationEditModel().getIds();
|
|
| 70 | - treeModel.setEditIds(openIds);
|
|
| 70 | + Project navigationEditModel = context.getClientConfig().getNavigationEditModel();
|
|
| 71 | + if (navigationEditModel != null) {
|
|
| 72 | + List<String> openIds = navigationEditModel.getIds();
|
|
| 73 | + treeModel.setEditIds(openIds);
|
|
| 74 | + }
|
|
| 71 | 75 | }
|
| 72 | 76 | if (createDataSource) {
|
| 73 | 77 | // create temporary data source
|
| ... | ... | @@ -822,7 +822,7 @@ observe.ui.title.connect.remoteDB=Connect to remove database |
| 822 | 822 | observe.ui.title.connect.serverDB=Connect to server database
|
| 823 | 823 | observe.ui.title.delete=Confirm a delete
|
| 824 | 824 | observe.ui.title.h2.server.parameters=Configuration of local database in server mode
|
| 825 | -observe.ui.title.import.avdth=Import avdth file in a local database
|
|
| 825 | +observe.ui.title.import.avdth=Import avdth file
|
|
| 826 | 826 | observe.ui.title.import.localDB=Import a local database from a backup
|
| 827 | 827 | observe.ui.title.need.confirm=Need a confirmation...
|
| 828 | 828 | observe.ui.title.need.confirm.to.disable.referential=Need a confirmation to disable a referentiel data...
|
| ... | ... | @@ -822,7 +822,7 @@ observe.ui.title.connect.remoteDB=Conexión a una fuente de datos distante |
| 822 | 822 | observe.ui.title.connect.serverDB=Conexión a un servidor de datos distante
|
| 823 | 823 | observe.ui.title.delete=Confirmación de la eliminación
|
| 824 | 824 | observe.ui.title.h2.server.parameters=Configuración de la base local en modo servidor
|
| 825 | -observe.ui.title.import.avdth=Import avdth file in a local database \#TODO
|
|
| 825 | +observe.ui.title.import.avdth=Import avdth file\#TODO
|
|
| 826 | 826 | observe.ui.title.import.localDB=Importar una base local gracia a una copia de seguridad
|
| 827 | 827 | observe.ui.title.need.confirm=Una confirmación se necesita...
|
| 828 | 828 | observe.ui.title.need.confirm.to.disable.referential=Una confirmación se necesita para désactivar un referencial...
|
| ... | ... | @@ -822,7 +822,7 @@ observe.ui.title.connect.remoteDB=Connexion à une source de données distante |
| 822 | 822 | observe.ui.title.connect.serverDB=Connexion à un serveur de données distant
|
| 823 | 823 | observe.ui.title.delete=Confirmation de suppression
|
| 824 | 824 | observe.ui.title.h2.server.parameters=Paramétrage de la base locale en mode serveur
|
| 825 | -observe.ui.title.import.avdth=Importer une base avdth dans la base locale
|
|
| 825 | +observe.ui.title.import.avdth=Importer une base avdth
|
|
| 826 | 826 | observe.ui.title.import.localDB=Importer une base locale depuis une sauvegarde
|
| 827 | 827 | observe.ui.title.need.confirm=Une confirmation de votre part est requise...
|
| 828 | 828 | observe.ui.title.need.confirm.to.disable.referential=Une confirmation de votre part est requise pour désactiver un référentiel...
|
| ... | ... | @@ -331,14 +331,6 @@ |
| 331 | 331 | "lastUpdateDate": "2019-01-19T16:56:18.043Z",
|
| 332 | 332 | "text": "15/01/2019 - 17/01/2019 - observe.Common.none - Waliassaoun Ngoudzo"
|
| 333 | 333 | },
|
| 334 | - "dataLlCommonTripGroupByObservationsProgram:fr.ird.referential.common.Program#1609292987444#0.2779633795557708": {
|
|
| 335 | - "count": 0,
|
|
| 336 | - "editable": true,
|
|
| 337 | - "enable": true,
|
|
| 338 | - "id": "fr.ird.referential.common.Program#1609292987444#0.2779633795557708",
|
|
| 339 | - "lastUpdateDate": "2020-12-30T01:49:47.515Z",
|
|
| 340 | - "text": "[LL] observe.data.Data.program FINSS"
|
|
| 341 | - },
|
|
| 342 | 334 | "referentialCommon": {
|
| 343 | 335 | "editable": true,
|
| 344 | 336 | "text": "observe.referential.package.title"
|
| ... | ... | @@ -74,7 +74,6 @@ public class DataSourceMigrationForVersion_8_0 extends ByMajorMigrationVersionRe |
| 74 | 74 | if (withIds) {
|
| 75 | 75 | addCommonCountry(executor);
|
| 76 | 76 | addCommonPerson(executor);
|
| 77 | - addCommonProgram(executor);
|
|
| 78 | 77 | fillSpeciesLists(executor);
|
| 79 | 78 | }
|
| 80 | 79 | processSchema(executor, withIds, "40", "ps_common");
|
| ... | ... | @@ -166,15 +165,6 @@ public class DataSourceMigrationForVersion_8_0 extends ByMajorMigrationVersionRe |
| 166 | 165 | });
|
| 167 | 166 | }
|
| 168 | 167 | |
| 169 | - private void addCommonProgram(MigrationVersionResourceExecutor executor) {
|
|
| 170 | - Set<String> existingCodes = executor.findMultipleResultAstSet(TopiaSqlQuery.wrap("SELECT code FROM observe_common.Program", resultSet -> resultSet.getString(1)));
|
|
| 171 | - Stream.of("50").forEach(code -> {
|
|
| 172 | - if (!existingCodes.contains(code)) {
|
|
| 173 | - executor.addScript("30", "add_referential_common_Program_" + code);
|
|
| 174 | - }
|
|
| 175 | - });
|
|
| 176 | - }
|
|
| 177 | - |
|
| 178 | 168 | private void fillSpeciesLists(MigrationVersionResourceExecutor executor) {
|
| 179 | 169 | List<String> speciesIds = executor.findMultipleResult(new TopiaSqlQuery<>() {
|
| 180 | 170 | @Override
|
| 1 | ----
|
|
| 2 | --- #%L
|
|
| 3 | --- ObServe Core :: Persistence :: Resources
|
|
| 4 | --- %%
|
|
| 5 | --- Copyright (C) 2008 - 2022 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 | -INSERT INTO common.program(topiaid, topiaversion, topiacreatedate, lastupdatedate, code, uri, homeid, needcomment, status, label1, label2, label3, label4, label5, label6, label7, label8, organism, nontargetobservation, targetdiscardsobservation, samplesobservation, objectsobservation, detailedactivitiesobservation, mammalsobservation, birdsobservation, baitobservation, startdate, enddate, comment, geartype)VALUES ('fr.ird.referential.common.Program#1609292987444#0.2779633795557708', 1, '2020-12-30 01:41:23.965', '2020-12-30 01:49:47.515', '50', null, null, FALSE, 1, 'FINSS', 'FINSS', 'FINSS', null, null, null, null, null, 'fr.ird.referential.common.Organism#1267835067241#0.06632537553306939', 1, 1, 1, 0, 0, 0, 0, 0, '2020-05-17 00:00:00', '2021-12-31 00:00:00', null, 1); |
| ... | ... | @@ -32,6 +32,8 @@ import fr.ird.observe.spi.context.DtoEntityContext; |
| 32 | 32 | import fr.ird.observe.test.DatabaseName;
|
| 33 | 33 | import fr.ird.observe.test.spi.CopyDatabaseConfiguration;
|
| 34 | 34 | import fr.ird.observe.test.spi.DatabaseNameConfiguration;
|
| 35 | +import org.apache.logging.log4j.LogManager;
|
|
| 36 | +import org.apache.logging.log4j.Logger;
|
|
| 35 | 37 | import org.junit.Assert;
|
| 36 | 38 | import org.junit.Test;
|
| 37 | 39 | import org.junit.runner.RunWith;
|
| ... | ... | @@ -54,6 +56,8 @@ import java.util.stream.Collectors; |
| 54 | 56 | @RunWith(Parameterized.class)
|
| 55 | 57 | public class SqlServiceTest extends PersistenceTestSupportWrite {
|
| 56 | 58 | |
| 59 | + private static final Logger log = LogManager.getLogger(SqlServiceTest.class);
|
|
| 60 | + |
|
| 57 | 61 | @Parameterized.Parameter
|
| 58 | 62 | public Class<? extends DataEntity> entityType;
|
| 59 | 63 | |
| ... | ... | @@ -69,6 +73,7 @@ public class SqlServiceTest extends PersistenceTestSupportWrite { |
| 69 | 73 | DtoEntityContext<BusinessDto, DtoReference, ? extends DataEntity, ?> spi = ObservePersistenceBusinessProject.fromEntity(entityType);
|
| 70 | 74 | String variableName = ObservePersistenceFixtures.getEntityVariableName(entityType);
|
| 71 | 75 | String id = ObservePersistenceFixtures.getVariable(variableName);
|
| 76 | + log.info(String.format("test delete for: %s", id));
|
|
| 72 | 77 | ObserveTopiaApplicationContext applicationContext = localTestMethodResource.getTopiaApplicationContext();
|
| 73 | 78 | try (ObserveTopiaPersistenceContext persistenceContext = applicationContext.newPersistenceContext()) {
|
| 74 | 79 | boolean exists = spi.getDao(persistenceContext).forTopiaIdEquals(id).exists();
|
| ... | ... | @@ -35,7 +35,7 @@ common.ocean=3 |
| 35 | 35 | common.organism=10
|
| 36 | 36 | common.person=739
|
| 37 | 37 | ps_common.program=17
|
| 38 | -ll_common.program=19
|
|
| 38 | +ll_common.program=18
|
|
| 39 | 39 | common.sex=5
|
| 40 | 40 | common.shipowner=27
|
| 41 | 41 | common.sizemeasuretype=21
|
| ... | ... | @@ -28,9 +28,9 @@ count.common.full=1 |
| 28 | 28 | count.common.loadDisabledRootNodes=0
|
| 29 | 29 | count.common.loadEmptyRootNodes=0
|
| 30 | 30 | count.ll.default=2
|
| 31 | -count.ll.full=22
|
|
| 32 | -count.ll.loadDisabledRootNodes=19
|
|
| 33 | -count.ll.loadEmptyRootNodes=12
|
|
| 31 | +count.ll.full=21
|
|
| 32 | +count.ll.loadDisabledRootNodes=18
|
|
| 33 | +count.ll.loadEmptyRootNodes=11
|
|
| 34 | 34 | count.none.default=0
|
| 35 | 35 | count.none.full=9
|
| 36 | 36 | count.none.loadDisabledRootNodes=0
|
| ... | ... | @@ -22,7 +22,7 @@ |
| 22 | 22 | defaultArg1=FIXME
|
| 23 | 23 | defaultId=${REFERENTIAL_PS_COMMON_PROGRAM}
|
| 24 | 24 | loadAllData.count=115
|
| 25 | -loadAllReferential.count=36
|
|
| 25 | +loadAllReferential.count=35
|
|
| 26 | 26 | loadData.arg1=${defaultArg1}
|
| 27 | 27 | loadData.id=${PS_COMMON_TRIP}
|
| 28 | 28 | loadOrCreateData.arg1=${defaultArg1}
|
| ... | ... | @@ -116419,38 +116419,6 @@ |
| 116419 | 116419 | }
|
| 116420 | 116420 | ]
|
| 116421 | 116421 | },
|
| 116422 | - {
|
|
| 116423 | - "reference": {
|
|
| 116424 | - "type": "fr.ird.observe.dto.referential.ll.common.ProgramReference",
|
|
| 116425 | - "content": {
|
|
| 116426 | - "code": "50",
|
|
| 116427 | - "label": "FINSS",
|
|
| 116428 | - "tripCount": 0,
|
|
| 116429 | - "startDate": "2020-05-17T00:00:00.000Z",
|
|
| 116430 | - "endDate": "2021-12-31T00:00:00.000Z",
|
|
| 116431 | - "observation": false,
|
|
| 116432 | - "logbook": false,
|
|
| 116433 | - "needComment": false,
|
|
| 116434 | - "enabled": true,
|
|
| 116435 | - "id": "fr.ird.referential.ll.common.Program#1609292987444#0.2779633795557708",
|
|
| 116436 | - "lastUpdateDate": "2021-09-17T00:00:00.000Z",
|
|
| 116437 | - "topiaVersion": 2,
|
|
| 116438 | - "topiaCreateDate": "2020-12-30T01:41:23.965Z"
|
|
| 116439 | - }
|
|
| 116440 | - },
|
|
| 116441 | - "messages": [
|
|
| 116442 | - {
|
|
| 116443 | - "fieldName": "label1",
|
|
| 116444 | - "scope": "WARNING",
|
|
| 116445 | - "message": "Le libellé anglais n\u0027est pas traduit."
|
|
| 116446 | - },
|
|
| 116447 | - {
|
|
| 116448 | - "fieldName": "label3",
|
|
| 116449 | - "scope": "WARNING",
|
|
| 116450 | - "message": "Le libellé espagnol n\u0027est pas traduit."
|
|
| 116451 | - }
|
|
| 116452 | - ]
|
|
| 116453 | - },
|
|
| 116454 | 116422 | {
|
| 116455 | 116423 | "reference": {
|
| 116456 | 116424 | "type": "fr.ird.observe.dto.referential.ll.common.SettingShapeReference",
|
| ... | ... | @@ -270,7 +270,7 @@ exists.arg1=${defaultArg1} |
| 270 | 270 | exists.id=${defaultId}
|
| 271 | 271 | getEnabledReferentialLabelSet.count=10
|
| 272 | 272 | getNaturalIds.count=0
|
| 273 | -getReferenceSet.count=36
|
|
| 273 | +getReferenceSet.count=35
|
|
| 274 | 274 | getReferentialDtoSet.count=0
|
| 275 | 275 | getReferentialIds.count=91
|
| 276 | 276 | getReferentialReferenceSets.count=2
|
| ... | ... | @@ -25,4 +25,4 @@ REFERENCE_DATA_COUNT=64 |
| 25 | 25 | ENTITIES_LIMIT_SIZE=100
|
| 26 | 26 | # fr.ird.observe.services.service.referential.ReferentialService
|
| 27 | 27 | # fr.ird.observe.services.local.service.referential.DifferentialModelTest
|
| 28 | -REFERENTIAL_COUNT=4061 |
|
| 28 | +REFERENTIAL_COUNT=4060 |