use of org.pentaho.metaverse.impl.MetaverseNode 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.impl.MetaverseNode in project pentaho-metaverse by pentaho.
the class RepositoryLocatorTest method setUp.
@Before
public void setUp() throws Exception {
RepositoryLocator loc = new RepositoryLocator() {
@Override
protected IUnifiedRepository getUnifiedRepository(IPentahoSession session) throws Exception {
return null;
}
@Override
protected Object getContents(RepositoryFile locatedItem) throws Exception {
return null;
}
/**
* Returns the locator node for this locator. The locator node is the node in the metaverse
* that represents this locator. It is used to create a link from this locator to the documents
* that are found by/within it.
*
* @return The locator node in the metaverse
*/
@Override
public IMetaverseNode getLocatorNode() {
return new MetaverseNode(mock(Vertex.class));
}
@Override
public URI getRootUri() {
return null;
}
};
loc.setMetaverseBuilder(metaverseBuilder);
baseLocator = spy(loc);
when(baseLocator.getMetaverseBuilder()).thenReturn(metaverseBuilder);
when(metaverseBuilder.getMetaverseObjectFactory()).thenReturn(metaverseObjectFactory);
when(metaverseObjectFactory.createDocumentObject()).thenReturn(new MetaverseDocument());
}
use of org.pentaho.metaverse.impl.MetaverseNode in project pentaho-metaverse by pentaho.
the class BlueprintsGraphMetaverseReader method findNode.
@Override
public IMetaverseNode findNode(String id) {
Vertex vertex = getGraph().getVertex(id);
if (vertex == null) {
return null;
}
MetaverseUtil.enhanceVertex(vertex);
MetaverseNode node = new MetaverseNode(vertex);
return node;
}
use of org.pentaho.metaverse.impl.MetaverseNode in project pentaho-metaverse by pentaho.
the class BlueprintsGraphMetaverseReader method findNodes.
@Override
public List<IMetaverseNode> findNodes(String property, String value) {
Iterable<Vertex> vertices = getGraph().getVertices(property, value);
if (vertices == null) {
return null;
}
List<IMetaverseNode> result = new ArrayList<IMetaverseNode>();
Iterator<Vertex> verticesIt = vertices.iterator();
while (verticesIt.hasNext()) {
MetaverseNode node = new MetaverseNode(verticesIt.next());
result.add(node);
}
return result;
}
Aggregations