Search in sources :

Example 56 with TinkerGraph

use of com.tinkerpop.blueprints.impls.tg.TinkerGraph in project frames by tinkerpop.

the class FramedGraphTest method generateGraph.

public Graph generateGraph() {
    final TinkerGraph baseGraph = new TinkerGraph();
    baseGraph.getFeatures().isPersistent = false;
    return new FramedGraph<TinkerGraph>(baseGraph);
}
Also used : TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph)

Example 57 with TinkerGraph

use of com.tinkerpop.blueprints.impls.tg.TinkerGraph in project frames by tinkerpop.

the class FramedGraphTest method testCreateFrame.

public void testCreateFrame() {
    Graph graph = new TinkerGraph();
    FramedGraph<Graph> framedGraph = new FramedGraphFactory().create(graph);
    Person person = framedGraph.addVertex(null, Person.class);
    assertEquals(person.asVertex(), graph.getVertices().iterator().next());
    int counter = 0;
    for (Vertex v : graph.getVertices()) {
        counter++;
    }
    assertEquals(counter, 1);
    counter = 0;
    for (Edge e : graph.getEdges()) {
        counter++;
    }
    assertEquals(counter, 0);
    Person person2 = framedGraph.addVertex("aPerson", Person.class);
    assertEquals(person2.asVertex().getId(), "aPerson");
    counter = 0;
    for (Vertex v : graph.getVertices()) {
        counter++;
    }
    assertEquals(counter, 2);
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) Graph(com.tinkerpop.blueprints.Graph) TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) Person(com.tinkerpop.frames.domain.classes.Person) Edge(com.tinkerpop.blueprints.Edge)

Example 58 with TinkerGraph

use of com.tinkerpop.blueprints.impls.tg.TinkerGraph in project hale by halestudio.

the class GraphMLDialog method open.

/**
 * Opens the dialog for displaying the graph
 *
 * @throws IOException may be thrown if the graph string from the database
 *             can fails to convert
 */
public void open() throws IOException {
    Shell parent = super.getParent();
    final Shell shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.MIN | SWT.MODELESS);
    shell.setFocus();
    shell.addFocusListener(new FocusListener() {

        @Override
        public void focusLost(FocusEvent e) {
            shell.setMinimized(true);
        }

        @Override
        public void focusGained(FocusEvent e) {
        // ignore
        }
    });
    shell.setLayout(GridLayoutFactory.fillDefaults().create());
    shell.setText(getText());
    final Composite viewerContainer = new Composite(shell, SWT.EMBEDDED);
    viewerContainer.setLayout(new FillLayout());
    viewerContainer.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    TinkerGraph tgraph = new TinkerGraph();
    GraphMLReader greader = new GraphMLReader(tgraph);
    ByteArrayInputStream in;
    in = new ByteArrayInputStream(graphString.getBytes(("UTF-8")));
    greader.inputGraph(in);
    GraphViewer viewer = new GraphViewer(viewerContainer, SWT.NONE);
    TreeLayoutAlgorithm la = new TreeLayoutAlgorithm(TreeLayoutAlgorithm.RIGHT_LEFT);
    viewer.setLabelProvider(new GraphMLLabelProvider());
    viewer.setContentProvider(new GraphMLContentProvider());
    viewer.setInput(tgraph.getEdges());
    viewer.setLayoutAlgorithm(la, true);
    viewer.applyLayout();
    viewerContainer.pack();
    viewerContainer.setVisible(true);
    shell.open();
    Display display = parent.getDisplay();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
}
Also used : Composite(org.eclipse.swt.widgets.Composite) TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) TreeLayoutAlgorithm(org.eclipse.zest.layouts.algorithms.TreeLayoutAlgorithm) FillLayout(org.eclipse.swt.layout.FillLayout) FocusEvent(org.eclipse.swt.events.FocusEvent) Shell(org.eclipse.swt.widgets.Shell) GraphViewer(org.eclipse.zest.core.viewers.GraphViewer) ByteArrayInputStream(java.io.ByteArrayInputStream) GraphMLReader(com.tinkerpop.blueprints.util.io.graphml.GraphMLReader) FocusListener(org.eclipse.swt.events.FocusListener) Display(org.eclipse.swt.widgets.Display)

