Search in sources :

Example 6 with CertCaseOrWorkItemDto

use of com.evolveum.midpoint.web.page.admin.certification.dto.CertCaseOrWorkItemDto in project midpoint by Evolveum.

the class DirectAssignmentCertGuiHandler method getCaseInfoButtonTitle.

@Override
public String getCaseInfoButtonTitle(IModel<? extends CertCaseOrWorkItemDto> rowModel, PageBase page) {
    CertCaseOrWorkItemDto dto = rowModel.getObject();
    AccessCertificationCaseType acase = dto.getCertCase();
    if (!(acase instanceof AccessCertificationAssignmentCaseType)) {
        // should not occur, TODO treat gracefully
        return null;
    }
    AccessCertificationAssignmentCaseType assignmentCase = (AccessCertificationAssignmentCaseType) acase;
    AssignmentType assignment = assignmentCase.getAssignment();
    List<String> infoList = new ArrayList<>();
    String assignmentOrInducement;
    if (Boolean.TRUE.equals(assignmentCase.isIsInducement())) {
        assignmentOrInducement = page.createStringResource("PageCert.message.textInducement").getString();
    } else {
        assignmentOrInducement = page.createStringResource("PageCert.message.textAssignment").getString();
    }
    String targetType = getLocalizedTypeName(acase.getTargetRef().getType(), page);
    String targetName = dto.getTargetName();
    String objectType = getLocalizedTypeName(acase.getObjectRef().getType(), page);
    String objectName = dto.getObjectName();
    // If object is UserType, display user's fullName in addition to the name
    if (QNameUtil.match(acase.getObjectRef().getType(), UserType.COMPLEX_TYPE)) {
        try {
            PrismObject<UserType> object = page.getModelService().getObject(UserType.class, acase.getObjectRef().getOid(), null, page.getPageTask(), page.getPageTask().getResult());
            if (object != null) {
                UserType userObj = object.asObjectable();
                PolyStringType fullName = userObj.getFullName();
                if (fullName != null && !StringUtils.isEmpty(fullName.getOrig())) {
                    objectName = fullName.getOrig() + " (" + objectName + ")";
                }
            }
        } catch (Exception e) {
            // probably autz exception, mute it and return object name
            LOGGER.debug("Error retrieving full object in getCaseInfoButtonTitle: {}", e.getMessage());
        }
    }
    infoList.add(page.createStringResource("PageCert.message.assignment", assignmentOrInducement, emptyToDash(targetType), emptyToDash(targetName), emptyToDash(objectType), emptyToDash(objectName)).getString());
    if (StringUtils.isNotEmpty(assignment.getDescription())) {
        infoList.add(page.createStringResource("PageCert.message.textDescription", assignment.getDescription()).getString());
    }
    if (assignment.getOrder() != null) {
        infoList.add(page.createStringResource("PageCert.message.textOrder", assignment.getOrder()).getString());
    }
    if (assignment.getConstruction() != null) {
        if (assignment.getConstruction().getKind() != null) {
            infoList.add(page.createStringResource("PageCert.message.textKind", page.createStringResource(assignment.getConstruction().getKind()).getString()).getString());
        }
        if (assignment.getConstruction().getIntent() != null) {
            infoList.add(page.createStringResource("PageCert.message.textIntent", assignment.getConstruction().getIntent()).getString());
        }
    }
    if (acase.getTargetRef().getRelation() != null) {
        infoList.add(page.createStringResource("PageCert.message.textRelation", acase.getTargetRef().getRelation().getLocalPart()).getString());
    }
    Task task = page.createSimpleTask("dummy");
    if (assignment.getOrgRef() != null) {
        String orgName = WebModelServiceUtils.resolveReferenceName(assignment.getOrgRef(), page, task, task.getResult());
        infoList.add(page.createStringResource("PageCert.message.textOrg", orgName).getString());
    }
    if (assignment.getTenantRef() != null) {
        String tenantName = WebModelServiceUtils.resolveReferenceName(assignment.getTenantRef(), page, task, task.getResult());
        infoList.add(page.createStringResource("PageCert.message.textTenant", tenantName).getString());
    }
    PrismContainer<? extends Containerable> extensionContainer = assignment.asPrismContainerValue().findContainer(AssignmentType.F_EXTENSION);
    if (extensionContainer != null && !extensionContainer.isEmpty()) {
        List<String> extensionItemNameList = new ArrayList<>();
        for (Item extensionItem : extensionContainer.getValue().getItems()) {
            extensionItemNameList.add(extensionItem.getElementName().getLocalPart());
        }
        infoList.add(page.createStringResource("PageCert.message.textExtensions", StringUtils.join(extensionItemNameList, ", ")).getString());
    }
    if (assignment.getActivation() != null) {
        String validFrom = WebComponentUtil.formatDate(assignment.getActivation().getValidFrom());
        if (validFrom != null) {
            infoList.add(page.createStringResource("PageCert.message.textValidFrom", validFrom).getString());
        }
        String validTo = WebComponentUtil.formatDate(assignment.getActivation().getValidTo());
        if (validTo != null) {
            infoList.add(page.createStringResource("PageCert.message.textValidTo", validTo).getString());
        }
        if (assignment.getActivation().getAdministrativeStatus() != null) {
            infoList.add(page.createStringResource("PageCert.message.textAdministrativeState", page.createStringResource(assignment.getActivation().getAdministrativeStatus()).getString()).getString());
        }
    }
    String rv = StringUtils.join(infoList, "<br/>");
    return rv;
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) Task(com.evolveum.midpoint.task.api.Task) ArrayList(java.util.ArrayList) CertCaseOrWorkItemDto(com.evolveum.midpoint.web.page.admin.certification.dto.CertCaseOrWorkItemDto) Item(com.evolveum.midpoint.prism.Item)

Aggregations

CertCaseOrWorkItemDto (com.evolveum.midpoint.web.page.admin.certification.dto.CertCaseOrWorkItemDto)6 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)5 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)3 ICellPopulator (org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator)3 CertWorkItemDto (com.evolveum.midpoint.web.page.admin.certification.dto.CertWorkItemDto)2 TooltipBehavior (com.evolveum.midpoint.web.util.TooltipBehavior)2 DisplayType (com.evolveum.midpoint.xml.ns._public.common.common_3.DisplayType)2 Item (com.evolveum.midpoint.prism.Item)1 Task (com.evolveum.midpoint.task.api.Task)1 AjaxLinkPanel (com.evolveum.midpoint.web.component.data.column.AjaxLinkPanel)1 CertGuiHandler (com.evolveum.midpoint.web.page.admin.certification.handlers.CertGuiHandler)1 ObjectTypeGuiDescriptor (com.evolveum.midpoint.web.util.ObjectTypeGuiDescriptor)1 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)1 PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 QName (javax.xml.namespace.QName)1 RepeatingView (org.apache.wicket.markup.repeater.RepeatingView)1