Exemplo n.º 1
0
  private boolean isShadowAssociation() {
    if (!ShadowType.class.isAssignableFrom(getObject().getObject().getCompileTimeClass())) {
      return false;
    }

    if (!ShadowType.F_ASSOCIATION.equals(container.getElementName())) {
      return false;
    }

    return true;
  }
Exemplo n.º 2
0
  private List<ContainerWrapper> createCustomContainerWrapper(
      PrismObject object, QName name, PageBase pageBase) {
    PrismContainer container = object.findContainer(name);
    ContainerStatus status = container == null ? ContainerStatus.ADDING : ContainerStatus.MODIFYING;
    List<ContainerWrapper> list = new ArrayList<ContainerWrapper>();
    if (container == null) {
      PrismContainerDefinition definition = getDefinition().findContainerDefinition(name);
      container = definition.instantiate();
    }

    ContainerWrapper wrapper =
        new ContainerWrapper(this, container, status, new ItemPath(name), pageBase);
    addSubresult(wrapper.getResult());
    list.add(wrapper);
    // list.addAll(createContainerWrapper(container, null, pageBase));
    if (!ShadowType.F_ASSOCIATION.equals(name)) {
      // [pm] is this OK? "name" is the name of the container itself; originally here was an empty
      // path - that seems more logical
      list.addAll(createContainerWrapper(container, new ItemPath(name), pageBase));
    }

    return list;
  }
Exemplo n.º 3
0
  private List<ContainerWrapper> createContainerWrapper(
      PrismContainer parent, ItemPath path, PageBase pageBase) {

    PrismContainerDefinition definition = parent.getDefinition();
    List<ContainerWrapper> wrappers = new ArrayList<ContainerWrapper>();

    List<ItemPathSegment> segments = new ArrayList<ItemPathSegment>();
    if (path != null) {
      segments.addAll(path.getSegments());
    }
    ItemPath parentPath = new ItemPath(segments);
    for (ItemDefinition def : (Collection<ItemDefinition>) definition.getDefinitions()) {
      if (!(def instanceof PrismContainerDefinition)) {
        continue;
      }
      if (ObjectSpecificationType.COMPLEX_TYPE.equals(def.getTypeName())) {
        continue; // TEMPORARY FIX
      }
      if (TriggerType.COMPLEX_TYPE.equals(def.getTypeName())) {
        continue; // TEMPORARY FIX TODO: remove after getEditSchema
        // (authorization) will be fixed.
      }
      if (ApprovalSchemaType.COMPLEX_TYPE.equals(def.getTypeName())) {
        continue;
      }

      LOGGER.trace("ObjectWrapper.createContainerWrapper processing definition: {}", def);

      PrismContainerDefinition containerDef = (PrismContainerDefinition) def;
      if (!showAssignments && AssignmentType.COMPLEX_TYPE.equals(containerDef.getTypeName())) {
        continue;
      }
      if (!showInheritedObjectAttributes) {
        boolean result = INHERITED_OBJECT_SUBCONTAINERS.contains(containerDef.getName());
        LOGGER.info("checking " + containerDef.getName() + ", result = " + result);
        if (result) {
          continue;
        }
      }

      ItemPath newPath = createPropertyPath(parentPath, containerDef.getName());

      // [med]
      // The following code fails to work when parent is multivalued or
      // potentially multivalued.
      // Therefore (as a brutal hack), for multivalued parents we simply
      // skip it.
      if (parent.size() <= 1) {

        // the same check as in getValue() implementation
        boolean isMultiValued =
            parent.getDefinition() != null
                && !parent.getDefinition().isDynamic()
                && !parent.getDefinition().isSingleValue();
        if (!isMultiValued) {
          PrismContainer prismContainer = parent.findContainer(def.getName());

          ContainerWrapper container;
          if (prismContainer != null) {
            container =
                new ContainerWrapper(
                    this, prismContainer, ContainerStatus.MODIFYING, newPath, pageBase);
          } else {
            prismContainer = containerDef.instantiate();
            container =
                new ContainerWrapper(
                    this, prismContainer, ContainerStatus.ADDING, newPath, pageBase);
          }
          addSubresult(container.getResult());
          wrappers.add(container);

          if (!AssignmentType.COMPLEX_TYPE.equals(containerDef.getTypeName())
              || !ShadowType.F_ASSOCIATION.equals(parent.getElementName())) { // do
            // not
            // show
            // internals
            // of
            // Assignments
            // (e.g.
            // activation)
            wrappers.addAll(createContainerWrapper(prismContainer, newPath, pageBase));
          }
        }
      }
    }

    return wrappers;
  }