use of org.pentaho.metaverse.api.IMetaverseNode in project pentaho-metaverse by pentaho.
the class TransExecutorStepAnalyzer method customAnalyze.
@Override
protected void customAnalyze(TransExecutorMeta meta, IMetaverseNode node) throws MetaverseAnalyzerException {
String transPath = meta.getFileName();
TransMeta subTransMeta = null;
Repository repo = parentTransMeta.getRepository();
switch(meta.getSpecificationMethod()) {
case FILENAME:
transPath = parentTransMeta.environmentSubstitute(meta.getFileName());
try {
String normalized = KettleAnalyzerUtil.normalizeFilePath(transPath);
subTransMeta = getSubTransMeta(normalized);
transPath = normalized;
} catch (Exception e) {
throw new MetaverseAnalyzerException("Sub transformation can not be found - " + transPath, e);
}
break;
case REPOSITORY_BY_NAME:
if (repo != null) {
String dir = parentTransMeta.environmentSubstitute(meta.getDirectoryPath());
String file = parentTransMeta.environmentSubstitute(meta.getTransName());
try {
RepositoryDirectoryInterface rdi = repo.findDirectory(dir);
subTransMeta = repo.loadTransformation(file, rdi, null, true, null);
transPath = subTransMeta.getPathAndName() + "." + subTransMeta.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 {
subTransMeta = repo.loadTransformation(meta.getTransObjectId(), null);
transPath = subTransMeta.getPathAndName() + "." + subTransMeta.getDefaultExtension();
} catch (KettleException e) {
throw new MetaverseAnalyzerException("Sub transformation can not be found by reference - " + meta.getTransObjectId(), e);
}
} else {
throw new MetaverseAnalyzerException("Not connected to a repository, can't get the transformation");
}
break;
}
// analyze the sub trans?
IComponentDescriptor ds = new MetaverseComponentDescriptor(subTransMeta.getName(), DictionaryConst.NODE_TYPE_TRANS, descriptor.getNamespace().getParentNamespace());
IMetaverseNode transformationNode = createNodeFromDescriptor(ds);
transformationNode.setProperty(DictionaryConst.PROPERTY_NAMESPACE, ds.getNamespaceId());
transformationNode.setProperty(DictionaryConst.PROPERTY_PATH, transPath);
transformationNode.setLogicalIdGenerator(DictionaryConst.LOGICAL_ID_GENERATOR_DOCUMENT);
metaverseBuilder.addLink(node, DictionaryConst.LINK_EXECUTES, transformationNode);
connectToSubTransInputFields(meta, subTransMeta, transformationNode, descriptor);
connectToSubTransOutputFields(meta, subTransMeta, transformationNode, descriptor);
node.setProperty(TRANSFORMATION_TO_EXECUTE, transPath);
if (StringUtils.isNotEmpty(meta.getExecutionResultTargetStep())) {
node.setProperty(EXECUTION_RESULTS_TARGET, meta.getExecutionResultTargetStep());
}
if (StringUtils.isNotEmpty(meta.getOutputRowsSourceStep())) {
node.setProperty(OUTPUT_ROWS_TARGET, meta.getOutputRowsSourceStep());
}
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 BlueprintsGraphMetaverseReader method findLink.
@Override
public IMetaverseLink findLink(String leftNodeID, String linkType, String rightNodeID, Direction direction) {
Vertex vertex = getGraph().getVertex(leftNodeID);
if (vertex == null) {
return null;
}
Iterable<Edge> edges = linkType == null ? vertex.getEdges(direction) : vertex.getEdges(direction, linkType);
IMetaverseLink link = new MetaverseLink();
IMetaverseNode node1 = new MetaverseNode(vertex);
Direction opDirection = direction == Direction.IN ? Direction.OUT : Direction.IN;
Vertex vertex2 = null;
if (rightNodeID != null) {
Iterator<Edge> it = edges.iterator();
while (it.hasNext()) {
Edge edge = it.next();
if (rightNodeID.equals((String) edge.getVertex(opDirection).getId())) {
vertex2 = edge.getVertex(opDirection);
IMetaverseNode node2 = new MetaverseNode(vertex2);
String label = edge.getLabel();
link.setLabel(label);
String localized = Messages.getString(MetaverseUtil.MESSAGE_PREFIX_LINKTYPE + label);
if (!localized.startsWith("!")) {
link.setProperty(DictionaryConst.PROPERTY_TYPE_LOCALIZED, localized);
}
if (direction == Direction.OUT) {
link.setFromNode(node1);
link.setToNode(node2);
} else {
link.setFromNode(node2);
link.setToNode(node1);
}
return link;
}
}
}
return null;
}
use of org.pentaho.metaverse.api.IMetaverseNode in project pentaho-metaverse by pentaho.
the class BaseLocator method startScan.
/**
* Starts a full scan by this locator.
*
* @param locatorRunner The locator runner to use
* @throws MetaverseLocatorException
*/
protected void startScan(LocatorRunner<T> locatorRunner) throws MetaverseLocatorException {
if (futureTask != null && !futureTask.isDone()) {
throw new MetaverseLocatorException(Messages.getString("ERROR.BaseLocator.ScanAlreadyExecuting"));
}
IMetaverseNode node = getLocatorNode();
Date lastRun = new Date();
node.setProperty("lastScan", Long.toString(lastRun.getTime()));
metaverseBuilder.addNode(node);
runner = locatorRunner;
runner.setLocator(this);
LOG.debug(Messages.getString("DEBUG.Locator.StartScan", getLocatorType()));
futureTask = completionService.submit(runner, node.getStringID());
}
use of org.pentaho.metaverse.api.IMetaverseNode in project pentaho-metaverse by pentaho.
the class BaseLocator method getNamespace.
protected INamespace getNamespace() {
IMetaverseNode locatorNode = metaverseBuilder.getMetaverseObjectFactory().createNodeObject(UUID.randomUUID().toString(), getRepositoryId(), DictionaryConst.NODE_TYPE_LOCATOR);
locatorNode.setLogicalIdGenerator(DictionaryConst.LOGICAL_ID_GENERATOR_LOCATOR);
return new Namespace(locatorNode.getLogicalId());
}
use of org.pentaho.metaverse.api.IMetaverseNode in project pentaho-metaverse by pentaho.
the class MetaverseReaderIT method testSearch.
@Test
public void testSearch() throws Exception {
List<String> whatWeAreLookingFor = new ArrayList<String>(Arrays.asList(DictionaryConst.NODE_TYPE_TRANS));
List<IMetaverseNode> nodes = reader.findNodes(DictionaryConst.PROPERTY_TYPE, DictionaryConst.NODE_TYPE_DATA_COLUMN);
List<String> startingPoint = new ArrayList<String>(Arrays.asList(nodes.get(0).getStringID()));
System.out.println("Looking for Transformations that write/read Database Column " + nodes.get(0).getName());
Graph g = reader.search(whatWeAreLookingFor, startingPoint, false);
// make sure the Transformation node is in the resulting graph
assertNotNull(g.getVertices(DictionaryConst.PROPERTY_TYPE, DictionaryConst.NODE_TYPE_TRANS));
// make sure the starting point node is in the resulting graph
assertNotNull(g.getVertex(nodes.get(0).getStringID()));
GraphMLWriter writer = new GraphMLWriter();
writer.outputGraph(g, new FileOutputStream(IntegrationTestUtil.getOutputPath("searchOut.graphml")));
}
Aggregations