Search in sources :

Example 6 with ConditionalSearchFilterType

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

the class TestCorrelationConfiramtionEvaluator method test004CorrelationMatchCaseInsensitive.

@Test
public void test004CorrelationMatchCaseInsensitive() throws Exception {
    String TEST_NAME = "test004CorrelationMatchCaseInsensitive";
    TestUtil.displayTestTile(this, TEST_NAME);
    Task task = taskManager.createTaskInstance(TEST_NAME);
    OperationResult result = task.getResult();
    //		importObjectFromFile(USER_JACK_FILENAME);
    PrismObject<UserType> userType = repositoryService.getObject(UserType.class, USER_JACK_OID, null, result);
    //assert jack
    assertNotNull(userType);
    ShadowType shadow = parseObjectType(ACCOUNT_SHADOW_JACK_DUMMY_FILE, ShadowType.class);
    ConditionalSearchFilterType query = PrismTestUtil.parseAtomicValue(new File(CORRELATION_CASE_INSENSITIVE), ConditionalSearchFilterType.COMPLEX_TYPE);
    //		List<QueryType> queries = new ArrayList<QueryType>();
    //		queries.add(query);
    //		
    ResourceType resourceType = parseObjectType(RESOURCE_DUMMY_FILE, ResourceType.class);
    resourceType.getSynchronization().getObjectSynchronization().get(0).getCorrelation().clear();
    resourceType.getSynchronization().getObjectSynchronization().get(0).getCorrelation().add(query);
    userType.asObjectable().setName(new PolyStringType("JACK"));
    ObjectSynchronizationType objectSynchronizationType = resourceType.getSynchronization().getObjectSynchronization().get(0);
    try {
        boolean matchedUsers = evaluator.matchUserCorrelationRule(UserType.class, shadow.asPrismObject(), userType, objectSynchronizationType, resourceType, getSystemConfiguration(), task, result);
        System.out.println("matched users " + matchedUsers);
        AssertJUnit.assertTrue(matchedUsers);
    } catch (Exception ex) {
        LOGGER.error("exception occured: {}", ex.getMessage(), ex);
        throw ex;
    }
//		assertNotNull("Correlation evaluator returned null collection of matched users.", matchedUsers);
//		assertEquals("Found more than one user.", 1, matchedUsers.size());
//		
//		PrismObject<UserType> jack = matchedUsers.get(0);
//		assertUser(jack, "c0c010c0-d34d-b33f-f00d-111111111111", "jack", "Jack Sparrow", "Jack", "Sparrow");
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) Task(com.evolveum.midpoint.task.api.Task) ObjectSynchronizationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectSynchronizationType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ConditionalSearchFilterType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConditionalSearchFilterType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) File(java.io.File) Test(org.testng.annotations.Test) AbstractInternalModelIntegrationTest(com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)

Example 7 with ConditionalSearchFilterType

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

the class TestCorrelationConfiramtionEvaluator method test002CorrelationMoreThanOne.

@Test
public void test002CorrelationMoreThanOne() throws Exception {
    String TEST_NAME = "test002CorrelationMoreThanOne";
    TestUtil.displayTestTile(this, TEST_NAME);
    Task task = taskManager.createTaskInstance(TEST_NAME);
    OperationResult result = task.getResult();
    //		importObjectFromFile(USER_JACK_FILENAME);
    PrismObject<UserType> userType = repositoryService.getObject(UserType.class, USER_JACK_OID, null, result);
    //assert jack
    assertNotNull(userType);
    ShadowType shadow = parseObjectType(ACCOUNT_SHADOW_JACK_DUMMY_FILE, ShadowType.class);
    List<ConditionalSearchFilterType> filters = new ArrayList<>();
    ConditionalSearchFilterType filter = PrismTestUtil.parseAtomicValue(new File(CORRELATION_FIRST_FILTER), ConditionalSearchFilterType.COMPLEX_TYPE);
    filters.add(filter);
    filter = PrismTestUtil.parseAtomicValue(new File(CORRELATION_SECOND_FILTER), ConditionalSearchFilterType.COMPLEX_TYPE);
    filters.add(filter);
    ResourceType resourceType = parseObjectType(RESOURCE_DUMMY_FILE, ResourceType.class);
    List<PrismObject<UserType>> matchedUsers = evaluator.findFocusesByCorrelationRule(UserType.class, shadow, filters, resourceType, getSystemConfiguration(), task, result);
    assertNotNull("Correlation evaluator returned null collection of matched users.", matchedUsers);
    assertEquals("Found more than one user.", 1, matchedUsers.size());
    PrismObject<UserType> jack = matchedUsers.get(0);
    assertUser(jack, "c0c010c0-d34d-b33f-f00d-111111111111", "jack", "Jack Sparrow", "Jack", "Sparrow");
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ArrayList(java.util.ArrayList) ConditionalSearchFilterType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConditionalSearchFilterType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PrismObject(com.evolveum.midpoint.prism.PrismObject) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) File(java.io.File) Test(org.testng.annotations.Test) AbstractInternalModelIntegrationTest(com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)

