IBM Enterprise Records, Version 5.1.+            

Creating a disposition schedule

/* 
This sample demonstrates how to create a disposition schedule and phase, and associate a disposition schedule with an entity such as a record category, record folder, and record type. 

For creating a disposition schedule, it is assumed that the Action object of type Cutoff is already created in the RM application. The user needs to get the ID of the Action object to be associated with the disposition schedule. 

For creating a Phase object, it is assumed that an Action object is already created. Phase Action can be of any type except Cutoff. The user needs to get the ID of the action to be associated with the phase. 

For updating the Phases associated with a disposition schedule, the user needs to pass the list of Properties Collecttion and permissions to update the phases. Each phase property collection should contain the GUID of the phase to be updated. 

*/


package test; 
import com.filenet.wcm.api.*; 
import com.filenet.wcm.api.util.*; 
import com.filenet.rm.api.*; 
import com.filenet.rm.api.util.*; 
import java.io.*; 
import java.util.Locale; 


//The SampleDisposition class demonstrates disposition schedules using the RM Java(TM) API.

public class SampleDisposition 

{ 
   public static void main(String args[]) 
   { 
      SampleDisposition loDisp = new SampleDisposition(); 


      //getRMObjectStore 
      RMObjectStore loRMStore = loDisp.getRMObjectStore(); 



      //create a disposition schedule 

      DispositionSchedule loSchedule = loDisp.createDispositionSchedule(loRMStore); 



      // creating and associating phase to disposition schedule 

      RMCustomObject loCustObj = loDisp.createPhase(loRMStore, loSchedule); 



      //Updating the Phase name

      loDisp.UpdatePhaseNames(loSchedule, newString[]{"newPhase1"});


      //Adds the disposition schedule to a RecordCategory object
      //Getting reference to an existing RecordCategory object
      RecordCategory loRecCategory = 
         (RecordCategory)loRMStore.getObject(RMType.RM_TYPE_RECORDCATEGORY, "???"); 

      // Adds the disposition schedule to the RecordCategory object
      loRecCategory.allocateDisposalSchedule(loSchedule); 

      //property "Disposition Instruction" 
      System.out.println("Disposition Ends Here"); 
   } 

   //Creates and returns the DispositionSchedule object on the given RMObjectStore
   public DispositionSchedule createDispositionSchedule(RMObjectStore aoRMOS) 
   { 
      DispositionSchedule loDispSchedule = null; 
      RMCustomObject loRMCustObj = getAction(aoRMOS, "{21BD9BD9-2924-4890-A3B8-DDB67B66BF62}"); 
      Properties loProperties = getDispositionScheduleProperties(loRMCustObj); 
      loDispSchedule = aoRMOS.createDispositionSchedule(loProperties, null); 
      return loDispSchedule; 
   } 

   //Creates and returns Phase objects associated with a disposition schedule in an RMObjectStore
   public RMCustomObject createPhase(RMObjectStore aoRMOS, DispositionSchedule aoDispSchedule) 
   { 
      RMCustomObject loPhase = null; 
      RMCustomObject loRMCustObj = getAction(aoRMOS, "{11B5D663-5E5C-4E04-B862-5934FAF13D42}"); 
      Properties loProperties = getPhaseProperties(loRMCustObj); 
      loPhase = aoDispSchedule.createPhasewithAlternateRetention(loProperties, null, null); 
      return loPhase; 
   }

   public RMObjectStore getRMObjectStore() 
   { 
      RMObjectStore loRMStore=null; 

      //Getting connecting session for the server on which it is installed 
      Session loSession = this.getSession(); 
      ObjectStore loStore = ObjectFactory.getObjectStore("DOD21042004", loSession); 
      RMUtil loUtil = new RMUtil(); 

      // Converting the object store to RM object store that supports FPOS 
      loRMStore = loUtil.getRMObjectStore(loStore); 
      return loRMStore; 
   } 

