gpt4 book ai didi

java - 如何获取FileNet P8中的属性数据类型

转载 作者:行者123 更新时间:2023-12-02 15:29:15 28 4
gpt4 key购买 nike

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

最佳答案

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

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

这个想法是:

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

我从这里借用了代码:Working with Properties

您还应该熟悉这一点:Properties

编辑以添加不同的方法:

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

// 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.
...

也看看这里:Working With Classes

关于java - 如何获取FileNet P8中的属性数据类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40023937/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com