Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
d553e3ff
by Tony Chemit at 2022-04-16T10:58:42+02:00
-
3898e8a3
by Tony Chemit at 2022-04-16T10:59:18+02:00
-
486c6ed9
by Tony Chemit at 2022-04-16T11:10:25+02:00
-
3a4e870a
by Tony Chemit at 2022-04-16T11:14:57+02:00
15 changed files:
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/layout/ContentLayoutUINavigationHandler.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/layout/ContentLayoutUINavigationInitializer.java
- core/api/dto/src/test/resources/fixtures/api.properties
- core/persistence/java/src/main/java/fr/ird/observe/entities/Entities.java
- core/persistence/java/src/main/java/fr/ird/observe/entities/ObserveTopiaApplicationContext.java
- core/persistence/java/src/main/java/fr/ird/observe/entities/data/ll/common/TripSpi.java
- + core/persistence/java/src/main/java/fr/ird/observe/entities/data/ll/logbook/ActivitySampleReplicateRequestCallback.java
- + core/persistence/java/src/main/java/fr/ird/observe/entities/data/ll/logbook/LogbookReplicateRequestCallback.java
- + core/persistence/java/src/main/java/fr/ird/observe/entities/data/ll/observation/ObservationReplicateRequestCallback.java
- core/persistence/java/src/main/java/fr/ird/observe/entities/data/ps/common/TripReplicatePartialRequestCallback.java
- + core/persistence/java/src/main/java/fr/ird/observe/entities/data/ps/observation/ObservationReplicateRequestCallback.java
- core/persistence/java/src/test/resources/fixtures/persistence.properties
- model/src/main/models/Observe/dto/class/decorator.properties
- model/src/main/models/Observe/dto/class/decoratorWithClassifier.properties
- pom.xml
Changes:
| ... | ... | @@ -53,7 +53,7 @@ public abstract class ContentLayoutUINavigationHandler<N extends ContentLayoutUI |
| 53 | 53 | |
| 54 | 54 | @Override
|
| 55 | 55 | public final String getText() {
|
| 56 | - return getNode().getScope().getI18nTranslation("type");
|
|
| 56 | + return getNode().getInitializer().getText();
|
|
| 57 | 57 | }
|
| 58 | 58 | |
| 59 | 59 | @Override
|
| ... | ... | @@ -28,6 +28,8 @@ import fr.ird.observe.client.datasource.editor.api.navigation.tree.NavigationSco |
| 28 | 28 | import fr.ird.observe.dto.data.DataGroupByDto;
|
| 29 | 29 | import fr.ird.observe.dto.reference.DataDtoReference;
|
| 30 | 30 | import fr.ird.observe.dto.reference.DtoReference;
|
| 31 | +import io.ultreia.java4all.decoration.Decorator;
|
|
| 32 | +import io.ultreia.java4all.util.SingletonSupplier;
|
|
| 31 | 33 | |
| 32 | 34 | import java.util.Objects;
|
| 33 | 35 | import java.util.function.Function;
|
| ... | ... | @@ -43,18 +45,37 @@ public class ContentLayoutUINavigationInitializer extends NavigationInitializer< |
| 43 | 45 | * How to get show data information.
|
| 44 | 46 | */
|
| 45 | 47 | private final Function<DtoReference, Boolean> showData;
|
| 48 | + private final SingletonSupplier<String> textSupplier;
|
|
| 46 | 49 | private DataDtoReference reference;
|
| 50 | + private Decorator decorator;
|
|
| 47 | 51 | |
| 48 | 52 | public ContentLayoutUINavigationInitializer(NavigationScope scope, DataDtoReference reference) {
|
| 49 | 53 | super(scope);
|
| 50 | 54 | this.reference = Objects.requireNonNull(reference);
|
| 51 | 55 | String showDataPropertyName = scope.getShowDataPropertyName();
|
| 52 | 56 | this.showData = showDataPropertyName == null ? e -> true : e -> e.get(showDataPropertyName);
|
| 57 | + this.textSupplier = SingletonSupplier.of(this::computeText);
|
|
| 58 | + |
|
| 59 | + }
|
|
| 60 | + |
|
| 61 | + private String computeText() {
|
|
| 62 | + String result;
|
|
| 63 | + if (isShowData()) {
|
|
| 64 | + // add statistics
|
|
| 65 | + result = decorator.decorate(reference);
|
|
| 66 | + } else {
|
|
| 67 | + result = getScope().getI18nTranslation("type");
|
|
| 68 | + |
|
| 69 | + }
|
|
| 70 | + return result;
|
|
| 53 | 71 | }
|
| 54 | 72 | |
| 55 | 73 | @Override
|
| 56 | 74 | protected Object init(NavigationContext<ContentLayoutUINavigationContext> context) {
|
| 57 | 75 | context.initReference(reference);
|
| 76 | + String decoratorClassifier = getScope().getMainType().getSimpleName().replace("Dto", "");
|
|
| 77 | + decorator = context.getDecoratorService().getDecoratorByType(reference.getReferenceType(), decoratorClassifier);
|
|
| 78 | + |
|
| 58 | 79 | return getScope().getMainType();
|
| 59 | 80 | }
|
| 60 | 81 | |
| ... | ... | @@ -65,6 +86,7 @@ public class ContentLayoutUINavigationInitializer extends NavigationInitializer< |
| 65 | 86 | @Override
|
| 66 | 87 | protected void reload(NavigationContext<ContentLayoutUINavigationContext> context) {
|
| 67 | 88 | // parentReference = context.reloadReference(parentReference);
|
| 89 | + textSupplier.clear();
|
|
| 68 | 90 | }
|
| 69 | 91 | |
| 70 | 92 | public boolean isShowData() {
|
| ... | ... | @@ -94,6 +116,10 @@ public class ContentLayoutUINavigationInitializer extends NavigationInitializer< |
| 94 | 116 | return reference;
|
| 95 | 117 | }
|
| 96 | 118 | |
| 119 | + public String getText() {
|
|
| 120 | + return textSupplier.get();
|
|
| 121 | + }
|
|
| 122 | + |
|
| 97 | 123 | public String getSelectedId() {
|
| 98 | 124 | return getReference().getId();
|
| 99 | 125 | }
|
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | ###
|
| 22 | 22 | DATA_FORM_COUNT=57
|
| 23 | 23 | REFERENTIAL_FORM_COUNT=91
|
| 24 | -DECORATOR_DEFINITIONS_COUNT=569
|
|
| 24 | +DECORATOR_DEFINITIONS_COUNT=573
|
|
| 25 | 25 | DataGroupByDtoToDefinitionMapping.count=24
|
| 26 | 26 | ReferenceDtoToDtoClassMapping.count=157
|
| 27 | 27 | DtoToReferenceDtoMapping.count=157
|
| ... | ... | @@ -62,4 +62,22 @@ public class Entities { |
| 62 | 62 | java.sql.Date date = resultSet.getDate(dateColumnIndex);
|
| 63 | 63 | return createPoint(type, date, resultSet, dateColumnIndex + 1);
|
| 64 | 64 | }
|
| 65 | + |
|
| 66 | + public static String updateLlTripVersion(String id, String now) {
|
|
| 67 | + return String.format("UPDATE ll_common.Trip SET" +
|
|
| 68 | + " topiaVersion = topiaVersion + 1," +
|
|
| 69 | + " lastUpdateDate = '%s'::timestamp WHERE topiaId = '%s';", now, id);
|
|
| 70 | + }
|
|
| 71 | + |
|
| 72 | + public static String updatePsTripVersion(String id, String now) {
|
|
| 73 | + return String.format("UPDATE ps_common.Trip SET" +
|
|
| 74 | + " topiaVersion = topiaVersion + 1," +
|
|
| 75 | + " lastUpdateDate = '%s'::timestamp WHERE topiaId = '%s';", now, id);
|
|
| 76 | + }
|
|
| 77 | + |
|
| 78 | + public static String updateLastUpdateDate(String id, String now) {
|
|
| 79 | + return String.format("UPDATE common.LastUpdateDate SET" +
|
|
| 80 | + " topiaVersion = topiaVersion + 1," +
|
|
| 81 | + " lastUpdateDate = '%s'::timestamp WHERE type = '%s';", now, id);
|
|
| 82 | + }
|
|
| 65 | 83 | } |
| ... | ... | @@ -49,6 +49,7 @@ import org.nuiton.topia.service.sql.plan.copy.TopiaEntitySqlCopyPlanModel; |
| 49 | 49 | import org.nuiton.topia.service.sql.plan.delete.TopiaEntitySqlDeletePlanModel;
|
| 50 | 50 | import org.nuiton.topia.service.sql.plan.replicate.TopiaEntitySqlReplicatePlanModel;
|
| 51 | 51 | import org.nuiton.topia.service.sql.request.ReplicatePartialRequestCallback;
|
| 52 | +import org.nuiton.topia.service.sql.request.ReplicateRequestCallback;
|
|
| 52 | 53 | import org.nuiton.topia.service.sql.usage.TopiaEntitySqlUsageModel;
|
| 53 | 54 | |
| 54 | 55 | import java.util.Date;
|
| ... | ... | @@ -116,6 +117,11 @@ public class ObserveTopiaApplicationContext extends AbstractObserveTopiaApplicat |
| 116 | 117 | return ObserveTopiaEntitySqlModelResource.get().getReplicatePartialRequestCallbacks();
|
| 117 | 118 | }
|
| 118 | 119 | |
| 120 | + @Override
|
|
| 121 | + public Set<ReplicateRequestCallback> getReplicateRequestCallbacks() {
|
|
| 122 | + return ObserveTopiaEntitySqlModelResource.get().getReplicateRequestCallbacks();
|
|
| 123 | + }
|
|
| 124 | + |
|
| 119 | 125 | @Override
|
| 120 | 126 | public final TagValues getDtoTagValues() {
|
| 121 | 127 | return ObserveTopiaEntitySqlModelResource.get().getDtoTagValues();
|
| ... | ... | @@ -32,13 +32,15 @@ import fr.ird.observe.dto.referential.ReferentialLocale; |
| 32 | 32 | import fr.ird.observe.dto.referential.common.SpeciesReference;
|
| 33 | 33 | import fr.ird.observe.dto.referential.ll.common.VesselActivityReference;
|
| 34 | 34 | import fr.ird.observe.entities.data.ll.logbook.Activity;
|
| 35 | +import fr.ird.observe.entities.referential.common.DataQuality;
|
|
| 35 | 36 | import fr.ird.observe.entities.referential.common.Ocean;
|
| 37 | +import fr.ird.observe.entities.referential.common.Person;
|
|
| 36 | 38 | import fr.ird.observe.entities.referential.common.Species;
|
| 37 | 39 | import fr.ird.observe.entities.referential.common.SpeciesList;
|
| 40 | +import fr.ird.observe.entities.referential.ll.common.ObservationMethod;
|
|
| 41 | +import fr.ird.observe.entities.referential.ll.common.Program;
|
|
| 38 | 42 | import fr.ird.observe.spi.service.ServiceContext;
|
| 39 | 43 | import io.ultreia.java4all.util.Dates;
|
| 40 | -import org.apache.logging.log4j.LogManager;
|
|
| 41 | -import org.apache.logging.log4j.Logger;
|
|
| 42 | 44 | |
| 43 | 45 | import java.util.Date;
|
| 44 | 46 | import java.util.LinkedHashSet;
|
| ... | ... | @@ -53,36 +55,49 @@ import java.util.stream.Stream; |
| 53 | 55 | * @since 9.0.0
|
| 54 | 56 | */
|
| 55 | 57 | public class TripSpi extends GeneratedTripSpi {
|
| 56 | - private static final Logger log = LogManager.getLogger(TripSpi.class);
|
|
| 57 | - |
|
| 58 | - @SuppressWarnings("UnusedReturnValue")
|
|
| 59 | - public static boolean copyTripLogbookMetaData(Trip oldTrip, Trip newTrip) {
|
|
| 60 | - if (!newTrip.isLogbookAvailability()) {
|
|
| 61 | - // copy logbook meta-data to new trip
|
|
| 62 | - log.info(String.format("Add logbook metadata to trip: %s", newTrip.getTopiaId()));
|
|
| 63 | - newTrip.setLogbookAvailability(true);
|
|
| 64 | - newTrip.setLogbookComment(oldTrip.getLogbookComment());
|
|
| 65 | - newTrip.setLogbookDataEntryOperator(oldTrip.getLogbookDataEntryOperator());
|
|
| 66 | - newTrip.setLogbookDataQuality(oldTrip.getLogbookDataQuality());
|
|
| 67 | - return true;
|
|
| 68 | - }
|
|
| 69 | - return false;
|
|
| 58 | + |
|
| 59 | + public String copyLogbookMetadata(Trip trip, String newId) {
|
|
| 60 | + Program logbookProgram = trip.getLogbookProgram();
|
|
| 61 | + String logbookComment = trip.getLogbookComment();
|
|
| 62 | + Person logbookDataEntryOperator = trip.getLogbookDataEntryOperator();
|
|
| 63 | + DataQuality logbookDataQuality = trip.getLogbookDataQuality();
|
|
| 64 | + return String.format("UPDATE ll_common.Trip SET" +
|
|
| 65 | + " logbookProgram = %s," +
|
|
| 66 | + " logbookAvailability = TRUE," +
|
|
| 67 | + " logbookDataEntryOperator = %s," +
|
|
| 68 | + " logbookDataQuality = %s," +
|
|
| 69 | + " logbookComment = %s" +
|
|
| 70 | + " WHERE topiaId = '%s';",
|
|
| 71 | + toId(logbookProgram),
|
|
| 72 | + toId(logbookDataEntryOperator),
|
|
| 73 | + toId(logbookDataQuality),
|
|
| 74 | + escapeComment(logbookComment),
|
|
| 75 | + newId);
|
|
| 70 | 76 | }
|
| 71 | 77 | |
| 72 | - @SuppressWarnings("UnusedReturnValue")
|
|
| 73 | - public static boolean copyTripObservationMetaData(Trip oldTrip, Trip newTrip) {
|
|
| 74 | - if (!newTrip.isObservationsAvailability()) {
|
|
| 75 | - // copy observation meta-data to new trip
|
|
| 76 | - log.info(String.format("Add observation metadata to trip: %s", newTrip.getTopiaId()));
|
|
| 77 | - newTrip.setObservationsAvailability(true);
|
|
| 78 | - newTrip.setObservationsComment(oldTrip.getObservationsComment());
|
|
| 79 | - newTrip.setObservationMethod(oldTrip.getObservationMethod());
|
|
| 80 | - newTrip.setObserver(oldTrip.getObserver());
|
|
| 81 | - newTrip.setObservationsDataEntryOperator(oldTrip.getObservationsDataEntryOperator());
|
|
| 82 | - newTrip.setObservationsDataQuality(oldTrip.getObservationsDataQuality());
|
|
| 83 | - return true;
|
|
| 84 | - }
|
|
| 85 | - return false;
|
|
| 78 | + public String copyObservationsMetadata(Trip trip, String newId) {
|
|
| 79 | + Program observationsProgram = trip.getObservationsProgram();
|
|
| 80 | + String observationsComment = trip.getObservationsComment();
|
|
| 81 | + Person observationsDataEntryOperator = trip.getObservationsDataEntryOperator();
|
|
| 82 | + DataQuality observationsDataQuality = trip.getObservationsDataQuality();
|
|
| 83 | + ObservationMethod observationMethod = trip.getObservationMethod();
|
|
| 84 | + Person observer = trip.getObserver();
|
|
| 85 | + return String.format("UPDATE ll_common.Trip SET" +
|
|
| 86 | + " observationsProgram = %s," +
|
|
| 87 | + " observationsAvailability = TRUE," +
|
|
| 88 | + " observationsDataEntryOperator = %s," +
|
|
| 89 | + " observationsDataQuality = %s," +
|
|
| 90 | + " observationsMethod = %s," +
|
|
| 91 | + " observer = %s," +
|
|
| 92 | + " observationsComment = %s" +
|
|
| 93 | + " WHERE topiaId = '%s';",
|
|
| 94 | + toId(observationsProgram),
|
|
| 95 | + toId(observationsDataEntryOperator),
|
|
| 96 | + toId(observationsDataQuality),
|
|
| 97 | + toId(observationMethod),
|
|
| 98 | + toId(observer),
|
|
| 99 | + escapeComment(observationsComment),
|
|
| 100 | + newId);
|
|
| 86 | 101 | }
|
| 87 | 102 | |
| 88 | 103 | @Override
|
| 1 | +package fr.ird.observe.entities.data.ll.logbook;
|
|
| 2 | + |
|
| 3 | +/*-
|
|
| 4 | + * #%L
|
|
| 5 | + * ObServe Core :: Persistence :: Java
|
|
| 6 | + * %%
|
|
| 7 | + * Copyright (C) 2008 - 2022 IRD, Code Lutin, 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 com.google.auto.service.AutoService;
|
|
| 26 | +import fr.ird.observe.entities.Entities;
|
|
| 27 | +import fr.ird.observe.entities.ToolkitTopiaPersistenceContextSupport;
|
|
| 28 | +import fr.ird.observe.entities.data.ll.common.Trip;
|
|
| 29 | +import fr.ird.observe.entities.data.ll.common.TripTopiaDao;
|
|
| 30 | +import org.nuiton.topia.persistence.internal.AbstractTopiaPersistenceContext;
|
|
| 31 | +import org.nuiton.topia.persistence.script.SqlScriptWriter;
|
|
| 32 | +import org.nuiton.topia.service.sql.internal.SqlRequestSetConsumerContext;
|
|
| 33 | +import org.nuiton.topia.service.sql.request.ReplicateRequest;
|
|
| 34 | +import org.nuiton.topia.service.sql.request.ReplicateRequestCallback;
|
|
| 35 | + |
|
| 36 | +import static fr.ird.observe.spi.context.DataDtoEntityContext.timestamp;
|
|
| 37 | + |
|
| 38 | +/**
|
|
| 39 | + * Replicate call back for Activity Sample to a Trip.
|
|
| 40 | + * <p>
|
|
| 41 | + * Created on 15/04/2022.
|
|
| 42 | + *
|
|
| 43 | + * @author Tony Chemit - dev@tchemit.fr
|
|
| 44 | + * @since 9.0.0
|
|
| 45 | + */
|
|
| 46 | +@AutoService(ReplicateRequestCallback.class)
|
|
| 47 | +public class ActivitySampleReplicateRequestCallback implements ReplicateRequestCallback {
|
|
| 48 | + |
|
| 49 | + @Override
|
|
| 50 | + public boolean accept(ReplicateRequest request) {
|
|
| 51 | + return !request.getOldParentId().contains(".Trip#")
|
|
| 52 | + && request.getNewParentId().contains(".Trip#")
|
|
| 53 | + && request.getDataType().equals(Sample.class.getName());
|
|
| 54 | + }
|
|
| 55 | + |
|
| 56 | + @Override
|
|
| 57 | + public void consume(ReplicateRequest request, SqlRequestSetConsumerContext sourcePersistenceContext) {
|
|
| 58 | + SqlScriptWriter writer = sourcePersistenceContext.getWriter();
|
|
| 59 | + |
|
| 60 | + AbstractTopiaPersistenceContext persistenceContext = sourcePersistenceContext.getSourcePersistenceContext();
|
|
| 61 | + TripTopiaDao tripDao = Trip.getDao(persistenceContext);
|
|
| 62 | + boolean newTripModified = false;
|
|
| 63 | + String oldId = request.getOldParentId();
|
|
| 64 | + String oldTripId = Activity.SPI.getParentId((ToolkitTopiaPersistenceContextSupport) persistenceContext, oldId).getId();
|
|
| 65 | + Trip oldTrip = tripDao.forTopiaIdEquals(oldTripId).findUnique();
|
|
| 66 | + String newId = request.getNewParentId();
|
|
| 67 | + Trip newTrip = tripDao.forTopiaIdEquals(newId).findUnique();
|
|
| 68 | + if (!newTrip.isLogbookAvailability()) {
|
|
| 69 | + newTripModified = true;
|
|
| 70 | + writer.writeSql(Trip.SPI.copyLogbookMetadata(oldTrip, newId));
|
|
| 71 | + }
|
|
| 72 | + String now = timestamp(sourcePersistenceContext.now());
|
|
| 73 | + writer.writeSql(Entities.updateLlTripVersion(oldId, now));
|
|
| 74 | + if (newTripModified) {
|
|
| 75 | + writer.writeSql(Entities.updateLlTripVersion(newId, now));
|
|
| 76 | + }
|
|
| 77 | + }
|
|
| 78 | +} |
| 1 | +package fr.ird.observe.entities.data.ll.logbook;
|
|
| 2 | + |
|
| 3 | +/*-
|
|
| 4 | + * #%L
|
|
| 5 | + * ObServe Core :: Persistence :: Java
|
|
| 6 | + * %%
|
|
| 7 | + * Copyright (C) 2008 - 2022 IRD, Code Lutin, 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 com.google.auto.service.AutoService;
|
|
| 26 | +import fr.ird.observe.entities.Entities;
|
|
| 27 | +import fr.ird.observe.entities.data.ll.common.Trip;
|
|
| 28 | +import fr.ird.observe.entities.data.ll.common.TripTopiaDao;
|
|
| 29 | +import org.nuiton.topia.persistence.script.SqlScriptWriter;
|
|
| 30 | +import org.nuiton.topia.service.sql.internal.SqlRequestSetConsumerContext;
|
|
| 31 | +import org.nuiton.topia.service.sql.request.ReplicateRequest;
|
|
| 32 | +import org.nuiton.topia.service.sql.request.ReplicateRequestCallback;
|
|
| 33 | + |
|
| 34 | +import static fr.ird.observe.spi.context.DataDtoEntityContext.timestamp;
|
|
| 35 | + |
|
| 36 | +/**
|
|
| 37 | + * Replicate call back for any logbook data from a Trip to a Trip.
|
|
| 38 | + * <p>
|
|
| 39 | + * Created on 15/04/2022.
|
|
| 40 | + *
|
|
| 41 | + * @author Tony Chemit - dev@tchemit.fr
|
|
| 42 | + * @since 9.0.0
|
|
| 43 | + */
|
|
| 44 | +@AutoService(ReplicateRequestCallback.class)
|
|
| 45 | +public class LogbookReplicateRequestCallback implements ReplicateRequestCallback {
|
|
| 46 | + |
|
| 47 | + @Override
|
|
| 48 | + public boolean accept(ReplicateRequest request) {
|
|
| 49 | + return request.getOldParentId().contains(".Trip#")
|
|
| 50 | + && request.getNewParentId().contains(".Trip#")
|
|
| 51 | + && request.getDataType().startsWith(fr.ird.observe.spi.module.ll.logbook.BusinessDataPackage.get().getPackageName());
|
|
| 52 | + }
|
|
| 53 | + |
|
| 54 | + @Override
|
|
| 55 | + public void consume(ReplicateRequest request, SqlRequestSetConsumerContext sourcePersistenceContext) {
|
|
| 56 | + SqlScriptWriter writer = sourcePersistenceContext.getWriter();
|
|
| 57 | + TripTopiaDao dao = Trip.getDao(sourcePersistenceContext.getSourcePersistenceContext());
|
|
| 58 | + boolean newTripModified = false;
|
|
| 59 | + String oldId = request.getOldParentId();
|
|
| 60 | + Trip oldTrip = dao.forTopiaIdEquals(oldId).findUnique();
|
|
| 61 | + String newId = request.getNewParentId();
|
|
| 62 | + Trip newTrip = dao.forTopiaIdEquals(newId).findUnique();
|
|
| 63 | + if (!newTrip.isLogbookAvailability()) {
|
|
| 64 | + newTripModified = true;
|
|
| 65 | + writer.writeSql(Trip.SPI.copyLogbookMetadata(oldTrip, newId));
|
|
| 66 | + }
|
|
| 67 | + String now = timestamp(sourcePersistenceContext.now());
|
|
| 68 | + writer.writeSql(Entities.updateLlTripVersion(oldId, now));
|
|
| 69 | + if (newTripModified) {
|
|
| 70 | + writer.writeSql(Entities.updateLlTripVersion(newId, now));
|
|
| 71 | + }
|
|
| 72 | + }
|
|
| 73 | +} |
| 1 | +package fr.ird.observe.entities.data.ll.observation;
|
|
| 2 | + |
|
| 3 | +/*-
|
|
| 4 | + * #%L
|
|
| 5 | + * ObServe Core :: Persistence :: Java
|
|
| 6 | + * %%
|
|
| 7 | + * Copyright (C) 2008 - 2022 IRD, Code Lutin, 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 com.google.auto.service.AutoService;
|
|
| 26 | +import fr.ird.observe.entities.Entities;
|
|
| 27 | +import fr.ird.observe.entities.data.ll.common.Trip;
|
|
| 28 | +import fr.ird.observe.entities.data.ll.common.TripTopiaDao;
|
|
| 29 | +import org.nuiton.topia.persistence.script.SqlScriptWriter;
|
|
| 30 | +import org.nuiton.topia.service.sql.internal.SqlRequestSetConsumerContext;
|
|
| 31 | +import org.nuiton.topia.service.sql.request.ReplicateRequest;
|
|
| 32 | +import org.nuiton.topia.service.sql.request.ReplicateRequestCallback;
|
|
| 33 | + |
|
| 34 | +import static fr.ird.observe.spi.context.DataDtoEntityContext.timestamp;
|
|
| 35 | + |
|
| 36 | +/**
|
|
| 37 | + * Replicate call back for any observation data from a Trip to a Trip.
|
|
| 38 | + * <p>
|
|
| 39 | + * Created on 15/04/2022.
|
|
| 40 | + *
|
|
| 41 | + * @author Tony Chemit - dev@tchemit.fr
|
|
| 42 | + * @since 9.0.0
|
|
| 43 | + */
|
|
| 44 | +@AutoService(ReplicateRequestCallback.class)
|
|
| 45 | +public class ObservationReplicateRequestCallback implements ReplicateRequestCallback {
|
|
| 46 | + |
|
| 47 | + @Override
|
|
| 48 | + public boolean accept(ReplicateRequest request) {
|
|
| 49 | + return request.getOldParentId().contains(".Trip#")
|
|
| 50 | + && request.getNewParentId().contains(".Trip#")
|
|
| 51 | + && request.getDataType().startsWith(fr.ird.observe.spi.module.ll.observation.BusinessDataPackage.get().getPackageName());
|
|
| 52 | + }
|
|
| 53 | + |
|
| 54 | + @Override
|
|
| 55 | + public void consume(ReplicateRequest request, SqlRequestSetConsumerContext sourcePersistenceContext) {
|
|
| 56 | + SqlScriptWriter writer = sourcePersistenceContext.getWriter();
|
|
| 57 | + TripTopiaDao dao = Trip.getDao(sourcePersistenceContext.getSourcePersistenceContext());
|
|
| 58 | + boolean newTripModified = false;
|
|
| 59 | + String oldId = request.getOldParentId();
|
|
| 60 | + Trip oldTrip = dao.forTopiaIdEquals(oldId).findUnique();
|
|
| 61 | + String newId = request.getNewParentId();
|
|
| 62 | + Trip newTrip = dao.forTopiaIdEquals(newId).findUnique();
|
|
| 63 | + if (!newTrip.isObservationsAvailability()) {
|
|
| 64 | + newTripModified = true;
|
|
| 65 | + writer.writeSql(Trip.SPI.copyObservationsMetadata(oldTrip, newId));
|
|
| 66 | + }
|
|
| 67 | + String now = timestamp(sourcePersistenceContext.now());
|
|
| 68 | + writer.writeSql(Entities.updateLlTripVersion(oldId, now));
|
|
| 69 | + if (newTripModified) {
|
|
| 70 | + writer.writeSql(Entities.updateLlTripVersion(newId, now));
|
|
| 71 | + }
|
|
| 72 | + }
|
|
| 73 | +} |
| ... | ... | @@ -23,6 +23,7 @@ package fr.ird.observe.entities.data.ps.common; |
| 23 | 23 | */
|
| 24 | 24 | |
| 25 | 25 | import com.google.auto.service.AutoService;
|
| 26 | +import fr.ird.observe.entities.Entities;
|
|
| 26 | 27 | import fr.ird.observe.entities.data.DataEntity;
|
| 27 | 28 | import fr.ird.observe.entities.data.ps.landing.Landing;
|
| 28 | 29 | import org.nuiton.topia.persistence.script.SqlScriptWriter;
|
| ... | ... | @@ -131,25 +132,13 @@ public class TripReplicatePartialRequestCallback implements ReplicatePartialRequ |
| 131 | 132 | newTripModified = true;
|
| 132 | 133 | }
|
| 133 | 134 | String now = timestamp(sourcePersistenceContext.now());
|
| 134 | - writer.writeSql(updateTripVersion(oldId, now));
|
|
| 135 | + writer.writeSql(Entities.updatePsTripVersion(oldId, now));
|
|
| 135 | 136 | if (newTripModified) {
|
| 136 | - writer.writeSql(updateTripVersion(newId, now));
|
|
| 137 | + writer.writeSql(Entities.updatePsTripVersion(newId, now));
|
|
| 137 | 138 | }
|
| 138 | 139 | for (Class<? extends DataEntity> lastUpdateDate : lastUpdateDates) {
|
| 139 | - writer.writeSql(updateLastUpdateDate(lastUpdateDate.getName(), now));
|
|
| 140 | + writer.writeSql(Entities.updateLastUpdateDate(lastUpdateDate.getName(), now));
|
|
| 140 | 141 | }
|
| 141 | 142 | }
|
| 142 | 143 | |
| 143 | - public String updateTripVersion(String id, String now) {
|
|
| 144 | - return String.format("UPDATE ps_common.Trip SET" +
|
|
| 145 | - " topiaVersion = topiaVersion + 1," +
|
|
| 146 | - " lastUpdateDate = '%s'::timestamp WHERE topiaId = '%s';", now, id);
|
|
| 147 | - }
|
|
| 148 | - |
|
| 149 | - public String updateLastUpdateDate(String id, String now) {
|
|
| 150 | - return String.format("UPDATE common.LastUpdateDate SET" +
|
|
| 151 | - " topiaVersion = topiaVersion + 1," +
|
|
| 152 | - " lastUpdateDate = '%s'::timestamp WHERE type = '%s';", now, id);
|
|
| 153 | - }
|
|
| 154 | - |
|
| 155 | 144 | } |
| 1 | +package fr.ird.observe.entities.data.ps.observation;
|
|
| 2 | + |
|
| 3 | +/*-
|
|
| 4 | + * #%L
|
|
| 5 | + * ObServe Core :: Persistence :: Java
|
|
| 6 | + * %%
|
|
| 7 | + * Copyright (C) 2008 - 2022 IRD, Code Lutin, 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 com.google.auto.service.AutoService;
|
|
| 26 | +import fr.ird.observe.entities.Entities;
|
|
| 27 | +import fr.ird.observe.entities.data.ps.common.Trip;
|
|
| 28 | +import fr.ird.observe.entities.data.ps.common.TripTopiaDao;
|
|
| 29 | +import org.nuiton.topia.persistence.script.SqlScriptWriter;
|
|
| 30 | +import org.nuiton.topia.service.sql.internal.SqlRequestSetConsumerContext;
|
|
| 31 | +import org.nuiton.topia.service.sql.request.ReplicateRequest;
|
|
| 32 | +import org.nuiton.topia.service.sql.request.ReplicateRequestCallback;
|
|
| 33 | + |
|
| 34 | +import static fr.ird.observe.spi.context.DataDtoEntityContext.timestamp;
|
|
| 35 | + |
|
| 36 | +/**
|
|
| 37 | + * Replicate call back for any observation data from a Trip to a Trip.
|
|
| 38 | + * <p>
|
|
| 39 | + * Created on 15/04/2022.
|
|
| 40 | + *
|
|
| 41 | + * @author Tony Chemit - dev@tchemit.fr
|
|
| 42 | + * @since 9.0.0
|
|
| 43 | + */
|
|
| 44 | +@AutoService(ReplicateRequestCallback.class)
|
|
| 45 | +public class ObservationReplicateRequestCallback implements ReplicateRequestCallback {
|
|
| 46 | + |
|
| 47 | + @Override
|
|
| 48 | + public boolean accept(ReplicateRequest request) {
|
|
| 49 | + return request.getOldParentId().contains(".Trip#")
|
|
| 50 | + && request.getNewParentId().contains(".Trip#")
|
|
| 51 | + && request.getDataType().startsWith(fr.ird.observe.spi.module.ll.observation.BusinessDataPackage.get().getPackageName());
|
|
| 52 | + }
|
|
| 53 | + |
|
| 54 | + @Override
|
|
| 55 | + public void consume(ReplicateRequest request, SqlRequestSetConsumerContext sourcePersistenceContext) {
|
|
| 56 | + SqlScriptWriter writer = sourcePersistenceContext.getWriter();
|
|
| 57 | + TripTopiaDao dao = Trip.getDao(sourcePersistenceContext.getSourcePersistenceContext());
|
|
| 58 | + boolean newTripModified = false;
|
|
| 59 | + String oldId = request.getOldParentId();
|
|
| 60 | + Trip oldTrip = dao.forTopiaIdEquals(oldId).findUnique();
|
|
| 61 | + String newId = request.getNewParentId();
|
|
| 62 | + Trip newTrip = dao.forTopiaIdEquals(newId).findUnique();
|
|
| 63 | + if (!newTrip.isObservationsFilled()) {
|
|
| 64 | + newTripModified = true;
|
|
| 65 | + writer.writeSql(Trip.SPI.copyObservationsMetadata(oldTrip, newId));
|
|
| 66 | + }
|
|
| 67 | + String now = timestamp(sourcePersistenceContext.now());
|
|
| 68 | + writer.writeSql(Entities.updatePsTripVersion(oldId, now));
|
|
| 69 | + if (newTripModified) {
|
|
| 70 | + writer.writeSql(Entities.updatePsTripVersion(newId, now));
|
|
| 71 | + }
|
|
| 72 | + }
|
|
| 73 | +} |
| ... | ... | @@ -19,7 +19,7 @@ |
| 19 | 19 | # <http://www.gnu.org/licenses/gpl-3.0.html>.
|
| 20 | 20 | # #L%
|
| 21 | 21 | ###
|
| 22 | -DECORATOR_DEFINITIONS_COUNT=785
|
|
| 22 | +DECORATOR_DEFINITIONS_COUNT=791
|
|
| 23 | 23 | DataGroupByEntityToDefinitionMapping.count=24
|
| 24 | 24 | EntityToDtoClassMapping.count=308
|
| 25 | 25 | DtoToEntityContextMapping.count=185 |
| ... | ... | @@ -55,10 +55,10 @@ data.ll.observation.WeightMeasure=${weightMeasureType::label}##${weight} |
| 55 | 55 | data.ll.pairing.ActivityPairingResultItem=${observationActivity}##$(observe.data.ll.pairing.ActivityPairingResultItem.computedDistance) ${computedDistance}##$(observe.data.ll.pairing.ActivityPairingResultItem.computedTime) ${computedTimeStr}
|
| 56 | 56 | data.ps.common.GearUseFeatures=${gear::label}##${number}
|
| 57 | 57 | data.ps.common.GearUseFeaturesMeasurement=${gearCharacteristic::label}##${measurementValue}
|
| 58 | -data.ps.common.Trip=${startDate::date}##${endDate::date}##${vessel::label}##${vesselCode}##${routeObsSize}##${routeLogbookSize}##${sampleSize}
|
|
| 58 | +data.ps.common.Trip=${startDate::date}##${endDate::date}##${vessel::label}##${vesselCode}##( ${routeObsSize}##${routeLogbookSize}##${sampleSize} )
|
|
| 59 | 59 | data.ps.common.TripGearUseFeatures=$(observe.data.ps.common.TripGearUseFeatures.type)##${gearUseFeaturesSize}
|
| 60 | -data.ps.common.TripLocalmarket=$(observe.data.ps.common.TripLocalmarket.type)##${localmarketBatchSize}##${localmarketSurveySize}##${localmarketSampleSize}
|
|
| 61 | -data.ps.common.TripLogbook=$(observe.data.ps.common.TripLogbook.type)##${routeLogbookSize}##${sampleSize}##${wellPlanSize}
|
|
| 60 | +data.ps.common.TripLocalmarket=$(observe.data.ps.common.TripLocalmarket.type)##( ${localmarketBatchSize}##${localmarketSurveySize}##${localmarketSampleSize} )
|
|
| 61 | +data.ps.common.TripLogbook=$(observe.data.ps.common.TripLogbook.type)##( ${routeLogbookSize}##${sampleSize}##${wellPlanSize} )
|
|
| 62 | 62 | data.ps.dcp.FloatingObjectPreset=${this::label}
|
| 63 | 63 | data.ps.landing.Landing=${species::speciesLabel}##${weightCategory::label}##${weight}
|
| 64 | 64 | data.ps.landing.TripLanding=$(observe.data.ps.landing.TripLanding.type)##${landingSize}
|
| ... | ... | @@ -23,7 +23,7 @@ data.ll.common.Trip=Short|${startDate::date}##${endDate::date}##${vessel::label} |
| 23 | 23 | data.ll.observation.Basket=OnlyHaulingIdentifier|${haulingIdentifier}
|
| 24 | 24 | data.ll.observation.Branchline=OnlyHaulingIdentifier|${haulingIdentifier}
|
| 25 | 25 | data.ll.observation.Section=OnlyHaulingIdentifier|${haulingIdentifier}
|
| 26 | -data.ps.common.Trip=Short|${startDate::date}##${endDate::date}##${vessel::label}##${vesselCode}
|
|
| 26 | +data.ps.common.Trip=Short|${startDate::date}##${endDate::date}##${vessel::label}##${vesselCode}~TripLocalmarket|$(observe.data.ps.common.TripLocalmarket.type)##( ${localmarketBatchSize}##${localmarketSurveySize}##${localmarketSampleSize} )~TripLogbook|$(observe.data.ps.common.TripLogbook.type)##( ${routeLogbookSize}##${sampleSize}##${wellPlanSize} )
|
|
| 27 | 27 | data.ps.logbook.Activity=WithRoute|${date::date}##${time::niceTime}##${number}##${vesselActivity::label}
|
| 28 | 28 | data.ps.observation.Activity=WithRoute|${date::date}##${time::niceTime}##${vesselActivity::label}
|
| 29 | 29 | presets.RemoteDataSourceConfiguration=WithUrl|${name}##${url}
|
| ... | ... | @@ -23,7 +23,7 @@ |
| 23 | 23 | <parent>
|
| 24 | 24 | <groupId>io.ultreia.maven</groupId>
|
| 25 | 25 | <artifactId>pom</artifactId>
|
| 26 | - <version>2022.43</version>
|
|
| 26 | + <version>2022.44</version>
|
|
| 27 | 27 | </parent>
|
| 28 | 28 | <groupId>fr.ird.observe</groupId>
|
| 29 | 29 | <artifactId>ird-observe</artifactId>
|
| ... | ... | @@ -121,6 +121,7 @@ |
| 121 | 121 | </site>
|
| 122 | 122 | </distributionManagement>
|
| 123 | 123 | <properties>
|
| 124 | + <lib.version.java4all.topia>1.75-SNAPSHOT</lib.version.java4all.topia>
|
|
| 124 | 125 | <organizationId>ultreiaio</organizationId>
|
| 125 | 126 | <projectId>ird-observe</projectId>
|
| 126 | 127 | <stageId>frirdobserve</stageId>
|
| ... | ... | @@ -155,7 +156,7 @@ |
| 155 | 156 | <!-- build timestamp configuration -->
|
| 156 | 157 | <maven.build.timestamp.format>dd/MM/yyyy HH:mm z</maven.build.timestamp.format>
|
| 157 | 158 | <buildDate>${maven.build.timestamp}</buildDate>
|
| 158 | - <lib.version.toolkit>6.0.8</lib.version.toolkit>
|
|
| 159 | + <lib.version.toolkit>6.0.9-SNAPSHOT</lib.version.toolkit>
|
|
| 159 | 160 | <lib.version.ognl>3.1.29</lib.version.ognl>
|
| 160 | 161 | <!-- FIXME <lib.version.ognl>3.3.2</lib.version.ognl>-->
|
| 161 | 162 | <lib.version.h2>1.4.196</lib.version.h2>
|