Search in sources :

Example 31 with ShadowKindType

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

the class PageAccounts method createObjectQuery.

private ObjectQuery createObjectQuery() {
    AccountDetailsSearchDto dto = searchModel.getObject();
    String searchText = dto.getText();
    ShadowKindType kind = dto.getKind();
    String intent = dto.getIntent();
    String objectClass = dto.getObjectClass();
    FailedOperationTypeType failedOperatonType = dto.getFailedOperationType();
    S_AtomicFilterEntry q = QueryBuilder.queryFor(ShadowType.class, getPrismContext());
    if (StringUtils.isNotEmpty(searchText)) {
        PolyStringNormalizer normalizer = getPrismContext().getDefaultPolyStringNormalizer();
        String normalized = normalizer.normalize(searchText);
        q = q.item(ShadowType.F_NAME).contains(normalized).matchingNorm().and();
    }
    if (kind != null) {
        q = q.item(ShadowType.F_KIND).eq(kind).and();
    }
    if (StringUtils.isNotEmpty(intent)) {
        q = q.item(ShadowType.F_INTENT).eq(intent).and();
    }
    if (failedOperatonType != null) {
        q = q.item(ShadowType.F_FAILED_OPERATION_TYPE).eq(failedOperatonType).and();
    }
    if (StringUtils.isNotEmpty(objectClass)) {
        QName objClass = new QName(objectClass);
        for (QName qn : dto.getObjectClassList()) {
            if (objectClass.equals(qn.getLocalPart())) {
                objClass = qn;
            }
        }
        q = q.item(ShadowType.F_OBJECT_CLASS).eq(objClass).and();
    }
    return appendResourceQueryFilter(q);
}
Also used : AccountDetailsSearchDto(com.evolveum.midpoint.web.page.admin.configuration.dto.AccountDetailsSearchDto) QName(javax.xml.namespace.QName) S_AtomicFilterEntry(com.evolveum.midpoint.prism.query.builder.S_AtomicFilterEntry) ShadowKindType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType) FailedOperationTypeType(com.evolveum.midpoint.xml.ns._public.common.common_3.FailedOperationTypeType) PolyStringNormalizer(com.evolveum.midpoint.prism.polystring.PolyStringNormalizer)

Example 32 with ShadowKindType

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

the class ResourceTypeAssignmentPopupTabPanel method initParametersPanel.

@Override
protected void initParametersPanel(Fragment parametersPanel) {
    initModels();
    WebMarkupContainer kindContainer = new WebMarkupContainer(ID_KIND_CONTAINER);
    kindContainer.setOutputMarkupId(true);
    parametersPanel.add(kindContainer);
    DropDownChoicePanel<ShadowKindType> kindSelector = WebComponentUtil.createEnumPanel(ShadowKindType.class, ID_KIND, WebComponentUtil.createReadonlyModelFromEnum(ShadowKindType.class), Model.of(), ResourceTypeAssignmentPopupTabPanel.this, true);
    kindSelector.setOutputMarkupId(true);
    kindSelector.getBaseFormComponent().add(new AjaxFormComponentUpdatingBehavior("change") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            kindValueUpdatePerformed(target);
        }
    });
    kindSelector.getBaseFormComponent().add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isEnabled() {
            return getSelectedObjectsList() != null && getSelectedObjectsList().size() > 0;
        }
    });
    kindSelector.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    kindSelector.setOutputMarkupPlaceholderTag(true);
    kindContainer.add(kindSelector);
    WebMarkupContainer intentContainer = new WebMarkupContainer(ID_INTENT_CONTAINER);
    intentContainer.setOutputMarkupId(true);
    parametersPanel.add(intentContainer);
    DropDownChoicePanel<String> intentSelector = new DropDownChoicePanel<String>(ID_INTENT, Model.of(), intentValues, true);
    intentSelector.getBaseFormComponent().add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isEnabled() {
            return getKindValue() != null && getSelectedObjectsList() != null && getSelectedObjectsList().size() > 0;
        }
    });
    intentSelector.getBaseFormComponent().add(new AjaxFormComponentUpdatingBehavior("change") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            intentValueUpdatePerformed(target);
        }
    });
    intentSelector.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    intentSelector.setOutputMarkupId(true);
    intentSelector.setOutputMarkupPlaceholderTag(true);
    intentContainer.add(intentSelector);
    WebMarkupContainer associationContainer = new WebMarkupContainer(ID_ASSOCIATION_CONTAINER);
    associationContainer.setOutputMarkupId(true);
    associationContainer.add(new VisibleBehaviour(() -> isEntitlementAssignment()));
    parametersPanel.add(associationContainer);
    DropDownChoicePanel<ResourceAssociationDefinition> associationSelector = new DropDownChoicePanel<>(ID_ASSOCIATION, Model.of(), associationValuesModel, new IChoiceRenderer<ResourceAssociationDefinition>() {

        private static final long serialVersionUID = 1L;

        @Override
        public Object getDisplayValue(ResourceAssociationDefinition refinedAssociationDefinition) {
            return WebComponentUtil.getAssociationDisplayName(refinedAssociationDefinition);
        }

        @Override
        public String getIdValue(ResourceAssociationDefinition refinedAssociationDefinition, int index) {
            return Integer.toString(index);
        }

        @Override
        public ResourceAssociationDefinition getObject(String id, IModel<? extends List<? extends ResourceAssociationDefinition>> choices) {
            return StringUtils.isNotBlank(id) ? choices.getObject().get(Integer.parseInt(id)) : null;
        }
    }, true);
    associationSelector.setOutputMarkupId(true);
    associationSelector.getBaseFormComponent().add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isEnabled() {
            return getSelectedObjectsList() != null && getSelectedObjectsList().size() > 0 && getKindValue() != null && StringUtils.isNotEmpty(getIntentValue());
        }
    });
    associationSelector.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    associationSelector.setOutputMarkupPlaceholderTag(true);
    associationContainer.add(associationSelector);
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) DropDownChoicePanel(com.evolveum.midpoint.web.component.input.DropDownChoicePanel) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) ResourceAssociationDefinition(com.evolveum.midpoint.schema.processor.ResourceAssociationDefinition) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) EmptyOnChangeAjaxFormUpdatingBehavior(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior) ShadowKindType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 33 with ShadowKindType

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

