Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
9135411f
by Tony Chemit at 2021-01-20T20:23:08+01:00
11 changed files:
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/navigation/tree/root/RootNavigationCapability.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/navigation/tree/root/RootNavigationInitializer.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/navigation/tree/root/RootNavigationTreeNodeProvider.java
- client/datasource/editor/common/src/main/java/fr/ird/observe/client/datasource/editor/common/CommonRootNavigationTreeNodeProvider.java
- client/datasource/editor/ll/src/main/java/fr/ird/observe/client/datasource/editor/ll/LlRootNavigationTreeNodeProvider.java
- client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/PsRootNavigationTreeNodeProvider.java
- models/persistence/src/main/java/fr/ird/observe/entities/data/TripAwareTopiaDao.java
- models/persistence/src/main/java/fr/ird/observe/entities/data/ll/common/TripTopiaDao.java
- models/persistence/src/main/java/fr/ird/observe/entities/data/ps/common/TripTopiaDao.java
- services/local-impl/src/main/java/fr/ird/observe/services/local/service/data/NavigationServiceLocalSupport.java
- services/local-impl/src/main/java/fr/ird/observe/services/local/service/data/TripServiceLocalSupport.java
Changes:
| ... | ... | @@ -75,8 +75,8 @@ public class RootNavigationCapability implements ReferenceContainerCapability<Ro |
| 75 | 75 |
NavigationTreeConfig config = initializer.getConfig();
|
| 76 | 76 |
NavigationResult navigationResult = initializer.getNavigationResult();
|
| 77 | 77 |
List<ProgramReference> programs = initializer.getPrograms();
|
| 78 |
- List<? extends RootNavigationTreeNodeProvider> rootNodeProviders = initializer.getRootNodeProviders();
|
|
| 79 |
- List<? extends RootNavigationTreeNodeProvider> providers = rootNodeProviders.stream().filter(p -> config.isShowModule(p.getModule())).collect(Collectors.toList());
|
|
| 78 |
+ List<? extends RootNavigationTreeNodeProvider<?>> rootNodeProviders = initializer.getRootNodeProviders();
|
|
| 79 |
+ List<? extends RootNavigationTreeNodeProvider<?>> providers = rootNodeProviders.stream().filter(p -> config.isShowModule(p.getModule())).collect(Collectors.toList());
|
|
| 80 | 80 |
providers.forEach(p -> p.initRootDataNode(config, navigationResult, programs, rootNode));
|
| 81 | 81 |
if (config.isLoadReferential()) {
|
| 82 | 82 |
providers.forEach(p -> p.initRootReferentialNode(rootNode, navigationResult));
|
| ... | ... | @@ -98,13 +98,13 @@ public class RootNavigationCapability implements ReferenceContainerCapability<Ro |
| 98 | 98 |
return 0;
|
| 99 | 99 |
}
|
| 100 | 100 |
|
| 101 |
- public RootNavigationTreeNodeProvider getProvider(ProgramReference referenceType) {
|
|
| 101 |
+ public RootNavigationTreeNodeProvider<?> getProvider(ProgramReference referenceType) {
|
|
| 102 | 102 |
return getNode().getInitializer().getRootNodeProvider(referenceType);
|
| 103 | 103 |
}
|
| 104 | 104 |
|
| 105 | 105 |
public NavigationNode newChildNode(ProgramReference reference) {
|
| 106 | 106 |
RootNavigationNode node = getNode();
|
| 107 |
- RootNavigationTreeNodeProvider provider = getProvider(reference);
|
|
| 107 |
+ RootNavigationTreeNodeProvider<?> provider = getProvider(reference);
|
|
| 108 | 108 |
return provider.newChildNode(node, reference, 0);
|
| 109 | 109 |
}
|
| 110 | 110 |
|
| ... | ... | @@ -42,7 +42,7 @@ import java.util.Objects; |
| 42 | 42 |
* @since 8.0.1
|
| 43 | 43 |
*/
|
| 44 | 44 |
public class RootNavigationInitializer extends NavigationInitializer<RootNavigationContext> {
|
| 45 |
- private final SingletonSupplier<List<? extends RootNavigationTreeNodeProvider>> rootNodeProviders;
|
|
| 45 |
+ private final SingletonSupplier<List<? extends RootNavigationTreeNodeProvider<?>>> rootNodeProviders;
|
|
| 46 | 46 |
private final SingletonSupplier<Boolean> canLoadChildrenOnOpen;
|
| 47 | 47 |
private final NavigationTreeConfig config;
|
| 48 | 48 |
private final NavigationResult navigationResult;
|
| ... | ... | @@ -73,7 +73,7 @@ public class RootNavigationInitializer extends NavigationInitializer<RootNavigat |
| 73 | 73 |
protected void reload(NavigationContext<RootNavigationContext> context) {
|
| 74 | 74 |
}
|
| 75 | 75 |
|
| 76 |
- public final List<? extends RootNavigationTreeNodeProvider> getRootNodeProviders() {
|
|
| 76 |
+ public final List<? extends RootNavigationTreeNodeProvider<?>> getRootNodeProviders() {
|
|
| 77 | 77 |
return rootNodeProviders.get();
|
| 78 | 78 |
}
|
| 79 | 79 |
|
| ... | ... | @@ -30,11 +30,10 @@ import fr.ird.observe.client.datasource.editor.api.content.referential.Referenti |
| 30 | 30 |
import fr.ird.observe.client.datasource.editor.api.navigation.tree.NavigationNode;
|
| 31 | 31 |
import fr.ird.observe.dto.reference.DataDtoReference;
|
| 32 | 32 |
import fr.ird.observe.dto.referential.ReferentialDto;
|
| 33 |
-import fr.ird.observe.dto.referential.common.GearType;
|
|
| 34 | 33 |
import fr.ird.observe.dto.referential.common.ProgramReference;
|
| 35 | 34 |
import fr.ird.observe.services.service.data.NavigationResult;
|
| 36 |
-import fr.ird.observe.spi.module.BusinessModule;
|
|
| 37 | 35 |
import fr.ird.observe.spi.module.BusinessProject;
|
| 36 |
+import fr.ird.observe.spi.module.ObserveBusinessModule;
|
|
| 38 | 37 |
|
| 39 | 38 |
import java.util.Comparator;
|
| 40 | 39 |
import java.util.LinkedList;
|
| ... | ... | @@ -49,19 +48,17 @@ import java.util.stream.Collectors; |
| 49 | 48 |
* @author Tony Chemit - dev@tchemit.fr
|
| 50 | 49 |
* @since 8.0
|
| 51 | 50 |
*/
|
| 52 |
-public abstract class RootNavigationTreeNodeProvider {
|
|
| 53 |
- public static List<RootNavigationTreeNodeProvider> PROVIDERS;
|
|
| 54 |
- private final BusinessModule module;
|
|
| 55 |
- //FIXME Add this in BusinessModule
|
|
| 56 |
- private final GearType gearType;
|
|
| 51 |
+public abstract class RootNavigationTreeNodeProvider<B extends fr.ird.observe.spi.module.BusinessModule & ObserveBusinessModule> {
|
|
| 52 |
+ public static List<RootNavigationTreeNodeProvider<?>> PROVIDERS;
|
|
| 53 |
+ private final B module;
|
|
| 57 | 54 |
private final int priority;
|
| 58 | 55 |
private final ImmutableList<Class<? extends NavigationNode>> acceptedNodeTypes;
|
| 59 | 56 |
private final Class<? extends DataDtoReference> acceptedType;
|
| 60 | 57 |
|
| 61 |
- public static synchronized List<RootNavigationTreeNodeProvider> getProviders() {
|
|
| 58 |
+ public static synchronized List<RootNavigationTreeNodeProvider<?>> getProviders() {
|
|
| 62 | 59 |
if (PROVIDERS == null) {
|
| 63 | 60 |
PROVIDERS = new LinkedList<>();
|
| 64 |
- for (RootNavigationTreeNodeProvider o : ServiceLoader.load(RootNavigationTreeNodeProvider.class)) {
|
|
| 61 |
+ for (RootNavigationTreeNodeProvider<?> o : ServiceLoader.load(RootNavigationTreeNodeProvider.class)) {
|
|
| 65 | 62 |
PROVIDERS.add(o);
|
| 66 | 63 |
}
|
| 67 | 64 |
PROVIDERS.sort(Comparator.comparing(RootNavigationTreeNodeProvider::priority));
|
| ... | ... | @@ -69,9 +66,8 @@ public abstract class RootNavigationTreeNodeProvider { |
| 69 | 66 |
return PROVIDERS;
|
| 70 | 67 |
}
|
| 71 | 68 |
|
| 72 |
- protected RootNavigationTreeNodeProvider(BusinessProject project, BusinessModule module, GearType gearType, ImmutableList<Class<? extends NavigationNode>> acceptedNodeTypes, Class<? extends DataDtoReference> acceptedType) {
|
|
| 69 |
+ protected RootNavigationTreeNodeProvider(BusinessProject project, B module, ImmutableList<Class<? extends NavigationNode>> acceptedNodeTypes, Class<? extends DataDtoReference> acceptedType) {
|
|
| 73 | 70 |
this.module = Objects.requireNonNull(module);
|
| 74 |
- this.gearType = gearType;
|
|
| 75 | 71 |
this.acceptedNodeTypes = acceptedNodeTypes;
|
| 76 | 72 |
this.acceptedType = acceptedType;
|
| 77 | 73 |
this.priority = Objects.requireNonNull(project).getModulePriority(module);
|
| ... | ... | @@ -124,7 +120,7 @@ public abstract class RootNavigationTreeNodeProvider { |
| 124 | 120 |
return priority;
|
| 125 | 121 |
}
|
| 126 | 122 |
|
| 127 |
- public BusinessModule getModule() {
|
|
| 123 |
+ public B getModule() {
|
|
| 128 | 124 |
return module;
|
| 129 | 125 |
}
|
| 130 | 126 |
|
| ... | ... | @@ -140,7 +136,7 @@ public abstract class RootNavigationTreeNodeProvider { |
| 140 | 136 |
}
|
| 141 | 137 |
|
| 142 | 138 |
public boolean accept(ProgramReference childrenReference) {
|
| 143 |
- return gearType != null && Objects.equals(gearType, childrenReference.getGearType());
|
|
| 139 |
+ return module.accept(childrenReference);
|
|
| 144 | 140 |
}
|
| 145 | 141 |
|
| 146 | 142 |
public ContentListUINavigationNode newChildNode(RootNavigationNode node, ProgramReference reference, int tripCount) {
|
| ... | ... | @@ -26,21 +26,18 @@ import com.google.auto.service.AutoService; |
| 26 | 26 |
import com.google.common.collect.ImmutableList;
|
| 27 | 27 |
import fr.ird.observe.client.datasource.editor.api.navigation.tree.root.RootNavigationTreeNodeProvider;
|
| 28 | 28 |
import fr.ird.observe.spi.module.ObserveBusinessProject;
|
| 29 |
+import fr.ird.observe.spi.module.common.BusinessModule;
|
|
| 29 | 30 |
|
| 30 | 31 |
/**
|
| 31 | 32 |
* @author Tony Chemit - dev@tchemit.fr
|
| 32 | 33 |
* @since 8.0
|
| 33 | 34 |
*/
|
| 34 | 35 |
@AutoService(RootNavigationTreeNodeProvider.class)
|
| 35 |
-public class CommonRootNavigationTreeNodeProvider extends RootNavigationTreeNodeProvider {
|
|
| 36 |
+public class CommonRootNavigationTreeNodeProvider extends RootNavigationTreeNodeProvider<BusinessModule> {
|
|
| 36 | 37 |
|
| 37 | 38 |
public CommonRootNavigationTreeNodeProvider() {
|
| 38 |
- super(ObserveBusinessProject.get(), ObserveBusinessProject.get().getCommonBusinessModule(), null,
|
|
| 39 |
+ super(ObserveBusinessProject.get(), ObserveBusinessProject.get().getCommonBusinessModule(),
|
|
| 39 | 40 |
ImmutableList.of(fr.ird.observe.client.datasource.editor.common.referential.common.ReferentialHomeUINavigationNode.class), null);
|
| 40 | 41 |
}
|
| 41 | 42 |
|
| 42 |
-// @Override
|
|
| 43 |
-// public void initRootDataNode(NavigationTreeConfig config, NavigationResult navigationResult, List<ProgramReference> programs, RootNavigationNode rootNode) {
|
|
| 44 |
-// }
|
|
| 45 |
- |
|
| 46 | 43 |
}
|
| ... | ... | @@ -28,19 +28,19 @@ import fr.ird.observe.client.datasource.editor.api.navigation.tree.root.RootNavi |
| 28 | 28 |
import fr.ird.observe.client.datasource.editor.api.navigation.tree.root.RootNavigationTreeNodeProvider;
|
| 29 | 29 |
import fr.ird.observe.client.datasource.editor.ll.data.common.TripListUINavigationNode;
|
| 30 | 30 |
import fr.ird.observe.dto.data.ll.common.TripReference;
|
| 31 |
-import fr.ird.observe.dto.referential.common.GearType;
|
|
| 32 | 31 |
import fr.ird.observe.dto.referential.common.ProgramReference;
|
| 33 | 32 |
import fr.ird.observe.spi.module.ObserveBusinessProject;
|
| 33 |
+import fr.ird.observe.spi.module.ll.BusinessModule;
|
|
| 34 | 34 |
|
| 35 | 35 |
/**
|
| 36 | 36 |
* @author Tony Chemit - dev@tchemit.fr
|
| 37 | 37 |
* @since 8.0
|
| 38 | 38 |
*/
|
| 39 | 39 |
@AutoService(RootNavigationTreeNodeProvider.class)
|
| 40 |
-public class LlRootNavigationTreeNodeProvider extends RootNavigationTreeNodeProvider {
|
|
| 40 |
+public class LlRootNavigationTreeNodeProvider extends RootNavigationTreeNodeProvider<BusinessModule> {
|
|
| 41 | 41 |
|
| 42 | 42 |
public LlRootNavigationTreeNodeProvider() {
|
| 43 |
- super(ObserveBusinessProject.get(), ObserveBusinessProject.get().getLlBusinessModule(), GearType.longline,
|
|
| 43 |
+ super(ObserveBusinessProject.get(), ObserveBusinessProject.get().getLlBusinessModule(),
|
|
| 44 | 44 |
ImmutableList.of(TripListUINavigationNode.class,
|
| 45 | 45 |
fr.ird.observe.client.datasource.editor.ll.referential.common.ReferentialHomeUINavigationNode.class,
|
| 46 | 46 |
fr.ird.observe.client.datasource.editor.ll.referential.landing.ReferentialHomeUINavigationNode.class,
|
| ... | ... | @@ -28,19 +28,19 @@ import fr.ird.observe.client.datasource.editor.api.navigation.tree.root.RootNavi |
| 28 | 28 |
import fr.ird.observe.client.datasource.editor.api.navigation.tree.root.RootNavigationTreeNodeProvider;
|
| 29 | 29 |
import fr.ird.observe.client.datasource.editor.ps.data.common.TripListUINavigationNode;
|
| 30 | 30 |
import fr.ird.observe.dto.data.ll.common.TripReference;
|
| 31 |
-import fr.ird.observe.dto.referential.common.GearType;
|
|
| 32 | 31 |
import fr.ird.observe.dto.referential.common.ProgramReference;
|
| 33 | 32 |
import fr.ird.observe.spi.module.ObserveBusinessProject;
|
| 33 |
+import fr.ird.observe.spi.module.ps.BusinessModule;
|
|
| 34 | 34 |
|
| 35 | 35 |
/**
|
| 36 | 36 |
* @author Tony Chemit - dev@tchemit.fr
|
| 37 | 37 |
* @since 8.0
|
| 38 | 38 |
*/
|
| 39 | 39 |
@AutoService(RootNavigationTreeNodeProvider.class)
|
| 40 |
-public class PsRootNavigationTreeNodeProvider extends RootNavigationTreeNodeProvider {
|
|
| 40 |
+public class PsRootNavigationTreeNodeProvider extends RootNavigationTreeNodeProvider<BusinessModule> {
|
|
| 41 | 41 |
|
| 42 | 42 |
public PsRootNavigationTreeNodeProvider() {
|
| 43 |
- super(ObserveBusinessProject.get(), ObserveBusinessProject.get().getPsBusinessModule(), GearType.seine,
|
|
| 43 |
+ super(ObserveBusinessProject.get(), ObserveBusinessProject.get().getPsBusinessModule(),
|
|
| 44 | 44 |
ImmutableList.of(TripListUINavigationNode.class,
|
| 45 | 45 |
fr.ird.observe.client.datasource.editor.ps.referential.common.ReferentialHomeUINavigationNode.class,
|
| 46 | 46 |
fr.ird.observe.client.datasource.editor.ps.referential.observation.ReferentialHomeUINavigationNode.class),
|
| ... | ... | @@ -49,6 +49,6 @@ public class PsRootNavigationTreeNodeProvider extends RootNavigationTreeNodeProv |
| 49 | 49 |
|
| 50 | 50 |
@Override
|
| 51 | 51 |
public TripListUINavigationNode newChildNode(RootNavigationNode node, ProgramReference reference, int tripCount) {
|
| 52 |
- return TripListUINavigationNode.create(reference, (int) tripCount);
|
|
| 52 |
+ return TripListUINavigationNode.create(reference, tripCount);
|
|
| 53 | 53 |
}
|
| 54 | 54 |
}
|
| ... | ... | @@ -62,7 +62,7 @@ public interface TripAwareTopiaDao<D extends DataDto & fr.ird.observe.dto.data.T |
| 62 | 62 |
|
| 63 | 63 |
List<E> getMatchingTripsVesselWithinDateRange(String id, String vesselId, Date startDate, Date endDate);
|
| 64 | 64 |
|
| 65 |
- List<R> getChildren(ReferentialLocale referentialLocale, ImmutableMap<String, ProgramReference> programById, ImmutableMap<String, PersonReference> personById, ImmutableMap<String, VesselReference> vesselById);
|
|
| 65 |
+ List<R> getChildren(ReferentialLocale referentialLocale, String programId, ImmutableMap<String, ProgramReference> programById, ImmutableMap<String, PersonReference> personById, ImmutableMap<String, VesselReference> vesselById);
|
|
| 66 | 66 |
|
| 67 | 67 |
default void fillTripCountByProgramId(Map<String, Integer> map) {
|
| 68 | 68 |
TopiaEntityEnum entityEnum = ((AbstractObserveTopiaDao<?>) this).getTopiaEntityEnum();
|
| ... | ... | @@ -72,7 +72,7 @@ public interface TripAwareTopiaDao<D extends DataDto & fr.ird.observe.dto.data.T |
| 72 | 72 |
|
| 73 | 73 |
default List<E> getChildren(Program parent, Date lastUpdate) {
|
| 74 | 74 |
if (lastUpdate == null) {
|
| 75 |
- return forProperties(TripAware.PROPERTY_PROGRAM, parent).findAll();
|
|
| 75 |
+ return forEquals(TripAware.PROPERTY_PROGRAM, parent).findAll();
|
|
| 76 | 76 |
}
|
| 77 | 77 |
return forLastUpdateDateGreaterThan(lastUpdate).addEquals(TripAware.PROPERTY_PROGRAM, parent).findAll();
|
| 78 | 78 |
}
|
| ... | ... | @@ -55,7 +55,7 @@ import java.util.stream.Collectors; |
| 55 | 55 |
|
| 56 | 56 |
public class TripTopiaDao extends AbstractTripTopiaDao<Trip> implements TripAwareTopiaDao<TripDto, TripReference, Trip> {
|
| 57 | 57 |
|
| 58 |
- public static final String GET_TRIP_REFERENCES = "SELECT" +
|
|
| 58 |
+ public static final String GET_ALL_TRIP_REFERENCES = "SELECT" +
|
|
| 59 | 59 |
" t.program," +
|
| 60 | 60 |
" t.topiaId," +
|
| 61 | 61 |
" t.startDate," +
|
| ... | ... | @@ -66,6 +66,19 @@ public class TripTopiaDao extends AbstractTripTopiaDao<Trip> implements TripAwar |
| 66 | 66 |
" t.observationsAvailability," +
|
| 67 | 67 |
" t.logbookAvailability" +
|
| 68 | 68 |
" FROM %s.%s t;";
|
| 69 |
+ public static final String GET_TRIP_REFERENCES = "SELECT" +
|
|
| 70 |
+ " t.program," +
|
|
| 71 |
+ " t.topiaId," +
|
|
| 72 |
+ " t.startDate," +
|
|
| 73 |
+ " t.endDate," +
|
|
| 74 |
+ " t.tripType," +
|
|
| 75 |
+ " t.observer," +
|
|
| 76 |
+ " t.vessel," +
|
|
| 77 |
+ " t.observationsAvailability," +
|
|
| 78 |
+ " t.logbookAvailability" +
|
|
| 79 |
+ " FROM %s.%s t" +
|
|
| 80 |
+ " WHERE t.program = '%s';";
|
|
| 81 |
+ |
|
| 69 | 82 |
|
| 70 | 83 |
private static class TripMapActivityObsPointQuery extends TopiaSqlQuery<List<TripMapPoint>> {
|
| 71 | 84 |
|
| ... | ... | @@ -269,7 +282,7 @@ public class TripTopiaDao extends AbstractTripTopiaDao<Trip> implements TripAwar |
| 269 | 282 |
}
|
| 270 | 283 |
|
| 271 | 284 |
@Override
|
| 272 |
- public List<TripReference> getChildren(ReferentialLocale referentialLocale, ImmutableMap<String, ProgramReference> programById, ImmutableMap<String, PersonReference> personById, ImmutableMap<String, VesselReference> vesselById) {
|
|
| 285 |
+ public List<TripReference> getChildren(ReferentialLocale referentialLocale, String programId, ImmutableMap<String, ProgramReference> programById, ImmutableMap<String, PersonReference> personById, ImmutableMap<String, VesselReference> vesselById) {
|
|
| 273 | 286 |
|
| 274 | 287 |
String dbTableName = getTopiaEntityEnum().dbTableName();
|
| 275 | 288 |
Map<String, Integer> observationActivityCount = new TreeMap<>();
|
| ... | ... | @@ -281,12 +294,16 @@ public class TripTopiaDao extends AbstractTripTopiaDao<Trip> implements TripAwar |
| 281 | 294 |
Map<String, Integer> landingCount = new TreeMap<>();
|
| 282 | 295 |
fillCount(getCountSql(ObserveEntityEnum.ll_landing_Landing, dbTableName), landingCount);
|
| 283 | 296 |
|
| 284 |
- String sql = String.format(GET_TRIP_REFERENCES, getTopiaEntityEnum().dbSchemaName(), dbTableName);
|
|
| 285 |
- |
|
| 297 |
+ String sql;
|
|
| 298 |
+ if (programId == null) {
|
|
| 299 |
+ sql = String.format(GET_ALL_TRIP_REFERENCES, getTopiaEntityEnum().dbSchemaName(), dbTableName);
|
|
| 300 |
+ } else {
|
|
| 301 |
+ sql = String.format(GET_TRIP_REFERENCES, getTopiaEntityEnum().dbSchemaName(), dbTableName, programId);
|
|
| 302 |
+ }
|
|
| 286 | 303 |
TopiaSqlQuery<TripReference> query = TopiaSqlQuery.wrap(sql, resultSet -> {
|
| 287 | 304 |
TripDto dto = new TripDto();
|
| 288 |
- String programId = resultSet.getString(1);
|
|
| 289 |
- dto.setProgram(programById.get(programId));
|
|
| 305 |
+ String thisProgramId = resultSet.getString(1);
|
|
| 306 |
+ dto.setProgram(programById.get(thisProgramId));
|
|
| 290 | 307 |
String id = resultSet.getString(2);
|
| 291 | 308 |
dto.setId(id);
|
| 292 | 309 |
dto.setStartDate(resultSet.getDate(3));
|
| ... | ... | @@ -59,7 +59,7 @@ import java.util.stream.Collectors; |
| 59 | 59 |
*/
|
| 60 | 60 |
public class TripTopiaDao extends AbstractTripTopiaDao<Trip> implements TripAwareTopiaDao<TripDto, TripReference, Trip> {
|
| 61 | 61 |
|
| 62 |
- public static final String GET_TRIP_REFERENCES = "SELECT" +
|
|
| 62 |
+ public static final String GET_ALL_TRIP_REFERENCES = "SELECT" +
|
|
| 63 | 63 |
" t.program," +
|
| 64 | 64 |
" t.topiaId," +
|
| 65 | 65 |
" t.startDate," +
|
| ... | ... | @@ -68,6 +68,16 @@ public class TripTopiaDao extends AbstractTripTopiaDao<Trip> implements TripAwar |
| 68 | 68 |
" t.vessel" +
|
| 69 | 69 |
" FROM %s.%s t;";
|
| 70 | 70 |
|
| 71 |
+ public static final String GET_TRIP_REFERENCES = "SELECT" +
|
|
| 72 |
+ " t.program," +
|
|
| 73 |
+ " t.topiaId," +
|
|
| 74 |
+ " t.startDate," +
|
|
| 75 |
+ " t.endDate," +
|
|
| 76 |
+ " t.observer," +
|
|
| 77 |
+ " t.vessel" +
|
|
| 78 |
+ " FROM %s.%s t" +
|
|
| 79 |
+ " WHERE t.program = '%s';";
|
|
| 80 |
+ |
|
| 71 | 81 |
private static class TripMapActivityObservationPointQuery extends TopiaSqlQuery<TripMapPoint> {
|
| 72 | 82 |
|
| 73 | 83 |
private static final String SQL = "SELECT" +
|
| ... | ... | @@ -169,14 +179,20 @@ public class TripTopiaDao extends AbstractTripTopiaDao<Trip> implements TripAwar |
| 169 | 179 |
}
|
| 170 | 180 |
|
| 171 | 181 |
@Override
|
| 172 |
- public List<TripReference> getChildren(ReferentialLocale referentialLocale, ImmutableMap<String, ProgramReference> programById, ImmutableMap<String, PersonReference> personById, ImmutableMap<String, VesselReference> vesselById) {
|
|
| 182 |
+ public List<TripReference> getChildren(ReferentialLocale referentialLocale, String programId, ImmutableMap<String, ProgramReference> programById, ImmutableMap<String, PersonReference> personById, ImmutableMap<String, VesselReference> vesselById) {
|
|
| 173 | 183 |
String dbTableName = getTopiaEntityEnum().dbTableName();
|
| 174 |
- String sql = String.format(GET_TRIP_REFERENCES, getTopiaEntityEnum().dbSchemaName(), dbTableName);
|
|
| 184 |
+ |
|
| 185 |
+ String sql;
|
|
| 186 |
+ if (programId == null) {
|
|
| 187 |
+ sql = String.format(GET_ALL_TRIP_REFERENCES, getTopiaEntityEnum().dbSchemaName(), dbTableName);
|
|
| 188 |
+ } else {
|
|
| 189 |
+ sql = String.format(GET_TRIP_REFERENCES, getTopiaEntityEnum().dbSchemaName(), dbTableName, programId);
|
|
| 190 |
+ }
|
|
| 175 | 191 |
Map<String, Integer> observationRouteCount = new TreeMap<>();
|
| 176 | 192 |
fillCount(getCountSql(ObserveEntityEnum.ps_observation_Route, dbTableName), observationRouteCount);
|
| 177 | 193 |
|
| 178 | 194 |
TopiaSqlQuery<TripReference> query = TopiaSqlQuery.wrap(sql, resultSet -> {
|
| 179 |
- String programId = resultSet.getString(1);
|
|
| 195 |
+ String thisProgramId = resultSet.getString(1);
|
|
| 180 | 196 |
String id = resultSet.getString(2);
|
| 181 | 197 |
|
| 182 | 198 |
Integer routeCount = observationRouteCount.getOrDefault(id, 0);
|
| ... | ... | @@ -186,7 +202,7 @@ public class TripTopiaDao extends AbstractTripTopiaDao<Trip> implements TripAwar |
| 186 | 202 |
return routeCount;
|
| 187 | 203 |
}
|
| 188 | 204 |
};
|
| 189 |
- dto.setProgram(programById.get(programId));
|
|
| 205 |
+ dto.setProgram(programById.get(thisProgramId));
|
|
| 190 | 206 |
dto.setId(id);
|
| 191 | 207 |
dto.setStartDate(resultSet.getDate(3));
|
| 192 | 208 |
dto.setEndDate(resultSet.getDate(4));
|
| ... | ... | @@ -113,12 +113,12 @@ class NavigationServiceLocalSupport extends ObserveServiceLocal implements Navig |
| 113 | 113 |
ArrayListMultimap<String, fr.ird.observe.dto.data.ll.common.TripReference> tripLlByProgram = ArrayListMultimap.create();
|
| 114 | 114 |
if (canReadData) {
|
| 115 | 115 |
if (loadPs) {
|
| 116 |
- List<fr.ird.observe.dto.data.ps.common.TripReference> trips = fr.ird.observe.entities.data.ps.common.Trip.SPI.getDao(getTopiaPersistenceContext()).getChildren(referentialLocale, programById, personById, vesselById);
|
|
| 116 |
+ List<fr.ird.observe.dto.data.ps.common.TripReference> trips = fr.ird.observe.entities.data.ps.common.Trip.SPI.getDao(getTopiaPersistenceContext()).getChildren(referentialLocale, null, programById, personById, vesselById);
|
|
| 117 | 117 |
trips.forEach(t -> tripPsByProgram.put(t.getProgram().getId(), t));
|
| 118 | 118 |
|
| 119 | 119 |
}
|
| 120 | 120 |
if (loadLl) {
|
| 121 |
- List<fr.ird.observe.dto.data.ll.common.TripReference> tripLl = fr.ird.observe.entities.data.ll.common.Trip.SPI.getDao(getTopiaPersistenceContext()).getChildren(referentialLocale, programById, personById, vesselById);
|
|
| 121 |
+ List<fr.ird.observe.dto.data.ll.common.TripReference> tripLl = fr.ird.observe.entities.data.ll.common.Trip.SPI.getDao(getTopiaPersistenceContext()).getChildren(referentialLocale, null, programById, personById, vesselById);
|
|
| 122 | 122 |
tripLl.forEach(t -> tripLlByProgram.put(t.getProgram().getId(), t));
|
| 123 | 123 |
}
|
| 124 | 124 |
}
|
| ... | ... | @@ -182,8 +182,7 @@ public abstract class TripServiceLocalSupport<D extends OpenableDto & fr.ird.obs |
| 182 | 182 |
|
| 183 | 183 |
ImmutableSet<VesselReference> vessels = Vessel.toReferenceSet(referentialLocale, getTopiaPersistenceContext(), null).toSet();
|
| 184 | 184 |
ImmutableMap<String, VesselReference> vesselById = Maps.uniqueIndex(vessels, VesselReference::getId);
|
| 185 |
- |
|
| 186 |
- List<R> references = spi.getDao(getTopiaPersistenceContext()).getChildren(referentialLocale, programById, personById, vesselById);
|
|
| 185 |
+ List<R> references = spi.getDao(getTopiaPersistenceContext()).getChildren(referentialLocale, parentId, programById, personById, vesselById);
|
|
| 187 | 186 |
return DataDtoReferenceSet.of(spi.toReferenceType(), references, now());
|
| 188 | 187 |
}
|
| 189 | 188 |
|