Search in sources :

Example 26 with JobEntryCopy

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

the class JobMeta method findUnusedNr.

/**
 * Find unused nr.
 *
 * @param name the name
 * @return the int
 */
public int findUnusedNr(String name) {
    int nr = 1;
    JobEntryCopy je = findJobEntry(name, nr, true);
    while (je != null) {
        nr++;
        // log.logDebug("findUnusedNr()", "Trying unused nr: "+nr);
        je = findJobEntry(name, nr, true);
    }
    return nr;
}
Also used : JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint)

Example 27 with JobEntryCopy

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

the class JobMeta method getStringList.

/**
 * Get a list of all the strings used in this job.
 *
 * @return A list of StringSearchResult with strings used in the job
 */
public List<StringSearchResult> getStringList(boolean searchSteps, boolean searchDatabases, boolean searchNotes) {
    List<StringSearchResult> stringList = new ArrayList<StringSearchResult>();
    if (searchSteps) {
        // vars are...
        for (int i = 0; i < nrJobEntries(); i++) {
            JobEntryCopy entryMeta = getJobEntry(i);
            stringList.add(new StringSearchResult(entryMeta.getName(), entryMeta, this, BaseMessages.getString(PKG, "JobMeta.SearchMetadata.JobEntryName")));
            if (entryMeta.getDescription() != null) {
                stringList.add(new StringSearchResult(entryMeta.getDescription(), entryMeta, this, BaseMessages.getString(PKG, "JobMeta.SearchMetadata.JobEntryDescription")));
            }
            JobEntryInterface metaInterface = entryMeta.getEntry();
            StringSearcher.findMetaData(metaInterface, 1, stringList, entryMeta, this);
        }
    }
    // are...
    if (searchDatabases) {
        for (int i = 0; i < nrDatabases(); i++) {
            DatabaseMeta meta = getDatabase(i);
            stringList.add(new StringSearchResult(meta.getName(), meta, this, BaseMessages.getString(PKG, "JobMeta.SearchMetadata.DatabaseConnectionName")));
            if (meta.getHostname() != null) {
                stringList.add(new StringSearchResult(meta.getHostname(), meta, this, BaseMessages.getString(PKG, "JobMeta.SearchMetadata.DatabaseHostName")));
            }
            if (meta.getDatabaseName() != null) {
                stringList.add(new StringSearchResult(meta.getDatabaseName(), meta, this, BaseMessages.getString(PKG, "JobMeta.SearchMetadata.DatabaseName")));
            }
            if (meta.getUsername() != null) {
                stringList.add(new StringSearchResult(meta.getUsername(), meta, this, BaseMessages.getString(PKG, "JobMeta.SearchMetadata.DatabaseUsername")));
            }
            if (meta.getPluginId() != null) {
                stringList.add(new StringSearchResult(meta.getPluginId(), meta, this, BaseMessages.getString(PKG, "JobMeta.SearchMetadata.DatabaseTypeDescription")));
            }
            if (meta.getDatabasePortNumberString() != null) {
                stringList.add(new StringSearchResult(meta.getDatabasePortNumberString(), meta, this, BaseMessages.getString(PKG, "JobMeta.SearchMetadata.DatabasePort")));
            }
            if (meta.getServername() != null) {
                stringList.add(new StringSearchResult(meta.getServername(), meta, this, BaseMessages.getString(PKG, "JobMeta.SearchMetadata.DatabaseServer")));
            }
            // {
            if (meta.getPassword() != null) {
                stringList.add(new StringSearchResult(meta.getPassword(), meta, this, BaseMessages.getString(PKG, "JobMeta.SearchMetadata.DatabasePassword")));
            // }
            }
        }
    }
    // are...
    if (searchNotes) {
        for (int i = 0; i < nrNotes(); i++) {
            NotePadMeta meta = getNote(i);
            if (meta.getNote() != null) {
                stringList.add(new StringSearchResult(meta.getNote(), meta, this, BaseMessages.getString(PKG, "JobMeta.SearchMetadata.NotepadText")));
            }
        }
    }
    return stringList;
}
Also used : JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) JobEntryInterface(org.pentaho.di.job.entry.JobEntryInterface) ArrayList(java.util.ArrayList) StringSearchResult(org.pentaho.di.core.reflection.StringSearchResult) NotePadMeta(org.pentaho.di.core.NotePadMeta) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint)

Example 28 with JobEntryCopy

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

the class JobMeta method getXML.

/*
   * (non-Javadoc)
   *
   * @see org.pentaho.di.core.xml.XMLInterface#getXML()
   */
