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;
}
Aggregations