Search in sources :

Example 16 with ShadowKindType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType in project midpoint by Evolveum.

the class AssociationFromLinkExpressionEvaluator method evaluate.

@Override
public PrismValueDeltaSetTriple<PrismContainerValue<ShadowAssociationType>> evaluate(ExpressionEvaluationContext context, OperationResult result) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException {
    checkEvaluatorProfile(context);
    String desc = context.getContextDescription();
    AbstractRoleType thisRole = getRelevantRole(context);
    LOGGER.trace("Evaluating association from link {} on: {}", expressionEvaluatorBean.getDescription(), thisRole);
    // noinspection unchecked
    TypedValue<ResourceObjectDefinition> rAssocTargetDefTypedValue = context.getVariables().get(ExpressionConstants.VAR_ASSOCIATION_TARGET_OBJECT_CLASS_DEFINITION);
    if (rAssocTargetDefTypedValue == null || rAssocTargetDefTypedValue.getValue() == null) {
        throw new ExpressionEvaluationException("No association target object class definition variable in " + desc + "; the expression may be used in a wrong place. It is only supposed to create an association.");
    }
    ResourceObjectDefinition associationTargetDef = (ResourceObjectDefinition) rAssocTargetDefTypedValue.getValue();
    ShadowDiscriminatorType projectionDiscriminator = expressionEvaluatorBean.getProjectionDiscriminator();
    if (projectionDiscriminator == null) {
        throw new ExpressionEvaluationException("No projectionDiscriminator in " + desc);
    }
    ShadowKindType kind = projectionDiscriminator.getKind();
    if (kind == null) {
        throw new ExpressionEvaluationException("No kind in projectionDiscriminator in " + desc);
    }
    String intent = projectionDiscriminator.getIntent();
    PrismContainer<ShadowAssociationType> output = outputDefinition.instantiate();
    QName assocName = context.getMappingQName();
    String resourceOid = associationTargetDef.getResourceOid();
    List<String> candidateShadowOidList = new ArrayList<>();
    // Always process the first role (myself) regardless of recursion setting
    gatherCandidateShadowsFromAbstractRole(thisRole, candidateShadowOidList);
    if (thisRole instanceof OrgType && matchesForRecursion((OrgType) thisRole)) {
        gatherCandidateShadowsFromAbstractRoleRecurse((OrgType) thisRole, candidateShadowOidList, null, desc, context, result);
    }
    LOGGER.trace("Candidate shadow OIDs: {}", candidateShadowOidList);
    selectMatchingShadows(candidateShadowOidList, output, resourceOid, kind, intent, assocName, context, result);
    return ItemDeltaUtil.toDeltaSetTriple(output, null, prismContext);
}
Also used : QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) ResourceObjectDefinition(com.evolveum.midpoint.schema.processor.ResourceObjectDefinition) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) AbstractRoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType) ShadowKindType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType) ShadowAssociationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAssociationType) ShadowDiscriminatorType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowDiscriminatorType)

Example 17 with ShadowKindType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType in project midpoint by Evolveum.

the class AssociationSearchExpressionEvaluatorCache method invalidate.

// shadow may be null
public void invalidate(PrismObject<ResourceType> resource, PrismObject<? extends ShadowType> shadow) {
    LOGGER.trace("Invalidating cache for resource = {}, shadow kind = {}", resource, shadow != null ? shadow.asObjectable().getKind() : "(no shadow)");
    if (resource == null || resource.getOid() == null) {
        // shouldn't occur
        LOGGER.warn("No resource - invalidating all the cache");
        queries.clear();
        return;
    }
    String resourceOid = resource.getOid();
    ShadowKindType kind = null;
    if (shadow != null) {
        kind = shadow.asObjectable().getKind();
    }
    Set<Map.Entry<AssociationSearchQueryKey, AssociationSearchQueryResult>> entries = queries.entrySet();
    Iterator<Map.Entry<AssociationSearchQueryKey, AssociationSearchQueryResult>> iterator = entries.iterator();
    while (iterator.hasNext()) {
        Map.Entry<AssociationSearchQueryKey, AssociationSearchQueryResult> entry = iterator.next();
        if (matches(entry, resourceOid, kind)) {
            LOGGER.trace("Invalidating query key {}", entry.getKey());
            iterator.remove();
        }
    }
}
Also used : ShadowKindType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Map(java.util.Map)

