use of org.pentaho.di.job.entry.JobEntryCopy in project pentaho-kettle by pentaho.
the class JobGraph method openTransformation.
public void openTransformation() {
JobEntryCopy jobEntryCopy = getJobEntry();
final JobEntryInterface entry = jobEntryCopy.getEntry();
openTransformation((JobEntryTrans) entry, jobEntryCopy);
}
use of org.pentaho.di.job.entry.JobEntryCopy in project pentaho-kettle by pentaho.
the class JobHistoryDelegate method replayHistory.
/**
* Public for XUL.
*/
public void replayHistory() {
JobHistoryLogTab model = models[tabFolder.getSelectionIndex()];
int idx = model.logDisplayTableView.getSelectionIndex();
if (idx >= 0) {
String[] fields = model.logDisplayTableView.getItem(idx);
int batchId = Const.toInt(fields[0], -1);
// String dateString = fields[13];
// Date replayDate = XMLHandler.stringToDate(dateString);
List<JobEntryCopyResult> results = null;
boolean gotResults = false;
// We check in the Job Entry Logging to see the results from all the various job entries that were executed.
//
JobEntryLogTable jeLogTable = jobMeta.getJobEntryLogTable();
if (jeLogTable.isDefined()) {
try {
DatabaseMeta databaseMeta = jobMeta.getJobEntryLogTable().getDatabaseMeta();
Database db = new Database(Spoon.loggingObject, databaseMeta);
try {
db.connect();
String schemaTable = databaseMeta.getQuotedSchemaTableCombination(jeLogTable.getActualSchemaName(), jeLogTable.getActualTableName());
String sql = "SELECT * FROM " + schemaTable + " WHERE " + databaseMeta.quoteField(jeLogTable.getKeyField().getFieldName()) + " = " + batchId;
List<Object[]> rows = db.getRows(sql, 0);
RowMetaInterface rowMeta = db.getReturnRowMeta();
results = new ArrayList<JobEntryCopyResult>();
int jobEntryNameIndex = rowMeta.indexOfValue(jeLogTable.findField(JobEntryLogTable.ID.JOBENTRYNAME.toString()).getFieldName());
int jobEntryResultIndex = rowMeta.indexOfValue(jeLogTable.findField(JobEntryLogTable.ID.RESULT.toString()).getFieldName());
int jobEntryErrorsIndex = rowMeta.indexOfValue(jeLogTable.findField(JobEntryLogTable.ID.ERRORS.toString()).getFieldName());
LogTableField copyNrField = jeLogTable.findField(JobEntryLogTable.ID.COPY_NR.toString());
int jobEntryCopyNrIndex = copyNrField == null ? -1 : (copyNrField.isEnabled() ? rowMeta.indexOfValue(copyNrField.getFieldName()) : -1);
for (Object[] row : rows) {
String jobEntryName = rowMeta.getString(row, jobEntryNameIndex);
boolean jobEntryResult = rowMeta.getBoolean(row, jobEntryResultIndex);
long errors = rowMeta.getInteger(row, jobEntryErrorsIndex);
long copyNr = jobEntryCopyNrIndex < 0 ? 0 : rowMeta.getInteger(row, jobEntryCopyNrIndex);
JobEntryCopyResult result = new JobEntryCopyResult(jobEntryName, jobEntryResult, errors, (int) copyNr);
results.add(result);
}
} finally {
db.disconnect();
}
gotResults = true;
} catch (Exception e) {
new ErrorDialog(spoon.getShell(), BaseMessages.getString(PKG, "JobHistoryDelegate.ReplayHistory.UnexpectedErrorReadingJobEntryHistory.Text"), BaseMessages.getString(PKG, "JobHistoryDelegate.ReplayHistory.UnexpectedErrorReadingJobEntryHistory.Message"), e);
}
} else {
MessageBox box = new MessageBox(spoon.getShell(), SWT.ICON_ERROR | SWT.OK);
box.setText(BaseMessages.getString(PKG, "JobHistoryDelegate.ReplayHistory.NoJobEntryTable.Text"));
box.setMessage(BaseMessages.getString(PKG, "JobHistoryDelegate.ReplayHistory.NoJobEntryTable.Message"));
box.open();
}
// spoon.executeJob(jobGraph.getManagedObject(), true, false, replayDate, false);
if (!gotResults) {
// For some reason we have no execution results, simply list all the job entries so the user can choose...
//
results = new ArrayList<JobEntryCopyResult>();
for (JobEntryCopy copy : jobMeta.getJobCopies()) {
results.add(new JobEntryCopyResult(copy.getName(), null, null, copy.getNr()));
}
}
// OK, now that we have our list of job entries, let's first try to find the first job-entry that had a false
// result or where errors>0
// If the error was handled, we look further for a more appropriate target.
//
JobEntryCopy selection = null;
boolean more = true;
JobEntryCopy start = jobMeta.findStart();
while (selection == null && more) {
int nrNext = jobMeta.findNrNextJobEntries(start);
more = nrNext > 0;
for (int n = 0; n < nrNext; n++) {
JobEntryCopy copy = jobMeta.findNextJobEntry(start, n);
// See if we can find a result for this job entry...
//
JobEntryCopyResult result = JobEntryCopyResult.findResult(results, copy);
if (result != null) {
System.out.println("TODO: replay");
// Do nothing???
}
}
}
//
for (JobEntryCopyResult result : results) {
System.out.println("Job entry copy result -- Name=" + result.getJobEntryName() + ", result=" + result.getResult() + ", errors=" + result.getErrors() + ", nr=" + result.getCopyNr());
}
}
}
use of org.pentaho.di.job.entry.JobEntryCopy in project pentaho-kettle by pentaho.
the class JobLogDelegate method showErrors.
public void showErrors() {
String all = jobLogText.getText();
ArrayList<String> err = new ArrayList<String>();
int i = 0;
int startpos = 0;
int crlen = Const.CR.length();
String line = null;
String lineUpper = null;
while (i < all.length() - crlen) {
if (all.substring(i, i + crlen).equalsIgnoreCase(Const.CR)) {
line = all.substring(startpos, i);
lineUpper = line.toUpperCase();
if (lineUpper.indexOf(BaseMessages.getString(PKG, "JobLog.System.ERROR")) >= 0 || lineUpper.indexOf(BaseMessages.getString(PKG, "JobLog.System.EXCEPTION")) >= 0) {
err.add(line);
}
// New start of line
startpos = i + crlen;
}
i++;
}
line = all.substring(startpos);
lineUpper = line.toUpperCase();
if (lineUpper.indexOf(BaseMessages.getString(PKG, "JobLog.System.ERROR")) >= 0 || lineUpper.indexOf(BaseMessages.getString(PKG, "JobLog.System.EXCEPTION")) >= 0) {
err.add(line);
}
if (err.size() > 0) {
String[] err_lines = new String[err.size()];
for (i = 0; i < err_lines.length; i++) {
err_lines[i] = err.get(i);
}
EnterSelectionDialog esd = new EnterSelectionDialog(jobGraph.getShell(), err_lines, BaseMessages.getString(PKG, "JobLog.Dialog.ErrorLines.Title"), BaseMessages.getString(PKG, "JobLog.Dialog.ErrorLines.Message"));
line = esd.open();
if (line != null) {
JobMeta jobMeta = jobGraph.getManagedObject();
for (i = 0; i < jobMeta.nrJobEntries(); i++) {
JobEntryCopy entryCopy = jobMeta.getJobEntry(i);
if (line.indexOf(entryCopy.getName()) >= 0) {
spoon.editJobEntry(jobMeta, entryCopy);
}
}
// System.out.println("Error line selected: "+line);
}
}
}
use of org.pentaho.di.job.entry.JobEntryCopy in project pentaho-kettle by pentaho.
the class JobMeta method removeJobEntry.
/**
* Removes the job entry.
*
* @param i the i
*/
public void removeJobEntry(int i) {
JobEntryCopy deleted = jobcopies.remove(i);
if (deleted != null) {
// give step a chance to cleanup
deleted.setParentJobMeta(null);
if (deleted.getEntry() instanceof MissingEntry) {
removeMissingEntry((MissingEntry) deleted.getEntry());
}
}
setChanged();
}
use of org.pentaho.di.job.entry.JobEntryCopy in project pentaho-kettle by pentaho.
the class JobMeta method getResourceDependencies.
/**
* Gets the resource dependencies.
*
* @return the resource dependencies
*/
public List<ResourceReference> getResourceDependencies() {
List<ResourceReference> resourceReferences = new ArrayList<ResourceReference>();
JobEntryCopy copy = null;
JobEntryInterface entry = null;
for (int i = 0; i < jobcopies.size(); i++) {
// get the job entry copy
copy = jobcopies.get(i);
entry = copy.getEntry();
resourceReferences.addAll(entry.getResourceDependencies(this));
}
return resourceReferences;
}
Aggregations