Search in sources :

Example 6 with ObjectTypes

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);
}
Also used : Search(com.evolveum.midpoint.web.component.search.Search) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes)

Example 7 with ObjectTypes

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;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) SearchFilterType(com.evolveum.prism.xml.ns._public.query_3.SearchFilterType) QName(javax.xml.namespace.QName) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) List(java.util.List) ArrayList(java.util.ArrayList) PopulateType(com.evolveum.midpoint.xml.ns._public.common.common_3.PopulateType)

Example 8 with ObjectTypes

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;
}
Also used : QName(javax.xml.namespace.QName) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes)

Example 9 with ObjectTypes

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;
}
Also used : ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes)

Example 10 with ObjectTypes

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);
}
Also used : PageRepositoryQuery(com.evolveum.midpoint.web.page.admin.configuration.PageRepositoryQuery) QName(javax.xml.namespace.QName) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes)

Aggregations

ObjectTypes (com.evolveum.midpoint.schema.constants.ObjectTypes)17 QName (javax.xml.namespace.QName)7 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)3 DropDownChoice (org.apache.wicket.markup.html.form.DropDownChoice)3 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)2 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)2 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)2 ObjectTypeGuiDescriptor (com.evolveum.midpoint.web.util.ObjectTypeGuiDescriptor)2 ChangeHook (com.evolveum.midpoint.model.api.hooks.ChangeHook)1 HookOperationMode (com.evolveum.midpoint.model.api.hooks.HookOperationMode)1 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)1 S_FilterEntryOrEmpty (com.evolveum.midpoint.prism.query.builder.S_FilterEntryOrEmpty)1 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)1 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)1 RepositoryObjectDataProvider (com.evolveum.midpoint.web.component.data.RepositoryObjectDataProvider)1 Table (com.evolveum.midpoint.web.component.data.Table)1 Search (com.evolveum.midpoint.web.component.search.Search)1 PageRepositoryQuery (com.evolveum.midpoint.web.page.admin.configuration.PageRepositoryQuery)1 DebugSearchDto (com.evolveum.midpoint.web.page.admin.configuration.dto.DebugSearchDto)1 ConfigurationStorage (com.evolveum.midpoint.web.session.ConfigurationStorage)1