Search in sources :

Example 36 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.getTypeClass() != null ? ObjectTypes.getObjectType(search.getTypeClass().getSimpleName()) : 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)

Example 37 with ObjectTypes

use of com.evolveum.midpoint.schema.constants.ObjectTypes in project midpoint by Evolveum.

the class AssignmentPanel method newAssignmentClickPerformed.

protected void newAssignmentClickPerformed(AjaxRequestTarget target) {
    AssignmentPopup popupPanel = new AssignmentPopup(getPageBase().getMainPopupBodyId(), createAssignmentPopupModel()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void addPerformed(AjaxRequestTarget target, List<AssignmentType> newAssignmentsList) {
            super.addPerformed(target, newAssignmentsList);
            addSelectedAssignmentsPerformed(target, newAssignmentsList);
        }

        @Override
        protected List<ObjectTypes> getObjectTypesList() {
            return AssignmentPanel.this.getObjectTypesList();
        }

        @Override
        protected ObjectFilter getSubtypeFilter() {
            return AssignmentPanel.this.getSubtypeFilter();
        }

        @Override
        protected boolean isEntitlementAssignment() {
            return AssignmentPanel.this.isEntitlementAssignment();
        }

        @Override
        protected PrismContainerWrapper<AssignmentType> getAssignmentWrapperModel() {
            return AssignmentPanel.this.getModelObject();
        }

        @Override
        protected <F extends AssignmentHolderType> PrismObject<F> getFocusObject() {
            return getMultivalueContainerListPanel().getFocusObject();
        }
    };
    popupPanel.setOutputMarkupId(true);
    popupPanel.setOutputMarkupPlaceholderTag(true);
    getPageBase().showMainPopup(popupPanel, target);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AssignmentPopup(com.evolveum.midpoint.gui.api.component.AssignmentPopup) List(java.util.List) ArrayList(java.util.ArrayList) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes)

Example 38 with ObjectTypes

use of com.evolveum.midpoint.schema.constants.ObjectTypes in project midpoint by Evolveum.

the class AbstractSearchExpressionEvaluator method transformSingleValue.

