Search in sources :

Example 66 with PrismReferenceValue

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

the class QueryUtils method getPotentialAssigneesForUser.

private static List<PrismReferenceValue> getPotentialAssigneesForUser(MidPointPrincipal principal, QName limitationItemName) throws SchemaException {
    List<PrismReferenceValue> rv = new ArrayList<>();
    rv.add(new PrismReferenceValue(principal.getOid(), UserType.COMPLEX_TYPE));
    for (DelegatorWithOtherPrivilegesLimitations delegator : principal.getDelegatorWithOtherPrivilegesLimitationsCollection()) {
        if (DeputyUtils.limitationsAllow(delegator.getLimitations(), limitationItemName)) {
            rv.add(ObjectTypeUtil.createObjectRef(delegator.getDelegator()).asReferenceValue());
        }
    }
    return rv;
}
Also used : PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) ArrayList(java.util.ArrayList) DelegatorWithOtherPrivilegesLimitations(com.evolveum.midpoint.security.api.DelegatorWithOtherPrivilegesLimitations)

Example 67 with PrismReferenceValue

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

the class ReportUtils method getItemRealValue.

public static Object getItemRealValue(PrismContainerValue containerValue, String itemName) {
    Item item = containerValue.findItem(new QName(itemName));
    if (item == null || item.size() == 0) {
        return null;
    }
    if (item.size() > 1) {
        throw new IllegalStateException("More than one value in item " + item);
    }
    PrismValue value = item.getValue(0);
    if (value == null) {
        return null;
    }
    if (value instanceof PrismPropertyValue) {
        return ((PrismPropertyValue) value).getValue();
    } else if (value instanceof PrismReferenceValue) {
        ObjectReferenceType ort = new ObjectReferenceType();
        ort.setupReferenceValue((PrismReferenceValue) value);
        return ort;
    } else if (value instanceof PrismContainerValue) {
        // questionable
        return ((PrismContainerValue) value).asContainerable();
    } else {
        throw new IllegalStateException("Unknown PrismValue: " + value);
    }
}
Also used : Item(com.evolveum.midpoint.prism.Item) PrismContainerValue(com.evolveum.midpoint.prism.PrismContainerValue) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) QName(javax.xml.namespace.QName) PrismValue(com.evolveum.midpoint.prism.PrismValue) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue)

Example 68 with PrismReferenceValue

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

the class RoleGovernanceRelationsPanel method initLoadableModels.

private void initLoadableModels() {
    approverRelationObjects = new LoadableModel<List<String>>(false) {

        @Override
        protected List<String> load() {
            OperationResult result = new OperationResult(OPERATION_LOAD_APPROVER_RELATION_OBJECTS);
            PrismReferenceValue rv = new PrismReferenceValue(getModelObject().getOid());
            rv.setRelation(RelationTypes.APPROVER.getRelation());
            ObjectQuery query = QueryBuilder.queryFor(FocusType.class, getPageBase().getPrismContext()).item(FocusType.F_ASSIGNMENT, AssignmentType.F_TARGET_REF).ref(rv).build();
            List<PrismObject<FocusType>> approverRelationObjects = WebModelServiceUtils.searchObjects(FocusType.class, query, result, getPageBase());
            return getObjectOidsList(approverRelationObjects);
        }
    };
    ownerRelationObjects = new LoadableModel<List<String>>(false) {

        @Override
        protected List<String> load() {
            OperationResult result = new OperationResult(OPERATION_LOAD_OWNER_RELATION_OBJECTS);
            PrismReferenceValue rv = new PrismReferenceValue(getModelObject().getOid());
            rv.setRelation(RelationTypes.OWNER.getRelation());
            ObjectQuery query = QueryBuilder.queryFor(FocusType.class, getPageBase().getPrismContext()).item(FocusType.F_ASSIGNMENT, AssignmentType.F_TARGET_REF).ref(rv).build();
            List<PrismObject<FocusType>> ownerRelationObjects = WebModelServiceUtils.searchObjects(FocusType.class, query, result, getPageBase());
            return getObjectOidsList(ownerRelationObjects);
        }
    };
    managerRelationObjects = new LoadableModel<List<String>>(false) {

        @Override
        protected List<String> load() {
            OperationResult result = new OperationResult(OPERATION_LOAD_MANAGER_RELATION_OBJECTS);
            PrismReferenceValue rv = new PrismReferenceValue(getModelObject().getOid());
            rv.setRelation(RelationTypes.MANAGER.getRelation());
            ObjectQuery query = QueryBuilder.queryFor(FocusType.class, getPageBase().getPrismContext()).item(FocusType.F_ASSIGNMENT, AssignmentType.F_TARGET_REF).ref(rv).build();
            List<PrismObject<FocusType>> managerRelationObjects = WebModelServiceUtils.searchObjects(FocusType.class, query, result, getPageBase());
            return getObjectOidsList(managerRelationObjects);
        }
    };
}
Also used : PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) ArrayList(java.util.ArrayList) List(java.util.List) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 69 with PrismReferenceValue

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

