Tony CHEMIT pushed to branch develop-7.x at ultreiaio / ird-observe
Commits:
7 changed files:
- client/src/main/java/fr/ird/observe/client/ui/actions/main/global/ChangeFocusGlobalUIAction.java
- client/src/main/java/fr/ird/observe/client/ui/actions/main/global/GlobalUIActionSupport.java
- client/src/main/java/fr/ird/observe/client/ui/content/data/seine/FloatingObjectUIHandler.java
- client/src/main/java/fr/ird/observe/client/ui/content/data/seine/FloatingObjectUIModel.java
- client/src/main/java/fr/ird/observe/client/ui/content/data/seine/dcp/FloatingObjectPartsTreeNode.java
- dto/src/main/java/fr/ird/observe/dto/referential/seine/ObjectMaterialDto.java
- persistence/src/main/java/fr/ird/observe/binder/referential/seine/ObjectMaterialEntityReferenceBinder.java
Changes:
| ... | ... | @@ -10,12 +10,12 @@ package fr.ird.observe.client.ui.actions.main.global; |
| 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>.
|
| ... | ... | @@ -24,6 +24,7 @@ package fr.ird.observe.client.ui.actions.main.global; |
| 24 | 24 |
|
| 25 | 25 |
import fr.ird.observe.client.ui.ObserveKeyStrokes;
|
| 26 | 26 |
import fr.ird.observe.client.ui.ObserveMainUI;
|
| 27 |
+import fr.ird.observe.client.ui.ObserveUIMode;
|
|
| 27 | 28 |
import fr.ird.observe.client.ui.actions.UIActionSupport;
|
| 28 | 29 |
import fr.ird.observe.client.ui.content.ContentUI;
|
| 29 | 30 |
import org.apache.commons.logging.Log;
|
| ... | ... | @@ -43,10 +44,8 @@ import java.util.Objects; |
| 43 | 44 |
*/
|
| 44 | 45 |
public class ChangeFocusGlobalUIAction extends UIActionSupport {
|
| 45 | 46 |
|
| 46 |
- /** Logger */
|
|
| 47 |
- private static final Log log = LogFactory.getLog(ChangeFocusGlobalUIAction.class);
|
|
| 48 |
- |
|
| 49 | 47 |
public static final String ACTION_NAME = ChangeFocusGlobalUIAction.class.getName();
|
| 48 |
+ private static final Log log = LogFactory.getLog(ChangeFocusGlobalUIAction.class);
|
|
| 50 | 49 |
|
| 51 | 50 |
public ChangeFocusGlobalUIAction(ObserveMainUI mainUI) {
|
| 52 | 51 |
super(mainUI, ACTION_NAME, "<NONE>", "<NONE>", null, ObserveKeyStrokes.KEY_STROKE_CHANGE_FOCUS);
|
| ... | ... | @@ -54,6 +53,9 @@ public class ChangeFocusGlobalUIAction extends UIActionSupport { |
| 54 | 53 |
|
| 55 | 54 |
@Override
|
| 56 | 55 |
public void actionPerformed(ActionEvent e) {
|
| 56 |
+ if (!Objects.equals(getMainUI().getModel().getMode(), ObserveUIMode.DB)) {
|
|
| 57 |
+ return;
|
|
| 58 |
+ }
|
|
| 57 | 59 |
boolean navigation = getMainUI().getModel().isFocusOnNavigation();
|
| 58 | 60 |
|
| 59 | 61 |
JComponent focusComponent;
|
| ... | ... | @@ -24,6 +24,7 @@ package fr.ird.observe.client.ui.actions.main.global; |
| 24 | 24 |
|
| 25 | 25 |
import fr.ird.observe.client.ObserveSwingApplicationContext;
|
| 26 | 26 |
import fr.ird.observe.client.ui.ObserveMainUI;
|
| 27 |
+import fr.ird.observe.client.ui.ObserveUIMode;
|
|
| 27 | 28 |
import fr.ird.observe.client.ui.actions.UIActionSupport;
|
| 28 | 29 |
import fr.ird.observe.client.ui.content.ContentUI;
|
| 29 | 30 |
|
| ... | ... | @@ -31,6 +32,7 @@ import javax.swing.JComponent; |
| 31 | 32 |
import javax.swing.KeyStroke;
|
| 32 | 33 |
import javax.swing.SwingUtilities;
|
| 33 | 34 |
import java.awt.event.ActionEvent;
|
| 35 |
+import java.util.Objects;
|
|
| 34 | 36 |
|
| 35 | 37 |
/**
|
| 36 | 38 |
* Created on 11/11/16.
|
| ... | ... | @@ -47,7 +49,9 @@ public abstract class GlobalUIActionSupport extends UIActionSupport { |
| 47 | 49 |
protected abstract UIActionSupport getDelegateAction(ContentUI<?, ?> contentUI);
|
| 48 | 50 |
|
| 49 | 51 |
public void actionPerformed(ActionEvent e) {
|
| 50 |
- |
|
| 52 |
+ if (!Objects.equals(getMainUI().getModel().getMode(), ObserveUIMode.DB)) {
|
|
| 53 |
+ return;
|
|
| 54 |
+ }
|
|
| 51 | 55 |
boolean focusOnNavigation = getMainUI().getModel().isFocusOnNavigation();
|
| 52 | 56 |
JComponent focusOwner = (JComponent) getMainUI().getFocusOwner();
|
| 53 | 57 |
|
| ... | ... | @@ -187,7 +187,7 @@ public class FloatingObjectUIHandler extends ContentUIHandler<FloatingObjectDto, |
| 187 | 187 |
|
| 188 | 188 |
getModel().reset();
|
| 189 | 189 |
|
| 190 |
- openTable(partsSet, getUi().getTable(),bean.isPersisted());
|
|
| 190 |
+ openTable(partsSet, getUi().getTable(), bean.isPersisted());
|
|
| 191 | 191 |
|
| 192 | 192 |
setContentMode(mode);
|
| 193 | 193 |
|
| ... | ... | @@ -263,11 +263,10 @@ public class FloatingObjectUIHandler extends ContentUIHandler<FloatingObjectDto, |
| 263 | 263 |
saveResult.toDto(bean);
|
| 264 | 264 |
|
| 265 | 265 |
ImmutableSet<FloatingObjectPartDto> parts = getModel().toParts();
|
| 266 |
- getFloatingObjectService().saveParts(saveResult.getId(), parts);
|
|
| 266 |
+ log.info(String.format("will persist %d part(s).", parts.size()));
|
|
| 267 |
+ saveResult = getFloatingObjectService().saveParts(saveResult.getId(), parts);
|
|
| 267 | 268 |
saveResult.toDto(bean);
|
| 268 |
- |
|
| 269 | 269 |
return true;
|
| 270 |
- |
|
| 271 | 270 |
}
|
| 272 | 271 |
|
| 273 | 272 |
@Override
|
| ... | ... | @@ -326,7 +325,7 @@ public class FloatingObjectUIHandler extends ContentUIHandler<FloatingObjectDto, |
| 326 | 325 |
|
| 327 | 326 |
ObjectMaterialHierarchyDto detailedForm = getFloatingObjectService().getObjectMaterialHierarchy();
|
| 328 | 327 |
|
| 329 |
- ObjectMaterialTypeReference booleanType = getReferentialReferences(ObjectMaterialTypeReference.class).stream().filter(e->e.getTopiaId().equals("fr.ird.observe.entities.referentiel.seine.ObjectMaterialType#0#0")).findFirst().orElseThrow(IllegalStateException::new);
|
|
| 328 |
+ ObjectMaterialTypeReference booleanType = getReferentialReferences(ObjectMaterialTypeReference.class).stream().filter(e -> e.getTopiaId().equals("fr.ird.observe.entities.referentiel.seine.ObjectMaterialType#0#0")).findFirst().orElseThrow(IllegalStateException::new);
|
|
| 330 | 329 |
|
| 331 | 330 |
for (ObjectMaterialHierarchyDto objectMaterialHierarchyDto : detailedForm.getChildren()) {
|
| 332 | 331 |
objectMaterialHierarchyDto.setObjectMaterialType(booleanType);
|
| ... | ... | @@ -414,6 +413,9 @@ public class FloatingObjectUIHandler extends ContentUIHandler<FloatingObjectDto, |
| 414 | 413 |
treeModel.addTreeModelListener(new TreeModelAdapter() {
|
| 415 | 414 |
@Override
|
| 416 | 415 |
public void treeNodesChanged(TreeModelEvent e) {
|
| 416 |
+ if (treeModel.isAdjusting()) {
|
|
| 417 |
+ return;
|
|
| 418 |
+ }
|
|
| 417 | 419 |
getModel().setModified(true);
|
| 418 | 420 |
getModel().setPartsModified();
|
| 419 | 421 |
}
|
| ... | ... | @@ -10,12 +10,12 @@ package fr.ird.observe.client.ui.content.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>.
|
| ... | ... | @@ -44,6 +44,7 @@ import java.util.Map; |
| 44 | 44 |
import java.util.Objects;
|
| 45 | 45 |
import java.util.Optional;
|
| 46 | 46 |
import java.util.Set;
|
| 47 |
+import java.util.stream.Collectors;
|
|
| 47 | 48 |
|
| 48 | 49 |
import static org.nuiton.i18n.I18n.t;
|
| 49 | 50 |
|
| ... | ... | @@ -55,48 +56,41 @@ import static org.nuiton.i18n.I18n.t; |
| 55 | 56 |
*/
|
| 56 | 57 |
public class FloatingObjectUIModel extends ContentUIModel<FloatingObjectDto> {
|
| 57 | 58 |
|
| 58 |
- private static final long serialVersionUID = 1L;
|
|
| 59 |
- |
|
| 60 |
- static final String PROPERTY_PARTS_MODIFIED = "partsModified";
|
|
| 61 | 59 |
public static final String PROPERTY_GENERAL_TAB_VALID = "generalTabValid";
|
| 62 |
- private static final String PROPERTY_MATERIALS_TAB_VALID = "materialsTabValid";
|
|
| 60 |
+ public static final Set<String> GENERAL_TAB_PROPERTIES =
|
|
| 61 |
+ ImmutableSet.<String>builder().add(FloatingObjectDto.PROPERTY_OBJECT_OPERATION,
|
|
| 62 |
+ FloatingObjectDto.PROPERTY_SUPPORT_VESSEL_NAME,
|
|
| 63 |
+ FloatingObjectDto.PROPERTY_COMMENT).build();
|
|
| 64 |
+ static final String PROPERTY_PARTS_MODIFIED = "partsModified";
|
|
| 63 | 65 |
static final String PROPERTY_REFERENCE = "reference";
|
| 66 |
+ static final Set<String> MATERIALS_TAB_PROPERTIES =
|
|
| 67 |
+ ImmutableSet.<String>builder().add(FloatingObjectDto.PROPERTY_COMMENT, FloatingObjectDto.PROPERTY_MATERIALS_VALID).build();
|
|
| 68 |
+ private static final long serialVersionUID = 1L;
|
|
| 69 |
+ private static final String PROPERTY_MATERIALS_TAB_VALID = "materialsTabValid";
|
|
| 64 | 70 |
private static final String PROPERTY_ARRIVING = "arriving";
|
| 65 | 71 |
private static final String PROPERTY_LEAVING = "leaving";
|
| 66 |
- |
|
| 72 |
+ /** Logger. */
|
|
| 73 |
+ private static final Log log = LogFactory.getLog(FloatingObjectUIModel.class);
|
|
| 67 | 74 |
private final ReferentialLocale referentialLocale;
|
| 68 |
- |
|
| 75 |
+ private final ReferentialDtoReferenceBinder<ObjectMaterialDto, ObjectMaterialReference> binder;
|
|
| 76 |
+ private final Map<ObjectMaterialDto, String> whenArriving;
|
|
| 77 |
+ private final Map<ObjectMaterialDto, String> whenLeaving;
|
|
| 78 |
+ protected boolean generalTabValid;
|
|
| 69 | 79 |
private Map<String, ObjectMaterialDto> referentialMap;
|
| 70 | 80 |
private FloatingObjectPreset reference;
|
| 71 | 81 |
private boolean arriving;
|
| 72 | 82 |
private boolean leaving;
|
| 73 |
- private final ReferentialDtoReferenceBinder<ObjectMaterialDto, ObjectMaterialReference> binder;
|
|
| 74 |
- |
|
| 83 |
+ private boolean materialsTabValid;
|
|
| 75 | 84 |
|
| 76 | 85 |
public FloatingObjectUIModel() {
|
| 77 | 86 |
super(FloatingObjectDto.class);
|
| 78 |
- |
|
| 79 | 87 |
ObserveSwingApplicationContext applicationContext = ObserveSwingApplicationContext.get();
|
| 80 | 88 |
this.referentialLocale = applicationContext.getDecoratorService().getReferentialLocale();
|
| 81 | 89 |
this.whenArriving = new LinkedHashMap<>();
|
| 82 | 90 |
this.whenLeaving = new LinkedHashMap<>();
|
| 83 |
- binder = DtoModelHelper.fromReferentialDto(ObjectMaterialDto.class).toReferenceBinder();
|
|
| 91 |
+ this.binder = DtoModelHelper.fromReferentialDto(ObjectMaterialDto.class).toReferenceBinder();
|
|
| 84 | 92 |
}
|
| 85 | 93 |
|
| 86 |
- public static final Set<String> GENERAL_TAB_PROPERTIES =
|
|
| 87 |
- ImmutableSet.<String>builder().add(FloatingObjectDto.PROPERTY_OBJECT_OPERATION,
|
|
| 88 |
- FloatingObjectDto.PROPERTY_SUPPORT_VESSEL_NAME,
|
|
| 89 |
- FloatingObjectDto.PROPERTY_COMMENT).build();
|
|
| 90 |
- |
|
| 91 |
- static final Set<String> MATERIALS_TAB_PROPERTIES =
|
|
| 92 |
- ImmutableSet.<String>builder().add(FloatingObjectDto.PROPERTY_COMMENT, FloatingObjectDto.PROPERTY_MATERIALS_VALID).build();
|
|
| 93 |
- |
|
| 94 |
- protected boolean generalTabValid;
|
|
| 95 |
- private boolean materialsTabValid;
|
|
| 96 |
- |
|
| 97 |
- private final Map<ObjectMaterialDto, String> whenArriving;
|
|
| 98 |
- private final Map<ObjectMaterialDto, String> whenLeaving;
|
|
| 99 |
- |
|
| 100 | 94 |
public boolean isMaterialsTabValid() {
|
| 101 | 95 |
return materialsTabValid;
|
| 102 | 96 |
}
|
| ... | ... | @@ -119,11 +113,7 @@ public class FloatingObjectUIModel extends ContentUIModel<FloatingObjectDto> { |
| 119 | 113 |
|
| 120 | 114 |
ImmutableSet<FloatingObjectPartDto> toParts() {
|
| 121 | 115 |
ImmutableSet.Builder<FloatingObjectPartDto> result = ImmutableSet.builder();
|
| 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 |
- }
|
|
| 116 |
+ for (ObjectMaterialDto o : getAllWithData()) {
|
|
| 127 | 117 |
FloatingObjectPartDto partDto = new FloatingObjectPartDto();
|
| 128 | 118 |
partDto.setObjectMaterial(binder.toReference(referentialLocale, o));
|
| 129 | 119 |
if (arriving) {
|
| ... | ... | @@ -165,10 +155,10 @@ public class FloatingObjectUIModel extends ContentUIModel<FloatingObjectDto> { |
| 165 | 155 |
return whenLeaving;
|
| 166 | 156 |
}
|
| 167 | 157 |
|
| 168 |
- public Set<ObjectMaterialDto> getAll() {
|
|
| 158 |
+ public Set<ObjectMaterialDto> getAllWithData() {
|
|
| 169 | 159 |
Set<ObjectMaterialDto> all = new LinkedHashSet<>(whenArriving.keySet());
|
| 170 | 160 |
all.addAll(whenLeaving.keySet());
|
| 171 |
- return all;
|
|
| 161 |
+ return all.stream().filter(ObjectMaterialDto::withData).collect(Collectors.toSet());
|
|
| 172 | 162 |
}
|
| 173 | 163 |
|
| 174 | 164 |
void setReferentialMap(Map<String, ObjectMaterialDto> referentialMap) {
|
| ... | ... | @@ -234,9 +224,6 @@ public class FloatingObjectUIModel extends ContentUIModel<FloatingObjectDto> { |
| 234 | 224 |
return arriving;
|
| 235 | 225 |
}
|
| 236 | 226 |
|
| 237 |
- /** Logger. */
|
|
| 238 |
- private static final Log log = LogFactory.getLog(FloatingObjectUIModel.class);
|
|
| 239 |
- |
|
| 240 | 227 |
public void setArriving(boolean arriving) {
|
| 241 | 228 |
this.arriving = arriving;
|
| 242 | 229 |
log.debug("setArriving: " + arriving);
|
| ... | ... | @@ -253,17 +240,4 @@ public class FloatingObjectUIModel extends ContentUIModel<FloatingObjectDto> { |
| 253 | 240 |
firePropertyChange(PROPERTY_LEAVING, leaving);
|
| 254 | 241 |
}
|
| 255 | 242 |
|
| 256 |
- void recomputeComputedValues() {
|
|
| 257 |
- FloatingObjectDto bean = getBean();
|
|
| 258 |
- |
|
| 259 |
- log.info("Computed values need to be recomputed.");
|
|
| 260 |
- bean.setComputedWhenArrivingBiodegradable(null);
|
|
| 261 |
- bean.setComputedWhenArrivingNonEntangling(null);
|
|
| 262 |
- bean.setComputedWhenArrivingSimplifiedObjectType(null);
|
|
| 263 |
- bean.setComputedWhenLeavingBiodegradable(null);
|
|
| 264 |
- bean.setComputedWhenLeavingNonEntangling(null);
|
|
| 265 |
- bean.setComputedWhenLeavingSimplifiedObjectType(null);
|
|
| 266 |
- fireComputedValuesChanged();
|
|
| 267 |
- }
|
|
| 268 |
- |
|
| 269 | 243 |
}
|
| ... | ... | @@ -63,9 +63,8 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im |
| 63 | 63 |
if (dto != null) {
|
| 64 | 64 |
FloatingObjectPartsTreeNodeContext childModel = new FloatingObjectPartsTreeNodeContext(dto, rootModel);
|
| 65 | 65 |
root = new FloatingObjectPartsTreeNode(childModel);
|
| 66 |
- ImmutableSet.Builder<FloatingObjectPartsTreeNode> companionsBuilder = dto.isChildrenMultiSelectable() ? ImmutableSet.builder() : null;
|
|
| 67 |
- root.computeCompanions(companionsBuilder);
|
|
| 68 |
- root.setCompanions(companionsBuilder);
|
|
| 66 |
+ root.computeCompanions(null);
|
|
| 67 |
+ root.setCompanions(null);
|
|
| 69 | 68 |
} else {
|
| 70 | 69 |
root = new FloatingObjectPartsTreeNode(rootModel);
|
| 71 | 70 |
}
|
| ... | ... | @@ -276,13 +275,19 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im |
| 276 | 275 |
companionsBuilder.add(this);
|
| 277 | 276 |
}
|
| 278 | 277 |
|
| 279 |
- ImmutableSet.Builder<FloatingObjectPartsTreeNode> childCompanionsBuilder = getUserObject().dto.isChildrenMultiSelectable() ? ImmutableSet.builder() : null;
|
|
| 278 |
+ ImmutableSet.Builder<FloatingObjectPartsTreeNode> childCompanionsBuilder = needCompanions() ? ImmutableSet.builder() : null;
|
|
| 280 | 279 |
for (FloatingObjectPartsTreeNode child : this) {
|
| 281 | 280 |
child.computeCompanions(childCompanionsBuilder);
|
| 282 | 281 |
}
|
| 283 | 282 |
setCompanions(childCompanionsBuilder);
|
| 284 | 283 |
}
|
| 285 | 284 |
|
| 285 |
+ |
|
| 286 |
+ private boolean needCompanions() {
|
|
| 287 |
+ ObjectMaterialHierarchyDto dto = getUserObject().dto;
|
|
| 288 |
+ return dto != null && !dto.isChildrenMultiSelectable() && !isLeaf();
|
|
| 289 |
+ }
|
|
| 290 |
+ |
|
| 286 | 291 |
private static class FloatingObjectPartsTreeNodeContext {
|
| 287 | 292 |
|
| 288 | 293 |
// main model to get and store values
|
| ... | ... | @@ -334,7 +339,7 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im |
| 334 | 339 |
// mandatory if enabled parent is so or parent makes this child to be
|
| 335 | 340 |
this.mandatory = parent.mandatory || parent.needOneSelection;
|
| 336 | 341 |
// exclusive if his parent requires it
|
| 337 |
- this.exclusive = parent.dto != null && parent.dto.isChildrenMultiSelectable();
|
|
| 342 |
+ this.exclusive = parent.dto != null && !parent.dto.isChildrenMultiSelectable();
|
|
| 338 | 343 |
log.info(String.format("New node: %s - mandatory %s - needOneSelection %s - exclusive %s", dto.getLabel2(), mandatory, needOneSelection, exclusive));
|
| 339 | 344 |
}
|
| 340 | 345 |
|
| ... | ... | @@ -10,19 +10,18 @@ package fr.ird.observe.dto.referential.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>.
|
| 22 | 22 |
* #L%
|
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 |
-import fr.ird.observe.dto.referential.FormulaHelper;
|
|
| 26 | 25 |
import org.apache.commons.lang3.StringUtils;
|
| 27 | 26 |
|
| 28 | 27 |
public class ObjectMaterialDto extends GeneratedObjectMaterialDto {
|
| ... | ... | @@ -45,14 +44,15 @@ public class ObjectMaterialDto extends GeneratedObjectMaterialDto { |
| 45 | 44 |
return objectMaterialType != null && "fr.ird.observe.entities.referentiel.seine.ObjectMaterialType#0#1".equals(objectMaterialType.getId());
|
| 46 | 45 |
}
|
| 47 | 46 |
|
| 48 |
- @Override
|
|
| 49 |
- public void setValidation(String validation) {
|
|
| 50 |
- super.setValidation(validation);
|
|
| 51 |
- boolean result = FormulaHelper.validateObjectMaterialValidation(validation, 10);
|
|
| 52 |
- setValidationValid(result);
|
|
| 53 |
- }
|
|
| 54 |
- |
|
| 55 | 47 |
public boolean withValidation() {
|
| 56 | 48 |
return StringUtils.isNoneEmpty(validation);
|
| 57 | 49 |
}
|
| 50 |
+ |
|
| 51 |
+ /**
|
|
| 52 |
+ * @return {code true} if node contains no data to persist, {@code false} otherwise.
|
|
| 53 |
+ */
|
|
| 54 |
+ public boolean withData() {
|
|
| 55 |
+ ObjectMaterialReference parent = getParent();
|
|
| 56 |
+ return parent != null && parent.getParentId() != null;
|
|
| 57 |
+ }
|
|
| 58 | 58 |
}
|
| ... | ... | @@ -45,7 +45,7 @@ public class ObjectMaterialEntityReferenceBinder extends ReferentialEntityRefere |
| 45 | 45 |
@Override
|
| 46 | 46 |
public ObjectMaterialReference toReference(ReferentialLocale referentialLocale, ObjectMaterial dto) {
|
| 47 | 47 |
return new ObjectMaterialReference(dto, dto.getCode(), dto.getLabel(referentialLocale),
|
| 48 |
- Optional.ofNullable(dto.getParent()).map(ObjectMaterial::getParent).map(TopiaEntity::getTopiaId).orElse(null),
|
|
| 48 |
+ Optional.ofNullable(dto.getParent()).map(TopiaEntity::getTopiaId).orElse(null),
|
|
| 49 | 49 |
Optional.ofNullable(dto.getObjectMaterialType()).map(TopiaEntity::getTopiaId).orElse(null),
|
| 50 | 50 |
dto.getValidation(),
|
| 51 | 51 |
dto.isBiodegradable(),
|