private DynamicGridRow addParentSystemRow(TreeMap<IScheduledJob, Integer> map, SystemJobVo systemJob) { DynamicGridRow dynRowSystemJob = form.dyngrdSystemJobs().getRows().newRow(); DynamicGridCell systemJobCell = dynRowSystemJob.getCells().newCell(getColumnFromDynamicGridSystemJobs(COLNAME), DynamicCellType.HTMLVIEW); DynamicGridCell imgCell = dynRowSystemJob.getCells().newCell(getColumnFromDynamicGridSystemJobs(COLIMG), DynamicCellType.IMAGE); imgCell.setValue(form.getImages().Admin.SystemJob32); String jobText = "<b>" + systemJob.getName() + "</b>" + " (" + map.get(systemJob)+ ")"; jobText += "<br>"; jobText += systemJob.getDescription() != null ? systemJob.getDescription() : "No Description for job" + "<br> "; systemJobCell.setValue(jobText); dynRowSystemJob.setSelectable(true); dynRowSystemJob.setIdentifier(systemJob); dynRowSystemJob.setValue(systemJob); return dynRowSystemJob; }
private void populateDyngrdConfiguredJobs(IConfiguredScheduledJob[] configuredJobs, ISchedulerServlet servletInstance, SystemJobVo systemJob) throws Exception { form.dyngrdConfiguredJobs().getRows().clear(); form.dyngrdConfiguredJobs().setFooterValue(null); int total = 0; for(int i = 0; i < configuredJobs.length; i++) { if (configuredJobs[i].getScheduledJob().getScheduledJobID()== systemJob.getID_SystemJob()) { addConfiguredJobRecord(systemJob, configuredJobs[i], form.dyngrdConfiguredJobs().getRows().newRow(), servletInstance); total ++; } } form.dyngrdConfiguredJobs().setFooterValue("Total: " + total + " configured jobs"); }
private void populateDyngrdSystemJobs(IConfiguredScheduledJob[] configuredJobs, ISchedulerServlet servletInstance) throws Exception { TreeMap<IScheduledJob, Integer> map = new TreeMap<IScheduledJob, Integer>(); SystemJobVoCollection availableJobs = domain.listAvailableSystemJobs(); countForConfiguredJobsForSystemJobs(configuredJobs, availableJobs, map); form.dyngrdSystemJobs().getRows().clear(); for (Iterator iter = map.keySet().iterator(); iter.hasNext();) { SystemJobVo systemJob = (SystemJobVo) iter.next(); addParentSystemRow(map, systemJob); } form.dyngrdSystemJobs().setFooterValue("Total: " + availableJobs.size() + " available system jobs"); form.dyngrdSystemJobs().setValue(form.getGlobalContext().Admin.getSystemJob()); if (form.dyngrdSystemJobs().getSelectedRow() != null) { onDyngrdSystemJobsRowSelectionChanged(form.dyngrdSystemJobs().getSelectedRow()); } }
@Override protected void onDyngrdSystemJobsRowSelectionChanged(DynamicGridRow row) throws PresentationLogicException { ISchedulerServlet servletInstance = getTaskSchedulerServlet(); if (servletInstance == null) { engine.showMessage("Cannot get SchedulerServletInstance"); return ; } IScheduledJobsProvider provider = engine.getScheduledJobsProvider(); if (provider == null) { engine.showMessage("Cannot get ScheduledJobsProvider"); return; } try { form.getGlobalContext().Admin.setSystemJob((SystemJobVo)row.getIdentifier()); populateDyngrdConfiguredJobs(provider.getConfiguredScheduledJobs(), servletInstance, (SystemJobVo)row.getIdentifier()); } catch (Exception err) { engine.showMessage(err.getMessage()); return; } updateContextMenu(); }
public SystemJobVo getSystemJobVo(Integer id) { if(id == null) { throw new CodingRuntimeException("SystemJobVo id is null"); } DomainFactory factory = getDomainFactory(); SystemJob doSystemJob = (SystemJob) factory.getDomainObject(SystemJob.class, id); return (SystemJobVoAssembler.create(doSystemJob)); }
public SystemJobVo getSystemJobByImsId(Integer imsId) { DomainFactory factory = getDomainFactory(); String hqlString = "from SystemJob job where job.isActive = :isActive and job.imsId = :imsID"; List jobs = factory.find(hqlString, new String[] {"isActive", "imsID"}, new Object[] {true, new Integer(imsId)}); if (jobs != null && jobs.size() > 0) { return SystemJobVoAssembler.createSystemJobVoCollectionFromSystemJob(jobs).get(0); } return null; }
private void addConfiguredJobRecord(SystemJobVo systemJob, IConfiguredScheduledJob configuredJob, DynamicGridRow jobRow, ISchedulerServlet servletInstance) throws Exception { jobRow.setIdentifier(configuredJob); jobRow.setValue(configuredJob); String jobName = "<font size='2'><b>" + configuredJob.getConfiguredScheduledJobName() + "</b></font><br>"; String jobImageOk = "<img src='" + form.getImages().Admin.SystemJobConfigured32.getImagePath() + "' width='35' heigth/>"; String jobImageError = "<img src='" + form.getImages().Admin.SystemJobUnconfigured32.getImagePath() + "'/>"; String triggerText = configuredJob.getConfiguredScheduledJobCronExpression() != null ? "Run <font color=#0000FF>" + configuredJob.getConfiguredScheduledJobCronExpressionText() : "No trigger for job" + "</font>"; String lastTriggerStatus = ""; if (configuredJob != null && configuredJob.getConfiguredScheduledJobID() > 0) { ConfiguredJobExecutionSummaryVo summary = domain.getHistory(configuredJob.getConfiguredScheduledJobID()); if (summary != null && summary.getStartDateTimeIsNotNull() && summary.getEndDateTimeIsNotNull() && summary.getStatusIsNotNull()) { lastTriggerStatus = " <font color=#000000>Last run: start on </font>" + summary.getStartDateTime() + "<font color=#000000> finished on </font>" + summary.getEndDateTime() + "<font color=#000000> with status: </font>" + (summary.getStatus() == null ? "Unknown" : SchedulerJobExecutionStatus.parse(summary.getStatus()) == null ? "Unknown" : (SchedulerJobExecutionStatus.parse(summary.getStatus()).toString() == "Succeeded" ? "<font color=#00FF00>" + SchedulerJobExecutionStatus.parse(summary.getStatus()).toString() + "</font>" : "<font color=#FF0000>" + SchedulerJobExecutionStatus.parse(summary.getStatus()).toString() + "</font>")); } } DynamicGridCell jobNameCell = jobRow.getCells().newCell(getColumnFromDynamicGridConfiguredJobs(COLNAME), DynamicCellType.HTMLVIEW); String jobImage; String jobText; String jobStatus; try { if (servletInstance.getStatus(configuredJob.getConfiguredScheduledJobID()).equals(SchedulerJobStatus.ERROR)) { jobImage = jobImageError; jobStatus = "<font color=#000000>Job Status: </font><font color=#FF0000>" + servletInstance.getStatus(configuredJob.getConfiguredScheduledJobID()) + "</font>"; } else if (servletInstance.getStatus(configuredJob.getConfiguredScheduledJobID()).equals(SchedulerJobStatus.BLOCKED)) { jobImage = jobImageOk; jobStatus = "<font color=#000000>Job Status: </font><font color=#FE2EF7>" + servletInstance.getStatus(configuredJob.getConfiguredScheduledJobID()) + "</font>"; } else { jobImage = jobImageOk; jobStatus = "<font color=#000000>Job Status: </font><font color=#04B404>" + servletInstance.getStatus(configuredJob.getConfiguredScheduledJobID()) + "</font>"; } jobText = "<table cellpadding='0' cellspacing='0' border='0' width='100%'><tr><td width='40' rowspan='2'>" + jobImage + "</td><td>"+ jobName +"</td></tr><tr><td>" + triggerText + "<br>" + jobStatus + "<br>" + lastTriggerStatus + "</td></tr></table>"; } catch (Exception err) { jobImage = jobImageError; jobText = "<table cellpadding='0' cellspacing='0' border='0' width='100%'><tr><td width='40' rowspan='2'>" + jobImage + "</td><td><font size='2' color=#FF0000><b>"+ "Trigger error!" +"</b></font></td></tr><tr><td><font color=#000000>Trigger with id " + configuredJob.getConfiguredScheduledJobID() + " has returned an error: " + "<br><font color=#0000FF><i>" + err.getMessage() + "</i></font></td></tr></table>"; jobRow.setSelectable(false); } jobNameCell.setValue(jobText); }