コード例 #1
0
  private AssignmentItemDto createAssignmentItem(
      PrismObject<UserType> user,
      PrismContainerValue assignment,
      Task task,
      OperationResult result) {
    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 = null;
      if (construction.getValue().asContainerable() != null && !construction.isEmpty()) {
        ConstructionType constr = (ConstructionType) construction.getValue().asContainerable();
        description =
            (String)
                construction.getPropertyRealValue(ConstructionType.F_DESCRIPTION, String.class);

        if (constr.getResourceRef() != null) {
          ObjectReferenceType resourceRef = constr.getResourceRef();

          PrismObject resource =
              WebModelUtils.loadObject(
                  ResourceType.class, resourceRef.getOid(), this, task, result);
          name = WebMiscUtil.getName(resource);
        }
      }

      return new AssignmentItemDto(
          AssignmentEditorDtoType.ACCOUNT_CONSTRUCTION, name, description, null);
    }

    PrismReferenceValue refValue = targetRef.getValue();
    PrismObject value = refValue.getObject();
    if (value == null) {
      // resolve reference
      value = WebModelUtils.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 = WebMiscUtil.getName(value);
    AssignmentEditorDtoType type = AssignmentEditorDtoType.getType(value.getCompileTimeClass());
    String relation = refValue.getRelation() != null ? refValue.getRelation().getLocalPart() : null;
    String description = null;
    if (RoleType.class.isAssignableFrom(value.getCompileTimeClass())) {
      description = (String) value.getPropertyRealValue(RoleType.F_DESCRIPTION, String.class);
    }

    return new AssignmentItemDto(type, name, description, relation);
  }
コード例 #2
0
  @Override
  public String getCaseInfoButtonTitle(
      IModel<? extends CertCaseOrDecisionDto> rowModel, PageBase page) {
    CertCaseOrDecisionDto dto = rowModel.getObject();
    AccessCertificationCaseType _case = dto.getCertCase();
    if (!(_case instanceof AccessCertificationAssignmentCaseType)) {
      return null; // should not occur, TODO treat gracefully
    }
    AccessCertificationAssignmentCaseType assignmentCase =
        (AccessCertificationAssignmentCaseType) _case;
    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(_case.getTargetRef().getType(), page);
    String targetName = dto.getTargetName();
    String objectType = getLocalizedTypeName(_case.getObjectRef().getType(), page);
    String objectName = dto.getObjectName();

    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 (_case.getTargetRef().getRelation() != null) {
      infoList.add(
          page.createStringResource(
                  "PageCert.message.textRelation",
                  _case.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;
  }