Example 8 with ConditionalSearchFilterType

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

the class TestCorrelationConfiramtionEvaluator method test006CorrelationFindCaseInsensitive.

@Test
public void test006CorrelationFindCaseInsensitive() throws Exception {
    String TEST_NAME = "test006CorrelationFindCaseInsensitive";
    TestUtil.displayTestTile(this, TEST_NAME);
    Task task = taskManager.createTaskInstance(TEST_NAME);
    OperationResult result = task.getResult();
    //		importObjectFromFile(USER_JACK_FILENAME);
    PrismObject<UserType> userType = repositoryService.getObject(UserType.class, USER_JACK_OID, null, result);
    //assert jack
    assertNotNull(userType);
    ShadowType shadow = parseObjectType(ACCOUNT_SHADOW_JACK_DUMMY_FILE, ShadowType.class);
    ConditionalSearchFilterType query = PrismTestUtil.parseAtomicValue(new File(CORRELATION_CASE_INSENSITIVE), ConditionalSearchFilterType.COMPLEX_TYPE);
    List<ConditionalSearchFilterType> queries = new ArrayList<>();
    queries.add(query);
    //		
    ResourceType resourceType = parseObjectType(RESOURCE_DUMMY_FILE, ResourceType.class);
    //		resourceType.getSynchronization().getObjectSynchronization().get(0).getCorrelation().add(query);
    userType.asObjectable().setName(new PolyStringType("JACK"));
    Collection<? extends ItemDelta> modifications = PropertyDelta.createModificationReplacePropertyCollection(UserType.F_NAME, userType.getDefinition(), new PolyString("JACK", "jack"));
    repositoryService.modifyObject(UserType.class, USER_JACK_OID, modifications, result);
    List<PrismObject<UserType>> matchedUsers = evaluator.findFocusesByCorrelationRule(UserType.class, shadow, queries, resourceType, getSystemConfiguration(), task, result);
    System.out.println("matched users " + matchedUsers);
    assertNotNull("Correlation evaluator returned null collection of matched users.", matchedUsers);
    assertEquals("Found more than one user.", 1, matchedUsers.size());
    PrismObject<UserType> jack = matchedUsers.get(0);
    assertUser(jack, "c0c010c0-d34d-b33f-f00d-111111111111", "JACK", "Jack Sparrow", "Jack", "Sparrow");
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ConditionalSearchFilterType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConditionalSearchFilterType) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PrismObject(com.evolveum.midpoint.prism.PrismObject) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) File(java.io.File) Test(org.testng.annotations.Test) AbstractInternalModelIntegrationTest(com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)

Example 9 with ConditionalSearchFilterType

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

the class SynchronizationExpressionsEvaluator method matchFocusByCorrelationRule.

