Tony CHEMIT pushed to branch develop-7.x at ultreiaio / ird-observe
Commits:
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:
| ... | ... | @@ -28,6 +28,8 @@ import fr.ird.observe.dto.data.seine.FloatingObjectReference; |
| 28 | 28 |
import fr.ird.observe.dto.referential.ReferentialLocale;
|
| 29 | 29 |
import fr.ird.observe.entities.seine.FloatingObject;
|
| 30 | 30 |
|
| 31 |
+import java.util.Optional;
|
|
| 32 |
+ |
|
| 31 | 33 |
/**
|
| 32 | 34 |
* Created on 24/11/15.
|
| 33 | 35 |
*
|
| ... | ... | @@ -41,6 +43,6 @@ public class FloatingObjectEntityReferenceBinder extends DataEntityReferenceBind |
| 41 | 43 |
|
| 42 | 44 |
@Override
|
| 43 | 45 |
public FloatingObjectReference toReference(ReferentialLocale referentialLocale, FloatingObject entity) {
|
| 44 |
- return new FloatingObjectReference(entity, entity.getObjectOperation().getLabel(referentialLocale));
|
|
| 46 |
+ return new FloatingObjectReference(entity, Optional.ofNullable(entity.getObjectOperation()).map(e->e.getLabel(referentialLocale)).orElse(null));
|
|
| 45 | 47 |
}
|
| 46 | 48 |
}
|
| 1 |
-package fr.ird.observe.entities.seine;
|
|
| 2 |
- |
|
| 3 |
-/*
|
|
| 4 |
- * #%L
|
|
| 5 |
- * ObServe :: Persistence
|
|
| 6 |
- * %%
|
|
| 7 |
- * Copyright (C) 2008 - 2020 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 fr.ird.observe.entities.referentiel.I18nReferenceEntities;
|
|
| 26 |
-import fr.ird.observe.entities.referentiel.seine.ObjectOperation;
|
|
| 27 |
-import fr.ird.observe.entities.referentiel.seine.ObjectOperationImpl;
|
|
| 28 |
-import org.nuiton.topia.persistence.support.TopiaSqlQuery;
|
|
| 29 |
-import org.nuiton.topia.persistence.support.TopiaSqlSupport;
|
|
| 30 |
- |
|
| 31 |
-import java.sql.Connection;
|
|
| 32 |
-import java.sql.PreparedStatement;
|
|
| 33 |
-import java.sql.ResultSet;
|
|
| 34 |
-import java.sql.SQLException;
|
|
| 35 |
-import java.util.List;
|
|
| 36 |
- |
|
| 37 |
-public class FloatingObjectTopiaDao extends AbstractFloatingObjectTopiaDao<FloatingObject> {
|
|
| 38 |
- |
|
| 39 |
- public List<FloatingObject> findAllStubByActivityId(String activityId, int referenceLocale) {
|
|
| 40 |
- |
|
| 41 |
- return StubSqlQuery.findAll(topiaSqlSupport, activityId, referenceLocale);
|
|
| 42 |
- |
|
| 43 |
- }
|
|
| 44 |
- |
|
| 45 |
- private static class StubSqlQuery extends TopiaSqlQuery<FloatingObject> {
|
|
| 46 |
- |
|
| 47 |
- private final String sql;
|
|
| 48 |
- |
|
| 49 |
- private final String id;
|
|
| 50 |
- |
|
| 51 |
- private final int referenceLocale;
|
|
| 52 |
- |
|
| 53 |
- static List<FloatingObject> findAll(TopiaSqlSupport context, String activityId, int referenceLocale) {
|
|
| 54 |
- |
|
| 55 |
- String sql = "SELECT" +
|
|
| 56 |
- " fo.topiaId," +
|
|
| 57 |
- " ot." + I18nReferenceEntities.getPropertyName(referenceLocale) +
|
|
| 58 |
- " FROM observe_seine.floatingobject fo, observe_seine.objectOperation ot" +
|
|
| 59 |
- " WHERE " +
|
|
| 60 |
- " fo.activity = ?" +
|
|
| 61 |
- " AND fo.objectOperation = ot.topiaid" +
|
|
| 62 |
- " ORDER BY ot." + I18nReferenceEntities.getPropertyName(referenceLocale);
|
|
| 63 |
- |
|
| 64 |
- StubSqlQuery request = new StubSqlQuery(sql, activityId, referenceLocale);
|
|
| 65 |
- return context.findMultipleResult(request);
|
|
| 66 |
- |
|
| 67 |
- }
|
|
| 68 |
- |
|
| 69 |
- StubSqlQuery(String sql, String id, int referenceLocale) {
|
|
| 70 |
- this.sql = sql;
|
|
| 71 |
- this.id = id;
|
|
| 72 |
- this.referenceLocale = referenceLocale;
|
|
| 73 |
- }
|
|
| 74 |
- |
|
| 75 |
- @Override
|
|
| 76 |
- public PreparedStatement prepareQuery(Connection connection) throws SQLException {
|
|
| 77 |
- PreparedStatement preparedStatement = connection.prepareStatement(sql);
|
|
| 78 |
- preparedStatement.setString(1, id);
|
|
| 79 |
- return preparedStatement;
|
|
| 80 |
- }
|
|
| 81 |
- |
|
| 82 |
- @Override
|
|
| 83 |
- public FloatingObject prepareResult(ResultSet set) throws SQLException {
|
|
| 84 |
- |
|
| 85 |
- FloatingObject floatingObject = new FloatingObjectImpl();
|
|
| 86 |
- floatingObject.setTopiaId(set.getString(1));
|
|
| 87 |
- |
|
| 88 |
- String objectTypeLabel = set.getString(2);
|
|
| 89 |
- ObjectOperation objectType = new ObjectOperationImpl();
|
|
| 90 |
- I18nReferenceEntities.setLabel(referenceLocale, objectType, objectTypeLabel);
|
|
| 91 |
- floatingObject.setObjectOperation(objectType);
|
|
| 92 |
- |
|
| 93 |
- return floatingObject;
|
|
| 94 |
- |
|
| 95 |
- }
|
|
| 96 |
- |
|
| 97 |
- }
|
|
| 98 |
- |
|
| 99 |
-}
|
| ... | ... | @@ -26,7 +26,7 @@ |
| 26 | 26 |
<parent>
|
| 27 | 27 |
<groupId>io.ultreia.maven</groupId>
|
| 28 | 28 |
<artifactId>pom</artifactId>
|
| 29 |
- <version>2020.17</version>
|
|
| 29 |
+ <version>2020.19</version>
|
|
| 30 | 30 |
</parent>
|
| 31 | 31 |
|
| 32 | 32 |
<groupId>fr.ird.observe</groupId>
|
| ... | ... | @@ -382,6 +382,12 @@ public class ConsolidateDataServiceLocal extends ObserveServiceLocal implements |
| 382 | 382 |
|
| 383 | 383 |
private void updateDcp(FloatingObject dcp, ConsolidationActivitySeineDataContext activityContext) {
|
| 384 | 384 |
|
| 385 |
+ if (dcp.getObjectOperation() == null) {
|
|
| 386 |
+ log.warn("**********************");
|
|
| 387 |
+ log.warn(String.format("Floating object %s has no object operation....", dcp.getTopiaId()));
|
|
| 388 |
+ log.warn("**********************");
|
|
| 389 |
+ return;
|
|
| 390 |
+ }
|
|
| 385 | 391 |
FloatingObjectConsolidateEngine floatingObjectConsolidateEngine = activityContext.floatingObjectConsolidateEngine;
|
| 386 | 392 |
|
| 387 | 393 |
ReferentialLocale referentialLocale = getReferentialLocale();
|
| ... | ... | @@ -78,8 +78,7 @@ public class FloatingObjectServiceLocal extends ObserveServiceLocal implements F |
| 78 | 78 |
|
| 79 | 79 |
@Override
|
| 80 | 80 |
public DataDtoReferenceSet<FloatingObjectReference> getFloatingObjectByActivitySeine(String activitySeineId) {
|
| 81 |
- ReferentialLocale referenceLocale = getReferentialLocale();
|
|
| 82 |
- List<FloatingObject> entities = ObserveServiceLocal.FLOATING_OBJECT_SPI.getDao(getTopiaPersistenceContext()).findAllStubByActivityId(activitySeineId, referenceLocale.ordinal());
|
|
| 81 |
+ Set<FloatingObject> entities = ObserveServiceLocal.ACTIVITY_SEINE_SPI.loadEntity(getTopiaPersistenceContext(), activitySeineId).getFloatingObject();
|
|
| 83 | 82 |
return FLOATING_OBJECT_SPI.toDataReferenceSet(entities, getReferentialLocale());
|
| 84 | 83 |
}
|
| 85 | 84 |
|