Friday, December 10, 2010

Updating the Scheduled task attribute in OIM


public void updateSchedulerTimeStamp(String currentTime)
    {
        String methodName = "updateSchedulerTimeStamp";
      //  logger.setMethodStartLog(sClassName, s1);
        String s2 = "Enterprise User Target Recon";
        try
        {
            HashMap hashmap = new HashMap();
            hashmap.put("Task Scheduler.Name", s2);
            tcSchedulerOperationsIntf tcSchOper = (tcSchedulerOperationsIntf) getUtility("Thor.API.Operations.tcSchedulerOperationsIntf");
            tcResultSet tcresultset = tcSchOper.findScheduleTasks(hashmap);
            if(tcresultset != null && tcresultset.getRowCount() > 0)
            {
                 
                   logger.debug(className, methodName, "UPDATE TIME STAMP---->Result set has values");
                tcresultset.goToRow(0);
                long l = tcresultset.getLongValue("Task Scheduler.Key");
                logger.debug(className, methodName, "UPDATE TIME STAMP---->Result set has values");
                String s3 = String.valueOf(l);
                //Task Scheduler.Task Attributes.Key logger.debug(className, methodName, "UPDATE TIME STAMP----->Task Scheduler key"+s3);
                hashmap.clear();

                hashmap.put("Task Scheduler.Key", s3);
            
                hashmap.put("Task Scheduler.Task Attributes.Name", "LastRunDate");
                logger.debug(className, methodName, "UPDATE TIME STAMP-----> HashMap is "+hashmap);
                tcResultSet tcresultset1 = tcSchOper.findScheduleTaskAttributes(hashmap);
                if(tcresultset1 != null && tcresultset1.getRowCount()>0){
                  tcresultset1.goToRow(0);
                    long l1 = tcresultset1.getLongValue("Task Scheduler.Task Attributes.Key");
                    logger.debug(className, methodName, "UPDATE TIME STAMP----->Task Scheduler Attribute key "+l1);
                    hashmap.put("Task Scheduler.Task Attributes.Value", currentTime);
                    logger.debug(className, methodName, "UPDATE TIME STAMP----->Current Time is "+currentTime);
                    tcSchOper.updateScheduleTaskAttribute(l, l1, hashmap);   
                }
                else{
                  logger.debug(className, methodName, "UPDATE TIME STAMP----->Could not find any values for the scheduler attributes");
                }
               
            }
        }
        catch(tcAPIException tcapiexception)
        {
            logger.error(className, methodName, tcapiexception.getMessage());
            logger.setStackTrace(tcapiexception, className, methodName, tcapiexception.getMessage());
        }
        catch(tcColumnNotFoundException tccolumnnotfoundexception)
        {
            logger.error(className, methodName, tccolumnnotfoundexception.getMessage());
            logger.setStackTrace(tccolumnnotfoundexception, className, methodName, tccolumnnotfoundexception.getMessage());
        }
        catch(tcScheduledTaskNotFoundException tcscheduledtasknotfoundexception)
        {
            logger.error(className, methodName, tcscheduledtasknotfoundexception.getMessage());
            logger.setStackTrace(tcscheduledtasknotfoundexception, className, methodName, tcscheduledtasknotfoundexception.getMessage());
        }
        catch(tcNoSuchTaskAttributeException tcnosuchtaskattributeexception)
        {
            logger.error(className, methodName, tcnosuchtaskattributeexception.getMessage());
            logger.setStackTrace(tcnosuchtaskattributeexception, className, methodName, tcnosuchtaskattributeexception.getMessage());
        }
        logger.setMethodFinishLog(className, methodName);
    }
     

3 comments:

  1. Hi,

    thanks for your post. I'm unable to find the interface you mentioned Thor.API.Operations.tcSchedulerOperationsIntf in my libraries. can you please tell me in which jar you have this interface? i'm using OIM 903 apis

    ReplyDelete
    Replies
    1. Hi Ravi,

      You should find the scheduler related api in xlscheduler.jar. Let me know if you can find in there.

      Thanks,
      Vishnu

      Delete
    2. Hi friends, could u plz share java code for "how to write custom scheduled task in oim 9.1". Thanks, N Krishna.

      Delete