use of org.pentaho.di.trans.step.StepMetaInterface in project pentaho-kettle by pentaho.
the class TransMetaConverter method resolveStepMetaResources.
private static void resolveStepMetaResources(TransMeta transMeta) {
for (StepMeta stepMeta : transMeta.getSteps()) {
StepMetaInterface smi = stepMeta.getStepMetaInterface();
if (smi instanceof ResolvableResource) {
ResolvableResource resolvableMeta = (ResolvableResource) smi;
resolvableMeta.resolve();
}
}
}
use of org.pentaho.di.trans.step.StepMetaInterface in project pentaho-kettle by pentaho.
the class TransWebSocketEngineAdapter method getSubSteps.
@SuppressWarnings("unchecked")
private List<StepMetaDataCombi> getSubSteps(Transformation transformation, StepMetaDataCombi combi) {
HashMap<String, Transformation> config = ((Optional<HashMap<String, Transformation>>) transformation.getConfig(TransMetaConverter.SUB_TRANSFORMATIONS_KEY)).orElse(Maps.newHashMap());
StepMetaInterface smi = combi.stepMeta.getStepMetaInterface();
return config.keySet().stream().filter(key -> stepHasDependency(combi, smi, key)).flatMap(key -> opsToSteps(config.get(key)).stream()).collect(Collectors.toList());
}
use of org.pentaho.di.trans.step.StepMetaInterface in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryTransDelegate method loadTransformation.
/**
* Read a transformation with a certain name from a repository
*
* @param rep
* The repository to read from.
* @param transname
* The name of the transformation.
* @param repdir
* the path to the repository directory
* @param monitor
* The progress monitor to display the progress of the file-open operation in a dialog
* @param setInternalVariables
* true if you want to set the internal variables based on this transformation information
*/
public TransMeta loadTransformation(TransMeta transMeta, String transname, RepositoryDirectoryInterface repdir, ProgressMonitorListener monitor, boolean setInternalVariables) throws KettleException {
transMeta.setRepository(repository);
transMeta.setMetaStore(repository.metaStore);
synchronized (repository) {
try {
String pathAndName = repdir.isRoot() ? repdir + transname : repdir + RepositoryDirectory.DIRECTORY_SEPARATOR + transname;
transMeta.setName(transname);
transMeta.setRepositoryDirectory(repdir);
// Get the transformation id
if (log.isDetailed()) {
log.logDetailed(BaseMessages.getString(PKG, "TransMeta.Log.LookingForTransformation", transname, repdir.getPath()));
}
if (monitor != null) {
monitor.subTask(BaseMessages.getString(PKG, "TransMeta.Monitor.ReadingTransformationInfoTask.Title"));
}
transMeta.setObjectId(getTransformationID(transname, repdir.getObjectId()));
if (monitor != null) {
monitor.worked(1);
}
// If no valid id is available in the database, then give error...
if (transMeta.getObjectId() != null) {
ObjectId[] noteids = repository.getTransNoteIDs(transMeta.getObjectId());
ObjectId[] stepids = repository.getStepIDs(transMeta.getObjectId());
ObjectId[] hopids = getTransHopIDs(transMeta.getObjectId());
int nrWork = 3 + noteids.length + stepids.length + hopids.length;
if (monitor != null) {
monitor.beginTask(BaseMessages.getString(PKG, "TransMeta.Monitor.LoadingTransformationTask.Title") + pathAndName, nrWork);
}
if (log.isDetailed()) {
log.logDetailed(BaseMessages.getString(PKG, "TransMeta.Log.LoadingTransformation", transMeta.getName()));
}
// Load the common database connections
if (monitor != null) {
monitor.subTask(BaseMessages.getString(PKG, "TransMeta.Monitor.ReadingTheAvailableSharedObjectsTask.Title"));
}
try {
transMeta.setSharedObjects(readTransSharedObjects(transMeta));
} catch (Exception e) {
log.logError(BaseMessages.getString(PKG, "TransMeta.ErrorReadingSharedObjects.Message", e.toString()));
log.logError(Const.getStackTracker(e));
}
if (monitor != null) {
monitor.worked(1);
}
// Load the notes...
if (monitor != null) {
monitor.subTask(BaseMessages.getString(PKG, "TransMeta.Monitor.ReadingNoteTask.Title"));
}
for (int i = 0; i < noteids.length; i++) {
NotePadMeta ni = repository.notePadDelegate.loadNotePadMeta(noteids[i]);
if (transMeta.indexOfNote(ni) < 0) {
transMeta.addNote(ni);
}
if (monitor != null) {
monitor.worked(1);
}
}
if (monitor != null) {
monitor.subTask(BaseMessages.getString(PKG, "TransMeta.Monitor.ReadingStepsTask.Title"));
}
// read all the attributes
repository.connectionDelegate.fillStepAttributesBuffer(transMeta.getObjectId());
// on one go!
for (int i = 0; i < stepids.length; i++) {
if (log.isDetailed()) {
log.logDetailed(BaseMessages.getString(PKG, "TransMeta.Log.LoadingStepWithID") + stepids[i]);
}
if (monitor != null) {
monitor.subTask(BaseMessages.getString(PKG, "TransMeta.Monitor.ReadingStepTask.Title") + (i + 1) + "/" + (stepids.length));
}
StepMeta stepMeta = repository.stepDelegate.loadStepMeta(stepids[i], transMeta.getDatabases(), transMeta.getPartitionSchemas());
if (stepMeta.isMissing()) {
transMeta.addMissingTrans((MissingTrans) stepMeta.getStepMetaInterface());
}
// In this case, we just add or replace the shared steps.
// The repository is considered "more central"
transMeta.addOrReplaceStep(stepMeta);
if (monitor != null) {
monitor.worked(1);
}
}
if (monitor != null) {
monitor.worked(1);
}
// clear the buffer (should be empty anyway)
repository.connectionDelegate.setStepAttributesBuffer(null);
// Have all StreamValueLookups, etc. reference the correct source steps...
for (int i = 0; i < transMeta.nrSteps(); i++) {
StepMetaInterface sii = transMeta.getStep(i).getStepMetaInterface();
sii.searchInfoAndTargetSteps(transMeta.getSteps());
}
if (monitor != null) {
monitor.subTask(BaseMessages.getString(PKG, "TransMeta.Monitor.LoadingTransformationDetailsTask.Title"));
}
loadRepTrans(transMeta);
if (monitor != null) {
monitor.worked(1);
}
if (monitor != null) {
monitor.subTask(BaseMessages.getString(PKG, "TransMeta.Monitor.ReadingHopTask.Title"));
}
for (int i = 0; i < hopids.length; i++) {
TransHopMeta hi = loadTransHopMeta(hopids[i], transMeta.getSteps());
if (hi != null) {
transMeta.addTransHop(hi);
}
if (monitor != null) {
monitor.worked(1);
}
}
//
for (int i = 0; i < transMeta.nrSteps(); i++) {
StepPartitioningMeta stepPartitioningMeta = transMeta.getStep(i).getStepPartitioningMeta();
if (stepPartitioningMeta != null) {
stepPartitioningMeta.setPartitionSchemaAfterLoading(transMeta.getPartitionSchemas());
}
}
//
for (int i = 0; i < transMeta.nrSteps(); i++) {
transMeta.getStep(i).setClusterSchemaAfterLoading(transMeta.getClusterSchemas());
}
if (monitor != null) {
monitor.subTask(BaseMessages.getString(PKG, "TransMeta.Monitor.ReadingTheDependenciesTask.Title"));
}
ObjectId[] depids = repository.getTransDependencyIDs(transMeta.getObjectId());
for (int i = 0; i < depids.length; i++) {
TransDependency td = loadTransDependency(depids[i], transMeta.getDatabases());
transMeta.addDependency(td);
}
if (monitor != null) {
monitor.worked(1);
}
// Load the group attributes map
//
transMeta.setAttributesMap(loadTransAttributesMap(transMeta.getObjectId()));
//
for (int i = 0; i < transMeta.nrSteps(); i++) {
StepMeta stepMeta = transMeta.getStep(i);
String sourceStep = repository.getStepAttributeString(stepMeta.getObjectId(), "step_error_handling_source_step");
if (sourceStep != null) {
StepErrorMeta stepErrorMeta = repository.stepDelegate.loadStepErrorMeta(transMeta, stepMeta, transMeta.getSteps());
// a bit of a trick, I know.
stepErrorMeta.getSourceStep().setStepErrorMeta(stepErrorMeta);
}
}
// Load all the log tables for the transformation...
//
RepositoryAttributeInterface attributeInterface = new KettleDatabaseRepositoryTransAttribute(repository.connectionDelegate, transMeta.getObjectId());
for (LogTableInterface logTable : transMeta.getLogTables()) {
logTable.loadFromRepository(attributeInterface);
}
if (monitor != null) {
monitor.subTask(BaseMessages.getString(PKG, "TransMeta.Monitor.SortingStepsTask.Title"));
}
transMeta.sortSteps();
if (monitor != null) {
monitor.worked(1);
}
if (monitor != null) {
monitor.done();
}
} else {
throw new KettleException(BaseMessages.getString(PKG, "TransMeta.Exception.TransformationDoesNotExist") + transMeta.getName());
}
if (log.isDetailed()) {
log.logDetailed(BaseMessages.getString(PKG, "TransMeta.Log.LoadedTransformation2", transname, String.valueOf(transMeta.getRepositoryDirectory() == null)));
log.logDetailed(BaseMessages.getString(PKG, "TransMeta.Log.LoadedTransformation", transname, transMeta.getRepositoryDirectory().getPath()));
}
// close prepared statements, minimize locking etc.
//
repository.connectionDelegate.closeAttributeLookupPreparedStatements();
return transMeta;
} catch (KettleDatabaseException e) {
log.logError(BaseMessages.getString(PKG, "TransMeta.Log.DatabaseErrorOccuredReadingTransformation") + Const.CR + e);
throw new KettleException(BaseMessages.getString(PKG, "TransMeta.Exception.DatabaseErrorOccuredReadingTransformation"), e);
} catch (Exception e) {
log.logError(BaseMessages.getString(PKG, "TransMeta.Log.DatabaseErrorOccuredReadingTransformation") + Const.CR + e);
throw new KettleException(BaseMessages.getString(PKG, "TransMeta.Exception.DatabaseErrorOccuredReadingTransformation2"), e);
} finally {
transMeta.initializeVariablesFrom(null);
if (setInternalVariables) {
transMeta.setInternalKettleVariables();
}
}
}
}
use of org.pentaho.di.trans.step.StepMetaInterface in project pentaho-kettle by pentaho.
the class TransMeta method addStep.
/**
* Add a new step to the transformation at the specified index. This method sets the step's parent transformation to
* the this transformation, and marks that the transformations' steps have changed.
*
* @param p
* The index into the step list
* @param stepMeta
* The step to be added.
*/
public void addStep(int p, StepMeta stepMeta) {
steps.add(p, stepMeta);
stepMeta.setParentTransMeta(this);
changed_steps = true;
StepMetaInterface iface = stepMeta.getStepMetaInterface();
if (iface instanceof StepMetaChangeListenerInterface) {
addStepChangeListener(p, (StepMetaChangeListenerInterface) stepMeta.getStepMetaInterface());
}
clearCaches();
}
use of org.pentaho.di.trans.step.StepMetaInterface in project pentaho-kettle by pentaho.
the class RepositoryImporterTest method testImportTrans_patchTransEntries_without_variables.
@Test
public void testImportTrans_patchTransEntries_without_variables() throws KettleException {
JobEntryInterface jobEntryInterface = createJobEntry("");
StepMetaInterface stepMeta = createStepMeta("/userName");
RepositoryImporter importer = createRepositoryImporter(jobEntryInterface, stepMeta, true);
importer.setBaseDirectory(baseDirectory);
importer.importTransformation(entityNode, feedback);
verify((HasRepositoryDirectories) stepMeta).setDirectories(new String[] { ROOT_PATH + USER_NAME_PATH });
}
Aggregations