Search in sources :

Example 6 with GetObjectType

use of com.evolveum.midpoint.xml.ns._public.model.model_3.GetObjectType in project midpoint by Evolveum.

the class AbstractPopupTabPanel method initObjectListPanel.

protected Component initObjectListPanel() {
    PopupObjectListPanel<O> listPanel = new PopupObjectListPanel<>(ID_OBJECT_LIST_PANEL, getObjectType().getClassDefinition(), true) {

        private static final long serialVersionUID = 1L;

        @Override
        protected List<IColumn<SelectableBean<O>, String>> createDefaultColumns() {
            if (AbstractRoleType.class.isAssignableFrom(getType())) {
                return new ArrayList<>((Collection) ColumnUtils.getDefaultAbstractRoleColumns(false));
            } else {
                return super.createDefaultColumns();
            }
        }

        @Override
        protected void onUpdateCheckbox(AjaxRequestTarget target, IModel<SelectableBean<O>> rowModel) {
            onSelectionPerformed(target, rowModel);
        }

        @Override
        protected List<O> getPreselectedObjectList() {
            return getPreselectedObjects();
        }

        @Override
        protected IModel<Boolean> getCheckBoxEnableModel(IModel<SelectableBean<O>> rowModel) {
            return getObjectSelectCheckBoxEnableModel(rowModel);
        }

        @Override
        protected ObjectQuery getCustomizeContentQuery() {
            ObjectQuery customQuery = AbstractPopupTabPanel.this.addFilterToContentQuery();
            if (customQuery == null) {
                customQuery = AbstractPopupTabPanel.this.getPageBase().getPrismContext().queryFactory().createQuery();
            }
            List<ObjectReferenceType> archetypeRefList = getArchetypeRefList();
            if (!CollectionUtils.isEmpty(archetypeRefList)) {
                List<ObjectFilter> archetypeRefFilterList = new ArrayList<>();
                for (ObjectReferenceType archetypeRef : archetypeRefList) {
                    ObjectFilter filter = AbstractPopupTabPanel.this.getPageBase().getPrismContext().queryFor(AssignmentHolderType.class).item(AssignmentHolderType.F_ARCHETYPE_REF).ref(archetypeRef.getOid()).buildFilter();
                    ((RefFilter) filter).setTargetTypeNullAsAny(true);
                    archetypeRefFilterList.add(filter);
                }
                if (!CollectionUtils.isEmpty(archetypeRefFilterList)) {
                    OrFilter archetypeRefOrFilter = AbstractPopupTabPanel.this.getPageBase().getPrismContext().queryFactory().createOr(archetypeRefFilterList);
                    customQuery.addFilter(archetypeRefOrFilter);
                }
            }
            ObjectFilter subTypeFilter = getSubtypeFilter();
            if (subTypeFilter != null) {
                customQuery.addFilter(subTypeFilter);
            }
            return customQuery;
        }
    };
    listPanel.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        public boolean isVisible() {
            return isObjectListPanelVisible();
        }
    });
    listPanel.setOutputMarkupId(true);
    return listPanel;
}
Also used : RefFilter(com.evolveum.midpoint.prism.query.RefFilter) IModel(org.apache.wicket.model.IModel) ArrayList(java.util.ArrayList) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) OrFilter(com.evolveum.midpoint.prism.query.OrFilter) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AssignmentHolderType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentHolderType)

Example 7 with GetObjectType

use of com.evolveum.midpoint.xml.ns._public.model.model_3.GetObjectType in project midpoint by Evolveum.

the class MultiTypesMemberPopupTabPanel method prepareDelta.

@Override
protected ObjectDelta prepareDelta() {
    Class classType = WebComponentUtil.qnameToClass(getPageBase().getPrismContext(), getObjectType().getTypeQName());
    ObjectReferenceType ref = ObjectTypeUtil.createObjectRef(getAbstractRoleTypeObject(), getRelationValue());
    return getPageBase().getPrismContext().deltaFactory().object().createModificationAddReference(classType, "fakeOid", ObjectType.F_PARENT_ORG_REF, ref.asReferenceValue());
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)

