use of org.pentaho.di.repository.LongObjectId in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryDatabaseDelegate method loadDatabaseMeta.
/**
* Load the Database Info
*/
public DatabaseMeta loadDatabaseMeta(ObjectId id_database) throws KettleException {
DatabaseMeta databaseMeta = new DatabaseMeta();
try {
RowMetaAndData r = getDatabase(id_database);
if (r != null) {
ObjectId id_database_type = // con_type
new LongObjectId(r.getInteger(KettleDatabaseRepository.FIELD_DATABASE_ID_DATABASE_TYPE, 0));
String dbTypeDesc = getDatabaseTypeCode(id_database_type);
if (dbTypeDesc != null) {
databaseMeta.setDatabaseInterface(DatabaseMeta.getDatabaseInterface(dbTypeDesc));
// new attributes
databaseMeta.setAttributes(new Properties());
}
databaseMeta.setObjectId(id_database);
databaseMeta.setName(r.getString(KettleDatabaseRepository.FIELD_DATABASE_NAME, ""));
ObjectId id_database_contype = new LongObjectId(// con_access
r.getInteger(KettleDatabaseRepository.FIELD_DATABASE_ID_DATABASE_CONTYPE, 0));
databaseMeta.setAccessType(DatabaseMeta.getAccessType(getDatabaseConTypeCode(id_database_contype)));
databaseMeta.setHostname(r.getString(KettleDatabaseRepository.FIELD_DATABASE_HOST_NAME, ""));
databaseMeta.setDBName(r.getString(KettleDatabaseRepository.FIELD_DATABASE_DATABASE_NAME, ""));
databaseMeta.setDBPort(r.getString(KettleDatabaseRepository.FIELD_DATABASE_PORT, ""));
databaseMeta.setUsername(r.getString(KettleDatabaseRepository.FIELD_DATABASE_USERNAME, ""));
databaseMeta.setPassword(Encr.decryptPasswordOptionallyEncrypted(r.getString(KettleDatabaseRepository.FIELD_DATABASE_PASSWORD, "")));
databaseMeta.setServername(r.getString(KettleDatabaseRepository.FIELD_DATABASE_SERVERNAME, ""));
databaseMeta.setDataTablespace(r.getString(KettleDatabaseRepository.FIELD_DATABASE_DATA_TBS, ""));
databaseMeta.setIndexTablespace(r.getString(KettleDatabaseRepository.FIELD_DATABASE_INDEX_TBS, ""));
// Also, load all the properties we can find...
final Collection<RowMetaAndData> attrs = repository.connectionDelegate.getDatabaseAttributes(id_database);
for (RowMetaAndData row : attrs) {
String code = row.getString(KettleDatabaseRepository.FIELD_DATABASE_ATTRIBUTE_CODE, "");
String attribute = row.getString(KettleDatabaseRepository.FIELD_DATABASE_ATTRIBUTE_VALUE_STR, "");
databaseMeta.getAttributes().put(code, Const.NVL(attribute, ""));
}
}
return databaseMeta;
} catch (KettleDatabaseException dbe) {
throw new KettleException("Error loading database connection from repository (id_database=" + id_database + ")", dbe);
}
}
use of org.pentaho.di.repository.LongObjectId in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryJobEntryDelegate method loadJobEntryBase.
public void loadJobEntryBase(JobEntryBase jobEntryBase, ObjectId id_jobentry, List<DatabaseMeta> databases, List<SlaveServer> slaveServers) throws KettleException {
try {
RowMetaAndData r = getJobEntry(id_jobentry);
if (r != null) {
jobEntryBase.setName(r.getString("NAME", null));
jobEntryBase.setDescription(r.getString("DESCRIPTION", null));
long id_jobentry_type = r.getInteger("ID_JOBENTRY_TYPE", 0);
RowMetaAndData jetrow = getJobEntryType(new LongObjectId(id_jobentry_type));
if (jetrow != null) {
jobEntryBase.setPluginId(jetrow.getString("CODE", null));
}
}
} catch (KettleDatabaseException dbe) {
throw new KettleException("Unable to load base job entry information from the repository for id_jobentry=" + id_jobentry, dbe);
}
}
use of org.pentaho.di.repository.LongObjectId in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryMetaStoreDelegate method insertElementType.
public ObjectId insertElementType(KDBRMetaStoreElementType type) throws KettleException {
ObjectId idType = repository.connectionDelegate.getNextID(quoteTable(KettleDatabaseRepository.TABLE_R_ELEMENT_TYPE), quote(KettleDatabaseRepository.FIELD_ELEMENT_TYPE_ID_ELEMENT_TYPE));
RowMetaAndData table = new RowMetaAndData();
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_ELEMENT_TYPE_ID_ELEMENT_TYPE), idType);
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_ELEMENT_TYPE_ID_NAMESPACE), type.getNamespaceId());
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_ELEMENT_TYPE_NAME), type.getName());
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_ELEMENT_TYPE_DESCRIPTION), type.getDescription());
repository.connectionDelegate.getDatabase().prepareInsert(table.getRowMeta(), KettleDatabaseRepository.TABLE_R_ELEMENT_TYPE);
repository.connectionDelegate.getDatabase().setValuesInsert(table);
repository.connectionDelegate.getDatabase().insertRow();
repository.connectionDelegate.getDatabase().closeInsert();
type.setId(new LongObjectId(idType));
if (log.isDebug()) {
log.logDebug("Saved element type [" + type.getName() + "]");
}
return idType;
}
use of org.pentaho.di.repository.LongObjectId in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryMetaStoreDelegate method insertElement.
public ObjectId insertElement(IMetaStoreElementType elementType, IMetaStoreElement element) throws MetaStoreException {
try {
LongObjectId elementId = repository.connectionDelegate.getNextID(quoteTable(KettleDatabaseRepository.TABLE_R_ELEMENT), quote(KettleDatabaseRepository.FIELD_ELEMENT_ID_ELEMENT));
RowMetaAndData table = new RowMetaAndData();
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_ELEMENT_ID_ELEMENT), elementId.longValue());
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_ELEMENT_ID_ELEMENT_TYPE), Long.valueOf(elementType.getId()));
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_ELEMENT_NAME), element.getName());
repository.connectionDelegate.getDatabase().prepareInsert(table.getRowMeta(), KettleDatabaseRepository.TABLE_R_ELEMENT);
repository.connectionDelegate.getDatabase().setValuesInsert(table);
repository.connectionDelegate.getDatabase().insertRow();
repository.connectionDelegate.getDatabase().closeInsert();
element.setId(elementId.toString());
// Now save the attributes
//
insertAttributes(element.getChildren(), elementId, new LongObjectId(0L));
if (log.isDebug()) {
log.logDebug("Saved element with name [" + element.getName() + "]");
}
return elementId;
} catch (Exception e) {
throw new MetaStoreException("Unable to create new element with name '" + element.getName() + "'", e);
}
}
use of org.pentaho.di.repository.LongObjectId in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryMetaStoreDelegate method insertAttributes.
private void insertAttributes(List<IMetaStoreAttribute> children, LongObjectId elementId, LongObjectId parentAttributeId) throws Exception {
for (IMetaStoreAttribute child : children) {
LongObjectId attributeId = repository.connectionDelegate.getNextID(quoteTable(KettleDatabaseRepository.TABLE_R_ELEMENT_ATTRIBUTE), quote(KettleDatabaseRepository.FIELD_ELEMENT_ATTRIBUTE_ID_ELEMENT_ATTRIBUTE));
RowMetaAndData table = new RowMetaAndData();
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_ELEMENT_ATTRIBUTE_ID_ELEMENT_ATTRIBUTE), attributeId.longValue());
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_ELEMENT_ATTRIBUTE_ID_ELEMENT), elementId.longValue());
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_ELEMENT_ATTRIBUTE_ID_ELEMENT_ATTRIBUTE_PARENT), parentAttributeId.longValue());
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_ELEMENT_ATTRIBUTE_KEY), child.getId());
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_ELEMENT_ATTRIBUTE_VALUE), encodeAttributeValue(child.getValue()));
repository.connectionDelegate.getDatabase().prepareInsert(table.getRowMeta(), KettleDatabaseRepository.TABLE_R_ELEMENT_ATTRIBUTE);
repository.connectionDelegate.getDatabase().setValuesInsert(table);
repository.connectionDelegate.getDatabase().insertRow();
repository.connectionDelegate.getDatabase().closeInsert();
child.setId(attributeId.toString());
}
}
Aggregations