Search in sources :

Example 71 with PrismReferenceValue

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

the class SceneItemValuePanel method initLayout.

private void initLayout() {
    final VisibleEnableBehaviour visibleIfReference = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            SceneItemValue object = getModelObject();
            return hasValidReferenceValue(object);
        }
    };
    final VisibleEnableBehaviour visibleIfNotReference = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            SceneItemValue object = getModelObject();
            return !hasValidReferenceValue(object);
        }
    };
    final ImagePanel icon = new ImagePanel(ID_ICON, new IconModel(), new TitleModel());
    icon.add(visibleIfReference);
    add(icon);
    final Label label = new Label(ID_LABEL, new LabelModel());
    label.add(visibleIfNotReference);
    add(label);
    final LinkPanel link = new LinkPanel(ID_LINK, new LabelModel()) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            if (!(getModelObject().getSourceValue() instanceof PrismReferenceValue)) {
                return;
            }
            PrismReferenceValue refValue = (PrismReferenceValue) getModelObject().getSourceValue();
            ObjectReferenceType ort = new ObjectReferenceType();
            ort.setupReferenceValue(refValue);
            WebComponentUtil.dispatchToObjectDetailsPage(ort, getPageBase(), false);
        }
    };
    link.add(visibleIfReference);
    add(link);
    final Label additionalText = new Label(ID_ADDITIONAL_TEXT, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return getModelObject() != null ? getModelObject().getAdditionalText() : null;
        }
    });
    add(additionalText);
}
Also used : SceneItemValue(com.evolveum.midpoint.model.api.visualizer.SceneItemValue) Label(org.apache.wicket.markup.html.basic.Label) LinkPanel(com.evolveum.midpoint.web.component.data.column.LinkPanel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) ImagePanel(com.evolveum.midpoint.web.component.data.column.ImagePanel)

Example 72 with PrismReferenceValue

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

the class RepositoryObjectDataProvider method createItem.

private DebugObjectItem createItem(PrismObject<? extends ObjectType> object, OperationResult result) {
    DebugObjectItem item = DebugObjectItem.createDebugObjectItem(object);
    if (ShadowType.class.isAssignableFrom(object.getCompileTimeClass())) {
        PrismReference ref = object.findReference(new ItemPath(ShadowType.F_RESOURCE_REF));
        if (ref == null || ref.getValue() == null) {
            return item;
        }
        PrismReferenceValue refValue = ref.getValue();
        String resourceOid = refValue.getOid();
        ResourceDescription desc = resourceCache.get(resourceOid);
        if (desc == null) {
            desc = loadDescription(resourceOid, result);
            resourceCache.put(resourceOid, desc);
        }
        item.setResourceName(desc.getName());
        item.setResourceType(desc.getType());
    }
    return item;
}
Also used : PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) PrismReference(com.evolveum.midpoint.prism.PrismReference) DebugObjectItem(com.evolveum.midpoint.web.page.admin.configuration.dto.DebugObjectItem) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 73 with PrismReferenceValue

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

the class RepositoryObjectDataProvider method loadDescription.

private ResourceDescription loadDescription(String oid, OperationResult result) {
    Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(ResourceType.F_CONNECTOR, GetOperationOptions.createResolve());
    OperationResult subResult = result.createSubresult(OPERATION_LOAD_RESOURCE);
    subResult.addParam("oid", oid);
    PrismObject<ResourceType> resource = null;
    String type = null;
    try {
        resource = getModel().getObject(ResourceType.class, oid, options, getPage().createSimpleTask(OPERATION_LOAD_RESOURCE), subResult);
        PrismReference ref = resource.findReference(ResourceType.F_CONNECTOR_REF);
        if (ref != null && ref.getValue() != null) {
            PrismReferenceValue refValue = ref.getValue();
            if (refValue.getObject() != null) {
                PrismObject connector = refValue.getObject();
                PrismProperty<String> pType = connector.findProperty(ConnectorType.F_CONNECTOR_TYPE);
                if (pType != null && pType.getRealValue() != null) {
                    type = pType.getRealValue(String.class);
                }
            }
        }
        subResult.recordSuccess();
    } catch (Exception ex) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load resource for account", ex);
        subResult.recordFatalError("Couldn't load resource for account.");
    } finally {
        subResult.recomputeStatus();
    }
    return new ResourceDescription(oid, WebComponentUtil.getName(resource), type);
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) PrismReference(com.evolveum.midpoint.prism.PrismReference) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)

