use of org.pentaho.di.job.JobEntryResult in project pentaho-kettle by pentaho.
the class JobEntryMail method addBacktracking.
private void addBacktracking(JobTracker jobTracker, StringBuilder messageText, int level) {
int nr = jobTracker.nrJobTrackers();
messageText.append(Const.rightPad(" ", level * 2));
messageText.append(Const.NVL(jobTracker.getJobName(), "-"));
JobEntryResult jer = jobTracker.getJobEntryResult();
if (jer != null) {
messageText.append(" : ");
if (jer.getJobEntryName() != null) {
messageText.append(" : ");
messageText.append(jer.getJobEntryName());
}
if (jer.getResult() != null) {
messageText.append(" : ");
messageText.append("[" + jer.getResult().toString() + "]");
}
if (jer.getReason() != null) {
messageText.append(" : ");
messageText.append(jer.getReason());
}
if (jer.getComment() != null) {
messageText.append(" : ");
messageText.append(jer.getComment());
}
if (jer.getLogDate() != null) {
messageText.append(" (");
messageText.append(XMLHandler.date2string(jer.getLogDate()));
messageText.append(')');
}
}
messageText.append(Const.CR);
for (int i = 0; i < nr; i++) {
JobTracker jt = jobTracker.getJobTracker(i);
addBacktracking(jt, messageText, level + 1);
}
}
use of org.pentaho.di.job.JobEntryResult in project pentaho-kettle by pentaho.
the class JobEntryLogTable method getLogRecord.
/**
* This method calculates all the values that are required
*
* @param id
* the id to use or -1 if no id is needed
* @param status
* the log status to use
* @param subject
* the object to log
* @param parent
* the parent to which the object belongs
*/
public RowMetaAndData getLogRecord(LogStatus status, Object subject, Object parent) {
if (subject == null || subject instanceof JobEntryCopy) {
JobEntryCopy jobEntryCopy = (JobEntryCopy) subject;
Job parentJob = (Job) parent;
RowMetaAndData row = new RowMetaAndData();
for (LogTableField field : fields) {
if (field.isEnabled()) {
Object value = null;
if (subject != null) {
JobEntryInterface jobEntry = jobEntryCopy.getEntry();
JobTracker jobTracker = parentJob.getJobTracker();
JobTracker entryTracker = jobTracker.findJobTracker(jobEntryCopy);
JobEntryResult jobEntryResult = null;
if (entryTracker != null) {
jobEntryResult = entryTracker.getJobEntryResult();
}
Result result = null;
if (jobEntryResult != null) {
result = jobEntryResult.getResult();
}
switch(ID.valueOf(field.getId())) {
case ID_BATCH:
value = new Long(parentJob.getBatchId());
break;
case CHANNEL_ID:
value = jobEntry.getLogChannel().getLogChannelId();
break;
case LOG_DATE:
value = new Date();
break;
case JOBNAME:
value = parentJob.getJobname();
break;
case JOBENTRYNAME:
value = jobEntry.getName();
break;
case LINES_READ:
value = new Long(result != null ? result.getNrLinesRead() : 0);
break;
case LINES_WRITTEN:
value = new Long(result != null ? result.getNrLinesWritten() : 0);
break;
case LINES_UPDATED:
value = new Long(result != null ? result.getNrLinesUpdated() : 0);
break;
case LINES_INPUT:
value = new Long(result != null ? result.getNrLinesInput() : 0);
break;
case LINES_OUTPUT:
value = new Long(result != null ? result.getNrLinesOutput() : 0);
break;
case LINES_REJECTED:
value = new Long(result != null ? result.getNrLinesRejected() : 0);
break;
case ERRORS:
value = new Long(result != null ? result.getNrErrors() : 0);
break;
case RESULT:
value = new Boolean(result != null ? result.getResult() : false);
break;
case NR_RESULT_FILES:
value = new Long(result != null && result.getResultFiles() != null ? result.getResultFiles().size() : 0);
break;
case NR_RESULT_ROWS:
value = new Long(result != null && result.getRows() != null ? result.getRows().size() : 0);
break;
case LOG_FIELD:
if (result != null) {
value = result.getLogText();
}
break;
case COPY_NR:
value = new Long(jobEntryCopy.getNr());
break;
default:
break;
}
}
row.addValue(field.getFieldName(), field.getDataType(), value);
row.getRowMeta().getValueMeta(row.size() - 1).setLength(field.getLength());
}
}
return row;
} else {
return null;
}
}
use of org.pentaho.di.job.JobEntryResult in project pentaho-kettle by pentaho.
the class JobTracker method findJobTracker.
/**
* Finds the JobTracker for the job entry specified. Use this to
*
* @param jobEntryCopy
* The entry to search the job tracker for
* @return The JobTracker of null if none could be found...
*/
public JobTracker findJobTracker(JobEntryCopy jobEntryCopy) {
if (jobEntryCopy.getName() == null) {
return null;
}
lock.readLock().lock();
try {
ListIterator<JobTracker> it = jobTrackers.listIterator(jobTrackers.size());
while (it.hasPrevious()) {
JobTracker tracker = it.previous();
JobEntryResult result = tracker.getJobEntryResult();
if (result != null) {
if (jobEntryCopy.getName().equals(result.getJobEntryName()) && jobEntryCopy.getNr() == result.getJobEntryNr()) {
return tracker;
}
}
}
} finally {
lock.readLock().unlock();
}
return null;
}
use of org.pentaho.di.job.JobEntryResult in project pentaho-kettle by pentaho.
the class JobGraph method getJobImage.
public Image getJobImage(Device device, int x, int y, float magnificationFactor) {
GCInterface gc = new SWTGC(device, new Point(x, y), iconsize);
int gridSize = PropsUI.getInstance().isShowCanvasGridEnabled() ? PropsUI.getInstance().getCanvasGridSize() : 1;
JobPainter jobPainter = new JobPainter(gc, jobMeta, new Point(x, y), new SwtScrollBar(hori), new SwtScrollBar(vert), hop_candidate, drop_candidate, selectionRegion, areaOwners, mouseOverEntries, PropsUI.getInstance().getIconSize(), PropsUI.getInstance().getLineWidth(), gridSize, PropsUI.getInstance().getShadowSize(), PropsUI.getInstance().isAntiAliasingEnabled(), PropsUI.getInstance().getNoteFont().getName(), PropsUI.getInstance().getNoteFont().getHeight());
jobPainter.setMagnification(magnificationFactor);
jobPainter.setEntryLogMap(entryLogMap);
jobPainter.setStartHopEntry(startHopEntry);
jobPainter.setEndHopLocation(endHopLocation);
jobPainter.setEndHopEntry(endHopEntry);
jobPainter.setNoInputEntry(noInputEntry);
if (job != null) {
jobPainter.setJobEntryResults(job.getJobEntryResults());
} else {
jobPainter.setJobEntryResults(new ArrayList<JobEntryResult>());
}
List<JobEntryCopy> activeJobEntries = new ArrayList<>();
if (job != null) {
if (job.getActiveJobEntryJobs().size() > 0) {
activeJobEntries.addAll(job.getActiveJobEntryJobs().keySet());
}
if (job.getActiveJobEntryTransformations().size() > 0) {
activeJobEntries.addAll(job.getActiveJobEntryTransformations().keySet());
}
}
jobPainter.setActiveJobEntries(activeJobEntries);
jobPainter.drawJob();
return (Image) gc.getImage();
}
use of org.pentaho.di.job.JobEntryResult in project pentaho-kettle by pentaho.
the class JobGraph method setToolTip.
protected void setToolTip(int x, int y, int screenX, int screenY) {
if (!spoon.getProperties().showToolTips()) {
return;
}
// Some stupid bug in GTK+ causes a phantom tool tip to pop up, even if the tip is
canvas.setToolTipText("-");
// null
canvas.setToolTipText(null);
Image tipImage = null;
JobHopMeta hi = findJobHop(x, y);
// check the area owner list...
//
StringBuilder tip = new StringBuilder();
AreaOwner areaOwner = getVisibleAreaOwner(x, y);
if (areaOwner != null && areaOwner.getAreaType() != null) {
JobEntryCopy jobEntryCopy;
switch(areaOwner.getAreaType()) {
case JOB_HOP_ICON:
hi = (JobHopMeta) areaOwner.getOwner();
if (hi.isUnconditional()) {
tipImage = GUIResource.getInstance().getImageUnconditionalHop();
tip.append(BaseMessages.getString(PKG, "JobGraph.Hop.Tooltip.Unconditional", hi.getFromEntry().getName(), Const.CR));
} else {
if (hi.getEvaluation()) {
tip.append(BaseMessages.getString(PKG, "JobGraph.Hop.Tooltip.EvaluatingTrue", hi.getFromEntry().getName(), Const.CR));
tipImage = GUIResource.getInstance().getImageTrue();
} else {
tip.append(BaseMessages.getString(PKG, "JobGraph.Hop.Tooltip.EvaluatingFalse", hi.getFromEntry().getName(), Const.CR));
tipImage = GUIResource.getInstance().getImageFalse();
}
}
break;
case JOB_HOP_PARALLEL_ICON:
hi = (JobHopMeta) areaOwner.getOwner();
tip.append(BaseMessages.getString(PKG, "JobGraph.Hop.Tooltip.Parallel", hi.getFromEntry().getName(), Const.CR));
tipImage = GUIResource.getInstance().getImageParallelHop();
break;
case CUSTOM:
String message = (String) areaOwner.getOwner();
tip.append(message);
tipImage = null;
GUIResource.getInstance().getImageTransGraph();
break;
case JOB_ENTRY_MINI_ICON_INPUT:
tip.append(BaseMessages.getString(PKG, "JobGraph.EntryInputConnector.Tooltip"));
tipImage = GUIResource.getInstance().getImageHopInput();
resetDelayTimer((JobEntryCopy) areaOwner.getOwner());
break;
case JOB_ENTRY_MINI_ICON_OUTPUT:
tip.append(BaseMessages.getString(PKG, "JobGraph.EntryOutputConnector.Tooltip"));
tipImage = GUIResource.getInstance().getImageHopOutput();
resetDelayTimer((JobEntryCopy) areaOwner.getOwner());
break;
case JOB_ENTRY_MINI_ICON_EDIT:
tip.append(BaseMessages.getString(PKG, "JobGraph.EditStep.Tooltip"));
tipImage = GUIResource.getInstance().getImageEdit();
resetDelayTimer((JobEntryCopy) areaOwner.getOwner());
break;
case JOB_ENTRY_MINI_ICON_CONTEXT:
tip.append(BaseMessages.getString(PKG, "JobGraph.ShowMenu.Tooltip"));
tipImage = GUIResource.getInstance().getImageContextMenu();
resetDelayTimer((JobEntryCopy) areaOwner.getOwner());
break;
case JOB_ENTRY_RESULT_FAILURE:
case JOB_ENTRY_RESULT_SUCCESS:
JobEntryResult jobEntryResult = (JobEntryResult) areaOwner.getOwner();
jobEntryCopy = (JobEntryCopy) areaOwner.getParent();
Result result = jobEntryResult.getResult();
tip.append("'").append(jobEntryCopy.getName()).append("' ");
if (result.getResult()) {
tipImage = GUIResource.getInstance().getImageTrue();
tip.append("finished successfully.");
} else {
tipImage = GUIResource.getInstance().getImageFalse();
tip.append("failed.");
}
tip.append(Const.CR).append("------------------------").append(Const.CR).append(Const.CR);
tip.append("Result : ").append(result.getResult()).append(Const.CR);
tip.append("Errors : ").append(result.getNrErrors()).append(Const.CR);
if (result.getNrLinesRead() > 0) {
tip.append("Lines read : ").append(result.getNrLinesRead()).append(Const.CR);
}
if (result.getNrLinesWritten() > 0) {
tip.append("Lines written : ").append(result.getNrLinesWritten()).append(Const.CR);
}
if (result.getNrLinesInput() > 0) {
tip.append("Lines input : ").append(result.getNrLinesInput()).append(Const.CR);
}
if (result.getNrLinesOutput() > 0) {
tip.append("Lines output : ").append(result.getNrLinesOutput()).append(Const.CR);
}
if (result.getNrLinesUpdated() > 0) {
tip.append("Lines updated : ").append(result.getNrLinesUpdated()).append(Const.CR);
}
if (result.getNrLinesDeleted() > 0) {
tip.append("Lines deleted : ").append(result.getNrLinesDeleted()).append(Const.CR);
}
if (result.getNrLinesRejected() > 0) {
tip.append("Lines rejected : ").append(result.getNrLinesRejected()).append(Const.CR);
}
if (result.getResultFiles() != null && !result.getResultFiles().isEmpty()) {
tip.append(Const.CR).append("Result files:").append(Const.CR);
if (result.getResultFiles().size() > 10) {
tip.append(" (10 files of ").append(result.getResultFiles().size()).append(" shown");
}
List<ResultFile> files = new ArrayList<>(result.getResultFiles().values());
for (int i = 0; i < files.size(); i++) {
ResultFile file = files.get(i);
tip.append(" - ").append(file.toString()).append(Const.CR);
}
}
if (result.getRows() != null && !result.getRows().isEmpty()) {
tip.append(Const.CR).append("Result rows: ");
if (result.getRows().size() > 10) {
tip.append(" (10 rows of ").append(result.getRows().size()).append(" shown");
}
tip.append(Const.CR);
for (int i = 0; i < result.getRows().size() && i < 10; i++) {
RowMetaAndData row = result.getRows().get(i);
tip.append(" - ").append(row.toString()).append(Const.CR);
}
}
break;
case JOB_ENTRY_RESULT_CHECKPOINT:
tip.append("The job started here since this is the furthest checkpoint " + "that was reached last time the transformation was executed.");
tipImage = GUIResource.getInstance().getImageCheckpoint();
break;
default:
break;
}
}
if (hi != null && tip.length() == 0) {
// Set the tooltip for the hop:
tip.append(BaseMessages.getString(PKG, "JobGraph.Dialog.HopInfo")).append(Const.CR);
tip.append(BaseMessages.getString(PKG, "JobGraph.Dialog.HopInfo.SourceEntry")).append(" ").append(hi.getFromEntry().getName()).append(Const.CR);
tip.append(BaseMessages.getString(PKG, "JobGraph.Dialog.HopInfo.TargetEntry")).append(" ").append(hi.getToEntry().getName()).append(Const.CR);
tip.append(BaseMessages.getString(PKG, "TransGraph.Dialog.HopInfo.Status")).append(" ");
tip.append((hi.isEnabled() ? BaseMessages.getString(PKG, "JobGraph.Dialog.HopInfo.Enable") : BaseMessages.getString(PKG, "JobGraph.Dialog.HopInfo.Disable")));
if (hi.isUnconditional()) {
tipImage = GUIResource.getInstance().getImageUnconditionalHop();
} else {
if (hi.getEvaluation()) {
tipImage = GUIResource.getInstance().getImageTrue();
} else {
tipImage = GUIResource.getInstance().getImageFalse();
}
}
}
if (tip == null || tip.length() == 0) {
toolTip.hide();
} else {
if (!tip.toString().equalsIgnoreCase(getToolTipText())) {
if (tipImage != null) {
toolTip.setImage(tipImage);
} else {
toolTip.setImage(GUIResource.getInstance().getImageSpoon());
}
toolTip.setText(tip.toString());
toolTip.hide();
toolTip.show(new org.eclipse.swt.graphics.Point(screenX, screenY));
}
}
}
Aggregations