Search in sources :

Example 16 with GraphNode

use of au.gov.asd.tac.constellation.graph.node.GraphNode in project constellation by constellation-app.

the class FindNGTest method findListValuesTest.

@Test
public void findListValuesTest() throws InterruptedException, PluginException {
    ArrayList<FindRule> rules = new ArrayList<>();
    ReadableGraph rg = graph.getReadableGraph();
    try {
        // setup find criteria / rules
        HashMap<String, Object> values = new HashMap<>();
        values.put("string_content", "name1,nAMe2,name3");
        values.put("string_case_sensitive", false);
        values.put("string_use_list", true);
        FindRule rule1 = new FindRule(FindTypeOperators.Type.STRING, new GraphAttribute(rg, vNameAttr), FindTypeOperators.Operator.IS, values);
        rules.add(rule1);
        // perform find search
        // need to create temporary GraphNode and skip the RemoteInit portion of the initialisation
        GraphNode aGraphNode = new GraphNode(graph, null, new TopComponent(), null);
        final AdvancedFindPlugin queryPlugin = new AdvancedFindPlugin(GraphElementType.VERTEX, rules, false);
        PluginExecution.withPlugin(queryPlugin).executeNow(graph);
        final List<FindResult> results = queryPlugin.getResults();
        // validate results
        assertEquals("result size", 3, results.size());
        assertTrue("node 'name1' found", nodeFound(rg, "name1", results));
        assertTrue("node 'name2' found", nodeFound(rg, "name2", results));
        assertTrue("node 'name3' found", nodeFound(rg, "name3", results));
    } finally {
        rg.release();
    }
}
Also used : ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) AdvancedFindPlugin(au.gov.asd.tac.constellation.views.find.advanced.AdvancedFindPlugin) HashMap(java.util.HashMap) GraphAttribute(au.gov.asd.tac.constellation.graph.GraphAttribute) FindRule(au.gov.asd.tac.constellation.views.find.advanced.FindRule) ArrayList(java.util.ArrayList) GraphNode(au.gov.asd.tac.constellation.graph.node.GraphNode) TopComponent(org.openide.windows.TopComponent) FindResult(au.gov.asd.tac.constellation.views.find.advanced.FindResult) Test(org.testng.annotations.Test)

Example 17 with GraphNode

use of au.gov.asd.tac.constellation.graph.node.GraphNode in project constellation by constellation-app.

the class FindNGTest method findSingleNodeIsTest.

@Test
public void findSingleNodeIsTest() throws InterruptedException, PluginException {
    ArrayList<FindRule> rules = new ArrayList<>();
    ReadableGraph rg = graph.getReadableGraph();
    try {
        // setup find criteria / rules
        HashMap<String, Object> values = new HashMap<>();
        values.put("string_content", "name1");
        values.put("string_case_sensitive", false);
        values.put("string_use_list", false);
        FindRule rule1 = new FindRule(FindTypeOperators.Type.STRING, new GraphAttribute(rg, rg.getAttribute(GraphElementType.VERTEX, vNameAttr)), FindTypeOperators.Operator.IS, values);
        rules.add(rule1);
        // perform find search
        // need to create temporary GraphNode and skip the RemoteInit portion of the initialisation
        GraphNode aGraphNode = new GraphNode(graph, null, new TopComponent(), null);
        final AdvancedFindPlugin queryPlugin = new AdvancedFindPlugin(GraphElementType.VERTEX, rules, false);
        PluginExecution.withPlugin(queryPlugin).executeNow(graph);
        final List<FindResult> results = queryPlugin.getResults();
        // validate results
        assertEquals("result size", 1, results.size());
        assertTrue("node 'name1' found", nodeFound(rg, "name1", results));
    } finally {
        rg.release();
    }
}
Also used : ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) AdvancedFindPlugin(au.gov.asd.tac.constellation.views.find.advanced.AdvancedFindPlugin) HashMap(java.util.HashMap) GraphAttribute(au.gov.asd.tac.constellation.graph.GraphAttribute) FindRule(au.gov.asd.tac.constellation.views.find.advanced.FindRule) ArrayList(java.util.ArrayList) GraphNode(au.gov.asd.tac.constellation.graph.node.GraphNode) TopComponent(org.openide.windows.TopComponent) FindResult(au.gov.asd.tac.constellation.views.find.advanced.FindResult) Test(org.testng.annotations.Test)

Example 18 with GraphNode

use of au.gov.asd.tac.constellation.graph.node.GraphNode in project constellation by constellation-app.

the class GraphStatusLine method resultChanged.

