Friday, February 28, 2014

SOA - Update Schedule Object

I was writing SOA code to modify schedule object, thought it will be helpful if I share....
#1. My requirement is to update a schedule object.
#2. I cannot directly update a schedule object using RAC API until unless it is a TCComponent.
#3. I searched for ScheduleManagementService from BMIDE services folder. 
#4. To establish any SOA service, we need to get the service connection by,






#5. As my requirement is to only update schedule object.
            a. Firstly, I need to get the schedule object tag.
            bI found that I can use ServiceData data =                                                          scmService.updateSchedules(updateContainer); service to update schedules.
Data is SOA service return information
updateContainer contains all information of your updated schedule object. // look into the attachment for further usage of update container.
  
Hope this is helpful....

  















// modify "is_template" attribute value to "no"...
modifySchedule(schedules,session);
private void modifySchedule(TCComponent[] schedules, TCSession session) {
// TODO Auto-generated method stub
session = (TCSession) AIFUtility.getDefaultSession();
System.out.println("**** SESSION= "+session);
ScheduleManagementService scmService = ScheduleManagementService.getService(session);
try {
for (int inx = 0; inx < schedules.length; inx++) {
        String objectName = schedules[inx].getProperty("object_name");                     
        TCComponent schedule = schedules[inx];
        AttributeUpdateContainer[] attributeContainer = new                                                                         AttributeUpdateContainer[1];
        attributeContainer[0] = new AttributeUpdateContainer();
        attributeContainer[0].attrName = "is_template";
        attributeContainer[0].attrType = 6;
        attributeContainer[0].attrValue = Boolean.toString(false);
        ObjectUpdateContainer[] updateContainer = new ObjectUpdateContainer[1];
        updateContainer[0] = new ObjectUpdateContainer();
        updateContainer[0].object = schedule;
        updateContainer[0].updates = attributeContainer;
     try {
     ServiceData data = scmService.updateSchedules(updateContainer);
     } catch (ServiceException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
     }    
     }
     } catch (TCException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
     }
}