Wednesday, 11 May 2016

Java Sample for Retrieving collections of individual classes meta data and individual properties meta data (FileNet Content Engine API)

// Java Sample for Retrieving collections of individual classes meta data and individual properties meta data (FileNet Content Engine API)

public void FetchPropClassDesc(Connection conn) {

try {
Domain domain = Factory.Domain.fetchInstance(conn, null, null);
ObjectStore objStore = Factory.ObjectStore.fetchInstance(domain,"OSNAME", null);


/*
ClassDescription Are collections of metadata that describe individual classes
Provide access to PropertyDescriptionobjects associated with class 
Return default permission for an object of a particular class
Determine if versioning is enabled for a particular Document class
Assign a document lifecycle policy to a document class or subclassRetrieve
*/

ClassDescriptionSet classDescriptions= objStore.get_ClassDescriptions();
ClassDescription classDesc;
Iterator it = classDescriptions.iterator();
while (it.hasNext()) 
{
classDesc= (ClassDescription)it.next();
System.out.println("Class name = " + classDesc.get_DisplayName());

}

PropertyFilter pf= new PropertyFilter();
pf.addIncludeType(0, null, null, FilteredPropertyType.ANY,1);
Document document=Factory.Document.fetchInstance(objStore, new Id("{08CA2852-111B-4E5D-B032-DBG2A653B4FD}"), pf);
String documentName= document.get_Name();
System.out.println(documentName+ " Document has been retrieved");


com.filenet.api.meta.ClassDescription classDescription= document.get_ClassDescription();
/*
Are collections of metadata that describe individual properties
Are contained in the ClassDescriptionPropertyDescriptionsproperty
Provide information on how the property needs to be represented to the user
Contain information such as choice lists 
Each instance of a PropertyDescription object describes a specific property for a single class
*/

PropertyDescriptionList propDescs= classDescription.get_PropertyDescriptions();
PropertyDescription propDesc; 
Iterator propIt= propDescs.iterator();
while (propIt.hasNext()) 
{
propDesc=(PropertyDescription)propIt.next();

System.out.println("Property name = " +propDesc.get_SymbolicName()); 
//get_SymbolicName(): A String thatrepresents the programmatic identifier for this PropertyDescription

System.out.println("Read only? " + propDesc.get_IsReadOnly().toString()); 
//get_IsReadOnly(): A Boolean value that indicates whether or not you can modify the value of the property. If true, the property value can be changed only by the server

System.out.println("Value of Property" + propDesc.get_Settability()); 
//get_Settability(): A constant that indicates when the value of a property can be setRetrieve (READ_ONLY-3, READ_WRITE-0, SETTABLE_ONLY_BEFORE_CHECKIN-1, SETTABLE_ONLY_ON_CREATE)

System.out.println("Is Value Required ? "+propDesc.get_IsValueRequired()); 
//get_IsValueRequired(): A Boolean value that indicates whether the property is required to have a value (true) or not (false)

System.out.println("Cardinality = " + propDesc.get_Cardinality()); 
//get_Cardinality() :A constant that indicates the cardinality of the PropertyDescription (ENUM-1, LIST-2, SINGLE-0)

System.out.println(""+propDesc.get_IsSystemGenerated());
/*get_IsSystemGenerated(): A Boolean value that indicates whether the property has its value set automatically by the Content Engine server (true) or not (false). 
If the value is true, the described property does one of the following:
Provides system information
Has its value determined by the server
*/

}

} catch (Exception e) {
e.printStackTrace();
}
}

No comments:

Post a Comment