Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe Commits: 1810406c by Tony Chemit at 2023-01-03T18:56:21+01:00 Imperfection de la validation sur une activité de pêche - Closes #2581 - - - - - bdedac69 by Tony Chemit at 2023-01-03T18:56:26+01:00 Après création d'une activité, le nœud captures n'apparaît pas - Closes #2582 - - - - - 95d05194 by Tony Chemit at 2023-01-03T18:56:30+01:00 Les activités ne sont pas disponibles lors de la création d'un échantillon (mais disponible en mode mis à jour) - Closes #2584 - - - - - 8e4455c5 by Tony Chemit at 2023-01-03T18:56:33+01:00 Problème sur la sauvegarde d'un échantillon (si on lui associe des activités) - Closes #2585 - - - - - 12 changed files: - client/datasource/editor/spi/src/main/java/fr/ird/observe/client/datasource/editor/spi/content/CapabilityDescriptor.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/logbook/ActivityDto-create-error-validation.xml - core/api/validation/src/main/resources/fr/ird/observe/dto/data/ps/logbook/ActivityDto-update-error-validation.xml - core/persistence/java/src/main/java/fr/ird/observe/entities/data/ps/logbook/SampleSpi.java - core/persistence/resources/src/main/resources/fr/ird/observe/entities/data/ps/logbook/Activity/validation-create.json - core/persistence/resources/src/main/resources/fr/ird/observe/entities/data/ps/logbook/Activity/validation-update.json - model/src/main/models/Observe/dto/attribute/notNullIf.properties - server/runner/src/main/webResources/doc/api/public/data/ps/logbook/Activity/validation-create-error.xml - server/runner/src/main/webResources/doc/api/public/data/ps/logbook/Activity/validation-create.json - server/runner/src/main/webResources/doc/api/public/data/ps/logbook/Activity/validation-update-error.xml - server/runner/src/main/webResources/doc/api/public/data/ps/logbook/Activity/validation-update.json Changes: ===================================== client/datasource/editor/spi/src/main/java/fr/ird/observe/client/datasource/editor/spi/content/CapabilityDescriptor.java ===================================== @@ -388,7 +388,7 @@ public class CapabilityDescriptor { switch (capacityNodeType) { case STATIC_WITH_PREDICATE: { String beanPropertyName = getOptionalPredicate().orElseThrow(); - return String.format(" .onPredicate(d-> d.is%1$s() && d.get%2$sStatValue() > 0, %3$s.class)\n", beanPropertyName, Strings.removeEnd(beanPropertyName,"Enabled"), getNodeTypeSimpleName()); + return String.format(" .onPredicate(%1$s::is%2$s, %3$s.class)\n", mainDtoType.getSimpleName(), beanPropertyName, getNodeTypeSimpleName()); } case REFERENCE_LIST: case REFERENCE: { ===================================== core/api/validation/src/main/filtered-resources/META-INF/validators/validation.json ===================================== @@ -9666,7 +9666,7 @@ "name": "schoolType", "comments": [ "check if referential schoolType is disabled (only if validation is strong)", - "schoolType is mandatory except if !setEnabled" + "schoolType is mandatory except if !setEnabled || reasonForNoFishing != null" ] }, { @@ -9939,7 +9939,7 @@ "name": "schoolType", "comments": [ "check if referential schoolType is disabled (only if validation is strong)", - "schoolType is mandatory except if !setEnabled" + "schoolType is mandatory except if !setEnabled || reasonForNoFishing != null" ] }, { ===================================== core/api/validation/src/main/resources/fr/ird/observe/dto/data/ps/logbook/ActivityDto-create-error-validation.xml ===================================== @@ -236,9 +236,9 @@ </field> <field name="schoolType"> - <!-- schoolType is mandatory except if !setEnabled --> + <!-- schoolType is mandatory except if !setEnabled || reasonForNoFishing != null --> <field-validator type="mandatory" short-circuit="true"> - <param name="skip"><![CDATA[ !setEnabled ]]></param> + <param name="skip"><![CDATA[ !setEnabled || reasonForNoFishing != null ]]></param> <message>observe.data.ps.logbook.Activity.schoolType.validation.required</message> </field-validator> ===================================== core/api/validation/src/main/resources/fr/ird/observe/dto/data/ps/logbook/ActivityDto-update-error-validation.xml ===================================== @@ -236,9 +236,9 @@ </field> <field name="schoolType"> - <!-- schoolType is mandatory except if !setEnabled --> + <!-- schoolType is mandatory except if !setEnabled || reasonForNoFishing != null --> <field-validator type="mandatory" short-circuit="true"> - <param name="skip"><![CDATA[ !setEnabled ]]></param> + <param name="skip"><![CDATA[ !setEnabled || reasonForNoFishing != null ]]></param> <message>observe.data.ps.logbook.Activity.schoolType.validation.required</message> </field-validator> ===================================== core/persistence/java/src/main/java/fr/ird/observe/entities/data/ps/logbook/SampleSpi.java ===================================== @@ -29,6 +29,7 @@ import fr.ird.observe.dto.referential.ReferentialLocale; import fr.ird.observe.entities.data.ps.common.Trip; import fr.ird.observe.entities.referential.ps.common.SampleType; import fr.ird.observe.entities.referential.ps.logbook.SampleQuality; +import fr.ird.observe.services.service.SaveResultDto; import fr.ird.observe.spi.service.ServiceContext; import java.util.Objects; @@ -63,7 +64,9 @@ public class SampleSpi extends GeneratedSampleSpi { preCreated.setSampleType(SampleType.loadEntity(context, ProtectedIdsPs.PS_LOGBOOK_SAMPLE_DEFAULT_SAMPLE_TYPE_ID)); preCreated.setSampleQuality(SampleQuality.loadEntity(context, ProtectedIdsPs.PS_LOGBOOK_SAMPLE_DEFAULT_SAMPLE_QUALITY_ID)); preCreated.setSuperSample(false); - return super.preCreate(context, parent, preCreated); + Form<SampleDto> form = super.preCreate(context, parent, preCreated); + form.getObject().setActivity(Trip.SPI.getLogbookSetActivities(context, parent.getTopiaId())); + return form; } @Override @@ -90,6 +93,13 @@ public class SampleSpi extends GeneratedSampleSpi { private int getSampleSpeciesSubNumber(Sample entity) { return (int) entity.getSampleSpecies().stream().mapToInt(SampleSpecies::getSubSampleNumber).distinct().count(); } + + @Override + protected SaveResultDto saveEntity(ServiceContext context, Trip parent, Sample entity) { + SampleActivity.SPI.initId(context, entity.getSampleActivity()); + return super.saveEntity(context, parent, entity); + } + //FIXME Add a callback in MoveRequest // @Override // public void moveCallback(Trip oldParent, Trip newParent, List<Sample> moved) { ===================================== core/persistence/resources/src/main/resources/fr/ird/observe/entities/data/ps/logbook/Activity/validation-create.json ===================================== @@ -124,7 +124,7 @@ "schoolType": { "errors": [ "check if referential schoolType is disabled (only if validation is strong)", - "schoolType is mandatory except if !setEnabled" + "schoolType is mandatory except if !setEnabled || reasonForNoFishing != null" ], "warnings": [ "check if referential schoolType is disabled (only if validation is not strong)" ===================================== core/persistence/resources/src/main/resources/fr/ird/observe/entities/data/ps/logbook/Activity/validation-update.json ===================================== @@ -124,7 +124,7 @@ "schoolType": { "errors": [ "check if referential schoolType is disabled (only if validation is strong)", - "schoolType is mandatory except if !setEnabled" + "schoolType is mandatory except if !setEnabled || reasonForNoFishing != null" ], "warnings": [ "check if referential schoolType is disabled (only if validation is not strong)" ===================================== model/src/main/models/Observe/dto/attribute/notNullIf.properties ===================================== @@ -46,7 +46,7 @@ data.ps.localmarket.Batch.attribute.weight=countOrWeightValid data.ps.logbook.Activity.attribute.latitude=floatingObjectEnabled && !setEnabled data.ps.logbook.Activity.attribute.longitude=floatingObjectEnabled && !setEnabled data.ps.logbook.Activity.attribute.quadrant=floatingObjectEnabled && !setEnabled -data.ps.logbook.Activity.attribute.schoolType=!setEnabled +data.ps.logbook.Activity.attribute.schoolType=!setEnabled || reasonForNoFishing != null data.ps.logbook.Activity.attribute.setCount=!setEnabled data.ps.logbook.Activity.attribute.setSuccessStatus=!setEnabled || reasonForNoFishing != null data.ps.logbook.Catch.attribute.weight=count != null && count > 0 ===================================== server/runner/src/main/webResources/doc/api/public/data/ps/logbook/Activity/validation-create-error.xml ===================================== @@ -234,9 +234,9 @@ </field> <field name="schoolType"> - <!-- schoolType is mandatory except if !setEnabled --> + <!-- schoolType is mandatory except if !setEnabled || reasonForNoFishing != null --> <field-validator type="mandatory" short-circuit="true"> - <param name="skip"><![CDATA[ !setEnabled ]]></param> + <param name="skip"><![CDATA[ !setEnabled || reasonForNoFishing != null ]]></param> <message>observe.data.ps.logbook.Activity.schoolType.validation.required</message> </field-validator> ===================================== server/runner/src/main/webResources/doc/api/public/data/ps/logbook/Activity/validation-create.json ===================================== @@ -124,7 +124,7 @@ "schoolType": { "errors": [ "check if referential schoolType is disabled (only if validation is strong)", - "schoolType is mandatory except if !setEnabled" + "schoolType is mandatory except if !setEnabled || reasonForNoFishing != null" ], "warnings": [ "check if referential schoolType is disabled (only if validation is not strong)" ===================================== server/runner/src/main/webResources/doc/api/public/data/ps/logbook/Activity/validation-update-error.xml ===================================== @@ -234,9 +234,9 @@ </field> <field name="schoolType"> - <!-- schoolType is mandatory except if !setEnabled --> + <!-- schoolType is mandatory except if !setEnabled || reasonForNoFishing != null --> <field-validator type="mandatory" short-circuit="true"> - <param name="skip"><![CDATA[ !setEnabled ]]></param> + <param name="skip"><![CDATA[ !setEnabled || reasonForNoFishing != null ]]></param> <message>observe.data.ps.logbook.Activity.schoolType.validation.required</message> </field-validator> ===================================== server/runner/src/main/webResources/doc/api/public/data/ps/logbook/Activity/validation-update.json ===================================== @@ -124,7 +124,7 @@ "schoolType": { "errors": [ "check if referential schoolType is disabled (only if validation is strong)", - "schoolType is mandatory except if !setEnabled" + "schoolType is mandatory except if !setEnabled || reasonForNoFishing != null" ], "warnings": [ "check if referential schoolType is disabled (only if validation is not strong)" View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/8b41a19189b06da580e06945c... -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/8b41a19189b06da580e06945c... You're receiving this email because of your account on gitlab.com.