public String getXML() {
    // Clear the embedded named clusters.  We will be repopulating from steps that used named clusters
    getNamedClusterEmbedManager().clear();
    Props props = null;
    if (Props.isInitialized()) {
        props = Props.getInstance();
    }
    StringBuilder retval = new StringBuilder(500);
    retval.append(XMLHandler.openTag(XML_TAG)).append(Const.CR);
    retval.append("  ").append(XMLHandler.addTagValue("name", getName()));
    retval.append("  ").append(XMLHandler.addTagValue("description", description));
    retval.append("  ").append(XMLHandler.addTagValue("extended_description", extendedDescription));
    retval.append("  ").append(XMLHandler.addTagValue("job_version", jobVersion));
    if (jobStatus >= 0) {
        retval.append("  ").append(XMLHandler.addTagValue("job_status", jobStatus));
    }
    retval.append("  ").append(XMLHandler.addTagValue("directory", (directory != null ? directory.getPath() : RepositoryDirectory.DIRECTORY_SEPARATOR)));
    retval.append("  ").append(XMLHandler.addTagValue("created_user", createdUser));
    retval.append("  ").append(XMLHandler.addTagValue("created_date", XMLHandler.date2string(createdDate)));
    retval.append("  ").append(XMLHandler.addTagValue("modified_user", modifiedUser));
    retval.append("  ").append(XMLHandler.addTagValue("modified_date", XMLHandler.date2string(modifiedDate)));
    retval.append("    ").append(XMLHandler.openTag(XML_TAG_PARAMETERS)).append(Const.CR);
    String[] parameters = listParameters();
    for (int idx = 0; idx < parameters.length; idx++) {
        retval.append("      ").append(XMLHandler.openTag("parameter")).append(Const.CR);
        retval.append("        ").append(XMLHandler.addTagValue("name", parameters[idx]));
        try {
            retval.append("        ").append(XMLHandler.addTagValue("default_value", getParameterDefault(parameters[idx])));
            retval.append("        ").append(XMLHandler.addTagValue("description", getParameterDescription(parameters[idx])));
        } catch (UnknownParamException e) {
        // skip the default value and/or description. This exception should never happen because we use listParameters()
        // above.
        }
        retval.append("      ").append(XMLHandler.closeTag("parameter")).append(Const.CR);
    }
    retval.append("    ").append(XMLHandler.closeTag(XML_TAG_PARAMETERS)).append(Const.CR);
    Set<DatabaseMeta> usedDatabaseMetas = getUsedDatabaseMetas();
    // Save the database connections...
    for (int i = 0; i < nrDatabases(); i++) {
        DatabaseMeta dbMeta = getDatabase(i);
        if (props != null && props.areOnlyUsedConnectionsSavedToXML()) {
            if (usedDatabaseMetas.contains(dbMeta)) {
                retval.append(dbMeta.getXML());
            }
        } else {
            retval.append(dbMeta.getXML());
        }
    }
    // The slave servers...
    // 
    retval.append("    ").append(XMLHandler.openTag(XML_TAG_SLAVESERVERS)).append(Const.CR);
    for (int i = 0; i < slaveServers.size(); i++) {
        SlaveServer slaveServer = slaveServers.get(i);
        retval.append(slaveServer.getXML());
    }
    retval.append("    ").append(XMLHandler.closeTag(XML_TAG_SLAVESERVERS)).append(Const.CR);
    // 
    for (LogTableInterface logTable : getLogTables()) {
        retval.append(logTable.getXML());
    }
    retval.append("   ").append(XMLHandler.addTagValue("pass_batchid", batchIdPassed));
    retval.append("   ").append(XMLHandler.addTagValue("shared_objects_file", sharedObjectsFile));
    retval.append("  ").append(XMLHandler.openTag("entries")).append(Const.CR);
    for (int i = 0; i < nrJobEntries(); i++) {
        JobEntryCopy jge = getJobEntry(i);
        jge.getEntry().setRepository(repository);
        retval.append(jge.getXML());
    }
    retval.append("  ").append(XMLHandler.closeTag("entries")).append(Const.CR);
    retval.append("  ").append(XMLHandler.openTag("hops")).append(Const.CR);
    for (JobHopMeta hi : jobhops) {
        // Look at all the hops
        retval.append(hi.getXML());
    }
    retval.append("  ").append(XMLHandler.closeTag("hops")).append(Const.CR);
    retval.append("  ").append(XMLHandler.openTag("notepads")).append(Const.CR);
    for (int i = 0; i < nrNotes(); i++) {
        NotePadMeta ni = getNote(i);
        retval.append(ni.getXML());
    }
    retval.append("  ").append(XMLHandler.closeTag("notepads")).append(Const.CR);
    // Also store the attribute groups
    // 
    retval.append(AttributesUtil.getAttributesXml(attributesMap));
    retval.append(XMLHandler.closeTag(XML_TAG)).append(Const.CR);
    return XMLFormatter.format(retval.toString());
}
Also used : Props(org.pentaho.di.core.Props) SlaveServer(org.pentaho.di.cluster.SlaveServer) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) LogTableInterface(org.pentaho.di.core.logging.LogTableInterface) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) UnknownParamException(org.pentaho.di.core.parameters.UnknownParamException) NotePadMeta(org.pentaho.di.core.NotePadMeta)

