Search in sources :

Example 21 with JobEntryCopy

use of org.pentaho.di.job.entry.JobEntryCopy in project pentaho-kettle by pentaho.

the class JobMeta method getAlternativeJobentryName.

/**
 * Proposes an alternative job entry name when the original already exists...
 *
 * @param entryname The job entry name to find an alternative for..
 * @return The alternative stepname.
 */
public String getAlternativeJobentryName(String entryname) {
    String newname = entryname;
    JobEntryCopy jec = findJobEntry(newname);
    int nr = 1;
    while (jec != null) {
        nr++;
        newname = entryname + " " + nr;
        jec = findJobEntry(newname);
    }
    return newname;
}
Also used : JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint)

Example 22 with JobEntryCopy

use of org.pentaho.di.job.entry.JobEntryCopy in project pentaho-kettle by pentaho.

the class JobMeta method getUsedDatabaseMetas.

private Set<DatabaseMeta> getUsedDatabaseMetas() {
    Set<DatabaseMeta> databaseMetas = new HashSet<DatabaseMeta>();
    for (JobEntryCopy jobEntryCopy : getJobCopies()) {
        DatabaseMeta[] dbs = jobEntryCopy.getEntry().getUsedDatabaseConnections();
        if (dbs != null) {
            for (DatabaseMeta db : dbs) {
                databaseMetas.add(db);
            }
        }
    }
    databaseMetas.add(jobLogTable.getDatabaseMeta());
    for (LogTableInterface logTable : getExtraLogTables()) {
        databaseMetas.add(logTable.getDatabaseMeta());
    }
    return databaseMetas;
}
Also used : LogTableInterface(org.pentaho.di.core.logging.LogTableInterface) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) HashSet(java.util.HashSet)

Example 23 with JobEntryCopy

use of org.pentaho.di.job.entry.JobEntryCopy in project pentaho-kettle by pentaho.

the class JobMeta method getMaximum.

/**
 * Gets the maximum.
 *
 * @return the maximum
 */
public Point getMaximum() {
    int maxx = 0, maxy = 0;
    for (int i = 0; i < nrJobEntries(); i++) {
        JobEntryCopy entry = getJobEntry(i);
        Point loc = entry.getLocation();
        if (loc.x > maxx) {
            maxx = loc.x;
        }
        if (loc.y > maxy) {
            maxy = loc.y;
        }
    }
    for (int i = 0; i < nrNotes(); i++) {
        NotePadMeta ni = getNote(i);
        Point loc = ni.getLocation();
        if (loc.x + ni.width > maxx) {
            maxx = loc.x + ni.width;
        }
        if (loc.y + ni.height > maxy) {
            maxy = loc.y + ni.height;
        }
    }
    return new Point(maxx + 100, maxy + 100);
}
Also used : JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) NotePadMeta(org.pentaho.di.core.NotePadMeta) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint)

Example 24 with JobEntryCopy

use of org.pentaho.di.job.entry.JobEntryCopy in project pentaho-kettle by pentaho.

the class JobMeta method hasLoop.

/**
 * Checks for loop.
 *
 * @param entry  the entry
 * @param lookup the lookup
 * @return true, if successful
 */
private boolean hasLoop(JobEntryCopy entry, JobEntryCopy lookup, HashSet<JobEntryCopy> checkedEntries) {
    String cacheKey = entry.getName() + " - " + (lookup != null ? lookup.getName() : "");
    Boolean hasLoop = loopCache.get(cacheKey);
    if (hasLoop != null) {
        return hasLoop;
    }
    hasLoop = false;
    checkedEntries.add(entry);
    int nr = findNrPrevJobEntries(entry);
    for (int i = 0; i < nr; i++) {
        JobEntryCopy prevJobMeta = findPrevJobEntry(entry, i);
        if (prevJobMeta != null && (prevJobMeta.equals(lookup) || (!checkedEntries.contains(prevJobMeta) && hasLoop(prevJobMeta, lookup == null ? entry : lookup, checkedEntries)))) {
            hasLoop = true;
            break;
        }
    }
    loopCache.put(cacheKey, hasLoop);
    return hasLoop;
}
Also used : JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint)

Example 25 with JobEntryCopy

use of org.pentaho.di.job.entry.JobEntryCopy in project pentaho-kettle by pentaho.

the class JobMeta method getMinimum.

/**
 * Get the minimum point on the canvas of a job
 *
 * @return Minimum coordinate of a step in the job
 */
public Point getMinimum() {
    int minx = Integer.MAX_VALUE;
    int miny = Integer.MAX_VALUE;
    for (int i = 0; i < nrJobEntries(); i++) {
        JobEntryCopy jobEntryCopy = getJobEntry(i);
        Point loc = jobEntryCopy.getLocation();
        if (loc.x < minx) {
            minx = loc.x;
        }
        if (loc.y < miny) {
            miny = loc.y;
        }
    }
    for (int i = 0; i < nrNotes(); i++) {
        NotePadMeta notePadMeta = getNote(i);
        Point loc = notePadMeta.getLocation();
        if (loc.x < minx) {
            minx = loc.x;
        }
        if (loc.y < miny) {
            miny = loc.y;
        }
    }
    if (minx > BORDER_INDENT && minx != Integer.MAX_VALUE) {
        minx -= BORDER_INDENT;
    } else {
        minx = 0;
    }
    if (miny > BORDER_INDENT && miny != Integer.MAX_VALUE) {
        miny -= BORDER_INDENT;
    } else {
        miny = 0;
    }
    return new Point(minx, miny);
}
Also used : JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) NotePadMeta(org.pentaho.di.core.NotePadMeta) 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