Search in sources :

Example 6 with FindRule

use of au.gov.asd.tac.constellation.views.find.advanced.FindRule in project constellation by constellation-app.

the class FindTopComponent method restoreState.

/**
 * Restores a given state to the FindTopComponent.
 *
 * @param state The state that contains all relevant information to restore
 * as to previously defined.
 */
public void restoreState(final FindState state) {
    // Determine the state of the GraphElementType:
    switch(state.getGraphElementType()) {
        case TRANSACTION:
            cmbGraphElementType.setSelectedItem(Bundle.Find_TRANSACTION());
            break;
        case EDGE:
            cmbGraphElementType.setSelectedItem(Bundle.Find_EDGE());
            break;
        case LINK:
            cmbGraphElementType.setSelectedItem(Bundle.Find_LINK());
            break;
        case VERTEX:
        default:
            cmbGraphElementType.setSelectedItem(Bundle.Find_VERTEX());
            break;
    }
    // Start with a blank slate:
    panelFind.removeAll();
    // Determine the state of ANY/ALL:
    if (state.isAny()) {
        cmbMatch.setSelectedItem(Bundle.Find_ANY());
    } else {
        cmbMatch.setSelectedItem(Bundle.Find_ALL());
    }
    // Determine the state of HELD:
    chkAddToSelection.setSelected(state.isHeld());
    if (!state.getRules().isEmpty()) {
        for (FindRule rule : state.getRules()) {
            final FindCriteriaPanel findCriteriaPanel = new FindCriteriaPanel(this, rule, attributes);
            findCriteriaPanel.repaint();
            panelFind.add(findCriteriaPanel);
        }
        shader();
        this.validate();
        this.repaint();
    } else {
        setDefaultFindCriteriaPanels();
    }
}
Also used : FindRule(au.gov.asd.tac.constellation.views.find.advanced.FindRule)

Example 7 with FindRule

use of au.gov.asd.tac.constellation.views.find.advanced.FindRule in project constellation by constellation-app.

the class FindNGTest method findSingleNodeContainTest.

@Test
public void findSingleNodeContainTest() 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", "e1");
        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.CONTAINS, 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 8 with FindRule

use of au.gov.asd.tac.constellation.views.find.advanced.FindRule in project constellation by constellation-app.

the class FindNGTest method findTransactionsTest.

@Test
public void findTransactionsTest() 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", "name");
        values.put("string_case_sensitive", true);
        values.put("string_use_list", false);
        FindRule rule1 = new FindRule(FindTypeOperators.Type.STRING, new GraphAttribute(rg, tNameAttr), FindTypeOperators.Operator.CONTAINS, 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.TRANSACTION, rules, false);
        PluginExecution.withPlugin(queryPlugin).executeNow(graph);
        final List<FindResult> results = queryPlugin.getResults();
        // validate results
        assertEquals("result size", 5, results.size());
        assertTrue("tx 'name101' found", transactionFound(rg, "name101", results));
        assertTrue("tx 'name102' found", transactionFound(rg, "name102", results));
        assertTrue("tx 'name103' found", transactionFound(rg, "name103", results));
        assertTrue("tx 'name104' found", transactionFound(rg, "name104", results));
        assertTrue("tx 'name105' found", transactionFound(rg, "name105", 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 9 with FindRule

use of au.gov.asd.tac.constellation.views.find.advanced.FindRule 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 10 with FindRule

use of au.gov.asd.tac.constellation.views.find.advanced.FindRule 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)

Aggregations

FindRule (au.gov.asd.tac.constellation.views.find.advanced.FindRule)10 GraphAttribute (au.gov.asd.tac.constellation.graph.GraphAttribute)9 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)9 GraphNode (au.gov.asd.tac.constellation.graph.node.GraphNode)8 AdvancedFindPlugin (au.gov.asd.tac.constellation.views.find.advanced.AdvancedFindPlugin)8 FindResult (au.gov.asd.tac.constellation.views.find.advanced.FindResult)8 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)8 TopComponent (org.openide.windows.TopComponent)8 Test (org.testng.annotations.Test)8 Attribute (au.gov.asd.tac.constellation.graph.Attribute)1 Graph (au.gov.asd.tac.constellation.graph.Graph)1 Date (java.util.Date)1 GregorianCalendar (java.util.GregorianCalendar)1