use of com.evolveum.midpoint.repo.sql.query2.QueryDefinitionRegistry2 in project midpoint by Evolveum.
the class ItemPathResolver method findRestrictedEntityDefinition.
/**
* Given existing entity definition and a request for narrowing it, tries to find refined definition.
*/
public JpaEntityDefinition findRestrictedEntityDefinition(JpaEntityDefinition baseEntityDefinition, QName specificTypeName) throws QueryException {
QueryDefinitionRegistry2 registry = QueryDefinitionRegistry2.getInstance();
JpaEntityDefinition specificEntityDefinition = registry.findEntityDefinition(specificTypeName);
if (!baseEntityDefinition.isAssignableFrom(specificEntityDefinition)) {
throw new QueryException("Entity " + baseEntityDefinition + " cannot be restricted to " + specificEntityDefinition);
}
return specificEntityDefinition;
}
use of com.evolveum.midpoint.repo.sql.query2.QueryDefinitionRegistry2 in project midpoint by Evolveum.
the class ItemPathResolver method findProperDataDefinition.
/**
* Finds the proper definition for (possibly abstract) entity.
* Returns the most abstract entity that can be used.
* Checks for conflicts, such as user.locality vs org.locality.
*
* @param path Path to be found (non-empty!)
* @param itemDefinition Definition of target property, required/used only for "any" properties
* @param clazz Kind of definition to be looked for
* @param prismContext
* @return Entity type definition + item definition, or null if nothing was found
*/
public <T extends JpaDataNodeDefinition> ProperDataSearchResult<T> findProperDataDefinition(JpaEntityDefinition baseEntityDefinition, ItemPath path, ItemDefinition itemDefinition, Class<T> clazz, PrismContext prismContext) throws QueryException {
QueryDefinitionRegistry2 registry = QueryDefinitionRegistry2.getInstance();
ProperDataSearchResult<T> candidateResult = null;
for (JpaEntityDefinition entityDefinition : findPossibleBaseEntities(baseEntityDefinition, registry)) {
DataSearchResult<T> result = entityDefinition.findDataNodeDefinition(path, itemDefinition, clazz, prismContext);
if (result != null) {
if (candidateResult == null) {
candidateResult = new ProperDataSearchResult<>(entityDefinition, result);
} else {
// there is no possibility of false alarm.
if (!candidateResult.getEntityDefinition().isAssignableFrom(entityDefinition)) {
throw new QueryException("Unable to determine root entity for " + path + ": found incompatible candidates: " + candidateResult.getEntityDefinition() + " and " + entityDefinition);
}
}
}
}
LOGGER.trace("findProperDataDefinition: base='{}', path='{}', def='{}', class={} -- returning '{}'", baseEntityDefinition, path, itemDefinition, clazz.getSimpleName(), candidateResult);
return candidateResult;
}
Aggregations