   //Returns the minimum disposition properties that are required for disposition schedule. 
   //These properties are DisposalScheduleName, DisposalScheduleStartDate(Proposed), and 
   //DisposalScheduleCutoffAction
   private Properties getDispositionScheduleProperties(RMCustomObject aoRMCustObj) 
   { 
      Properties loProps = ObjectFactory.getProperties(); 
      Property loCalProp = ObjectFactory.getProperty(RMProperty.CALENDAR_DATE); 
      loCalProp.setValue(new java.util.Date()); 
      loProps.add(loCalProp);

      Property loNameProp = ObjectFactory.getProperty(RMProperty.DISPOSAL_SCHEDULE_NAME); 
      loNameProp.setValue("Disposal_Schedule"); 
      loProps.add(loNameProp); 

      Property loActionProp = ObjectFactory.getProperty(RMProperty.CUTOFF_ACTION); 
      loActionProp.setValue(aoRMCustObj.thisBaseObject()); 
      loProps.add(loActionProp); 
      return loProps; 
   } 

   //Returns the minimum phase properties that are required for creating a Phase object. 
   //These properties are phase name, phase action and, phase ID.
   private Properties getPhaseProperties(RMCustomObject aoRMCustObj) 
   { 
      Properties loProps = ObjectFactory.getProperties(); 
      Property loNameProp = ObjectFactory.getProperty(RMProperty.PHASE_NAME); 
      loNameProp.setValue("Phase"); 
      loProps.add(loNameProp); 

      Property loActionProp = ObjectFactory.getProperty(RMProperty.PHASE_ACTION); 
      loActionProp.setValue(aoRMCustObj.thisBaseObject()); 
      loProps.add(loActionProp); 
      return loProps; 
   } 

   // Sample code to update the Phases.
   // Updates the Phase names associated with the Disposition Schedule.
   public void updatePhaseNames(DispositionSchedule aoSchedule, string[] aoNewPhaseNames) 
   {
      RMCustomObjects phases = aoschedule.getPhases();
      Iterator it = phases.iterator();

      if (!it.hasNext())
      {
         System.out.printIn("Schedule does not have phase.");
         return;
      } 

      java.util.List list = new java.util.ArrayList();
      int i = 0;

      while (it.hasNext()) 
      {
         String phaseGUID = ((RMCustomObject)it.next()).getId();
         Properties loProps = ObjectFactory.getProperties(); 

         // phase ID
         Property loIDProp = ObjectFactory.getProperty(RMProperty.ID); 
         loIDProp.setValue(phaseGUID); 
         loProps.add(loIDProp); 

         // phase name
         Property loNameProp = ObjectFactory.getProperty(RMProperty.PHASE_NAME); 
         loNameProp.setValue(aoNewphaseNames[i]); 
         loProps.add(loNameProp); 

         list.add(loProps);
         list.add (loProps) 
      } 

      // permissions
      com.filenet.wcm.api.Permissions perms = ObjectFactory.getPermissions();
      schedule.updatePhases(list, perms);
   }

   //Returns an Action object for the given action ID in RMObjectStore. 
   private RMCustomObject getAction(RMObjectStore aoRMOS, String asActionId) 
   { 
      RMCustomObject loCustObject = null; 
      loCustObject = (RMCustomObject)aoRMOS.getObject(RMType.RM_TYPE_ACTION, asActionId); 
      return loCustObject; 
   } 

   //Returns a DispositionSchedule object for the given disposition schedule ID in RMObjectStore. 
   private DispositionSchedule getDispositionSchedule(RMObjectStore aoRMOS, String asDispositionId) 
   { 
      DispositionSchedule loCustObject = null; 
      loCustObject = (DispositionSchedule) aoRMOS.getObject(RMType.RM_TYPE_DISPOSALSCHEDULE, asDispositionId); 
      return loCustObject; 
   } 

   /** 
   * Returns a Session object for the server where the Content Engine (CE) server is installed. 
   * For creating a session, the WcmAPIConfig.properties file should be present in the classpath. 
   * This file contains entries for the server where the CE Server is installed. 
   */ 
   private Session getSession() 
   { 
      String lsUserId = "??"; 
      String lsPassword = "??"; 
      String lsDomain = "??"; 
      String lsAppId = "??"; 
      Session loSession = ObjectFactory.getSession(lsAppId, null, lsUserId, lsPassword, lsDomain); 
      loSession.verify(); 
      return loSession; 
   } 
}


Feedback

Last updated: August 2011


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