Example 18 with ShadowKindType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType in project midpoint by Evolveum.

the class ResourceShadowDiscriminator method fromResourceShadowDiscriminatorType.

public static ResourceShadowDiscriminator fromResourceShadowDiscriminatorType(ShadowDiscriminatorType bean, boolean provideDefaultIntent) {
    if (bean == null) {
        return null;
    }
    // For compatibility. Otherwise the kind should be explicitly serialized.
    ShadowKindType kind = ObjectUtils.defaultIfNull(bean.getKind(), ShadowKindType.ACCOUNT);
    String intent = bean.getIntent() != null || !provideDefaultIntent ? bean.getIntent() : SchemaConstants.INTENT_DEFAULT;
    ResourceShadowDiscriminator rsd = new ResourceShadowDiscriminator(bean.getResourceRef() != null ? bean.getResourceRef().getOid() : null, kind, intent, bean.getTag(), BooleanUtils.isTrue(bean.isTombstone()));
    rsd.setObjectClass(bean.getObjectClassName());
    if (bean.getDiscriminatorOrder() != null) {
        rsd.setOrder(bean.getDiscriminatorOrder());
    }
    return rsd;
}
Also used : ShadowKindType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType)

Example 19 with ShadowKindType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType in project midpoint by Evolveum.

the class PageTaskAdd method initLayout.

