use of org.pentaho.di.core.RowMetaAndData in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryJobDelegate method renameJob.
public synchronized void renameJob(ObjectId id_job, RepositoryDirectoryInterface newParentDir, String newname) throws KettleException {
if (newParentDir != null || newname != null) {
RowMetaAndData table = new RowMetaAndData();
String sql = "UPDATE " + quoteTable(KettleDatabaseRepository.TABLE_R_JOB) + " SET ";
boolean additionalParameter = false;
if (newname != null) {
additionalParameter = true;
sql += quote(KettleDatabaseRepository.FIELD_JOB_NAME) + " = ? ";
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_JOB_NAME), newname);
}
if (newParentDir != null) {
if (additionalParameter) {
sql += ", ";
}
sql += quote(KettleDatabaseRepository.FIELD_JOB_ID_DIRECTORY) + " = ? ";
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOB_ID_DIRECTORY), newParentDir.getObjectId());
}
sql += "WHERE " + quote(KettleDatabaseRepository.FIELD_JOB_ID_JOB) + " = ?";
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOB_ID_JOB), id_job);
log.logBasic("sql = [" + sql + "]");
log.logBasic("row = [" + table + "]");
repository.connectionDelegate.getDatabase().execStatement(sql, table.getRowMeta(), table.getData());
}
}
use of org.pentaho.di.core.RowMetaAndData in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryJobDelegate method moveJob.
public synchronized void moveJob(String jobname, ObjectId id_directory_from, ObjectId id_directory_to) throws KettleException {
String sql = "UPDATE " + quoteTable(KettleDatabaseRepository.TABLE_R_JOB) + " SET " + quote(KettleDatabaseRepository.FIELD_JOB_ID_DIRECTORY) + " = ? WHERE " + quote(KettleDatabaseRepository.FIELD_JOB_NAME) + " = ? AND " + quote(KettleDatabaseRepository.FIELD_JOB_ID_DIRECTORY) + " = ?";
RowMetaAndData par = new RowMetaAndData();
par.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOB_ID_DIRECTORY), id_directory_to);
par.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_JOB_NAME), jobname);
par.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOB_ID_DIRECTORY), id_directory_from);
repository.connectionDelegate.getDatabase().execStatement(sql, par.getRowMeta(), par.getData());
}
use of org.pentaho.di.core.RowMetaAndData in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryJobDelegate method insertJob.
private synchronized void insertJob(JobMeta jobMeta) throws KettleException {
RowMetaAndData table = new RowMetaAndData();
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOB_ID_JOB), jobMeta.getObjectId());
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOB_ID_DIRECTORY), jobMeta.getRepositoryDirectory().getObjectId());
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_JOB_NAME), jobMeta.getName());
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_JOB_DESCRIPTION), jobMeta.getDescription());
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_JOB_EXTENDED_DESCRIPTION), jobMeta.getExtendedDescription());
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_JOB_JOB_VERSION), jobMeta.getJobversion());
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOB_JOB_STATUS), new Long(jobMeta.getJobstatus() < 0 ? -1L : jobMeta.getJobstatus()));
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOB_ID_DATABASE_LOG), jobMeta.getJobLogTable().getDatabaseMeta() != null ? jobMeta.getJobLogTable().getDatabaseMeta().getObjectId() : -1L);
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_JOB_TABLE_NAME_LOG), jobMeta.getJobLogTable().getTableName());
table.addValue(new ValueMetaBoolean(KettleDatabaseRepository.FIELD_JOB_USE_BATCH_ID), jobMeta.getJobLogTable().isBatchIdUsed());
table.addValue(new ValueMetaBoolean(KettleDatabaseRepository.FIELD_JOB_USE_LOGFIELD), jobMeta.getJobLogTable().isLogFieldUsed());
repository.connectionDelegate.insertJobAttribute(jobMeta.getObjectId(), 0, KettleDatabaseRepository.JOB_ATTRIBUTE_LOG_SIZE_LIMIT, 0, jobMeta.getJobLogTable().getLogSizeLimit());
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_JOB_CREATED_USER), jobMeta.getCreatedUser());
table.addValue(new ValueMetaDate(KettleDatabaseRepository.FIELD_JOB_CREATED_DATE), jobMeta.getCreatedDate());
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_JOB_MODIFIED_USER), jobMeta.getModifiedUser());
table.addValue(new ValueMetaDate(KettleDatabaseRepository.FIELD_JOB_MODIFIED_DATE), jobMeta.getModifiedDate());
table.addValue(new ValueMetaBoolean(KettleDatabaseRepository.FIELD_JOB_PASS_BATCH_ID), jobMeta.isBatchIdPassed());
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_JOB_SHARED_FILE), jobMeta.getSharedObjectsFile());
repository.connectionDelegate.getDatabase().prepareInsert(table.getRowMeta(), KettleDatabaseRepository.TABLE_R_JOB);
repository.connectionDelegate.getDatabase().setValuesInsert(table);
repository.connectionDelegate.getDatabase().insertRow();
if (log.isDebug()) {
log.logDebug("Inserted new record into table " + quoteTable(KettleDatabaseRepository.TABLE_R_JOB) + " with data : " + table);
}
repository.connectionDelegate.getDatabase().closeInsert();
// Save the logging connection link...
if (jobMeta.getJobLogTable().getDatabaseMeta() != null) {
repository.insertJobEntryDatabase(jobMeta.getObjectId(), null, jobMeta.getJobLogTable().getDatabaseMeta().getObjectId());
}
// Save the logging tables too..
//
RepositoryAttributeInterface attributeInterface = new KettleDatabaseRepositoryJobAttribute(repository.connectionDelegate, jobMeta.getObjectId());
for (LogTableInterface logTable : jobMeta.getLogTables()) {
logTable.saveToRepository(attributeInterface);
}
}
use of org.pentaho.di.core.RowMetaAndData in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryJobDelegate method getJobsWithIDList.
public String[] getJobsWithIDList(List<Object[]> list, RowMetaInterface rowMeta) throws KettleException {
String[] jobList = new String[list.size()];
for (int i = 0; i < list.size(); i++) {
long id_job = rowMeta.getInteger(list.get(i), quote(KettleDatabaseRepository.FIELD_JOB_ID_JOB), -1L);
if (id_job > 0) {
RowMetaAndData jobRow = getJob(new LongObjectId(id_job));
if (jobRow != null) {
String jobName = jobRow.getString(KettleDatabaseRepository.FIELD_JOB_NAME, "<name not found>");
long id_directory = jobRow.getInteger(KettleDatabaseRepository.FIELD_JOB_ID_DIRECTORY, -1L);
RepositoryDirectoryInterface dir = // always
repository.loadRepositoryDirectoryTree().findDirectory(new LongObjectId(id_directory));
// reload the
// directory
// tree!
jobList[i] = dir.getPathObjectCombination(jobName);
}
}
}
return jobList;
}
use of org.pentaho.di.core.RowMetaAndData in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryJobEntryDelegate method loadJobEntryCopy.
/**
* Load the chef graphical entry from repository We load type, name & description if no entry can be found.
*
* @param log
* the logging channel
* @param rep
* the Repository
* @param jobId
* The job ID
* @param jobEntryCopyId
* The jobentry copy ID
* @param jobentries
* A list with all jobentries
* @param databases
* A list with all defined databases
*/
public JobEntryCopy loadJobEntryCopy(ObjectId jobId, ObjectId jobEntryCopyId, List<JobEntryInterface> jobentries, List<DatabaseMeta> databases, List<SlaveServer> slaveServers, String jobname) throws KettleException {
JobEntryCopy jobEntryCopy = new JobEntryCopy();
try {
jobEntryCopy.setObjectId(jobEntryCopyId);
// Handle GUI information: nr, location, ...
RowMetaAndData r = getJobEntryCopy(jobEntryCopyId);
if (r != null) {
// These are the jobentry_copy fields...
//
ObjectId jobEntryId = new LongObjectId(r.getInteger(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_ID_JOBENTRY, 0));
ObjectId jobEntryTypeId = new LongObjectId(r.getInteger(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_ID_JOBENTRY_TYPE, 0));
jobEntryCopy.setNr((int) r.getInteger(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_NR, 0));
int locx = (int) r.getInteger(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_GUI_LOCATION_X, 0);
int locy = (int) r.getInteger(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_GUI_LOCATION_Y, 0);
boolean isdrawn = r.getBoolean(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_GUI_DRAW, false);
boolean isparallel = r.getBoolean(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_PARALLEL, false);
// Do we have the jobentry already?
//
jobEntryCopy.setEntry(JobMeta.findJobEntry(jobentries, jobEntryId));
if (jobEntryCopy.getEntry() == null) {
// What type of jobentry do we load now?
// Get the jobentry type code
//
RowMetaAndData rt = getJobEntryType(new LongObjectId(jobEntryTypeId));
if (rt != null) {
String jet_code = rt.getString(KettleDatabaseRepository.FIELD_JOBENTRY_TYPE_CODE, null);
JobEntryInterface jobEntry = null;
PluginRegistry registry = PluginRegistry.getInstance();
PluginInterface jobPlugin = registry.findPluginWithId(JobEntryPluginType.class, jet_code);
if (jobPlugin == null) {
jobEntry = new MissingEntry(jobname, jet_code);
} else {
jobEntry = (JobEntryInterface) registry.loadClass(jobPlugin);
}
if (jobEntry != null) {
jobEntryCopy.setEntry(jobEntry);
//
if (jobEntry instanceof JobEntryBase) {
loadJobEntryBase((JobEntryBase) jobEntry, jobEntryId, databases, slaveServers);
((JobEntryBase) jobEntry).setAttributesMap(loadJobEntryAttributesMap(jobId, jobEntryId));
}
compatibleJobEntryLoadRep(jobEntry, repository, jobEntryTypeId, databases, slaveServers);
jobEntry.loadRep(repository, repository.metaStore, jobEntryId, databases, slaveServers);
jobEntryCopy.getEntry().setObjectId(jobEntryId);
jobentries.add(jobEntryCopy.getEntry());
} else {
throw new KettleException("JobEntryLoader was unable to find Job Entry Plugin with description [" + jet_code + "].");
}
} else {
throw new KettleException("Unable to find Job Entry Type with id=" + jobEntryTypeId + " in the repository");
}
}
jobEntryCopy.setLocation(locx, locy);
jobEntryCopy.setDrawn(isdrawn);
jobEntryCopy.setLaunchingInParallel(isparallel);
return jobEntryCopy;
} else {
throw new KettleException("Unable to find job entry copy in repository with id_jobentry_copy=" + jobEntryCopyId);
}
} catch (KettleDatabaseException dbe) {
throw new KettleException("Unable to load job entry copy from repository with id_jobentry_copy=" + jobEntryCopyId, dbe);
}
}
Aggregations