Search in sources :

Example 71 with PrismObject

use of com.evolveum.midpoint.prism.PrismObject in project midpoint by Evolveum.

the class TestCorrelationConfiramtionEvaluator method test003CorrelationWithCondition.

@Test
public void test003CorrelationWithCondition() throws Exception {
    String TEST_NAME = "test003CorrelationWithCondition";
    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> queries = new ArrayList<>();
    ConditionalSearchFilterType query = PrismTestUtil.parseAtomicValue(new File(CORRELATION_WITH_CONDITION), ConditionalSearchFilterType.COMPLEX_TYPE);
    queries.add(query);
    query = PrismTestUtil.parseAtomicValue(new File(CORRELATION_WITH_CONDITION_EMPL_NUMBER), ConditionalSearchFilterType.COMPLEX_TYPE);
    queries.add(query);
    ResourceType resourceType = parseObjectType(RESOURCE_DUMMY_FILE, ResourceType.class);
    List<PrismObject<UserType>> matchedUsers = evaluator.findFocusesByCorrelationRule(UserType.class, shadow, queries, 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 72 with PrismObject

use of com.evolveum.midpoint.prism.PrismObject 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 73 with PrismObject

use of com.evolveum.midpoint.prism.PrismObject 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 74 with PrismObject

use of com.evolveum.midpoint.prism.PrismObject in project midpoint by Evolveum.

the class ScenePanel method initLayout.

private void initLayout() {
    final IModel<SceneDto> model = getModel();
    WebMarkupContainer box = new WebMarkupContainer(ID_BOX);
    box.add(AttributeModifier.append("class", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            SceneDto dto = model.getObject();
            if (dto.getBoxClassOverride() != null) {
                return dto.getBoxClassOverride();
            }
            if (dto.getChangeType() == null) {
                return null;
            }
            switch(dto.getChangeType()) {
                case ADD:
                    return "box-success";
                case DELETE:
                    return "box-danger";
                case MODIFY:
                    return "box-info";
                default:
                    return null;
            }
        }
    }));
    add(box);
    WebMarkupContainer headerPanel = new WebMarkupContainer(ID_HEADER_PANEL);
    box.add(headerPanel);
    headerPanel.add(new SceneButtonPanel(ID_OPTION_BUTTONS, model) {

        @Override
        public void minimizeOnClick(AjaxRequestTarget target) {
            headerOnClickPerformed(target, model);
        }
    });
    Label headerChangeType = new Label(ID_HEADER_CHANGE_TYPE, new ChangeTypeModel());
    //headerChangeType.setRenderBodyOnly(true);
    Label headerObjectType = new Label(ID_HEADER_OBJECT_TYPE, new ObjectTypeModel());
    //headerObjectType.setRenderBodyOnly(true);
    IModel<String> nameModel = new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return model.getObject().getName(ScenePanel.this);
        }
    };
    Label headerNameLabel = new Label(ID_HEADER_NAME_LABEL, nameModel);
    LinkPanel headerNameLink = new LinkPanel(ID_HEADER_NAME_LINK, nameModel) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            PrismContainerValue<?> value = getModelObject().getScene().getSourceValue();
            if (value != null && value.getParent() instanceof PrismObject) {
                PrismObject<? extends ObjectType> object = (PrismObject<? extends ObjectType>) value.getParent();
                WebComponentUtil.dispatchToObjectDetailsPage(ObjectTypeUtil.createObjectRef(object), getPageBase(), false);
            }
        }
    };
    Label headerDescription = new Label(ID_HEADER_DESCRIPTION, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return model.getObject().getDescription(ScenePanel.this);
        }
    });
    Label headerWrapperDisplayName = new Label(ID_HEADER_WRAPPER_DISPLAY_NAME, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            String key = ((WrapperScene) getModelObject().getScene()).getDisplayNameKey();
            Object[] parameters = ((WrapperScene) getModelObject().getScene()).getDisplayNameParameters();
            return new StringResourceModel(key, this).setModel(null).setDefaultValue(key).setParameters(parameters).getObject();
        }
    });
    headerPanel.add(headerChangeType);
    headerPanel.add(headerObjectType);
    headerPanel.add(headerNameLabel);
    headerPanel.add(headerNameLink);
    headerPanel.add(headerDescription);
    headerPanel.add(headerWrapperDisplayName);
    headerChangeType.add(createHeaderOnClickBehaviour(model));
    headerObjectType.add(createHeaderOnClickBehaviour(model));
    headerNameLabel.add(createHeaderOnClickBehaviour(model));
    headerDescription.add(createHeaderOnClickBehaviour(model));
    headerWrapperDisplayName.add(createHeaderOnClickBehaviour(model));
    VisibleEnableBehaviour visibleIfNotWrapper = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !getModelObject().isWrapper();
        }
    };
    VisibleEnableBehaviour visibleIfWrapper = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getModelObject().isWrapper();
        }
    };
    VisibleEnableBehaviour visibleIfExistingObject = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            if (getModelObject().isWrapper()) {
                return false;
            }
            return isExistingViewableObject();
        }
    };
    VisibleEnableBehaviour visibleIfNotWrapperAndNotExistingObject = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            if (getModelObject().isWrapper()) {
                return false;
            }
            return !isExistingViewableObject();
        }
    };
    headerChangeType.add(visibleIfNotWrapper);
    headerObjectType.add(visibleIfNotWrapper);
    headerNameLabel.add(visibleIfNotWrapperAndNotExistingObject);
    headerNameLink.add(visibleIfExistingObject);
    headerDescription.add(visibleIfNotWrapper);
    headerWrapperDisplayName.add(visibleIfWrapper);
    WebMarkupContainer body = new WebMarkupContainer(ID_BODY);
    body.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            SceneDto wrapper = model.getObject();
            return !wrapper.isMinimized();
        }
    });
    box.add(body);
    WebMarkupContainer itemsTable = new WebMarkupContainer(ID_ITEMS_TABLE);
    itemsTable.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !model.getObject().getItems().isEmpty();
        }
    });
    WebMarkupContainer oldValueLabel = new WebMarkupContainer(ID_OLD_VALUE_LABEL);
    oldValueLabel.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return model.getObject().containsDeltaItems();
        }
    });
    itemsTable.add(oldValueLabel);
    WebMarkupContainer newValueLabel = new WebMarkupContainer(ID_NEW_VALUE_LABEL);
    newValueLabel.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return model.getObject().containsDeltaItems();
        }
    });
    itemsTable.add(newValueLabel);
    WebMarkupContainer valueLabel = new WebMarkupContainer(ID_VALUE_LABEL);
    valueLabel.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !model.getObject().containsDeltaItems();
        }
    });
    itemsTable.add(valueLabel);
    ListView<SceneItemDto> items = new ListView<SceneItemDto>(ID_ITEMS, new PropertyModel<List<SceneItemDto>>(model, SceneDto.F_ITEMS)) {

        @Override
        protected void populateItem(ListItem<SceneItemDto> item) {
            SceneItemPanel panel = new SceneItemPanel(ID_ITEM, item.getModel());
            panel.setRenderBodyOnly(true);
            item.add(panel);
        }
    };
    items.setReuseItems(true);
    itemsTable.add(items);
    body.add(itemsTable);
    ListView<SceneDto> partialScenes = new ListView<SceneDto>(ID_PARTIAL_SCENES, new PropertyModel<List<SceneDto>>(model, SceneDto.F_PARTIAL_SCENES)) {

        @Override
        protected void populateItem(ListItem<SceneDto> item) {
            ScenePanel panel = new ScenePanel(ID_PARTIAL_SCENE, item.getModel());
            panel.setOutputMarkupPlaceholderTag(true);
            item.add(panel);
        }
    };
    partialScenes.setReuseItems(true);
    body.add(partialScenes);
}
Also used : Label(org.apache.wicket.markup.html.basic.Label) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) LinkPanel(com.evolveum.midpoint.web.component.data.column.LinkPanel) PrismObject(com.evolveum.midpoint.prism.PrismObject) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) ListView(org.apache.wicket.markup.html.list.ListView) List(java.util.List) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 75 with PrismObject