Example 74 with PrismReferenceValue

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

the class SearchTest method assignmentResourceRefSearchTest.

@Test
public void assignmentResourceRefSearchTest() throws Exception {
    PrismReferenceValue resourceRef = new PrismReferenceValue("10000000-0000-0000-0000-000000000004", ResourceType.COMPLEX_TYPE);
    ObjectQuery query = QueryBuilder.queryFor(RoleType.class, prismContext).item(RoleType.F_ASSIGNMENT, AssignmentType.F_CONSTRUCTION, ConstructionType.F_RESOURCE_REF).ref(resourceRef).build();
    OperationResult result = new OperationResult("search");
    List<PrismObject<RoleType>> roles = repositoryService.searchObjects(RoleType.class, query, null, result);
    result.recomputeStatus();
    assertTrue(result.isSuccess());
    assertEquals("Should find one role", 1, roles.size());
    assertEquals("Wrong role name", "Judge", roles.get(0).getName().getOrig());
    PrismReferenceValue resourceRef2 = new PrismReferenceValue("FFFFFFFF-0000-0000-0000-000000000004", ResourceType.COMPLEX_TYPE);
    query = QueryBuilder.queryFor(RoleType.class, prismContext).item(RoleType.F_ASSIGNMENT, AssignmentType.F_CONSTRUCTION, ConstructionType.F_RESOURCE_REF).ref(resourceRef2).build();
    roles = repositoryService.searchObjects(RoleType.class, query, null, result);
    result.recomputeStatus();
    assertTrue(result.isSuccess());
    assertEquals("Should find zero roles", 0, roles.size());
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Test(org.testng.annotations.Test)

Example 75 with PrismReferenceValue

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

the class SearchTest method assignmentOrgRefSearchTest.

@Test
public void assignmentOrgRefSearchTest() throws Exception {
    PrismReferenceValue o123456 = new PrismReferenceValue("o123456", OrgType.COMPLEX_TYPE);
    ObjectQuery query = QueryBuilder.queryFor(UserType.class, prismContext).item(UserType.F_ASSIGNMENT, AssignmentType.F_ORG_REF).ref(o123456).build();
    OperationResult result = new OperationResult("search");
    List<PrismObject<UserType>> users = repositoryService.searchObjects(UserType.class, query, null, result);
    result.recomputeStatus();
    assertTrue(result.isSuccess());
    assertEquals("Should find one user", 1, users.size());
    assertEquals("Wrong user name", "atestuserX00002", users.get(0).getName().getOrig());
    PrismReferenceValue o999 = new PrismReferenceValue("o999", RoleType.COMPLEX_TYPE);
    query = QueryBuilder.queryFor(UserType.class, prismContext).item(UserType.F_ASSIGNMENT, AssignmentType.F_ORG_REF).ref(o999).build();
    users = repositoryService.searchObjects(UserType.class, query, null, result);
    result.recomputeStatus();
    assertTrue(result.isSuccess());
    assertEquals("Should find zero users", 0, users.size());
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Test(org.testng.annotations.Test)

Aggregations

PrismReferenceValue (com.evolveum.midpoint.prism.PrismReferenceValue)126 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)64 Test (org.testng.annotations.Test)47 Task (com.evolveum.midpoint.task.api.Task)45 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)32 ReferenceDelta (com.evolveum.midpoint.prism.delta.ReferenceDelta)27 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)26 PrismObject (com.evolveum.midpoint.prism.PrismObject)25 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)25 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)24 ArrayList (java.util.ArrayList)22 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)21 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)20 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)16 PrismReference (com.evolveum.midpoint.prism.PrismReference)15 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)15 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)15 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)12 Collection (java.util.Collection)12 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)11