Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
d8ca5361
by Tony Chemit at 2023-07-19T12:12:40+02:00
-
8cddc462
by Tony Chemit at 2023-07-20T09:29:51+02:00
27 changed files:
- core/persistence/java/src/main/java/fr/ird/observe/entities/data/ll/landing/LandingSpi.java
- core/persistence/java/src/main/java/fr/ird/observe/entities/data/ll/logbook/ActivitySpi.java
- core/persistence/java/src/main/java/fr/ird/observe/entities/data/ll/logbook/SampleSpi.java
- core/persistence/java/src/main/java/fr/ird/observe/entities/data/ll/observation/ActivitySpi.java
- core/persistence/java/src/main/java/fr/ird/observe/entities/data/ps/localmarket/SurveySpi.java
- core/persistence/java/src/main/java/fr/ird/observe/entities/data/ps/logbook/ActivitySpi.java
- core/persistence/java/src/main/java/fr/ird/observe/entities/data/ps/logbook/RouteSpi.java
- 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/logbook/WellSpi.java
- core/persistence/java/src/main/java/fr/ird/observe/entities/data/ps/observation/ActivitySpi.java
- core/persistence/java/src/main/java/fr/ird/observe/entities/data/ps/observation/RouteSpi.java
- core/persistence/resources/src/main/resources/fr/ird/observe/entities/data/ll/common/Trip/validation-update.json
- core/persistence/resources/src/main/resources/fr/ird/observe/entities/data/ll/landing/LandingPart/validation-update.json
- core/persistence/resources/src/main/resources/fr/ird/observe/entities/data/ps/logbook/Activity/validation-update.json
- core/persistence/resources/src/main/resources/fr/ird/observe/entities/data/ps/logbook/Route/validation-update.json
- core/persistence/resources/src/main/resources/fr/ird/observe/entities/data/ps/observation/Activity/validation-update.json
- core/persistence/resources/src/main/resources/fr/ird/observe/entities/data/ps/observation/Catch/validation-update.json
- core/persistence/resources/src/main/resources/fr/ird/observe/entities/data/ps/observation/Route/validation-update.json
- server/runner/src/main/webResources/doc/api/public/data/ll/common/Trip/validation-update.json
- server/runner/src/main/webResources/doc/api/public/data/ll/landing/LandingPart/validation-update.json
- server/runner/src/main/webResources/doc/api/public/data/ps/logbook/Activity/validation-update.json
- server/runner/src/main/webResources/doc/api/public/data/ps/logbook/Route/validation-update.json
- server/runner/src/main/webResources/doc/api/public/data/ps/observation/Activity/validation-update.json
- server/runner/src/main/webResources/doc/api/public/data/ps/observation/Catch/validation-update.json
- server/runner/src/main/webResources/doc/api/public/data/ps/observation/Route/validation-update.json
- toolkit/persistence/src/main/java/fr/ird/observe/spi/context/OpenableDtoEntityContext.java
- toolkit/plugin/src/main/java/fr/ird/observe/toolkit/maven/plugin/server/definition/ValidationDefinitionTemplate.java
Changes:
| ... | ... | @@ -26,8 +26,11 @@ import fr.ird.observe.dto.data.ll.landing.LandingDto; |
| 26 | 26 | import fr.ird.observe.dto.form.Form;
|
| 27 | 27 | import fr.ird.observe.entities.data.ll.common.Trip;
|
| 28 | 28 | import fr.ird.observe.services.service.SaveResultDto;
|
| 29 | +import fr.ird.observe.spi.result.AddEntityToUpdateStep;
|
|
| 29 | 30 | import fr.ird.observe.spi.service.ServiceContext;
|
| 30 | 31 | |
| 32 | +import java.util.function.Consumer;
|
|
| 33 | + |
|
| 31 | 34 | /**
|
| 32 | 35 | * Created on 10/05/2021.
|
| 33 | 36 | *
|
| ... | ... | @@ -43,8 +46,8 @@ public class LandingSpi extends GeneratedLandingSpi { |
| 43 | 46 | }
|
| 44 | 47 | |
| 45 | 48 | @Override
|
| 46 | - protected SaveResultDto saveEntity(ServiceContext context, Trip parent, Landing entity) {
|
|
| 49 | + protected SaveResultDto saveEntity(ServiceContext context, Trip parent, Landing entity, Consumer<AddEntityToUpdateStep> extraConsumer) {
|
|
| 47 | 50 | LandingPart.SPI.initId(context, entity.getLandingPart());
|
| 48 | - return super.saveEntity(context, parent, entity);
|
|
| 51 | + return super.saveEntity(context, parent, entity, extraConsumer);
|
|
| 49 | 52 | }
|
| 50 | 53 | } |
| ... | ... | @@ -34,6 +34,7 @@ import fr.ird.observe.dto.referential.ReferentialLocale; |
| 34 | 34 | import fr.ird.observe.entities.data.ll.common.Trip;
|
| 35 | 35 | import fr.ird.observe.entities.referential.common.DataQuality;
|
| 36 | 36 | import fr.ird.observe.entities.referential.common.Species;
|
| 37 | +import fr.ird.observe.spi.result.AddEntityToUpdateStep;
|
|
| 37 | 38 | import fr.ird.observe.spi.service.ServiceContext;
|
| 38 | 39 | import io.ultreia.java4all.util.Dates;
|
| 39 | 40 | import org.apache.logging.log4j.LogManager;
|
| ... | ... | @@ -41,6 +42,7 @@ import org.apache.logging.log4j.Logger; |
| 41 | 42 | |
| 42 | 43 | import java.util.Calendar;
|
| 43 | 44 | import java.util.Date;
|
| 45 | +import java.util.function.Consumer;
|
|
| 44 | 46 | import java.util.stream.Collectors;
|
| 45 | 47 | |
| 46 | 48 | /**
|
| ... | ... | @@ -104,11 +106,11 @@ public class ActivitySpi extends GeneratedActivitySpi { |
| 104 | 106 | // }
|
| 105 | 107 | |
| 106 | 108 | @Override
|
| 107 | - public void onSave(ServiceContext context, Trip parent, Activity entity, ActivityDto dto, boolean needCopy) {
|
|
| 109 | + public Consumer<AddEntityToUpdateStep> onSave(ServiceContext context, Trip parent, Activity entity, ActivityDto dto, boolean needCopy) {
|
|
| 108 | 110 | if (!dto.isSetEnabled() && entity.getSet() != null) {
|
| 109 | 111 | log.info(String.format("Remove set: %s", entity.getSet().getTopiaId()));
|
| 110 | 112 | entity.setSet(null);
|
| 111 | 113 | }
|
| 112 | - super.onSave(context, parent, entity, dto, needCopy);
|
|
| 114 | + return super.onSave(context, parent, entity, dto, needCopy);
|
|
| 113 | 115 | }
|
| 114 | 116 | } |
| ... | ... | @@ -27,10 +27,12 @@ import fr.ird.observe.dto.data.ll.logbook.SampleDto; |
| 27 | 27 | import fr.ird.observe.dto.form.Form;
|
| 28 | 28 | import fr.ird.observe.entities.data.ll.common.Trip;
|
| 29 | 29 | import fr.ird.observe.services.service.SaveResultDto;
|
| 30 | +import fr.ird.observe.spi.result.AddEntityToUpdateStep;
|
|
| 30 | 31 | import fr.ird.observe.spi.service.ServiceContext;
|
| 31 | 32 | |
| 32 | 33 | import java.util.Calendar;
|
| 33 | 34 | import java.util.Date;
|
| 35 | +import java.util.function.Consumer;
|
|
| 34 | 36 | |
| 35 | 37 | /**
|
| 36 | 38 | * Created on 10/05/2021.
|
| ... | ... | @@ -57,8 +59,8 @@ public class SampleSpi extends GeneratedSampleSpi { |
| 57 | 59 | }
|
| 58 | 60 | |
| 59 | 61 | @Override
|
| 60 | - protected SaveResultDto saveEntity(ServiceContext context, Trip parent, Sample entity) {
|
|
| 62 | + protected SaveResultDto saveEntity(ServiceContext context, Trip parent, Sample entity, Consumer<AddEntityToUpdateStep> extraConsumer) {
|
|
| 61 | 63 | SamplePart.SPI.initId(context, entity.getSamplePart());
|
| 62 | - return super.saveEntity(context, parent, entity);
|
|
| 64 | + return super.saveEntity(context, parent, entity, extraConsumer);
|
|
| 63 | 65 | }
|
| 64 | 66 | } |
| ... | ... | @@ -29,12 +29,14 @@ import fr.ird.observe.dto.data.ll.observation.ActivityReference; |
| 29 | 29 | import fr.ird.observe.dto.form.Form;
|
| 30 | 30 | import fr.ird.observe.dto.referential.ReferentialLocale;
|
| 31 | 31 | import fr.ird.observe.entities.data.ll.common.Trip;
|
| 32 | +import fr.ird.observe.spi.result.AddEntityToUpdateStep;
|
|
| 32 | 33 | import fr.ird.observe.spi.service.ServiceContext;
|
| 33 | 34 | import org.apache.logging.log4j.LogManager;
|
| 34 | 35 | import org.apache.logging.log4j.Logger;
|
| 35 | 36 | |
| 36 | 37 | import java.util.Calendar;
|
| 37 | 38 | import java.util.Date;
|
| 39 | +import java.util.function.Consumer;
|
|
| 38 | 40 | |
| 39 | 41 | /**
|
| 40 | 42 | * Created on 10/05/2021.
|
| ... | ... | @@ -78,12 +80,12 @@ public class ActivitySpi extends GeneratedActivitySpi { |
| 78 | 80 | // }
|
| 79 | 81 | |
| 80 | 82 | @Override
|
| 81 | - public void onSave(ServiceContext context, Trip parent, Activity entity, ActivityDto dto, boolean needCopy) {
|
|
| 83 | + public Consumer<AddEntityToUpdateStep> onSave(ServiceContext context, Trip parent, Activity entity, ActivityDto dto, boolean needCopy) {
|
|
| 82 | 84 | if (!dto.isSetEnabled() && entity.getSet() != null) {
|
| 83 | 85 | log.info(String.format("Remove set: %s", entity.getSet().getTopiaId()));
|
| 84 | 86 | entity.setSet(null);
|
| 85 | 87 | }
|
| 86 | - super.onSave(context, parent, entity, dto, needCopy);
|
|
| 88 | + return super.onSave(context, parent, entity, dto, needCopy);
|
|
| 87 | 89 | }
|
| 88 | 90 | |
| 89 | 91 | } |
| ... | ... | @@ -35,6 +35,7 @@ import java.util.Collection; |
| 35 | 35 | import java.util.LinkedList;
|
| 36 | 36 | import java.util.Objects;
|
| 37 | 37 | import java.util.Set;
|
| 38 | +import java.util.function.Consumer;
|
|
| 38 | 39 | import java.util.stream.Collectors;
|
| 39 | 40 | |
| 40 | 41 | /**
|
| ... | ... | @@ -61,7 +62,7 @@ public class SurveySpi extends GeneratedSurveySpi { |
| 61 | 62 | }
|
| 62 | 63 | |
| 63 | 64 | @Override
|
| 64 | - public void onSave(ServiceContext context, Trip parent, Survey entity, SurveyDto dto, boolean needCopy) {
|
|
| 65 | + public Consumer<AddEntityToUpdateStep> onSave(ServiceContext context, Trip parent, Survey entity, SurveyDto dto, boolean needCopy) {
|
|
| 65 | 66 | |
| 66 | 67 | // Get all batch ids associated to this survey
|
| 67 | 68 | Set<String> newBatchIds = dto.getBatches().stream().map(BatchReference::getId).collect(Collectors.toSet());
|
| ... | ... | @@ -70,8 +71,8 @@ public class SurveySpi extends GeneratedSurveySpi { |
| 70 | 71 | // Remove from batches survey if equals to this one
|
| 71 | 72 | String surveyId = dto.getId();
|
| 72 | 73 | localmarketBatches.stream()
|
| 73 | - .filter(b -> b.getSurvey() != null && surveyId.equals(b.getSurvey().getTopiaId()))
|
|
| 74 | - .forEach(b -> b.setSurvey(null));
|
|
| 74 | + .filter(b -> b.getSurvey() != null && surveyId.equals(b.getSurvey().getTopiaId()))
|
|
| 75 | + .forEach(b -> b.setSurvey(null));
|
|
| 75 | 76 | }
|
| 76 | 77 | if (needCopy) {
|
| 77 | 78 | fromDto(context, entity, dto);
|
| ... | ... | @@ -79,18 +80,19 @@ public class SurveySpi extends GeneratedSurveySpi { |
| 79 | 80 | // Set new association on batches associated to this survey
|
| 80 | 81 | localmarketBatches.stream().filter(b -> newBatchIds.contains(b.getTopiaId())).forEach(b -> b.setSurvey(entity));
|
| 81 | 82 | super.onSave(context, parent, entity, dto, false);
|
| 83 | + return s -> s.updateCollection(SurveyPart.SPI, entity.getSurveyPart());
|
|
| 82 | 84 | }
|
| 83 | -//
|
|
| 85 | + |
|
| 84 | 86 | // @Override
|
| 85 | 87 | // public void moveCallback(Trip oldParent, Trip newParent, List<Survey> moved) {
|
| 86 | 88 | // //FIXME Copy missing meta-data to new parent?
|
| 87 | 89 | // }
|
| 88 | 90 | |
| 89 | - |
|
| 90 | - @Override
|
|
| 91 | - public void saveCallback(AddEntityToUpdateStep saveHelper, Survey entity) {
|
|
| 92 | - saveHelper.updateCollection(SurveyPart.SPI, entity.getSurveyPart());
|
|
| 93 | - }
|
|
| 91 | +//
|
|
| 92 | +// @Override
|
|
| 93 | +// public void saveCallback(AddEntityToUpdateStep saveHelper, Survey entity) {
|
|
| 94 | +// saveHelper.updateCollection(SurveyPart.SPI, entity.getSurveyPart());
|
|
| 95 | +// }
|
|
| 94 | 96 | |
| 95 | 97 | public void fillFormObject(ReferentialLocale referentialLocale, Trip trip, Survey survey, Form<SurveyDto> form) {
|
| 96 | 98 | Collection<Batch> availableBatches = new LinkedList<>();
|
| ... | ... | @@ -30,6 +30,7 @@ import fr.ird.observe.dto.form.Form; |
| 30 | 30 | import fr.ird.observe.dto.referential.ReferentialLocale;
|
| 31 | 31 | import fr.ird.observe.entities.referential.common.FpaZone;
|
| 32 | 32 | import fr.ird.observe.entities.referential.ps.logbook.InformationSource;
|
| 33 | +import fr.ird.observe.spi.result.AddEntityToUpdateStep;
|
|
| 33 | 34 | import fr.ird.observe.spi.service.ServiceContext;
|
| 34 | 35 | import io.ultreia.java4all.util.Dates;
|
| 35 | 36 | import org.apache.logging.log4j.LogManager;
|
| ... | ... | @@ -37,6 +38,7 @@ import org.apache.logging.log4j.Logger; |
| 37 | 38 | |
| 38 | 39 | import java.util.Date;
|
| 39 | 40 | import java.util.function.BiConsumer;
|
| 41 | +import java.util.function.Consumer;
|
|
| 40 | 42 | |
| 41 | 43 | /**
|
| 42 | 44 | * Created on 10/05/2021.
|
| ... | ... | @@ -103,7 +105,7 @@ public class ActivitySpi extends GeneratedActivitySpi { |
| 103 | 105 | }
|
| 104 | 106 | |
| 105 | 107 | @Override
|
| 106 | - public void onSave(ServiceContext context, Route parent, Activity entity, ActivityDto dto, boolean needCopy) {
|
|
| 108 | + public Consumer<AddEntityToUpdateStep> onSave(ServiceContext context, Route parent, Activity entity, ActivityDto dto, boolean needCopy) {
|
|
| 107 | 109 | if (!dto.isCatchesEnabled() && entity.isCatchesNotEmpty()) {
|
| 108 | 110 | log.info(String.format("Remove %d catch(es).", entity.getCatchesSize()));
|
| 109 | 111 | entity.clearCatches();
|
| ... | ... | @@ -114,7 +116,7 @@ public class ActivitySpi extends GeneratedActivitySpi { |
| 114 | 116 | }
|
| 115 | 117 | entity.clearFloatingObject();
|
| 116 | 118 | }
|
| 117 | - super.onSave(context, parent, entity, dto, needCopy);
|
|
| 119 | + return null;
|
|
| 118 | 120 | }
|
| 119 | 121 | |
| 120 | 122 | @Override
|
| ... | ... | @@ -29,12 +29,14 @@ import fr.ird.observe.dto.form.Form; |
| 29 | 29 | import fr.ird.observe.entities.data.ps.common.Trip;
|
| 30 | 30 | import fr.ird.observe.entities.data.ps.common.TripSpi;
|
| 31 | 31 | import fr.ird.observe.services.service.SaveResultDto;
|
| 32 | +import fr.ird.observe.spi.result.AddEntityToUpdateStep;
|
|
| 32 | 33 | import fr.ird.observe.spi.service.ServiceContext;
|
| 33 | 34 | import io.ultreia.java4all.util.Dates;
|
| 34 | 35 | import org.apache.commons.lang3.time.DateUtils;
|
| 35 | 36 | |
| 36 | 37 | import java.util.Date;
|
| 37 | 38 | import java.util.Set;
|
| 39 | +import java.util.function.Consumer;
|
|
| 38 | 40 | import java.util.stream.Collectors;
|
| 39 | 41 | |
| 40 | 42 | /**
|
| ... | ... | @@ -59,14 +61,14 @@ public class RouteSpi extends GeneratedRouteSpi { |
| 59 | 61 | }
|
| 60 | 62 | |
| 61 | 63 | @Override
|
| 62 | - protected SaveResultDto saveEntity(ServiceContext context, Trip parent, Route entity) {
|
|
| 64 | + protected SaveResultDto saveEntity(ServiceContext context, Trip parent, Route entity, Consumer<AddEntityToUpdateStep> extraConsumer) {
|
|
| 63 | 65 | if (TripSpi.updateEndDate(parent)) {
|
| 64 | 66 | return newSaveHelper(context)
|
| 65 | 67 | .update(Trip.SPI, parent)
|
| 66 | 68 | .update(this, entity)
|
| 67 | 69 | .build(entity);
|
| 68 | 70 | }
|
| 69 | - return super.saveEntity(context, parent, entity);
|
|
| 71 | + return super.saveEntity(context, parent, entity, extraConsumer);
|
|
| 70 | 72 | }
|
| 71 | 73 | |
| 72 | 74 | @Override
|
| ... | ... | @@ -30,9 +30,11 @@ 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 | 32 | import fr.ird.observe.services.service.SaveResultDto;
|
| 33 | +import fr.ird.observe.spi.result.AddEntityToUpdateStep;
|
|
| 33 | 34 | import fr.ird.observe.spi.service.ServiceContext;
|
| 34 | 35 | |
| 35 | 36 | import java.util.Objects;
|
| 37 | +import java.util.function.Consumer;
|
|
| 36 | 38 | |
| 37 | 39 | /**
|
| 38 | 40 | * Created on 10/05/2021.
|
| ... | ... | @@ -70,7 +72,7 @@ public class SampleSpi extends GeneratedSampleSpi { |
| 70 | 72 | }
|
| 71 | 73 | |
| 72 | 74 | @Override
|
| 73 | - public void onSave(ServiceContext context, Trip parent, Sample entity, SampleDto dto, boolean needCopy) {
|
|
| 75 | + public Consumer<AddEntityToUpdateStep> onSave(ServiceContext context, Trip parent, Sample entity, SampleDto dto, boolean needCopy) {
|
|
| 74 | 76 | boolean superSampleChanged = !Objects.equals(entity.isSuperSample(), dto.isSuperSample());
|
| 75 | 77 | if (superSampleChanged && entity.isSampleSpeciesNotEmpty()) {
|
| 76 | 78 | // superSample changed (adapt)
|
| ... | ... | @@ -87,7 +89,7 @@ public class SampleSpi extends GeneratedSampleSpi { |
| 87 | 89 | entity.getSampleSpecies().forEach(sampleSpecies -> sampleSpecies.setSubSampleNumber(0));
|
| 88 | 90 | }
|
| 89 | 91 | }
|
| 90 | - super.onSave(context, parent, entity, dto, needCopy);
|
|
| 92 | + return super.onSave(context, parent, entity, dto, needCopy);
|
|
| 91 | 93 | }
|
| 92 | 94 | |
| 93 | 95 | private int getSampleSpeciesSubNumber(Sample entity) {
|
| ... | ... | @@ -95,9 +97,9 @@ public class SampleSpi extends GeneratedSampleSpi { |
| 95 | 97 | }
|
| 96 | 98 | |
| 97 | 99 | @Override
|
| 98 | - protected SaveResultDto saveEntity(ServiceContext context, Trip parent, Sample entity) {
|
|
| 100 | + protected SaveResultDto saveEntity(ServiceContext context, Trip parent, Sample entity, Consumer<AddEntityToUpdateStep> extraConsumer) {
|
|
| 99 | 101 | SampleActivity.SPI.initId(context, entity.getSampleActivity());
|
| 100 | - return super.saveEntity(context, parent, entity);
|
|
| 102 | + return super.saveEntity(context, parent, entity, extraConsumer);
|
|
| 101 | 103 | }
|
| 102 | 104 | |
| 103 | 105 | //FIXME Add a callback in MoveRequest
|
| ... | ... | @@ -22,30 +22,43 @@ package fr.ird.observe.entities.data.ps.logbook; |
| 22 | 22 | * #L%
|
| 23 | 23 | */
|
| 24 | 24 | |
| 25 | +import fr.ird.observe.dto.data.ps.logbook.WellDto;
|
|
| 25 | 26 | import fr.ird.observe.entities.data.ps.common.Trip;
|
| 26 | 27 | import fr.ird.observe.services.service.SaveResultDto;
|
| 27 | 28 | import fr.ird.observe.spi.result.AddEntityToUpdateStep;
|
| 28 | 29 | import fr.ird.observe.spi.service.ServiceContext;
|
| 29 | 30 | |
| 30 | 31 | import java.util.Set;
|
| 32 | +import java.util.function.Consumer;
|
|
| 31 | 33 | |
| 32 | 34 | public class WellSpi extends GeneratedWellSpi {
|
| 33 | 35 | |
| 36 | +// @Override
|
|
| 37 | +// public void saveCallback(AddEntityToUpdateStep saveHelper, Well entity) {
|
|
| 38 | +// Set<WellActivity> wellActivity = entity.getWellActivity();
|
|
| 39 | +// saveHelper.updateCollection(WellActivity.SPI, wellActivity);
|
|
| 40 | +// wellActivity.forEach(c -> saveHelper.updateCollection(WellActivitySpecies.SPI, c.getWellActivitySpecies(), false));
|
|
| 41 | +// saveHelper.updateLastUpdateDateTable(WellActivitySpecies.SPI);
|
|
| 42 | +// }
|
|
| 43 | + |
|
| 34 | 44 | @Override
|
| 35 | - public void saveCallback(AddEntityToUpdateStep saveHelper, Well entity) {
|
|
| 36 | - Set<WellActivity> wellActivity = entity.getWellActivity();
|
|
| 37 | - saveHelper.updateCollection(WellActivity.SPI, wellActivity);
|
|
| 38 | - wellActivity.forEach(c -> saveHelper.updateCollection(WellActivitySpecies.SPI, c.getWellActivitySpecies(), false));
|
|
| 39 | - saveHelper.updateLastUpdateDateTable(WellActivitySpecies.SPI);
|
|
| 45 | + public Consumer<AddEntityToUpdateStep> onSave(ServiceContext context, Trip parent, Well entity, WellDto dto, boolean needCopy) {
|
|
| 46 | + super.onSave(context, parent, entity, dto, needCopy);
|
|
| 47 | + return s -> {
|
|
| 48 | + Set<WellActivity> wellActivity = entity.getWellActivity();
|
|
| 49 | + s.updateCollection(WellActivity.SPI, wellActivity);
|
|
| 50 | + wellActivity.forEach(c -> s.updateCollection(WellActivitySpecies.SPI, c.getWellActivitySpecies(), false));
|
|
| 51 | + s.updateLastUpdateDateTable(WellActivitySpecies.SPI);
|
|
| 52 | + };
|
|
| 40 | 53 | }
|
| 41 | 54 | |
| 42 | 55 | @Override
|
| 43 | - protected SaveResultDto saveEntity(ServiceContext context, Trip parent, Well entity) {
|
|
| 56 | + protected SaveResultDto saveEntity(ServiceContext context, Trip parent, Well entity, Consumer<AddEntityToUpdateStep> extraConsumer) {
|
|
| 44 | 57 | Set<WellActivity> wellActivity = entity.getWellActivity();
|
| 45 | 58 | if (wellActivity != null) {
|
| 46 | 59 | WellActivity.SPI.initId(context, wellActivity);
|
| 47 | 60 | wellActivity.forEach(activity -> WellActivitySpecies.SPI.initId(context, activity.getWellActivitySpecies()));
|
| 48 | 61 | }
|
| 49 | - return super.saveEntity(context, parent, entity);
|
|
| 62 | + return super.saveEntity(context, parent, entity, extraConsumer);
|
|
| 50 | 63 | }
|
| 51 | 64 | } //WellSpi |
| ... | ... | @@ -31,6 +31,7 @@ import fr.ird.observe.dto.referential.ReferentialLocale; |
| 31 | 31 | import fr.ird.observe.dto.referential.common.SpeciesReference;
|
| 32 | 32 | import fr.ird.observe.entities.referential.common.FpaZone;
|
| 33 | 33 | import fr.ird.observe.entities.referential.common.Species;
|
| 34 | +import fr.ird.observe.spi.result.AddEntityToUpdateStep;
|
|
| 34 | 35 | import fr.ird.observe.spi.service.ServiceContext;
|
| 35 | 36 | import io.ultreia.java4all.util.Dates;
|
| 36 | 37 | import org.apache.logging.log4j.LogManager;
|
| ... | ... | @@ -39,6 +40,7 @@ import org.apache.logging.log4j.Logger; |
| 39 | 40 | import java.util.Date;
|
| 40 | 41 | import java.util.LinkedHashSet;
|
| 41 | 42 | import java.util.function.BiConsumer;
|
| 43 | +import java.util.function.Consumer;
|
|
| 42 | 44 | import java.util.stream.Stream;
|
| 43 | 45 | |
| 44 | 46 | /**
|
| ... | ... | @@ -97,7 +99,7 @@ public class ActivitySpi extends GeneratedActivitySpi { |
| 97 | 99 | }
|
| 98 | 100 | |
| 99 | 101 | @Override
|
| 100 | - public void onSave(ServiceContext context, Route parent, Activity entity, ActivityDto dto, boolean needCopy) {
|
|
| 102 | + public Consumer<AddEntityToUpdateStep> onSave(ServiceContext context, Route parent, Activity entity, ActivityDto dto, boolean needCopy) {
|
|
| 101 | 103 | if (!dto.isSetEnabled() && entity.getSet() != null) {
|
| 102 | 104 | log.info(String.format("Remove set: %s", entity.getSet().getTopiaId()));
|
| 103 | 105 | entity.setSet(null);
|
| ... | ... | @@ -108,7 +110,7 @@ public class ActivitySpi extends GeneratedActivitySpi { |
| 108 | 110 | }
|
| 109 | 111 | entity.clearFloatingObject();
|
| 110 | 112 | }
|
| 111 | - super.onSave(context, parent, entity, dto, needCopy);
|
|
| 113 | + return super.onSave(context, parent, entity, dto, needCopy);
|
|
| 112 | 114 | }
|
| 113 | 115 | |
| 114 | 116 | @Override
|
| ... | ... | @@ -30,6 +30,7 @@ import fr.ird.observe.dto.form.Form; |
| 30 | 30 | import fr.ird.observe.entities.data.ps.common.Trip;
|
| 31 | 31 | import fr.ird.observe.entities.data.ps.common.TripSpi;
|
| 32 | 32 | import fr.ird.observe.services.service.SaveResultDto;
|
| 33 | +import fr.ird.observe.spi.result.AddEntityToUpdateStep;
|
|
| 33 | 34 | import fr.ird.observe.spi.service.ServiceContext;
|
| 34 | 35 | import io.ultreia.java4all.util.Dates;
|
| 35 | 36 | import org.apache.commons.lang3.time.DateUtils;
|
| ... | ... | @@ -39,6 +40,7 @@ import java.util.Date; |
| 39 | 40 | import java.util.LinkedHashSet;
|
| 40 | 41 | import java.util.Objects;
|
| 41 | 42 | import java.util.Set;
|
| 43 | +import java.util.function.Consumer;
|
|
| 42 | 44 | import java.util.stream.Collectors;
|
| 43 | 45 | |
| 44 | 46 | /**
|
| ... | ... | @@ -72,7 +74,7 @@ public class RouteSpi extends GeneratedRouteSpi { |
| 72 | 74 | }
|
| 73 | 75 | |
| 74 | 76 | @Override
|
| 75 | - public void onSave(ServiceContext context, Trip parent, Route entity, RouteDto dto, boolean needCopy) {
|
|
| 77 | + public Consumer<AddEntityToUpdateStep> onSave(ServiceContext context, Trip parent, Route entity, RouteDto dto, boolean needCopy) {
|
|
| 76 | 78 | |
| 77 | 79 | boolean dateHasChanged = false;
|
| 78 | 80 | if (dto.isPersisted()) {
|
| ... | ... | @@ -85,18 +87,18 @@ public class RouteSpi extends GeneratedRouteSpi { |
| 85 | 87 | if (dateHasChanged) {
|
| 86 | 88 | getDao(context).updateActivitiesDate(entity.getTopiaId(), new java.sql.Date(dto.getDate().getTime()));
|
| 87 | 89 | }
|
| 88 | - super.onSave(context, parent, entity, dto, needCopy);
|
|
| 90 | + return super.onSave(context, parent, entity, dto, needCopy);
|
|
| 89 | 91 | }
|
| 90 | 92 | |
| 91 | 93 | @Override
|
| 92 | - protected SaveResultDto saveEntity(ServiceContext context, Trip parent, Route entity) {
|
|
| 94 | + protected SaveResultDto saveEntity(ServiceContext context, Trip parent, Route entity, Consumer<AddEntityToUpdateStep> extraConsumer) {
|
|
| 93 | 95 | if (TripSpi.updateEndDate(parent)) {
|
| 94 | 96 | return newSaveHelper(context)
|
| 95 | 97 | .update(Trip.SPI, parent)
|
| 96 | 98 | .update(this, entity)
|
| 97 | 99 | .build(entity);
|
| 98 | 100 | }
|
| 99 | - return super.saveEntity(context, parent, entity);
|
|
| 101 | + return super.saveEntity(context, parent, entity, extraConsumer);
|
|
| 100 | 102 | }
|
| 101 | 103 | |
| 102 | 104 | @Override
|
| ... | ... | @@ -25,6 +25,7 @@ |
| 25 | 25 | "endDate": {
|
| 26 | 26 | "errors": [
|
| 27 | 27 | "endDate <= now",
|
| 28 | + "endDate > any activity date",
|
|
| 28 | 29 | "endDate >= startDate",
|
| 29 | 30 | "endDate is mandatory"
|
| 30 | 31 | ]
|
| ... | ... | @@ -184,6 +185,7 @@ |
| 184 | 185 | },
|
| 185 | 186 | "startDate": {
|
| 186 | 187 | "errors": [
|
| 188 | + "startDate < any activity date",
|
|
| 187 | 189 | "startDate <= now",
|
| 188 | 190 | "startDate is mandatory"
|
| 189 | 191 | ]
|
| 1 | 1 | {
|
| 2 | + "categoryMax": {
|
|
| 3 | + "errors": [
|
|
| 4 | + "if filled, categoryMax > categoryMin"
|
|
| 5 | + ]
|
|
| 6 | + },
|
|
| 2 | 7 | "conservation": {
|
| 3 | 8 | "errors": [
|
| 4 | 9 | "check if referential conservation is disabled (only if validation is strong)"
|
| ... | ... | @@ -29,6 +29,11 @@ |
| 29 | 29 | "check if referential dataQuality is disabled (only if validation is not strong)"
|
| 30 | 30 | ]
|
| 31 | 31 | },
|
| 32 | + "floatingObjectEmpty": {
|
|
| 33 | + "warnings": [
|
|
| 34 | + "No DCP"
|
|
| 35 | + ]
|
|
| 36 | + },
|
|
| 32 | 37 | "fpaZone": {
|
| 33 | 38 | "errors": [
|
| 34 | 39 | "check if referential fpaZone is disabled (only if validation is strong)"
|
| 1 | 1 | {
|
| 2 | + "activity": {
|
|
| 3 | + "errors": [
|
|
| 4 | + "activities quadrant check",
|
|
| 5 | + "activities time check"
|
|
| 6 | + ]
|
|
| 7 | + },
|
|
| 2 | 8 | "comment": {
|
| 3 | 9 | "errors": [
|
| 4 | 10 | "comment (if not null) is not a blank string",
|
| ... | ... | @@ -35,6 +35,11 @@ |
| 35 | 35 | "ersId (if not null) is not a blank string"
|
| 36 | 36 | ]
|
| 37 | 37 | },
|
| 38 | + "floatingObjectEmpty": {
|
|
| 39 | + "warnings": [
|
|
| 40 | + "No DCP"
|
|
| 41 | + ]
|
|
| 42 | + },
|
|
| 38 | 43 | "homeId": {
|
| 39 | 44 | "errors": [
|
| 40 | 45 | "homeId (if not null) is not a blank string"
|
| ... | ... | @@ -44,18 +49,12 @@ |
| 44 | 49 | "errors": [
|
| 45 | 50 | "check latitude format",
|
| 46 | 51 | "latitude is mandatory"
|
| 47 | - ],
|
|
| 48 | - "warnings": [
|
|
| 49 | - "check speed"
|
|
| 50 | 52 | ]
|
| 51 | 53 | },
|
| 52 | 54 | "longitude": {
|
| 53 | 55 | "errors": [
|
| 54 | 56 | "check longitude format",
|
| 55 | 57 | "longitude is mandatory"
|
| 56 | - ],
|
|
| 57 | - "warnings": [
|
|
| 58 | - "check speed"
|
|
| 59 | 58 | ]
|
| 60 | 59 | },
|
| 61 | 60 | "nextFpaZone": {
|
| ... | ... | @@ -138,13 +137,12 @@ |
| 138 | 137 | "unique activity time on route"
|
| 139 | 138 | ],
|
| 140 | 139 | "warnings": [
|
| 141 | - "check speed"
|
|
| 140 | + "Check speed"
|
|
| 142 | 141 | ]
|
| 143 | 142 | },
|
| 144 | 143 | "vesselActivity": {
|
| 145 | 144 | "errors": [
|
| 146 | 145 | "check if referential vesselActivity is disabled (only if validation is strong)",
|
| 147 | - "if end of search activity possible?",
|
|
| 148 | 146 | "vesselActivity is mandatory"
|
| 149 | 147 | ],
|
| 150 | 148 | "warnings": [
|
| ... | ... | @@ -77,6 +77,7 @@ |
| 77 | 77 | "species": {
|
| 78 | 78 | "errors": [
|
| 79 | 79 | "check if referential species is disabled (only if validation is strong)",
|
| 80 | + "check missing observed system",
|
|
| 80 | 81 | "species is mandatory"
|
| 81 | 82 | ],
|
| 82 | 83 | "warnings": [
|
| 1 | 1 | {
|
| 2 | + "activity": {
|
|
| 3 | + "errors": [
|
|
| 4 | + "activities quadrant check",
|
|
| 5 | + "activities speed check",
|
|
| 6 | + "activities time check"
|
|
| 7 | + ],
|
|
| 8 | + "warnings": [
|
|
| 9 | + "activities speed check",
|
|
| 10 | + "end of search activity required"
|
|
| 11 | + ]
|
|
| 12 | + },
|
|
| 2 | 13 | "comment": {
|
| 3 | 14 | "errors": [
|
| 4 | 15 | "comment (if not null) is not a blank string",
|
| ... | ... | @@ -18,6 +29,10 @@ |
| 18 | 29 | "endLogValue": {
|
| 19 | 30 | "errors": [
|
| 20 | 31 | "endLogValue is a positive number"
|
| 32 | + ],
|
|
| 33 | + "warnings": [
|
|
| 34 | + "loch matin < endLogValue ou l'un des deux lochs non renseigne",
|
|
| 35 | + "| endLogValue - loch Matin | < maxGap ou l'un des deux lochs non renseigne"
|
|
| 21 | 36 | ]
|
| 22 | 37 | },
|
| 23 | 38 | "homeId": {
|
| ... | ... | @@ -30,7 +45,7 @@ |
| 30 | 45 | "startLogValue is a positive number"
|
| 31 | 46 | ],
|
| 32 | 47 | "warnings": [
|
| 33 | - "check loch matin ( supérieur a tout loch soir d'une route plus ancienne)"
|
|
| 48 | + "check loch matin ( superieur a tout loch soir d'une route plus ancienne)"
|
|
| 34 | 49 | ]
|
| 35 | 50 | }
|
| 36 | 51 | } |
| \ No newline at end of file |
| ... | ... | @@ -25,6 +25,7 @@ |
| 25 | 25 | "endDate": {
|
| 26 | 26 | "errors": [
|
| 27 | 27 | "endDate <= now",
|
| 28 | + "endDate > any activity date",
|
|
| 28 | 29 | "endDate >= startDate",
|
| 29 | 30 | "endDate is mandatory"
|
| 30 | 31 | ]
|
| ... | ... | @@ -184,6 +185,7 @@ |
| 184 | 185 | },
|
| 185 | 186 | "startDate": {
|
| 186 | 187 | "errors": [
|
| 188 | + "startDate < any activity date",
|
|
| 187 | 189 | "startDate <= now",
|
| 188 | 190 | "startDate is mandatory"
|
| 189 | 191 | ]
|
| 1 | 1 | {
|
| 2 | + "categoryMax": {
|
|
| 3 | + "errors": [
|
|
| 4 | + "if filled, categoryMax > categoryMin"
|
|
| 5 | + ]
|
|
| 6 | + },
|
|
| 2 | 7 | "conservation": {
|
| 3 | 8 | "errors": [
|
| 4 | 9 | "check if referential conservation is disabled (only if validation is strong)"
|
| ... | ... | @@ -29,6 +29,11 @@ |
| 29 | 29 | "check if referential dataQuality is disabled (only if validation is not strong)"
|
| 30 | 30 | ]
|
| 31 | 31 | },
|
| 32 | + "floatingObjectEmpty": {
|
|
| 33 | + "warnings": [
|
|
| 34 | + "No DCP"
|
|
| 35 | + ]
|
|
| 36 | + },
|
|
| 32 | 37 | "fpaZone": {
|
| 33 | 38 | "errors": [
|
| 34 | 39 | "check if referential fpaZone is disabled (only if validation is strong)"
|
| 1 | 1 | {
|
| 2 | + "activity": {
|
|
| 3 | + "errors": [
|
|
| 4 | + "activities quadrant check",
|
|
| 5 | + "activities time check"
|
|
| 6 | + ]
|
|
| 7 | + },
|
|
| 2 | 8 | "comment": {
|
| 3 | 9 | "errors": [
|
| 4 | 10 | "comment (if not null) is not a blank string",
|
| ... | ... | @@ -35,6 +35,11 @@ |
| 35 | 35 | "ersId (if not null) is not a blank string"
|
| 36 | 36 | ]
|
| 37 | 37 | },
|
| 38 | + "floatingObjectEmpty": {
|
|
| 39 | + "warnings": [
|
|
| 40 | + "No DCP"
|
|
| 41 | + ]
|
|
| 42 | + },
|
|
| 38 | 43 | "homeId": {
|
| 39 | 44 | "errors": [
|
| 40 | 45 | "homeId (if not null) is not a blank string"
|
| ... | ... | @@ -44,18 +49,12 @@ |
| 44 | 49 | "errors": [
|
| 45 | 50 | "check latitude format",
|
| 46 | 51 | "latitude is mandatory"
|
| 47 | - ],
|
|
| 48 | - "warnings": [
|
|
| 49 | - "check speed"
|
|
| 50 | 52 | ]
|
| 51 | 53 | },
|
| 52 | 54 | "longitude": {
|
| 53 | 55 | "errors": [
|
| 54 | 56 | "check longitude format",
|
| 55 | 57 | "longitude is mandatory"
|
| 56 | - ],
|
|
| 57 | - "warnings": [
|
|
| 58 | - "check speed"
|
|
| 59 | 58 | ]
|
| 60 | 59 | },
|
| 61 | 60 | "nextFpaZone": {
|
| ... | ... | @@ -138,13 +137,12 @@ |
| 138 | 137 | "unique activity time on route"
|
| 139 | 138 | ],
|
| 140 | 139 | "warnings": [
|
| 141 | - "check speed"
|
|
| 140 | + "Check speed"
|
|
| 142 | 141 | ]
|
| 143 | 142 | },
|
| 144 | 143 | "vesselActivity": {
|
| 145 | 144 | "errors": [
|
| 146 | 145 | "check if referential vesselActivity is disabled (only if validation is strong)",
|
| 147 | - "if end of search activity possible?",
|
|
| 148 | 146 | "vesselActivity is mandatory"
|
| 149 | 147 | ],
|
| 150 | 148 | "warnings": [
|
| ... | ... | @@ -77,6 +77,7 @@ |
| 77 | 77 | "species": {
|
| 78 | 78 | "errors": [
|
| 79 | 79 | "check if referential species is disabled (only if validation is strong)",
|
| 80 | + "check missing observed system",
|
|
| 80 | 81 | "species is mandatory"
|
| 81 | 82 | ],
|
| 82 | 83 | "warnings": [
|
| 1 | 1 | {
|
| 2 | + "activity": {
|
|
| 3 | + "errors": [
|
|
| 4 | + "activities quadrant check",
|
|
| 5 | + "activities speed check",
|
|
| 6 | + "activities time check"
|
|
| 7 | + ],
|
|
| 8 | + "warnings": [
|
|
| 9 | + "activities speed check",
|
|
| 10 | + "end of search activity required"
|
|
| 11 | + ]
|
|
| 12 | + },
|
|
| 2 | 13 | "comment": {
|
| 3 | 14 | "errors": [
|
| 4 | 15 | "comment (if not null) is not a blank string",
|
| ... | ... | @@ -18,6 +29,10 @@ |
| 18 | 29 | "endLogValue": {
|
| 19 | 30 | "errors": [
|
| 20 | 31 | "endLogValue is a positive number"
|
| 32 | + ],
|
|
| 33 | + "warnings": [
|
|
| 34 | + "loch matin < endLogValue ou l'un des deux lochs non renseigne",
|
|
| 35 | + "| endLogValue - loch Matin | < maxGap ou l'un des deux lochs non renseigne"
|
|
| 21 | 36 | ]
|
| 22 | 37 | },
|
| 23 | 38 | "homeId": {
|
| ... | ... | @@ -30,7 +45,7 @@ |
| 30 | 45 | "startLogValue is a positive number"
|
| 31 | 46 | ],
|
| 32 | 47 | "warnings": [
|
| 33 | - "check loch matin ( supérieur a tout loch soir d'une route plus ancienne)"
|
|
| 48 | + "check loch matin ( superieur a tout loch soir d'une route plus ancienne)"
|
|
| 34 | 49 | ]
|
| 35 | 50 | }
|
| 36 | 51 | } |
| \ No newline at end of file |
| ... | ... | @@ -56,6 +56,7 @@ import java.util.List; |
| 56 | 56 | import java.util.Set;
|
| 57 | 57 | import java.util.TreeSet;
|
| 58 | 58 | import java.util.function.BiConsumer;
|
| 59 | +import java.util.function.Consumer;
|
|
| 59 | 60 | import java.util.function.Function;
|
| 60 | 61 | import java.util.stream.Collectors;
|
| 61 | 62 | import java.util.stream.Stream;
|
| ... | ... | @@ -95,13 +96,14 @@ public abstract class OpenableDtoEntityContext< |
| 95 | 96 | public void onLoadForm(ServiceContext context, E entity, Form<D> form) {
|
| 96 | 97 | }
|
| 97 | 98 | |
| 98 | - public void onSave(ServiceContext context, PE parent, E entity, D dto, boolean needCopy) {
|
|
| 99 | + public Consumer<AddEntityToUpdateStep> onSave(ServiceContext context, PE parent, E entity, D dto, boolean needCopy) {
|
|
| 99 | 100 | if (needCopy) {
|
| 100 | 101 | fromDto(context.getReferentialLocale(), entity, dto);
|
| 101 | 102 | }
|
| 102 | 103 | if (dto.isNotPersisted()) {
|
| 103 | 104 | addChildrenToParent(parent, entity);
|
| 104 | 105 | }
|
| 106 | + return null;
|
|
| 105 | 107 | }
|
| 106 | 108 | |
| 107 | 109 | public Set<ToolkitIdDtoBean> getRealDependencies(ServiceContext context, Set<String> ids) {
|
| ... | ... | @@ -250,18 +252,16 @@ public abstract class OpenableDtoEntityContext< |
| 250 | 252 | PE parent = parentSpi().loadEntity(context, parentId);
|
| 251 | 253 | E entity = loadOrCreateEntityFromDto(context, dto);
|
| 252 | 254 | checkLastUpdateDate(context, entity, dto);
|
| 253 | - onSave(context, parent, entity, dto, true);
|
|
| 254 | - return saveEntity(context, parent, entity);
|
|
| 255 | - }
|
|
| 256 | - |
|
| 257 | - public void saveCallback(AddEntityToUpdateStep saveHelper, E entity) {
|
|
| 255 | + Consumer<AddEntityToUpdateStep> extraConsumer = onSave(context, parent, entity, dto, true);
|
|
| 256 | + return saveEntity(context, parent, entity, extraConsumer);
|
|
| 258 | 257 | }
|
| 259 | 258 | |
| 260 | - protected SaveResultDto saveEntity(ServiceContext context, PE parent, E entity) {
|
|
| 259 | + protected SaveResultDto saveEntity(ServiceContext context, PE parent, E entity, Consumer<AddEntityToUpdateStep> extraConsumer) {
|
|
| 261 | 260 | AddEntityToUpdateStep saveHelper = newSaveHelper(context).update(this, entity);
|
| 262 | - saveCallback(saveHelper, entity);
|
|
| 263 | - return saveHelper
|
|
| 264 | - .build(entity);
|
|
| 261 | + if (extraConsumer != null) {
|
|
| 262 | + extraConsumer.accept(saveHelper);
|
|
| 263 | + }
|
|
| 264 | + return saveHelper.build(entity);
|
|
| 265 | 265 | }
|
| 266 | 266 | |
| 267 | 267 | protected BiConsumer<E, R> getChildrenExtraConsumer(PE parent) {
|
| ... | ... | @@ -174,7 +174,7 @@ public class ValidationDefinitionTemplate { |
| 174 | 174 | }
|
| 175 | 175 | Pair<String, String> pair = generateTypeDefinitionContent(validatorsByType, gson, dtoType);
|
| 176 | 176 | String createFileContent = pair.getLeft();
|
| 177 | - String updateFileContent = pair.getLeft();
|
|
| 177 | + String updateFileContent = pair.getRight();
|
|
| 178 | 178 | |
| 179 | 179 | Files.write(path.resolve(DtoEntityContext.VALIDATION_CREATE_CLASSIFIER), createFileContent.getBytes(StandardCharsets.UTF_8));
|
| 180 | 180 | Files.write(path.resolve(DtoEntityContext.VALIDATION_UPDATE_CLASSIFIER), updateFileContent.getBytes(StandardCharsets.UTF_8));
|