Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
54f1e72c
by Tony Chemit at 2023-02-15T15:05:28+01:00
17 changed files:
- client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/dcp/DcpUIModelStates.java
- client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/localmarket/TripBatchUIModelStates.java
- core/api/dto/src/main/java/fr/ird/observe/dto/ProtectedIdsPs.java
- core/api/dto/src/main/java/fr/ird/observe/dto/data/ps/dcp/consolidate/FloatingObjectConsolidateEngine.java
- core/api/dto/src/main/java/fr/ird/observe/dto/data/ps/dcp/consolidate/FloatingObjectConsolidateResult.java
- − core/api/dto/src/main/java/fr/ird/observe/dto/data/ps/dcp/consolidate/FloatingObjectResultConsolidateBuilder.java
- core/api/dto/src/main/java/fr/ird/observe/dto/data/ps/localmarket/consolidate/BatchConsolidateResult.java
- core/api/dto/src/main/java/fr/ird/observe/dto/data/ps/observation/consolidate/ActivityConsolidateResult.java
- − core/api/dto/src/main/java/fr/ird/observe/dto/data/ps/observation/consolidate/CatchModification.java
- − core/api/dto/src/main/java/fr/ird/observe/dto/data/ps/observation/consolidate/SampleMeasureModification.java
- core/persistence/java/src/main/java/fr/ird/observe/entities/data/ps/common/TripConsolidateEngine.java
- core/persistence/java/src/main/java/fr/ird/observe/entities/data/ps/observation/ActivityConsolidateContext.java
- core/persistence/java/src/main/java/fr/ird/observe/entities/data/ps/observation/ActivityConsolidateResultBuilder.java
- core/services/test/src/main/java/fr/ird/observe/services/service/data/ps/ConsolidateDataServiceFixtures.java
- toolkit/api/src/main/java/fr/ird/observe/dto/DtoPropertyModifications.java
- toolkit/api/src/main/java/fr/ird/observe/dto/DtoPropertyModification.java → toolkit/api/src/main/java/fr/ird/observe/dto/JavaBeanPropertyModification.java
- toolkit/api/src/main/java/fr/ird/observe/spi/json/toolkit/DtoPropertyModificationAdapter.java → toolkit/api/src/main/java/fr/ird/observe/spi/json/toolkit/JavaBeanPropertyModificationAdapter.java
Changes:
| ... | ... | @@ -100,8 +100,8 @@ public interface DcpUIModelStates<D extends DataDto & FloatingObjectAware, P ext |
| 100 | 100 | default void recomputeComputedValues() {
|
| 101 | 101 | Optional<FloatingObjectConsolidateResult> result = consolidate(getConsolidateEngine());
|
| 102 | 102 | result.ifPresent(r -> {
|
| 103 | - log.info("Flush " + r.getFloatingObjectModifications().size() + " consolidate dcp changes...");
|
|
| 104 | - r.flushToDto(getBean());
|
|
| 103 | + log.info("Flush " + r.getModifications().size() + " consolidate dcp changes...");
|
|
| 104 | + r.flushToBean(getBean());
|
|
| 105 | 105 | fireComputedValuesChanged();
|
| 106 | 106 | });
|
| 107 | 107 | }
|
| ... | ... | @@ -104,7 +104,7 @@ public class TripBatchUIModelStates extends GeneratedTripBatchUIModelStates { |
| 104 | 104 | BatchConsolidateResult result = psConsolidateDataService.consolidateLocalmarketBatch(request);
|
| 105 | 105 | if (result != null) {
|
| 106 | 106 | log.info("Flush consolidate batch changes...");
|
| 107 | - result.flushToDto(getTableEditBean());
|
|
| 107 | + result.flushToBean(getTableEditBean());
|
|
| 108 | 108 | String lengthWeightParameterNotFound = result.getLengthWeightParameterNotFound();
|
| 109 | 109 | if (lengthWeightParameterNotFound != null) {
|
| 110 | 110 | log.warn(lengthWeightParameterNotFound);
|
| ... | ... | @@ -77,4 +77,7 @@ public interface ProtectedIdsPs { |
| 77 | 77 | String PS_LOGBOOK_SAMPLE_DEFAULT_SAMPLE_QUALITY_ID = "fr.ird.referential.ps.logbook.SampleQuality#1464000000000#01";
|
| 78 | 78 | Set<String> PS_LOGBOOK_CATCH_SPECIES_FATES = Set.of("fr.ird.referential.ps.common.SpeciesFate#1239832683619#0.5722739932065866", "fr.ird.referential.ps.common.SpeciesFate#1501492537510#0.9210847837998154");
|
| 79 | 79 | String PS_LOCAL_MARKET_SAMPLE_DEFAULT_SAMPLE_TYPE_ID = "fr.ird.referential.ps.common.SampleType#1464000000000#01";
|
| 80 | + String PS_LOCAL_MARKET_BATCH_WEIGHT_TYPE_WEIGHING = "fr.ird.referential.ps.localmarket.BatchWeightType#1464000000000#01";
|
|
| 81 | + String PS_LOCAL_MARKET_BATCH_WEIGHT_TYPE_SINGLE_SPECIES_INDIVIDUAL = "fr.ird.referential.ps.localmarket.BatchWeightType#1464000000000#02";
|
|
| 82 | + String PS_LOCAL_MARKET_BATCH_WEIGHT_TYPE_PACKAGING_NOT_WEIGHTED = "fr.ird.referential.ps.localmarket.BatchWeightType#1464000000000#03";
|
|
| 80 | 83 | } |
| ... | ... | @@ -28,7 +28,6 @@ import fr.ird.observe.dto.data.ps.FloatingObjectAware; |
| 28 | 28 | import fr.ird.observe.dto.data.ps.FloatingObjectPartAware;
|
| 29 | 29 | import fr.ird.observe.dto.data.ps.dcp.SimplifiedObjectTypeManager;
|
| 30 | 30 | import fr.ird.observe.dto.data.ps.observation.FloatingObjectDto;
|
| 31 | -import fr.ird.observe.dto.data.ps.observation.consolidate.FloatingObjectConsolidateRequest;
|
|
| 32 | 31 | import io.ultreia.java4all.bean.monitor.BeanMonitor;
|
| 33 | 32 | |
| 34 | 33 | import java.util.Optional;
|
| ... | ... | @@ -47,12 +46,12 @@ public class FloatingObjectConsolidateEngine { |
| 47 | 46 | |
| 48 | 47 | private static class FloatingObjectConsolidateContext {
|
| 49 | 48 | |
| 50 | - final FloatingObjectResultConsolidateBuilder resultBuilder;
|
|
| 51 | - final BeanMonitor dcpMonitor;
|
|
| 49 | + final FloatingObjectConsolidateResult.Builder resultBuilder;
|
|
| 50 | + final BeanMonitor monitor;
|
|
| 52 | 51 | |
| 53 | - FloatingObjectConsolidateContext(FloatingObjectResultConsolidateBuilder resultBuilder) {
|
|
| 54 | - this.resultBuilder = resultBuilder;
|
|
| 55 | - dcpMonitor = new BeanMonitor(
|
|
| 52 | + FloatingObjectConsolidateContext(FloatingObjectConsolidateResult.Builder builder) {
|
|
| 53 | + this.resultBuilder = builder;
|
|
| 54 | + this.monitor = new BeanMonitor(
|
|
| 56 | 55 | FloatingObjectDto.PROPERTY_COMPUTED_WHEN_ARRIVING_BIODEGRADABLE,
|
| 57 | 56 | FloatingObjectDto.PROPERTY_COMPUTED_WHEN_ARRIVING_NON_ENTANGLING,
|
| 58 | 57 | FloatingObjectDto.PROPERTY_COMPUTED_WHEN_ARRIVING_SIMPLIFIED_OBJECT_TYPE,
|
| ... | ... | @@ -62,17 +61,15 @@ public class FloatingObjectConsolidateEngine { |
| 62 | 61 | );
|
| 63 | 62 | }
|
| 64 | 63 | |
| 65 | - |
|
| 66 | - void watchDcp(DataDto dcp) {
|
|
| 67 | - dcpMonitor.setBean(dcp);
|
|
| 64 | + void watch(DataDto floatingObject) {
|
|
| 65 | + monitor.setBean(floatingObject);
|
|
| 68 | 66 | }
|
| 69 | 67 | |
| 70 | - void flushDcp() {
|
|
| 71 | - if (dcpMonitor.wasModified()) {
|
|
| 72 | - DataDto dcp = (DataDto) dcpMonitor.getBean();
|
|
| 73 | - resultBuilder.flushDcpModification(dcp, dcpMonitor.getModifiedProperties());
|
|
| 68 | + void flush() {
|
|
| 69 | + if (monitor.wasModified()) {
|
|
| 70 | + resultBuilder.flush(monitor);
|
|
| 74 | 71 | }
|
| 75 | - dcpMonitor.setBean(null);
|
|
| 72 | + monitor.setBean(null);
|
|
| 76 | 73 | }
|
| 77 | 74 | }
|
| 78 | 75 | |
| ... | ... | @@ -80,7 +77,7 @@ public class FloatingObjectConsolidateEngine { |
| 80 | 77 | this.simplifiedObjectTypeManager = simplifiedObjectTypeManager;
|
| 81 | 78 | }
|
| 82 | 79 | |
| 83 | - public Optional<FloatingObjectConsolidateResult> consolidate(FloatingObjectConsolidateRequest request) {
|
|
| 80 | + public Optional<FloatingObjectConsolidateResult> consolidate(fr.ird.observe.dto.data.ps.observation.consolidate.FloatingObjectConsolidateRequest request) {
|
|
| 84 | 81 | return consolidate0(request);
|
| 85 | 82 | }
|
| 86 | 83 | |
| ... | ... | @@ -91,36 +88,35 @@ public class FloatingObjectConsolidateEngine { |
| 91 | 88 | |
| 92 | 89 | private <F extends DataDto & FloatingObjectAware, P extends DataDto & FloatingObjectPartAware> Optional<FloatingObjectConsolidateResult> consolidate0(FloatingObjectAdapter<F, P> request) {
|
| 93 | 90 | |
| 94 | - FloatingObjectResultConsolidateBuilder builder = new FloatingObjectResultConsolidateBuilder();
|
|
| 91 | + FloatingObjectConsolidateResult.Builder builder = FloatingObjectConsolidateResult.builder();
|
|
| 95 | 92 | FloatingObjectConsolidateContext context = new FloatingObjectConsolidateContext(builder);
|
| 96 | 93 | |
| 97 | - F dcp = request.getFloatingObject();
|
|
| 98 | - context.watchDcp(dcp);
|
|
| 94 | + F floatingObject = request.getFloatingObject();
|
|
| 95 | + context.watch(floatingObject);
|
|
| 99 | 96 | |
| 100 | 97 | Set<P> whenArriving = request.getWhenArriving();
|
| 101 | 98 | Set<P> whenLeaving = request.getWhenLeaving();
|
| 102 | 99 | |
| 103 | - computeDcpValue(dcp, FloatingObjectDto.PROPERTY_COMPUTED_WHEN_ARRIVING_SIMPLIFIED_OBJECT_TYPE, request, whenArriving, this::computeDcpSimplifiedObjectType0);
|
|
| 104 | - computeDcpValue(dcp, FloatingObjectDto.PROPERTY_COMPUTED_WHEN_LEAVING_SIMPLIFIED_OBJECT_TYPE, request, whenLeaving, this::computeDcpSimplifiedObjectType0);
|
|
| 100 | + computeDcpValue(floatingObject, FloatingObjectDto.PROPERTY_COMPUTED_WHEN_ARRIVING_SIMPLIFIED_OBJECT_TYPE, request, whenArriving, this::computeDcpSimplifiedObjectType0);
|
|
| 101 | + computeDcpValue(floatingObject, FloatingObjectDto.PROPERTY_COMPUTED_WHEN_LEAVING_SIMPLIFIED_OBJECT_TYPE, request, whenLeaving, this::computeDcpSimplifiedObjectType0);
|
|
| 105 | 102 | |
| 106 | - computeDcpValue(dcp, FloatingObjectDto.PROPERTY_COMPUTED_WHEN_ARRIVING_NON_ENTANGLING, request, whenArriving, this::computeDcpNonEntangling0);
|
|
| 107 | - computeDcpValue(dcp, FloatingObjectDto.PROPERTY_COMPUTED_WHEN_LEAVING_NON_ENTANGLING, request, whenLeaving, this::computeDcpNonEntangling0);
|
|
| 103 | + computeDcpValue(floatingObject, FloatingObjectDto.PROPERTY_COMPUTED_WHEN_ARRIVING_NON_ENTANGLING, request, whenArriving, this::computeDcpNonEntangling0);
|
|
| 104 | + computeDcpValue(floatingObject, FloatingObjectDto.PROPERTY_COMPUTED_WHEN_LEAVING_NON_ENTANGLING, request, whenLeaving, this::computeDcpNonEntangling0);
|
|
| 108 | 105 | |
| 109 | - computeDcpValue(dcp, FloatingObjectDto.PROPERTY_COMPUTED_WHEN_ARRIVING_BIODEGRADABLE, request, whenArriving, this::computeDcpBiodegradable0);
|
|
| 110 | - computeDcpValue(dcp, FloatingObjectDto.PROPERTY_COMPUTED_WHEN_LEAVING_BIODEGRADABLE, request, whenLeaving, this::computeDcpBiodegradable0);
|
|
| 106 | + computeDcpValue(floatingObject, FloatingObjectDto.PROPERTY_COMPUTED_WHEN_ARRIVING_BIODEGRADABLE, request, whenArriving, this::computeDcpBiodegradable0);
|
|
| 107 | + computeDcpValue(floatingObject, FloatingObjectDto.PROPERTY_COMPUTED_WHEN_LEAVING_BIODEGRADABLE, request, whenLeaving, this::computeDcpBiodegradable0);
|
|
| 111 | 108 | |
| 112 | - context.flushDcp();
|
|
| 109 | + context.flush();
|
|
| 113 | 110 | |
| 114 | 111 | return builder.build();
|
| 115 | - |
|
| 116 | 112 | }
|
| 117 | 113 | |
| 118 | - private <F extends DataDto&FloatingObjectAware, P extends DataDto&FloatingObjectPartAware> void computeDcpValue(F dcp, String propertyName, FloatingObjectAdapter<F, P> adapter, Set<P> parts, BiFunction<FloatingObjectAdapter<F, P>, Set<P>, Object> valueComputer) {
|
|
| 114 | + private <F extends DataDto & FloatingObjectAware, P extends DataDto & FloatingObjectPartAware> void computeDcpValue(F dcp, String propertyName, FloatingObjectAdapter<F, P> adapter, Set<P> parts, BiFunction<FloatingObjectAdapter<F, P>, Set<P>, Object> valueComputer) {
|
|
| 119 | 115 | Object newValue = valueComputer.apply(adapter, parts);
|
| 120 | 116 | dcp.set(propertyName, newValue);
|
| 121 | 117 | }
|
| 122 | 118 | |
| 123 | - private <F extends DataDto&FloatingObjectAware, P extends DataDto&FloatingObjectPartAware> DcpComputedValue computeDcpBiodegradable0(FloatingObjectAdapter<F, P> adapter, Set<P> parts) {
|
|
| 119 | + private <F extends DataDto & FloatingObjectAware, P extends DataDto & FloatingObjectPartAware> DcpComputedValue computeDcpBiodegradable0(FloatingObjectAdapter<F, P> adapter, Set<P> parts) {
|
|
| 124 | 120 | if (parts.isEmpty()) {
|
| 125 | 121 | return null;
|
| 126 | 122 | }
|
| ... | ... | @@ -139,7 +135,7 @@ public class FloatingObjectConsolidateEngine { |
| 139 | 135 | return result;
|
| 140 | 136 | }
|
| 141 | 137 | |
| 142 | - private <F extends DataDto&FloatingObjectAware, P extends DataDto&FloatingObjectPartAware> String computeDcpSimplifiedObjectType0(FloatingObjectAdapter<F, P> adapter, Set<P> parts) {
|
|
| 138 | + private <F extends DataDto & FloatingObjectAware, P extends DataDto & FloatingObjectPartAware> String computeDcpSimplifiedObjectType0(FloatingObjectAdapter<F, P> adapter, Set<P> parts) {
|
|
| 143 | 139 | if (parts.isEmpty()) {
|
| 144 | 140 | return null;
|
| 145 | 141 | }
|
| ... | ... | @@ -147,7 +143,7 @@ public class FloatingObjectConsolidateEngine { |
| 147 | 143 | return simplifiedObjectTypeManager.getStandardCode(objectMaterialIds);
|
| 148 | 144 | }
|
| 149 | 145 | |
| 150 | - private <F extends DataDto&FloatingObjectAware, P extends DataDto&FloatingObjectPartAware> DcpComputedValue computeDcpNonEntangling0(FloatingObjectAdapter<F, P> adapter, Set<P> parts) {
|
|
| 146 | + private <F extends DataDto & FloatingObjectAware, P extends DataDto & FloatingObjectPartAware> DcpComputedValue computeDcpNonEntangling0(FloatingObjectAdapter<F, P> adapter, Set<P> parts) {
|
|
| 151 | 147 | if (parts.isEmpty()) {
|
| 152 | 148 | return null;
|
| 153 | 149 | }
|
| ... | ... | @@ -23,44 +23,64 @@ package fr.ird.observe.dto.data.ps.dcp.consolidate; |
| 23 | 23 | */
|
| 24 | 24 | |
| 25 | 25 | |
| 26 | -import fr.ird.observe.dto.DtoPropertyModification;
|
|
| 27 | -import fr.ird.observe.dto.ObserveDto;
|
|
| 26 | +import fr.ird.observe.dto.JavaBeanPropertyModification;
|
|
| 28 | 27 | import fr.ird.observe.dto.data.DataDto;
|
| 28 | +import io.ultreia.java4all.bean.JavaBean;
|
|
| 29 | +import io.ultreia.java4all.bean.monitor.BeanMonitor;
|
|
| 30 | +import io.ultreia.java4all.util.json.JsonAware;
|
|
| 29 | 31 | |
| 30 | -import java.io.Serializable;
|
|
| 32 | +import java.util.LinkedHashSet;
|
|
| 33 | +import java.util.Optional;
|
|
| 31 | 34 | import java.util.Set;
|
| 32 | 35 | |
| 33 | 36 | /**
|
| 34 | - * Pour retourner le résultat de la consolidation d'une activité de type Seine.
|
|
| 37 | + * Contains the result of a consolidation operation on a Floating Object.
|
|
| 35 | 38 | * <p>
|
| 36 | - * Un tel objet est créé uniquement si des modifications on été effectuée sur l'activité.
|
|
| 39 | + * UA such object is only created if there is some modification on a the floating object.
|
|
| 37 | 40 | * <p>
|
| 38 | 41 | * Created on 28/08/15.
|
| 39 | 42 | *
|
| 40 | 43 | * @author Tony Chemit - dev@tchemit.fr
|
| 41 | 44 | */
|
| 42 | -public class FloatingObjectConsolidateResult implements Serializable, ObserveDto {
|
|
| 43 | - |
|
| 44 | - private static final long serialVersionUID = 1L;
|
|
| 45 | +public class FloatingObjectConsolidateResult implements JsonAware {
|
|
| 45 | 46 | |
| 46 | 47 | /**
|
| 47 | 48 | * All modifications on floating object.
|
| 48 | 49 | */
|
| 49 | - private final Set<DtoPropertyModification> floatingObjectModifications;
|
|
| 50 | + private final Set<JavaBeanPropertyModification> modifications;
|
|
| 50 | 51 | |
| 51 | - FloatingObjectConsolidateResult(Set<DtoPropertyModification> floatingObjectModifications) {
|
|
| 52 | - this.floatingObjectModifications = floatingObjectModifications;
|
|
| 52 | + public static Builder builder() {
|
|
| 53 | + return new Builder();
|
|
| 53 | 54 | }
|
| 54 | 55 | |
| 55 | - public Set<DtoPropertyModification> getFloatingObjectModifications() {
|
|
| 56 | - return floatingObjectModifications;
|
|
| 57 | - }
|
|
| 56 | + public static class Builder {
|
|
| 57 | + |
|
| 58 | + private final Set<JavaBeanPropertyModification> modifications = new LinkedHashSet<>();
|
|
| 58 | 59 | |
| 59 | - public void flushToDto(DataDto dto) {
|
|
| 60 | - for (DtoPropertyModification floatingObjectModification : floatingObjectModifications) {
|
|
| 61 | - Serializable newValue = floatingObjectModification.getNewValue();
|
|
| 62 | - dto.set(floatingObjectModification.getPropertyName(), newValue);
|
|
| 60 | + public Optional<FloatingObjectConsolidateResult> build() {
|
|
| 61 | + boolean noModification = modifications.isEmpty();
|
|
| 62 | + return Optional.ofNullable(noModification ? null : new FloatingObjectConsolidateResult(modifications));
|
|
| 63 | 63 | }
|
| 64 | + |
|
| 65 | + public void flush(BeanMonitor monitor) {
|
|
| 66 | + DataDto dcp = (DataDto) monitor.getBean();
|
|
| 67 | + for (String modifiedProperty : monitor.getModifiedProperties()) {
|
|
| 68 | + JavaBeanPropertyModification element = new JavaBeanPropertyModification(dcp, modifiedProperty);
|
|
| 69 | + modifications.add(element);
|
|
| 70 | + }
|
|
| 71 | + }
|
|
| 72 | + }
|
|
| 73 | + |
|
| 74 | + FloatingObjectConsolidateResult(Set<JavaBeanPropertyModification> modifications) {
|
|
| 75 | + this.modifications = modifications;
|
|
| 76 | + }
|
|
| 77 | + |
|
| 78 | + public Set<JavaBeanPropertyModification> getModifications() {
|
|
| 79 | + return modifications;
|
|
| 80 | + }
|
|
| 81 | + |
|
| 82 | + public void flushToBean(JavaBean dto) {
|
|
| 83 | + modifications.forEach(modification -> modification.flushToBean(dto));
|
|
| 64 | 84 | }
|
| 65 | 85 | }
|
| 66 | 86 |
| 1 | -package fr.ird.observe.dto.data.ps.dcp.consolidate;
|
|
| 2 | - |
|
| 3 | -/*-
|
|
| 4 | - * #%L
|
|
| 5 | - * ObServe Core :: API :: Dto
|
|
| 6 | - * %%
|
|
| 7 | - * Copyright (C) 2008 - 2023 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 | - |
|
| 26 | -import fr.ird.observe.dto.DtoPropertyModification;
|
|
| 27 | -import fr.ird.observe.dto.data.DataDto;
|
|
| 28 | - |
|
| 29 | -import java.util.LinkedHashSet;
|
|
| 30 | -import java.util.Optional;
|
|
| 31 | -import java.util.Set;
|
|
| 32 | - |
|
| 33 | -/**
|
|
| 34 | - * @author Tony Chemit - dev@tchemit.fr
|
|
| 35 | - * @since 7.0
|
|
| 36 | - */
|
|
| 37 | -public class FloatingObjectResultConsolidateBuilder {
|
|
| 38 | - |
|
| 39 | - private final Set<DtoPropertyModification> modifications = new LinkedHashSet<>();
|
|
| 40 | - |
|
| 41 | - public Optional<FloatingObjectConsolidateResult> build() {
|
|
| 42 | - boolean noModification = modifications.isEmpty();
|
|
| 43 | - return Optional.ofNullable(noModification ? null : new FloatingObjectConsolidateResult(modifications));
|
|
| 44 | - }
|
|
| 45 | - |
|
| 46 | - void flushDcpModification(DataDto dcp, String... propertyNamesModified) {
|
|
| 47 | - for (String modifiedProperty : propertyNamesModified) {
|
|
| 48 | - DtoPropertyModification element = new DtoPropertyModification(dcp, modifiedProperty);
|
|
| 49 | - modifications.add(element);
|
|
| 50 | - }
|
|
| 51 | - }
|
|
| 52 | -} |
| ... | ... | @@ -22,8 +22,9 @@ package fr.ird.observe.dto.data.ps.localmarket.consolidate; |
| 22 | 22 | * #L%
|
| 23 | 23 | */
|
| 24 | 24 | |
| 25 | -import fr.ird.observe.dto.DtoPropertyModification;
|
|
| 26 | 25 | import fr.ird.observe.dto.DtoPropertyModifications;
|
| 26 | +import fr.ird.observe.dto.JavaBeanPropertyModification;
|
|
| 27 | +import fr.ird.observe.dto.ProtectedIdsPs;
|
|
| 27 | 28 | import fr.ird.observe.dto.data.ps.localmarket.BatchDto;
|
| 28 | 29 | import fr.ird.observe.dto.data.ps.localmarket.BatchWeightComputedValueSource;
|
| 29 | 30 | import fr.ird.observe.dto.referential.common.SpeciesReference;
|
| ... | ... | @@ -65,7 +66,7 @@ public class BatchConsolidateResult extends DtoPropertyModifications { |
| 65 | 66 | }
|
| 66 | 67 | |
| 67 | 68 | @Override
|
| 68 | - protected BatchConsolidateResult createResult(String id, String label, Set<DtoPropertyModification> modifications, String lengthWeightParameterNotFound) {
|
|
| 69 | + protected BatchConsolidateResult createResult(String id, String label, Set<JavaBeanPropertyModification> modifications, String lengthWeightParameterNotFound) {
|
|
| 69 | 70 | return new BatchConsolidateResult(id, label, modifications, lengthWeightParameterNotFound);
|
| 70 | 71 | }
|
| 71 | 72 | |
| ... | ... | @@ -83,12 +84,12 @@ public class BatchConsolidateResult extends DtoPropertyModifications { |
| 83 | 84 | BatchWeightTypeReference batchWeightType = dto.getPackaging().getBatchWeightType();
|
| 84 | 85 | Integer count = dto.getCount();
|
| 85 | 86 | switch (batchWeightType.getId()) {
|
| 86 | - case "fr.ird.referential.ps.localmarket.BatchWeightType#1464000000000#01":
|
|
| 87 | + case ProtectedIdsPs.PS_LOCAL_MARKET_BATCH_WEIGHT_TYPE_WEIGHING:
|
|
| 87 | 88 | // pesée poids direct
|
| 88 | 89 | // P = batch.weight
|
| 89 | 90 | // donc rien à faire
|
| 90 | 91 | break;
|
| 91 | - case "fr.ird.referential.ps.localmarket.BatchWeightType#1464000000000#02":
|
|
| 92 | + case ProtectedIdsPs.PS_LOCAL_MARKET_BATCH_WEIGHT_TYPE_SINGLE_SPECIES_INDIVIDUAL:
|
|
| 92 | 93 | // espèce unité
|
| 93 | 94 | // P = poids moyen de l'espèce * batch.count / 1000
|
| 94 | 95 | // ocean = océan de débarquement de la marée = ps_common.trip.ocean
|
| ... | ... | @@ -113,7 +114,7 @@ public class BatchConsolidateResult extends DtoPropertyModifications { |
| 113 | 114 | });
|
| 114 | 115 | }
|
| 115 | 116 | break;
|
| 116 | - case "fr.ird.referential.ps.localmarket.BatchWeightType#1464000000000#03":
|
|
| 117 | + case ProtectedIdsPs.PS_LOCAL_MARKET_BATCH_WEIGHT_TYPE_PACKAGING_NOT_WEIGHTED:
|
|
| 117 | 118 | // Paquet/Conditionnement non pesé
|
| 118 | 119 | // P = batch.packaging.meanWeight * batch.count (ou null si pas de packaging.meanWeight)
|
| 119 | 120 | if (count != null) {
|
| ... | ... | @@ -132,7 +133,7 @@ public class BatchConsolidateResult extends DtoPropertyModifications { |
| 132 | 133 | return new BatchConsolidateResultBuilder(rtpMeanWeightFinder);
|
| 133 | 134 | }
|
| 134 | 135 | |
| 135 | - BatchConsolidateResult(String batchId, String batchLabel, Set<DtoPropertyModification> modifications, String lengthWeightParameterNotFound) {
|
|
| 136 | + BatchConsolidateResult(String batchId, String batchLabel, Set<JavaBeanPropertyModification> modifications, String lengthWeightParameterNotFound) {
|
|
| 136 | 137 | super(batchId, batchLabel, modifications, lengthWeightParameterNotFound);
|
| 137 | 138 | }
|
| 138 | 139 |
| ... | ... | @@ -23,7 +23,7 @@ package fr.ird.observe.dto.data.ps.observation.consolidate; |
| 23 | 23 | */
|
| 24 | 24 | |
| 25 | 25 | |
| 26 | -import fr.ird.observe.dto.DtoPropertyModification;
|
|
| 26 | +import fr.ird.observe.dto.JavaBeanPropertyModification;
|
|
| 27 | 27 | import fr.ird.observe.dto.ObserveDto;
|
| 28 | 28 | |
| 29 | 29 | import java.io.Serializable;
|
| ... | ... | @@ -63,17 +63,17 @@ public class ActivityConsolidateResult implements Serializable, ObserveDto { |
| 63 | 63 | private String newSchoolType;
|
| 64 | 64 | |
| 65 | 65 | /**
|
| 66 | - * L'ensemble des modifications sur les échantillons.
|
|
| 66 | + * All modification on samples.
|
|
| 67 | 67 | */
|
| 68 | - private Set<SampleMeasureModification> sampleMeasureModifications;
|
|
| 68 | + private Set<JavaBeanPropertyModification> sampleMeasureModifications;
|
|
| 69 | 69 | /**
|
| 70 | - * L'ensemble des modifications sur les captures non cibles.
|
|
| 70 | + * All modification on catches.
|
|
| 71 | 71 | */
|
| 72 | - private Set<CatchModification> catchModifications;
|
|
| 72 | + private Set<JavaBeanPropertyModification> catchModifications;
|
|
| 73 | 73 | /**
|
| 74 | - * L'ensemble des modifications sur les objets flottants.
|
|
| 74 | + * All modification on floating objects.
|
|
| 75 | 75 | */
|
| 76 | - private Set<DtoPropertyModification> floatingObjectModifications;
|
|
| 76 | + private Set<JavaBeanPropertyModification> floatingObjectModifications;
|
|
| 77 | 77 | |
| 78 | 78 | private Set<String> lengthWeightParameterNotFound ;
|
| 79 | 79 | private Set<String> lengthLengthParameterNotFound;
|
| ... | ... | @@ -94,27 +94,27 @@ public class ActivityConsolidateResult implements Serializable, ObserveDto { |
| 94 | 94 | this.activityLabel = activityLabel;
|
| 95 | 95 | }
|
| 96 | 96 | |
| 97 | - public Set<SampleMeasureModification> getSampleMeasureModifications() {
|
|
| 97 | + public Set<JavaBeanPropertyModification> getSampleMeasureModifications() {
|
|
| 98 | 98 | return sampleMeasureModifications;
|
| 99 | 99 | }
|
| 100 | 100 | |
| 101 | - public void setSampleMeasureModifications(Set<SampleMeasureModification> sampleMeasureModifications) {
|
|
| 101 | + public void setSampleMeasureModifications(Set<JavaBeanPropertyModification> sampleMeasureModifications) {
|
|
| 102 | 102 | this.sampleMeasureModifications = sampleMeasureModifications;
|
| 103 | 103 | }
|
| 104 | 104 | |
| 105 | - public Set<CatchModification> getCatchModifications() {
|
|
| 105 | + public Set<JavaBeanPropertyModification> getCatchModifications() {
|
|
| 106 | 106 | return catchModifications;
|
| 107 | 107 | }
|
| 108 | 108 | |
| 109 | - public void setCatchModifications(Set<CatchModification> catchModifications) {
|
|
| 109 | + public void setCatchModifications(Set<JavaBeanPropertyModification> catchModifications) {
|
|
| 110 | 110 | this.catchModifications = catchModifications;
|
| 111 | 111 | }
|
| 112 | 112 | |
| 113 | - public Set<DtoPropertyModification> getFloatingObjectModifications() {
|
|
| 113 | + public Set<JavaBeanPropertyModification> getFloatingObjectModifications() {
|
|
| 114 | 114 | return floatingObjectModifications;
|
| 115 | 115 | }
|
| 116 | 116 | |
| 117 | - public void setFloatingObjectModifications(Set<DtoPropertyModification> floatingObjectModifications) {
|
|
| 117 | + public void setFloatingObjectModifications(Set<JavaBeanPropertyModification> floatingObjectModifications) {
|
|
| 118 | 118 | this.floatingObjectModifications = floatingObjectModifications;
|
| 119 | 119 | }
|
| 120 | 120 |
| 1 | -package fr.ird.observe.dto.data.ps.observation.consolidate;
|
|
| 2 | - |
|
| 3 | -/*-
|
|
| 4 | - * #%L
|
|
| 5 | - * ObServe Core :: API :: Dto
|
|
| 6 | - * %%
|
|
| 7 | - * Copyright (C) 2008 - 2023 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 java.io.Serializable;
|
|
| 26 | - |
|
| 27 | -/**
|
|
| 28 | - * Created by tchemit on 04/08/17.
|
|
| 29 | - *
|
|
| 30 | - * @author Tony Chemit - dev@tchemit.fr
|
|
| 31 | - */
|
|
| 32 | -public class CatchModification implements Serializable {
|
|
| 33 | - |
|
| 34 | - private static final long serialVersionUID = 1L;
|
|
| 35 | - protected String speciesLabel;
|
|
| 36 | - protected String propertyName;
|
|
| 37 | - protected Number newValue;
|
|
| 38 | - String catchId;
|
|
| 39 | - |
|
| 40 | - public String getCatchCatchId() {
|
|
| 41 | - return catchId;
|
|
| 42 | - }
|
|
| 43 | - |
|
| 44 | - public String getSpeciesLabel() {
|
|
| 45 | - return speciesLabel;
|
|
| 46 | - }
|
|
| 47 | - |
|
| 48 | - public String getPropertyName() {
|
|
| 49 | - return propertyName;
|
|
| 50 | - }
|
|
| 51 | - |
|
| 52 | - public Number getNewValue() {
|
|
| 53 | - return newValue;
|
|
| 54 | - }
|
|
| 55 | - |
|
| 56 | - public void setCatchId(String catchId) {
|
|
| 57 | - this.catchId = catchId;
|
|
| 58 | - }
|
|
| 59 | - |
|
| 60 | - public void setSpeciesLabel(String speciesLabel) {
|
|
| 61 | - this.speciesLabel = speciesLabel;
|
|
| 62 | - }
|
|
| 63 | - |
|
| 64 | - public void setPropertyName(String propertyName) {
|
|
| 65 | - this.propertyName = propertyName;
|
|
| 66 | - }
|
|
| 67 | - |
|
| 68 | - public void setNewValue(Number newValue) {
|
|
| 69 | - this.newValue = newValue;
|
|
| 70 | - }
|
|
| 71 | -} |
| 1 | -package fr.ird.observe.dto.data.ps.observation.consolidate;
|
|
| 2 | - |
|
| 3 | -/*-
|
|
| 4 | - * #%L
|
|
| 5 | - * ObServe Core :: API :: Dto
|
|
| 6 | - * %%
|
|
| 7 | - * Copyright (C) 2008 - 2023 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 java.io.Serializable;
|
|
| 26 | - |
|
| 27 | -/**
|
|
| 28 | - * Created by tchemit on 04/08/17.
|
|
| 29 | - *
|
|
| 30 | - * @author Tony Chemit - dev@tchemit.fr
|
|
| 31 | - */
|
|
| 32 | -public class SampleMeasureModification implements Serializable {
|
|
| 33 | - |
|
| 34 | - private static final long serialVersionUID = 1L;
|
|
| 35 | - protected String speciesLabel;
|
|
| 36 | - protected String propertyName;
|
|
| 37 | - protected Float newValue;
|
|
| 38 | - private String id;
|
|
| 39 | - |
|
| 40 | - public String getId() {
|
|
| 41 | - return id;
|
|
| 42 | - }
|
|
| 43 | - |
|
| 44 | - public String getSpeciesLabel() {
|
|
| 45 | - return speciesLabel;
|
|
| 46 | - }
|
|
| 47 | - |
|
| 48 | - public String getPropertyName() {
|
|
| 49 | - return propertyName;
|
|
| 50 | - }
|
|
| 51 | - |
|
| 52 | - public Float getNewValue() {
|
|
| 53 | - return newValue;
|
|
| 54 | - }
|
|
| 55 | - |
|
| 56 | - public void setId(String id) {
|
|
| 57 | - this.id = id;
|
|
| 58 | - }
|
|
| 59 | - |
|
| 60 | - public void setSpeciesLabel(String speciesLabel) {
|
|
| 61 | - this.speciesLabel = speciesLabel;
|
|
| 62 | - }
|
|
| 63 | - |
|
| 64 | - public void setPropertyName(String propertyName) {
|
|
| 65 | - this.propertyName = propertyName;
|
|
| 66 | - }
|
|
| 67 | - |
|
| 68 | - public void setNewValue(Float newValue) {
|
|
| 69 | - this.newValue = newValue;
|
|
| 70 | - }
|
|
| 71 | -} |
| ... | ... | @@ -162,7 +162,7 @@ public class TripConsolidateEngine { |
| 162 | 162 | // add to result
|
| 163 | 163 | localmarketBatchResults.add(r);
|
| 164 | 164 | // flush back to entity
|
| 165 | - r.flushToDto(batch);
|
|
| 165 | + r.flushToBean(batch);
|
|
| 166 | 166 | });
|
| 167 | 167 | }
|
| 168 | 168 | |
| ... | ... | @@ -193,11 +193,11 @@ public class TripConsolidateEngine { |
| 193 | 193 | activityContext.daoSupplier = (ObserveTopiaDaoSupplier) persistenceContext;
|
| 194 | 194 | activityContext.resultBuilder = resultBuilder;
|
| 195 | 195 | activityContext.trip = trip;
|
| 196 | - activityContext.routeObs = route;
|
|
| 197 | - activityContext.activityObs = activity;
|
|
| 198 | - activityContext.sampleMeasureObsMonitor = sampleMeasureMonitor;
|
|
| 199 | - activityContext.sampleObsMonitor = sampleMonitor;
|
|
| 200 | - activityContext.catchObsMonitor = catchMonitor;
|
|
| 196 | + activityContext.route = route;
|
|
| 197 | + activityContext.activity = activity;
|
|
| 198 | + activityContext.sampleMeasureMonitor = sampleMeasureMonitor;
|
|
| 199 | + activityContext.sampleMonitor = sampleMonitor;
|
|
| 200 | + activityContext.catchMonitor = catchMonitor;
|
|
| 201 | 201 | activityContext.floatingObjectConsolidateEngine = floatingObjectConsolidateEngine;
|
| 202 | 202 | activityContext.activityPrefix = activityPrefix;
|
| 203 | 203 | try {
|
| ... | ... | @@ -228,11 +228,11 @@ public class TripConsolidateEngine { |
| 228 | 228 | }
|
| 229 | 229 | |
| 230 | 230 | private void consolidateActivity(ActivityConsolidateContext activityContext) {
|
| 231 | - Activity activity = activityContext.activityObs;
|
|
| 231 | + Activity activity = activityContext.activity;
|
|
| 232 | 232 | log.debug(String.format("%s Start consolidate activity: %s", activityContext.activityPrefix, activity.getTopiaId()));
|
| 233 | 233 | if (activity.isFloatingObjectNotEmpty()) {
|
| 234 | - for (FloatingObject dcp : activity.getFloatingObject()) {
|
|
| 235 | - updateDcp(dcp, activityContext);
|
|
| 234 | + for (FloatingObject floatingObject : activity.getFloatingObject()) {
|
|
| 235 | + updateFloatingObject(floatingObject, activityContext);
|
|
| 236 | 236 | }
|
| 237 | 237 | }
|
| 238 | 238 | Set set = activity.getSet();
|
| ... | ... | @@ -249,22 +249,17 @@ public class TripConsolidateEngine { |
| 249 | 249 | activityContext.setSchoolTypeChanged(oldSchoolType == null ? null : oldSchoolType.getTopiaId(), newSchoolTypeId);
|
| 250 | 250 | }
|
| 251 | 251 | if (set.isSampleNotEmpty()) {
|
| 252 | - // des échantillons trouves
|
|
| 253 | 252 | for (Sample sample : set.getSample()) {
|
| 254 | 253 | if (sample.isSampleMeasureNotEmpty()) {
|
| 255 | 254 | for (SampleMeasure sampleMeasure : sample.getSampleMeasure()) {
|
| 256 | 255 | activityContext.watchSampleMeasure(sampleMeasure);
|
| 257 | - updateLengthWeightAble(activityContext,
|
|
| 258 | - sampleMeasure.getSpecies(),
|
|
| 259 | - /* pas de sexe precise */
|
|
| 260 | - sampleMeasure);
|
|
| 256 | + updateLengthWeightAble(activityContext, sampleMeasure.getSpecies(), sampleMeasure);
|
|
| 261 | 257 | activityContext.flushSampleMeasure();
|
| 262 | 258 | }
|
| 263 | 259 | }
|
| 264 | 260 | }
|
| 265 | 261 | }
|
| 266 | 262 | if (set.isCatchesNotEmpty()) {
|
| 267 | - // des captures trouves
|
|
| 268 | 263 | for (Catch aCatch : set.getCatches()) {
|
| 269 | 264 | activityContext.watchCatch(aCatch);
|
| 270 | 265 | updateCatch(activityContext, aCatch);
|
| ... | ... | @@ -274,11 +269,11 @@ public class TripConsolidateEngine { |
| 274 | 269 | }
|
| 275 | 270 | }
|
| 276 | 271 | |
| 277 | - private void updateDcp(FloatingObject dcp, ActivityConsolidateContext activityContext) {
|
|
| 272 | + private void updateFloatingObject(FloatingObject floatingObject, ActivityConsolidateContext activityContext) {
|
|
| 278 | 273 | |
| 279 | - if (dcp.getObjectOperation() == null) {
|
|
| 274 | + if (floatingObject.getObjectOperation() == null) {
|
|
| 280 | 275 | log.warn("**********************");
|
| 281 | - log.warn(String.format("Floating object %s has no object operation....", dcp.getTopiaId()));
|
|
| 276 | + log.warn(String.format("Floating object %s has no object operation....", floatingObject.getTopiaId()));
|
|
| 282 | 277 | log.warn("**********************");
|
| 283 | 278 | return;
|
| 284 | 279 | }
|
| ... | ... | @@ -286,22 +281,27 @@ public class TripConsolidateEngine { |
| 286 | 281 | |
| 287 | 282 | ReferentialLocale referentialLocale = context.getReferentialLocale();
|
| 288 | 283 | |
| 289 | - FloatingObjectDto floatingObjectDto = FloatingObject.toDto(referentialLocale, dcp);
|
|
| 284 | + FloatingObjectDto floatingObjectDto = FloatingObject.toDto(referentialLocale, floatingObject);
|
|
| 290 | 285 | |
| 291 | - java.util.Set<FloatingObjectPartDto> floatingObjectPartSet = new LinkedHashSet<>(FloatingObjectPart.SPI.toDataDtoList(referentialLocale, dcp.getFloatingObjectPart()));
|
|
| 286 | + java.util.Set<FloatingObjectPartDto> floatingObjectPartSet = new LinkedHashSet<>(FloatingObjectPart.SPI.toDataDtoList(referentialLocale, floatingObject.getFloatingObjectPart()));
|
|
| 292 | 287 | FloatingObjectConsolidateRequest request = new FloatingObjectConsolidateRequest(floatingObjectDto, floatingObjectPartSet);
|
| 293 | 288 | Optional<FloatingObjectConsolidateResult> result = floatingObjectConsolidateEngine.consolidate(request);
|
| 294 | 289 | |
| 295 | - result.ifPresent(r -> activityContext.flushDcp(dcp, r));
|
|
| 290 | + result.ifPresent(r -> {
|
|
| 291 | + // flush to main result
|
|
| 292 | + activityContext.flushFloatingObject(r);
|
|
| 293 | + // flush back modifications detected to entity
|
|
| 294 | + r.flushToBean(floatingObject);
|
|
| 295 | + });
|
|
| 296 | 296 | |
| 297 | 297 | if (request.isNeedClean()) {
|
| 298 | 298 | log.warn("**********************");
|
| 299 | - log.warn(String.format("Floating object %s has some bad parts, this will be fixed here....", dcp.getTopiaId()));
|
|
| 299 | + log.warn(String.format("Floating object %s has some bad parts, this will be fixed here....", floatingObject.getTopiaId()));
|
|
| 300 | 300 | log.warn("**********************");
|
| 301 | 301 | // Need to clean dcp parts
|
| 302 | - boolean notWhenArriving = !dcp.getObjectOperation().isWhenArriving();
|
|
| 303 | - boolean notWhenLeaving = !dcp.getObjectOperation().isWhenLeaving();
|
|
| 304 | - for (FloatingObjectPart floatingObjectPart : dcp.getFloatingObjectPart()) {
|
|
| 302 | + boolean notWhenArriving = !floatingObject.getObjectOperation().isWhenArriving();
|
|
| 303 | + boolean notWhenLeaving = !floatingObject.getObjectOperation().isWhenLeaving();
|
|
| 304 | + for (FloatingObjectPart floatingObjectPart : floatingObject.getFloatingObjectPart()) {
|
|
| 305 | 305 | if (floatingObjectPart.getWhenArriving() != null && notWhenArriving) {
|
| 306 | 306 | log.info(String.format("Set whenArriving to null for part: %s", floatingObjectPart.getTopiaId()));
|
| 307 | 307 | floatingObjectPart.setWhenArriving(null);
|
| ... | ... | @@ -333,7 +333,7 @@ public class TripConsolidateEngine { |
| 333 | 333 | // récupération des échantillon de cette espèce sur les calée
|
| 334 | 334 | |
| 335 | 335 | // on recherche sur le couple species/speciesFate (ou sur le couple species/null)
|
| 336 | - Collection<SampleMeasure> sampleMeasures = getSampleMeasures(activityContext.getSetObs(), species, aCatch.getSpeciesFate());
|
|
| 336 | + Collection<SampleMeasure> sampleMeasures = getSampleMeasures(activityContext.getSet(), species, aCatch.getSpeciesFate());
|
|
| 337 | 337 | |
| 338 | 338 | if (aCatch.getCatchWeight() != null || aCatch.getTotalCount() != null) {
|
| 339 | 339 | // -- Cas n°2 (pas de taille / poids moyen mais au moins un des deux taille / poids)
|
| ... | ... | @@ -448,11 +448,11 @@ public class TripConsolidateEngine { |
| 448 | 448 | |
| 449 | 449 | private void computeCatchMeanValues(Catch aCatch, LengthWeightParameter lengthWeightParameter) {
|
| 450 | 450 | if (lengthWeightParameter != null) {
|
| 451 | - if (aCatch.getMeanLength() == null) {
|
|
| 451 | + if (aCatch.getMeanLength() == null && lengthWeightParameter.getMeanLength() != null) {
|
|
| 452 | 452 | aCatch.setMeanLength(lengthWeightParameter.getMeanLength());
|
| 453 | 453 | aCatch.setMeanLengthComputedSource(CatchComputedValueSource.fromReferentiel);
|
| 454 | 454 | }
|
| 455 | - if (aCatch.getMeanWeight() == null) {
|
|
| 455 | + if (aCatch.getMeanWeight() == null && lengthWeightParameter.getMeanWeight() != null) {
|
|
| 456 | 456 | aCatch.setMeanWeight(lengthWeightParameter.getMeanWeight());
|
| 457 | 457 | aCatch.setMeanWeightComputedSource(CatchComputedValueSource.fromReferentiel);
|
| 458 | 458 | }
|
| ... | ... | @@ -23,11 +23,8 @@ package fr.ird.observe.entities.data.ps.observation; |
| 23 | 23 | */
|
| 24 | 24 | |
| 25 | 25 | import fr.ird.observe.decoration.DecoratorService;
|
| 26 | -import fr.ird.observe.dto.DtoPropertyModification;
|
|
| 27 | -import fr.ird.observe.dto.data.ps.DcpComputedValue;
|
|
| 28 | 26 | import fr.ird.observe.dto.data.ps.dcp.consolidate.FloatingObjectConsolidateEngine;
|
| 29 | 27 | import fr.ird.observe.dto.data.ps.dcp.consolidate.FloatingObjectConsolidateResult;
|
| 30 | -import fr.ird.observe.dto.data.ps.observation.FloatingObjectDto;
|
|
| 31 | 28 | import fr.ird.observe.entities.ObserveTopiaDaoSupplier;
|
| 32 | 29 | import fr.ird.observe.entities.data.ps.common.Trip;
|
| 33 | 30 | import fr.ird.observe.entities.referential.LengthLengthParameterNotFoundException;
|
| ... | ... | @@ -55,8 +52,8 @@ public class ActivityConsolidateContext { |
| 55 | 52 | |
| 56 | 53 | public Locale locale;
|
| 57 | 54 | public Trip trip;
|
| 58 | - public fr.ird.observe.entities.data.ps.observation.Route routeObs;
|
|
| 59 | - public fr.ird.observe.entities.data.ps.observation.Activity activityObs;
|
|
| 55 | + public fr.ird.observe.entities.data.ps.observation.Route route;
|
|
| 56 | + public fr.ird.observe.entities.data.ps.observation.Activity activity;
|
|
| 60 | 57 | public ObserveTopiaDaoSupplier daoSupplier;
|
| 61 | 58 | public boolean failIfLengthWeightParameterNotFound;
|
| 62 | 59 | public boolean failIfLengthLengthParameterNotFound;
|
| ... | ... | @@ -64,25 +61,25 @@ public class ActivityConsolidateContext { |
| 64 | 61 | public String activityPrefix;
|
| 65 | 62 | public ActivityConsolidateResultBuilder resultBuilder;
|
| 66 | 63 | public FloatingObjectConsolidateEngine floatingObjectConsolidateEngine;
|
| 67 | - public BeanMonitor sampleObsMonitor;
|
|
| 68 | - public BeanMonitor sampleMeasureObsMonitor;
|
|
| 69 | - public BeanMonitor catchObsMonitor;
|
|
| 64 | + public BeanMonitor sampleMonitor;
|
|
| 65 | + public BeanMonitor sampleMeasureMonitor;
|
|
| 66 | + public BeanMonitor catchMonitor;
|
|
| 70 | 67 | |
| 71 | 68 | public Ocean getOcean() {
|
| 72 | 69 | return trip.getOcean();
|
| 73 | 70 | }
|
| 74 | 71 | |
| 75 | - public Date getRouteObsDate() {
|
|
| 76 | - return routeObs.getDate();
|
|
| 72 | + public Date getRouteDate() {
|
|
| 73 | + return route.getDate();
|
|
| 77 | 74 | }
|
| 78 | 75 | |
| 79 | - public fr.ird.observe.entities.data.ps.observation.Set getSetObs() {
|
|
| 80 | - return activityObs.getSet();
|
|
| 76 | + public fr.ird.observe.entities.data.ps.observation.Set getSet() {
|
|
| 77 | + return activity.getSet();
|
|
| 81 | 78 | }
|
| 82 | 79 | |
| 83 | 80 | public Optional<LengthWeightParameter> findLengthWeightParameter(Species species, Sex sex, SizeMeasureType sizeMeasureType) {
|
| 84 | 81 | Ocean ocean = getOcean();
|
| 85 | - Date routeDate = getRouteObsDate();
|
|
| 82 | + Date routeDate = getRouteDate();
|
|
| 86 | 83 | try {
|
| 87 | 84 | return Optional.ofNullable(LengthWeightParameters.findLengthWeightParameter(decoratorService, daoSupplier, species, sex, ocean, routeDate, sizeMeasureType));
|
| 88 | 85 | } catch (LengthWeightParameterNotFoundException e) {
|
| ... | ... | @@ -96,7 +93,7 @@ public class ActivityConsolidateContext { |
| 96 | 93 | |
| 97 | 94 | public Optional<LengthLengthParameter> findLengthLengthParameter(Species species, Sex sex, SizeMeasureType inputSizeMeasureType, SizeMeasureType outputSizeMeasureType) {
|
| 98 | 95 | Ocean ocean = getOcean();
|
| 99 | - Date routeDate = getRouteObsDate();
|
|
| 96 | + Date routeDate = getRouteDate();
|
|
| 100 | 97 | try {
|
| 101 | 98 | return LengthLengthParameters.findLengthLengthParameter(decoratorService, daoSupplier, species, ocean, sex, routeDate, inputSizeMeasureType, outputSizeMeasureType);
|
| 102 | 99 | } catch (LengthLengthParameterNotFoundException e) {
|
| ... | ... | @@ -113,14 +110,12 @@ public class ActivityConsolidateContext { |
| 113 | 110 | }
|
| 114 | 111 | |
| 115 | 112 | public void watchSampleMeasure(SampleMeasure sampleMeasure) {
|
| 116 | - sampleMeasureObsMonitor.setBean(sampleMeasure);
|
|
| 113 | + sampleMeasureMonitor.setBean(sampleMeasure);
|
|
| 117 | 114 | if (sampleMeasure.isIsLengthComputed()) {
|
| 118 | - // Reset de la valeur calculée
|
|
| 119 | 115 | sampleMeasure.setLength(null);
|
| 120 | 116 | sampleMeasure.setIsLengthComputed(false);
|
| 121 | 117 | }
|
| 122 | 118 | if (sampleMeasure.isIsWeightComputed()) {
|
| 123 | - // Reset de la valeur calculée
|
|
| 124 | 119 | sampleMeasure.setWeight(null);
|
| 125 | 120 | sampleMeasure.setIsWeightComputed(false);
|
| 126 | 121 | }
|
| ... | ... | @@ -128,15 +123,15 @@ public class ActivityConsolidateContext { |
| 128 | 123 | |
| 129 | 124 | |
| 130 | 125 | public void flushSampleMeasure() {
|
| 131 | - if (sampleMeasureObsMonitor.wasModified()) {
|
|
| 132 | - SampleMeasure sampleMeasure = (SampleMeasure) sampleMeasureObsMonitor.getBean();
|
|
| 133 | - resultBuilder.flushSampleMeasureModification(sampleMeasure, sampleMeasureObsMonitor.getModifiedProperties());
|
|
| 126 | + if (sampleMeasureMonitor.wasModified()) {
|
|
| 127 | + SampleMeasure sampleMeasure = (SampleMeasure) sampleMeasureMonitor.getBean();
|
|
| 128 | + resultBuilder.flushSampleMeasureModification(sampleMeasure, sampleMeasureMonitor.getModifiedProperties());
|
|
| 134 | 129 | }
|
| 135 | - sampleMeasureObsMonitor.setBean(null);
|
|
| 130 | + sampleMeasureMonitor.setBean(null);
|
|
| 136 | 131 | }
|
| 137 | 132 | |
| 138 | 133 | public void watchCatch(Catch aCatch) {
|
| 139 | - catchObsMonitor.setBean(aCatch);
|
|
| 134 | + catchMonitor.setBean(aCatch);
|
|
| 140 | 135 | if (aCatch.isCatchWeightComputed()) {
|
| 141 | 136 | aCatch.setCatchWeight(null);
|
| 142 | 137 | aCatch.setCatchWeightComputedSource(null);
|
| ... | ... | @@ -156,50 +151,15 @@ public class ActivityConsolidateContext { |
| 156 | 151 | }
|
| 157 | 152 | |
| 158 | 153 | public void flushCatch() {
|
| 159 | - if (catchObsMonitor.wasModified()) {
|
|
| 160 | - Catch aCatch = (Catch) catchObsMonitor.getBean();
|
|
| 161 | - resultBuilder.flushCatchModification(aCatch, catchObsMonitor.getModifiedProperties());
|
|
| 154 | + if (catchMonitor.wasModified()) {
|
|
| 155 | + Catch aCatch = (Catch) catchMonitor.getBean();
|
|
| 156 | + resultBuilder.flushCatchModification(aCatch, catchMonitor.getModifiedProperties());
|
|
| 162 | 157 | }
|
| 163 | - catchObsMonitor.setBean(null);
|
|
| 158 | + catchMonitor.setBean(null);
|
|
| 164 | 159 | }
|
| 165 | 160 | |
| 166 | - public void flushDcp(FloatingObject dcp, FloatingObjectConsolidateResult floatingObjectConsolidateResult) {
|
|
| 167 | - resultBuilder.flushDcpModification(floatingObjectConsolidateResult);
|
|
| 168 | - for (DtoPropertyModification floatingObjectModification : floatingObjectConsolidateResult.getFloatingObjectModifications()) {
|
|
| 169 | - String modifiedProperty = floatingObjectModification.getPropertyName();
|
|
| 170 | - switch (modifiedProperty) {
|
|
| 171 | - case FloatingObjectDto.PROPERTY_COMPUTED_WHEN_ARRIVING_BIODEGRADABLE: {
|
|
| 172 | - |
|
| 173 | - dcp.setComputedWhenArrivingBiodegradable((DcpComputedValue) floatingObjectModification.getNewValue());
|
|
| 174 | - break;
|
|
| 175 | - }
|
|
| 176 | - case FloatingObjectDto.PROPERTY_COMPUTED_WHEN_ARRIVING_NON_ENTANGLING: {
|
|
| 177 | - |
|
| 178 | - dcp.setComputedWhenArrivingNonEntangling((DcpComputedValue) floatingObjectModification.getNewValue());
|
|
| 179 | - break;
|
|
| 180 | - }
|
|
| 181 | - case FloatingObjectDto.PROPERTY_COMPUTED_WHEN_ARRIVING_SIMPLIFIED_OBJECT_TYPE: {
|
|
| 182 | - |
|
| 183 | - dcp.setComputedWhenArrivingSimplifiedObjectType((String) floatingObjectModification.getNewValue());
|
|
| 184 | - break;
|
|
| 185 | - }
|
|
| 186 | - case FloatingObjectDto.PROPERTY_COMPUTED_WHEN_LEAVING_BIODEGRADABLE: {
|
|
| 187 | - |
|
| 188 | - dcp.setComputedWhenLeavingBiodegradable((DcpComputedValue) floatingObjectModification.getNewValue());
|
|
| 189 | - break;
|
|
| 190 | - }
|
|
| 191 | - case FloatingObjectDto.PROPERTY_COMPUTED_WHEN_LEAVING_NON_ENTANGLING: {
|
|
| 192 | - |
|
| 193 | - dcp.setComputedWhenLeavingNonEntangling((DcpComputedValue) floatingObjectModification.getNewValue());
|
|
| 194 | - break;
|
|
| 195 | - }
|
|
| 196 | - case FloatingObjectDto.PROPERTY_COMPUTED_WHEN_LEAVING_SIMPLIFIED_OBJECT_TYPE: {
|
|
| 197 | - |
|
| 198 | - dcp.setComputedWhenLeavingSimplifiedObjectType((String) floatingObjectModification.getNewValue());
|
|
| 199 | - break;
|
|
| 200 | - }
|
|
| 201 | - }
|
|
| 202 | - }
|
|
| 161 | + public void flushFloatingObject(FloatingObjectConsolidateResult floatingObjectConsolidateResult) {
|
|
| 162 | + resultBuilder.flushFloatingObjectModification(floatingObjectConsolidateResult);
|
|
| 203 | 163 | }
|
| 204 | 164 | |
| 205 | 165 |
| ... | ... | @@ -22,11 +22,9 @@ package fr.ird.observe.entities.data.ps.observation; |
| 22 | 22 | * #L%
|
| 23 | 23 | */
|
| 24 | 24 | |
| 25 | -import fr.ird.observe.dto.DtoPropertyModification;
|
|
| 25 | +import fr.ird.observe.dto.JavaBeanPropertyModification;
|
|
| 26 | 26 | import fr.ird.observe.dto.data.ps.dcp.consolidate.FloatingObjectConsolidateResult;
|
| 27 | -import fr.ird.observe.dto.data.ps.observation.consolidate.CatchModification;
|
|
| 28 | 27 | import fr.ird.observe.dto.data.ps.observation.consolidate.ActivityConsolidateResult;
|
| 29 | -import fr.ird.observe.dto.data.ps.observation.consolidate.SampleMeasureModification;
|
|
| 30 | 28 | import fr.ird.observe.dto.referential.I18nReferentialHelper;
|
| 31 | 29 | import fr.ird.observe.dto.referential.ReferentialLocale;
|
| 32 | 30 | import fr.ird.observe.entities.referential.common.Ocean;
|
| ... | ... | @@ -58,49 +56,46 @@ public class ActivityConsolidateResultBuilder { |
| 58 | 56 | private final ReferentialLocale referenceLocale;
|
| 59 | 57 | private final Set<String> lengthWeightParameterNotFoundBuilder = new LinkedHashSet<>();
|
| 60 | 58 | private final Set<String> lengthLengthParameterNotFoundBuilder = new LinkedHashSet<>();
|
| 61 | - private final Set<SampleMeasureModification> sampleMeasureObsModificationBuilder = new LinkedHashSet<>();
|
|
| 62 | - private final Set<CatchModification> catchObsModificationBuilder = new LinkedHashSet<>();
|
|
| 63 | - private final Set<DtoPropertyModification> dcpModificationBuilder = new LinkedHashSet<>();
|
|
| 64 | - private final String activitySeineLabel;
|
|
| 65 | - private final String activitySeineId;
|
|
| 59 | + private final Set<JavaBeanPropertyModification> sampleMeasureModificationBuilder = new LinkedHashSet<>();
|
|
| 60 | + private final Set<JavaBeanPropertyModification> catchModificationBuilder = new LinkedHashSet<>();
|
|
| 61 | + private final Set<JavaBeanPropertyModification> floatingObjectModificationBuilder = new LinkedHashSet<>();
|
|
| 62 | + private final String activityLabel;
|
|
| 63 | + private final String activityId;
|
|
| 66 | 64 | private String oldSchoolType;
|
| 67 | 65 | private String newSchoolType;
|
| 68 | 66 | |
| 69 | - public ActivityConsolidateResultBuilder(Locale locale, ReferentialLocale referenceLocale, String activitySeineId, String activitySeineLabel) {
|
|
| 67 | + public ActivityConsolidateResultBuilder(Locale locale, ReferentialLocale referenceLocale, String activityId, String activityLabel) {
|
|
| 70 | 68 | this.locale = locale;
|
| 71 | 69 | this.referenceLocale = referenceLocale;
|
| 72 | - this.activitySeineId = activitySeineId;
|
|
| 73 | - this.activitySeineLabel = activitySeineLabel;
|
|
| 70 | + this.activityId = activityId;
|
|
| 71 | + this.activityLabel = activityLabel;
|
|
| 74 | 72 | }
|
| 75 | 73 | |
| 76 | 74 | public Optional<ActivityConsolidateResult> build() {
|
| 77 | - Set<SampleMeasureModification> sampleMeasureObsModifications = sampleMeasureObsModificationBuilder;
|
|
| 78 | - Set<CatchModification> catchObsModifications = catchObsModificationBuilder;
|
|
| 79 | - Set<DtoPropertyModification> floatingObjectModifications = dcpModificationBuilder;
|
|
| 75 | + Set<JavaBeanPropertyModification> sampleMeasureModifications = sampleMeasureModificationBuilder;
|
|
| 76 | + Set<JavaBeanPropertyModification> catchModifications = catchModificationBuilder;
|
|
| 77 | + Set<JavaBeanPropertyModification> floatingObjectModifications = floatingObjectModificationBuilder;
|
|
| 80 | 78 | |
| 81 | - boolean noModification = (sampleMeasureObsModifications.isEmpty()
|
|
| 82 | - && catchObsModifications.isEmpty()
|
|
| 79 | + boolean noModification = sampleMeasureModifications.isEmpty()
|
|
| 80 | + && catchModifications.isEmpty()
|
|
| 83 | 81 | && floatingObjectModifications.isEmpty()
|
| 84 | - && newSchoolType == null);
|
|
| 82 | + && newSchoolType == null;
|
|
| 85 | 83 | |
| 86 | - ActivityConsolidateResult consolidateActivitySeineObsDataResult;
|
|
| 87 | 84 | if (noModification) {
|
| 88 | - consolidateActivitySeineObsDataResult = null;
|
|
| 89 | - } else {
|
|
| 90 | - consolidateActivitySeineObsDataResult = new ActivityConsolidateResult();
|
|
| 91 | - consolidateActivitySeineObsDataResult.setActivityId(activitySeineId);
|
|
| 92 | - consolidateActivitySeineObsDataResult.setActivityLabel(activitySeineLabel);
|
|
| 93 | - if (newSchoolType != null) {
|
|
| 94 | - consolidateActivitySeineObsDataResult.setSchoolTypeChanged(oldSchoolType, newSchoolType);
|
|
| 95 | - }
|
|
| 96 | - consolidateActivitySeineObsDataResult.setSampleMeasureModifications(sampleMeasureObsModifications);
|
|
| 97 | - consolidateActivitySeineObsDataResult.setCatchModifications(catchObsModifications);
|
|
| 98 | - consolidateActivitySeineObsDataResult.setFloatingObjectModifications(floatingObjectModifications);
|
|
| 99 | - consolidateActivitySeineObsDataResult.setFloatingObjectModifications(floatingObjectModifications);
|
|
| 100 | - consolidateActivitySeineObsDataResult.setLengthLengthParameterNotFound(getLengthLengthParameterNotFoundBuilder());
|
|
| 101 | - consolidateActivitySeineObsDataResult.setLengthWeightParameterNotFound(getLengthWeightParameterNotFoundBuilder());
|
|
| 85 | + return Optional.empty();
|
|
| 86 | + }
|
|
| 87 | + ActivityConsolidateResult result = new ActivityConsolidateResult();
|
|
| 88 | + result.setActivityId(activityId);
|
|
| 89 | + result.setActivityLabel(activityLabel);
|
|
| 90 | + if (newSchoolType != null) {
|
|
| 91 | + result.setSchoolTypeChanged(oldSchoolType, newSchoolType);
|
|
| 102 | 92 | }
|
| 103 | - return Optional.ofNullable(consolidateActivitySeineObsDataResult);
|
|
| 93 | + result.setSampleMeasureModifications(sampleMeasureModifications);
|
|
| 94 | + result.setCatchModifications(catchModifications);
|
|
| 95 | + result.setFloatingObjectModifications(floatingObjectModifications);
|
|
| 96 | + result.setLengthLengthParameterNotFound(getLengthLengthParameterNotFoundBuilder());
|
|
| 97 | + result.setLengthWeightParameterNotFound(getLengthWeightParameterNotFoundBuilder());
|
|
| 98 | + return Optional.of(result);
|
|
| 104 | 99 | }
|
| 105 | 100 | |
| 106 | 101 | public Set<String> getLengthWeightParameterNotFoundBuilder() {
|
| ... | ... | @@ -111,90 +106,22 @@ public class ActivityConsolidateResultBuilder { |
| 111 | 106 | return lengthLengthParameterNotFoundBuilder;
|
| 112 | 107 | }
|
| 113 | 108 | |
| 114 | - void flushDcpModification(FloatingObjectConsolidateResult result) {
|
|
| 115 | - dcpModificationBuilder.addAll(result.getFloatingObjectModifications());
|
|
| 109 | + void flushFloatingObjectModification(FloatingObjectConsolidateResult result) {
|
|
| 110 | + floatingObjectModificationBuilder.addAll(result.getModifications());
|
|
| 116 | 111 | }
|
| 117 | 112 | |
| 118 | - void flushSampleMeasureModification(SampleMeasure targetLength, String... propertyNamesModified) {
|
|
| 119 | - |
|
| 120 | - Species species = targetLength.getSpecies();
|
|
| 121 | - String speciesLabel = decorate(species);
|
|
| 113 | + void flushSampleMeasureModification(SampleMeasure sampleMeasure, String... propertyNamesModified) {
|
|
| 122 | 114 | for (String modifiedProperty : propertyNamesModified) {
|
| 123 | - if (modifiedProperty.equals(SampleMeasure.PROPERTY_LENGTH)) {
|
|
| 124 | - SampleMeasureModification element = new SampleMeasureModification();
|
|
| 125 | - element.setId(targetLength.getTopiaId());
|
|
| 126 | - element.setSpeciesLabel(speciesLabel);
|
|
| 127 | - element.setPropertyName(SampleMeasure.PROPERTY_LENGTH);
|
|
| 128 | - element.setNewValue(targetLength.getLength());
|
|
| 129 | - sampleMeasureObsModificationBuilder.add(element);
|
|
| 130 | - } else if (modifiedProperty.equals(SampleMeasure.PROPERTY_WEIGHT)) {
|
|
| 131 | - SampleMeasureModification element = new SampleMeasureModification();
|
|
| 132 | - element.setId(targetLength.getTopiaId());
|
|
| 133 | - element.setSpeciesLabel(speciesLabel);
|
|
| 134 | - element.setPropertyName(SampleMeasure.PROPERTY_LENGTH);
|
|
| 135 | - element.setNewValue(targetLength.getLength());
|
|
| 136 | - sampleMeasureObsModificationBuilder.add(element);
|
|
| 137 | - }
|
|
| 115 | + JavaBeanPropertyModification element = new JavaBeanPropertyModification(sampleMeasure, modifiedProperty);
|
|
| 116 | + sampleMeasureModificationBuilder.add(element);
|
|
| 138 | 117 | }
|
| 139 | 118 | }
|
| 140 | 119 | |
| 141 | 120 | void flushCatchModification(Catch aCatch, String... propertyNamesModified) {
|
| 142 | - |
|
| 143 | - Species species = aCatch.getSpecies();
|
|
| 144 | - String speciesLabel = decorate(species);
|
|
| 145 | 121 | for (String modifiedProperty : propertyNamesModified) {
|
| 146 | - switch (modifiedProperty) {
|
|
| 147 | - case Catch.PROPERTY_MEAN_LENGTH: {
|
|
| 148 | - |
|
| 149 | - CatchModification element = new CatchModification();
|
|
| 150 | - element.setCatchId(aCatch.getTopiaId());
|
|
| 151 | - element.setSpeciesLabel(speciesLabel);
|
|
| 152 | - element.setPropertyName(Catch.PROPERTY_MEAN_LENGTH);
|
|
| 153 | - element.setNewValue(aCatch.getMeanLength());
|
|
| 154 | -// element.computeValueSource = I18nEnumUtil.getLabel(locale, aCatches.getMeanLengthComputedSource());
|
|
| 155 | - catchObsModificationBuilder.add(element);
|
|
| 156 | - |
|
| 157 | - break;
|
|
| 158 | - }
|
|
| 159 | - case Catch.PROPERTY_MEAN_WEIGHT: {
|
|
| 160 | - |
|
| 161 | - CatchModification element = new CatchModification();
|
|
| 162 | - element.setCatchId(aCatch.getTopiaId());
|
|
| 163 | - element.setSpeciesLabel(speciesLabel);
|
|
| 164 | - element.setPropertyName(Catch.PROPERTY_MEAN_WEIGHT);
|
|
| 165 | - element.setNewValue(aCatch.getMeanWeight());
|
|
| 166 | -// element.computeValueSource = I18nEnumUtil.getLabel(locale, aCatches.getMeanWeightComputedSource());
|
|
| 167 | - catchObsModificationBuilder.add(element);
|
|
| 168 | - |
|
| 169 | - break;
|
|
| 170 | - }
|
|
| 171 | - case Catch.PROPERTY_CATCH_WEIGHT: {
|
|
| 172 | - |
|
| 173 | - CatchModification element = new CatchModification();
|
|
| 174 | - element.setCatchId(aCatch.getTopiaId());
|
|
| 175 | - element.setSpeciesLabel(speciesLabel);
|
|
| 176 | - element.setPropertyName(Catch.PROPERTY_CATCH_WEIGHT);
|
|
| 177 | - element.setNewValue(aCatch.getCatchWeight());
|
|
| 178 | -// element.computeValueSource = I18nEnumUtil.getLabel(locale, aCatches.getCatchWeightComputedSource());
|
|
| 179 | - catchObsModificationBuilder.add(element);
|
|
| 180 | - |
|
| 181 | - break;
|
|
| 182 | - }
|
|
| 183 | - case Catch.PROPERTY_TOTAL_COUNT: {
|
|
| 184 | - |
|
| 185 | - CatchModification element = new CatchModification();
|
|
| 186 | - element.setCatchId(aCatch.getTopiaId());
|
|
| 187 | - element.setSpeciesLabel(speciesLabel);
|
|
| 188 | - element.setPropertyName(Catch.PROPERTY_TOTAL_COUNT);
|
|
| 189 | - element.setNewValue(aCatch.getTotalCount());
|
|
| 190 | -// element.computeValueSource = I18nEnumUtil.getLabel(locale, aCatches.getTotalCountComputedSource());
|
|
| 191 | - catchObsModificationBuilder.add(element);
|
|
| 192 | - |
|
| 193 | - break;
|
|
| 194 | - }
|
|
| 195 | - }
|
|
| 122 | + JavaBeanPropertyModification element = new JavaBeanPropertyModification(aCatch, modifiedProperty);
|
|
| 123 | + catchModificationBuilder.add(element);
|
|
| 196 | 124 | }
|
| 197 | - |
|
| 198 | 125 | }
|
| 199 | 126 | |
| 200 | 127 | ActivityConsolidateResultBuilder registerLengthWeightParameterNotFound(Species species, Ocean ocean, Sex sex, Date routeDate) {
|
| ... | ... | @@ -228,6 +155,7 @@ public class ActivityConsolidateResultBuilder { |
| 228 | 155 | this.newSchoolType = newSchoolType;
|
| 229 | 156 | return this;
|
| 230 | 157 | }
|
| 158 | + |
|
| 231 | 159 | //FIXME use decorator
|
| 232 | 160 | private String decorate(Species species) {
|
| 233 | 161 | StringBuilder builder = new StringBuilder();
|
| ... | ... | @@ -68,8 +68,8 @@ public class ConsolidateDataServiceFixtures extends GeneratedConsolidateDataServ |
| 68 | 68 | Optional<FloatingObjectConsolidateResult> optionalResult = engine.consolidate(request);
|
| 69 | 69 | Assert.assertTrue(optionalResult.isPresent());
|
| 70 | 70 | FloatingObjectConsolidateResult result = optionalResult.get();
|
| 71 | - Assert.assertNotNull(result.getFloatingObjectModifications());
|
|
| 72 | - Assert.assertEquals(getIntegerProperty("consolidateFloatingObjectLogbook.count"), result.getFloatingObjectModifications().size());
|
|
| 71 | + Assert.assertNotNull(result.getModifications());
|
|
| 72 | + Assert.assertEquals(getIntegerProperty("consolidateFloatingObjectLogbook.count"), result.getModifications().size());
|
|
| 73 | 73 | }
|
| 74 | 74 | {
|
| 75 | 75 | String id = getProperty("consolidateFloatingObjectObservation.id");
|
| ... | ... | @@ -84,8 +84,8 @@ public class ConsolidateDataServiceFixtures extends GeneratedConsolidateDataServ |
| 84 | 84 | Optional<FloatingObjectConsolidateResult> optionalResult = engine.consolidate(request);
|
| 85 | 85 | Assert.assertTrue(optionalResult.isPresent());
|
| 86 | 86 | FloatingObjectConsolidateResult result = optionalResult.get();
|
| 87 | - Assert.assertNotNull(result.getFloatingObjectModifications());
|
|
| 88 | - Assert.assertEquals(getIntegerProperty("consolidateFloatingObjectObservation.count"), result.getFloatingObjectModifications().size());
|
|
| 87 | + Assert.assertNotNull(result.getModifications());
|
|
| 88 | + Assert.assertEquals(getIntegerProperty("consolidateFloatingObjectObservation.count"), result.getModifications().size());
|
|
| 89 | 89 | }
|
| 90 | 90 | }
|
| 91 | 91 |
| ... | ... | @@ -24,10 +24,10 @@ package fr.ird.observe.dto; |
| 24 | 24 | |
| 25 | 25 | import io.ultreia.java4all.bean.JavaBean;
|
| 26 | 26 | import io.ultreia.java4all.bean.monitor.BeanMonitor;
|
| 27 | +import io.ultreia.java4all.util.json.JsonAware;
|
|
| 27 | 28 | import org.apache.logging.log4j.LogManager;
|
| 28 | 29 | import org.apache.logging.log4j.Logger;
|
| 29 | 30 | |
| 30 | -import java.io.Serializable;
|
|
| 31 | 31 | import java.util.LinkedHashSet;
|
| 32 | 32 | import java.util.Optional;
|
| 33 | 33 | import java.util.Set;
|
| ... | ... | @@ -38,17 +38,17 @@ import java.util.Set; |
| 38 | 38 | * @author Tony Chemit - dev@tchemit.fr
|
| 39 | 39 | * @since 9.0.0
|
| 40 | 40 | */
|
| 41 | -public class DtoPropertyModifications implements ObserveDto {
|
|
| 41 | +public class DtoPropertyModifications implements JsonAware {
|
|
| 42 | 42 | private static final Logger log = LogManager.getLogger(DtoPropertyModifications.class);
|
| 43 | 43 | |
| 44 | 44 | private final String id;
|
| 45 | 45 | private final String label;
|
| 46 | - private final Set<DtoPropertyModification> properties;
|
|
| 46 | + private final Set<JavaBeanPropertyModification> properties;
|
|
| 47 | 47 | private final String lengthWeightParameterNotFound;
|
| 48 | 48 | |
| 49 | 49 | public static abstract class Builder<R extends DtoPropertyModifications> {
|
| 50 | 50 | private final BeanMonitor monitor;
|
| 51 | - private final Set<DtoPropertyModification> modifications = new LinkedHashSet<>();
|
|
| 51 | + private final Set<JavaBeanPropertyModification> modifications = new LinkedHashSet<>();
|
|
| 52 | 52 | private String id;
|
| 53 | 53 | private String label;
|
| 54 | 54 | private String lengthWeightParameterNotFound;
|
| ... | ... | @@ -57,7 +57,7 @@ public class DtoPropertyModifications implements ObserveDto { |
| 57 | 57 | monitor = new BeanMonitor(propertyNames);
|
| 58 | 58 | }
|
| 59 | 59 | |
| 60 | - protected void watch(IdDto dto) {
|
|
| 60 | + protected void watch(JavaBean dto) {
|
|
| 61 | 61 | modifications.clear();
|
| 62 | 62 | id = label = lengthWeightParameterNotFound = null;
|
| 63 | 63 | monitor.setBean(dto);
|
| ... | ... | @@ -80,13 +80,13 @@ public class DtoPropertyModifications implements ObserveDto { |
| 80 | 80 | return Optional.of(result);
|
| 81 | 81 | }
|
| 82 | 82 | |
| 83 | - protected abstract R createResult(String id, String label, Set<DtoPropertyModification> modifications, String lengthWeightParameterNotFound);
|
|
| 83 | + protected abstract R createResult(String id, String label, Set<JavaBeanPropertyModification> modifications, String lengthWeightParameterNotFound);
|
|
| 84 | 84 | |
| 85 | 85 | public void flushToResult(IdDto dto, String... propertyNamesModified) {
|
| 86 | 86 | this.id = dto.getId();
|
| 87 | 87 | this.label = dto.toString();
|
| 88 | 88 | for (String modifiedProperty : propertyNamesModified) {
|
| 89 | - DtoPropertyModification element = new DtoPropertyModification(dto, modifiedProperty);
|
|
| 89 | + JavaBeanPropertyModification element = new JavaBeanPropertyModification(dto, modifiedProperty);
|
|
| 90 | 90 | modifications.add(element);
|
| 91 | 91 | }
|
| 92 | 92 | }
|
| ... | ... | @@ -99,7 +99,7 @@ public class DtoPropertyModifications implements ObserveDto { |
| 99 | 99 | }
|
| 100 | 100 | }
|
| 101 | 101 | |
| 102 | - public DtoPropertyModifications(String id, String label, Set<DtoPropertyModification> properties, String lengthWeightParameterNotFound) {
|
|
| 102 | + public DtoPropertyModifications(String id, String label, Set<JavaBeanPropertyModification> properties, String lengthWeightParameterNotFound) {
|
|
| 103 | 103 | this.id = id;
|
| 104 | 104 | this.label = label;
|
| 105 | 105 | this.properties = properties;
|
| ... | ... | @@ -114,7 +114,7 @@ public class DtoPropertyModifications implements ObserveDto { |
| 114 | 114 | return label;
|
| 115 | 115 | }
|
| 116 | 116 | |
| 117 | - public Set<DtoPropertyModification> getProperties() {
|
|
| 117 | + public Set<JavaBeanPropertyModification> getProperties() {
|
|
| 118 | 118 | return properties;
|
| 119 | 119 | }
|
| 120 | 120 | |
| ... | ... | @@ -122,10 +122,7 @@ public class DtoPropertyModifications implements ObserveDto { |
| 122 | 122 | return lengthWeightParameterNotFound;
|
| 123 | 123 | }
|
| 124 | 124 | |
| 125 | - public void flushToDto(JavaBean dto) {
|
|
| 126 | - properties.forEach(modification -> {
|
|
| 127 | - Serializable newValue = modification.getNewValue();
|
|
| 128 | - dto.set(modification.getPropertyName(), newValue);
|
|
| 129 | - });
|
|
| 125 | + public void flushToBean(JavaBean bean) {
|
|
| 126 | + properties.forEach(modification -> modification.flushToBean(bean));
|
|
| 130 | 127 | }
|
| 131 | 128 | } |
| ... | ... | @@ -22,28 +22,35 @@ package fr.ird.observe.dto; |
| 22 | 22 | * #L%
|
| 23 | 23 | */
|
| 24 | 24 | |
| 25 | +import io.ultreia.java4all.bean.JavaBean;
|
|
| 26 | +import io.ultreia.java4all.util.json.JsonAware;
|
|
| 27 | + |
|
| 25 | 28 | import java.io.Serializable;
|
| 26 | 29 | import java.util.Objects;
|
| 27 | 30 | |
| 28 | 31 | /**
|
| 29 | - * Represents a modification on a property of a {@link IdDto}.
|
|
| 32 | + * To keep a javaBean property modification.
|
|
| 30 | 33 | * <p>
|
| 31 | - * Created on 30/08/2020.
|
|
| 34 | + * Created on 15/02/2023.
|
|
| 32 | 35 | *
|
| 33 | 36 | * @author Tony Chemit - dev@tchemit.fr
|
| 34 | - * @since 8.1.0
|
|
| 37 | + * @since 9.0.26
|
|
| 35 | 38 | */
|
| 36 | -public class DtoPropertyModification implements ObserveDto {
|
|
| 39 | +public class JavaBeanPropertyModification implements JsonAware {
|
|
| 37 | 40 | |
| 38 | 41 | private final String id;
|
| 39 | 42 | private final String propertyName;
|
| 40 | 43 | private final Serializable newValue;
|
| 41 | 44 | |
| 42 | - public DtoPropertyModification(IdDto dto, String propertyName) {
|
|
| 45 | + public JavaBeanPropertyModification(IdDto dto, String propertyName) {
|
|
| 43 | 46 | this(Objects.requireNonNull(dto).getId(), propertyName, dto.get(propertyName));
|
| 44 | 47 | }
|
| 45 | 48 | |
| 46 | - public DtoPropertyModification(String id, String propertyName, Serializable newValue) {
|
|
| 49 | + public JavaBeanPropertyModification(JavaBean bean, String propertyName) {
|
|
| 50 | + this(bean.get(ToolkitId.PROPERTY_TOOLKIT_ID), propertyName, bean.get(propertyName));
|
|
| 51 | + }
|
|
| 52 | + |
|
| 53 | + public JavaBeanPropertyModification(String id, String propertyName, Serializable newValue) {
|
|
| 47 | 54 | this.id = id;
|
| 48 | 55 | this.propertyName = propertyName;
|
| 49 | 56 | this.newValue = newValue;
|
| ... | ... | @@ -61,4 +68,9 @@ public class DtoPropertyModification implements ObserveDto { |
| 61 | 68 | return newValue;
|
| 62 | 69 | }
|
| 63 | 70 | |
| 71 | + public void flushToBean(JavaBean bean) {
|
|
| 72 | + Serializable newValue = getNewValue();
|
|
| 73 | + bean.set(getPropertyName(), newValue);
|
|
| 74 | + }
|
|
| 64 | 75 | }
|
| 76 | + |
| ... | ... | @@ -30,7 +30,7 @@ import com.google.gson.JsonObject; |
| 30 | 30 | import com.google.gson.JsonParseException;
|
| 31 | 31 | import com.google.gson.JsonSerializationContext;
|
| 32 | 32 | import com.google.gson.JsonSerializer;
|
| 33 | -import fr.ird.observe.dto.DtoPropertyModification;
|
|
| 33 | +import fr.ird.observe.dto.JavaBeanPropertyModification;
|
|
| 34 | 34 | import io.ultreia.java4all.util.json.JsonAdapter;
|
| 35 | 35 | |
| 36 | 36 | import java.io.Serializable;
|
| ... | ... | @@ -43,32 +43,36 @@ import java.lang.reflect.Type; |
| 43 | 43 | * @since 8.1.0
|
| 44 | 44 | */
|
| 45 | 45 | @AutoService(JsonAdapter.class)
|
| 46 | -public class DtoPropertyModificationAdapter implements JsonDeserializer<DtoPropertyModification>, JsonSerializer<DtoPropertyModification>, JsonAdapter {
|
|
| 46 | +public class JavaBeanPropertyModificationAdapter implements JsonDeserializer<JavaBeanPropertyModification>, JsonSerializer<JavaBeanPropertyModification>, JsonAdapter {
|
|
| 47 | + |
|
| 48 | + public static final String ID = "id";
|
|
| 49 | + public static final String PROPERTY_NAME = "propertyName";
|
|
| 50 | + public static final String TYPE = "type";
|
|
| 51 | + public static final String NEW_VALUE = "newValue";
|
|
| 52 | + |
|
| 47 | 53 | @Override
|
| 48 | 54 | public Class<?> type() {
|
| 49 | - return DtoPropertyModification.class;
|
|
| 55 | + return JavaBeanPropertyModification.class;
|
|
| 50 | 56 | }
|
| 51 | 57 | |
| 52 | - |
|
| 53 | 58 | @Override
|
| 54 | - public DtoPropertyModification deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
|
| 55 | - JsonObject reportVariableJson = json.getAsJsonObject();
|
|
| 56 | - |
|
| 57 | - String dcpId = context.deserialize(reportVariableJson.get("dcpId"), String.class);
|
|
| 58 | - String propertyName = context.deserialize(reportVariableJson.get("propertyName"), String.class);
|
|
| 59 | - Class<?> type = context.deserialize(reportVariableJson.get("type"), Class.class);
|
|
| 60 | - Serializable newValue1 = context.deserialize(reportVariableJson.get("newValue"), type);
|
|
| 61 | - return new DtoPropertyModification(dcpId, propertyName, newValue1);
|
|
| 59 | + public JavaBeanPropertyModification deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
|
| 60 | + JsonObject jsonObject = json.getAsJsonObject();
|
|
| 61 | + String dcpId = context.deserialize(jsonObject.get(ID), String.class);
|
|
| 62 | + String propertyName = context.deserialize(jsonObject.get(PROPERTY_NAME), String.class);
|
|
| 63 | + Class<?> type = context.deserialize(jsonObject.get(TYPE), Class.class);
|
|
| 64 | + Serializable newValue = context.deserialize(jsonObject.get(NEW_VALUE), type);
|
|
| 65 | + return new JavaBeanPropertyModification(dcpId, propertyName, newValue);
|
|
| 62 | 66 | }
|
| 63 | 67 | |
| 64 | 68 | @Override
|
| 65 | - public JsonElement serialize(DtoPropertyModification src, Type typeOfSrc, JsonSerializationContext context) {
|
|
| 69 | + public JsonElement serialize(JavaBeanPropertyModification src, Type typeOfSrc, JsonSerializationContext context) {
|
|
| 66 | 70 | JsonObject result = new JsonObject();
|
| 67 | - result.add("dcpId", context.serialize(src.getId()));
|
|
| 68 | - result.add("propertyName", context.serialize(src.getPropertyName()));
|
|
| 71 | + result.add(ID, context.serialize(src.getId()));
|
|
| 72 | + result.add(PROPERTY_NAME, context.serialize(src.getPropertyName()));
|
|
| 69 | 73 | Serializable newValue = src.getNewValue();
|
| 70 | - result.add("type", context.serialize(newValue == null ? String.class : newValue.getClass()));
|
|
| 71 | - result.add("newValue", context.serialize(newValue));
|
|
| 74 | + result.add(TYPE, context.serialize(newValue == null ? String.class : newValue.getClass()));
|
|
| 75 | + result.add(NEW_VALUE, context.serialize(newValue));
|
|
| 72 | 76 | return result;
|
| 73 | 77 | }
|
| 74 | 78 | } |