Example 59 with TinkerGraph

use of com.tinkerpop.blueprints.impls.tg.TinkerGraph in project hale by halestudio.

the class TreeGraphMLProvider method generateGraph.

/**
 * @see eu.esdihumboldt.hale.ui.cst.debug.metadata.internal.TreeGraphProvider#generateGraph()
 */
@Override
public Graph generateGraph() {
    tree.accept(graphVisitor);
    SetMultimap<String, String> connections = graphVisitor.getAllConnections();
    Set<String> ids = graphVisitor.getAllIds();
    TinkerGraph graph = new TinkerGraph();
    // add nodes to the graph
    for (String key : ids) {
        TransformationNode node = graphVisitor.getNode(key);
        Vertex vertex = graph.addVertex(key);
        setVertexProperty(node, vertex);
    }
    for (String key : connections.keySet()) {
        for (String value : connections.get(key)) {
            graph.addEdge(null, graph.getVertex(key), graph.getVertex(value), " ");
        }
    }
    return graph;
}
Also used : TransformationNode(eu.esdihumboldt.hale.common.align.model.transformation.tree.TransformationNode) Vertex(com.tinkerpop.blueprints.Vertex) TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph)

Example 60 with TinkerGraph

use of com.tinkerpop.blueprints.impls.tg.TinkerGraph in project pentaho-metaverse by pentaho.

the class LineageClientIT method setUp.

@Before
public void setUp() throws Exception {
    transMeta = new TransMeta(MERGE_JOIN_KTR_FILENAME);
    IDocument doc = MetaverseUtil.createDocument(new Namespace("SPOON"), transMeta, transMeta.getFilename(), transMeta.getName(), "ktr", URLConnection.getFileNameMap().getContentTypeFor(transMeta.getFilename()));
    Graph graph = new TinkerGraph();
    MetaverseUtil.addLineageGraph(doc, graph);
}
Also used : TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) Graph(com.tinkerpop.blueprints.Graph) TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) TransMeta(org.pentaho.di.trans.TransMeta) IDocument(org.pentaho.metaverse.api.IDocument) Namespace(org.pentaho.metaverse.api.Namespace) Before(org.junit.Before)

Aggregations

TinkerGraph (com.tinkerpop.blueprints.impls.tg.TinkerGraph)105 Vertex (com.tinkerpop.blueprints.Vertex)66 Graph (com.tinkerpop.blueprints.Graph)58 Test (org.junit.Test)42 Edge (com.tinkerpop.blueprints.Edge)33 ByteArrayOutputStream (java.io.ByteArrayOutputStream)12 ByteArrayInputStream (java.io.ByteArrayInputStream)11 JSONObject (org.codehaus.jettison.json.JSONObject)10 IMetaverseBuilder (org.pentaho.metaverse.api.IMetaverseBuilder)10 InputStream (java.io.InputStream)9 HashSet (java.util.HashSet)9 JSONTokener (org.codehaus.jettison.json.JSONTokener)8 KeyIndexableGraph (com.tinkerpop.blueprints.KeyIndexableGraph)7 Map (java.util.Map)6 MetaverseBuilder (org.pentaho.metaverse.impl.MetaverseBuilder)6 TypedGraphModuleBuilder (com.tinkerpop.frames.modules.typedgraph.TypedGraphModuleBuilder)5 HashMap (java.util.HashMap)5 Before (org.junit.Before)5 IndexableGraph (com.tinkerpop.blueprints.IndexableGraph)4 IgnoreIdTinkerGraph (com.tinkerpop.blueprints.impls.tg.IgnoreIdTinkerGraph)4