11 Replies Latest reply: Jun 26, 2012 7:50 AM by LeylaDah RSS

    Updating Scheduled Jobs fields information

    LeylaDah
      Hi Experts,

      working with OIM11g, I need to update some fields into a Scheduled Job form using the OIM APIs, have you any idea about how to do?

      Thanks
        • 1. Re: Updating Scheduled Jobs fields information
          Gyanprakash Pandey
          Refer APIs below:
          http://docs.oracle.com/cd/E17904_01/apirefs.1111/e17334/oracle/iam/scheduler/vo/JobDetails.html
          http://docs.oracle.com/cd/E17904_01/apirefs.1111/e17334/oracle/iam/scheduler/api/SchedulerService.html

          I haven't used them to set the parameters of scheduled job but I think these can be used to obtain the same.

          regards,
          GP
          • 2. Re: Updating Scheduled Jobs fields information
            LeylaDah
            Well, actually I'm working already on those API, I'm able to get back the Job details with all its fields, but I'm not able to push back my information to the Job..
            • 3. Re: Updating Scheduled Jobs fields information
              Gyanprakash Pandey
              Did you try something like this?

              SchedulerService ss = Platform.getservice(SchedulerService.class);
              JobDetails jb = ss.getJobDetail(jobnameInString);
              <modify jb using setters>
              ss.updateJob(jobDetails);

              regards,
              GP
              • 4. Re: Updating Scheduled Jobs fields information
                LeylaDah
                yes, it's exactly what I'm doing, the problem is that I don't understand what I should do where you marked as "<modify jb using setters>".

                I get the ss, I get the JobDet, but I don't find any example about how to manipulate a JobParameter in order to modify a JobDetail.
                • 5. Re: Updating Scheduled Jobs fields information
                  Gyanprakash Pandey
                  you can do that like this:

                  SchedulerService ss = Platform.getservice(SchedulerService.class);
                  JobDetails jb = ss.getJobDetail(jobnameInString);
                  Hashmap <String, String> data = new Hashmap<String, String>();
                  data.add("Schedule task attribute name1","value1");
                  data.add("Schedule task attribute name2","value2");
                  data.add("Schedule task attribute name3","value3");
                  jb.setParams(data);
                  ss.updateJob(jobDetails);

                  regards,
                  GP
                  • 6. Re: Updating Scheduled Jobs fields information
                    LeylaDah
                    The problem is that the format I should provide is not "HashMap<String,String>", but "*HashMap<String,JobParameter>*".
                    The "String" is the Job Field label, while the JobParameter is the information stored into the Job Field value.
                    I'm not able to manipulate the second information, I don't understand how I should create properly the JobParameter in order to push it back to the Scheduled Job.
                    • 7. Re: Updating Scheduled Jobs fields information
                      Gyanprakash Pandey
                      In that case you can use <String, Object>. and provide appropriate values. Can you please clarify what exactly the requirement is? Because if you want to just add the attributes that is done through xml and import in MDS.

                      regards,
                      GP
                      • 8. Re: Updating Scheduled Jobs fields information
                        LeylaDah
                        I just need to set to zero the ADCS Timestamp and change (not add) dynamically the value of some parameter according to the input.
                        • 9. Re: Updating Scheduled Jobs fields information
                          madhatter
                          Leyla Dah wrote:
                          Well, actually I'm working already on those API, I'm able to get back the Job details with all its fields, but I'm not able to push back my information to the Job..
                          See here for a complete example on how to create and delete job instances programmatically:

                          http://idmclub.wikidot.com/job

                          Regards,
                          Vladimir
                          • 10. Re: Updating Scheduled Jobs fields information
                            Gyanprakash Pandey
                            You can use code here. It's for timestamp you can use it for other attributes as well:

                            void updateTimeStamp(String scheduleTaskName) {
                                      tcSchedulerOperationsIntf tcSchOperations =Platform.getService(tcSchedulerOperationsIntf.class);;
                                           SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
                                           HashMap<String, String> hashMap = new HashMap<String, String>();
                                           hashMap.put("Task Scheduler.Name", scheduleTaskName);
                                           tcResultSet resultFindScheduleTasks = tcSchOp.findScheduleTasks(hashMap);
                                           int countResultFindScheduleTasks = resultFindScheduleTasks.getRowCount();
                                           long taskSchedulerKey = resultFindScheduleTasks.getLongValue("Task Scheduler.Key");
                                           long attributeKey = 0;
                                           tcResultSet result1 = tcSchOp.getScheduleTaskAttributes(taskSchedulerKey);
                                           String[] scheduledtaskattrs = result1.getColumnNames();
                                           for (int i = 0; i < result1.getRowCount(); i++) {
                                                result1.goToRow(i);
                                                for (int j = 0; j < scheduledtaskattrs.length; j++) {
                                                     if (scheduledtaskattrs[j] .equals("Task Scheduler.Task Attributes.Name")) {
                                                          String taskname = result1 .getStringValue("Task Scheduler.Task Attributes.Name");
                                                          if (taskname.equals("LDAPTimeStamp")) {
                                                               attributeKey = result1 .getLongValue("Task Scheduler.Task Attributes.Key");
                                                               
                                                          }
                                                     }
                                                }
                                           }
                                           HashMap<String, String> updateMap = new HashMap<String, String>();
                                           updateMap.put("Task Scheduler.Task Attributes.Name", "LDAPTimeStamp");
                                           updateMap.put("Task Scheduler.Task Attributes.Value", sdf.format(new Date())+"Z");
                                           tcSchOperations .updateScheduleTaskAttribute(taskSchedulerKey, attributeKey, updateMap);

                                      }

                            regards,
                            GP
                            • 11. Re: Updating Scheduled Jobs fields information
                              LeylaDah
                              This is what I was looking for, but I got almost at the same time the solution.

                              Thank you!