use of org.pentaho.di.repository.LongObjectId in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryCreationHelper method updateStepTypes.
/**
* Update the list in R_STEP_TYPE using the StepLoader StepPlugin entries
*
* @throws KettleException
* if the update didn't go as planned.
*/
public List<String> updateStepTypes(List<String> statements, boolean dryrun, boolean create) throws KettleException {
synchronized (repository) {
// We should only do an update if something has changed...
//
List<PluginInterface> plugins = pluginRegistry.getPlugins(StepPluginType.class);
ObjectId[] ids = loadPluginsIds(plugins, create);
for (int i = 0, idsLength = ids.length; i < idsLength; i++) {
ObjectId id = ids[i];
if (id == null) {
if (!create) {
id = repository.connectionDelegate.getNextStepTypeID();
} else {
id = new LongObjectId(i + 1);
}
PluginInterface sp = plugins.get(i);
RowMetaAndData table = new RowMetaAndData();
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_STEP_TYPE_ID_STEP_TYPE), id);
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_STEP_TYPE_CODE), sp.getIds()[0]);
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_STEP_TYPE_DESCRIPTION), sp.getName());
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_STEP_TYPE_HELPTEXT), sp.getDescription());
if (dryrun) {
String sql = database.getSQLOutput(null, KettleDatabaseRepository.TABLE_R_STEP_TYPE, table.getRowMeta(), table.getData(), null);
statements.add(sql);
} else {
database.prepareInsert(table.getRowMeta(), null, KettleDatabaseRepository.TABLE_R_STEP_TYPE);
database.setValuesInsert(table);
database.insertRow();
database.closeInsert();
}
}
}
}
return statements;
}
use of org.pentaho.di.repository.LongObjectId in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryTransDelegate method loadRepTrans.
/**
* Load the transformation name & other details from a repository.
*
* @param rep
* The repository to load the details from.
*/
private void loadRepTrans(TransMeta transMeta) throws KettleException {
try {
RowMetaAndData r = getTransformation(transMeta.getObjectId());
if (r != null) {
transMeta.setName(r.getString(KettleDatabaseRepository.FIELD_TRANSFORMATION_NAME, null));
// Trans description
transMeta.setDescription(r.getString(KettleDatabaseRepository.FIELD_TRANSFORMATION_DESCRIPTION, null));
transMeta.setExtendedDescription(r.getString(KettleDatabaseRepository.FIELD_TRANSFORMATION_EXTENDED_DESCRIPTION, null));
transMeta.setTransversion(r.getString(KettleDatabaseRepository.FIELD_TRANSFORMATION_TRANS_VERSION, null));
transMeta.setTransstatus((int) r.getInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_TRANS_STATUS, -1L));
TransLogTable logTable = transMeta.getTransLogTable();
logTable.findField(TransLogTable.ID.LINES_READ).setSubject(StepMeta.findStep(transMeta.getSteps(), new LongObjectId(r.getInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_STEP_READ, -1L))));
logTable.findField(TransLogTable.ID.LINES_READ).setSubject(StepMeta.findStep(transMeta.getSteps(), new LongObjectId(r.getInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_STEP_WRITE, -1L))));
logTable.findField(TransLogTable.ID.LINES_READ).setSubject(StepMeta.findStep(transMeta.getSteps(), new LongObjectId(r.getInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_STEP_INPUT, -1L))));
logTable.findField(TransLogTable.ID.LINES_READ).setSubject(StepMeta.findStep(transMeta.getSteps(), new LongObjectId(r.getInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_STEP_OUTPUT, -1L))));
logTable.findField(TransLogTable.ID.LINES_READ).setSubject(StepMeta.findStep(transMeta.getSteps(), new LongObjectId(r.getInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_STEP_UPDATE, -1L))));
long id_rejected = getTransAttributeInteger(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_ID_STEP_REJECTED);
if (id_rejected > 0) {
logTable.findField(TransLogTable.ID.LINES_REJECTED).setSubject(StepMeta.findStep(transMeta.getSteps(), new LongObjectId(id_rejected)));
}
DatabaseMeta logDb = DatabaseMeta.findDatabase(transMeta.getDatabases(), new LongObjectId(r.getInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_DATABASE_LOG, -1L)));
if (logDb != null) {
logTable.setConnectionName(logDb.getName());
// TODO: save/load name as a string, allow variables!
}
logTable.setTableName(r.getString(KettleDatabaseRepository.FIELD_TRANSFORMATION_TABLE_NAME_LOG, null));
logTable.setBatchIdUsed(r.getBoolean(KettleDatabaseRepository.FIELD_TRANSFORMATION_USE_BATCHID, false));
logTable.setLogFieldUsed(r.getBoolean(KettleDatabaseRepository.FIELD_TRANSFORMATION_USE_LOGFIELD, false));
transMeta.setMaxDateConnection(DatabaseMeta.findDatabase(transMeta.getDatabases(), new LongObjectId(r.getInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_DATABASE_MAXDATE, -1L))));
transMeta.setMaxDateTable(r.getString(KettleDatabaseRepository.FIELD_TRANSFORMATION_TABLE_NAME_MAXDATE, null));
transMeta.setMaxDateField(r.getString(KettleDatabaseRepository.FIELD_TRANSFORMATION_FIELD_NAME_MAXDATE, null));
transMeta.setMaxDateOffset(r.getNumber(KettleDatabaseRepository.FIELD_TRANSFORMATION_OFFSET_MAXDATE, 0.0));
transMeta.setMaxDateDifference(r.getNumber(KettleDatabaseRepository.FIELD_TRANSFORMATION_DIFF_MAXDATE, 0.0));
transMeta.setCreatedUser(r.getString(KettleDatabaseRepository.FIELD_TRANSFORMATION_CREATED_USER, null));
transMeta.setCreatedDate(r.getDate(KettleDatabaseRepository.FIELD_TRANSFORMATION_CREATED_DATE, null));
transMeta.setModifiedUser(r.getString(KettleDatabaseRepository.FIELD_TRANSFORMATION_MODIFIED_USER, null));
transMeta.setModifiedDate(r.getDate(KettleDatabaseRepository.FIELD_TRANSFORMATION_MODIFIED_DATE, null));
// Optional:
transMeta.setSizeRowset(Const.ROWS_IN_ROWSET);
Long val_size_rowset = r.getInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_SIZE_ROWSET);
if (val_size_rowset != null) {
transMeta.setSizeRowset(val_size_rowset.intValue());
}
long id_directory = r.getInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_DIRECTORY, -1L);
if (id_directory >= 0) {
if (log.isDetailed()) {
log.logDetailed("ID_DIRECTORY=" + id_directory);
}
// always reload the folder structure
//
transMeta.setRepositoryDirectory(repository.loadRepositoryDirectoryTree().findDirectory(new LongObjectId(id_directory)));
}
transMeta.setUsingUniqueConnections(getTransAttributeBoolean(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_UNIQUE_CONNECTIONS));
transMeta.setFeedbackShown(!"N".equalsIgnoreCase(getTransAttributeString(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_FEEDBACK_SHOWN)));
transMeta.setFeedbackSize((int) getTransAttributeInteger(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_FEEDBACK_SIZE));
transMeta.setUsingThreadPriorityManagment(!"N".equalsIgnoreCase(getTransAttributeString(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_USING_THREAD_PRIORITIES)));
// Performance monitoring for steps...
//
transMeta.setCapturingStepPerformanceSnapShots(getTransAttributeBoolean(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_CAPTURE_STEP_PERFORMANCE));
transMeta.setStepPerformanceCapturingDelay(getTransAttributeInteger(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_STEP_PERFORMANCE_CAPTURING_DELAY));
transMeta.setStepPerformanceCapturingSizeLimit(getTransAttributeString(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_STEP_PERFORMANCE_CAPTURING_SIZE_LIMIT));
transMeta.getPerformanceLogTable().setTableName(getTransAttributeString(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_STEP_PERFORMANCE_LOG_TABLE));
transMeta.getTransLogTable().setLogSizeLimit(getTransAttributeString(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_LOG_SIZE_LIMIT));
transMeta.getTransLogTable().setLogInterval(getTransAttributeString(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_LOG_INTERVAL));
transMeta.setTransformationType(TransformationType.getTransformationTypeByCode(getTransAttributeString(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_TRANSFORMATION_TYPE)));
transMeta.setSleepTimeEmpty((int) getTransAttributeInteger(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_SLEEP_TIME_EMPTY));
transMeta.setSleepTimeFull((int) getTransAttributeInteger(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_SLEEP_TIME_FULL));
loadRepParameters(transMeta);
}
} catch (KettleDatabaseException dbe) {
throw new KettleException(BaseMessages.getString(PKG, "TransMeta.Exception.UnableToLoadTransformationInfoFromRepository"), dbe);
} finally {
transMeta.initializeVariablesFrom(null);
transMeta.setInternalKettleVariables();
}
}
use of org.pentaho.di.repository.LongObjectId in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryTransDelegate method getTransformationsWithIDList.
public String[] getTransformationsWithIDList(List<Object[]> list, RowMetaInterface rowMeta) throws KettleException {
String[] transList = new String[list.size()];
for (int i = 0; i < list.size(); i++) {
long id_transformation = rowMeta.getInteger(list.get(i), quote(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_TRANSFORMATION), -1L);
if (id_transformation > 0) {
RowMetaAndData transRow = getTransformation(new LongObjectId(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;
}
use of org.pentaho.di.repository.LongObjectId in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryMetaStore method getElementTypeByName.
@Override
public IMetaStoreElementType getElementTypeByName(String namespace, String elementTypeName) throws MetaStoreException {
try {
LongObjectId namespaceId = delegate.getNamespaceId(namespace);
if (namespaceId == null) {
return null;
}
LongObjectId elementTypeId = delegate.getElementTypeId(namespaceId, elementTypeName);
if (elementTypeId == null) {
return null;
}
RowMetaAndData elementTypeRow = delegate.getElementType(elementTypeId);
return delegate.parseElementType(namespace, namespaceId, elementTypeRow);
} catch (Exception e) {
throw new MetaStoreException("Unable to get element type with name '" + elementTypeName + "' in namespace '" + namespace + "'", e);
}
}
use of org.pentaho.di.repository.LongObjectId in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryMetaStore method deleteElementType.
@Override
public void deleteElementType(String namespace, IMetaStoreElementType elementType) throws MetaStoreException, MetaStoreDependenciesExistsException {
try {
Collection<RowMetaAndData> elementTypeRows = delegate.getElements(new LongObjectId(new StringObjectId(elementType.getId())));
if (!elementTypeRows.isEmpty()) {
List<String> dependencies = new ArrayList<String>();
for (RowMetaAndData elementTypeRow : elementTypeRows) {
Long elementTypeId = elementTypeRow.getInteger(KettleDatabaseRepository.FIELD_ELEMENT_TYPE_ID_ELEMENT_TYPE);
dependencies.add(Long.toString(elementTypeId));
}
throw new MetaStoreDependenciesExistsException(dependencies, "The namespace to delete, '" + namespace + "' is not empty");
}
delegate.deleteElementType(new LongObjectId(new StringObjectId(elementType.getId())));
repository.commit();
} catch (MetaStoreDependenciesExistsException e) {
throw e;
} catch (Exception e) {
repository.rollback();
throw new MetaStoreException(e);
}
}
Aggregations