public <F extends FocusType> boolean matchFocusByCorrelationRule(SynchronizationContext<F> syncCtx, PrismObject<F> focus, OperationResult result) {
    if (!syncCtx.hasApplicablePolicy()) {
        LOGGER.warn("Resource does not support synchronization. Skipping evaluation correlation/confirmation for {} and {}", focus, syncCtx.getShadowedResourceObject());
        return false;
    }
    List<ConditionalSearchFilterType> conditionalFilters = syncCtx.getCorrelation();
    try {
        for (ConditionalSearchFilterType conditionalFilter : conditionalFilters) {
            // TODO: can we expect that systemConfig and resource are always present?
            if (matchUserCorrelationRule(syncCtx.getFocusClass(), syncCtx.getShadowedResourceObject(), syncCtx.getExpressionProfile(), focus, syncCtx.getResource().asObjectable(), syncCtx.getSystemConfiguration().asObjectable(), conditionalFilter, syncCtx.getTask(), result)) {
                LOGGER.debug("SYNCHRONIZATION: CORRELATION: expression for {} match user: {}", syncCtx.getShadowedResourceObject(), focus);
                return true;
            }
        }
    } catch (SchemaException ex) {
        throw new SystemException("Failed to match user using correlation rule. " + ex.getMessage(), ex);
    }
    LOGGER.debug("SYNCHRONIZATION: CORRELATION: expression for {} does not match user: {}", syncCtx.getShadowedResourceObject(), focus);
    return false;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) SystemException(com.evolveum.midpoint.util.exception.SystemException) ConditionalSearchFilterType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConditionalSearchFilterType)

Example 10 with ConditionalSearchFilterType

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

the class ConditionalSearchFilterEditor method initLayout.

protected void initLayout(PageResourceWizard parentPage) {
    ExpressionEditorPanel expressionEditor = new ExpressionEditorPanel(ID_EXPRESSION_PANEL, new PropertyModel<>(getModel(), ConditionalSearchFilterType.F_CONDITION.getLocalPart()), parentPage) {

        @Override
        public void performExpressionHook(AjaxRequestTarget target) {
            if (getExpressionDtoModel().getObject() != null) {
                ExpressionType expression = getExpressionDtoModel().getObject().getExpressionObject();
                ConditionalSearchFilterEditor.this.getModel().getObject().setCondition(expression);
            }
        }

        @Override
        public String getTypeLabelKey() {
            return "ConditionalSearchFilterEditor.condition.type.label";
        }

        @Override
        public String getDescriptionLabelKey() {
            return "ConditionalSearchFilterEditor.condition.description.label";
        }

        @Override
        public String getUpdateLabelKey() {
            return "ConditionalSearchFilterEditor.condition.update.label";
        }

        @Override
        public String getExpressionLabelKey() {
            return "ConditionalSearchFilterEditor.condition.label";
        }
    };
    add(expressionEditor);
    SearchFilterPanel filterClauseEditor = new SearchFilterPanel<>(ID_FILTER_CLAUSE_PANEL, (NonEmptyModel<ConditionalSearchFilterType>) getModel(), parentPage.getReadOnlyModel());
    add(filterClauseEditor);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ConditionalSearchFilterType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConditionalSearchFilterType) SearchFilterPanel(com.evolveum.midpoint.web.component.input.SearchFilterPanel) ExpressionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType) ExpressionEditorPanel(com.evolveum.midpoint.web.component.input.ExpressionEditorPanel)

Aggregations

ConditionalSearchFilterType (com.evolveum.midpoint.xml.ns._public.common.common_3.ConditionalSearchFilterType)11 AbstractInternalModelIntegrationTest (com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)6 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)6 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)6 Task (com.evolveum.midpoint.task.api.Task)6 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)6 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)6 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)6 File (java.io.File)6 Test (org.testng.annotations.Test)6 ArrayList (java.util.ArrayList)5 PrismObject (com.evolveum.midpoint.prism.PrismObject)4 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)2 SystemException (com.evolveum.midpoint.util.exception.SystemException)2 ExpressionType (com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType)2 ObjectSynchronizationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectSynchronizationType)2 PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)2 ExpressionVariables (com.evolveum.midpoint.repo.common.expression.ExpressionVariables)1 ExpressionProfile (com.evolveum.midpoint.schema.expression.ExpressionProfile)1 ExpressionEditorPanel (com.evolveum.midpoint.web.component.input.ExpressionEditorPanel)1