Tony CHEMIT pushed to branch develop-7.x at ultreiaio / ird-observe Commits: 9e467c62 by tchemit at 2020-04-17T12:55:47+02:00 update pom - - - - - f87d23db by tchemit at 2020-04-17T13:45:54+02:00 FOB sans objectOperation fait planter la consolidation des données - See #1469 - - - - - 5 changed files: - persistence/src/main/java/fr/ird/observe/binder/data/seine/FloatingObjectEntityReferenceBinder.java - − persistence/src/main/java/fr/ird/observe/entities/seine/FloatingObjectTopiaDao.java - pom.xml - services-local/src/main/java/fr/ird/observe/services/local/service/actions/consolidate/ConsolidateDataServiceLocal.java - services-local/src/main/java/fr/ird/observe/services/local/service/data/seine/FloatingObjectServiceLocal.java Changes: ===================================== persistence/src/main/java/fr/ird/observe/binder/data/seine/FloatingObjectEntityReferenceBinder.java ===================================== @@ -28,6 +28,8 @@ import fr.ird.observe.dto.data.seine.FloatingObjectReference; import fr.ird.observe.dto.referential.ReferentialLocale; import fr.ird.observe.entities.seine.FloatingObject; +import java.util.Optional; + /** * Created on 24/11/15. * @@ -41,6 +43,6 @@ public class FloatingObjectEntityReferenceBinder extends DataEntityReferenceBind @Override public FloatingObjectReference toReference(ReferentialLocale referentialLocale, FloatingObject entity) { - return new FloatingObjectReference(entity, entity.getObjectOperation().getLabel(referentialLocale)); + return new FloatingObjectReference(entity, Optional.ofNullable(entity.getObjectOperation()).map(e->e.getLabel(referentialLocale)).orElse(null)); } } ===================================== persistence/src/main/java/fr/ird/observe/entities/seine/FloatingObjectTopiaDao.java deleted ===================================== @@ -1,99 +0,0 @@ -package fr.ird.observe.entities.seine; - -/* - * #%L - * ObServe :: Persistence - * %% - * Copyright (C) 2008 - 2020 IRD, Code Lutin, Ultreia.io - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import fr.ird.observe.entities.referentiel.I18nReferenceEntities; -import fr.ird.observe.entities.referentiel.seine.ObjectOperation; -import fr.ird.observe.entities.referentiel.seine.ObjectOperationImpl; -import org.nuiton.topia.persistence.support.TopiaSqlQuery; -import org.nuiton.topia.persistence.support.TopiaSqlSupport; - -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.List; - -public class FloatingObjectTopiaDao extends AbstractFloatingObjectTopiaDao<FloatingObject> { - - public List<FloatingObject> findAllStubByActivityId(String activityId, int referenceLocale) { - - return StubSqlQuery.findAll(topiaSqlSupport, activityId, referenceLocale); - - } - - private static class StubSqlQuery extends TopiaSqlQuery<FloatingObject> { - - private final String sql; - - private final String id; - - private final int referenceLocale; - - static List<FloatingObject> findAll(TopiaSqlSupport context, String activityId, int referenceLocale) { - - String sql = "SELECT" + - " fo.topiaId," + - " ot." + I18nReferenceEntities.getPropertyName(referenceLocale) + - " FROM observe_seine.floatingobject fo, observe_seine.objectOperation ot" + - " WHERE " + - " fo.activity = ?" + - " AND fo.objectOperation = ot.topiaid" + - " ORDER BY ot." + I18nReferenceEntities.getPropertyName(referenceLocale); - - StubSqlQuery request = new StubSqlQuery(sql, activityId, referenceLocale); - return context.findMultipleResult(request); - - } - - StubSqlQuery(String sql, String id, int referenceLocale) { - this.sql = sql; - this.id = id; - this.referenceLocale = referenceLocale; - } - - @Override - public PreparedStatement prepareQuery(Connection connection) throws SQLException { - PreparedStatement preparedStatement = connection.prepareStatement(sql); - preparedStatement.setString(1, id); - return preparedStatement; - } - - @Override - public FloatingObject prepareResult(ResultSet set) throws SQLException { - - FloatingObject floatingObject = new FloatingObjectImpl(); - floatingObject.setTopiaId(set.getString(1)); - - String objectTypeLabel = set.getString(2); - ObjectOperation objectType = new ObjectOperationImpl(); - I18nReferenceEntities.setLabel(referenceLocale, objectType, objectTypeLabel); - floatingObject.setObjectOperation(objectType); - - return floatingObject; - - } - - } - -} ===================================== pom.xml ===================================== @@ -26,7 +26,7 @@ <parent> <groupId>io.ultreia.maven</groupId> <artifactId>pom</artifactId> - <version>2020.17</version> + <version>2020.19</version> </parent> <groupId>fr.ird.observe</groupId> ===================================== services-local/src/main/java/fr/ird/observe/services/local/service/actions/consolidate/ConsolidateDataServiceLocal.java ===================================== @@ -382,6 +382,12 @@ public class ConsolidateDataServiceLocal extends ObserveServiceLocal implements private void updateDcp(FloatingObject dcp, ConsolidationActivitySeineDataContext activityContext) { + if (dcp.getObjectOperation() == null) { + log.warn("**********************"); + log.warn(String.format("Floating object %s has no object operation....", dcp.getTopiaId())); + log.warn("**********************"); + return; + } FloatingObjectConsolidateEngine floatingObjectConsolidateEngine = activityContext.floatingObjectConsolidateEngine; ReferentialLocale referentialLocale = getReferentialLocale(); ===================================== services-local/src/main/java/fr/ird/observe/services/local/service/data/seine/FloatingObjectServiceLocal.java ===================================== @@ -78,8 +78,7 @@ public class FloatingObjectServiceLocal extends ObserveServiceLocal implements F @Override public DataDtoReferenceSet<FloatingObjectReference> getFloatingObjectByActivitySeine(String activitySeineId) { - ReferentialLocale referenceLocale = getReferentialLocale(); - List<FloatingObject> entities = ObserveServiceLocal.FLOATING_OBJECT_SPI.getDao(getTopiaPersistenceContext()).findAllStubByActivityId(activitySeineId, referenceLocale.ordinal()); + Set<FloatingObject> entities = ObserveServiceLocal.ACTIVITY_SEINE_SPI.loadEntity(getTopiaPersistenceContext(), activitySeineId).getFloatingObject(); return FLOATING_OBJECT_SPI.toDataReferenceSet(entities, getReferentialLocale()); } View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/48f4592c31414e0e39aab97f3... -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/48f4592c31414e0e39aab97f3... You're receiving this email because of your account on gitlab.com.