use of org.pentaho.di.core.row.value.ValueMetaInteger in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryConnectionDelegate method getTransAttributesWithPrefix.
public synchronized List<Object[]> getTransAttributesWithPrefix(ObjectId id_transformation, String codePrefix) throws KettleException {
String sql = "SELECT *" + " FROM " + databaseMeta.getQuotedSchemaTableCombination(null, KettleDatabaseRepository.TABLE_R_TRANS_ATTRIBUTE) + " WHERE " + quote(KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_ID_TRANSFORMATION) + " = ?" + " AND " + quote(KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_CODE) + " LIKE '" + codePrefix + "%'";
RowMetaAndData table = new RowMetaAndData();
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_ID_TRANSFORMATION), new LongObjectId(id_transformation));
return callRead(() -> database.getRows(sql, table.getRowMeta(), table.getData(), ResultSet.FETCH_FORWARD, false, 0, null));
}
use of org.pentaho.di.core.row.value.ValueMetaInteger in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryConnectionDelegate method getIDs.
public ObjectId[] getIDs(String sql, ObjectId... objectId) throws KettleException {
// Get the prepared statement
//
PreparedStatement ps = getPreparedStatement(sql);
// Assemble the parameters (if any)
//
RowMetaInterface parameterMeta = new RowMeta();
Object[] parameterData = new Object[objectId.length];
for (int i = 0; i < objectId.length; i++) {
parameterMeta.addValueMeta(new ValueMetaInteger("id" + (i + 1)));
parameterData[i] = ((LongObjectId) objectId[i]).longValue();
}
return callRead(new Callable<ObjectId[]>() {
@Override
public ObjectId[] call() throws Exception {
ResultSet resultSet = database.openQuery(ps, parameterMeta, parameterData);
List<Object[]> rows = database.getRows(resultSet, 0, null);
if (Utils.isEmpty(rows)) {
return new ObjectId[0];
}
RowMetaInterface rowMeta = database.getReturnRowMeta();
ObjectId[] ids = new ObjectId[rows.size()];
for (int i = 0; i < ids.length; i++) {
Object[] row = rows.get(i);
ids[i] = new LongObjectId(rowMeta.getInteger(row, 0));
}
return ids;
}
});
}
use of org.pentaho.di.core.row.value.ValueMetaInteger in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryConnectionDelegate method getTransAttributes.
public synchronized List<Object[]> getTransAttributes(ObjectId id_transformation, String code, long nr) throws KettleException {
String sql = "SELECT *" + " FROM " + databaseMeta.getQuotedSchemaTableCombination(null, KettleDatabaseRepository.TABLE_R_TRANS_ATTRIBUTE) + " WHERE " + quote(KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_ID_TRANSFORMATION) + " = ? AND " + quote(KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_CODE) + " = ? AND " + quote(KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_NR) + " = ?" + " ORDER BY " + quote(KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_VALUE_NUM);
RowMetaAndData table = new RowMetaAndData();
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_ID_TRANSFORMATION), new LongObjectId(id_transformation));
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_CODE), code);
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_NR), new Long(nr));
return callRead(() -> database.getRows(sql, table.getRowMeta(), table.getData(), ResultSet.FETCH_FORWARD, false, 0, null));
}
use of org.pentaho.di.core.row.value.ValueMetaInteger in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryCreationHelper method updateJobEntryTypes.
/**
* Update the list in R_JOBENTRY_TYPE
*
* @param create
*
* @exception KettleException
* if something went wrong during the update.
*/
public void updateJobEntryTypes(List<String> statements, boolean dryrun, boolean create) throws KettleException {
synchronized (repository) {
// We should only do an update if something has changed...
PluginRegistry registry = PluginRegistry.getInstance();
List<PluginInterface> jobPlugins = registry.getPlugins(JobEntryPluginType.class);
for (int i = 0; i < jobPlugins.size(); i++) {
PluginInterface jobPlugin = jobPlugins.get(i);
String type_desc = jobPlugin.getIds()[0];
String type_desc_long = jobPlugin.getName();
ObjectId id = null;
if (!create) {
id = repository.jobEntryDelegate.getJobEntryTypeID(type_desc);
}
if (id == null) {
// Not found, we need to add this one...
// We need to add this one ...
id = new LongObjectId(i + 1);
if (!create) {
id = repository.connectionDelegate.getNextJobEntryTypeID();
}
RowMetaAndData table = new RowMetaAndData();
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOBENTRY_TYPE_ID_JOBENTRY_TYPE), id);
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_JOBENTRY_TYPE_CODE), type_desc);
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_JOBENTRY_TYPE_DESCRIPTION), type_desc_long);
if (dryrun) {
String sql = database.getSQLOutput(null, KettleDatabaseRepository.TABLE_R_JOBENTRY_TYPE, table.getRowMeta(), table.getData(), null);
statements.add(sql);
} else {
database.prepareInsert(table.getRowMeta(), null, KettleDatabaseRepository.TABLE_R_JOBENTRY_TYPE);
database.setValuesInsert(table);
database.insertRow();
database.closeInsert();
}
}
}
}
}
use of org.pentaho.di.core.row.value.ValueMetaInteger in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryCreationHelper method updateDatabaseTypes.
/**
* Update the list in R_DATABASE_TYPE using the database plugin entries
*
* @throws KettleException
* if the update didn't go as planned.
*/
public List<String> updateDatabaseTypes(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(DatabasePluginType.class);
for (int i = 0; i < plugins.size(); i++) {
PluginInterface plugin = plugins.get(i);
ObjectId id = null;
if (!create) {
id = repository.databaseDelegate.getDatabaseTypeID(plugin.getIds()[0]);
}
if (id == null) {
// Not found, we need to add this one...
// We need to add this one ...
id = new LongObjectId(i + 1);
if (!create) {
id = repository.connectionDelegate.getNextDatabaseTypeID();
}
RowMetaAndData table = new RowMetaAndData();
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_DATABASE_TYPE_ID_DATABASE_TYPE), id);
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_DATABASE_TYPE_CODE), plugin.getIds()[0]);
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_DATABASE_TYPE_DESCRIPTION), plugin.getName());
if (dryrun) {
String sql = database.getSQLOutput(null, KettleDatabaseRepository.TABLE_R_DATABASE_TYPE, table.getRowMeta(), table.getData(), null);
statements.add(sql);
} else {
database.prepareInsert(table.getRowMeta(), null, KettleDatabaseRepository.TABLE_R_DATABASE_TYPE);
database.setValuesInsert(table);
database.insertRow();
database.closeInsert();
}
}
}
}
return statements;
}
Aggregations