Skip to content

Commit

Permalink
Assignments Panel: Add type hints to sorting if possible
Browse files Browse the repository at this point in the history
  • Loading branch information
tonydamage committed Sep 28, 2022
1 parent 7fdf97f commit e5b4166
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.evolveum.midpoint.prism.PrismConstants;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.path.ObjectReferencePathSegment;
import com.evolveum.midpoint.prism.query.AndFilter;
import com.evolveum.midpoint.prism.query.FullTextFilter;
import com.evolveum.midpoint.prism.query.ObjectFilter;
Expand Down Expand Up @@ -194,7 +195,7 @@ protected void postProcessWrapper(PrismContainerValueWrapper<AssignmentType> val
return super.createObjectOrderings(sortParam);
}
String property = sortParam.getProperty();
final ItemPath path;
ItemPath path;
if (TARGET_NAME_STRING.equals(property)) {
path = TARGET_NAME_PATH;
} else if (property.contains("/")) {
Expand All @@ -203,6 +204,15 @@ protected void postProcessWrapper(PrismContainerValueWrapper<AssignmentType> val
} else {
path = ItemPath.create(new QName(SchemaConstantsGenerated.NS_COMMON, sortParam.getProperty()));
}

if (path.startsWith(TARGET_REF_OBJ) && determineTargetRefType() != null) {
// we have more concrete targetRef type and we are sorting using targetRef/@
var afterDereference = path.rest(2);
var typeHint = determineTargetRefType();
path = ItemPath.create(AssignmentType.F_TARGET_REF, new ObjectReferencePathSegment(typeHint));
path = path.append(afterDereference);
}

OrderDirection order = sortParam.isAscending() ? OrderDirection.ASCENDING : OrderDirection.DESCENDING;
return Collections.singletonList(
getPrismContext().queryFactory().createOrdering(path, order));
Expand Down

0 comments on commit e5b4166

Please sign in to comment.