Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
70170fc0
by tchemit at 2020-04-17T11:58:23+02:00
2 changed files:
- − persistence/src/main/java/fr/ird/observe/entities/data/ps/observation/FloatingObjectTopiaDao.java
- services-local/src/main/java/fr/ird/observe/services/local/service/data/ps/observation/FloatingObjectServiceLocal.java
Changes:
| 1 |
-package fr.ird.observe.entities.data.ps.observation;
|
|
| 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.dto.referential.I18nReferentialHelper;
|
|
| 26 |
-import fr.ird.observe.entities.referential.ps.common.ObjectOperation;
|
|
| 27 |
-import fr.ird.observe.entities.referential.ps.common.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." + I18nReferentialHelper.getPropertyName(referenceLocale) +
|
|
| 58 |
- " FROM ps_observation.floatingobject fo, ps_common.objectOperation ot" +
|
|
| 59 |
- " WHERE " +
|
|
| 60 |
- " fo.activity = ?" +
|
|
| 61 |
- " AND fo.objectOperation = ot.topiaid" +
|
|
| 62 |
- " ORDER BY ot." + I18nReferentialHelper.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 |
- I18nReferentialHelper.setLabel(referenceLocale, objectType, objectTypeLabel);
|
|
| 91 |
- floatingObject.setObjectOperation(objectType);
|
|
| 92 |
- |
|
| 93 |
- return floatingObject;
|
|
| 94 |
- |
|
| 95 |
- }
|
|
| 96 |
- |
|
| 97 |
- }
|
|
| 98 |
- |
|
| 99 |
-}
|
| ... | ... | @@ -48,7 +48,6 @@ import fr.ird.observe.entities.referential.ps.common.TransmittingBuoyOperation; |
| 48 | 48 |
import fr.ird.observe.entities.referential.ps.common.TransmittingBuoyOwnership;
|
| 49 | 49 |
import fr.ird.observe.entities.referential.ps.common.TransmittingBuoyType;
|
| 50 | 50 |
import fr.ird.observe.entities.referential.ps.observation.ObjectMaterial;
|
| 51 |
-import fr.ird.observe.entities.referential.ps.observation.ObjectMaterialTopiaDao;
|
|
| 52 | 51 |
import fr.ird.observe.entities.referential.ps.observation.ObservedSystem;
|
| 53 | 52 |
import fr.ird.observe.services.local.service.ObserveServiceLocal;
|
| 54 | 53 |
import fr.ird.observe.services.service.data.ps.observation.FloatingObjectService;
|
| ... | ... | @@ -76,16 +75,14 @@ public class FloatingObjectServiceLocal extends ObserveServiceLocal implements F |
| 76 | 75 |
|
| 77 | 76 |
@Override
|
| 78 | 77 |
public ObjectMaterialHierarchyDto getObjectMaterialHierarchy() {
|
| 79 |
- ObjectMaterialTopiaDao dao = getTopiaPersistenceContext().getPsObservationObjectMaterialDao();
|
|
| 80 |
- List<ObjectMaterial> objectMaterials = dao.findAll();
|
|
| 78 |
+ List<ObjectMaterial> objectMaterials = ObjectMaterial.getDao(getTopiaPersistenceContext()).findAll();
|
|
| 81 | 79 |
objectMaterials.sort(Comparator.comparing(ObjectMaterial::getCode));
|
| 82 | 80 |
return getObjectMaterialHierarchyDtos(objectMaterials).get(0);
|
| 83 | 81 |
}
|
| 84 | 82 |
|
| 85 | 83 |
@Override
|
| 86 | 84 |
public DataDtoReferenceSet<FloatingObjectReference> getFloatingObjectByActivitySeine(String activitySeineId) {
|
| 87 |
- ReferentialLocale referenceLocale = getReferentialLocale();
|
|
| 88 |
- List<FloatingObject> entities = FloatingObject.getDao(getTopiaPersistenceContext()).findAllStubByActivityId(activitySeineId, referenceLocale.ordinal());
|
|
| 85 |
+ Set<FloatingObject> entities = Activity.loadEntity(getTopiaPersistenceContext(), activitySeineId).getFloatingObject();
|
|
| 89 | 86 |
return FloatingObject.toReferenceSet(entities, getReferentialLocale());
|
| 90 | 87 |
}
|
| 91 | 88 |
|