use of org.pentaho.di.repository.LongObjectId in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryTest method testInsertTransformationSlave.
@Test
public void testInsertTransformationSlave() throws KettleException {
ArgumentCaptor<String> argumentTableName = ArgumentCaptor.forClass(String.class);
ArgumentCaptor<RowMetaAndData> argumentTableData = ArgumentCaptor.forClass(RowMetaAndData.class);
doNothing().when(repo.connectionDelegate).insertTableRow(argumentTableName.capture(), argumentTableData.capture());
doReturn(new LongObjectId(789)).when(repo.connectionDelegate).getNextTransformationSlaveID();
ObjectId result = repo.insertTransformationSlave(new LongObjectId(456), new LongObjectId(123));
RowMetaAndData insertRecord = argumentTableData.getValue();
assertEquals(KettleDatabaseRepository.TABLE_R_TRANS_SLAVE, argumentTableName.getValue());
assertEquals(3, insertRecord.size());
assertEquals(ValueMetaInterface.TYPE_INTEGER, insertRecord.getValueMeta(0).getType());
assertEquals(KettleDatabaseRepository.FIELD_TRANS_SLAVE_ID_TRANS_SLAVE, insertRecord.getValueMeta(0).getName());
assertEquals(Long.valueOf(789), insertRecord.getInteger(0));
assertEquals(ValueMetaInterface.TYPE_INTEGER, insertRecord.getValueMeta(1).getType());
assertEquals(KettleDatabaseRepository.FIELD_TRANS_SLAVE_ID_TRANSFORMATION, insertRecord.getValueMeta(1).getName());
assertEquals(Long.valueOf(456), insertRecord.getInteger(1));
assertEquals(ValueMetaInterface.TYPE_INTEGER, insertRecord.getValueMeta(2).getType());
assertEquals(KettleDatabaseRepository.FIELD_TRANS_SLAVE_ID_SLAVE, insertRecord.getValueMeta(2).getName());
assertEquals(Long.valueOf(123), insertRecord.getInteger(2));
assertEquals(new LongObjectId(789), result);
}
use of org.pentaho.di.repository.LongObjectId in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryTest method testInsertTransformationPartitionSchema.
@Test
public void testInsertTransformationPartitionSchema() throws KettleException {
ArgumentCaptor<String> argumentTableName = ArgumentCaptor.forClass(String.class);
ArgumentCaptor<RowMetaAndData> argumentTableData = ArgumentCaptor.forClass(RowMetaAndData.class);
doNothing().when(repo.connectionDelegate).insertTableRow(argumentTableName.capture(), argumentTableData.capture());
doReturn(new LongObjectId(456)).when(repo.connectionDelegate).getNextTransformationPartitionSchemaID();
ObjectId result = repo.insertTransformationPartitionSchema(new LongObjectId(147), new LongObjectId(258));
RowMetaAndData insertRecord = argumentTableData.getValue();
assertEquals(KettleDatabaseRepository.TABLE_R_TRANS_PARTITION_SCHEMA, argumentTableName.getValue());
assertEquals(3, insertRecord.size());
assertEquals(ValueMetaInterface.TYPE_INTEGER, insertRecord.getValueMeta(0).getType());
assertEquals(KettleDatabaseRepository.FIELD_TRANS_PARTITION_SCHEMA_ID_TRANS_PARTITION_SCHEMA, insertRecord.getValueMeta(0).getName());
assertEquals(Long.valueOf(456), insertRecord.getInteger(0));
assertEquals(ValueMetaInterface.TYPE_INTEGER, insertRecord.getValueMeta(1).getType());
assertEquals(KettleDatabaseRepository.FIELD_TRANS_PARTITION_SCHEMA_ID_TRANSFORMATION, insertRecord.getValueMeta(1).getName());
assertEquals(Long.valueOf(147), insertRecord.getInteger(1));
assertEquals(ValueMetaInterface.TYPE_INTEGER, insertRecord.getValueMeta(2).getType());
assertEquals(KettleDatabaseRepository.FIELD_TRANS_PARTITION_SCHEMA_ID_PARTITION_SCHEMA, insertRecord.getValueMeta(2).getName());
assertEquals(Long.valueOf(258), insertRecord.getInteger(2));
assertEquals(new LongObjectId(456), result);
}
use of org.pentaho.di.repository.LongObjectId in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryConnectionDelegateUnitTest method testGetValueToIdMap.
@Test
public void testGetValueToIdMap() throws KettleException {
String tablename = "test-tablename";
String idfield = "test-idfield";
String lookupfield = "test-lookupfield";
List<Object[]> rows = new ArrayList<Object[]>();
int id = 1234;
LongObjectId longObjectId = new LongObjectId(id);
rows.add(new Object[] { lookupfield, id });
when(database.getRows(eq("SELECT " + lookupfield + ", " + idfield + " FROM " + tablename), any(RowMetaInterface.class), eq(new Object[] {}), eq(ResultSet.FETCH_FORWARD), eq(false), eq(-1), eq((ProgressMonitorListener) null))).thenReturn(rows);
Map<String, LongObjectId> valueToIdMap = kettleDatabaseRepositoryConnectionDelegate.getValueToIdMap(tablename, idfield, lookupfield);
assertEquals(1, valueToIdMap.size());
assertEquals(longObjectId, valueToIdMap.get(lookupfield));
}
use of org.pentaho.di.repository.LongObjectId in project pentaho-kettle by pentaho.
the class KettleDatabaseRepository method getUserHomeDirectory.
public RepositoryDirectory getUserHomeDirectory() throws KettleException {
RepositoryDirectory root = new RepositoryDirectory();
root.setObjectId(new LongObjectId(0L));
directoryDelegate.loadRepositoryDirectory(root, root.getObjectId());
return root;
}
use of org.pentaho.di.repository.LongObjectId in project pentaho-kettle by pentaho.
the class KettleDatabaseRepository method saveDatabaseMetaStepAttribute.
/**
* This method saves the object ID of the database object (if not null) in the step attributes
*
* @param id_transformation
* @param id_step
* @param string
* @param database
*/
public void saveDatabaseMetaStepAttribute(ObjectId id_transformation, ObjectId id_step, String code, DatabaseMeta database) throws KettleException {
ObjectId id = null;
if (database != null) {
id = database.getObjectId();
Long id_database = id == null ? Long.valueOf(-1L) : new LongObjectId(id).longValue();
saveStepAttribute(id_transformation, id_step, code, id_database);
}
}
Aggregations