Commit 6241ce32 authored by LAVENIER's avatar LAVENIER
Browse files

[enh] Referential DAO: add attribute includedIds to filter VO

parent 05a8b45a
......@@ -505,6 +505,7 @@ public class ReferentialDaoImpl
String searchText = StringUtils.trimToNull(filter.getSearchText());
String searchAttribute = StringUtils.trimToNull(filter.getSearchAttribute());
Integer[] statusIds = filter.getStatusIds();
Integer[] includedIds = filter.getIncludedIds();
Integer[] excludedIds = filter.getExcludedIds();
// Level Ids
......@@ -621,6 +622,16 @@ public class ReferentialDaoImpl
statusIdsClause = builder.in(entityRoot.get(IWithStatusEntity.Fields.STATUS).get(IEntity.Fields.ID)).value(statusIdsParam);
}
// Excluded Ids
Predicate includedClause = null;
ParameterExpression<Collection> includedIdsParam = null;
if (ArrayUtils.isNotEmpty(includedIds)) {
includedIdsParam = builder.parameter(Collection.class);
includedClause = builder.not(
builder.in(entityRoot.get(IEntity.Fields.ID)).value(includedIdsParam)
);
}
// Excluded Ids
Predicate excludedClause = null;
ParameterExpression<Collection> excludedIdsParam = null;
......@@ -651,6 +662,9 @@ public class ReferentialDaoImpl
if (statusIdsClause != null) {
whereClause = (whereClause == null) ? statusIdsClause : builder.and(whereClause, statusIdsClause);
}
if (excludedIdsParam != null) {
whereClause = (whereClause == null) ? includedClause : builder.and(whereClause, includedClause);
}
if (excludedIdsParam != null) {
whereClause = (whereClause == null) ? excludedClause : builder.and(whereClause, excludedClause);
}
......@@ -698,6 +712,9 @@ public class ReferentialDaoImpl
if (statusIdsClause != null) {
typedQuery.setParameter(statusIdsParam, ImmutableList.copyOf(statusIds));
}
if (includedClause != null) {
typedQuery.setParameter(includedIdsParam, ImmutableList.copyOf(includedIds));
}
if (excludedClause != null) {
typedQuery.setParameter(excludedIdsParam, ImmutableList.copyOf(excludedIds));
}
......
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