Example 8 with GetObjectType

use of com.evolveum.midpoint.xml.ns._public.model.model_3.GetObjectType in project midpoint by Evolveum.

the class ExpressionValidator method validate.

@Override
public void validate(IValidatable<T> validatable) {
    ExpressionType expressionType = expressionTypeModel.getObject();
    if (expressionType == null) {
        return;
    }
    PrismContext prismContext = serviceLocator.getPrismContext();
    Object valueToValidate = getValueToValidate(validatable);
    String contextDesc = " form component expression validation ";
    PrismPropertyDefinition<OperationResultType> outputDefinition = prismContext.definitionFactory().createPropertyDefinition(ExpressionConstants.OUTPUT_ELEMENT_NAME, OperationResultType.COMPLEX_TYPE);
    Task task = serviceLocator.createSimpleTask(OPERATION_EVALUATE_EXPRESSION);
    OperationResult result = new OperationResult(OPERATION_EVALUATE_EXPRESSION);
    ExpressionFactory expressionFactory = serviceLocator.getExpressionFactory();
    Expression<PrismPropertyValue<OperationResultType>, PrismPropertyDefinition<OperationResultType>> expression;
    try {
        expression = expressionFactory.makeExpression(expressionType, outputDefinition, MiscSchemaUtil.getExpressionProfile(), contextDesc, task, result);
    } catch (SchemaException | ObjectNotFoundException | SecurityViolationException e) {
        ValidationError error = new ValidationError();
        error.setMessage("Cannot make expression: " + e.getMessage());
        validatable.error(error);
        return;
    }
    VariablesMap variables = new VariablesMap();
    Class typeClass = (valueToValidate == null ? String.class : valueToValidate.getClass());
    variables.put(ExpressionConstants.VAR_INPUT, valueToValidate, typeClass);
    variables.putObject(ExpressionConstants.VAR_OBJECT, (ObjectType) getObjectType(), ObjectType.class);
    ExpressionEvaluationContext context = new ExpressionEvaluationContext(null, variables, contextDesc, task);
    PrismValueDeltaSetTriple<PrismPropertyValue<OperationResultType>> outputTriple;
    try {
        outputTriple = expression.evaluate(context, result);
    } catch (SchemaException | ExpressionEvaluationException | ObjectNotFoundException | CommunicationException | ConfigurationException | SecurityViolationException e) {
        ValidationError error = new ValidationError();
        error.setMessage("Cannot evaluate expression: " + e.getMessage());
        validatable.error(error);
        return;
    }
    if (outputTriple == null) {
        return;
    }
    Collection<PrismPropertyValue<OperationResultType>> outputValues = outputTriple.getNonNegativeValues();
    if (outputValues.isEmpty()) {
        return;
    }
    if (outputValues.size() > 1) {
        ValidationError error = new ValidationError();
        error.setMessage("Expression " + contextDesc + " produced more than one value");
        validatable.error(error);
    }
    OperationResultType operationResultType = outputValues.iterator().next().getRealValue();
    if (operationResultType == null) {
        return;
    }
    OperationResult returnResult = OperationResult.createOperationResult(operationResultType);
    if (!returnResult.isSuccess()) {
        ValidationError error = new ValidationError();
        if (returnResult.getUserFriendlyMessage() != null) {
            error.setMessage(WebModelServiceUtils.translateMessage(returnResult, serviceLocator));
        } else {
            error.setMessage(returnResult.getMessage());
        }
        validatable.error(error);
    }
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) PrismContext(com.evolveum.midpoint.prism.PrismContext) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) VariablesMap(com.evolveum.midpoint.schema.expression.VariablesMap) ValidationError(org.apache.wicket.validation.ValidationError) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ExpressionFactory(com.evolveum.midpoint.repo.common.expression.ExpressionFactory) ExpressionEvaluationContext(com.evolveum.midpoint.repo.common.expression.ExpressionEvaluationContext) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) ExpressionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType)

Example 9 with GetObjectType

