IBM Enterprise Records, Version 5.1.+            

Retrieving and setting object properties

All RM objects extend the ReadableMetadataObject interface of the Content Java™ API, and as a result you can retrieve properties just as you would for properties defined in the Content Java API (see "Retrieving Properties" in the Help for Content Java API.). That is, you can use the getProperties method. This method takes a string array that identifies the properties to return. If you pass in an empty array or a null, all readily available properties of that object are returned. To view the collection of properties as an XML string, use the getPropertiesXML method, as shown in the following code snippet.
// Retrieves the properties for a ObjectStore named
// SampleObjectStore as a String value in XML format.
String getDateCreatePropertyAsXML(Session aoSession)
{
   ObjectStore loStore = 
      ObjectFactory.getObjectStore("SampleObjectStore", aoSession); 
   RMUtil loUtil = new RMUtil();
   RMObjectStore loRMObjectStore = loUtil.getRMObjectStore(loStore); 
   String lsPropertiesXML = 
      loRMRMObjectStore.getPropertiesXML(new String[]{RMProperty.DATE_CREATED}); 
   return lsPropertiesXML; 
}
You can set properties for objects that extend the WriteableMetadataObject interface of the Content Java API (see "Setting Properties" in the Help for Content Java API for more information). All the RM Java API objects except RMObjectStore extend the WriteableMetadataObject interface. As a result, you can set properties of all objects (except RMObjectStore) using the setProperties method. This method sets the properties of an entity and persists the changes to the object store. This method takes a Properties collection that contains the Property objects to be persisted.
// Sets the name for an electronic record folder 
// whose ID is passed to the function 
void setNameForFolder(RMObjectStore aoRMStore, String asFolderId) 
{ 
   RecordFolder loRMObj =
      (RecordFolder)aoRMStore.getObject(RMType.RM_TYPE_ELECTRONICRECORDFOLDER, asFolderId); 

   Properties loProperties = ObjectFactory.getProperties(); 
   Property loName = ObjectFactory.getProperty(RMProperty.FOLDER_NAME); 
   loName.setValue("NewRMFolder"); 
   loProperties.add(loName); 
   loRMObj.setProperties(loProperties); 
}
Note: If you set an object-valued property, cast the object to thisBaseObject. See Associating a RecordType object with a RecordInfo object for a code snippet that sets an object-valued property.


Feedback

Last updated: August 2011


© Copyright IBM Corporation 2011.
This information center is powered by Eclipse technology. (http://www.eclipse.org)