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

Commits:

12 changed files:

Changes:

  • client/src/main/java/fr/ird/observe/client/ui/content/data/seine/FloatingObjectUI.jcss
    ... ... @@ -144,4 +144,5 @@ BeanComboBox {
    144 144
       treeTableModel:{new FloatingObjectPartsTreeTableModel(getModel())};
    
    145 145
       treeCellRenderer:{new FloatingObjectPartLegendTreeCellRenderer()};
    
    146 146
       selectionMode:{ListSelectionModel.SINGLE_SELECTION};
    
    147
    +  rootVisible:false;
    
    147 148
     }

  • client/src/main/java/fr/ird/observe/client/ui/content/data/seine/FloatingObjectUIHandler.java
    ... ... @@ -22,6 +22,7 @@
    22 22
     package fr.ird.observe.client.ui.content.data.seine;
    
    23 23
     
    
    24 24
     import com.google.common.collect.ImmutableSet;
    
    25
    +import com.google.common.collect.Maps;
    
    25 26
     import fr.ird.observe.client.ObserveSwingApplicationContext;
    
    26 27
     import fr.ird.observe.client.db.ClientDataContext;
    
    27 28
     import fr.ird.observe.client.db.ObserveSwingDataSource;
    
    ... ... @@ -45,6 +46,7 @@ import fr.ird.observe.dto.data.seine.FloatingObjectReference;
    45 46
     import fr.ird.observe.dto.data.seine.ObjectMaterialHierarchyDto;
    
    46 47
     import fr.ird.observe.dto.form.Form;
    
    47 48
     import fr.ird.observe.dto.referential.seine.ObjectMaterialDto;
    
    49
    +import fr.ird.observe.dto.referential.seine.ObjectMaterialTypeReference;
    
    48 50
     import fr.ird.observe.dto.referential.seine.ObjectOperationReference;
    
    49 51
     import fr.ird.observe.dto.result.SaveResultDto;
    
    50 52
     import fr.ird.observe.services.service.actions.consolidate.dcp.ConsolidateFloatingObjectRequest;
    
    ... ... @@ -187,7 +189,7 @@ public class FloatingObjectUIHandler extends ContentUIHandler<FloatingObjectDto,
    187 189
     
    
    188 190
             getModel().reset();
    
    189 191
     
    
    190
    -        openTable(partsSet, getUi().getTable());
    
    192
    +        openTable(partsSet, getUi().getTable(),bean.isPersisted());
    
    191 193
     
    
    192 194
             setContentMode(mode);
    
    193 195
     
    
    ... ... @@ -209,7 +211,7 @@ public class FloatingObjectUIHandler extends ContentUIHandler<FloatingObjectDto,
    209 211
             SwingUtilities.invokeLater(this::forceGrabFocusOnForm);
    
    210 212
         }
    
    211 213
     
    
    212
    -    private void openTable(Set<FloatingObjectPartReference> partsSet, JXTreeTable table) {
    
    214
    +    private void openTable(Set<FloatingObjectPartReference> partsSet, JXTreeTable table, boolean persisted) {
    
    213 215
     
    
    214 216
             FloatingObjectUIModel model = getModel();
    
    215 217
             for (FloatingObjectPartReference p : partsSet) {
    
    ... ... @@ -227,7 +229,9 @@ public class FloatingObjectUIHandler extends ContentUIHandler<FloatingObjectDto,
    227 229
             FloatingObjectPartsTreeTableModel treeTableModel = (FloatingObjectPartsTreeTableModel) table.getTreeTableModel();
    
    228 230
             treeTableModel.reset();
    
    229 231
     
    
    230
    -        table.expandAll();
    
    232
    +        if (persisted) {
    
    233
    +            table.expandAll();
    
    234
    +        }
    
    231 235
         }
    
    232 236
     
    
    233 237
         @Override
    
    ... ... @@ -322,10 +326,15 @@ public class FloatingObjectUIHandler extends ContentUIHandler<FloatingObjectDto,
    322 326
             // listen messages to see if required to add
    
    323 327
             ui.getErrorTableModel().addTableModelListener(computeTabValidStateListener);
    
    324 328
     
    
    325
    -        List<ObjectMaterialHierarchyDto> detailedForm = getFloatingObjectService().getObjectMaterialHierarchy();
    
    329
    +        ObjectMaterialHierarchyDto detailedForm = getFloatingObjectService().getObjectMaterialHierarchy();
    
    330
    +
    
    331
    +        ObjectMaterialTypeReference booleanType = getReferentialReferences(ObjectMaterialTypeReference.class).stream().filter(e->e.getTopiaId().equals("fr.ird.observe.entities.referentiel.seine.ObjectMaterialType#0#0")).findFirst().orElseThrow(IllegalStateException::new);
    
    326 332
     
    
    333
    +        for (ObjectMaterialHierarchyDto objectMaterialHierarchyDto : detailedForm.getChildren()) {
    
    334
    +            objectMaterialHierarchyDto.setObjectMaterialType(booleanType);
    
    335
    +        }
    
    327 336
             Map<String, ObjectMaterialDto> allMap = new TreeMap<>();
    
    328
    -        detailedForm.stream().flatMap(o -> o.getAllDtos().stream()).forEach(s -> allMap.putIfAbsent(s.getId(), s));
    
    337
    +        detailedForm.getAllDtos().forEach(s -> allMap.putIfAbsent(s.getId(), s));
    
    329 338
     
    
    330 339
             FloatingObjectUIModel model = getModel();
    
    331 340
             model.setReferentialMap(allMap);
    
    ... ... @@ -386,7 +395,7 @@ public class FloatingObjectUIHandler extends ContentUIHandler<FloatingObjectDto,
    386 395
             treeModel.reset();
    
    387 396
         }
    
    388 397
     
    
    389
    -    private void initTable(List<ObjectMaterialHierarchyDto> materials, JXTreeTable table) {
    
    398
    +    private void initTable(ObjectMaterialHierarchyDto materials, JXTreeTable table) {
    
    390 399
     
    
    391 400
             FloatingObjectPartsTreeTableModel treeModel = (FloatingObjectPartsTreeTableModel) table.getTreeTableModel();
    
    392 401
             treeModel.rebuildRootNode(materials);
    

  • client/src/main/java/fr/ird/observe/client/ui/content/data/seine/FloatingObjectUIModel.java
    ... ... @@ -120,6 +120,10 @@ public class FloatingObjectUIModel extends ContentUIModel<FloatingObjectDto> {
    120 120
         ImmutableSet<FloatingObjectPartDto> toParts() {
    
    121 121
             ImmutableSet.Builder<FloatingObjectPartDto> result = ImmutableSet.builder();
    
    122 122
             for (ObjectMaterialDto o : getAll()) {
    
    123
    +            if (o.getParent()!=null && o.getParent().getParentId()==null) {
    
    124
    +                // first level node, can't be send
    
    125
    +                continue;
    
    126
    +            }
    
    123 127
                 FloatingObjectPartDto partDto = new FloatingObjectPartDto();
    
    124 128
                 partDto.setObjectMaterial(binder.toReference(referentialLocale, o));
    
    125 129
                 if (arriving) {
    

  • client/src/main/java/fr/ird/observe/client/ui/content/data/seine/dcp/FloatingObjectPartsTreeNode.java
    ... ... @@ -10,12 +10,12 @@ package fr.ird.observe.client.ui.content.data.seine.dcp;
    10 10
      * it under the terms of the GNU General Public License as
    
    11 11
      * published by the Free Software Foundation, either version 3 of the
    
    12 12
      * License, or (at your option) any later version.
    
    13
    - * 
    
    13
    + *
    
    14 14
      * This program is distributed in the hope that it will be useful,
    
    15 15
      * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    16 16
      * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    17 17
      * GNU General Public License for more details.
    
    18
    - * 
    
    18
    + *
    
    19 19
      * You should have received a copy of the GNU General Public
    
    20 20
      * License along with this program.  If not, see
    
    21 21
      * <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    ... ... @@ -34,7 +34,6 @@ import org.jetbrains.annotations.NotNull;
    34 34
     
    
    35 35
     import java.util.Collections;
    
    36 36
     import java.util.Iterator;
    
    37
    -import java.util.List;
    
    38 37
     import java.util.Objects;
    
    39 38
     import java.util.Optional;
    
    40 39
     
    
    ... ... @@ -48,137 +47,6 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im
    48 47
         /** Logger. */
    
    49 48
         private static final Log log = LogFactory.getLog(FloatingObjectPartsTreeNode.class);
    
    50 49
     
    
    51
    -    static FloatingObjectPartsTreeNode createRoot(FloatingObjectUIModel model, List<ObjectMaterialHierarchyDto> referential) {
    
    52
    -        FloatingObjectPartsTreeNodeContext rootModel = new FloatingObjectPartsTreeNodeContext(model);
    
    53
    -        FloatingObjectPartsTreeNode root = new FloatingObjectPartsTreeNode(rootModel);
    
    54
    -        if (referential != null) {
    
    55
    -            for (ObjectMaterialHierarchyDto dto : referential) {
    
    56
    -                FloatingObjectPartsTreeNodeContext childModel = new FloatingObjectPartsTreeNodeContext(dto, rootModel);
    
    57
    -                FloatingObjectPartsTreeNode node = new FloatingObjectPartsTreeNode(childModel);
    
    58
    -                root.add(node);
    
    59
    -                ImmutableSet.Builder<FloatingObjectPartsTreeNode> companionsBuilder = dto.isChildrenMultiSelectable() ? ImmutableSet.builder() : null;
    
    60
    -                node.computeCompanions(companionsBuilder);
    
    61
    -                node.setCompanions(companionsBuilder);
    
    62
    -            }
    
    63
    -        }
    
    64
    -        return root;
    
    65
    -    }
    
    66
    -
    
    67
    -    boolean isNotValid() {
    
    68
    -        return !(getUserObject().validWhenArriving && getUserObject().validWhenLeaving);
    
    69
    -    }
    
    70
    -
    
    71
    -    private static class FloatingObjectPartsTreeNodeContext {
    
    72
    -
    
    73
    -        // main model to get and store values
    
    74
    -        private final FloatingObjectUIModel uiModel;
    
    75
    -        // dto (null for root)
    
    76
    -        private final ObjectMaterialHierarchyDto dto;
    
    77
    -        // Is the node is enabled (hierarchic value) ?
    
    78
    -        private final boolean enabled;
    
    79
    -        // Is this node editable ?
    
    80
    -        private final boolean editable;
    
    81
    -        // Is this node need at least one child selected ?
    
    82
    -        private final boolean needOneSelection;
    
    83
    -        // Is this node in the path of at least one mandatory child ancestor ?
    
    84
    -        private final boolean mandatory;
    
    85
    -        // Is the node is exclusive (means only one value possible for him and his brothers) ?
    
    86
    -        private final boolean exclusive;
    
    87
    -        // Is the node valid for whenArriving column ?
    
    88
    -        private boolean validWhenArriving = true;
    
    89
    -        // Is the node valid for whenLeaving column ?
    
    90
    -        private boolean validWhenLeaving = true;
    
    91
    -        // Set of brothers of this node that is in a exclusive group of node (only one value among all of them)
    
    92
    -        private ImmutableSet<FloatingObjectPartsTreeNode> companions;
    
    93
    -        // Internal to store debug node text
    
    94
    -        private String text;
    
    95
    -
    
    96
    -        FloatingObjectPartsTreeNodeContext(FloatingObjectUIModel uiModel) {
    
    97
    -            Objects.requireNonNull(uiModel);
    
    98
    -            this.uiModel = uiModel;
    
    99
    -            this.dto = null;
    
    100
    -            this.enabled = true;
    
    101
    -            this.editable = false;
    
    102
    -            this.mandatory = false;
    
    103
    -            this.exclusive = false;
    
    104
    -            this.needOneSelection = false;
    
    105
    -        }
    
    106
    -
    
    107
    -        FloatingObjectPartsTreeNodeContext(ObjectMaterialHierarchyDto dto, FloatingObjectPartsTreeNodeContext parent) {
    
    108
    -            Objects.requireNonNull(dto);
    
    109
    -            Objects.requireNonNull(parent);
    
    110
    -            this.uiModel = parent.uiModel;
    
    111
    -            this.dto = dto;
    
    112
    -            // enabled if parent is enabled and dto is enabled
    
    113
    -            this.enabled = parent.enabled && dto.isEnabled();
    
    114
    -            // need one selection if is enabled and dto requires it
    
    115
    -            this.needOneSelection = enabled && dto.isChildSelectionMandatory();
    
    116
    -            // editable if dto is selectable (we also make sure that the object material type is here too)
    
    117
    -            this.editable = dto.isSelectable() && dto.getObjectMaterialType() != null;
    
    118
    -            // mandatory if enabled parent is so or parent makes this child to be
    
    119
    -            this.mandatory = parent.mandatory || parent.needOneSelection;
    
    120
    -            // exclusive if his parent requires it
    
    121
    -            this.exclusive = parent.dto != null && parent.dto.isChildrenMultiSelectable();
    
    122
    -            log.info(String.format("New node: %s - mandatory %s - needOneSelection %s - exclusive %s", dto.getLabel2(), mandatory, needOneSelection, exclusive));
    
    123
    -        }
    
    124
    -
    
    125
    -        Object getValueAt(int column) {
    
    126
    -            switch (column) {
    
    127
    -                case 0: // dto
    
    128
    -                    return dto;
    
    129
    -                case 1: // when arriving
    
    130
    -                    return uiModel.getWhenArriving().get(dto);
    
    131
    -                case 2: // when leaving
    
    132
    -                    return uiModel.getWhenLeaving().get(dto);
    
    133
    -            }
    
    134
    -            throw new IllegalStateException();
    
    135
    -        }
    
    136
    -
    
    137
    -        void setValueAt(Object aValue, int column) {
    
    138
    -            switch (column) {
    
    139
    -                case 1: // when arriving
    
    140
    -                    uiModel.setWhenArriving(dto.getId(), aValue == null ? null : String.valueOf(aValue));
    
    141
    -                    return;
    
    142
    -                case 2: // when leaving
    
    143
    -                    uiModel.setWhenLeaving(dto.getId(), aValue == null ? null : String.valueOf(aValue));
    
    144
    -                    return;
    
    145
    -            }
    
    146
    -            throw new IllegalStateException();
    
    147
    -        }
    
    148
    -
    
    149
    -        boolean isColumnEditable(int column) {
    
    150
    -            switch (column) {
    
    151
    -                case 1: // when arriving
    
    152
    -                    return uiModel.isArriving();
    
    153
    -                case 2: // when leaving
    
    154
    -                    return uiModel.isLeaving();
    
    155
    -            }
    
    156
    -            throw new IllegalStateException();
    
    157
    -        }
    
    158
    -
    
    159
    -        boolean isValid(int column) {
    
    160
    -            switch (column) {
    
    161
    -                case 1: // when arriving
    
    162
    -                    return validWhenArriving;
    
    163
    -                case 2: // when leaving
    
    164
    -                    return validWhenLeaving;
    
    165
    -            }
    
    166
    -            throw new IllegalStateException();
    
    167
    -        }
    
    168
    -
    
    169
    -        Optional<FloatingObjectPartsTreeNode> getSelectedCompanion(int column) {
    
    170
    -            return companions.stream().filter(n -> n.getValueAt(column) != null).findFirst();
    
    171
    -        }
    
    172
    -
    
    173
    -        public String getText() {
    
    174
    -            if (text == null && dto != null) {
    
    175
    -                text = String.format("%s [value: %s-%s] [valid: %s-%s]", dto.getLabel2(), getValueAt(1), getValueAt(2), isValid(1), isValid(2));
    
    176
    -            }
    
    177
    -            return text;
    
    178
    -        }
    
    179
    -
    
    180
    -    }
    
    181
    -
    
    182 50
         private FloatingObjectPartsTreeNode(FloatingObjectPartsTreeNodeContext context) {
    
    183 51
             super(context);
    
    184 52
             if (context.dto != null) {
    
    ... ... @@ -189,6 +57,25 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im
    189 57
             }
    
    190 58
         }
    
    191 59
     
    
    60
    +    static FloatingObjectPartsTreeNode createRoot(FloatingObjectUIModel model, ObjectMaterialHierarchyDto dto) {
    
    61
    +        FloatingObjectPartsTreeNode root;
    
    62
    +        FloatingObjectPartsTreeNodeContext rootModel = new FloatingObjectPartsTreeNodeContext(model);
    
    63
    +        if (dto != null) {
    
    64
    +            FloatingObjectPartsTreeNodeContext childModel = new FloatingObjectPartsTreeNodeContext(dto, rootModel);
    
    65
    +            root = new FloatingObjectPartsTreeNode(childModel);
    
    66
    +            ImmutableSet.Builder<FloatingObjectPartsTreeNode> companionsBuilder = dto.isChildrenMultiSelectable() ? ImmutableSet.builder() : null;
    
    67
    +            root.computeCompanions(companionsBuilder);
    
    68
    +            root.setCompanions(companionsBuilder);
    
    69
    +        } else {
    
    70
    +            root = new FloatingObjectPartsTreeNode(rootModel);
    
    71
    +        }
    
    72
    +        return root;
    
    73
    +    }
    
    74
    +
    
    75
    +    boolean isNotValid() {
    
    76
    +        return !(getUserObject().validWhenArriving && getUserObject().validWhenLeaving);
    
    77
    +    }
    
    78
    +
    
    192 79
         @Override
    
    193 80
         public String toString() {
    
    194 81
             return getUserObject().getText();
    
    ... ... @@ -395,4 +282,116 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im
    395 282
             }
    
    396 283
             setCompanions(childCompanionsBuilder);
    
    397 284
         }
    
    285
    +
    
    286
    +    private static class FloatingObjectPartsTreeNodeContext {
    
    287
    +
    
    288
    +        // main model to get and store values
    
    289
    +        private final FloatingObjectUIModel uiModel;
    
    290
    +        // dto (null for root)
    
    291
    +        private final ObjectMaterialHierarchyDto dto;
    
    292
    +        // Is the node is enabled (hierarchic value) ?
    
    293
    +        private final boolean enabled;
    
    294
    +        // Is this node editable ?
    
    295
    +        private final boolean editable;
    
    296
    +        // Is this node need at least one child selected ?
    
    297
    +        private final boolean needOneSelection;
    
    298
    +        // Is this node in the path of at least one mandatory child ancestor ?
    
    299
    +        private final boolean mandatory;
    
    300
    +        // Is the node is exclusive (means only one value possible for him and his brothers) ?
    
    301
    +        private final boolean exclusive;
    
    302
    +        // Is the node valid for whenArriving column ?
    
    303
    +        private boolean validWhenArriving = true;
    
    304
    +        // Is the node valid for whenLeaving column ?
    
    305
    +        private boolean validWhenLeaving = true;
    
    306
    +        // Set of brothers of this node that is in a exclusive group of node (only one value among all of them)
    
    307
    +        private ImmutableSet<FloatingObjectPartsTreeNode> companions;
    
    308
    +        // Internal to store debug node text
    
    309
    +        private String text;
    
    310
    +
    
    311
    +        FloatingObjectPartsTreeNodeContext(FloatingObjectUIModel uiModel) {
    
    312
    +            Objects.requireNonNull(uiModel);
    
    313
    +            this.uiModel = uiModel;
    
    314
    +            this.dto = null;
    
    315
    +            this.enabled = true;
    
    316
    +            this.editable = false;
    
    317
    +            this.mandatory = false;
    
    318
    +            this.exclusive = false;
    
    319
    +            this.needOneSelection = false;
    
    320
    +        }
    
    321
    +
    
    322
    +        FloatingObjectPartsTreeNodeContext(ObjectMaterialHierarchyDto dto, FloatingObjectPartsTreeNodeContext parent) {
    
    323
    +            Objects.requireNonNull(dto);
    
    324
    +            Objects.requireNonNull(parent);
    
    325
    +            this.uiModel = parent.uiModel;
    
    326
    +            this.dto = dto;
    
    327
    +            // enabled if parent is enabled and dto is enabled
    
    328
    +            this.enabled = parent.enabled && dto.isEnabled();
    
    329
    +            // need one selection if is enabled and dto requires it
    
    330
    +            this.needOneSelection = enabled && dto.isChildSelectionMandatory();
    
    331
    +            // editable if dto is selectable (we also make sure that the object material type is here too)
    
    332
    +            this.editable = dto.isSelectable() && dto.getObjectMaterialType() != null;
    
    333
    +
    
    334
    +            // mandatory if enabled parent is so or parent makes this child to be
    
    335
    +            this.mandatory = parent.mandatory || parent.needOneSelection;
    
    336
    +            // exclusive if his parent requires it
    
    337
    +            this.exclusive = parent.dto != null && parent.dto.isChildrenMultiSelectable();
    
    338
    +            log.info(String.format("New node: %s - mandatory %s - needOneSelection %s - exclusive %s", dto.getLabel2(), mandatory, needOneSelection, exclusive));
    
    339
    +        }
    
    340
    +
    
    341
    +        Object getValueAt(int column) {
    
    342
    +            switch (column) {
    
    343
    +                case 0: // dto
    
    344
    +                    return dto;
    
    345
    +                case 1: // when arriving
    
    346
    +                    return uiModel.getWhenArriving().get(dto);
    
    347
    +                case 2: // when leaving
    
    348
    +                    return uiModel.getWhenLeaving().get(dto);
    
    349
    +            }
    
    350
    +            throw new IllegalStateException();
    
    351
    +        }
    
    352
    +
    
    353
    +        void setValueAt(Object aValue, int column) {
    
    354
    +            switch (column) {
    
    355
    +                case 1: // when arriving
    
    356
    +                    uiModel.setWhenArriving(dto.getId(), aValue == null ? null : String.valueOf(aValue));
    
    357
    +                    return;
    
    358
    +                case 2: // when leaving
    
    359
    +                    uiModel.setWhenLeaving(dto.getId(), aValue == null ? null : String.valueOf(aValue));
    
    360
    +                    return;
    
    361
    +            }
    
    362
    +            throw new IllegalStateException();
    
    363
    +        }
    
    364
    +
    
    365
    +        boolean isColumnEditable(int column) {
    
    366
    +            switch (column) {
    
    367
    +                case 1: // when arriving
    
    368
    +                    return uiModel.isArriving();
    
    369
    +                case 2: // when leaving
    
    370
    +                    return uiModel.isLeaving();
    
    371
    +            }
    
    372
    +            throw new IllegalStateException();
    
    373
    +        }
    
    374
    +
    
    375
    +        boolean isValid(int column) {
    
    376
    +            switch (column) {
    
    377
    +                case 1: // when arriving
    
    378
    +                    return validWhenArriving;
    
    379
    +                case 2: // when leaving
    
    380
    +                    return validWhenLeaving;
    
    381
    +            }
    
    382
    +            throw new IllegalStateException();
    
    383
    +        }
    
    384
    +
    
    385
    +        Optional<FloatingObjectPartsTreeNode> getSelectedCompanion(int column) {
    
    386
    +            return companions.stream().filter(n -> n.getValueAt(column) != null).findFirst();
    
    387
    +        }
    
    388
    +
    
    389
    +        public String getText() {
    
    390
    +            if (text == null && dto != null) {
    
    391
    +                text = String.format("%s [value: %s-%s] [valid: %s-%s]", dto.getLabel2(), getValueAt(1), getValueAt(2), isValid(1), isValid(2));
    
    392
    +            }
    
    393
    +            return text;
    
    394
    +        }
    
    395
    +
    
    396
    +    }
    
    398 397
     }

  • client/src/main/java/fr/ird/observe/client/ui/content/data/seine/dcp/FloatingObjectPartsTreeTableModel.java
    ... ... @@ -10,12 +10,12 @@ package fr.ird.observe.client.ui.content.data.seine.dcp;
    10 10
      * it under the terms of the GNU General Public License as
    
    11 11
      * published by the Free Software Foundation, either version 3 of the
    
    12 12
      * License, or (at your option) any later version.
    
    13
    - * 
    
    13
    + *
    
    14 14
      * This program is distributed in the hope that it will be useful,
    
    15 15
      * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    16 16
      * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    17 17
      * GNU General Public License for more details.
    
    18
    - * 
    
    18
    + *
    
    19 19
      * You should have received a copy of the GNU General Public
    
    20 20
      * License along with this program.  If not, see
    
    21 21
      * <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    ... ... @@ -32,8 +32,6 @@ import org.jdesktop.swingx.treetable.TreeTableNode;
    32 32
     import org.nuiton.i18n.I18n;
    
    33 33
     
    
    34 34
     import java.util.Arrays;
    
    35
    -import java.util.Collections;
    
    36
    -import java.util.List;
    
    37 35
     import java.util.Optional;
    
    38 36
     import java.util.stream.Collectors;
    
    39 37
     
    
    ... ... @@ -56,7 +54,7 @@ public class FloatingObjectPartsTreeTableModel extends DefaultTreeTableModel {
    56 54
         private ImmutableSet<FloatingObjectPartsTreeNode> withValidationNodes;
    
    57 55
     
    
    58 56
         public FloatingObjectPartsTreeTableModel(FloatingObjectUIModel uiModel) {
    
    59
    -        super(FloatingObjectPartsTreeNode.createRoot(uiModel, Collections.emptyList()), Arrays.asList(
    
    57
    +        super(FloatingObjectPartsTreeNode.createRoot(uiModel, null), Arrays.asList(
    
    60 58
                     I18n.t("observe.common.FloatingObjectDto.table.type"),
    
    61 59
                     I18n.t("observe.common.whenArriving"),
    
    62 60
                     I18n.t("observe.common.whenLeaving")));
    
    ... ... @@ -68,11 +66,6 @@ public class FloatingObjectPartsTreeTableModel extends DefaultTreeTableModel {
    68 66
             return (FloatingObjectPartsTreeNode) super.getRoot();
    
    69 67
         }
    
    70 68
     
    
    71
    -    public void rebuildRootNode(List<ObjectMaterialHierarchyDto> materials) {
    
    72
    -        FloatingObjectPartsTreeNode root = FloatingObjectPartsTreeNode.createRoot(uiModel, materials);
    
    73
    -        setRoot(root);
    
    74
    -    }
    
    75
    -
    
    76 69
         @Override
    
    77 70
         public void setRoot(TreeTableNode root) {
    
    78 71
             super.setRoot(root);
    
    ... ... @@ -91,6 +84,10 @@ public class FloatingObjectPartsTreeTableModel extends DefaultTreeTableModel {
    91 84
             withValidationNodes = ImmutableSet.copyOf(allNodes.stream().filter(FloatingObjectPartsTreeNode::withValidation).collect(Collectors.toSet()));
    
    92 85
         }
    
    93 86
     
    
    87
    +    public void rebuildRootNode(ObjectMaterialHierarchyDto materials) {
    
    88
    +        FloatingObjectPartsTreeNode root = FloatingObjectPartsTreeNode.createRoot(uiModel, materials);
    
    89
    +        setRoot(root);
    
    90
    +    }
    
    94 91
     
    
    95 92
         @Override
    
    96 93
         public int getColumnCount() {
    

  • persistence/src/main/resources/db/migration/7.2/01_update_objectMaterial-common.sql
    ... ... @@ -109,3 +109,4 @@ update observe_seine.objectmaterial set validation='x.length() >= 3 && x.length(
    109 109
     INSERT INTO observe_seine.objectMaterial (topiaid, topiaversion, topiacreatedate, lastupdatedate, needComment, status, legacyCode, standardCode, code, parent, label1, label2, label3, selectable, childrenMultiSelectable, childSelectionMandatory, objectMaterialType, validation, biodegradable, nonEntangling) values ('fr.ird.observe.entities.referentiel.seine.ObjectMaterial#0#1.3', 0, CURRENT_DATE, CURRENT_TIMESTAMP, false,  1, NULL, 'FOB', ''        , null , 'FOB', 'FOB', 'FOB', false, true , true, NULL, NULL, false, false);
    
    110 110
     UPDATE observe_seine.objectmaterial SET parent='fr.ird.observe.entities.referentiel.seine.ObjectMaterial#0#1.3' WHERE parent IS NULL;
    
    111 111
     UPDATE observe_seine.objectmaterial SET parent= NULL WHERE topiaid='fr.ird.observe.entities.referentiel.seine.ObjectMaterial#0#1.3';
    
    112
    +UPDATE observe_seine.objectmaterial SET SELECTABLE = TRUE WHERE parent='fr.ird.observe.entities.referentiel.seine.ObjectMaterial#0#1.3' and status = '1';
    \ No newline at end of file

  • services-local/src/main/java/fr/ird/observe/services/local/service/data/seine/FloatingObjectServiceLocal.java
    ... ... @@ -74,12 +74,11 @@ public class FloatingObjectServiceLocal extends ObserveServiceLocal implements F
    74 74
         private static final Set<String> FOB_OBSERVED_SYSTEM_EXCLUDE_OPERATIONS = ImmutableSet.of("fr.ird.observe.entities.referentiel.seine.ObjectOperation#0#10", "fr.ird.observe.entities.referentiel.seine.ObjectOperation#0#1");
    
    75 75
     
    
    76 76
         @Override
    
    77
    -    public List<ObjectMaterialHierarchyDto> getObjectMaterialHierarchy() {
    
    77
    +    public ObjectMaterialHierarchyDto getObjectMaterialHierarchy() {
    
    78 78
             ObjectMaterialTopiaDao dao = getTopiaPersistenceContext().getObjectMaterialDao();
    
    79 79
             List<ObjectMaterial> objectMaterials = dao.findAll();
    
    80 80
             objectMaterials.sort(Comparator.comparing(ObjectMaterial::getCode));
    
    81
    -        List<ObjectMaterialHierarchyDto> rootNode = getObjectMaterialHierarchyDtos(objectMaterials);
    
    82
    -        return rootNode.get(0).getChildren();
    
    81
    +        return getObjectMaterialHierarchyDtos(objectMaterials).get(0);
    
    83 82
         }
    
    84 83
     
    
    85 84
         @Override
    

  • services-local/src/test/java/fr/ird/observe/services/local/service/data/seine/FloatingObjectServiceLocalTest.java
    ... ... @@ -10,12 +10,12 @@ package fr.ird.observe.services.local.service.data.seine;
    10 10
      * it under the terms of the GNU General Public License as
    
    11 11
      * published by the Free Software Foundation, either version 3 of the
    
    12 12
      * License, or (at your option) any later version.
    
    13
    - * 
    
    13
    + *
    
    14 14
      * This program is distributed in the hope that it will be useful,
    
    15 15
      * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    16 16
      * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    17 17
      * GNU General Public License for more details.
    
    18
    - * 
    
    18
    + *
    
    19 19
      * You should have received a copy of the GNU General Public
    
    20 20
      * License along with this program.  If not, see
    
    21 21
      * <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    ... ... @@ -27,7 +27,6 @@ import fr.ird.observe.services.local.service.ServiceLocalTestSupport;
    27 27
     import fr.ird.observe.services.service.data.seine.FloatingObjectService;
    
    28 28
     import fr.ird.observe.test.DatabaseName;
    
    29 29
     import fr.ird.observe.test.spi.DatabaseNameConfiguration;
    
    30
    -import java.util.List;
    
    31 30
     import org.junit.Assert;
    
    32 31
     import org.junit.Before;
    
    33 32
     import org.junit.Test;
    
    ... ... @@ -50,9 +49,8 @@ public class FloatingObjectServiceLocalTest extends ServiceLocalTestSupport {
    50 49
         @Test
    
    51 50
         public void getObjectMaterialHierarchy() {
    
    52 51
     
    
    53
    -        List<ObjectMaterialHierarchyDto> form = service.getObjectMaterialHierarchy();
    
    52
    +        ObjectMaterialHierarchyDto form = service.getObjectMaterialHierarchy();
    
    54 53
             Assert.assertNotNull(form);
    
    55
    -        Assert.assertEquals(4, form.size());
    
    56 54
     
    
    57 55
         }
    
    58 56
     
    

  • services/src/main/java/fr/ird/observe/services/service/data/seine/FloatingObjectService.java
    ... ... @@ -40,8 +40,6 @@ import io.ultreia.java4all.http.spi.Delete;
    40 40
     import io.ultreia.java4all.http.spi.Get;
    
    41 41
     import io.ultreia.java4all.http.spi.Post;
    
    42 42
     
    
    43
    -import java.util.List;
    
    44
    -
    
    45 43
     /**
    
    46 44
      * @author Tony Chemit - dev@tchemit.fr
    
    47 45
      */
    
    ... ... @@ -49,7 +47,7 @@ public interface FloatingObjectService extends ObserveService {
    49 47
     
    
    50 48
         @Get
    
    51 49
         @ReadReferentialPermission
    
    52
    -    List<ObjectMaterialHierarchyDto> getObjectMaterialHierarchy();
    
    50
    +    ObjectMaterialHierarchyDto getObjectMaterialHierarchy();
    
    53 51
     
    
    54 52
         @Get
    
    55 53
         @ReadDataPermission
    

  • test/src/main/resources/db/7.2/dataForTestLongline.sql.gz
    No preview for this file type
  • test/src/main/resources/db/7.2/dataForTestSeine.sql.gz
    No preview for this file type
  • test/src/main/resources/db/7.2/referentiel.sql.gz
    No preview for this file type