Ignore:
Timestamp:
Oct 29, 2014, 10:49:23 AM (8 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1875: Abort multiple jobs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.3-stable/www/views/jobs/index.jsp

    r6447 r6581  
    5858  import="java.util.List"
    5959  import="java.util.ArrayList"
     60  import="java.util.Collection"
    6061  import="java.util.Collections"
    6162%>
     
    278279    redirect = viewPage;
    279280  }
     281  else if ("AbortJobs".equals(cmd))
     282  {
     283    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     284    dc = sc.newDbControl();
     285    int numAborted = 0;
     286    int numSelected = 0;
     287    for (int jobId : cc.getSelected())
     288    {
     289      numSelected++;
     290      Job job = Job.getById(dc, jobId);
     291      SignalTransporter signalTransporter = job.getSignalTransporter();
     292      if (signalTransporter == null)
     293      {
     294        if (job.getStatus() == Job.Status.WAITING)
     295        {
     296          job.doneError("Aborted by user");
     297          numAborted++;
     298        }
     299      }
     300      else
     301      {
     302        Collection<Signal> supportedSignals = signalTransporter.getSupportedSignals();
     303        if (supportedSignals == null || supportedSignals.contains(Signal.ABORT))
     304        {
     305          signalTransporter.send(Signal.ABORT);
     306          numAborted++;
     307        }
     308      }
     309    }
     310    dc.commit();
     311   
     312    message = numAborted + " of " + numSelected + " jobs have been aborted ";
     313    Thread.sleep(500);
     314    redirect = listPage;
     315  }
    280316  else if ("AbortJob".equals(cmd))
    281317  {
Note: See TracChangeset for help on using the changeset viewer.