如何通过符号名称获取 PropertyTemplate 并附加到自定义对象 class IBM FileNet CE API

How to fetch the PropertyTemplate by symbolic name and appended to Custom Object class IBM FileNet CE API

如何通过 IBM FileNet CE API

通过符号名称获取 PropertyTemplate 并附加到自定义对象 class

您可以使用以下函数获取 属性 模板:

public PropertyTemplate getPropertyTemplate(String name, ObjectStore objectStore ) 
{
    String queryFormat = "SELECT [This] FROM [PropertyTemplate] WHERE ([SymbolicName] = ''{0}'')";      
    SearchScope scope = new SearchScope( objectStore );
    String query = MessageFormat.format(queryFormat, name );
    RepositoryRowSet fetchRows = scope.fetchRows(new SearchSQL( query ), null, null, null );
    Iterator<?> iterator = fetchRows.iterator();
    if ( !iterator.hasNext() )
    {
        return null;
    }

    RepositoryRow row = (RepositoryRow) iterator.next();
    return (PropertyTemplate) row.getProperties().getObjectValue("This");
}

然后使用以下代码将属性模板添加到class:


PropertyTemplate propertyTemplate = getPropertyTemplate(name, objectStore);
ClassDefinition classDefinition = Factory.ClassDefinition.fetchInstance(objectStore, className, null);
PropertyDefinition propertyDefinition = propertyTemplate.createClassProperty();

// Set some additional properties on the property definition 
// to override template defaults

classDefinition.get_PropertyDefinitions().add(propertyDefinition);
classDefinition.save(RefreshMode.NO_REFRESH);