use of com.evolveum.midpoint.xml.ns._public.model.model_3.GetObjectType in project midpoint by Evolveum.

the class PageAuditLogDetails method connectDeltas.

private List<ObjectDeltaOperationType> connectDeltas(List<ObjectDeltaOperationType> deltas) {
    Map<PolyStringType, ObjectDeltaOperationType> focusDeltas = new HashMap<>();
    List<ObjectDeltaOperationType> otherDeltas = new ArrayList<>();
    for (ObjectDeltaOperationType delta : deltas) {
        if (delta != null && delta.getObjectDelta() != null && FocusType.class.isAssignableFrom(WebComponentUtil.qnameToClass(getPrismContext(), delta.getObjectDelta().getObjectType()))) {
            if (focusDeltas.containsKey(delta.getObjectName())) {
                focusDeltas.get(delta.getObjectName()).setResourceName(null);
                focusDeltas.get(delta.getObjectName()).setResourceOid(null);
                if (delta.getObjectDelta() != null) {
                    if (focusDeltas.get(delta.getObjectName()).getObjectDelta() == null) {
                        focusDeltas.get(delta.getObjectName()).setObjectDelta(delta.getObjectDelta());
                    } else {
                        focusDeltas.get(delta.getObjectName()).getObjectDelta().getItemDelta().addAll(delta.getObjectDelta().getItemDelta());
                    }
                    for (ItemDeltaType itemDelta : delta.getObjectDelta().getItemDelta()) {
                        if (itemDelta == null) {
                            // TODO why?
                            continue;
                        }
                    }
                }
            } else {
                focusDeltas.put(delta.getObjectName(), delta);
            }
        } else {
            otherDeltas.add(delta);
        }
    }
    List<ObjectDeltaOperationType> retDeltas = new ArrayList<>();
    retDeltas.addAll(focusDeltas.values());
    retDeltas.addAll(otherDeltas);
    return retDeltas;
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) ObjectDeltaOperationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType) FocusType(com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType) ItemDeltaType(com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)

Example 10 with GetObjectType

use of com.evolveum.midpoint.xml.ns._public.model.model_3.GetObjectType in project midpoint by Evolveum.

the class ActionsExecutedInformation method mapToJaxb.

private void mapToJaxb(Map<ActionsExecutedObjectsKey, ObjectActionsExecutedEntryType> map, List<ObjectActionsExecutedEntryType> list) {
    for (Map.Entry<ActionsExecutedObjectsKey, ObjectActionsExecutedEntryType> entry : map.entrySet()) {
        ObjectActionsExecutedEntryType e = entry.getValue().clone();
        e.setObjectType(entry.getKey().getObjectType());
        e.setOperation(ChangeType.toChangeTypeType(entry.getKey().getOperation()));
        e.setChannel(entry.getKey().getChannel());
        list.add(e);
    }
}
Also used : HashMap(java.util.HashMap) Map(java.util.Map) ObjectActionsExecutedEntryType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectActionsExecutedEntryType)

Aggregations

HashMap (java.util.HashMap)5 ResourceObjectTypeDefinitionType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectTypeDefinitionType)3 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)2 ObjectActionsExecutedEntryType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectActionsExecutedEntryType)2 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)2 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)2 SingleCacheStateInformationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SingleCacheStateInformationType)2 Map (java.util.Map)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)2 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)1 PrismContext (com.evolveum.midpoint.prism.PrismContext)1 PrismPropertyDefinition (com.evolveum.midpoint.prism.PrismPropertyDefinition)1 PrismPropertyValue (com.evolveum.midpoint.prism.PrismPropertyValue)1 ObjectFilter (com.evolveum.midpoint.prism.query.ObjectFilter)1 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)1 OrFilter (com.evolveum.midpoint.prism.query.OrFilter)1 RefFilter (com.evolveum.midpoint.prism.query.RefFilter)1 ExpressionEvaluationContext (com.evolveum.midpoint.repo.common.expression.ExpressionEvaluationContext)1 ExpressionFactory (com.evolveum.midpoint.repo.common.expression.ExpressionFactory)1