use of org.pentaho.di.repository.LongObjectId in project pentaho-kettle by pentaho.
the class RepositoryDirectoryUITest method testLoadRepositoryObjectsNulled.
@Test
public void testLoadRepositoryObjectsNulled() throws Exception {
RepositoryDirectory root = new RepositoryDirectory();
root.setObjectId(new LongObjectId(0L));
RepositoryDirectory dir = new RepositoryDirectory();
dir.setObjectId(new LongObjectId(1L));
root.addSubdirectory(dir);
RepositoryElementMetaInterface meta = mock(RepositoryElementMetaInterface.class);
when(meta.getObjectType()).thenReturn(RepositoryObjectType.TRANSFORMATION);
Repository repo = mock(Repository.class);
when(repo.getJobAndTransformationObjects(dir.getObjectId(), false)).thenReturn(Collections.singletonList(meta));
when(repo.getJobAndTransformationObjects(root.getObjectId(), false)).thenReturn(Collections.emptyList());
assertTrue(RepositoryDirectoryUI.loadRepositoryObjects(root, true, true, repo).isEmpty());
assertEquals(1, RepositoryDirectoryUI.loadRepositoryObjects(dir, true, true, repo).size());
}
use of org.pentaho.di.repository.LongObjectId in project pentaho-kettle by pentaho.
the class UIRepositoryDirectoryTest method testGetRepositoryObjectsNulled.
@Test
public void testGetRepositoryObjectsNulled() throws Exception {
RepositoryDirectory root = new RepositoryDirectory();
root.setObjectId(new LongObjectId(0L));
RepositoryDirectory dir = new RepositoryDirectory();
dir.setObjectId(new LongObjectId(1L));
root.addSubdirectory(dir);
RepositoryElementMetaInterface meta = mock(RepositoryElementMetaInterface.class);
when(meta.getObjectType()).thenReturn(RepositoryObjectType.TRANSFORMATION);
Repository repo = mock(Repository.class);
when(repo.getJobAndTransformationObjects(dir.getObjectId(), false)).thenReturn(Collections.singletonList(meta));
when(repo.getJobAndTransformationObjects(root.getObjectId(), false)).thenReturn(Collections.emptyList());
UIRepositoryDirectory uiDir = new UIRepositoryDirectory(root, null, repo);
UIRepositoryObjects objects = uiDir.getRepositoryObjects();
assertNotNull(objects);
uiDir = new UIRepositoryDirectory(dir, uiDir, repo);
objects = uiDir.getRepositoryObjects();
assertEquals(1, objects.size());
}
use of org.pentaho.di.repository.LongObjectId in project pentaho-kettle by pentaho.
the class UIRepositoryDirectoryTest method testGetRepositoryObjectsFilled.
@Test
public void testGetRepositoryObjectsFilled() throws Exception {
RepositoryDirectory root = new RepositoryDirectory();
root.setObjectId(new LongObjectId(0L));
RepositoryDirectory dir = new RepositoryDirectory();
dir.setObjectId(new LongObjectId(1L));
root.addSubdirectory(dir);
RepositoryElementMetaInterface meta = mock(RepositoryElementMetaInterface.class);
when(meta.getObjectType()).thenReturn(RepositoryObjectType.TRANSFORMATION);
root.setRepositoryObjects(Collections.emptyList());
dir.setRepositoryObjects(Collections.singletonList(meta));
Repository repo = mock(Repository.class);
UIRepositoryDirectory uiDir = new UIRepositoryDirectory(root, null, repo);
UIRepositoryObjects objects = uiDir.getRepositoryObjects();
assertNotNull(objects);
uiDir = new UIRepositoryDirectory(dir, uiDir, repo);
objects = uiDir.getRepositoryObjects();
assertEquals(1, objects.size());
verifyZeroInteractions(repo);
}
use of org.pentaho.di.repository.LongObjectId in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryStepDelegate method loadStepMeta.
/**
* Create a new step by loading the metadata from the specified repository.
*
* @param rep
* @param stepId
* @param databases
* @param counters
* @param partitionSchemas
* @throws KettleException
*/
public StepMeta loadStepMeta(ObjectId stepId, List<DatabaseMeta> databases, List<PartitionSchema> partitionSchemas) throws KettleException {
StepMeta stepMeta = new StepMeta();
PluginRegistry registry = PluginRegistry.getInstance();
try {
RowMetaAndData r = getStep(stepId);
if (r != null) {
stepMeta.setObjectId(stepId);
stepMeta.setName(r.getString(KettleDatabaseRepository.FIELD_STEP_NAME, null));
stepMeta.setDescription(r.getString(KettleDatabaseRepository.FIELD_STEP_DESCRIPTION, null));
long id_step_type = r.getInteger(KettleDatabaseRepository.FIELD_STEP_ID_STEP_TYPE, -1L);
RowMetaAndData steptyperow = getStepType(new LongObjectId(id_step_type));
stepMeta.setStepID(steptyperow.getString(KettleDatabaseRepository.FIELD_STEP_TYPE_CODE, null));
stepMeta.setDistributes(r.getBoolean(KettleDatabaseRepository.FIELD_STEP_DISTRIBUTE, true));
int copies = (int) r.getInteger(KettleDatabaseRepository.FIELD_STEP_COPIES, 1);
String copiesString = r.getString(KettleDatabaseRepository.FIELD_STEP_COPIES_STRING, null);
if (!Utils.isEmpty(copiesString)) {
stepMeta.setCopiesString(copiesString);
} else {
stepMeta.setCopies(copies);
}
int x = (int) r.getInteger(KettleDatabaseRepository.FIELD_STEP_GUI_LOCATION_X, 0);
int y = (int) r.getInteger(KettleDatabaseRepository.FIELD_STEP_GUI_LOCATION_Y, 0);
stepMeta.setLocation(new Point(x, y));
stepMeta.setDraw(r.getBoolean(KettleDatabaseRepository.FIELD_STEP_GUI_DRAW, false));
// Generate the appropriate class...
PluginInterface sp = registry.findPluginWithId(StepPluginType.class, stepMeta.getStepID());
if (sp == null) {
stepMeta.setStepMetaInterface(new MissingTrans(stepMeta.getName(), stepMeta.getStepID()));
} else {
stepMeta.setStepMetaInterface((StepMetaInterface) registry.loadClass(sp));
}
if (stepMeta.getStepMetaInterface() != null) {
// Read the step info from the repository!
readRepCompatibleStepMeta(stepMeta.getStepMetaInterface(), repository, stepMeta.getObjectId(), databases);
stepMeta.getStepMetaInterface().readRep(repository, repository.metaStore, stepMeta.getObjectId(), databases);
}
// Get the partitioning as well...
//
stepMeta.setStepPartitioningMeta(loadStepPartitioningMeta(stepMeta.getObjectId()));
stepMeta.getStepPartitioningMeta().setPartitionSchemaAfterLoading(partitionSchemas);
// Get the cluster schema name
//
stepMeta.setClusterSchemaName(repository.getStepAttributeString(stepId, "cluster_schema"));
// Are we using a custom row distribution plugin?
//
String rowDistributionCode = repository.getStepAttributeString(stepId, 0, "row_distribution_code");
RowDistributionInterface rowDistribution = PluginRegistry.getInstance().loadClass(RowDistributionPluginType.class, rowDistributionCode, RowDistributionInterface.class);
stepMeta.setRowDistribution(rowDistribution);
// Load the attribute groups map
//
stepMeta.setAttributesMap(loadStepAttributesMap(stepId));
//
return stepMeta;
} else {
throw new KettleException(BaseMessages.getString(PKG, "StepMeta.Exception.StepInfoCouldNotBeFound", String.valueOf(stepId)));
}
} catch (KettleDatabaseException dbe) {
throw new KettleException(BaseMessages.getString(PKG, "StepMeta.Exception.StepCouldNotBeLoaded", String.valueOf(stepMeta.getObjectId())), dbe);
}
}
use of org.pentaho.di.repository.LongObjectId in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryTransDelegate method insertTransformation.
// CHECKSTYLE:LineLength:OFF
private synchronized void insertTransformation(TransMeta transMeta) throws KettleException {
RowMetaAndData table = new RowMetaAndData();
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_TRANSFORMATION), new LongObjectId(transMeta.getObjectId()));
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_TRANSFORMATION_NAME), transMeta.getName());
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_TRANSFORMATION_DESCRIPTION), transMeta.getDescription());
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_TRANSFORMATION_EXTENDED_DESCRIPTION), transMeta.getExtendedDescription());
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_TRANSFORMATION_TRANS_VERSION), transMeta.getTransversion());
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_TRANS_STATUS), new Long(transMeta.getTransstatus() < 0 ? -1L : transMeta.getTransstatus()));
TransLogTable logTable = transMeta.getTransLogTable();
StepMeta step = (StepMeta) logTable.getSubject(TransLogTable.ID.LINES_READ);
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_STEP_READ), step == null ? null : step.getObjectId());
step = (StepMeta) logTable.getSubject(TransLogTable.ID.LINES_WRITTEN);
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_STEP_WRITE), step == null ? null : step.getObjectId());
step = (StepMeta) logTable.getSubject(TransLogTable.ID.LINES_INPUT);
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_STEP_INPUT), step == null ? null : step.getObjectId());
step = (StepMeta) logTable.getSubject(TransLogTable.ID.LINES_OUTPUT);
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_STEP_OUTPUT), step == null ? null : step.getObjectId());
step = (StepMeta) logTable.getSubject(TransLogTable.ID.LINES_UPDATED);
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_STEP_UPDATE), step == null ? null : step.getObjectId());
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_DATABASE_LOG), logTable.getDatabaseMeta() == null ? new LongObjectId(-1L).longValue() : new LongObjectId(logTable.getDatabaseMeta().getObjectId()).longValue());
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_TRANSFORMATION_TABLE_NAME_LOG), logTable.getDatabaseMeta());
table.addValue(new ValueMetaBoolean(KettleDatabaseRepository.FIELD_TRANSFORMATION_USE_BATCHID), Boolean.valueOf(logTable.isBatchIdUsed()));
table.addValue(new ValueMetaBoolean(KettleDatabaseRepository.FIELD_TRANSFORMATION_USE_LOGFIELD), Boolean.valueOf(logTable.isLogFieldUsed()));
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_DATABASE_MAXDATE), transMeta.getMaxDateConnection() == null ? new LongObjectId(-1L).longValue() : new LongObjectId(transMeta.getMaxDateConnection().getObjectId()).longValue());
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_TRANSFORMATION_TABLE_NAME_MAXDATE), transMeta.getMaxDateTable());
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_TRANSFORMATION_FIELD_NAME_MAXDATE), transMeta.getMaxDateField());
table.addValue(new ValueMetaNumber(KettleDatabaseRepository.FIELD_TRANSFORMATION_OFFSET_MAXDATE), new Double(transMeta.getMaxDateOffset()));
table.addValue(new ValueMetaNumber(KettleDatabaseRepository.FIELD_TRANSFORMATION_DIFF_MAXDATE), new Double(transMeta.getMaxDateDifference()));
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_TRANSFORMATION_CREATED_USER), transMeta.getCreatedUser());
table.addValue(new ValueMetaDate(KettleDatabaseRepository.FIELD_TRANSFORMATION_CREATED_DATE), transMeta.getCreatedDate());
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_TRANSFORMATION_MODIFIED_USER), transMeta.getModifiedUser());
table.addValue(new ValueMetaDate(KettleDatabaseRepository.FIELD_TRANSFORMATION_MODIFIED_DATE), transMeta.getModifiedDate());
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_SIZE_ROWSET), new Long(transMeta.getSizeRowset()));
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_DIRECTORY), transMeta.getRepositoryDirectory().getObjectId());
repository.connectionDelegate.getDatabase().prepareInsert(table.getRowMeta(), KettleDatabaseRepository.TABLE_R_TRANSFORMATION);
repository.connectionDelegate.getDatabase().setValuesInsert(table);
repository.connectionDelegate.getDatabase().insertRow();
repository.connectionDelegate.getDatabase().closeInsert();
step = (StepMeta) logTable.getSubject(TransLogTable.ID.LINES_REJECTED);
if (step != null) {
ObjectId rejectedId = step.getObjectId();
repository.connectionDelegate.insertTransAttribute(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_ID_STEP_REJECTED, rejectedId == null ? null : Long.valueOf(rejectedId.toString()), null);
}
repository.connectionDelegate.insertTransAttribute(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_UNIQUE_CONNECTIONS, 0, transMeta.isUsingUniqueConnections() ? "Y" : "N");
repository.connectionDelegate.insertTransAttribute(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_FEEDBACK_SHOWN, 0, transMeta.isFeedbackShown() ? "Y" : "N");
repository.connectionDelegate.insertTransAttribute(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_FEEDBACK_SIZE, transMeta.getFeedbackSize(), "");
repository.connectionDelegate.insertTransAttribute(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_USING_THREAD_PRIORITIES, 0, transMeta.isUsingThreadPriorityManagment() ? "Y" : "N");
repository.connectionDelegate.insertTransAttribute(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_SHARED_FILE, 0, transMeta.getSharedObjectsFile());
repository.connectionDelegate.insertTransAttribute(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_CAPTURE_STEP_PERFORMANCE, 0, transMeta.isCapturingStepPerformanceSnapShots() ? "Y" : "N");
repository.connectionDelegate.insertTransAttribute(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_STEP_PERFORMANCE_CAPTURING_DELAY, transMeta.getStepPerformanceCapturingDelay(), "");
repository.connectionDelegate.insertTransAttribute(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_STEP_PERFORMANCE_CAPTURING_SIZE_LIMIT, 0, transMeta.getStepPerformanceCapturingSizeLimit());
repository.connectionDelegate.insertTransAttribute(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_STEP_PERFORMANCE_LOG_TABLE, 0, transMeta.getPerformanceLogTable().getTableName());
repository.connectionDelegate.insertTransAttribute(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_LOG_SIZE_LIMIT, 0, transMeta.getTransLogTable().getLogSizeLimit());
repository.connectionDelegate.insertTransAttribute(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_LOG_INTERVAL, 0, transMeta.getTransLogTable().getLogInterval());
repository.connectionDelegate.insertTransAttribute(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_TRANSFORMATION_TYPE, 0, transMeta.getTransformationType().getCode());
repository.connectionDelegate.insertTransAttribute(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_SLEEP_TIME_EMPTY, transMeta.getSleepTimeEmpty(), null);
repository.connectionDelegate.insertTransAttribute(transMeta.getObjectId(), 0, KettleDatabaseRepository.TRANS_ATTRIBUTE_SLEEP_TIME_FULL, transMeta.getSleepTimeFull(), null);
// Save the logging connection link...
if (logTable.getDatabaseMeta() != null) {
repository.insertStepDatabase(transMeta.getObjectId(), null, logTable.getDatabaseMeta().getObjectId());
}
// Save the maxdate connection link...
if (transMeta.getMaxDateConnection() != null) {
repository.insertStepDatabase(transMeta.getObjectId(), null, transMeta.getMaxDateConnection().getObjectId());
}
// Save the logging tables too..
//
RepositoryAttributeInterface attributeInterface = new KettleDatabaseRepositoryTransAttribute(repository.connectionDelegate, transMeta.getObjectId());
transMeta.getTransLogTable().saveToRepository(attributeInterface);
transMeta.getStepLogTable().saveToRepository(attributeInterface);
transMeta.getPerformanceLogTable().saveToRepository(attributeInterface);
transMeta.getChannelLogTable().saveToRepository(attributeInterface);
}
Aggregations