Search in sources :

Example 16 with JobEntryCopy

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);
}
Also used : JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) JobEntryInterface(org.pentaho.di.job.entry.JobEntryInterface)

Example 17 with 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());
        }
    }
}
Also used : LogTableField(org.pentaho.di.core.logging.LogTableField) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) KettleValueException(org.pentaho.di.core.exception.KettleValueException) MessageBox(org.eclipse.swt.widgets.MessageBox) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) Database(org.pentaho.di.core.database.Database) JobEntryLogTable(org.pentaho.di.core.logging.JobEntryLogTable)

Example 18 with JobEntryCopy

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);
        }
    }
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) ArrayList(java.util.ArrayList) EnterSelectionDialog(org.pentaho.di.ui.core.dialog.EnterSelectionDialog)

Example 19 with JobEntryCopy

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();
}
Also used : JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) MissingEntry(org.pentaho.di.job.entries.missing.MissingEntry)

Example 20 with JobEntryCopy

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;
}
Also used : JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) JobEntryInterface(org.pentaho.di.job.entry.JobEntryInterface) ArrayList(java.util.ArrayList) ResourceReference(org.pentaho.di.resource.ResourceReference) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint)

Aggregations

JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)149 Point (org.pentaho.di.core.gui.Point)54 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)51 JobMeta (org.pentaho.di.job.JobMeta)47 KettleException (org.pentaho.di.core.exception.KettleException)30 Test (org.junit.Test)28 JobEntryInterface (org.pentaho.di.job.entry.JobEntryInterface)28 NotePadMeta (org.pentaho.di.core.NotePadMeta)24 JobHopMeta (org.pentaho.di.job.JobHopMeta)24 ArrayList (java.util.ArrayList)18 Job (org.pentaho.di.job.Job)18 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)16 JobEntryTrans (org.pentaho.di.job.entries.trans.JobEntryTrans)15 MessageBox (org.eclipse.swt.widgets.MessageBox)13 PluginInterface (org.pentaho.di.core.plugins.PluginInterface)10 Result (org.pentaho.di.core.Result)8 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)8 AreaOwner (org.pentaho.di.core.gui.AreaOwner)8 JobEntrySpecial (org.pentaho.di.job.entries.special.JobEntrySpecial)8 Before (org.junit.Before)7