IBM Enterprise Records, Version 5.1.2    

Setting property value for an existing record

Sample code for setting property value using the RM Java API is available for you to use.

/*
To set a property on a record, create a new properties collection and populate it with 
new property instances which have been set with the new property values. Then store this 
new properties collection onto the record.


The following example code demonstrates this process by updating both a Record Category 
and a Record with new DateTime-type properties.


RM API is built on top of the older Content Platform Engine 3.x Java API. 
In the Content Platform Engine 4.x environment, the software uses the "Content JAVA Compatibility Layer API" 
which is built on top of the newer Content Platform Engine 4.x Java API For Content Platform Engine.
*/

package test;
// Import the required classes
import java.util.Date;
import com.filenet.rm.api.*;
import com.filenet.rm.api.util.RMUtil;
import com.filenet.wcm.api.*;

/**
 * Simple example class on how to set a DateTime property
 * on both Record and Record Category objects using the 
 * FileNet Records Manager API.
 */
public class TestSetProperties
{
    public static final String FPOS_NAME    = "FPOS_WAS_450_BASE";
    public static final String REC_CAT_PATH = "/Records Management/File Plan/BDSUnitTest_TopCat";
    public static final String REC_CAT_ID   = "{4038F133-DF48-48C1-83FC-248A4D228EAE}";
    public static final String RECORD_PATH  = "/Records Management/File Plan/BDSUnitTest_TopCat/ElectRec_072943.515";
    public static final String RECORD_ID    = "{F459C2B6-F8FD-4F72-64AC-CAC3EA61356C}";
    
    public static final String USERNAME     = "rangelj";
    public static final String PASSWORD     = "monkey1";
    
    /**
     * Main entry point method
     *
     * @param args  (not used)
     */
    public static void main(String[] args)
    {

        // Initialize a Session object to connect to the CE server. Connection information
        //  for the particular CE server is contained in the associated WcmApiConfig.properties file.

        Session session = ObjectFactory.getSession("TestApp", null, USERNAME, PASSWORD);
        session.verify();

        // Create an instance of the required FPOS in which the declaration is to be done.
        ObjectStore fposBase = ObjectFactory.getObjectStore(FPOS_NAME, session);

        // Convert this base ObjectStore instance into an RMAPI RMObjectStore.
        RMObjectStore fpos   = RMUtil._getRMObjectStore(fposBase);
        
        // Retrieve the base BCL Folder that represents the RecordCategory.
        //  The software is using the full path of the RecordCategory; could use its ID string instead.
        //  (Note that a RecordFolder or Volume can be acquired in the same manner).
        Folder recCatBase     = (Folder)(fposBase.getObject(BaseObject.TYPE_FOLDER, REC_CAT_PATH));

        // Retrieve a RecordCategory object. Convert this base Folder instance 
        //  into an Records Manager API RecordCategory.
        RecordCategory recCat = fpos.getRecordCategoryInterface(recCatBase);
        
        // Create a properties collection to create a RecordCategory object.
        Properties newRecCatProps = ObjectFactory.getProperties();
                
        // Specify the "Date of Last Review" 
        //  RecordCategory property. Note use of property's symbolic name.
        Property   dateOfLastReviewProp = ObjectFactory.getProperty("DateOfLastReview");
                
        // Specify the DateTime value to current date/time.
        dateOfLastReviewProp.setValue( new Date() );
                
        // Add this property to the Properties collection.
        newRecCatProps.add(dateOfLastReviewProp);
                
        // Additional properties can be defined, set, and added to this same
        //  Properties collection, if desired.
        
        // Now store this Properties collection on the RecordCategory. This method performs
        //  the actual persistence to the FPOS. Only the properties contained in this
        //  collection are affected on the actual Folder object residing on the ObjectStore.
        //  In other words, other properties of the Folder not mentioned in this collection
        //  are unaffected.
        recCat.setProperties(newRecCatProps);
                
        // Properties for a Record object are set in a similar manner.
        //  First get a specific record. Retrieve the RECORD_ID object with which a 
        //  Pattern object is to be associated. The software is using the Record's ID string. 
        //  The record's full path could be used instead.
        Document recordBase = (Document)(fposBase.getObject(BaseObject.TYPE_DOCUMENT, RECORD_ID));
        RecordInfo record   = fpos.getRecordInfoInterface(recordBase);
                
        // Now specify the property set/update process.
        Properties newRecordProps = ObjectFactory.getProperties();
        Property reviewDateProp   = ObjectFactory.getProperty("ReviewDate");
        reviewDateProp.setValue( new Date() );
        newRecordProps.add(reviewDateProp);
        record.setProperties(newRecordProps);
    }

}


Feedback

Last updated: November 2013
ierdg060.htm

© Copyright IBM Corporation 2013