use of org.pentaho.di.core.RowMetaAndData in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryTransDelegate method insertTransformation.
// CHECKSTYLE:LineLength:OFF
private synchronized void insertTransformation(TransMeta transMeta) throws KettleException {
RowMetaAndData table = new RowMetaAndData();
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_TRANSFORMATION), new LongObjectId(transMeta.getObjectId()));
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_TRANSFORMATION_NAME), transMeta.getName());
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_TRANSFORMATION_DESCRIPTION), transMeta.getDescription());
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_TRANSFORMATION_EXTENDED_DESCRIPTION), transMeta.getExtendedDescription());
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_TRANSFORMATION_TRANS_VERSION), transMeta.getTransversion());
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_TRANS_STATUS), new Long(transMeta.getTransstatus() < 0 ? -1L : transMeta.getTransstatus()));
TransLogTable logTable = transMeta.getTransLogTable();
StepMeta step = (StepMeta) logTable.getSubject(TransLogTable.ID.LINES_READ);
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_STEP_READ), step == null ? null : step.getObjectId());
step = (StepMeta) logTable.getSubject(TransLogTable.ID.LINES_WRITTEN);
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_STEP_WRITE), step == null ? null : step.getObjectId());
step = (StepMeta) logTable.getSubject(TransLogTable.ID.LINES_INPUT);
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_STEP_INPUT), step == null ? null : step.getObjectId());
step = (StepMeta) logTable.getSubject(TransLogTable.ID.LINES_OUTPUT);
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_STEP_OUTPUT), step == null ? null : step.getObjectId());
step = (StepMeta) logTable.getSubject(TransLogTable.ID.LINES_UPDATED);
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_STEP_UPDATE), step == null ? null : step.getObjectId());
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_DATABASE_LOG), logTable.getDatabaseMeta() == null ? new LongObjectId(-1L).longValue() : new LongObjectId(logTable.getDatabaseMeta().getObjectId()).longValue());
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_TRANSFORMATION_TABLE_NAME_LOG), logTable.getDatabaseMeta());
table.addValue(new ValueMetaBoolean(KettleDatabaseRepository.FIELD_TRANSFORMATION_USE_BATCHID), Boolean.valueOf(logTable.isBatchIdUsed()));
table.addValue(new ValueMetaBoolean(KettleDatabaseRepository.FIELD_TRANSFORMATION_USE_LOGFIELD), Boolean.valueOf(logTable.isLogFieldUsed()));
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_DATABASE_MAXDATE), transMeta.getMaxDateConnection() == null ? new LongObjectId(-1L).longValue() : new LongObjectId(transMeta.getMaxDateConnection().getObjectId()).longValue());
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_TRANSFORMATION_TABLE_NAME_MAXDATE), transMeta.getMaxDateTable());
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_TRANSFORMATION_FIELD_NAME_MAXDATE), transMeta.getMaxDateField());
table.addValue(new ValueMetaNumber(KettleDatabaseRepository.FIELD_TRANSFORMATION_OFFSET_MAXDATE), new Double(transMeta.getMaxDateOffset()));
table.addValue(new ValueMetaNumber(KettleDatabaseRepository.FIELD_TRANSFORMATION_DIFF_MAXDATE), new Double(transMeta.getMaxDateDifference()));
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_TRANSFORMATION_CREATED_USER), transMeta.getCreatedUser());
table.addValue(new ValueMetaDate(KettleDatabaseRepository.FIELD_TRANSFORMATION_CREATED_DATE), transMeta.getCreatedDate());
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_TRANSFORMATION_MODIFIED_USER), transMeta.getModifiedUser());
table.addValue(new ValueMetaDate(KettleDatabaseRepository.FIELD_TRANSFORMATION_MODIFIED_DATE), transMeta.getModifiedDate());
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_SIZE_ROWSET), new Long(transMeta.getSizeRowset()));
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_DIRECTORY), transMeta.getRepositoryDirectory().getObjectId());
repository.connectionDelegate.getDatabase().prepareInsert(table.getRowMeta(), KettleDatabaseRepository.TABLE_R_TRANSFORMATION);
repository.connectionDelegate.getDatabase().setValuesInsert(table);
repository.connectionDelegate.getDatabase().insertRow();
repository.connectionDelegate.getDatabase().closeInsert();
step = (StepMeta) logTable.getSubject(TransLogTable.ID.LINES_REJECTED);
if (step != null) {
ObjectId rejectedId = step.getObjectId();
repository.connectionDelegate.insertTransAttribute(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_ID_STEP_REJECTED, rejectedId == null ? null : Long.valueOf(rejectedId.toString()), null);
}
repository.connectionDelegate.insertTransAttribute(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_UNIQUE_CONNECTIONS, 0, transMeta.isUsingUniqueConnections() ? "Y" : "N");
repository.connectionDelegate.insertTransAttribute(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_FEEDBACK_SHOWN, 0, transMeta.isFeedbackShown() ? "Y" : "N");
repository.connectionDelegate.insertTransAttribute(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_FEEDBACK_SIZE, transMeta.getFeedbackSize(), "");
repository.connectionDelegate.insertTransAttribute(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_USING_THREAD_PRIORITIES, 0, transMeta.isUsingThreadPriorityManagment() ? "Y" : "N");
repository.connectionDelegate.insertTransAttribute(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_SHARED_FILE, 0, transMeta.getSharedObjectsFile());
repository.connectionDelegate.insertTransAttribute(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_CAPTURE_STEP_PERFORMANCE, 0, transMeta.isCapturingStepPerformanceSnapShots() ? "Y" : "N");
repository.connectionDelegate.insertTransAttribute(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_STEP_PERFORMANCE_CAPTURING_DELAY, transMeta.getStepPerformanceCapturingDelay(), "");
repository.connectionDelegate.insertTransAttribute(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_STEP_PERFORMANCE_CAPTURING_SIZE_LIMIT, 0, transMeta.getStepPerformanceCapturingSizeLimit());
repository.connectionDelegate.insertTransAttribute(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_STEP_PERFORMANCE_LOG_TABLE, 0, transMeta.getPerformanceLogTable().getTableName());
repository.connectionDelegate.insertTransAttribute(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_LOG_SIZE_LIMIT, 0, transMeta.getTransLogTable().getLogSizeLimit());
repository.connectionDelegate.insertTransAttribute(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_LOG_INTERVAL, 0, transMeta.getTransLogTable().getLogInterval());
repository.connectionDelegate.insertTransAttribute(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_TRANSFORMATION_TYPE, 0, transMeta.getTransformationType().getCode());
repository.connectionDelegate.insertTransAttribute(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_SLEEP_TIME_EMPTY, transMeta.getSleepTimeEmpty(), null);
repository.connectionDelegate.insertTransAttribute(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_SLEEP_TIME_FULL, transMeta.getSleepTimeFull(), null);
// Save the logging connection link...
if (logTable.getDatabaseMeta() != null) {
repository.insertStepDatabase(transMeta.getObjectId(), null, logTable.getDatabaseMeta().getObjectId());
}
// Save the maxdate connection link...
if (transMeta.getMaxDateConnection() != null) {
repository.insertStepDatabase(transMeta.getObjectId(), null, transMeta.getMaxDateConnection().getObjectId());
}
// Save the logging tables too..
//
RepositoryAttributeInterface attributeInterface = new KettleDatabaseRepositoryTransAttribute(repository.connectionDelegate, transMeta.getObjectId());
transMeta.getTransLogTable().saveToRepository(attributeInterface);
transMeta.getStepLogTable().saveToRepository(attributeInterface);
transMeta.getPerformanceLogTable().saveToRepository(attributeInterface);
transMeta.getChannelLogTable().saveToRepository(attributeInterface);
}
use of org.pentaho.di.core.RowMetaAndData in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryTransDelegate method loadTransDependency.
public TransDependency loadTransDependency(ObjectId id_dependency, List<DatabaseMeta> databases) throws KettleException {
TransDependency transDependency = new TransDependency();
try {
transDependency.setObjectId(id_dependency);
RowMetaAndData r = getTransDependency(id_dependency);
if (r != null) {
long id_connection = r.getInteger("ID_DATABASE", 0);
transDependency.setDatabase(DatabaseMeta.findDatabase(databases, new LongObjectId(id_connection)));
transDependency.setTablename(r.getString("TABLE_NAME", null));
transDependency.setFieldname(r.getString("FIELD_NAME", null));
}
return transDependency;
} catch (KettleException dbe) {
throw new KettleException(BaseMessages.getString(PKG, "TransDependency.Exception.UnableToLoadTransformationDependency") + id_dependency, dbe);
}
}
use of org.pentaho.di.core.RowMetaAndData in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryTransDelegate method loadTransHopMeta.
public TransHopMeta loadTransHopMeta(ObjectId id_trans_hop, List<StepMeta> steps) throws KettleException {
TransHopMeta hopTransMeta = new TransHopMeta();
try {
hopTransMeta.setObjectId(id_trans_hop);
RowMetaAndData r = getTransHop(id_trans_hop);
hopTransMeta.setEnabled(r.getBoolean("ENABLED", false));
long id_step_from = r.getInteger("ID_STEP_FROM", 0);
long id_step_to = r.getInteger("ID_STEP_TO", 0);
StepMeta fromStep = StepMeta.findStep(steps, new LongObjectId(id_step_from));
//
if (fromStep == null && id_step_from > 0) {
// Simply load this, we only want the name, we don't care about the
// rest...
//
StepMeta stepMeta = repository.stepDelegate.loadStepMeta(new LongObjectId(id_step_from), new ArrayList<DatabaseMeta>(), new ArrayList<PartitionSchema>());
fromStep = StepMeta.findStep(steps, stepMeta.getName());
}
if (fromStep == null) {
log.logError("Unable to determine source step of transformation hop with ID: " + id_trans_hop);
// Invalid hop, simply ignore. See: PDI-2446
return null;
}
hopTransMeta.setFromStep(fromStep);
hopTransMeta.getFromStep().setDraw(true);
hopTransMeta.setToStep(StepMeta.findStep(steps, new LongObjectId(id_step_to)));
//
if (hopTransMeta.getToStep() == null && id_step_to > 0) {
// Simply load this, we only want the name, we don't care about
// the rest...
StepMeta stepMeta = repository.stepDelegate.loadStepMeta(new LongObjectId(id_step_to), new ArrayList<DatabaseMeta>(), new ArrayList<PartitionSchema>());
hopTransMeta.setToStep(StepMeta.findStep(steps, stepMeta.getName()));
}
if (hopTransMeta.getFromStep() == null || hopTransMeta.getFromStep() == null) {
//
return null;
}
hopTransMeta.getToStep().setDraw(true);
return hopTransMeta;
} catch (KettleDatabaseException dbe) {
throw new KettleException(BaseMessages.getString(PKG, "TransHopMeta.Exception.LoadTransformationHopInfo") + id_trans_hop, dbe);
}
}
use of org.pentaho.di.core.RowMetaAndData in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryTransDelegate method renameTransformation.
public synchronized void renameTransformation(ObjectId id_transformation, RepositoryDirectoryInterface newParentDir, String newname) throws KettleException {
if (newParentDir != null || newname != null) {
RowMetaAndData table = new RowMetaAndData();
String sql = "UPDATE " + quoteTable(KettleDatabaseRepository.TABLE_R_TRANSFORMATION) + " SET ";
boolean additionalParameter = false;
if (newname != null) {
additionalParameter = true;
sql += quote(KettleDatabaseRepository.FIELD_TRANSFORMATION_NAME) + " = ? ";
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_TRANSFORMATION_NAME), newname);
}
if (newParentDir != null) {
if (additionalParameter) {
sql += ", ";
}
sql += quote(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_DIRECTORY) + " = ? ";
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_DIRECTORY), newParentDir.getObjectId());
}
sql += "WHERE " + quote(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_TRANSFORMATION) + " = ?";
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_TRANSFORMATION), id_transformation);
log.logBasic("sql = [" + sql + "]");
log.logBasic("row = [" + table + "]");
repository.connectionDelegate.getDatabase().execStatement(sql, table.getRowMeta(), table.getData());
repository.connectionDelegate.getDatabase().commit();
}
}
use of org.pentaho.di.core.RowMetaAndData in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryTransDelegate method getTransformationsWithIDList.
public String[] getTransformationsWithIDList(ObjectId[] ids) throws KettleException {
String[] transList = new String[ids.length];
for (int i = 0; i < ids.length; i++) {
ObjectId id_transformation = ids[i];
if (id_transformation != null) {
RowMetaAndData transRow = getTransformation(id_transformation);
if (transRow != null) {
String transName = transRow.getString(KettleDatabaseRepository.FIELD_TRANSFORMATION_NAME, "<name not found>");
long id_directory = transRow.getInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_DIRECTORY, -1L);
RepositoryDirectoryInterface dir = repository.loadRepositoryDirectoryTree().findDirectory(new LongObjectId(id_directory));
transList[i] = dir.getPathObjectCombination(transName);
}
}
}
return transList;
}
Aggregations