the class PageSelfDashboard method createAssignmentItem.

private AssignmentItemDto createAssignmentItem(PrismObject<UserType> user, PrismContainerValue<AssignmentType> assignment, Task task, OperationResult result) {
    ActivationType activation = assignment.asContainerable().getActivation();
    if (activation != null && activation.getAdministrativeStatus() != null && !activation.getAdministrativeStatus().equals(ActivationStatusType.ENABLED)) {
        return null;
    }
    PrismReference targetRef = assignment.findReference(AssignmentType.F_TARGET_REF);
    if (targetRef == null || targetRef.isEmpty()) {
        // account construction
        PrismContainer construction = assignment.findContainer(AssignmentType.F_CONSTRUCTION);
        String name = null;
        String description = "";
        if (construction.getValue().asContainerable() != null && !construction.isEmpty()) {
            ConstructionType constr = (ConstructionType) construction.getValue().asContainerable();
            if (constr.getResourceRef() != null) {
                ObjectReferenceType resourceRef = constr.getResourceRef();
                PrismObject resource = WebModelServiceUtils.loadObject(ResourceType.class, resourceRef.getOid(), this, task, result);
                name = WebComponentUtil.getName(resource);
                description = constr.getDescription();
            }
        }
        return new AssignmentItemDto(AssignmentEditorDtoType.CONSTRUCTION, name, description, null);
    }
    PrismReferenceValue refValue = targetRef.getValue();
    PrismObject value = refValue.getObject();
    if (value == null) {
        // resolve reference
        value = WebModelServiceUtils.loadObject(ObjectType.class, refValue.getOid(), this, task, result);
    }
    if (value == null) {
        // we couldn't resolve assignment details
        return new AssignmentItemDto(null, null, null, null);
    }
    String name = WebComponentUtil.getDisplayNameOrName(value);
    AssignmentEditorDtoType type = AssignmentEditorDtoType.getType(value.getCompileTimeClass());
    String relation = refValue.getRelation() != null ? refValue.getRelation().getLocalPart() : null;
    return new AssignmentItemDto(type, name, getAssignmentDescription(value), relation);
}
Also used : AssignmentEditorDtoType(com.evolveum.midpoint.web.component.assignment.AssignmentEditorDtoType) PrismObject(com.evolveum.midpoint.prism.PrismObject) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) PrismReference(com.evolveum.midpoint.prism.PrismReference) PrismContainer(com.evolveum.midpoint.prism.PrismContainer) AssignmentItemDto(com.evolveum.midpoint.web.page.admin.home.dto.AssignmentItemDto)

Example 70 with PrismReferenceValue

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

the class SearchItemPanel method findLookupTable.

private PrismObject<LookupTableType> findLookupTable(ItemDefinition definition) {
    PrismReferenceValue valueEnumerationRef = definition.getValueEnumerationRef();
    if (valueEnumerationRef == null) {
        return null;
    }
    PageBase page = getPageBase();
    String lookupTableUid = valueEnumerationRef.getOid();
    Task task = page.createSimpleTask("loadLookupTable");
    OperationResult result = task.getResult();
    Collection<SelectorOptions<GetOperationOptions>> options = WebModelServiceUtils.createLookupTableRetrieveOptions();
    return WebModelServiceUtils.loadObject(LookupTableType.class, lookupTableUid, options, page, task, result);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PageBase(com.evolveum.midpoint.gui.api.page.PageBase)

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