@NotNull
@Override
protected List<V> transformSingleValue(VariablesMap variables, PlusMinusZero valueDestination, boolean useNew, ExpressionEvaluationContext context, String contextDescription, Task task, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException {
    QName targetTypeQName = expressionEvaluatorBean.getTargetType();
    if (targetTypeQName == null) {
        targetTypeQName = getDefaultTargetType();
    }
    if (targetTypeQName != null && QNameUtil.isUnqualified(targetTypeQName)) {
        targetTypeQName = prismContext.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;
    ObjectQuery query = null;
    List<ItemDelta<V, D>> additionalAttributeDeltas = null;
    PopulateType populateAssignmentType = expressionEvaluatorBean.getPopulate();
    if (populateAssignmentType != null) {
        if (outputDefinition instanceof PrismContainerDefinition) {
            additionalAttributeDeltas = PopulatorUtil.computePopulateItemDeltas(populateAssignmentType, (PrismContainerDefinition<?>) outputDefinition, variables, context, contextDescription, task, result);
        } else {
            LOGGER.warn("Search expression {} applied to non-container target, ignoring populate definition", contextDescription);
        }
    }
    if (expressionEvaluatorBean.getOid() != null) {
        resultValues = new ArrayList<>(1);
        resultValues.add(createPrismValue(expressionEvaluatorBean.getOid(), targetTypeQName, additionalAttributeDeltas, context));
    } else {
        SearchFilterType filterType = expressionEvaluatorBean.getFilter();
        if (filterType == null) {
            throw new SchemaException("No filter in " + shortDebugDump());
        }
        query = prismContext.getQueryConverter().createObjectQuery(targetTypeClass, filterType);
        LOGGER.trace("XML query converted to: {}", query.debugDumpLazily());
        query = ExpressionUtil.evaluateQueryExpressions(query, variables, context.getExpressionProfile(), context.getExpressionFactory(), prismContext, context.getContextDescription(), task, result);
        LOGGER.trace("Expression in query evaluated to: {}", query.debugDumpLazily());
        query = extendQuery(query, context);
        LOGGER.trace("Query after extension: {}", query.debugDumpLazily());
        resultValues = executeSearchUsingCache(targetTypeClass, targetTypeQName, query, additionalAttributeDeltas, context, contextDescription, task, result);
        if (resultValues.isEmpty()) {
            ObjectReferenceType defaultTargetRef = expressionEvaluatorBean.getDefaultTargetRef();
            if (defaultTargetRef != null) {
                resultValues.add(createPrismValue(defaultTargetRef.getOid(), targetTypeQName, additionalAttributeDeltas, context));
            }
        }
    }
    if (resultValues.isEmpty() && expressionEvaluatorBean.isCreateOnDemand() == Boolean.TRUE && (valueDestination == PlusMinusZero.PLUS || valueDestination == PlusMinusZero.ZERO || useNew)) {
        String createdObjectOid = createOnDemand(targetTypeClass, variables, context, context.getContextDescription(), task, result);
        resultValues.add(createPrismValue(createdObjectOid, targetTypeQName, additionalAttributeDeltas, context));
    }
    LOGGER.trace("Search expression {} (valueDestination={}) got {} results for query {}", contextDescription, valueDestination, resultValues.size(), query);
    return resultValues;
}
Also used : 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) NotNull(org.jetbrains.annotations.NotNull)

Example 39 with ObjectTypes

use of com.evolveum.midpoint.schema.constants.ObjectTypes in project midpoint by Evolveum.

the class AbstractModelIntegrationTest method determineSynchronization.

/**
 * Returns appropriate object synchronization settings for the class.
 * Assumes single sync setting for now.
 */
protected ObjectSynchronizationType determineSynchronization(ResourceType resource, Class<UserType> type, String name) {
    SynchronizationType synchronization = resource.getSynchronization();
    if (synchronization == null) {
        return null;
    }
    List<ObjectSynchronizationType> objectSynchronizations = synchronization.getObjectSynchronization();
    if (objectSynchronizations.isEmpty()) {
        return null;
    }
    for (ObjectSynchronizationType objSyncType : objectSynchronizations) {
        QName focusTypeQName = objSyncType.getFocusType();
        if (focusTypeQName == null) {
            if (type != UserType.class) {
                continue;
            }
        } else {
            ObjectTypes focusType = ObjectTypes.getObjectTypeFromTypeQName(focusTypeQName);
            if (type != (Class<?>) focusType.getClassDefinition()) {
                continue;
            }
        }
        if (name == null) {
            // we got it
            return objSyncType;
        } else {
            if (name.equals(objSyncType.getName())) {
                return objSyncType;
            }
        }
    }
    throw new IllegalArgumentException("Synchronization setting for " + type + " and name " + name + " not found in " + resource);
}
Also used : QName(javax.xml.namespace.QName) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes)

Example 40 with ObjectTypes

use of com.evolveum.midpoint.schema.constants.ObjectTypes in project midpoint by Evolveum.

the class NinjaUtils method getTypes.

public static List<ObjectTypes> getTypes(Set<ObjectTypes> selected) {
    List<ObjectTypes> types = new ArrayList<>();
    if (selected != null && !selected.isEmpty()) {
        types.addAll(selected);
    } else {
        for (ObjectTypes type : ObjectTypes.values()) {
            Class<? extends ObjectType> clazz = type.getClassDefinition();
            if (Modifier.isAbstract(clazz.getModifiers())) {
                continue;
            }
            types.add(type);
        }
    }
    Collections.sort(types);
    return types;
}
Also used : ArrayList(java.util.ArrayList) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes)

Aggregations

ObjectTypes (com.evolveum.midpoint.schema.constants.ObjectTypes)46 QName (javax.xml.namespace.QName)16 ArrayList (java.util.ArrayList)11 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)11 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)8 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)8 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)7 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)7 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)6 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)6 List (java.util.List)6 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)5 ITab (org.apache.wicket.extensions.markup.html.tabs.ITab)5 AssignmentPopup (com.evolveum.midpoint.gui.api.component.AssignmentPopup)4 OnChangeAjaxBehavior (org.apache.wicket.ajax.form.OnChangeAjaxBehavior)4 DropDownChoice (org.apache.wicket.markup.html.form.DropDownChoice)4 CountablePanelTab (com.evolveum.midpoint.gui.api.component.tabs.CountablePanelTab)3 PanelTab (com.evolveum.midpoint.gui.api.component.tabs.PanelTab)3 PrismContainerWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper)3 AssignmentObjectRelation (com.evolveum.midpoint.model.api.AssignmentObjectRelation)3