Automic Workload Automation

 View Only
Expand all | Collapse all

JAVA API: Set Active/Inactive task in schedule Monitor.

  • 1.  JAVA API: Set Active/Inactive task in schedule Monitor.

    Posted Jan 06, 2017 12:23 AM

    I Would like to set Active Flag in Schedule monitor task by using JAVA API in AE V10
    Do any one has sample code or advice for this? or which class in JAVA that do this action?

     

    iotjzf2wec5h.pnghttps://us.v-cdn.net/5019921/uploads/editor/rg/iotjzf2wec5h.png" width="785">



  • 2.  JAVA API: Set Active/Inactive task in schedule Monitor.

    Posted Jan 06, 2017 03:08 AM

    Hi Link,


     

    I don't have an example, but it is classScheduleTask, methodsetActive(boolean active):

    Sets this ScheduleTask active or inactive.


    regards,

    Peter



  • 3.  JAVA API: Set Active/Inactive task in schedule Monitor.

    Posted Jan 06, 2017 10:04 AM
    I had a little spare time this morning, so here's an example that allows you to mark any Task Active that matches any start time provided, delimited by semicolon:

    import java.io.IOException; import java.util.Iterator; import com.uc4.api.UC4ObjectName; import com.uc4.api.objects.Schedule; import com.uc4.api.objects.ScheduleTask; import com.uc4.communication.Connection; import com.uc4.communication.requests.CloseObject; import com.uc4.communication.requests.GetObjectProperties; import com.uc4.communication.requests.OpenObject; import com.uc4.communication.requests.SaveObject; public class checkSch {            public static void main (String[] args) throws IOException {                      int AEClientToConnect = Integer.parseInt(args[0]);           String AELevel = args[1];           String getSchedule = args[2];           String[] getTimes = args[3].split(";");           boolean modified = false;           Connection conn = new ConnectionManager().authenticate(AEClientToConnect, AELevel);                      GetObjectProperties getProperties = new GetObjectProperties(new UC4ObjectName(getSchedule));           conn.sendRequestAndWait(getProperties);                      if (getProperties.getOpenByUser() != null) {                System.out.println("Object " + getSchedule + " is currently being modified by user " + getProperties.getOpenByUser() +                          " and is read-only.\nPlease either wait or contact this user to resolve this.");                System.exit(1);           } else {                UC4ObjectName jschobj = new UC4ObjectName(getSchedule);                OpenObject openSch = new OpenObject(jschobj);                conn.sendRequestAndWait(openSch);                                     Schedule schedule = (Schedule) openSch.getUC4Object();                                Iterator<ScheduleTask> tasks = schedule.taskIterator();                while (tasks.hasNext()) {                     ScheduleTask task = tasks.next();                     for (int i = 0; i < getTimes.length; i++) {                          if (task.getStartTime().toString().equals(getTimes[i])) {                               System.out.println("Task " + task.getTaskName() + " matches start time of " + getTimes[i] + " and will be marked Active!");                               task.setActive(true);                               modified = true;                          }                     }                }                                if (modified) {                     conn.sendRequestAndWait(new SaveObject(schedule));                     conn.sendRequestAndWait(new CloseObject(schedule));                     conn.close();                } else {                     System.out.println("No Tasks matching start times given were found!");                     conn.close();                }           }      } }




  • 4.  JAVA API: Set Active/Inactive task in schedule Monitor.

    Posted Jan 08, 2017 11:34 PM

    Thanks all  Peter Grundler Michael Coxson. I really appreciate your helps.

    I have tried ScheduleTask as well but it seems that it is to modify the schedule definition (Edit mode).
    However what I need is to activate/inactivate fromactivity window of schedule (Last monitor).
    The one that show little clock-with-a-pencil icon after editing.

    Any idea?

    Thank you in advance



  • 5.  JAVA API: Set Active/Inactive task in schedule Monitor.

    Posted Jan 09, 2017 10:06 AM
    Ah, ok. So you need to set active/inactive a time in a running schedule.  From the looks of it that is not possible, as the ScheduleMonitor.Task object only offers "gets" and if you check your own screenshots above you will see (Read Only) in the title field of the Task Properties window.  My guess is that once the ScheduleTasks are committed to the engine their start times are set, though it may be possible to modify them with an AE script call--I'd have to check.


  • 6.  JAVA API: Set Active/Inactive task in schedule Monitor.

    Posted Jan 09, 2017 03:34 PM
    Hi Surawadee_Tangtorkit_1865,

    In short: I dont think there is a way to do this with the API currently.

    Here is a longer explanation as to why:

    As correctly pointed out by Michael & Peter, there is a Schedule class and a ScheduleTask class in the API. The Schedule class represents a SCHED object, and the ScheduleTask represents a single task / entry in a SCHED object.. however, they do not represent a running SCHED object (just its definition).

    the actual SCHED monitor is represented by class "ScheduleMonitor" and this gives access to an iterator of ScheduleMonitor.Task objects.. which, you guessed it, represent the live Tasks of a live SCHED Monitor (so basically that would be the object you are trying to Activate / Deactivate).

    Unfortunately, the ScheduleMonitor.Task only has "getters" methods, no "setters" method.. so you cannot use it to set its status. 

    Why this class has no "setters" is unclear to me. I have tried to circumvent this a few times with no success so far. 

    bren


  • 7.  JAVA API: Set Active/Inactive task in schedule Monitor.

    Posted Jan 09, 2017 03:41 PM
    Also, FYI, i am double checking with our engineering dept to make sure im not missing anything and this is indeed not currently possible.. 

    I will post their response here when i get it!

    bren


  • 8.  JAVA API: Set Active/Inactive task in schedule Monitor.

    Posted Jan 10, 2017 08:44 AM
    Hi everyone,

    I got confirmation that this operation is indeed not currently covered by the Java API. I will be opening a Product Enhancement around it indeed.


  • 9.  JAVA API: Set Active/Inactive task in schedule Monitor.

    Posted Jan 10, 2017 09:21 AM
    So at this point, Surawadee, your best bet is essentially to clear your current executing Schedule from the Schedule Monitor, modify the Schedule object to activate/deactivate the given Tasks, and then re-execute the Schedule to place it back into the Monitor.  It's certainly a more "permanent" update, but currently it looks like about the only real method to achieve your result.


  • 10.  JAVA API: Set Active/Inactive task in schedule Monitor.

    Posted Jan 10, 2017 08:10 PM

    Michael_Coxson_5769  Thanks for the suggestion :) I actually would like to avoid the ID to have modify permission in production system. I checked the AE script before checking on this JAVA API but it does not exist. Only active JOBP can be modified, not JSCH. 

    brendan_sapience_automic Thanks for checking on this. It would be really helpful if this feature can be done via the AE script as well as MODIFY_TASK does for JOBP.  



  • 11.  JAVA API: Set Active/Inactive task in schedule Monitor.

    Posted Jan 03, 2018 07:57 PM
    Hi,

    i added a request in the Ideation system for this, feel free to vote it up when you see it (it will likely be visible tomorrow)!


  • 12.  JAVA API: Set Active/Inactive task in schedule Monitor.

    Posted Jan 03, 2018 10:27 PM

    Thanks brendan_sapience_automic  
    I saw you posted the idea last year. Was it the same thing ?
    Deactivate and Activate Tasks that are part of a running JSCH with the Java API 



  • 13.  JAVA API: Set Active/Inactive task in schedule Monitor.

    Posted Jan 04, 2018 08:29 AM
    possibly... i dont have access to the external request and couldnt locate my original request..