private void initLayout() {
    Form mainForm = new Form(ID_FORM_MAIN);
    add(mainForm);
    final DropDownChoice resource = new DropDownChoice<>(ID_RESOURCE, new PropertyModel<TaskAddResourcesDto>(model, TaskAddDto.F_RESOURCE), new AbstractReadOnlyModel<List<TaskAddResourcesDto>>() {

        @Override
        public List<TaskAddResourcesDto> getObject() {
            return createResourceList();
        }
    }, new ChoiceableChoiceRenderer<TaskAddResourcesDto>());
    resource.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            TaskAddDto dto = model.getObject();
            boolean sync = TaskCategory.LIVE_SYNCHRONIZATION.equals(dto.getCategory());
            boolean recon = TaskCategory.RECONCILIATION.equals(dto.getCategory());
            boolean importAccounts = TaskCategory.IMPORTING_ACCOUNTS.equals(dto.getCategory());
            return sync || recon || importAccounts;
        }
    });
    resource.add(new AjaxFormComponentUpdatingBehavior("change") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            PageTaskAdd.this.loadResource();
            target.add(get(ID_FORM_MAIN + ":" + ID_OBJECT_CLASS));
        }
    });
    resource.setOutputMarkupId(true);
    mainForm.add(resource);
    final DropDownChoice focusType = new DropDownChoice<>(ID_FOCUS_TYPE, new PropertyModel<QName>(model, TaskAddDto.F_FOCUS_TYPE), new AbstractReadOnlyModel<List<QName>>() {

        @Override
        public List<QName> getObject() {
            return createFocusTypeList();
        }
    }, new QNameChoiceRenderer());
    focusType.setOutputMarkupId(true);
    focusType.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            TaskAddDto dto = model.getObject();
            return TaskCategory.RECOMPUTATION.equals(dto.getCategory());
        }
    });
    mainForm.add(focusType);
    final DropDownChoice kind = new DropDownChoice<>(ID_KIND, new PropertyModel<ShadowKindType>(model, TaskAddDto.F_KIND), WebComponentUtil.createReadonlyModelFromEnum(ShadowKindType.class), new EnumChoiceRenderer<ShadowKindType>());
    kind.setOutputMarkupId(true);
    kind.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            TaskAddDto dto = model.getObject();
            boolean sync = TaskCategory.LIVE_SYNCHRONIZATION.equals(dto.getCategory());
            boolean recon = TaskCategory.RECONCILIATION.equals(dto.getCategory());
            boolean importAccounts = TaskCategory.IMPORTING_ACCOUNTS.equals(dto.getCategory());
            return sync || recon || importAccounts;
        }
    });
    mainForm.add(kind);
    final TextField<String> intent = new TextField<>(ID_INTENT, new PropertyModel<String>(model, TaskAddDto.F_INTENT));
    mainForm.add(intent);
    intent.setOutputMarkupId(true);
    intent.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            TaskAddDto dto = model.getObject();
            boolean sync = TaskCategory.LIVE_SYNCHRONIZATION.equals(dto.getCategory());
            boolean recon = TaskCategory.RECONCILIATION.equals(dto.getCategory());
            boolean importAccounts = TaskCategory.IMPORTING_ACCOUNTS.equals(dto.getCategory());
            return sync || recon || importAccounts;
        }
    });
    if (model.getObject() != null && model.getObject().getResource() != null && model.getObject().getResource().getOid() != null) {
        loadResource();
    }
    AutoCompleteSettings autoCompleteSettings = new AutoCompleteSettings();
    autoCompleteSettings.setShowListOnEmptyInput(true);
    autoCompleteSettings.setMaxHeightInPx(200);
    final AutoCompleteTextField<String> objectClass = new AutoCompleteTextField<String>(ID_OBJECT_CLASS, new PropertyModel<String>(model, TaskAddDto.F_OBJECT_CLASS), autoCompleteSettings) {

        @Override
        protected Iterator<String> getChoices(String input) {
            return prepareObjectClassChoiceList(input);
        }
    };
    objectClass.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            TaskAddDto dto = model.getObject();
            boolean sync = TaskCategory.LIVE_SYNCHRONIZATION.equals(dto.getCategory());
            boolean recon = TaskCategory.RECONCILIATION.equals(dto.getCategory());
            boolean importAccounts = TaskCategory.IMPORTING_ACCOUNTS.equals(dto.getCategory());
            return sync || recon || importAccounts;
        }
    });
    mainForm.add(objectClass);
    DropDownChoice type = new DropDownChoice<>(ID_CATEGORY, new PropertyModel<String>(model, TaskAddDto.F_CATEGORY), new AbstractReadOnlyModel<List<String>>() {

        @Override
        public List<String> getObject() {
            return WebComponentUtil.createTaskCategoryList();
        }
    }, new StringChoiceRenderer("pageTask.category."));
    type.add(new AjaxFormComponentUpdatingBehavior("change") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            target.add(resource);
            target.add(intent);
            target.add(kind);
            target.add(objectClass);
            target.add(focusType);
        }
    });
    type.setRequired(true);
    mainForm.add(type);
    TextField<String> name = new TextField<>(ID_NAME, new PropertyModel<String>(model, TaskAddDto.F_NAME));
    name.setRequired(true);
    mainForm.add(name);
    initScheduling(mainForm);
    initAdvanced(mainForm);
    CheckBox dryRun = new CheckBox(ID_DRY_RUN, new PropertyModel<Boolean>(model, TaskAddDto.F_DRY_RUN));
    mainForm.add(dryRun);
    initButtons(mainForm);
}
Also used : TaskAddDto(com.evolveum.midpoint.web.page.admin.server.dto.TaskAddDto) Form(org.apache.wicket.markup.html.form.Form) AutoCompleteTextField(org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteTextField) TextField(org.apache.wicket.markup.html.form.TextField) AutoCompleteTextField(org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteTextField) DateTextField(org.apache.wicket.datetime.markup.html.form.DateTextField) List(java.util.List) ArrayList(java.util.ArrayList) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) QNameChoiceRenderer(com.evolveum.midpoint.web.component.input.QNameChoiceRenderer) QName(javax.xml.namespace.QName) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AutoCompleteSettings(org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteSettings) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) StringChoiceRenderer(com.evolveum.midpoint.web.component.input.StringChoiceRenderer) CheckBox(org.apache.wicket.markup.html.form.CheckBox) AjaxCheckBox(org.apache.wicket.ajax.markup.html.form.AjaxCheckBox) TaskAddResourcesDto(com.evolveum.midpoint.web.page.admin.server.dto.TaskAddResourcesDto) ShadowKindType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType)

