Trouble updating job deadline in specific jobstream through tws Java API

118 views Asked by At

I would like to change the deadline of a job within a specific jobstream using the Java-API. Updating the deadline of the jobstream itself gives no issues. Using a queryfilter on jobstream-level I get the jobstreamheader-id (jsh) and instantiate a JobStream object. This can be modified and set back.

  JobStream js = (JobStream) model.getTWSObject(JobStream.class, jsh.getId(), false, context);
  TimeRestrictions t = js.getTimeRestrictions();
  t.setDeadlineOffset(Long.parseLong(newDlineOffset));
  js.setTimeRestrictions(t);
  model.setTWSObject(js, false, false, context);

However I don't see how I can update the timerestrictions of the Jobs within the JobStream. I can get a list of jobs in the jobstream, and find the timerestrictions of those jobs themselves:

List<Job> joblist = js.getJobs();
  for (Job j : joblist) {
    j.getTimeRestrictions().getDeadlineOffset();
  }

However, after editing the job-object I cannot seem to update the jobstream-object again; there is no setJobs-function for the jobstream-object.

Does anybody have an idea how I can realize this?

2

There are 2 answers

2
Lorenzo Amorosa On

in order to update a job inside the job stream you should change the value in the job and then set the job stream again

In your example:

        List<Job> joblist = js.getJobs();
          for (Job j : joblist) {
            j.getTimeRestrictions().setDeadlineOffset(Long.parseLong(newDlineOffset));              
          }

        model.setTWSObject(js, false, false, context);

I hope this can help.

Lorenzo

0
TinekeW On

Turned out it wasn't necessary to explicitly set the Job of the JobStream again. When editing the Job, and then just setting the JobStream object, the edited Job-properties were also included in the JobStream-object.

JobStream js = (JobStream) model.getTWSObject(JobStream.class, jsh.getId(), false, context);
List<Job> joblist = js.getJobs();
  for (Job j : joblist) {
    TimeRestrictions t = j.getTimeRestrictions();
    t.setDeadLineOffset(offset);
    j.setTimeRestrictions(t);
  }
model.setTWSObject(js, false, false, context);