use of org.pentaho.di.core.row.value.ValueMetaString in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryConnectionDelegate method getIDWithValue.
public synchronized LongObjectId getIDWithValue(String tablename, String idfield, String lookupfield, String value) throws KettleException {
RowMetaAndData par = new RowMetaAndData();
par.addValue(new ValueMetaString("value"), value);
RowMetaAndData result = getOneRow("SELECT " + idfield + " FROM " + tablename + " WHERE " + lookupfield + " = ?", par.getRowMeta(), par.getData());
if (result != null && result.getRowMeta() != null && result.getData() != null && result.isNumeric(0)) {
return new LongObjectId(result.getInteger(0, 0));
}
return null;
}
use of org.pentaho.di.core.row.value.ValueMetaString in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryConnectionDelegate method insertJobEntryAttribute.
public synchronized ObjectId insertJobEntryAttribute(ObjectId id_job, ObjectId id_jobentry, long nr, String code, double value_num, String value_str) throws KettleException {
ObjectId id = getNextJobEntryAttributeID();
RowMetaAndData table = new RowMetaAndData();
// CHECKSTYLE:LineLength:OFF
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOBENTRY_ATTRIBUTE_ID_JOBENTRY_ATTRIBUTE), id);
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOBENTRY_ATTRIBUTE_ID_JOB), id_job);
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOBENTRY_ATTRIBUTE_ID_JOBENTRY), id_jobentry);
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOBENTRY_ATTRIBUTE_NR), new Long(nr));
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_JOBENTRY_ATTRIBUTE_CODE), code);
table.addValue(new ValueMetaNumber(KettleDatabaseRepository.FIELD_JOBENTRY_ATTRIBUTE_VALUE_NUM), new Double(value_num));
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_JOBENTRY_ATTRIBUTE_VALUE_STR), value_str);
database.prepareInsert(table.getRowMeta(), KettleDatabaseRepository.TABLE_R_JOBENTRY_ATTRIBUTE);
database.setValuesInsert(table);
database.insertRow();
database.closeInsert();
return id;
}
use of org.pentaho.di.core.row.value.ValueMetaString in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryConnectionDelegate method getJobEntryAttributeRow.
private RowMetaAndData getJobEntryAttributeRow(ObjectId id_jobentry, int nr, String code) throws KettleException {
RowMetaAndData par = new RowMetaAndData();
par.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOBENTRY_ATTRIBUTE_ID_JOBENTRY), id_jobentry);
par.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_JOBENTRY_ATTRIBUTE_CODE), code);
par.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOBENTRY_ATTRIBUTE_NR), new Long(nr));
if (pstmt_entry_attributes == null) {
setLookupJobEntryAttribute();
}
database.setValues(par.getRowMeta(), par.getData(), pstmt_entry_attributes);
return callRead(new Callable<RowMetaAndData>() {
@Override
public RowMetaAndData call() throws Exception {
Object[] lookup = database.getLookup(pstmt_entry_attributes);
return new RowMetaAndData(database.getReturnRowMeta(), lookup);
}
});
}
use of org.pentaho.di.core.row.value.ValueMetaString in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryDatabaseDelegate method insertDatabase.
public synchronized ObjectId insertDatabase(String name, String type, String access, String host, String dbname, String port, String user, String pass, String servername, String data_tablespace, String index_tablespace) throws KettleException {
ObjectId id = repository.connectionDelegate.getNextDatabaseID();
ObjectId id_database_type = getDatabaseTypeID(type);
if (id_database_type == null) {
// New support database type: add it!
id_database_type = repository.connectionDelegate.getNextDatabaseTypeID();
String tablename = KettleDatabaseRepository.TABLE_R_DATABASE_TYPE;
RowMetaInterface tableMeta = new RowMeta();
tableMeta.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_DATABASE_TYPE_ID_DATABASE_TYPE, 5, 0));
tableMeta.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_DATABASE_TYPE_CODE, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
tableMeta.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_DATABASE_TYPE_DESCRIPTION, KettleDatabaseRepository.REP_STRING_LENGTH, 0));
repository.connectionDelegate.getDatabase().prepareInsert(tableMeta, tablename);
Object[] tableData = new Object[3];
int tableIndex = 0;
tableData[tableIndex++] = new LongObjectId(id_database_type).longValue();
tableData[tableIndex++] = type;
tableData[tableIndex++] = type;
repository.connectionDelegate.getDatabase().setValuesInsert(tableMeta, tableData);
repository.connectionDelegate.getDatabase().insertRow();
repository.connectionDelegate.getDatabase().closeInsert();
}
ObjectId id_database_contype = getDatabaseConTypeID(access);
RowMetaAndData table = new RowMetaAndData();
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_DATABASE_ID_DATABASE), id);
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_DATABASE_NAME), name);
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_DATABASE_ID_DATABASE_TYPE), id_database_type);
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_DATABASE_ID_DATABASE_CONTYPE), id_database_contype);
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_DATABASE_HOST_NAME), host);
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_DATABASE_DATABASE_NAME), dbname);
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_DATABASE_PORT), Long.valueOf(Const.toLong(port, -1)));
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_DATABASE_USERNAME), user);
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_DATABASE_PASSWORD), Encr.encryptPasswordIfNotUsingVariables(pass));
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_DATABASE_SERVERNAME), servername);
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_DATABASE_DATA_TBS), data_tablespace);
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_DATABASE_INDEX_TBS), index_tablespace);
repository.connectionDelegate.getDatabase().prepareInsert(table.getRowMeta(), KettleDatabaseRepository.TABLE_R_DATABASE);
repository.connectionDelegate.getDatabase().setValuesInsert(table);
repository.connectionDelegate.getDatabase().insertRow();
repository.connectionDelegate.getDatabase().closeInsert();
return id;
}
use of org.pentaho.di.core.row.value.ValueMetaString in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryDatabaseDelegate method createAttributeRow.
private RowMetaAndData createAttributeRow(ObjectId idDatabase, String code, String strValue) throws KettleException {
ObjectId id = repository.connectionDelegate.getNextDatabaseAttributeID();
RowMetaAndData table = new RowMetaAndData();
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_DATABASE_ATTRIBUTE_ID_DATABASE_ATTRIBUTE), id);
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_DATABASE_ATTRIBUTE_ID_DATABASE), idDatabase);
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_DATABASE_ATTRIBUTE_CODE), code);
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_DATABASE_ATTRIBUTE_VALUE_STR), strValue);
return table;
}
Aggregations