Example 29 with JobEntryCopy

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

the class JobMeta method renameJobEntryIfNameCollides.

/**
 * See if the name of the supplied job entry copy doesn't collide with any other job entry copy in the job.
 *
 * @param je The job entry copy to verify the name for.
 */
public void renameJobEntryIfNameCollides(JobEntryCopy je) {
    // First see if the name changed.
    // If so, we need to verify that the name is not already used in the
    // job.
    // 
    String newname = je.getName();
    // See if this name exists in the other job entries
    // 
    boolean found;
    int nr = 1;
    do {
        found = false;
        for (JobEntryCopy copy : jobcopies) {
            if (copy != je && copy.getName().equalsIgnoreCase(newname) && copy.getNr() == 0) {
                found = true;
            }
        }
        if (found) {
            nr++;
            newname = je.getName() + " (" + nr + ")";
        }
    } while (found);
    // Rename if required.
    // 
    je.setName(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 30 with JobEntryCopy

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

the class JobMeta method getSQLStatements.

/**
 * Builds a list of all the SQL statements that this transformation needs in order to work properly.
 *
 * @return An ArrayList of SQLStatement objects.
 */
public List<SQLStatement> getSQLStatements(Repository repository, IMetaStore metaStore, ProgressMonitorListener monitor) throws KettleException {
    if (monitor != null) {
        monitor.beginTask(BaseMessages.getString(PKG, "JobMeta.Monitor.GettingSQLNeededForThisJob"), nrJobEntries() + 1);
    }
    List<SQLStatement> stats = new ArrayList<SQLStatement>();
    for (int i = 0; i < nrJobEntries(); i++) {
        JobEntryCopy copy = getJobEntry(i);
        if (monitor != null) {
            monitor.subTask(BaseMessages.getString(PKG, "JobMeta.Monitor.GettingSQLForJobEntryCopy") + copy + "]");
        }
        stats.addAll(copy.getEntry().getSQLStatements(repository, metaStore, this));
        stats.addAll(compatibleGetEntrySQLStatements(copy.getEntry(), repository));
        stats.addAll(compatibleGetEntrySQLStatements(copy.getEntry(), repository, this));
        if (monitor != null) {
            monitor.worked(1);
        }
    }
    // Also check the sql for the logtable...
    if (monitor != null) {
        monitor.subTask(BaseMessages.getString(PKG, "JobMeta.Monitor.GettingSQLStatementsForJobLogTables"));
    }
    if (jobLogTable.getDatabaseMeta() != null && !Utils.isEmpty(jobLogTable.getTableName())) {
        Database db = new Database(this, jobLogTable.getDatabaseMeta());
        try {
            db.connect();
            RowMetaInterface fields = jobLogTable.getLogRecord(LogStatus.START, null, null).getRowMeta();
            String sql = db.getDDL(jobLogTable.getTableName(), fields);
            if (sql != null && sql.length() > 0) {
                SQLStatement stat = new SQLStatement(BaseMessages.getString(PKG, "JobMeta.SQLFeedback.ThisJob"), jobLogTable.getDatabaseMeta(), sql);
                stats.add(stat);
            }
        } catch (KettleDatabaseException dbe) {
            SQLStatement stat = new SQLStatement(BaseMessages.getString(PKG, "JobMeta.SQLFeedback.ThisJob"), jobLogTable.getDatabaseMeta(), null);
            stat.setError(BaseMessages.getString(PKG, "JobMeta.SQLFeedback.ErrorObtainingJobLogTableInfo") + dbe.getMessage());
            stats.add(stat);
        } finally {
            db.disconnect();
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    if (monitor != null) {
        monitor.done();
    }
    return stats;
}
Also used : JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) ArrayList(java.util.ArrayList) Database(org.pentaho.di.core.database.Database) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) SQLStatement(org.pentaho.di.core.SQLStatement) 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