Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
5e5a84e2
by Tony Chemit at 2022-06-06T17:49:46+02:00
6 changed files:
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/ropen/ContentRootOpenableUINavigationNode.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/ropen/actions/SaveContentRootOpenableUIAdapter.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/navigation/tree/NavigationNode.java
- client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/common/TripUIModelStates.java
- + core/persistence/java/src/main/java/fr/ird/observe/entities/data/ps/localmarket/SampleSampleSpeciesSpi.java
- core/persistence/java/src/main/java/fr/ird/observe/entities/data/ps/localmarket/SurveySpi.java
Changes:
| ... | ... | @@ -24,11 +24,8 @@ package fr.ird.observe.client.datasource.editor.api.content.data.ropen; |
| 24 | 24 | |
| 25 | 25 | import fr.ird.observe.client.datasource.editor.api.content.data.rlist.ContentRootListUINavigationNode;
|
| 26 | 26 | import fr.ird.observe.client.datasource.editor.api.navigation.tree.NavigationNode;
|
| 27 | -import fr.ird.observe.client.datasource.editor.api.navigation.tree.capability.ReferenceContainerCapability;
|
|
| 28 | 27 | import fr.ird.observe.dto.data.DataGroupByDto;
|
| 29 | 28 | import fr.ird.observe.dto.reference.DataDtoReference;
|
| 30 | -import org.apache.logging.log4j.LogManager;
|
|
| 31 | -import org.apache.logging.log4j.Logger;
|
|
| 32 | 29 | |
| 33 | 30 | import java.awt.Font;
|
| 34 | 31 | import java.util.function.Supplier;
|
| ... | ... | @@ -40,7 +37,6 @@ import java.util.function.Supplier; |
| 40 | 37 | * @since 8.0.1
|
| 41 | 38 | */
|
| 42 | 39 | public abstract class ContentRootOpenableUINavigationNode extends NavigationNode {
|
| 43 | - private static final Logger log = LogManager.getLogger(ContentRootOpenableUINavigationNode.class);
|
|
| 44 | 40 | |
| 45 | 41 | public static <N extends ContentRootOpenableUINavigationNode> N init(N node, Supplier<? extends DataGroupByDto<?>> parentReference, DataDtoReference reference) {
|
| 46 | 42 | ContentRootOpenableUINavigationInitializer initializer = new ContentRootOpenableUINavigationInitializer(node.getScope(), parentReference, reference);
|
| ... | ... | @@ -81,37 +77,6 @@ public abstract class ContentRootOpenableUINavigationNode extends NavigationNode |
| 81 | 77 | return getInitializer().getParentReference();
|
| 82 | 78 | }
|
| 83 | 79 | |
| 84 | - public void updateReference(String id) {
|
|
| 85 | - boolean notPersisted = getInitializer().isNotPersisted();
|
|
| 86 | - NavigationNode parent = getParent();
|
|
| 87 | - int oldPosition = parent.getIndex(this);
|
|
| 88 | - DataDtoReference reference = getInitializer().updateReference(getContext(), id);
|
|
| 89 | - if (notPersisted) {
|
|
| 90 | - getInitializer().updateEditNodeId(id);
|
|
| 91 | - getInitializer().updateSelectNodeId(id);
|
|
| 92 | - }
|
|
| 93 | - // reload node data
|
|
| 94 | - reloadNodeData();
|
|
| 95 | - |
|
| 96 | - if (notPersisted) {
|
|
| 97 | - dirty();
|
|
| 98 | - populateChildrenIfNotLoaded();
|
|
| 99 | - }
|
|
| 100 | - |
|
| 101 | - ReferenceContainerCapability<?> capability = (ReferenceContainerCapability<?>) parent.getCapability();
|
|
| 102 | - int newPosition = capability.getNodePosition(reference);
|
|
| 103 | - if (oldPosition != newPosition) {
|
|
| 104 | - log.info(String.format("Move node from: %d to %d", oldPosition, newPosition));
|
|
| 105 | - parent.moveNode(this, newPosition);
|
|
| 106 | - }
|
|
| 107 | - |
|
| 108 | - // repaint selected node and his children
|
|
| 109 | - nodeChangedDeep();
|
|
| 110 | - |
|
| 111 | - // reload from parent to root
|
|
| 112 | - parent.reloadNodeDataToRoot();
|
|
| 113 | - }
|
|
| 114 | - |
|
| 115 | 80 | @Override
|
| 116 | 81 | public Font getNodeFont(Font defaultFont) {
|
| 117 | 82 | if (getInitializer().isOpen()) {
|
| ... | ... | @@ -29,7 +29,12 @@ 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.ContentRootOpenableUINavigationNode;
|
| 30 | 30 | import fr.ird.observe.client.datasource.editor.api.navigation.NavigationTree;
|
| 31 | 31 | import fr.ird.observe.client.datasource.editor.api.navigation.NavigationUIHandler;
|
| 32 | +import fr.ird.observe.client.datasource.editor.api.navigation.tree.NavigationNode;
|
|
| 33 | +import fr.ird.observe.client.datasource.editor.api.navigation.tree.capability.ReferenceContainerCapability;
|
|
| 32 | 34 | import fr.ird.observe.dto.data.RootOpenableDto;
|
| 35 | +import fr.ird.observe.dto.reference.DataDtoReference;
|
|
| 36 | +import org.apache.logging.log4j.LogManager;
|
|
| 37 | +import org.apache.logging.log4j.Logger;
|
|
| 33 | 38 | |
| 34 | 39 | /**
|
| 35 | 40 | * Created on 16/10/2020.
|
| ... | ... | @@ -39,6 +44,8 @@ import fr.ird.observe.dto.data.RootOpenableDto; |
| 39 | 44 | */
|
| 40 | 45 | public class SaveContentRootOpenableUIAdapter<D extends RootOpenableDto, U extends ContentRootOpenableUI<D, U>> implements SaveUIAdapter<D, U> {
|
| 41 | 46 | |
| 47 | + private static final Logger log = LogManager.getLogger(SaveContentRootOpenableUIAdapter.class);
|
|
| 48 | + |
|
| 42 | 49 | @Override
|
| 43 | 50 | public final void adaptUi(DataSourceEditor dataSourceEditor, U ui, boolean notPersisted, D bean) {
|
| 44 | 51 | |
| ... | ... | @@ -48,7 +55,7 @@ public class SaveContentRootOpenableUIAdapter<D extends RootOpenableDto, U exten |
| 48 | 55 | ContentRootOpenableUINavigationNode node = model.getSource();
|
| 49 | 56 | // We need to inject ot node the new reference (it could does not know the id if not persisted)
|
| 50 | 57 | // As I prefer to use a unique code (for persisted or not, keep it like this)
|
| 51 | - node.updateReference(bean.getId());
|
|
| 58 | + updateReference(node, bean.getId());
|
|
| 52 | 59 | |
| 53 | 60 | NavigationTree tree = dataSourceEditor.getNavigationUI().getTree();
|
| 54 | 61 | tree.reSelectSafeNode(node);
|
| ... | ... | @@ -63,4 +70,36 @@ public class SaveContentRootOpenableUIAdapter<D extends RootOpenableDto, U exten |
| 63 | 70 | }
|
| 64 | 71 | NavigationUIHandler.updateStatistics(dataSourceEditor.getNavigationUI(), 0, 1);
|
| 65 | 72 | }
|
| 73 | + |
|
| 74 | + |
|
| 75 | + public void updateReference(ContentRootOpenableUINavigationNode node , String id) {
|
|
| 76 | + boolean notPersisted = node.getInitializer().isNotPersisted();
|
|
| 77 | + NavigationNode parent = node.getParent();
|
|
| 78 | + int oldPosition = parent.getIndex(node);
|
|
| 79 | + DataDtoReference reference = node.getInitializer().updateReference(node.getContext(), id);
|
|
| 80 | + if (notPersisted) {
|
|
| 81 | + node.getInitializer().updateEditNodeId(id);
|
|
| 82 | + node.getInitializer().updateSelectNodeId(id);
|
|
| 83 | + }
|
|
| 84 | + // reload node data
|
|
| 85 | + node.reloadNodeDataAndChildren();
|
|
| 86 | + |
|
| 87 | + if (notPersisted) {
|
|
| 88 | + node.dirty();
|
|
| 89 | + node.populateChildrenIfNotLoaded();
|
|
| 90 | + }
|
|
| 91 | + |
|
| 92 | + ReferenceContainerCapability<?> capability = (ReferenceContainerCapability<?>) parent.getCapability();
|
|
| 93 | + int newPosition = capability.getNodePosition(reference);
|
|
| 94 | + if (oldPosition != newPosition) {
|
|
| 95 | + log.info(String.format("Move node from: %d to %d", oldPosition, newPosition));
|
|
| 96 | + parent.moveNode(node, newPosition);
|
|
| 97 | + }
|
|
| 98 | + |
|
| 99 | + // repaint selected node and his children
|
|
| 100 | + node.nodeChangedDeep();
|
|
| 101 | + |
|
| 102 | + // reload from parent to root
|
|
| 103 | + parent.reloadNodeDataToRoot();
|
|
| 104 | + }
|
|
| 66 | 105 | } |
| ... | ... | @@ -358,6 +358,23 @@ public abstract class NavigationNode extends DefaultMutableTreeNode implements W |
| 358 | 358 | }
|
| 359 | 359 | }
|
| 360 | 360 | |
| 361 | + public void reloadNodeDataAndChildren() {
|
|
| 362 | + dirty();
|
|
| 363 | + Object userObject = getContext().reload();
|
|
| 364 | + setUserObject(userObject);
|
|
| 365 | + loaded();
|
|
| 366 | + Enumeration<?> children = children();
|
|
| 367 | + while (children.hasMoreElements()) {
|
|
| 368 | + NavigationNode childNode = (NavigationNode) children.nextElement();
|
|
| 369 | + if (childNode.isLoaded()) {
|
|
| 370 | + childNode.updateNode();
|
|
| 371 | + } else {
|
|
| 372 | + Object childrenUserObject = childNode.getContext().reload();
|
|
| 373 | + childNode.setUserObject(childrenUserObject);
|
|
| 374 | + }
|
|
| 375 | + }
|
|
| 376 | + }
|
|
| 377 | + |
|
| 361 | 378 | public void updateSelectNodeId() {
|
| 362 | 379 | if (getScope().isSelectNode()) {
|
| 363 | 380 | ReferenceCapability<?> capability = (ReferenceCapability<?>) getCapability();
|
| ... | ... | @@ -229,9 +229,6 @@ public class TripUIModelStates extends GeneratedTripUIModelStates { |
| 229 | 229 | }
|
| 230 | 230 | |
| 231 | 231 | private void onLandingHarbourChanged(PropertyChangeEvent event) {
|
| 232 | - if (!isOpened() || isReadingMode()) {
|
|
| 233 | - return;
|
|
| 234 | - }
|
|
| 235 | 232 | HarbourReference newValue = (HarbourReference) event.getNewValue();
|
| 236 | 233 | boolean localMarketPossible = newValue != null && harbourWithPackaging.contains(newValue);
|
| 237 | 234 | setLocalmarketPossible(localMarketPossible);
|
| 1 | +package fr.ird.observe.entities.data.ps.localmarket;
|
|
| 2 | + |
|
| 3 | +/*-
|
|
| 4 | + * #%L
|
|
| 5 | + * ObServe Core :: Persistence :: Java
|
|
| 6 | + * %%
|
|
| 7 | + * Copyright (C) 2008 - 2022 IRD, Ultreia.io
|
|
| 8 | + * %%
|
|
| 9 | + * This program is free software: you can redistribute it and/or modify
|
|
| 10 | + * it under the terms of the GNU General Public License as
|
|
| 11 | + * published by the Free Software Foundation, either version 3 of the
|
|
| 12 | + * License, or (at your option) any later version.
|
|
| 13 | + *
|
|
| 14 | + * This program is distributed in the hope that it will be useful,
|
|
| 15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
| 16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
| 17 | + * GNU General Public License for more details.
|
|
| 18 | + *
|
|
| 19 | + * You should have received a copy of the GNU General Public
|
|
| 20 | + * License along with this program. If not, see
|
|
| 21 | + * <http://www.gnu.org/licenses/gpl-3.0.html>.
|
|
| 22 | + * #L%
|
|
| 23 | + */
|
|
| 24 | + |
|
| 25 | +import fr.ird.observe.spi.result.AddEntityToUpdateStep;
|
|
| 26 | + |
|
| 27 | +public class SampleSampleSpeciesSpi extends GeneratedSampleSampleSpeciesSpi {
|
|
| 28 | + @Override
|
|
| 29 | + public void saveCallback(AddEntityToUpdateStep saveHelper, Sample entity) {
|
|
| 30 | + super.saveCallback(saveHelper, entity);
|
|
| 31 | + entity.getSampleSpecies().forEach(c -> saveHelper.updateCollection(SampleSpeciesMeasure.SPI, c.getSampleSpeciesMeasure(), false));
|
|
| 32 | + }
|
|
| 33 | +} |
| ... | ... | @@ -28,6 +28,7 @@ import fr.ird.observe.dto.data.ps.localmarket.SurveyDto; |
| 28 | 28 | import fr.ird.observe.dto.form.Form;
|
| 29 | 29 | import fr.ird.observe.dto.referential.ReferentialLocale;
|
| 30 | 30 | import fr.ird.observe.entities.data.ps.common.Trip;
|
| 31 | +import fr.ird.observe.spi.result.AddEntityToUpdateStep;
|
|
| 31 | 32 | import fr.ird.observe.spi.service.ServiceContext;
|
| 32 | 33 | |
| 33 | 34 | import java.util.Collection;
|
| ... | ... | @@ -92,6 +93,12 @@ public class SurveySpi extends GeneratedSurveySpi { |
| 92 | 93 | // //FIXME Copy missing meta-data to new parent?
|
| 93 | 94 | // }
|
| 94 | 95 | |
| 96 | + |
|
| 97 | + @Override
|
|
| 98 | + public void saveCallback(AddEntityToUpdateStep saveHelper, Survey entity) {
|
|
| 99 | + saveHelper.updateCollection(SurveyPart.SPI, entity.getSurveyPart());
|
|
| 100 | + }
|
|
| 101 | + |
|
| 95 | 102 | public void fillFormObject(ReferentialLocale referentialLocale, Trip trip, Survey survey, Form<SurveyDto> form) {
|
| 96 | 103 | Collection<Batch> availableBatches = new LinkedList<>();
|
| 97 | 104 | Collection<Batch> selectedBatches = new LinkedList<>();
|