Example 20 with ShadowKindType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType in project midpoint by Evolveum.

the class PageTaskAdd method loadTask.

private TaskAddDto loadTask(TaskType taskType) {
    TaskAddDto taskAdd = new TaskAddDto();
    taskAdd.setCategory(taskType.getCategory());
    PrismProperty<ShadowKindType> pKind;
    try {
        pKind = taskType.asPrismObject().findOrCreateProperty(new ItemPath(TaskType.F_EXTENSION, SchemaConstants.MODEL_EXTENSION_KIND));
        taskAdd.setKind(pKind.getRealValue());
    } catch (SchemaException e) {
        warn("Could not set kind for new task : " + e.getMessage());
    }
    PrismProperty<String> pIntent;
    try {
        pIntent = taskType.asPrismObject().findOrCreateProperty(new ItemPath(TaskType.F_EXTENSION, SchemaConstants.MODEL_EXTENSION_INTENT));
        taskAdd.setIntent(pIntent.getRealValue());
    } catch (SchemaException e) {
        warn("Could not set intent for new task : " + e.getMessage());
    }
    PrismProperty<QName> pObjectClass;
    try {
        pObjectClass = taskType.asPrismObject().findOrCreateProperty(new ItemPath(TaskType.F_EXTENSION, SchemaConstants.OBJECTCLASS_PROPERTY_NAME));
        QName objectClass = pObjectClass.getRealValue();
        if (objectClass != null) {
            taskAdd.setObjectClass(objectClass.getLocalPart());
        }
    } catch (SchemaException e) {
        warn("Could not set obejctClass for new task : " + e.getMessage());
    }
    ObjectReferenceType ref = taskType.getObjectRef();
    if (ref != null) {
        TaskAddResourcesDto resource = new TaskAddResourcesDto(ref.getOid(), WebComponentUtil.getName(ref));
        taskAdd.setResource(resource);
    }
    return taskAdd;
}
Also used : TaskAddDto(com.evolveum.midpoint.web.page.admin.server.dto.TaskAddDto) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) QName(javax.xml.namespace.QName) ShadowKindType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType) TaskAddResourcesDto(com.evolveum.midpoint.web.page.admin.server.dto.TaskAddResourcesDto) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Aggregations

ShadowKindType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType)33 QName (javax.xml.namespace.QName)15 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)13 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)13 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)12 PrismObject (com.evolveum.midpoint.prism.PrismObject)8 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)8 ArrayList (java.util.ArrayList)7 ShadowAssociationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAssociationType)6 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)5 List (java.util.List)5 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)5 RefinedResourceSchema (com.evolveum.midpoint.common.refinery.RefinedResourceSchema)4 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)4 ResourceObjectTypeDefinition (com.evolveum.midpoint.schema.processor.ResourceObjectTypeDefinition)4 NotNull (org.jetbrains.annotations.NotNull)4 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)3 ResourceShadowDiscriminator (com.evolveum.midpoint.schema.ResourceShadowDiscriminator)3 ResourceAttributeContainer (com.evolveum.midpoint.schema.processor.ResourceAttributeContainer)3 ResourceSchema (com.evolveum.midpoint.schema.processor.ResourceSchema)3