Java Example
Task instances can only be created from subclasses of the base
CmTask
class. The following Java™ example show how to create a
subclass. Two of the system property definitions of the subclass are set with default values, and a custom property definition is added.
CmTask
// Fetch base task class definition from the server.
ClassDefinition objClassDef = Factory.ClassDefinition.fetchInstance(store, ClassNames.CM_TASK, null);
// Create subclass of the CmTask class.
ClassDefinition objSubClassDef = objClassDef.createSubclass();
// Set up locale and name subclass.
LocalizedString objLocStr = Factory.LocalizedString.createInstance();
objLocStr.set_LocalizedText("Flood Claim Task Subclass");
objLocStr.set_LocaleName(store.get_LocaleName());
objSubClassDef.set_DisplayNames(Factory.LocalizedString.createList());
objSubClassDef.get_DisplayNames().add(objLocStr);
objSubClassDef.set_SymbolicName("fcTaskSubclass");
// Set default values on PreCondition and PostCondition property definitions.
PropertyDefinitionList objPropDefs = objSubClassDef.get_PropertyDefinitions();
ListIterator iter = objPropDefs.listIterator();
PropertyDefinitionString
objPropDef = null;
String objPropDefSymbolicName = null;
// Iterate property definitions until PreCondition and PostCondition found.
for (int i=0; i < objPropDefs.size(); i++)
{
}
PropertyTemplateString objPropTemplate = Factory.PropertyTemplateString.fetchInstance
// Create property definition from property template.
objPropDef = (PropertyDefinitionString
)objPropTemplate.createClassProperty();
// Add new property definition to subclass.
objPropDefs.add(objPropDef);
// Save task subclass to the server.
objSubClassDef.save(RefreshMode.REFRESH);
http://blog.sina.com.cn/u/2003329161
原IBM网址: