use of com.evolveum.midpoint.repo.sql.query2.definition.JpaAnyItemLinkDefinition in project midpoint by Evolveum.
the class JpaAnyContainerDefinition method nextLinkDefinition.
@Override
public DataSearchResult nextLinkDefinition(ItemPath path, ItemDefinition itemDefinition, PrismContext prismContext) throws QueryException {
if (ItemPath.asSingleName(path) == null) {
throw new QueryException("Couldn't resolve paths other than those in the form of single name in extension/attributes container: " + path);
}
if (itemDefinition == null) {
throw new QueryException("Couldn't resolve dynamically defined item path '" + path + "' without proper definition");
}
CollectionSpecification collSpec = itemDefinition.isSingleValue() ? null : new CollectionSpecification();
// longs, strings, ...
String jpaName;
JpaDataNodeDefinition jpaNodeDefinition;
if (itemDefinition instanceof PrismPropertyDefinition) {
try {
jpaName = RAnyConverter.getAnySetType(itemDefinition, prismContext);
} catch (SchemaException e) {
throw new QueryException(e.getMessage(), e);
}
// TODO
jpaNodeDefinition = new JpaAnyPropertyDefinition(Object.class, null);
} else if (itemDefinition instanceof PrismReferenceDefinition) {
jpaName = "references";
jpaNodeDefinition = new JpaAnyReferenceDefinition(Object.class, RObject.class);
} else {
throw new QueryException("Unsupported 'any' item: " + itemDefinition);
}
JpaLinkDefinition<?> linkDefinition = new JpaAnyItemLinkDefinition(itemDefinition.getName(), jpaName, collSpec, getOwnerType(), jpaNodeDefinition);
return new DataSearchResult<>(linkDefinition, ItemPath.EMPTY_PATH);
}
use of com.evolveum.midpoint.repo.sql.query2.definition.JpaAnyItemLinkDefinition in project midpoint by Evolveum.
the class ItemPathResolver method createJoinCondition.
private Condition createJoinCondition(String joinedItemAlias, JpaLinkDefinition joinedItemDefinition, RootHibernateQuery hibernateQuery) throws QueryException {
Condition condition = null;
if (joinedItemDefinition instanceof JpaAnyItemLinkDefinition) {
JpaAnyItemLinkDefinition anyLinkDef = (JpaAnyItemLinkDefinition) joinedItemDefinition;
AndCondition conjunction = hibernateQuery.createAnd();
if (anyLinkDef.getOwnerType() != null) {
// null for assignment extensions
conjunction.add(hibernateQuery.createEq(joinedItemAlias + ".ownerType", anyLinkDef.getOwnerType()));
}
conjunction.add(hibernateQuery.createEq(joinedItemAlias + "." + RAnyValue.F_NAME, RUtil.qnameToString(anyLinkDef.getItemName())));
condition = conjunction;
} else if (joinedItemDefinition.getCollectionSpecification() instanceof VirtualCollectionSpecification) {
VirtualCollectionSpecification vcd = (VirtualCollectionSpecification) joinedItemDefinition.getCollectionSpecification();
List<Condition> conditions = new ArrayList<>(vcd.getAdditionalParams().length);
for (VirtualQueryParam vqp : vcd.getAdditionalParams()) {
// e.g. name = "assignmentOwner", type = RAssignmentOwner.class, value = "ABSTRACT_ROLE"
Object value = createQueryParamValue(vqp);
Condition c = hibernateQuery.createEq(joinedItemAlias + "." + vqp.name(), value);
conditions.add(c);
}
if (conditions.size() > 1) {
condition = hibernateQuery.createAnd(conditions);
} else if (conditions.size() == 1) {
condition = conditions.iterator().next();
}
}
return condition;
}
Aggregations