[Git][ultreiaio/ird-observe][develop-9.0.x] PS-LocalMarket-Batch (use in form only ids for available packaging ids)
Tony CHEMIT pushed to branch develop-9.0.x at ultreiaio / ird-observe Commits: 70762198 by Tony Chemit at 2023-02-05T09:41:21+01:00 PS-LocalMarket-Batch (use in form only ids for available packaging ids) - - - - - 10 changed files: - client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/localmarket/TripBatchUIModelStates.java - core/api/validation/src/main/filtered-resources/META-INF/validators/validation.json - core/api/validation/src/main/resources/fr/ird/observe/dto/data/ps/localmarket/TripBatchDto-create-error-validation.xml - − core/api/validation/src/main/resources/fr/ird/observe/dto/data/ps/localmarket/TripBatchDto-create-warning-validation.xml - core/api/validation/src/main/resources/fr/ird/observe/dto/data/ps/localmarket/TripBatchDto-update-error-validation.xml - − core/api/validation/src/main/resources/fr/ird/observe/dto/data/ps/localmarket/TripBatchDto-update-warning-validation.xml - core/persistence/java/src/main/java/fr/ird/observe/entities/data/ps/common/TripBatchSpi.java - model/src/main/models/Observe/dto/23-data-ps-localmarket.model - model/src/main/models/Observe/dto/attribute/ordered.properties - model/src/main/models/Observe/dto/attribute/unique.properties Changes: ===================================== client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/localmarket/TripBatchUIModelStates.java ===================================== @@ -36,7 +36,6 @@ import fr.ird.observe.dto.data.ps.localmarket.consolidate.BatchConsolidateReques import fr.ird.observe.dto.data.ps.localmarket.consolidate.BatchConsolidateResult; import fr.ird.observe.dto.form.Form; import fr.ird.observe.dto.reference.DataDtoReferenceSet; -import fr.ird.observe.dto.reference.DtoReferenceCollection; import fr.ird.observe.dto.referential.ps.localmarket.PackagingReference; import fr.ird.observe.navigation.id.Project; import fr.ird.observe.services.ObserveServicesProvider; @@ -47,8 +46,8 @@ import org.apache.logging.log4j.Logger; import java.beans.PropertyChangeEvent; import java.util.LinkedHashSet; -import java.util.LinkedList; import java.util.Set; +import java.util.stream.Collectors; @GenerateJavaBeanDefinition public class TripBatchUIModelStates extends GeneratedTripBatchUIModelStates { @@ -124,15 +123,15 @@ public class TripBatchUIModelStates extends GeneratedTripBatchUIModelStates { @Override protected void loadReferentialCacheOnOpenForm(Form<TripBatchDto> form) { - if (getReferenceCache().isHideDisabledReferential()) { - form.getObject().setAvailablePackagings(new LinkedHashSet<>(DtoReferenceCollection.filterEnabled(form.getObject().getAvailablePackagings()))); - } getReferenceCache().setDataReferenceSet(BatchDto.PROPERTY_SURVEY, DataDtoReferenceSet.of(SurveyReference.class, form.getObject().getLocalmarketSurvey(), null)); super.loadReferentialCacheOnOpenForm(form); } protected ReferencesFilter<PackagingReference> newPackagingList() { - return (dto, incomingReferences) -> new LinkedList<>(((TripBatchDto) dto).getAvailablePackagings()); + return (dto, incomingReferences) -> { + LinkedHashSet<String> availablePackagingIds = ((TripBatchDto) dto).getAvailablePackagingIds(); + return incomingReferences.stream().filter(e -> availablePackagingIds.contains(e.getId())).collect(Collectors.toList()); + }; } } ===================================== core/api/validation/src/main/filtered-resources/META-INF/validators/validation.json ===================================== @@ -9398,69 +9398,29 @@ "scope": "ERROR", "context": "create", "fields": [ - { - "name": "availablePackagings", - "comments": [ - "check if referential availablePackagings is disabled (only if validation is strong)" - ] - }, { "name": "comment", "comments": [ "comment (if not null) is not a blank string", - "comment is required if one of the selected referential requires it (availablePackagings)", "comment length <= 8192" ] } ] }, - { - "type": "fr.ird.observe.dto.data.ps.localmarket.TripBatchDto", - "scope": "WARNING", - "context": "create", - "fields": [ - { - "name": "availablePackagings", - "comments": [ - "check if referential availablePackagings is disabled (only if validation is not strong)" - ] - } - ] - }, { "type": "fr.ird.observe.dto.data.ps.localmarket.TripBatchDto", "scope": "ERROR", "context": "update", "fields": [ - { - "name": "availablePackagings", - "comments": [ - "check if referential availablePackagings is disabled (only if validation is strong)" - ] - }, { "name": "comment", "comments": [ "comment (if not null) is not a blank string", - "comment is required if one of the selected referential requires it (availablePackagings)", "comment length <= 8192" ] } ] }, - { - "type": "fr.ird.observe.dto.data.ps.localmarket.TripBatchDto", - "scope": "WARNING", - "context": "update", - "fields": [ - { - "name": "availablePackagings", - "comments": [ - "check if referential availablePackagings is disabled (only if validation is not strong)" - ] - } - ] - }, { "type": "fr.ird.observe.dto.data.ps.localmarket.WellIdDto", "scope": "ERROR", ===================================== core/api/validation/src/main/resources/fr/ird/observe/dto/data/ps/localmarket/TripBatchDto-create-error-validation.xml ===================================== @@ -24,13 +24,6 @@ "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd"> <validators> - <field name="availablePackagings"> - <!-- check if referential availablePackagings is disabled (only if validation is strong) --> - <field-validator type="checkDisabledReferentialOnErrorScope"> - <message/> - </field-validator> - </field> - <field name="comment"> <!-- comment (if not null) is not a blank string --> <field-validator type="notBlankString" short-circuit="true"> @@ -42,12 +35,6 @@ <param name="maxLength">8192</param> <message/> </field-validator> - - <!-- comment is required if one of the selected referential requires it (availablePackagings) --> - <field-validator type="commentNeeded"> - <param name="propertyNames">availablePackagings</param> - <message/> - </field-validator> </field> </validators> ===================================== core/api/validation/src/main/resources/fr/ird/observe/dto/data/ps/localmarket/TripBatchDto-create-warning-validation.xml deleted ===================================== @@ -1,34 +0,0 @@ -<!-- - #%L - ObServe Core :: API :: Validation - %% - Copyright (C) 2008 - 2023 IRD, Ultreia.io - %% - 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 - 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 - License along with this program. If not, see - <http://www.gnu.org/licenses/gpl-3.0.html>. - #L% - --> -<!DOCTYPE validators PUBLIC - "-//Apache Struts//XWork Validator 1.0.3//EN" - "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd"> -<validators> - - <field name="availablePackagings"> - <!-- check if referential availablePackagings is disabled (only if validation is not strong) --> - <field-validator type="checkDisabledReferentialOnWarningScope"> - <message/> - </field-validator> - </field> - -</validators> ===================================== core/api/validation/src/main/resources/fr/ird/observe/dto/data/ps/localmarket/TripBatchDto-update-error-validation.xml ===================================== @@ -24,13 +24,6 @@ "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd"> <validators> - <field name="availablePackagings"> - <!-- check if referential availablePackagings is disabled (only if validation is strong) --> - <field-validator type="checkDisabledReferentialOnErrorScope"> - <message/> - </field-validator> - </field> - <field name="comment"> <!-- comment (if not null) is not a blank string --> <field-validator type="notBlankString" short-circuit="true"> @@ -42,12 +35,6 @@ <param name="maxLength">8192</param> <message/> </field-validator> - - <!-- comment is required if one of the selected referential requires it (availablePackagings) --> - <field-validator type="commentNeeded"> - <param name="propertyNames">availablePackagings</param> - <message/> - </field-validator> </field> </validators> ===================================== core/api/validation/src/main/resources/fr/ird/observe/dto/data/ps/localmarket/TripBatchDto-update-warning-validation.xml deleted ===================================== @@ -1,34 +0,0 @@ -<!-- - #%L - ObServe Core :: API :: Validation - %% - Copyright (C) 2008 - 2023 IRD, Ultreia.io - %% - 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 - 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 - License along with this program. If not, see - <http://www.gnu.org/licenses/gpl-3.0.html>. - #L% - --> -<!DOCTYPE validators PUBLIC - "-//Apache Struts//XWork Validator 1.0.3//EN" - "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd"> -<validators> - - <field name="availablePackagings"> - <!-- check if referential availablePackagings is disabled (only if validation is not strong) --> - <field-validator type="checkDisabledReferentialOnWarningScope"> - <message/> - </field-validator> - </field> - -</validators> ===================================== core/persistence/java/src/main/java/fr/ird/observe/entities/data/ps/common/TripBatchSpi.java ===================================== @@ -25,7 +25,6 @@ package fr.ird.observe.entities.data.ps.common; import fr.ird.observe.dto.data.ps.localmarket.TripBatchDto; import fr.ird.observe.dto.form.Form; import fr.ird.observe.dto.referential.ReferentialLocale; -import fr.ird.observe.dto.referential.ps.localmarket.PackagingReference; import fr.ird.observe.entities.referential.common.Harbour; import fr.ird.observe.entities.referential.ps.localmarket.Packaging; import fr.ird.observe.spi.service.ServiceContext; @@ -39,8 +38,8 @@ public class TripBatchSpi extends GeneratedTripBatchSpi { @Override public void loadForm(ServiceContext context, String id, Trip parent, Form<TripBatchDto> form) { - LinkedHashSet<PackagingReference> availablePackaging = getPackaging(context, parent); - form.getObject().setAvailablePackagings(availablePackaging); + LinkedHashSet<String> availablePackagingIds = getAvailablePackagingIds(context, parent); + form.getObject().setAvailablePackagingIds(availablePackagingIds); } @Override @@ -55,14 +54,14 @@ public class TripBatchSpi extends GeneratedTripBatchSpi { entity.setLogbookComment(dto.getComment()); } - protected LinkedHashSet<PackagingReference> getPackaging(ServiceContext context, Trip trip) { + protected LinkedHashSet<String> getAvailablePackagingIds(ServiceContext context, Trip trip) { Harbour landingHarbour = trip.getLandingHarbour(); Date date = trip.getEndDate(); try (Stream<Packaging> stream = Packaging.getDao(context).streamAll()) { - return Packaging.toReferenceSet(context.getReferentialLocale(), - stream.filter(p -> p.acceptHarbour(landingHarbour) && p.acceptDate(date)), - null, - null).stream().collect(Collectors.toCollection(LinkedHashSet::new)); + return stream + .filter(p -> p.acceptHarbour(landingHarbour) && p.acceptDate(date)) + .map(Packaging::getTopiaId) + .collect(Collectors.toCollection(LinkedHashSet::new)); } } ===================================== model/src/main/models/Observe/dto/23-data-ps-localmarket.model ===================================== @@ -48,7 +48,7 @@ species {*:*} referential.common.SpeciesReference data.ps.localmarket.TripBatch > data.Container >> data.SkipSimpleMove localmarketBatch + {*} data.ps.localmarket.Batch localmarketSurvey + {*} data.ps.localmarket.SurveyReference -availablePackagings + {*} referential.ps.localmarket.PackagingReference +availablePackagingIds + {*} String data.ps.localmarket.WellId > Business >> data.InlineDataDto data.NotEntityDto data.WellIdAware well String ===================================== model/src/main/models/Observe/dto/attribute/ordered.properties ===================================== @@ -42,7 +42,7 @@ data.ps.localmarket.SampleSpecies.attribute.sampleSpeciesMeasure=true data.ps.localmarket.Survey.attribute.availableBatches=true data.ps.localmarket.Survey.attribute.batches=true data.ps.localmarket.Survey.attribute.surveyPart=true -data.ps.localmarket.TripBatch.attribute.availablePackagings=true +data.ps.localmarket.TripBatch.attribute.availablePackagingIds=true data.ps.localmarket.TripBatch.attribute.localmarketBatch=true data.ps.localmarket.TripBatch.attribute.localmarketSurvey=true data.ps.logbook.ActivityCatch.attribute.catches=true ===================================== model/src/main/models/Observe/dto/attribute/unique.properties ===================================== @@ -32,7 +32,7 @@ data.ps.common.Trip.attribute.localmarketSurvey=true data.ps.common.Trip.attribute.routeLogbook=true data.ps.common.Trip.attribute.routeObs=true data.ps.localmarket.Sample.attribute.well=true -data.ps.localmarket.TripBatch.attribute.availablePackagings=true +data.ps.localmarket.TripBatch.attribute.availablePackagingIds=true data.ps.localmarket.TripBatch.attribute.localmarketSurvey=true data.ps.logbook.Route.attribute.activity=true data.ps.observation.Activity.attribute.nonTargetCatchSpecies=true View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/commit/707621985b090e49389760d7d9... -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/commit/707621985b090e49389760d7d9... You're receiving this email because of your account on gitlab.com.
participants (1)
-
Tony CHEMIT (@tchemit)