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();
}
}
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();
}
}
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();
}
}
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();
}
}
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();
}
}
Aggregations