use of org.pentaho.di.core.logging.LogTableInterface in project pentaho-kettle by pentaho.
the class JobDelegate method saveJobDetails.
private void saveJobDetails(DataNode rootNode, JobMeta jobMeta) throws KettleException {
rootNode.setProperty(PROP_EXTENDED_DESCRIPTION, jobMeta.getExtendedDescription());
rootNode.setProperty(PROP_JOB_VERSION, jobMeta.getJobversion());
rootNode.setProperty(PROP_JOB_STATUS, jobMeta.getJobstatus() < 0 ? -1L : jobMeta.getJobstatus());
if (jobMeta.getJobLogTable().getDatabaseMeta() != null) {
DataNodeRef ref = new DataNodeRef(jobMeta.getJobLogTable().getDatabaseMeta().getObjectId().getId());
rootNode.setProperty(PROP_DATABASE_LOG, ref);
}
rootNode.setProperty(PROP_TABLE_NAME_LOG, jobMeta.getJobLogTable().getTableName());
rootNode.setProperty(PROP_CREATED_USER, jobMeta.getCreatedUser());
rootNode.setProperty(PROP_CREATED_DATE, jobMeta.getCreatedDate());
rootNode.setProperty(PROP_MODIFIED_USER, jobMeta.getModifiedUser());
rootNode.setProperty(PROP_MODIFIED_DATE, jobMeta.getModifiedDate());
rootNode.setProperty(PROP_USE_BATCH_ID, jobMeta.getJobLogTable().isBatchIdUsed());
rootNode.setProperty(PROP_PASS_BATCH_ID, jobMeta.isBatchIdPassed());
rootNode.setProperty(PROP_USE_LOGFIELD, jobMeta.getJobLogTable().isLogFieldUsed());
rootNode.setProperty(PROP_SHARED_FILE, jobMeta.getSharedObjectsFile());
rootNode.setProperty(PROP_LOG_SIZE_LIMIT, jobMeta.getJobLogTable().getLogSizeLimit());
// Save the logging tables too..
//
RepositoryAttributeInterface attributeInterface = new PurRepositoryAttribute(rootNode, jobMeta.getDatabases());
for (LogTableInterface logTable : jobMeta.getLogTables()) {
logTable.saveToRepository(attributeInterface);
}
// Load the attributes map
//
AttributesMapUtil.saveAttributesMap(rootNode, jobMeta);
}
use of org.pentaho.di.core.logging.LogTableInterface in project pentaho-kettle by pentaho.
the class TransDelegate method saveTransformationDetails.
private void saveTransformationDetails(final DataNode rootNode, final TransMeta transMeta) throws KettleException {
rootNode.setProperty(PROP_EXTENDED_DESCRIPTION, transMeta.getExtendedDescription());
rootNode.setProperty(PROP_TRANS_VERSION, transMeta.getTransversion());
rootNode.setProperty(PROP_TRANS_STATUS, transMeta.getTransstatus() < 0 ? -1L : transMeta.getTransstatus());
rootNode.setProperty(PROP_STEP_READ, transMeta.getTransLogTable().getStepnameRead());
rootNode.setProperty(PROP_STEP_WRITE, transMeta.getTransLogTable().getStepnameWritten());
rootNode.setProperty(PROP_STEP_INPUT, transMeta.getTransLogTable().getStepnameInput());
rootNode.setProperty(PROP_STEP_OUTPUT, transMeta.getTransLogTable().getStepnameOutput());
rootNode.setProperty(PROP_STEP_UPDATE, transMeta.getTransLogTable().getStepnameUpdated());
rootNode.setProperty(PROP_STEP_REJECTED, transMeta.getTransLogTable().getStepnameRejected());
if (transMeta.getTransLogTable().getDatabaseMeta() != null) {
DataNodeRef ref = new DataNodeRef(transMeta.getTransLogTable().getDatabaseMeta().getObjectId().getId());
rootNode.setProperty(PROP_DATABASE_LOG, ref);
}
rootNode.setProperty(PROP_TABLE_NAME_LOG, transMeta.getTransLogTable().getTableName());
rootNode.setProperty(PROP_USE_BATCHID, Boolean.valueOf(transMeta.getTransLogTable().isBatchIdUsed()));
rootNode.setProperty(PROP_USE_LOGFIELD, Boolean.valueOf(transMeta.getTransLogTable().isLogFieldUsed()));
if (transMeta.getMaxDateConnection() != null) {
DataNodeRef ref = new DataNodeRef(transMeta.getMaxDateConnection().getObjectId().getId());
rootNode.setProperty(PROP_ID_DATABASE_MAXDATE, ref);
}
rootNode.setProperty(PROP_TABLE_NAME_MAXDATE, transMeta.getMaxDateTable());
rootNode.setProperty(PROP_FIELD_NAME_MAXDATE, transMeta.getMaxDateField());
rootNode.setProperty(PROP_OFFSET_MAXDATE, new Double(transMeta.getMaxDateOffset()));
rootNode.setProperty(PROP_DIFF_MAXDATE, new Double(transMeta.getMaxDateDifference()));
rootNode.setProperty(PROP_CREATED_USER, transMeta.getCreatedUser());
rootNode.setProperty(PROP_CREATED_DATE, transMeta.getCreatedDate());
rootNode.setProperty(PROP_MODIFIED_USER, transMeta.getModifiedUser());
rootNode.setProperty(PROP_MODIFIED_DATE, transMeta.getModifiedDate());
rootNode.setProperty(PROP_SIZE_ROWSET, transMeta.getSizeRowset());
rootNode.setProperty(PROP_UNIQUE_CONNECTIONS, transMeta.isUsingUniqueConnections());
rootNode.setProperty(PROP_FEEDBACK_SHOWN, transMeta.isFeedbackShown());
rootNode.setProperty(PROP_FEEDBACK_SIZE, transMeta.getFeedbackSize());
rootNode.setProperty(PROP_USING_THREAD_PRIORITIES, transMeta.isUsingThreadPriorityManagment());
rootNode.setProperty(PROP_SHARED_FILE, transMeta.getSharedObjectsFile());
rootNode.setProperty(PROP_CAPTURE_STEP_PERFORMANCE, transMeta.isCapturingStepPerformanceSnapShots());
rootNode.setProperty(PROP_STEP_PERFORMANCE_CAPTURING_DELAY, transMeta.getStepPerformanceCapturingDelay());
rootNode.setProperty(PROP_STEP_PERFORMANCE_CAPTURING_SIZE_LIMIT, transMeta.getStepPerformanceCapturingSizeLimit());
rootNode.setProperty(PROP_STEP_PERFORMANCE_LOG_TABLE, transMeta.getPerformanceLogTable().getTableName());
rootNode.setProperty(PROP_LOG_SIZE_LIMIT, transMeta.getTransLogTable().getLogSizeLimit());
rootNode.setProperty(PROP_LOG_INTERVAL, transMeta.getTransLogTable().getLogInterval());
rootNode.setProperty(PROP_TRANSFORMATION_TYPE, transMeta.getTransformationType().getCode());
// Save the logging tables too..
//
RepositoryAttributeInterface attributeInterface = new PurRepositoryAttribute(rootNode, transMeta.getDatabases());
for (LogTableInterface logTable : transMeta.getLogTables()) {
logTable.saveToRepository(attributeInterface);
}
// Save the transformation attribute groups map
//
AttributesMapUtil.saveAttributesMap(rootNode, transMeta);
}
use of org.pentaho.di.core.logging.LogTableInterface in project pentaho-kettle by pentaho.
the class KettleFileTableModel method getLogging.
public static String getLogging(ReportSubjectLocation filename) throws KettleException {
List<LogTableInterface> logTables;
if (filename.isTransformation()) {
TransMeta transMeta = TransformationInformation.getInstance().getTransMeta(filename);
logTables = transMeta.getLogTables();
} else {
JobMeta jobMeta = JobInformation.getInstance().getJobMeta(filename);
logTables = jobMeta.getLogTables();
}
String logging = "";
for (Iterator<LogTableInterface> iterator = logTables.iterator(); iterator.hasNext(); ) {
LogTableInterface logTableInterface = iterator.next();
if (logTableInterface.getDatabaseMeta() != null && !Utils.isEmpty(logTableInterface.getTableName())) {
if (logging.length() > 0) {
logging += ", ";
}
logging += logTableInterface.getTableName() + "@" + logTableInterface.getDatabaseMeta().getName();
}
}
return logging;
}
use of org.pentaho.di.core.logging.LogTableInterface in project pentaho-kettle by pentaho.
the class TransDialog method sql.
/**
* Generates code for create table... Conversions done by Database
*/
private void sql() {
getLogInfo();
try {
boolean allOK = true;
for (LogTableInterface logTable : new LogTableInterface[] { transLogTable, performanceLogTable, channelLogTable, stepLogTable, metricsLogTable }) {
if (logTable.getDatabaseMeta() != null && !Utils.isEmpty(logTable.getTableName())) {
// OK, we have something to work with!
//
Database db = null;
try {
db = new Database(transMeta, logTable.getDatabaseMeta());
db.shareVariablesWith(transMeta);
db.connect();
StringBuilder ddl = new StringBuilder();
RowMetaInterface fields = logTable.getLogRecord(LogStatus.START, null, null).getRowMeta();
String tableName = db.environmentSubstitute(logTable.getTableName());
String schemaTable = logTable.getDatabaseMeta().getQuotedSchemaTableCombination(db.environmentSubstitute(logTable.getSchemaName()), tableName);
String createTable = db.getDDL(schemaTable, fields);
if (!Utils.isEmpty(createTable)) {
ddl.append("-- ").append(logTable.getLogTableType()).append(Const.CR);
ddl.append("--").append(Const.CR).append(Const.CR);
ddl.append(createTable).append(Const.CR);
}
java.util.List<RowMetaInterface> indexes = logTable.getRecommendedIndexes();
for (int i = 0; i < indexes.size(); i++) {
RowMetaInterface index = indexes.get(i);
if (!index.isEmpty()) {
String createIndex = db.getCreateIndexStatement(schemaTable, "IDX_" + tableName + "_" + (i + 1), index.getFieldNames(), false, false, false, true);
if (!Utils.isEmpty(createIndex)) {
ddl.append(createIndex);
}
}
}
if (ddl.length() > 0) {
allOK = false;
SQLEditor sqledit = new SQLEditor(transMeta, shell, SWT.NONE, logTable.getDatabaseMeta(), transMeta.getDbCache(), ddl.toString());
sqledit.open();
}
} finally {
if (db != null) {
db.disconnect();
}
}
}
}
if (allOK) {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_INFORMATION);
mb.setText(BaseMessages.getString(PKG, "TransDialog.NoSqlNedds.DialogTitle"));
mb.setMessage(BaseMessages.getString(PKG, "TransDialog.NoSqlNedds.DialogMessage"));
mb.open();
}
} catch (Exception e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "TransDialog.ErrorOccurred.DialogTitle"), BaseMessages.getString(PKG, "TransDialog.ErrorOccurred.DialogMessage"), e);
}
}
use of org.pentaho.di.core.logging.LogTableInterface in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryTransDelegate method loadTransformation.
/**
* Read a transformation with a certain name from a repository
*
* @param rep
* The repository to read from.
* @param transname
* The name of the transformation.
* @param repdir
* the path to the repository directory
* @param monitor
* The progress monitor to display the progress of the file-open operation in a dialog
* @param setInternalVariables
* true if you want to set the internal variables based on this transformation information
*/
public TransMeta loadTransformation(TransMeta transMeta, String transname, RepositoryDirectoryInterface repdir, ProgressMonitorListener monitor, boolean setInternalVariables) throws KettleException {
transMeta.setRepository(repository);
transMeta.setMetaStore(repository.metaStore);
synchronized (repository) {
try {
String pathAndName = repdir.isRoot() ? repdir + transname : repdir + RepositoryDirectory.DIRECTORY_SEPARATOR + transname;
transMeta.setName(transname);
transMeta.setRepositoryDirectory(repdir);
// Get the transformation id
if (log.isDetailed()) {
log.logDetailed(BaseMessages.getString(PKG, "TransMeta.Log.LookingForTransformation", transname, repdir.getPath()));
}
if (monitor != null) {
monitor.subTask(BaseMessages.getString(PKG, "TransMeta.Monitor.ReadingTransformationInfoTask.Title"));
}
transMeta.setObjectId(getTransformationID(transname, repdir.getObjectId()));
if (monitor != null) {
monitor.worked(1);
}
// If no valid id is available in the database, then give error...
if (transMeta.getObjectId() != null) {
ObjectId[] noteids = repository.getTransNoteIDs(transMeta.getObjectId());
ObjectId[] stepids = repository.getStepIDs(transMeta.getObjectId());
ObjectId[] hopids = getTransHopIDs(transMeta.getObjectId());
int nrWork = 3 + noteids.length + stepids.length + hopids.length;
if (monitor != null) {
monitor.beginTask(BaseMessages.getString(PKG, "TransMeta.Monitor.LoadingTransformationTask.Title") + pathAndName, nrWork);
}
if (log.isDetailed()) {
log.logDetailed(BaseMessages.getString(PKG, "TransMeta.Log.LoadingTransformation", transMeta.getName()));
}
// Load the common database connections
if (monitor != null) {
monitor.subTask(BaseMessages.getString(PKG, "TransMeta.Monitor.ReadingTheAvailableSharedObjectsTask.Title"));
}
try {
transMeta.setSharedObjects(readTransSharedObjects(transMeta));
} catch (Exception e) {
log.logError(BaseMessages.getString(PKG, "TransMeta.ErrorReadingSharedObjects.Message", e.toString()));
log.logError(Const.getStackTracker(e));
}
if (monitor != null) {
monitor.worked(1);
}
// Load the notes...
if (monitor != null) {
monitor.subTask(BaseMessages.getString(PKG, "TransMeta.Monitor.ReadingNoteTask.Title"));
}
for (int i = 0; i < noteids.length; i++) {
NotePadMeta ni = repository.notePadDelegate.loadNotePadMeta(noteids[i]);
if (transMeta.indexOfNote(ni) < 0) {
transMeta.addNote(ni);
}
if (monitor != null) {
monitor.worked(1);
}
}
if (monitor != null) {
monitor.subTask(BaseMessages.getString(PKG, "TransMeta.Monitor.ReadingStepsTask.Title"));
}
// read all the attributes
repository.connectionDelegate.fillStepAttributesBuffer(transMeta.getObjectId());
// on one go!
for (int i = 0; i < stepids.length; i++) {
if (log.isDetailed()) {
log.logDetailed(BaseMessages.getString(PKG, "TransMeta.Log.LoadingStepWithID") + stepids[i]);
}
if (monitor != null) {
monitor.subTask(BaseMessages.getString(PKG, "TransMeta.Monitor.ReadingStepTask.Title") + (i + 1) + "/" + (stepids.length));
}
StepMeta stepMeta = repository.stepDelegate.loadStepMeta(stepids[i], transMeta.getDatabases(), transMeta.getPartitionSchemas());
if (stepMeta.isMissing()) {
transMeta.addMissingTrans((MissingTrans) stepMeta.getStepMetaInterface());
}
// In this case, we just add or replace the shared steps.
// The repository is considered "more central"
transMeta.addOrReplaceStep(stepMeta);
if (monitor != null) {
monitor.worked(1);
}
}
if (monitor != null) {
monitor.worked(1);
}
// clear the buffer (should be empty anyway)
repository.connectionDelegate.setStepAttributesBuffer(null);
// Have all StreamValueLookups, etc. reference the correct source steps...
for (int i = 0; i < transMeta.nrSteps(); i++) {
StepMetaInterface sii = transMeta.getStep(i).getStepMetaInterface();
sii.searchInfoAndTargetSteps(transMeta.getSteps());
}
if (monitor != null) {
monitor.subTask(BaseMessages.getString(PKG, "TransMeta.Monitor.LoadingTransformationDetailsTask.Title"));
}
loadRepTrans(transMeta);
if (monitor != null) {
monitor.worked(1);
}
if (monitor != null) {
monitor.subTask(BaseMessages.getString(PKG, "TransMeta.Monitor.ReadingHopTask.Title"));
}
for (int i = 0; i < hopids.length; i++) {
TransHopMeta hi = loadTransHopMeta(hopids[i], transMeta.getSteps());
if (hi != null) {
transMeta.addTransHop(hi);
}
if (monitor != null) {
monitor.worked(1);
}
}
//
for (int i = 0; i < transMeta.nrSteps(); i++) {
StepPartitioningMeta stepPartitioningMeta = transMeta.getStep(i).getStepPartitioningMeta();
if (stepPartitioningMeta != null) {
stepPartitioningMeta.setPartitionSchemaAfterLoading(transMeta.getPartitionSchemas());
}
}
//
for (int i = 0; i < transMeta.nrSteps(); i++) {
transMeta.getStep(i).setClusterSchemaAfterLoading(transMeta.getClusterSchemas());
}
if (monitor != null) {
monitor.subTask(BaseMessages.getString(PKG, "TransMeta.Monitor.ReadingTheDependenciesTask.Title"));
}
ObjectId[] depids = repository.getTransDependencyIDs(transMeta.getObjectId());
for (int i = 0; i < depids.length; i++) {
TransDependency td = loadTransDependency(depids[i], transMeta.getDatabases());
transMeta.addDependency(td);
}
if (monitor != null) {
monitor.worked(1);
}
// Load the group attributes map
//
transMeta.setAttributesMap(loadTransAttributesMap(transMeta.getObjectId()));
//
for (int i = 0; i < transMeta.nrSteps(); i++) {
StepMeta stepMeta = transMeta.getStep(i);
String sourceStep = repository.getStepAttributeString(stepMeta.getObjectId(), "step_error_handling_source_step");
if (sourceStep != null) {
StepErrorMeta stepErrorMeta = repository.stepDelegate.loadStepErrorMeta(transMeta, stepMeta, transMeta.getSteps());
// a bit of a trick, I know.
stepErrorMeta.getSourceStep().setStepErrorMeta(stepErrorMeta);
}
}
// Load all the log tables for the transformation...
//
RepositoryAttributeInterface attributeInterface = new KettleDatabaseRepositoryTransAttribute(repository.connectionDelegate, transMeta.getObjectId());
for (LogTableInterface logTable : transMeta.getLogTables()) {
logTable.loadFromRepository(attributeInterface);
}
if (monitor != null) {
monitor.subTask(BaseMessages.getString(PKG, "TransMeta.Monitor.SortingStepsTask.Title"));
}
transMeta.sortSteps();
if (monitor != null) {
monitor.worked(1);
}
if (monitor != null) {
monitor.done();
}
} else {
throw new KettleException(BaseMessages.getString(PKG, "TransMeta.Exception.TransformationDoesNotExist") + transMeta.getName());
}
if (log.isDetailed()) {
log.logDetailed(BaseMessages.getString(PKG, "TransMeta.Log.LoadedTransformation2", transname, String.valueOf(transMeta.getRepositoryDirectory() == null)));
log.logDetailed(BaseMessages.getString(PKG, "TransMeta.Log.LoadedTransformation", transname, transMeta.getRepositoryDirectory().getPath()));
}
// close prepared statements, minimize locking etc.
//
repository.connectionDelegate.closeAttributeLookupPreparedStatements();
return transMeta;
} catch (KettleDatabaseException e) {
log.logError(BaseMessages.getString(PKG, "TransMeta.Log.DatabaseErrorOccuredReadingTransformation") + Const.CR + e);
throw new KettleException(BaseMessages.getString(PKG, "TransMeta.Exception.DatabaseErrorOccuredReadingTransformation"), e);
} catch (Exception e) {
log.logError(BaseMessages.getString(PKG, "TransMeta.Log.DatabaseErrorOccuredReadingTransformation") + Const.CR + e);
throw new KettleException(BaseMessages.getString(PKG, "TransMeta.Exception.DatabaseErrorOccuredReadingTransformation2"), e);
} finally {
transMeta.initializeVariablesFrom(null);
if (setInternalVariables) {
transMeta.setInternalKettleVariables();
}
}
}
}
Aggregations