use of org.pentaho.metaverse.api.IMetaverseNode in project pentaho-metaverse by pentaho.
the class JobExecutorStepAnalyzer method customAnalyze.
@Override
protected void customAnalyze(JobExecutorMeta meta, IMetaverseNode node) throws MetaverseAnalyzerException {
String jobPath = meta.getFileName();
JobMeta subJobMeta = null;
Repository repo = parentTransMeta.getRepository();
switch(meta.getSpecificationMethod()) {
case FILENAME:
jobPath = parentTransMeta.environmentSubstitute(meta.getFileName());
try {
String normalized = KettleAnalyzerUtil.normalizeFilePath(jobPath);
subJobMeta = getSubJobMeta(parentTransMeta, normalized);
jobPath = normalized;
} catch (Exception e) {
throw new MetaverseAnalyzerException("Sub transformation can not be found - " + jobPath, e);
}
break;
case REPOSITORY_BY_NAME:
if (repo != null) {
String dir = parentTransMeta.environmentSubstitute(meta.getDirectoryPath());
String file = parentTransMeta.environmentSubstitute(meta.getJobName());
try {
RepositoryDirectoryInterface rdi = repo.findDirectory(dir);
subJobMeta = repo.loadJob(file, rdi, null, null);
String filename = subJobMeta.getFilename() == null ? subJobMeta.toString() : subJobMeta.getFilename();
jobPath = filename + "." + subJobMeta.getDefaultExtension();
} catch (KettleException e) {
throw new MetaverseAnalyzerException("Sub transformation can not be found in repository - " + file, e);
}
} else {
throw new MetaverseAnalyzerException("Not connected to a repository, can't get the transformation");
}
break;
case REPOSITORY_BY_REFERENCE:
if (repo != null) {
try {
subJobMeta = repo.loadJob(meta.getJobObjectId(), null);
String filename = subJobMeta.getFilename() == null ? subJobMeta.toString() : subJobMeta.getFilename();
jobPath = filename + "." + subJobMeta.getDefaultExtension();
} catch (KettleException e) {
throw new MetaverseAnalyzerException("Sub transformation can not be found by reference - " + meta.getJobObjectId(), e);
}
} else {
throw new MetaverseAnalyzerException("Not connected to a repository, can't get the transformation");
}
break;
}
// analyze the sub trans?
IComponentDescriptor ds = new MetaverseComponentDescriptor(subJobMeta.getName(), DictionaryConst.NODE_TYPE_JOB, descriptor.getNamespace().getParentNamespace());
IMetaverseNode jobNode = createNodeFromDescriptor(ds);
jobNode.setProperty(DictionaryConst.PROPERTY_NAMESPACE, ds.getNamespaceId());
jobNode.setProperty(DictionaryConst.PROPERTY_PATH, jobPath);
jobNode.setLogicalIdGenerator(DictionaryConst.LOGICAL_ID_GENERATOR_DOCUMENT);
metaverseBuilder.addLink(node, DictionaryConst.LINK_EXECUTES, jobNode);
connectToSubJobOutputFields(meta, subJobMeta, jobNode, descriptor);
node.setProperty(JOB_TO_EXECUTE, jobPath);
if (StringUtils.isNotEmpty(meta.getExecutionResultTargetStep())) {
node.setProperty(EXECUTION_RESULTS_TARGET, meta.getExecutionResultTargetStep());
}
if (StringUtils.isNotEmpty(meta.getResultFilesTargetStep())) {
node.setProperty(RESULT_FILES_TARGET, meta.getResultFilesTargetStep());
}
}
use of org.pentaho.metaverse.api.IMetaverseNode in project pentaho-metaverse by pentaho.
the class JobExecutorStepAnalyzer method connectToSubJobOutputFields.
protected void connectToSubJobOutputFields(JobExecutorMeta meta, JobMeta subJobMeta, IMetaverseNode subTransNode, IComponentDescriptor descriptor) {
if (meta.getResultRowsTargetStep() != null) {
String outputStep = meta.getResultRowsTargetStep();
for (int i = 0; i < meta.getResultRowsField().length; i++) {
String fieldName = meta.getResultRowsField()[i];
IMetaverseNode outNode = getOutputs().findNode(outputStep, fieldName);
// TODO
/* if ( outNode != null ) {
// add link, if needed, from sub tran result fields to the node just created
linkResultFieldToSubTrans( outNode, subJobMeta, subTransNode, descriptor );
}*/
}
}
}
use of org.pentaho.metaverse.api.IMetaverseNode in project pentaho-metaverse by pentaho.
the class MergeJoinStepAnalyzer method customAnalyze.
@Override
protected void customAnalyze(MergeJoinMeta mergeJoinMeta, IMetaverseNode node) throws MetaverseAnalyzerException {
// create links for the merging of the input streams on field(s)
String[] keyFields1 = mergeJoinMeta.getKeyFields1();
String[] keyFields2 = mergeJoinMeta.getKeyFields2();
String joinType = mergeJoinMeta.getJoinType();
String[] prevStepNames = parentTransMeta.getPrevStepNames(getStepName());
node.setProperty(DictionaryConst.PROPERTY_JOIN_TYPE, joinType);
node.setProperty(DictionaryConst.PROPERTY_JOIN_FIELDS_LEFT, Arrays.asList(keyFields1));
node.setProperty(DictionaryConst.PROPERTY_JOIN_FIELDS_RIGHT, Arrays.asList(keyFields2));
boolean isInner = MergeJoinMeta.join_types[0].equals(joinType);
boolean isLeftOuter = MergeJoinMeta.join_types[1].equals(joinType);
boolean isRightOuter = MergeJoinMeta.join_types[2].equals(joinType);
boolean isFullOuter = MergeJoinMeta.join_types[3].equals(joinType);
for (int i = 0; i < keyFields1.length; i++) {
IMetaverseNode leftNode = getInputs().findNode(prevStepNames[0], keyFields1[i]);
IMetaverseNode rightNode = getInputs().findNode(prevStepNames[1], keyFields2[i]);
// handle links for join types between fields
if ((isInner || isLeftOuter || isFullOuter) && leftNode != null && rightNode != null) {
metaverseBuilder.addLink(leftNode, DictionaryConst.LINK_JOINS, rightNode);
}
if ((isInner || isRightOuter || isFullOuter) && leftNode != null && rightNode != null) {
metaverseBuilder.addLink(rightNode, DictionaryConst.LINK_JOINS, leftNode);
}
}
}
use of org.pentaho.metaverse.api.IMetaverseNode in project pentaho-metaverse by pentaho.
the class MongoDbInputStepAnalyzer method createTableNode.
@Override
protected IMetaverseNode createTableNode(IExternalResourceInfo resource) throws MetaverseAnalyzerException {
MongoDbResourceInfo resourceInfo = (MongoDbResourceInfo) resource;
// create a node for the collection
MetaverseComponentDescriptor componentDescriptor = new MetaverseComponentDescriptor(resourceInfo.getCollection(), DictionaryConst.NODE_TYPE_MONGODB_COLLECTION, getConnectionNode(), getDescriptor().getContext());
// set the namespace to be the id of the connection node.
IMetaverseNode node = createNodeFromDescriptor(componentDescriptor);
node.setProperty(DictionaryConst.PROPERTY_NAMESPACE, componentDescriptor.getNamespace().getNamespaceId());
node.setProperty(COLLECTION, resourceInfo.getCollection());
node.setLogicalIdGenerator(DictionaryConst.LOGICAL_ID_GENERATOR_DEFAULT);
return node;
}
use of org.pentaho.metaverse.api.IMetaverseNode in project pentaho-metaverse by pentaho.
the class RowsFromResultStepAnalyzer method processInputs.
@Override
protected StepNodes processInputs(RowsFromResultMeta meta) {
StepNodes inputs = new StepNodes();
// get all input steps
String[] fieldNames = meta.getFieldname();
for (int j = 0; j < fieldNames.length; j++) {
String fieldName = fieldNames[j];
RowMetaInterface rmi = null;
try {
rmi = parentTransMeta.getStepFields(parentStepMeta);
int type = rmi.getValueMeta(j).getType();
ValueMetaInterface vmi = rmi.getValueMeta(j);
// IMetaverseNode prevFieldNode = createInputFieldNode( StepAnalyzer.NONE, fieldName, type );
IMetaverseNode prevFieldNode = createInputFieldNode(descriptor.getContext(), vmi, StepAnalyzer.NONE, getInputNodeType());
getMetaverseBuilder().addLink(prevFieldNode, DictionaryConst.LINK_INPUTS, rootNode);
inputs.addNode(StepAnalyzer.NONE, fieldName, prevFieldNode);
} catch (KettleStepException e) {
// eat it
}
}
return inputs;
}
Aggregations