コード例 #1
0
ファイル: JcrTypeManager.java プロジェクト: Digt/TrustedNet
  /** Adds a type to collection. */
  private void addTypeInternal(AbstractTypeDefinition type) {
    if (type == null) {
      return;
    }

    TypeDefinitionContainerImpl tc = new TypeDefinitionContainerImpl();
    tc.setTypeDefinition(type);

    // add to parent
    if (type.getParentTypeId() != null) {
      TypeDefinitionContainerImpl tdc = fTypes.get(type.getParentTypeId());
      if (tdc != null) {
        if (tdc.getChildren() == null) {
          tdc.setChildren(new ArrayList<TypeDefinitionContainer>());
        }
        tdc.getChildren().add(tc);
      }
    }

    fTypes.put(type.getId(), tc);
  }
コード例 #2
0
ファイル: JcrTypeManager.java プロジェクト: Digt/TrustedNet
  /**
   * Adds a type to collection with inheriting base type properties.
   *
   * @param type type to add
   * @return <code>true</code> iff the type was successfully added
   */
  public boolean addType(TypeDefinition type) {
    if (type == null) {
      return false;
    }

    if (fTypes.containsKey(type.getId())) {
      // can't overwrite a type
      return false;
    }

    AbstractTypeDefinition newType = (AbstractTypeDefinition) copyTypeDefinition(type);

    if (!newType.getBaseTypeId().value().equals(newType.getId())) {

      // find base type
      TypeDefinition baseType;
      if (newType.getBaseTypeId() == BaseTypeId.CMIS_DOCUMENT) {
        baseType = copyTypeDefinition(fTypes.get(DOCUMENT_TYPE_ID).getTypeDefinition());
      } else if (newType.getBaseTypeId() == BaseTypeId.CMIS_FOLDER) {
        baseType = copyTypeDefinition(fTypes.get(FOLDER_TYPE_ID).getTypeDefinition());
      } else if (newType.getBaseTypeId() == BaseTypeId.CMIS_RELATIONSHIP) {
        baseType = copyTypeDefinition(fTypes.get(RELATIONSHIP_TYPE_ID).getTypeDefinition());
      } else if (newType.getBaseTypeId() == BaseTypeId.CMIS_POLICY) {
        baseType = copyTypeDefinition(fTypes.get(POLICY_TYPE_ID).getTypeDefinition());
      } else {
        return false;
      }

      // copy property definition
      for (PropertyDefinition<?> propDef : baseType.getPropertyDefinitions().values()) {
        ((AbstractPropertyDefinition<?>) propDef).setIsInherited(true);
        newType.addPropertyDefinition(propDef);
      }
    }

    // add it
    addTypeInternal(newType);

    log.info("Added type '" + newType.getId() + "'.");

    return true;
  }
コード例 #3
0
ファイル: JcrTypeManager.java プロジェクト: Digt/TrustedNet
  public static void addBasePropertyDefinitions(AbstractTypeDefinition type) {
    type.addPropertyDefinition(
        createPropDef(
            PropertyIds.BASE_TYPE_ID,
            "Base Type Id",
            "Base Type Id",
            PropertyType.ID,
            Cardinality.SINGLE,
            Updatability.READONLY,
            false,
            true));

    type.addPropertyDefinition(
        createPropDef(
            PropertyIds.OBJECT_ID,
            "Object Id",
            "Object Id",
            PropertyType.ID,
            Cardinality.SINGLE,
            Updatability.READONLY,
            false,
            true));

    type.addPropertyDefinition(
        createPropDef(
            PropertyIds.OBJECT_TYPE_ID,
            "Type Id",
            "Type Id",
            PropertyType.ID,
            Cardinality.SINGLE,
            Updatability.ONCREATE,
            false,
            true));

    type.addPropertyDefinition(
        createPropDef(
            PropertyIds.NAME,
            "Name",
            "Name",
            PropertyType.STRING,
            Cardinality.SINGLE,
            Updatability.READWRITE,
            false,
            true));

    type.addPropertyDefinition(
        createPropDef(
            PropertyIds.CREATED_BY,
            "Created By",
            "Created By",
            PropertyType.STRING,
            Cardinality.SINGLE,
            Updatability.READONLY,
            false,
            true));

    type.addPropertyDefinition(
        createPropDef(
            PropertyIds.CREATION_DATE,
            "Creation Date",
            "Creation Date",
            PropertyType.DATETIME,
            Cardinality.SINGLE,
            Updatability.READONLY,
            false,
            true));

    type.addPropertyDefinition(
        createPropDef(
            PropertyIds.LAST_MODIFIED_BY,
            "Last Modified By",
            "Last Modified By",
            PropertyType.STRING,
            Cardinality.SINGLE,
            Updatability.READONLY,
            false,
            true));

    type.addPropertyDefinition(
        createPropDef(
            PropertyIds.LAST_MODIFICATION_DATE,
            "Last Modification Date",
            "Last Modification Date",
            PropertyType.DATETIME,
            Cardinality.SINGLE,
            Updatability.READONLY,
            false,
            true));

    type.addPropertyDefinition(
        createPropDef(
            PropertyIds.CHANGE_TOKEN,
            "Change Token",
            "Change Token",
            PropertyType.STRING,
            Cardinality.SINGLE,
            Updatability.READONLY,
            false,
            false));
  }