Tony CHEMIT pushed to branch develop-7.x at ultreiaio / ird-observe Commits: ba747f4c by tchemit at 2018-11-23T12:32:45Z Question calculs biodégradable, nonentangling et type simplifié à l'arrivée et au départ - Closes #1177 - - - - - e73b7d6d by tchemit at 2018-11-23T12:32:45Z [PS] Libération faune accessoire -> Exception - Closes #1174 - - - - - 6 changed files: - client-core/src/main/java/fr/ird/observe/client/ui/content/ContentUIHandler.java - client-core/src/main/java/fr/ird/observe/client/ui/content/ContentUIModel.java - client-core/src/main/java/fr/ird/observe/client/ui/content/table/ContentTableUIHandler.java - client-core/src/main/java/fr/ird/observe/client/ui/content/table/ContentTableUIModel.java - services/src/main/java/fr/ird/observe/services/service/actions/consolidate/dcp/ConsolidateFloatingObjectResultBuilder.java - services/src/main/java/fr/ird/observe/services/service/actions/consolidate/dcp/FloatingObjectConsolidateEngine.java Changes: ===================================== client-core/src/main/java/fr/ird/observe/client/ui/content/ContentUIHandler.java ===================================== @@ -179,7 +179,7 @@ public abstract class ContentUIHandler<E extends IdDto, U extends ContentUI<E, U if (model.isCreatingMode()) { // on peut quitter le mode creation si le modele est non modifie et valide - if (!(model.isEnabled() && model.isEditing() && (model.isModified() || !model.isValid()))) { + if (!(model.isEnabled() && model.isEditing() && (model.isGlobalModified() || !model.isValid()))) { if (model.isEditing()) { ui.stopEdit(); } @@ -189,8 +189,8 @@ public abstract class ContentUIHandler<E extends IdDto, U extends ContentUI<E, U } } else { - // on peut quiiter le mode mise a jour si le modele est non modifie - if (!(model.isEnabled() && model.isEditing() && model.isModified())) { + // on peut quitter le mode mise a jour si le modele est non modifie + if (!(model.isEnabled() && model.isEditing() && model.isGlobalModified())) { if (model.isEditing()) { ui.stopEdit(); } ===================================== client-core/src/main/java/fr/ird/observe/client/ui/content/ContentUIModel.java ===================================== @@ -230,6 +230,9 @@ public abstract class ContentUIModel<E extends IdDto> extends AbstractSerializab return modified; } + public boolean isGlobalModified() { + return isModified(); + } public void setModified(boolean modified) { Object oldValue = this.modified; this.modified = modified; ===================================== client-core/src/main/java/fr/ird/observe/client/ui/content/table/ContentTableUIHandler.java ===================================== @@ -40,8 +40,8 @@ import fr.ird.observe.dto.data.seine.ActivitySeineDto; import fr.ird.observe.dto.data.seine.TargetCatchDto; import fr.ird.observe.dto.referential.SpeciesReference; import fr.ird.observe.dto.referential.seine.WeightCategoryReference; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.nuiton.validator.NuitonValidatorScope; import javax.swing.JButton; @@ -331,6 +331,12 @@ public abstract class ContentTableUIHandler<E extends IdDto, D extends IdDto, U U ui = getUi(); + if (getModel().isModified() || getModel().isCanSaveRow()) { + + // flush modified line to model + getTableModel().updateRowFromEditBean(); + } + List<D> objets = ui.getTableModel().getData(); boolean canContinue; ===================================== client-core/src/main/java/fr/ird/observe/client/ui/content/table/ContentTableUIModel.java ===================================== @@ -6,15 +6,15 @@ * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the + * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public + * + * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% @@ -25,8 +25,8 @@ import fr.ird.observe.client.ObserveSwingTechnicalException; import fr.ird.observe.client.ui.content.ContentUIModel; import fr.ird.observe.dto.IdDto; import org.apache.commons.lang3.reflect.ConstructorUtils; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.nuiton.util.beans.BinderModelBuilder; import javax.swing.DefaultListSelectionModel; @@ -165,6 +165,10 @@ public abstract class ContentTableUIModel<E extends IdDto, D extends IdDto> exte } } + public boolean isGlobalModified() { + return super.isGlobalModified() || getTableModel().isModified() || isCanSaveRow(); + } + public boolean isCanSaveRow() { return canSaveRow; } ===================================== services/src/main/java/fr/ird/observe/services/service/actions/consolidate/dcp/ConsolidateFloatingObjectResultBuilder.java ===================================== @@ -70,20 +70,20 @@ public class ConsolidateFloatingObjectResultBuilder { } case FloatingObjectDto.PROPERTY_COMPUTED_WHEN_LEAVING_BIODEGRADABLE: { - FloatingObjectModification element = new FloatingObjectModification(dcp.getId(), modifiedProperty, dcp.getComputedWhenArrivingBiodegradable()); + FloatingObjectModification element = new FloatingObjectModification(dcp.getId(), modifiedProperty, dcp.getComputedWhenLeavingBiodegradable()); modificationsBuilder.add(element); break; } case FloatingObjectDto.PROPERTY_COMPUTED_WHEN_LEAVING_NON_ENTANGLING: { - FloatingObjectModification element = new FloatingObjectModification(dcp.getId(), FloatingObjectDto.PROPERTY_COMPUTED_WHEN_LEAVING_NON_ENTANGLING, dcp.getComputedWhenLeavingNonEntangling()); + FloatingObjectModification element = new FloatingObjectModification(dcp.getId(), modifiedProperty, dcp.getComputedWhenLeavingNonEntangling()); modificationsBuilder.add(element); break; } case FloatingObjectDto.PROPERTY_COMPUTED_WHEN_LEAVING_SIMPLIFIED_OBJECT_TYPE: { - FloatingObjectModification element = new FloatingObjectModification(dcp.getId(), FloatingObjectDto.PROPERTY_COMPUTED_WHEN_LEAVING_SIMPLIFIED_OBJECT_TYPE, dcp.getComputedWhenLeavingSimplifiedObjectType()); + FloatingObjectModification element = new FloatingObjectModification(dcp.getId(), modifiedProperty, dcp.getComputedWhenLeavingSimplifiedObjectType()); modificationsBuilder.add(element); break; } ===================================== services/src/main/java/fr/ird/observe/services/service/actions/consolidate/dcp/FloatingObjectConsolidateEngine.java ===================================== @@ -122,19 +122,20 @@ public class FloatingObjectConsolidateEngine { } private DcpComputedValue computeDcpBiodegradable0(Set<FloatingObjectPartDto> FloatingObjectPartDtos) { - DcpComputedValue result = DcpComputedValue.UNKNOWN; - if (!FloatingObjectPartDtos.isEmpty()) { - for (FloatingObjectPartDto FloatingObjectPartDto : FloatingObjectPartDtos) { - Boolean biodegradable = FloatingObjectPartDto.getObjectMaterial().getBiodegradable(); - if (biodegradable==null) { - continue; - } - if (!biodegradable) { - result = DcpComputedValue.FALSE; - break; - } - result = DcpComputedValue.TRUE; + if (FloatingObjectPartDtos.isEmpty()) { + return null; + } + DcpComputedValue result = DcpComputedValue.UNKNOWN; + for (FloatingObjectPartDto FloatingObjectPartDto : FloatingObjectPartDtos) { + Boolean biodegradable = FloatingObjectPartDto.getObjectMaterial().getBiodegradable(); + if (biodegradable==null) { + continue; + } + if (!biodegradable) { + result = DcpComputedValue.FALSE; + break; } + result = DcpComputedValue.TRUE; } return result; } @@ -148,19 +149,20 @@ public class FloatingObjectConsolidateEngine { } private DcpComputedValue computeDcpNonEntangling0(Set<FloatingObjectPartDto> FloatingObjectPartDtos) { + if (FloatingObjectPartDtos.isEmpty()) { + return null; + } DcpComputedValue result = DcpComputedValue.UNKNOWN; - if (!FloatingObjectPartDtos.isEmpty()) { - for (FloatingObjectPartDto FloatingObjectPartDto : FloatingObjectPartDtos) { - Boolean nonEntangling = FloatingObjectPartDto.getObjectMaterial().getNonEntangling(); - if (nonEntangling==null) { - continue; - } - if (!nonEntangling) { - result = DcpComputedValue.FALSE; - break; - } - result = DcpComputedValue.TRUE; + for (FloatingObjectPartDto FloatingObjectPartDto : FloatingObjectPartDtos) { + Boolean nonEntangling = FloatingObjectPartDto.getObjectMaterial().getNonEntangling(); + if (nonEntangling==null) { + continue; + } + if (!nonEntangling) { + result = DcpComputedValue.FALSE; + break; } + result = DcpComputedValue.TRUE; } return result; } View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/compare/6598bbc95d923fab443751f72f2... -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/compare/6598bbc95d923fab443751f72f2... You're receiving this email because of your account on gitlab.com.