private void addItem(ConfiguredJobExecutionSummaryVo item) { grdHistoryRow row = form.grdHistory().getRows().newRow(); row.setValue(item); if (SchedulerJobExecutionStatus.parse(item.getStatus()) != null) { if (SchedulerJobExecutionStatus.parse(item.getStatus()).toString().equals("Succeeded")) { row.setColImage(form.getImages().Admin.LogInformation); } else if (SchedulerJobExecutionStatus.parse(item.getStatus()).toString().equals("Failed")) { row.setColImage(form.getImages().Admin.LogFatalError); } } row.setColStartDateTime(item.getStartDateTime() == null ? "Unknown" : item.getStartDateTime().toString()); row.setColEndDateTime(item.getEndDateTime() == null ? "Unknown" : item.getEndDateTime().toString()); row.setColStatus(item.getStatus() == null ? "Unknown" : SchedulerJobExecutionStatus.parse(item.getStatus()) == null ? "Unknown" : SchedulerJobExecutionStatus.parse(item.getStatus()).toString()); row.setColMessage(item.getMessage() == null ? "No details." : item.getMessage()); }
@Override protected void onGrdHistorySelectionChanged() throws PresentationLogicException { showDetailsAndTraceTabs(); form.lyrDetails().showtabDetails(); form.lyrDetails().tabDetails().txtDetails().setValue(form.grdHistory().getSelectedRow() != null ? (form.grdHistory().getSelectedRow().getValue() != null ? form.grdHistory().getSelectedRow().getValue().getMessage() : null) : null); form.lyrDetails().tabTrace().grdTrace().getRows().clear(); ConfiguredJobExecutionSummaryVo item = form.grdHistory().getValue(); if(item != null && item.getTraces() != null) { ConfiguredJobExecutionTraceVoCollection list = item.getTraces(); for(int x = 0; x < list.size(); x++) { addTraceItem(list.get(x)); } } if (form.btnRefresh().isVisible()) { form.lyrDetails().showtabTrace(); form.lyrDetails().tabTrace().grdTrace().setValue(form.lyrDetails().tabTrace().grdTrace().getRows().get(form.lyrDetails().tabTrace().grdTrace().getRows().size()-1).getValue()); } }
public void saveExecutionSummaryAndTrace(IConfiguredScheduledJob job, SchedulerJobExecutionSummary summary, SchedulerJobExecutionTrace trace) { ConfiguredJobExecutionSummaryVo record = new ConfiguredJobExecutionSummaryVo(); record.setConfiguredJob(getConfiguredScheduledJobVo(job.getConfiguredScheduledJobID())); record.setStartDateTime(summary.getStartDateTime()); record.setEndDateTime(summary.getEndDateTime()); record.setMessage(summary.getMessage()); record.setStatus(summary.getStatus().getId()); ConfiguredJobExecutionTraceVoCollection traces = new ConfiguredJobExecutionTraceVoCollection(); if(trace != null) { for(int x = 0; x < trace.getTrace().size(); x++) { ITraceRecord traceRecord = trace.getTrace().get(x); ConfiguredJobExecutionTraceVo item = new ConfiguredJobExecutionTraceVo(); item.setDateTime(traceRecord.getDateTime()); item.setMessage(traceRecord.getMessage()); traces.add(item); } } record.setTraces(traces); String[] errors = record.validate(); if(errors != null && errors.length > 0) { throw new RuntimeException("Unable to save the scheduled job execution summary due to validation errors"); } DomainFactory factory = getDomainFactory(); try { factory.save(ConfiguredJobExecutionSummaryVoAssembler.extractConfiguredJobExecutionSummary(factory, record)); } catch (StaleObjectException e) { e.printStackTrace(); } }
public ConfiguredJobExecutionSummaryVo getHistory(Integer id) { DomainFactory factory = getDomainFactory(); DomainObject summary = factory.findFirst("from ConfiguredJobExecutionSummary job where job.configuredJob.id = " + id + " order by id desc"); if (summary instanceof ConfiguredJobExecutionSummary) { return ConfiguredJobExecutionSummaryVoAssembler.create((ConfiguredJobExecutionSummary) summary); } return null; }
@Override protected void onGrdHistorySelectionChanged() throws PresentationLogicException { showDetailsAndTraceTabs(); form.lyrDetails().showtabDetails(); form.lyrDetails().tabDetails().txtDetails().setValue(form.grdHistory().getSelectedRow() != null ? (form.grdHistory().getSelectedRow().getValue() != null ? form.grdHistory().getSelectedRow().getValue().getMessage() : null) : null); form.lyrDetails().tabTrace().grdTrace().getRows().clear(); ConfiguredJobExecutionSummaryVo item = form.grdHistory().getValue(); if(item != null && item.getTraces() != null) { ConfiguredJobExecutionTraceVoCollection list = item.getTraces(); for(int x = 0; x < list.size(); x++) { addTraceItem(list.get(x)); } } if (form.btnRefresh().isVisible()) { form.lyrDetails().showtabTrace(); if (form.lyrDetails().tabTrace().grdTrace().getRows().size() > 0) //WDEV-17838 { form.lyrDetails().tabTrace().grdTrace().setValue(form.lyrDetails().tabTrace().grdTrace().getRows().get(form.lyrDetails().tabTrace().grdTrace().getRows().size()-1).getValue()); } } }
private void loadData() { form.btnRefresh().setVisible(false); form.grdHistory().getRows().clear(); ISchedulerServlet servletInstance = getTaskSchedulerServlet(); ConfiguredJobVo currentJobConfiguration = form.getGlobalContext().Admin.getCurrentJobConfiguration(); ISchedulerJob instance = servletInstance.getJob(currentJobConfiguration.getID_ConfiguredJob()); if (instance != null) { form.btnRefresh().setVisible(true); ConfiguredJobExecutionSummaryVo executionSummary = new ConfiguredJobExecutionSummaryVo(); executionSummary.setMessage("Scheduled job is running."); executionSummary.setStartDateTime(instance.getJobStartDateTime()); if (instance.getExecutionTrace() != null) { List<ITraceRecord> traces = instance.getExecutionTrace().getTrace(); ConfiguredJobExecutionTraceVoCollection coll = new ConfiguredJobExecutionTraceVoCollection(); for (int i = 0; i < traces.size(); i++) { ConfiguredJobExecutionTraceVo vo = new ConfiguredJobExecutionTraceVo(); vo.setMessage(traces.get(i).getMessage()); vo.setDateTime(traces.get(i).getDateTime()); coll.add(vo); } executionSummary.setTraces(coll); } grdHistoryRow row = form.grdHistory().getRows().newRow(); row.setValue(executionSummary); row.setColImage(form.getImages().Core.Time); row.setColStartDateTime(executionSummary.getStartDateTime() == null ? "Unknown" : executionSummary.getStartDateTime().toString()); row.setColEndDateTime(null); row.setColStatus("In Progress"); row.setColMessage(executionSummary.getMessage() == null ? "No details." : executionSummary.getMessage()); } ConfiguredJobExecutionSummaryVoCollection list = domain.getHistory(form.getGlobalContext().Admin.getCurrentJobConfiguration()); for(int x = 0; x < list.size(); x++) { addItem(list.get(x)); } }
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); }