如何在 FileNet P8 中获取属性数据类型

Arj*_*jun 2 java filenet-p8

在 FileNet P8 中,我需要使用 JAVA API 获取自定义类的属性的数据类型。有没有办法做同样的事情?

Chr*_*ell 6

这应该让您了解您需要做什么:

    //SymbolicName of the property we will search for.
    String strSearchName = PropertyNames.DATE_LAST_MODIFIED;
    //Document (or other object) that we will use to get classDescription.
    Document document = (Document) arg0; 

    PropertyDescription objPropDesc = null;
    PropertyDescriptionList pdl = document.get_ClassDescription().get_PropertyDescriptions();
    Iterator<?> iter = pdl.iterator();
    while (iter.hasNext())
    {                                               
        objPropDesc = (PropertyDescription) iter.next();                      

       // Get SymbolicName property from the property cache
       String strPropDescSymbolicName = objPropDesc.get_SymbolicName();

       if (strPropDescSymbolicName.equalsIgnoreCase(strSearchName))
       {
          // PropertyDescription object found
          System.out.println("Property description selected: " + strPropDescSymbolicName);
          System.out.println(objPropDesc);

          TypeID type = objPropDesc.get_DataType();
          System.out.println(type.toString());
          break;
       }
    }
Run Code Online (Sandbox Code Playgroud)

这个想法是:

  1. 取一个对象(在本例中为 Document)。
  2. 获取它的类描述。
  3. 从类描述中获取属性描述列表。
  4. 循环遍历属性描述,直到找到要查找的描述。
  5. 从属性描述中获取 TypeId。
  6. TypeId 包含您需要了解属性的类型的信息。

我从这里借用了代码:使用属性

您还应该熟悉这一点:属性

编辑以添加不同的方法:

在创建文档的情况下,我们需要能够获取到 Class Description 对象。这意味着我们需要执行额外的往返。

// Get the ClassDescription
String strSymbolicName = "myClassName";
ClassDescription objClassDesc = Factory.ClassDescription.fetchInstance(myObjStore, strSymbolicName, null);

// find the PropertyDescription     
PropertyDescription pds = null;
PropertyDescriptionList pdl = objClassDesc.get_PropertyDescriptions()??;
Iterator<?> itr = pdl.iterator();
while(itr.hasNext()){ 
    pds = (PropertyDescription) itr.next();
    System.out.println("Symbolic Name is "+pds.get_SymbolicName()+" DataType is "+pds.get_DataType().toString()); 
}

// You can now use it in a loop of several documents if you wish.
...
Run Code Online (Sandbox Code Playgroud)

也看看这里:使用类