use of com.evolveum.midpoint.schema.constants.ObjectTypes in project midpoint by Evolveum.
the class PageDebugList method setupSearchDto.
private void setupSearchDto(DebugSearchDto dto) {
ObjectTypes type = dto.getType();
Search search = SearchFactory.createSearch(type.getClassDefinition(), this);
dto.setSearch(search);
}
use of com.evolveum.midpoint.schema.constants.ObjectTypes in project midpoint by Evolveum.
the class AbstractSearchExpressionEvaluator method transformSingleValue.
@Override
protected List<V> transformSingleValue(ExpressionVariables variables, PlusMinusZero valueDestination, boolean useNew, ExpressionEvaluationContext context, String contextDescription, Task task, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException {
// if (LOGGER.isTraceEnabled()) {
// LOGGER.trace("transformSingleValue in {}\nvariables:\n{}\nvalueDestination: {}\nuseNew: {}",
// new Object[]{contextDescription, variables.debugDump(1), valueDestination, useNew});
// }
QName targetTypeQName = getExpressionEvaluatorType().getTargetType();
if (targetTypeQName == null) {
targetTypeQName = getDefaultTargetType();
}
if (targetTypeQName != null && QNameUtil.isUnqualified(targetTypeQName)) {
targetTypeQName = getPrismContext().getSchemaRegistry().resolveUnqualifiedTypeName(targetTypeQName);
}
ObjectTypes targetType = ObjectTypes.getObjectTypeFromTypeQName(targetTypeQName);
if (targetType == null) {
throw new SchemaException("Unknown target type " + targetTypeQName + " in " + shortDebugDump());
}
Class<? extends ObjectType> targetTypeClass = targetType.getClassDefinition();
List<V> resultValues = null;
ObjectQuery query = null;
List<ItemDelta<V, D>> additionalAttributeDeltas = null;
PopulateType populateAssignmentType = getExpressionEvaluatorType().getPopulate();
if (populateAssignmentType != null) {
additionalAttributeDeltas = collectAdditionalAttributes(populateAssignmentType, outputDefinition, variables, context, contextDescription, task, result);
}
if (getExpressionEvaluatorType().getOid() != null) {
resultValues = new ArrayList<>(1);
resultValues.add(createPrismValue(getExpressionEvaluatorType().getOid(), targetTypeQName, additionalAttributeDeltas, context));
} else {
SearchFilterType filterType = getExpressionEvaluatorType().getFilter();
if (filterType == null) {
throw new SchemaException("No filter in " + shortDebugDump());
}
query = QueryJaxbConvertor.createObjectQuery(targetTypeClass, filterType, prismContext);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("XML query converted to: {}", query.debugDump());
}
query = ExpressionUtil.evaluateQueryExpressions(query, variables, context.getExpressionFactory(), prismContext, context.getContextDescription(), task, result);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Expression in query evaluated to: {}", query.debugDump());
}
query = extendQuery(query, context);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Query after extension: {}", query.debugDump());
}
resultValues = executeSearchUsingCache(targetTypeClass, targetTypeQName, query, additionalAttributeDeltas, context, contextDescription, task, context.getResult());
if (resultValues.isEmpty()) {
ObjectReferenceType defaultTargetRef = getExpressionEvaluatorType().getDefaultTargetRef();
if (defaultTargetRef != null) {
resultValues.add(createPrismValue(defaultTargetRef.getOid(), targetTypeQName, additionalAttributeDeltas, context));
}
}
}
if (resultValues.isEmpty() && getExpressionEvaluatorType().isCreateOnDemand() == Boolean.TRUE && (valueDestination == PlusMinusZero.PLUS || valueDestination == PlusMinusZero.ZERO || useNew)) {
String createdObjectOid = createOnDemand(targetTypeClass, variables, context, context.getContextDescription(), task, context.getResult());
resultValues.add(createPrismValue(createdObjectOid, targetTypeQName, additionalAttributeDeltas, context));
}
LOGGER.trace("Search expression got {} results for query {}", resultValues == null ? "null" : resultValues.size(), query);
return (List<V>) resultValues;
}
use of com.evolveum.midpoint.schema.constants.ObjectTypes in project midpoint by Evolveum.
the class ClassDefinitionParser method parseObjectTypeClass.
public <T extends RObject> EntityDefinition parseObjectTypeClass(Class<T> type) {
ObjectTypes objectType = ClassMapper.getObjectTypeForHQLType(type);
QName jaxbName = objectType.getQName();
Class jaxbType = objectType.getClassDefinition();
EntityDefinition entityDefinition = new EntityDefinition(jaxbName, jaxbType, type.getSimpleName(), type);
updateEntityDefinition(entityDefinition);
return entityDefinition;
}
use of com.evolveum.midpoint.schema.constants.ObjectTypes in project midpoint by Evolveum.
the class ClassMapper method getHQLTypeClass.
public static Class<? extends RObject> getHQLTypeClass(Class<? extends ObjectType> clazz) {
Validate.notNull(clazz, "Class must not be null.");
ObjectTypes type = ObjectTypes.getObjectType(clazz);
Class<? extends RObject> hqlType = types.get(type).getClazz();
if (hqlType == null) {
throw new IllegalStateException("Couldn't find DB type for '" + clazz + "'.");
}
return hqlType;
}
use of com.evolveum.midpoint.schema.constants.ObjectTypes in project midpoint by Evolveum.
the class SearchPanel method debugPerformed.
private void debugPerformed() {
Search search = getModelObject();
PageRepositoryQuery pageQuery;
if (search != null) {
ObjectTypes type = search.getType() != null ? ObjectTypes.getObjectType(search.getType()) : null;
QName typeName = type != null ? type.getTypeQName() : null;
String inner = search.getAdvancedQuery();
if (StringUtils.isNotBlank(inner)) {
inner = "\n" + inner + "\n";
} else if (inner == null) {
inner = "";
}
pageQuery = new PageRepositoryQuery(typeName, "<query>" + inner + "</query>");
} else {
pageQuery = new PageRepositoryQuery();
}
SearchPanel.this.setResponsePage(pageQuery);
}
Aggregations