use of com.evolveum.midpoint.prism.PrismObject in project midpoint by Evolveum.

the class SampleFormFocusTabPanel method initLayout.

private void initLayout(final LoadableModel<ObjectWrapper<F>> focusModel, LoadableModel<List<AssignmentEditorDto>> assignmentsModel, PageBase pageBase) {
    add(new Label(ID_HEADER, "Object details"));
    WebMarkupContainer body = new WebMarkupContainer("body");
    add(body);
    addPrismPropertyPanel(body, ID_PROP_NAME, FocusType.F_NAME);
    addPrismPropertyPanel(body, ID_PROP_FULL_NAME, UserType.F_FULL_NAME);
    // TODO: create proxy for these operations
    Task task = pageBase.createSimpleTask(OPERATION_SEARCH_ROLES);
    List<PrismObject<RoleType>> availableRoles;
    try {
        availableRoles = pageBase.getModelService().searchObjects(RoleType.class, null, null, task, task.getResult());
    } catch (SchemaException | ObjectNotFoundException | SecurityViolationException | CommunicationException | ConfigurationException | ExpressionEvaluationException e) {
        task.getResult().recordFatalError(e);
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load roles", e);
        availableRoles = new ArrayList<>();
    // TODO: better errror reporting
    }
    add(new SimpleRoleSelector<F, RoleType>(ID_ROLES, assignmentsModel, availableRoles));
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Task(com.evolveum.midpoint.task.api.Task) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) Label(org.apache.wicket.markup.html.basic.Label) ArrayList(java.util.ArrayList) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) PrismObject(com.evolveum.midpoint.prism.PrismObject) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException)

Aggregations

PrismObject (com.evolveum.midpoint.prism.PrismObject)488 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)358 Test (org.testng.annotations.Test)227 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)219 Task (com.evolveum.midpoint.task.api.Task)205 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)97 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)95 ArrayList (java.util.ArrayList)81 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)79 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)64 QName (javax.xml.namespace.QName)59 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)50 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)40 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)37 ResultHandler (com.evolveum.midpoint.schema.ResultHandler)37 SearchResultMetadata (com.evolveum.midpoint.schema.SearchResultMetadata)37 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)37 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)37 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)35 SystemException (com.evolveum.midpoint.util.exception.SystemException)34