Skip to content

Commit

Permalink
another fix for MID-5512
Browse files Browse the repository at this point in the history
  • Loading branch information
katkav committed Jul 23, 2019
1 parent fc11a5c commit 5211bbc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
Expand Up @@ -1175,7 +1175,6 @@ protected List<ObjectTypes> load() {
List<ObjectTypes> choices = new ArrayList<>();

Collections.addAll(choices, ObjectTypes.values());
choices.remove(ObjectTypes.ASSIGNMENT_HOLDER_TYPE);
choices.remove(ObjectTypes.OBJECT);

return choices;
Expand Down
Expand Up @@ -315,6 +315,7 @@ public <T extends ObjectType> int countObjectsAttempt(Class<T> type, ObjectQuery

session = baseHelper.beginReadOnlyTransaction();
Number longCount;
query = refineAssignmentHolderQuery(type, query);
if (query == null || query.getFilter() == null) {
// this is 5x faster than count with 3 inner joins, it can probably improved also for queries which
// filters uses only properties from concrete entities like RUser, RRole by improving interpreter [lazyman]
Expand All @@ -341,6 +342,23 @@ public <T extends ObjectType> int countObjectsAttempt(Class<T> type, ObjectQuery
return count;
}


//TODO copied from QueryInterpreter, remove if full support for searching AssignmentHolderType is implemented MID-5579
/**
* Both ObjectType and AssignmentHolderType are mapped to RObject. So when searching for AssignmentHolderType it is not sufficient to
* query this table. This method hacks this situation a bit by introducing explicit type filter for AssignmentHolderType.
*/
private ObjectQuery refineAssignmentHolderQuery(Class<? extends Containerable> type, ObjectQuery query) {
if (!type.equals(AssignmentHolderType.class)) {
return query;
}
if (query == null) {
query = prismContext.queryFactory().createQuery();
}
query.setFilter(prismContext.queryFactory().createType(AssignmentHolderType.COMPLEX_TYPE, query.getFilter()));
return query;
}

public <C extends Containerable> int countContainersAttempt(Class<C> type, ObjectQuery query,
Collection<SelectorOptions<GetOperationOptions>> options, OperationResult result) {
boolean cases = AccessCertificationCaseType.class.equals(type);
Expand Down
Expand Up @@ -74,7 +74,7 @@ public RQuery interpret(ObjectQuery query, Class<? extends Containerable> type,
return new RQueryImpl(hqlQuery, hibernateQuery);
}

/**
/** MID-5579
* Both ObjectType and AssignmentHolderType are mapped to RObject. So when searching for AssignmentHolderType it is not sufficient to
* query this table. This method hacks this situation a bit by introducing explicit type filter for AssignmentHolderType.
*/
Expand Down

0 comments on commit 5211bbc

Please sign in to comment.