Search in sources :

Example 1 with AssignmentEditorDtoType

use of com.evolveum.midpoint.web.component.assignment.AssignmentEditorDtoType in project midpoint by Evolveum.

the class PageSelfDashboard method createAssignmentItem.

private AssignmentItemDto createAssignmentItem(AssignmentType assignment, Task task, OperationResult result) {
    ActivationType activation = assignment.getActivation();
    if (activation != null && activation.getAdministrativeStatus() != null && !activation.getAdministrativeStatus().equals(ActivationStatusType.ENABLED)) {
        return null;
    }
    ObjectReferenceType targetRef = assignment.getTargetRef();
    if (targetRef == null) {
        // account construction
        ConstructionType construction = assignment.getConstruction();
        String name = null;
        String description = "";
        if (construction != null) {
            if (construction.getResourceRef() != null) {
                ObjectReferenceType resourceRef = construction.getResourceRef();
                PrismObject resource = WebModelServiceUtils.loadObject(ResourceType.class, resourceRef.getOid(), this, task, result);
                name = WebComponentUtil.getName(resource, false);
                description = construction.getDescription();
            }
        }
        return new AssignmentItemDto(AssignmentEditorDtoType.CONSTRUCTION, name, description, null);
    }
    if (RelationTypes.APPROVER.getRelation().equals(assignment.getTargetRef().getRelation()) || RelationTypes.OWNER.getRelation().equals(assignment.getTargetRef().getRelation())) {
        return null;
    }
    PrismObject value = targetRef.getObject();
    if (value == null) {
        // resolve reference
        value = WebModelServiceUtils.loadObject(ObjectType.class, targetRef.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, false);
    AssignmentEditorDtoType type = AssignmentEditorDtoType.getType(value.getCompileTimeClass());
    String relation = targetRef.getRelation() != null ? targetRef.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) AssignmentItemDto(com.evolveum.midpoint.web.page.admin.home.dto.AssignmentItemDto)

Example 2 with AssignmentEditorDtoType

use of com.evolveum.midpoint.web.component.assignment.AssignmentEditorDtoType 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)

Aggregations

PrismObject (com.evolveum.midpoint.prism.PrismObject)2 AssignmentEditorDtoType (com.evolveum.midpoint.web.component.assignment.AssignmentEditorDtoType)2 AssignmentItemDto (com.evolveum.midpoint.web.page.admin.home.dto.AssignmentItemDto)2 PrismContainer (com.evolveum.midpoint.prism.PrismContainer)1 PrismReference (com.evolveum.midpoint.prism.PrismReference)1 PrismReferenceValue (com.evolveum.midpoint.prism.PrismReferenceValue)1