@Override
public void resultChanged(final LookupEvent ev) {
    if (graph != null) {
        graph.removeGraphChangeListener(this);
    }
    final Node[] activatedNodes = TopComponent.getRegistry().getActivatedNodes();
    if (activatedNodes.length > 0 && activatedNodes[0] instanceof GraphNode) {
        final GraphNode gnode = (GraphNode) activatedNodes[0];
        graph = gnode.getGraph();
        graph.addGraphChangeListener(this);
    } else {
        graph = null;
    }
    graphChanged(null);
}
Also used : Node(org.openide.nodes.Node) GraphNode(au.gov.asd.tac.constellation.graph.node.GraphNode) GraphNode(au.gov.asd.tac.constellation.graph.node.GraphNode)

Example 19 with GraphNode

use of au.gov.asd.tac.constellation.graph.node.GraphNode in project constellation by constellation-app.

the class ExportToImagePlugin method execute.

@Override
protected void execute(final PluginGraphs graphs, final PluginInteraction interaction, final PluginParameters parameters) throws InterruptedException, PluginException {
    final String fnam = parameters.getParameters().get(FILE_NAME_PARAMETER_ID).getStringValue();
    final File imageFile = new File(fnam);
    final GraphNode graphNode = GraphNode.getGraphNode(graphs.getGraph());
    final VisualManager visualManager = graphNode.getVisualManager();
    if (visualManager != null) {
        visualManager.exportToImage(imageFile);
        final ReadableGraph rg = graphs.getGraph().getReadableGraph();
        try {
            ConstellationLoggerHelper.exportPropertyBuilder(this, GraphRecordStoreUtilities.getVertices(rg, false, false, false).getAll(GraphRecordStoreUtilities.SOURCE + VisualConcept.VertexAttribute.LABEL), new File(fnam), ConstellationLoggerHelper.SUCCESS);
        } finally {
            rg.release();
        }
    }
}
Also used : VisualManager(au.gov.asd.tac.constellation.utilities.visual.VisualManager) ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) GraphNode(au.gov.asd.tac.constellation.graph.node.GraphNode) File(java.io.File)

Example 20 with GraphNode

use of au.gov.asd.tac.constellation.graph.node.GraphNode in project constellation by constellation-app.

the class CopyToNewGraphPlugin method read.

@Override
protected void read(final GraphReadMethods rg, final PluginInteraction interaction, final PluginParameters parameters) throws InterruptedException, PluginException {
    final String newSchemaName = parameters.getParameters().get(NEW_SCHEMA_NAME_PARAMETER_ID).getStringValue();
    final boolean copyAll = parameters.getParameters().get(COPY_ALL_PARAMETER_ID).getBooleanValue();
    final boolean copyKeys = parameters.getParameters().get(COPY_KEYS_PARAMETER_ID).getBooleanValue();
    final GraphNode gnode = GraphNode.getGraphNode(rg.getId());
    final String name;
    if (gnode != null) {
        name = nameWithoutNumericSuffix(gnode.getDisplayName());
    } else {
        name = "";
    }
    copy = makeGraph(rg, newSchemaName, copyKeys, copyAll);
    parameters.getParameters().get(NEW_GRAPH_OUTPUT_PARAMETER_ID).setObjectValue(copy);
    GraphOpener.getDefault().openGraph(copy, name);
}
Also used : GraphNode(au.gov.asd.tac.constellation.graph.node.GraphNode)

Aggregations

GraphNode (au.gov.asd.tac.constellation.graph.node.GraphNode)21 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)11 TopComponent (org.openide.windows.TopComponent)9 Test (org.testng.annotations.Test)9 GraphAttribute (au.gov.asd.tac.constellation.graph.GraphAttribute)8 AdvancedFindPlugin (au.gov.asd.tac.constellation.views.find.advanced.AdvancedFindPlugin)8 FindResult (au.gov.asd.tac.constellation.views.find.advanced.FindResult)8 FindRule (au.gov.asd.tac.constellation.views.find.advanced.FindRule)8 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)8 Graph (au.gov.asd.tac.constellation.graph.Graph)6 File (java.io.File)5 IOException (java.io.IOException)5 VisualManager (au.gov.asd.tac.constellation.utilities.visual.VisualManager)3 RestServiceException (au.gov.asd.tac.constellation.webserver.restapi.RestServiceException)2 BufferedImage (java.awt.image.BufferedImage)2 Semaphore (java.util.concurrent.Semaphore)2 GraphReadMethods (au.gov.asd.tac.constellation.graph.GraphReadMethods)1 WritableGraph (au.gov.asd.tac.constellation.graph.WritableGraph)1 GraphDataObject (au.gov.asd.tac.constellation.graph.file.GraphDataObject)1