Tony CHEMIT pushed to branch develop-9.0.x at ultreiaio / ird-observe
Commits:
-
d8016878
by Tony Chemit at 2023-01-03T14:29:48+01:00
-
cf5d1c5b
by Tony Chemit at 2023-01-03T18:35:10+01:00
-
5662c2b9
by Tony Chemit at 2023-01-03T18:35:10+01:00
-
395dc4e4
by Tony Chemit at 2023-01-03T18:35:10+01:00
-
a4c18864
by Tony Chemit at 2023-01-03T18:35:10+01:00
14 changed files:
- client/datasource/editor/spi/src/main/java/fr/ird/observe/client/datasource/editor/spi/content/CapabilityDescriptor.java
- core/api/dto/src/main/java/fr/ird/observe/dto/data/ps/observation/SetCatchDto.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/java/src/main/java/fr/ird/observe/entities/data/ps/observation/SetCatchSpi.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:
| ... | ... | @@ -388,7 +388,7 @@ public class CapabilityDescriptor { |
| 388 | 388 | switch (capacityNodeType) {
|
| 389 | 389 | case STATIC_WITH_PREDICATE: {
|
| 390 | 390 | String beanPropertyName = getOptionalPredicate().orElseThrow();
|
| 391 | - return String.format(" .onPredicate(d-> d.is%1$s() && d.get%2$sStatValue() > 0, %3$s.class)\n", beanPropertyName, Strings.removeEnd(beanPropertyName,"Enabled"), getNodeTypeSimpleName());
|
|
| 391 | + return String.format(" .onPredicate(%1$s::is%2$s, %3$s.class)\n", mainDtoType.getSimpleName(), beanPropertyName, getNodeTypeSimpleName());
|
|
| 392 | 392 | }
|
| 393 | 393 | case REFERENCE_LIST:
|
| 394 | 394 | case REFERENCE: {
|
| ... | ... | @@ -53,7 +53,7 @@ public class SetCatchDto extends GeneratedSetCatchDto { |
| 53 | 53 | * @return set of unsafe species used in catches
|
| 54 | 54 | */
|
| 55 | 55 | public Set<SpeciesReference> getUnsafeSpecies() {
|
| 56 | - return getCatches().stream().filter(CatchDto::isHasSample).map(CatchDto::getSpecies).collect(Collectors.toSet());
|
|
| 56 | + return getCatches().stream().filter(c -> c.isHasSample() || c.isHasRelease()).map(CatchDto::getSpecies).collect(Collectors.toSet());
|
|
| 57 | 57 | }
|
| 58 | 58 | |
| 59 | 59 | /**
|
| ... | ... | @@ -9666,7 +9666,7 @@ |
| 9666 | 9666 | "name": "schoolType",
|
| 9667 | 9667 | "comments": [
|
| 9668 | 9668 | "check if referential schoolType is disabled (only if validation is strong)",
|
| 9669 | - "schoolType is mandatory except if !setEnabled"
|
|
| 9669 | + "schoolType is mandatory except if !setEnabled || reasonForNoFishing != null"
|
|
| 9670 | 9670 | ]
|
| 9671 | 9671 | },
|
| 9672 | 9672 | {
|
| ... | ... | @@ -9939,7 +9939,7 @@ |
| 9939 | 9939 | "name": "schoolType",
|
| 9940 | 9940 | "comments": [
|
| 9941 | 9941 | "check if referential schoolType is disabled (only if validation is strong)",
|
| 9942 | - "schoolType is mandatory except if !setEnabled"
|
|
| 9942 | + "schoolType is mandatory except if !setEnabled || reasonForNoFishing != null"
|
|
| 9943 | 9943 | ]
|
| 9944 | 9944 | },
|
| 9945 | 9945 | {
|
| ... | ... | @@ -236,9 +236,9 @@ |
| 236 | 236 | </field>
|
| 237 | 237 | |
| 238 | 238 | <field name="schoolType">
|
| 239 | - <!-- schoolType is mandatory except if !setEnabled -->
|
|
| 239 | + <!-- schoolType is mandatory except if !setEnabled || reasonForNoFishing != null -->
|
|
| 240 | 240 | <field-validator type="mandatory" short-circuit="true">
|
| 241 | - <param name="skip"><![CDATA[ !setEnabled ]]></param>
|
|
| 241 | + <param name="skip"><![CDATA[ !setEnabled || reasonForNoFishing != null ]]></param>
|
|
| 242 | 242 | <message>observe.data.ps.logbook.Activity.schoolType.validation.required</message>
|
| 243 | 243 | </field-validator>
|
| 244 | 244 |
| ... | ... | @@ -236,9 +236,9 @@ |
| 236 | 236 | </field>
|
| 237 | 237 | |
| 238 | 238 | <field name="schoolType">
|
| 239 | - <!-- schoolType is mandatory except if !setEnabled -->
|
|
| 239 | + <!-- schoolType is mandatory except if !setEnabled || reasonForNoFishing != null -->
|
|
| 240 | 240 | <field-validator type="mandatory" short-circuit="true">
|
| 241 | - <param name="skip"><![CDATA[ !setEnabled ]]></param>
|
|
| 241 | + <param name="skip"><![CDATA[ !setEnabled || reasonForNoFishing != null ]]></param>
|
|
| 242 | 242 | <message>observe.data.ps.logbook.Activity.schoolType.validation.required</message>
|
| 243 | 243 | </field-validator>
|
| 244 | 244 |
| ... | ... | @@ -29,6 +29,7 @@ import fr.ird.observe.dto.referential.ReferentialLocale; |
| 29 | 29 | import fr.ird.observe.entities.data.ps.common.Trip;
|
| 30 | 30 | import fr.ird.observe.entities.referential.ps.common.SampleType;
|
| 31 | 31 | import fr.ird.observe.entities.referential.ps.logbook.SampleQuality;
|
| 32 | +import fr.ird.observe.services.service.SaveResultDto;
|
|
| 32 | 33 | import fr.ird.observe.spi.service.ServiceContext;
|
| 33 | 34 | |
| 34 | 35 | import java.util.Objects;
|
| ... | ... | @@ -63,7 +64,9 @@ public class SampleSpi extends GeneratedSampleSpi { |
| 63 | 64 | preCreated.setSampleType(SampleType.loadEntity(context, ProtectedIdsPs.PS_LOGBOOK_SAMPLE_DEFAULT_SAMPLE_TYPE_ID));
|
| 64 | 65 | preCreated.setSampleQuality(SampleQuality.loadEntity(context, ProtectedIdsPs.PS_LOGBOOK_SAMPLE_DEFAULT_SAMPLE_QUALITY_ID));
|
| 65 | 66 | preCreated.setSuperSample(false);
|
| 66 | - return super.preCreate(context, parent, preCreated);
|
|
| 67 | + Form<SampleDto> form = super.preCreate(context, parent, preCreated);
|
|
| 68 | + form.getObject().setActivity(Trip.SPI.getLogbookSetActivities(context, parent.getTopiaId()));
|
|
| 69 | + return form;
|
|
| 67 | 70 | }
|
| 68 | 71 | |
| 69 | 72 | @Override
|
| ... | ... | @@ -90,6 +93,13 @@ public class SampleSpi extends GeneratedSampleSpi { |
| 90 | 93 | private int getSampleSpeciesSubNumber(Sample entity) {
|
| 91 | 94 | return (int) entity.getSampleSpecies().stream().mapToInt(SampleSpecies::getSubSampleNumber).distinct().count();
|
| 92 | 95 | }
|
| 96 | + |
|
| 97 | + @Override
|
|
| 98 | + protected SaveResultDto saveEntity(ServiceContext context, Trip parent, Sample entity) {
|
|
| 99 | + SampleActivity.SPI.initId(context, entity.getSampleActivity());
|
|
| 100 | + return super.saveEntity(context, parent, entity);
|
|
| 101 | + }
|
|
| 102 | + |
|
| 93 | 103 | //FIXME Add a callback in MoveRequest
|
| 94 | 104 | // @Override
|
| 95 | 105 | // public void moveCallback(Trip oldParent, Trip newParent, List<Sample> moved) {
|
| ... | ... | @@ -48,7 +48,7 @@ public class SetCatchSpi extends GeneratedSetCatchSpi { |
| 48 | 48 | childDto.setHasSample(hasSample);
|
| 49 | 49 | });
|
| 50 | 50 | }
|
| 51 | - // on cherche si il y a des libérations d'espèce sensibles
|
|
| 51 | + // is there some non target catch release?
|
|
| 52 | 52 | if (entity.isNonTargetCatchReleaseNotEmpty()) {
|
| 53 | 53 | // get usable species ids
|
| 54 | 54 | java.util.Set<String> speciesId = ToolkitId.ids(entity.getNonTargetCatchRelease().stream().map(NonTargetCatchRelease::getSpecies));
|
| ... | ... | @@ -124,7 +124,7 @@ |
| 124 | 124 | "schoolType": {
|
| 125 | 125 | "errors": [
|
| 126 | 126 | "check if referential schoolType is disabled (only if validation is strong)",
|
| 127 | - "schoolType is mandatory except if !setEnabled"
|
|
| 127 | + "schoolType is mandatory except if !setEnabled || reasonForNoFishing != null"
|
|
| 128 | 128 | ],
|
| 129 | 129 | "warnings": [
|
| 130 | 130 | "check if referential schoolType is disabled (only if validation is not strong)"
|
| ... | ... | @@ -124,7 +124,7 @@ |
| 124 | 124 | "schoolType": {
|
| 125 | 125 | "errors": [
|
| 126 | 126 | "check if referential schoolType is disabled (only if validation is strong)",
|
| 127 | - "schoolType is mandatory except if !setEnabled"
|
|
| 127 | + "schoolType is mandatory except if !setEnabled || reasonForNoFishing != null"
|
|
| 128 | 128 | ],
|
| 129 | 129 | "warnings": [
|
| 130 | 130 | "check if referential schoolType is disabled (only if validation is not strong)"
|
| ... | ... | @@ -46,7 +46,7 @@ data.ps.localmarket.Batch.attribute.weight=countOrWeightValid |
| 46 | 46 | data.ps.logbook.Activity.attribute.latitude=floatingObjectEnabled && !setEnabled
|
| 47 | 47 | data.ps.logbook.Activity.attribute.longitude=floatingObjectEnabled && !setEnabled
|
| 48 | 48 | data.ps.logbook.Activity.attribute.quadrant=floatingObjectEnabled && !setEnabled
|
| 49 | -data.ps.logbook.Activity.attribute.schoolType=!setEnabled
|
|
| 49 | +data.ps.logbook.Activity.attribute.schoolType=!setEnabled || reasonForNoFishing != null
|
|
| 50 | 50 | data.ps.logbook.Activity.attribute.setCount=!setEnabled
|
| 51 | 51 | data.ps.logbook.Activity.attribute.setSuccessStatus=!setEnabled || reasonForNoFishing != null
|
| 52 | 52 | data.ps.logbook.Catch.attribute.weight=count != null && count > 0
|
| ... | ... | @@ -234,9 +234,9 @@ |
| 234 | 234 | </field>
|
| 235 | 235 | |
| 236 | 236 | <field name="schoolType">
|
| 237 | - <!-- schoolType is mandatory except if !setEnabled -->
|
|
| 237 | + <!-- schoolType is mandatory except if !setEnabled || reasonForNoFishing != null -->
|
|
| 238 | 238 | <field-validator type="mandatory" short-circuit="true">
|
| 239 | - <param name="skip"><![CDATA[ !setEnabled ]]></param>
|
|
| 239 | + <param name="skip"><![CDATA[ !setEnabled || reasonForNoFishing != null ]]></param>
|
|
| 240 | 240 | <message>observe.data.ps.logbook.Activity.schoolType.validation.required</message>
|
| 241 | 241 | </field-validator>
|
| 242 | 242 |
| ... | ... | @@ -124,7 +124,7 @@ |
| 124 | 124 | "schoolType": {
|
| 125 | 125 | "errors": [
|
| 126 | 126 | "check if referential schoolType is disabled (only if validation is strong)",
|
| 127 | - "schoolType is mandatory except if !setEnabled"
|
|
| 127 | + "schoolType is mandatory except if !setEnabled || reasonForNoFishing != null"
|
|
| 128 | 128 | ],
|
| 129 | 129 | "warnings": [
|
| 130 | 130 | "check if referential schoolType is disabled (only if validation is not strong)"
|
| ... | ... | @@ -234,9 +234,9 @@ |
| 234 | 234 | </field>
|
| 235 | 235 | |
| 236 | 236 | <field name="schoolType">
|
| 237 | - <!-- schoolType is mandatory except if !setEnabled -->
|
|
| 237 | + <!-- schoolType is mandatory except if !setEnabled || reasonForNoFishing != null -->
|
|
| 238 | 238 | <field-validator type="mandatory" short-circuit="true">
|
| 239 | - <param name="skip"><![CDATA[ !setEnabled ]]></param>
|
|
| 239 | + <param name="skip"><![CDATA[ !setEnabled || reasonForNoFishing != null ]]></param>
|
|
| 240 | 240 | <message>observe.data.ps.logbook.Activity.schoolType.validation.required</message>
|
| 241 | 241 | </field-validator>
|
| 242 | 242 |
| ... | ... | @@ -124,7 +124,7 @@ |
| 124 | 124 | "schoolType": {
|
| 125 | 125 | "errors": [
|
| 126 | 126 | "check if referential schoolType is disabled (only if validation is strong)",
|
| 127 | - "schoolType is mandatory except if !setEnabled"
|
|
| 127 | + "schoolType is mandatory except if !setEnabled || reasonForNoFishing != null"
|
|
| 128 | 128 | ],
|
| 129 | 129 | "warnings": [
|
| 130 | 130 | "check if referential schoolType is disabled (only if validation is not strong)"
|