IBM Enterprise Records, Version 5.1.+            

Associating a RecordType object with a RecordInfo object

After you create a RecordType object, you can associate it with a RecordInfo object by calling the allocateRecordType method on a RecordInfo object and passing in the RecordType object. For example:
//Associates a RecordType object with a RecordInfo object 
public void associateRecordType(RecordInfo aoRecordInfo, RecordType aoRecordType) 
{ 
   aoRecordInfo.allocateRecordType (aoRecordType); 
} 
You can also associate a RecordType object with a RecordInfo object using the setProperties method, as shown in the following code snippet:
//Associates the RecordType object with the RecordInfo object using the setProperties method
public void associateRecordType(RecordInfo aoRecordInfo, RecordType aoRecordType)
{
   Properties loProperties = ObjectFactory.getProperties();
   Property loRTProperty = ObjectFactory.getProperty(RMProperty.ASSOCIATED_RECORDTYPE);
   
   // Always use the thisBaseObject method while setting any object-valued property.
   // For example, set the object-valued property, and with RecordType
   // that is a custom object
   loRTProperty.setValue(aoRecordType.thisBaseObject());
   loProperties.add(loRTProperty);
   aoRecordInfo.setProperties(loProperties);
}   

Besides these two methods, you can also associate a RecordType object with a record at the time of record declaration by passing the RecordType property in properties collection.



Feedback

Last updated: August 2011


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