Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe

Commits:

6 changed files:

Changes:

  • client/datasource/editor/api/src/main/i18n/getters/java.getter
    ... ... @@ -325,6 +325,8 @@ observe.ui.tree.action.searchOrCreate.tip
    325 325
     observe.ui.tree.action.selectAll.tip
    
    326 326
     observe.ui.tree.action.unselectAll.tip
    
    327 327
     observe.ui.tree.loaded
    
    328
    +observe.ui.tree.need.reload.message
    
    329
    +observe.ui.tree.need.reload.title
    
    328 330
     observe.ui.tree.reload
    
    329 331
     observe.ui.type.action.create
    
    330 332
     observe.ui.type.action.delete
    

  • client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/ropen/actions/SaveContentRootOpenableUIAdapter.java
    ... ... @@ -29,15 +29,21 @@ import fr.ird.observe.client.datasource.editor.api.content.data.ropen.ContentRoo
    29 29
     import fr.ird.observe.client.datasource.editor.api.content.data.ropen.ContentRootOpenableUIModel;
    
    30 30
     import fr.ird.observe.client.datasource.editor.api.content.data.ropen.ContentRootOpenableUINavigationNode;
    
    31 31
     import fr.ird.observe.client.datasource.editor.api.navigation.NavigationTree;
    
    32
    +import fr.ird.observe.client.datasource.editor.api.navigation.NavigationTreeModel;
    
    32 33
     import fr.ird.observe.client.datasource.editor.api.navigation.NavigationUI;
    
    33 34
     import fr.ird.observe.client.datasource.editor.api.navigation.tree.capability.ReferenceContainerCapability;
    
    34 35
     import fr.ird.observe.client.datasource.editor.api.navigation.tree.root.RootNavigationNode;
    
    35 36
     import fr.ird.observe.dto.data.DataGroupByDto;
    
    36 37
     import fr.ird.observe.dto.data.RootOpenableDto;
    
    37 38
     import fr.ird.observe.dto.reference.DataDtoReference;
    
    39
    +import fr.ird.observe.dto.reference.ReferentialDtoReference;
    
    38 40
     import fr.ird.observe.navigation.tree.NavigationResult;
    
    41
    +import fr.ird.observe.navigation.tree.io.request.ToolkitTreeFlatModelRootRequest;
    
    42
    +import fr.ird.observe.navigation.tree.navigation.NavigationTreeConfig;
    
    43
    +import io.ultreia.java4all.i18n.I18n;
    
    39 44
     import org.apache.logging.log4j.LogManager;
    
    40 45
     import org.apache.logging.log4j.Logger;
    
    46
    +import org.nuiton.jaxx.runtime.swing.JOptionPanes;
    
    41 47
     
    
    42 48
     import java.util.Objects;
    
    43 49
     
    
    ... ... @@ -63,13 +69,13 @@ public class SaveContentRootOpenableUIAdapter<D extends RootOpenableDto, U exten
    63 69
             // get old groupBy dto
    
    64 70
             @SuppressWarnings("unchecked") DataGroupByDto<D> oldGroupByDto = (DataGroupByDto<D>) node.getParentReference();
    
    65 71
     
    
    66
    -        // new groupBy value
    
    67
    -        String newGroupByValue = oldGroupByDto.definition().toGroupByValue(bean, ((RootNavigationNode) node.getRoot()).getInitializer().getRequest().getGroupByFlavor());
    
    68
    -        // is groupBy has changed?
    
    69
    -        boolean groupByChanged = !Objects.equals(oldGroupByDto.getFilterValue(), newGroupByValue);
    
    72
    +        ToolkitTreeFlatModelRootRequest navigationRequest = ((RootNavigationNode) node.getRoot()).getInitializer().getRequest();
    
    73
    +        ComputeNavigationRequestChange<D,U> computeNavigationRequestChange = new ComputeNavigationRequestChange<>(oldGroupByDto, navigationRequest, bean);
    
    74
    +        computeNavigationRequestChange.warnUserIfNecessary(ui);
    
    75
    +
    
    70 76
             // We need to inject ot node the new reference (it could does not know the id if not persisted)
    
    71 77
             // As I prefer to use a unique code (for persisted or not, keep it like this)
    
    72
    -        node = updateReference(dataSourceEditor.getNavigationUI(), node, bean.getId(), oldGroupByDto, groupByChanged, newGroupByValue);
    
    78
    +        node = updateReference(dataSourceEditor.getNavigationUI(), node, computeNavigationRequestChange);
    
    73 79
     
    
    74 80
             tree.reSelectSafeNodeThen(node, () -> {
    
    75 81
                 dataSourceEditor.getModel().resetFromPreviousUi(ui);
    
    ... ... @@ -79,17 +85,125 @@ public class SaveContentRootOpenableUIAdapter<D extends RootOpenableDto, U exten
    79 85
             });
    
    80 86
         }
    
    81 87
     
    
    88
    +    public static class ComputeNavigationRequestChange<D extends RootOpenableDto, U extends ContentRootOpenableUI<D, U>> {
    
    89
    +        private final DataGroupByDto<D> oldGroupByDto;
    
    90
    +        private final ToolkitTreeFlatModelRootRequest navigationRequest;
    
    91
    +        private final D bean;
    
    92
    +        private final String newGroupByValue;
    
    93
    +        private final boolean groupByChanged;
    
    94
    +        private final boolean changeNavigationRequest;
    
    95
    +        private final boolean addNullGroupBy;
    
    96
    +        private final boolean addDisabledGroupBy;
    
    97
    +
    
    98
    +        ComputeNavigationRequestChange(DataGroupByDto<D> oldGroupByDto, ToolkitTreeFlatModelRootRequest navigationRequest, D bean) {
    
    99
    +            this.oldGroupByDto = oldGroupByDto;
    
    100
    +            this.navigationRequest = navigationRequest;
    
    101
    +            this.bean = bean;
    
    102
    +            this.newGroupByValue = oldGroupByDto.definition().toGroupByValue(bean, navigationRequest.getGroupByFlavor());
    
    103
    +            this.groupByChanged = !Objects.equals(oldGroupByDto.getFilterValue(), newGroupByValue);
    
    104
    +            boolean changeNavigationRequest = false;
    
    105
    +            boolean addNullGroupBy = false;
    
    106
    +            boolean addDisabledGroupBy = false;
    
    107
    +            if (groupByChanged) {
    
    108
    +                // check if old navigation request is compliant with new groupBy value
    
    109
    +                if (newGroupByValue == null) {
    
    110
    +                    if (!navigationRequest.isLoadNullGroupBy()) {
    
    111
    +                        // need to add null groupBy in navigation request
    
    112
    +                        changeNavigationRequest = true;
    
    113
    +                        addNullGroupBy = true;
    
    114
    +                    }
    
    115
    +                } else {
    
    116
    +                    if (oldGroupByDto.definition().isQualitative() && !navigationRequest.isLoadDisabledGroupBy()) {
    
    117
    +                        ReferentialDtoReference groupByObjectValue = (ReferentialDtoReference) oldGroupByDto.definition().toGroupByObjectValue(bean);
    
    118
    +                        if (groupByObjectValue.isDisabled()) {
    
    119
    +                            // need to add disabled groupBy in navigation request
    
    120
    +                            changeNavigationRequest = true;
    
    121
    +                            addDisabledGroupBy = true;
    
    122
    +                        }
    
    123
    +                    }
    
    124
    +                }
    
    125
    +            }
    
    126
    +            this.changeNavigationRequest = changeNavigationRequest;
    
    127
    +            this.addNullGroupBy = addNullGroupBy;
    
    128
    +            this.addDisabledGroupBy = addDisabledGroupBy;
    
    129
    +        }
    
    130
    +
    
    131
    +        public void warnUserIfNecessary(U ui) {
    
    132
    +            if (!isChangeNavigationRequest()) {
    
    133
    +                return;
    
    134
    +            }
    
    135
    +            // display message to user
    
    136
    +            if (isAddNullGroupBy()) {
    
    137
    +                // add null groupBy in navigation request
    
    138
    +                JOptionPanes.displayWarning(ui, I18n.t("observe.ui.tree.need.reload.title"), I18n.t("observe.ui.tree.need.reload.message"));
    
    139
    +                return;
    
    140
    +            }
    
    141
    +            if (isAddDisabledGroupBy()) {
    
    142
    +                // add disabled groupBy in navigation request
    
    143
    +                JOptionPanes.displayWarning(ui, I18n.t("observe.ui.tree.need.reload.title"), I18n.t("observe.ui.tree.need.reload.message"));
    
    144
    +            }
    
    145
    +        }
    
    146
    +
    
    147
    +        public DataGroupByDto<D> getOldGroupByDto() {
    
    148
    +            return oldGroupByDto;
    
    149
    +        }
    
    150
    +
    
    151
    +        public ToolkitTreeFlatModelRootRequest getNavigationRequest() {
    
    152
    +            return navigationRequest;
    
    153
    +        }
    
    154
    +
    
    155
    +        public D getBean() {
    
    156
    +            return bean;
    
    157
    +        }
    
    158
    +
    
    159
    +        public String getNewGroupByValue() {
    
    160
    +            return newGroupByValue;
    
    161
    +        }
    
    162
    +
    
    163
    +        public boolean isGroupByChanged() {
    
    164
    +            return groupByChanged;
    
    165
    +        }
    
    166
    +
    
    167
    +        public boolean isChangeNavigationRequest() {
    
    168
    +            return changeNavigationRequest;
    
    169
    +        }
    
    170
    +
    
    171
    +        public boolean isAddNullGroupBy() {
    
    172
    +            return addNullGroupBy;
    
    173
    +        }
    
    174
    +
    
    175
    +        public boolean isAddDisabledGroupBy() {
    
    176
    +            return addDisabledGroupBy;
    
    177
    +        }
    
    178
    +
    
    179
    +        NavigationResult updateNavigationResult(NavigationTreeModel navigationTreeModel) {
    
    180
    +            NavigationTreeConfig navigationTreeConfig = navigationTreeModel.getConfig();
    
    181
    +            if (isAddNullGroupBy()) {
    
    182
    +                navigationTreeConfig.setLoadNullGroupBy(true);
    
    183
    +                navigationTreeModel.getClientConfig().saveTreeConfig(navigationTreeConfig);
    
    184
    +                navigationRequest.setLoadNullGroupBy(true);
    
    185
    +            }
    
    186
    +            if (isAddDisabledGroupBy()) {
    
    187
    +                navigationTreeConfig.setLoadDisabledGroupBy(true);
    
    188
    +                navigationRequest.setLoadDisabledGroupBy(true);
    
    189
    +                navigationTreeModel.getClientConfig().saveTreeConfig(navigationTreeConfig);
    
    190
    +            }
    
    191
    +            return navigationTreeModel.updateNavigationResult();
    
    192
    +        }
    
    193
    +    }
    
    194
    +
    
    82 195
         public ContentRootOpenableUINavigationNode updateReference(NavigationUI navigationUI,
    
    83 196
                                                                    ContentRootOpenableUINavigationNode node,
    
    84
    -                                                               String id,
    
    85
    -                                                               DataGroupByDto<D> oldGroupByDto,
    
    86
    -                                                               boolean groupByChanged,
    
    87
    -                                                               String newGroupByValue) {
    
    197
    +                                                               ComputeNavigationRequestChange<D, U> computeNavigationRequestChange) {
    
    88 198
             boolean notPersisted = node.getInitializer().isNotPersisted();
    
    199
    +        String id = computeNavigationRequestChange.getBean().getId();
    
    200
    +        DataGroupByDto<D> oldGroupByDto = computeNavigationRequestChange.getOldGroupByDto();
    
    201
    +        boolean groupByChanged = computeNavigationRequestChange.isGroupByChanged();
    
    202
    +        String newGroupByValue = computeNavigationRequestChange.getNewGroupByValue();
    
    89 203
             ContentRootListUINavigationNode parent = node.getParent();
    
    90 204
             if (groupByChanged) {
    
    91 205
                 // the navigation must be updated, new parent groupBy value has changed
    
    92
    -            NavigationResult navigationResult = navigationUI.getTree().getModel().updateNavigationResult();
    
    206
    +            NavigationResult navigationResult = computeNavigationRequestChange.updateNavigationResult(navigationUI.getTree().getModel());
    
    93 207
                 // groupBy has changed (remove node from parent)
    
    94 208
                 RootNavigationNode rootNode = (RootNavigationNode) node.getRoot();
    
    95 209
                 node.removeFromParent();
    

  • client/runner/src/main/i18n/translations/client-runner_en_GB.properties
    ... ... @@ -927,6 +927,8 @@ observe.ui.tree.action.searchOrCreate.tip=Search or create a new trip
    927 927
     observe.ui.tree.action.selectAll.tip=Select All
    
    928 928
     observe.ui.tree.action.unselectAll.tip=Unselect All
    
    929 929
     observe.ui.tree.loaded=Tree reloaded (in %s)
    
    930
    +observe.ui.tree.need.reload.message=The current navigation tree configuration does not allow to display this trip after its update, it will be updated accordingly.
    
    931
    +observe.ui.tree.need.reload.title=Navigation tree update
    
    930 932
     observe.ui.tree.reload=Reload tree structure
    
    931 933
     observe.ui.type.action.create=Create a new %s
    
    932 934
     observe.ui.type.action.delete=Delete selected %s
    

  • client/runner/src/main/i18n/translations/client-runner_es_ES.properties
    ... ... @@ -927,6 +927,8 @@ observe.ui.tree.action.searchOrCreate.tip=Search or create a new trip \#TODO
    927 927
     observe.ui.tree.action.selectAll.tip=Seleccionar todo
    
    928 928
     observe.ui.tree.action.unselectAll.tip=Deseleccionar todo
    
    929 929
     observe.ui.tree.loaded=Tree reloaded (in %s)
    
    930
    +observe.ui.tree.need.reload.message=The current navigation tree configuration does not allow to display this trip after its update, it will be updated accordingly. \#TODO
    
    931
    +observe.ui.tree.need.reload.title=Navigation tree update \#TODO
    
    930 932
     observe.ui.tree.reload=Reload tree structure
    
    931 933
     observe.ui.type.action.create=Crear un objeto de tipo '%s'
    
    932 934
     observe.ui.type.action.delete=Eliminar el objeto de tipo '%s' seleccionado
    

  • client/runner/src/main/i18n/translations/client-runner_fr_FR.properties
    ... ... @@ -927,6 +927,8 @@ observe.ui.tree.action.searchOrCreate.tip=Rechercher ou créer une nouvelle mar
    927 927
     observe.ui.tree.action.selectAll.tip=Tout sélectionner
    
    928 928
     observe.ui.tree.action.unselectAll.tip=Tout désélectionner
    
    929 929
     observe.ui.tree.loaded=Arbre rechargé (en %s)
    
    930
    +observe.ui.tree.need.reload.message=La configuration actuelle de l'arbre de navigation ne permet plus d'afficher cette marée après sa modification, elle va être adaptée en conséquence.
    
    931
    +observe.ui.tree.need.reload.title=Mise à jour de la configuration de l'arbre
    
    930 932
     observe.ui.tree.reload=Chargement de la structure de l'arbre
    
    931 933
     observe.ui.type.action.create=Créer un objet de type '%s'
    
    932 934
     observe.ui.type.action.delete=Supprimer l'objet de type '%s' sélectionné
    

  • core/persistence/java/src/main/java/fr/ird/observe/entities/data/ll/logbook/ActivitySpi.java
    ... ... @@ -68,7 +68,7 @@ public class ActivitySpi extends GeneratedActivitySpi {
    68 68
                 ActivitySampleDto activitySampleDto = Sample.ACTIVITY_SAMPLE_SPI.toDto(referentialLocale, sample);
    
    69 69
                 dto.setActivitySample(ActivitySampleReference.of(referentialLocale, activitySampleDto));
    
    70 70
             }
    
    71
    -        if (set != null) {
    
    71
    +        if (set != null && set.isCatchesNotEmpty()) {
    
    72 72
                 dto.setCatchSpeciesIds(set.getCatches().stream().map(Catch::getSpecies).distinct().map(Species::getTopiaId).collect(Collectors.toSet()));
    
    73 73
             }
    
    74 74
         }