the class SynchronizationUtils method isPolicyApplicable.

/**
 * Checks if the synchronization policy matches given "parameters" (object class, kind, intent).
 */
public static boolean isPolicyApplicable(QName objectClass, ShadowKindType kind, String intent, @NotNull ObjectSynchronizationType synchronizationPolicy, PrismObject<ResourceType> resource, boolean strictIntent) throws SchemaException {
    if (objectClassDefinedAndNotMatching(objectClass, synchronizationPolicy.getObjectClass())) {
        return false;
    }
    ResourceSchema schema = ResourceSchemaFactory.getCompleteSchema(resource);
    Objects.requireNonNull(schema, "No schema defined in resource. Possible configuration problem?");
    ShadowKindType policyKind = requireNonNullElse(synchronizationPolicy.getKind(), ACCOUNT);
    String policyIntent = synchronizationPolicy.getIntent();
    ResourceObjectDefinition policyObjectClass;
    if (StringUtils.isEmpty(policyIntent)) {
        // TODO check this
        policyObjectClass = schema.findObjectDefinition(policyKind, null);
        if (policyObjectClass instanceof ResourceObjectTypeDefinition) {
            policyIntent = ((ResourceObjectTypeDefinition) policyObjectClass).getIntent();
        }
    } else {
        policyObjectClass = schema.findObjectDefinition(policyKind, policyIntent);
    }
    if (policyObjectClass == null) {
        return false;
    }
    // re-check objectClass if wasn't defined
    if (objectClassDefinedAndNotMatching(objectClass, List.of(policyObjectClass.getTypeName()))) {
        return false;
    }
    // kind
    LOGGER.trace("Comparing kinds, policy kind: {}, current kind: {}", policyKind, kind);
    if (kind != null && kind != UNKNOWN && !policyKind.equals(kind)) {
        LOGGER.trace("Kinds don't match, skipping policy {}", synchronizationPolicy);
        return false;
    }
    // intent
    // TODO is the intent always present in shadow at this time? [med]
    LOGGER.trace("Comparing intents, policy intent: {}, current intent: {}", policyIntent, intent);
    if (!strictIntent) {
        if (intent != null && !SchemaConstants.INTENT_UNKNOWN.equals(intent) && !MiscSchemaUtil.equalsIntent(intent, policyIntent)) {
            LOGGER.trace("Intents don't match, skipping policy {}", synchronizationPolicy);
            return false;
        }
    } else {
        if (!MiscSchemaUtil.equalsIntent(intent, policyIntent)) {
            LOGGER.trace("Intents don't match, skipping policy {}", synchronizationPolicy);
            return false;
        }
    }
    return true;
}
Also used : ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) ResourceObjectDefinition(com.evolveum.midpoint.schema.processor.ResourceObjectDefinition) ResourceObjectTypeDefinition(com.evolveum.midpoint.schema.processor.ResourceObjectTypeDefinition) ShadowKindType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType)

Example 34 with ShadowKindType

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

the class ResourceObjectClassifierImpl method createClassification.

@NotNull
private Classification createClassification(PrismObject<ShadowType> combinedObject, SynchronizationContext<?> syncCtx) throws SchemaException {
    ShadowType objectBean = combinedObject.asObjectable();
    // This is how original synchronization service was implemented: it did not overwrite previously known values.
    ShadowKindType newKind = ShadowUtil.isKnown(objectBean.getKind()) ? objectBean.getKind() : syncCtx.getKind();
    String newIntent = ShadowUtil.isKnown(objectBean.getIntent()) ? objectBean.getIntent() : syncCtx.getIntent();
    // And as for the tag, currently it creates syncCtx.tag value only if it really wants it to be changed.
    // Otherwise it is null.
    String newTag = objectBean.getTag() != null ? objectBean.getTag() : syncCtx.getTag();
    return new Classification(newKind, newIntent, newTag);
}
Also used : ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ShadowKindType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType) NotNull(org.jetbrains.annotations.NotNull)

Example 35 with ShadowKindType

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

the class AbstractModelIntegrationTest method createConstructionAssignment.

protected AssignmentType createConstructionAssignment(String resourceOid, ShadowKindType kind, String intent) {
    AssignmentType assignmentType = new AssignmentType();
    ConstructionType constructionType = new ConstructionType();
    constructionType.setKind(kind);
    assignmentType.setConstruction(constructionType);
    ObjectReferenceType resourceRef = new ObjectReferenceType();
    resourceRef.setOid(resourceOid);
    resourceRef.setType(ResourceType.COMPLEX_TYPE);
    constructionType.setResourceRef(resourceRef);
    constructionType.setIntent(intent);
    return assignmentType;
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)

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