Commit 9b3cf57b authored by LAVENIER's avatar LAVENIER
Browse files

[fix] Configuration file: keep Spring load order

parent 31e0131b
......@@ -22,6 +22,7 @@ package net.sumaris.core.util.env;
* #L%
*/
import com.google.common.collect.Lists;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.env.ConfigurableEnvironment;
......@@ -43,14 +44,14 @@ public class ConfigurableEnvironments {
List<MapPropertySource> sources = env.getPropertySources().stream()
.filter(source -> source instanceof MapPropertySource)
.map(source -> (MapPropertySource)source).collect(Collectors.toList());
Properties target = defaultOptions;
target = new Properties(target);
for (MapPropertySource source: sources) {
final Properties target = new Properties(defaultOptions);
for (MapPropertySource source: Lists.reverse(sources)) {
// Cascade properties (keep original order)
for (String key: source.getPropertyNames()) {
Object value = source.getProperty(key);
if (value != null) {
//log.info(" {}={}", key, value.toString());
log.info(" {}={}", key, value);
target.setProperty(key, value.toString());
}
}
......
......@@ -108,7 +108,7 @@ public class VesselSnapshotDaoImpl extends HibernateDaoSupport implements Vessel
// Apply sorting
addSorting(query, cb, root, sortAttribute, sortDirection);
// No tripFilter: execute request
// No filter: execute request
if (filter == null) {
TypedQuery<VesselSnapshotResult> q = getEntityManager().createQuery(query)
.setFirstResult(offset)
......
......@@ -19,3 +19,6 @@ spring.datasource.hikari.connectionInitSql=BEGIN \
DBMS_SESSION.SET_NLS('NLS_SORT', 'FRENCH_AI'); \
DBMS_SESSION.SET_NLS('NLS_COMP', 'LINGUISTIC'); \
END;
# Mandatory for Oracle with sequences incrementing with 1
sumaris.persistence.sequence.increment=1
\ No newline at end of file
......@@ -161,11 +161,7 @@ public class DataGraphQLService {
@GraphQLArgument(name = "sortBy", defaultValue = VesselSnapshotVO.Fields.EXTERIOR_MARKING) String sort,
@GraphQLArgument(name = "sortDirection", defaultValue = "asc") String direction
) {
// Filter on SIH program, when not an admin
if (!authService.isAdmin()) {
filter = VesselFilterVO.nullToEmpty(filter);
filter.setProgramLabel(ProgramEnum.SIH.getLabel());
}
fillVesselFilter(filter); // Restrict vessels access
return vesselService.findSnapshotByFilter(
filter,
......@@ -182,11 +178,7 @@ public class DataGraphQLService {
@GraphQLArgument(name = "sortBy") String sort,
@GraphQLArgument(name = "sortDirection", defaultValue = "asc") String direction
) {
// Filter on SIH program, when not an admin
if (!authService.isAdmin()) {
filter = VesselFilterVO.nullToEmpty(filter);
filter.setProgramLabel(ProgramEnum.SIH.getLabel());
}
fillVesselFilter(filter); // Restrict vessels access
return vesselService.findVesselsByFilter(
filter,
......@@ -198,6 +190,8 @@ public class DataGraphQLService {
@Transactional(readOnly = true)
@IsUser
public long getVesselsCount(@GraphQLArgument(name = "filter") VesselFilterVO filter) {
fillVesselFilter(filter); // Restrict vessels access
return vesselService.countVesselsByFilter(filter);
}
......@@ -1449,6 +1443,19 @@ public class DataGraphQLService {
.build();
}
/**
* Restrict to vessel, depending of user access rights
* @param filter
*/
protected VesselFilterVO fillVesselFilter(VesselFilterVO filter) {
// Filter on SIH program, when not an admin
if (!authService.isAdmin()) {
filter = VesselFilterVO.nullToEmpty(filter);
filter.setProgramLabel(ProgramEnum.SIH.getLabel());
}
return filter;
}
/**
* Restrict to self data and/or department data
* @param filter
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment