use of com.evolveum.midpoint.repo.sqale.ExtensionProcessor.ExtItemInfo in project midpoint by Evolveum.
the class ExtensionItemSqlMapper method primaryPath.
@Override
@Nullable
public Expression<?> primaryPath(Q entityPath, ItemDefinition<?> definition) throws QueryException {
Objects.requireNonNull(definition, "Null definition provided for extension/attributes item.");
JsonbPath path = rootToExtensionPath.apply(entityPath);
ExtItemInfo info = new ExtensionProcessor(repositoryContext).findExtensionItem(definition, holderType);
if (info == null) {
throw new QueryException("Extension property " + definition + " is not indexed and cannot be used for ordering.");
}
MExtItem extItem = info.item;
if (extItem.valueType.equals(STRING_TYPE) || ExtUtils.isEnumDefinition((PrismPropertyDefinition<?>) definition) || extItem.valueType.equals(DATETIME_TYPE)) {
return stringTemplate("{0}->>'{1s}'", path, info.getId());
} else if (extItem.valueType.equals(POLY_STRING_TYPE)) {
return stringTemplate("{0}->'{1s}'->>'" + JsonbUtils.JSONB_POLY_ORIG_KEY + "'", path, info.getId());
} else {
return stringTemplate("{0}->'{1s}'", path, info.getId());
}
}
Aggregations