use of au.gov.asd.tac.constellation.graph.WritableGraph in project constellation by constellation-app.
the class SelectAllPluginNGTest method testEdit1.
/**
* Test of edit method, of class SelectAllPlugin. select all edit with only
* vx on graph
*/
@Test
public void testEdit1() throws Exception {
System.out.println("select all edit with only vx on graph");
// Open a new graph
graph = new DualGraph(SchemaFactoryUtilities.getSchemaFactory(VisualSchemaFactory.VISUAL_SCHEMA_ID).createSchema());
int vxCount = 0;
final WritableGraph wg = graph.getWritableGraph("TEST", true);
try {
// Create Selected Attributes
selectedV = VisualConcept.VertexAttribute.SELECTED.ensure(wg);
selectedT = VisualConcept.TransactionAttribute.SELECTED.ensure(wg);
// Add vertices
vxId1 = wg.addVertex();
vxId2 = wg.addVertex();
// check default value is unselected
assertFalse(wg.getBooleanValue(selectedV, vxId1));
assertFalse(wg.getBooleanValue(selectedV, vxId2));
vxCount = wg.getVertexCount();
} finally {
wg.commit();
}
// run select all plugin
PluginExecution.withPlugin(new SelectAllPlugin()).executeNow(graph);
// Verify both selected and same amount of vx are present
final ReadableGraph rg = graph.getReadableGraph();
try {
assertTrue(rg.getBooleanValue(selectedV, vxId1));
assertTrue(rg.getBooleanValue(selectedV, vxId2));
assertEquals(rg.getVertexCount(), vxCount);
} finally {
rg.close();
}
// rerun plugin to ensure values are not only toggled, but are set explicitly as selected
// run select all plugin
PluginExecution.withPlugin(new SelectAllPlugin()).executeNow(graph);
// Verify both selected and same amount of vx are present
final ReadableGraph rg2 = graph.getReadableGraph();
try {
assertTrue(rg2.getBooleanValue(selectedV, vxId1));
assertTrue(rg2.getBooleanValue(selectedV, vxId2));
assertEquals(rg2.getVertexCount(), vxCount);
} finally {
rg2.close();
}
}
use of au.gov.asd.tac.constellation.graph.WritableGraph in project constellation by constellation-app.
the class DataAccessUtilitiesNGTest method testsaveDataAccessState.
@Test
public void testsaveDataAccessState() throws Exception {
System.out.println("testsaveDataAccessState");
// mock Tab
final Tab tab = mock(Tab.class);
ObservableList<Tab> observableArrayList = FXCollections.observableArrayList(tab);
// mock TabPane
final TabPane tabPane = mock(TabPane.class);
when(tabPane.getTabs()).thenReturn(observableArrayList);
final ScrollPane scrollPane = mock(ScrollPane.class);
final QueryPhasePane queryPhasePane = mock(QueryPhasePane.class);
final GlobalParametersPane globalParametersPane = mock(GlobalParametersPane.class);
final PluginParameters pluginParameters = mock(PluginParameters.class);
final PluginParameter pluginParameter = mock(PluginParameter.class);
when(tab.getContent()).thenReturn(scrollPane);
when(scrollPane.getContent()).thenReturn(queryPhasePane);
when(queryPhasePane.getGlobalParametersPane()).thenReturn(globalParametersPane);
when(globalParametersPane.getParams()).thenReturn(pluginParameters);
when(pluginParameter.getStringValue()).thenReturn("something");
final String someKey = "someKey";
final Map<String, PluginParameter<?>> map = Map.of(someKey, pluginParameter);
when(pluginParameters.getParameters()).thenReturn(map);
// mock graph
final Graph graph = mock(Graph.class);
final WritableGraph wGraph = mock(WritableGraph.class);
when(graph.getWritableGraph("Update Data Access State", true)).thenReturn(wGraph);
DataAccessUtilities.saveDataAccessState(tabPane, graph);
final DataAccessState expectedTab = new DataAccessState();
expectedTab.newTab();
expectedTab.add("someKey", "something");
assertEquals(expectedTab.getState().size(), 1);
verify(wGraph).setObjectValue(0, 0, expectedTab);
}
use of au.gov.asd.tac.constellation.graph.WritableGraph in project constellation by constellation-app.
the class AdvancedSearchPluginNGTest method testEdit.
/**
* Test of edit method, of class AdvancedSearchPlugin.
*/
@Test
public void testEdit() throws Exception {
System.out.println("edit");
setupGraph();
GraphElementType elementType = GraphElementType.VERTEX;
final String all = "All";
final String any = "Any";
final String ignore = "Ignore";
final String addTo = "Add To";
final String removeFrom = "Remove From";
final String findIn = "Find In";
boolean searchAllGraphs = false;
// STRING | VERTEX | MATCH ANY CRITERIA | INGORE CURRENT SELECTION | SEARCH 1 GRAPH
// Is
List<FindCriteriaValues> findCriteriaValuesList = new ArrayList<>();
StringCriteriaValues stringCriteriaValue1 = new StringCriteriaValues("string", "Identifier", "Is", "identifer name", true, false);
findCriteriaValuesList.add(stringCriteriaValue1);
AdvancedSearchParameters parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
AdvancedSearchPlugin advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
ReadableGraph rg = graph.getReadableGraph();
assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
assertEquals(rg.getBooleanValue(selectedV, vxId4), true);
rg.close();
// Is not
findCriteriaValuesList = new ArrayList<>();
stringCriteriaValue1 = new StringCriteriaValues("string", "Identifier", "Is Not", "identifer name", true, false);
findCriteriaValuesList.add(stringCriteriaValue1);
parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
rg = graph.getReadableGraph();
assertEquals(rg.getBooleanValue(selectedV, vxId1), false);
assertEquals(rg.getBooleanValue(selectedV, vxId2), false);
assertEquals(rg.getBooleanValue(selectedV, vxId3), false);
assertEquals(rg.getBooleanValue(selectedV, vxId4), false);
rg.close();
// Contains
findCriteriaValuesList = new ArrayList<>();
stringCriteriaValue1 = new StringCriteriaValues("string", "Identifier", "Contains", "identifer", true, false);
findCriteriaValuesList.add(stringCriteriaValue1);
parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
rg = graph.getReadableGraph();
assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
assertEquals(rg.getBooleanValue(selectedV, vxId4), true);
rg.close();
// Doesn't Contain
findCriteriaValuesList = new ArrayList<>();
stringCriteriaValue1 = new StringCriteriaValues("string", "Identifier", "Doesn't Contain", "identifer", true, false);
findCriteriaValuesList.add(stringCriteriaValue1);
parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
rg = graph.getReadableGraph();
assertEquals(rg.getBooleanValue(selectedV, vxId1), false);
assertEquals(rg.getBooleanValue(selectedV, vxId2), false);
assertEquals(rg.getBooleanValue(selectedV, vxId3), false);
assertEquals(rg.getBooleanValue(selectedV, vxId4), false);
rg.close();
// Begins With
findCriteriaValuesList = new ArrayList<>();
stringCriteriaValue1 = new StringCriteriaValues("string", "Identifier", "Begins With", "iden", true, false);
findCriteriaValuesList.add(stringCriteriaValue1);
parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
rg = graph.getReadableGraph();
assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
assertEquals(rg.getBooleanValue(selectedV, vxId4), true);
rg.close();
// Ends With
findCriteriaValuesList = new ArrayList<>();
stringCriteriaValue1 = new StringCriteriaValues("string", "Identifier", "Ends With", "name", true, false);
findCriteriaValuesList.add(stringCriteriaValue1);
parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
rg = graph.getReadableGraph();
assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
assertEquals(rg.getBooleanValue(selectedV, vxId4), true);
rg.close();
// Matches (Regex)
findCriteriaValuesList = new ArrayList<>();
stringCriteriaValue1 = new StringCriteriaValues("string", "Identifier", "Matches (Regex)", "den", true, false);
findCriteriaValuesList.add(stringCriteriaValue1);
parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
rg = graph.getReadableGraph();
assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
assertEquals(rg.getBooleanValue(selectedV, vxId4), true);
rg.close();
// Float
// Is
findCriteriaValuesList = new ArrayList<>();
FloatCriteriaValues floatCriteriaValues = new FloatCriteriaValues("float", "x", "Is", 1);
findCriteriaValuesList.add(floatCriteriaValues);
parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
rg = graph.getReadableGraph();
assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
assertEquals(rg.getBooleanValue(selectedV, vxId4), true);
rg.close();
// Is Not
findCriteriaValuesList = new ArrayList<>();
floatCriteriaValues = new FloatCriteriaValues("float", "x", "Is Not", 1);
findCriteriaValuesList.add(floatCriteriaValues);
parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
rg = graph.getReadableGraph();
assertEquals(rg.getBooleanValue(selectedV, vxId1), false);
assertEquals(rg.getBooleanValue(selectedV, vxId2), false);
assertEquals(rg.getBooleanValue(selectedV, vxId3), false);
assertEquals(rg.getBooleanValue(selectedV, vxId4), false);
rg.close();
// Is Less Than
findCriteriaValuesList = new ArrayList<>();
floatCriteriaValues = new FloatCriteriaValues("float", "x", "Is Less Than", 4);
findCriteriaValuesList.add(floatCriteriaValues);
parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
rg = graph.getReadableGraph();
assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
assertEquals(rg.getBooleanValue(selectedV, vxId4), true);
rg.close();
// Is Greater Than
findCriteriaValuesList = new ArrayList<>();
floatCriteriaValues = new FloatCriteriaValues("float", "x", "Is Greater Than", 0);
findCriteriaValuesList.add(floatCriteriaValues);
parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
rg = graph.getReadableGraph();
assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
assertEquals(rg.getBooleanValue(selectedV, vxId4), true);
rg.close();
// Is Between
findCriteriaValuesList = new ArrayList<>();
floatCriteriaValues = new FloatCriteriaValues("float", "x", "Is Between", 0, 4);
findCriteriaValuesList.add(floatCriteriaValues);
parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
rg = graph.getReadableGraph();
assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
assertEquals(rg.getBooleanValue(selectedV, vxId4), true);
rg.close();
// Boolean
// Is
findCriteriaValuesList = new ArrayList<>();
BooleanCriteriaValues booleanCriteriaValue = new BooleanCriteriaValues("boolean", "dim", "Is", true);
findCriteriaValuesList.add(booleanCriteriaValue);
parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
rg = graph.getReadableGraph();
assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
assertEquals(rg.getBooleanValue(selectedV, vxId4), true);
rg.close();
// Constellation Color
// Is
findCriteriaValuesList = new ArrayList<>();
ColourCriteriaValues colourCriteriaValue = new ColourCriteriaValues("color", "color", "Is", ConstellationColor.BLUE);
findCriteriaValuesList.add(colourCriteriaValue);
parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
rg = graph.getReadableGraph();
assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
assertEquals(rg.getBooleanValue(selectedV, vxId4), true);
rg.close();
// Is Not
findCriteriaValuesList = new ArrayList<>();
colourCriteriaValue = new ColourCriteriaValues("color", "color", "Is Not", ConstellationColor.BLUE);
findCriteriaValuesList.add(colourCriteriaValue);
parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
rg = graph.getReadableGraph();
assertEquals(rg.getBooleanValue(selectedV, vxId1), false);
assertEquals(rg.getBooleanValue(selectedV, vxId2), false);
assertEquals(rg.getBooleanValue(selectedV, vxId3), false);
assertEquals(rg.getBooleanValue(selectedV, vxId4), false);
rg.close();
// Constellation Icon
// Is
findCriteriaValuesList = new ArrayList<>();
IconCriteriaValues iconCriteriaValue = new IconCriteriaValues("icon", "background_icon", "Is", IconManager.getIcon("Flag.Australia"));
findCriteriaValuesList.add(iconCriteriaValue);
parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
rg = graph.getReadableGraph();
assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
assertEquals(rg.getBooleanValue(selectedV, vxId4), true);
rg.close();
// Is Not
findCriteriaValuesList = new ArrayList<>();
iconCriteriaValue = new IconCriteriaValues("icon", "background_icon", "Is Not", IconManager.getIcon("Flag.Australia"));
findCriteriaValuesList.add(iconCriteriaValue);
parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
rg = graph.getReadableGraph();
assertEquals(rg.getBooleanValue(selectedV, vxId1), false);
assertEquals(rg.getBooleanValue(selectedV, vxId2), false);
assertEquals(rg.getBooleanValue(selectedV, vxId3), false);
assertEquals(rg.getBooleanValue(selectedV, vxId4), false);
rg.close();
// DateTime
// Occured On
findCriteriaValuesList = new ArrayList<>();
DateTimeCriteriaValues dateTimeCriteriaValue = new DateTimeCriteriaValues("datetime", "DateTime", "Occured On", formatDateTime(testTime));
findCriteriaValuesList.add(dateTimeCriteriaValue);
elementType = GraphElementType.TRANSACTION;
parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
rg = graph.getReadableGraph();
LOG.log(Level.SEVERE, dateTimeCriteriaValue.getDateTimeStringPrimaryValue());
LOG.log(Level.SEVERE, dateTimeCriteriaValue.getDateTimeStringPrimaryValue());
LOG.log(Level.SEVERE, rg.getObjectValue(dateTimeT, txId1).toString());
assertEquals(rg.getBooleanValue(selectedT, txId1), true);
assertEquals(rg.getBooleanValue(selectedT, txId2), true);
assertEquals(rg.getBooleanValue(selectedT, txId3), false);
assertEquals(rg.getBooleanValue(selectedT, txId4), false);
rg.close();
// Didn't Occur On
findCriteriaValuesList = new ArrayList<>();
dateTimeCriteriaValue = new DateTimeCriteriaValues("datetime", "DateTime", "Didn't Occur On", formatDateTime(testTime));
findCriteriaValuesList.add(dateTimeCriteriaValue);
parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
rg = graph.getReadableGraph();
assertEquals(rg.getBooleanValue(selectedT, txId1), false);
assertEquals(rg.getBooleanValue(selectedT, txId2), false);
assertEquals(rg.getBooleanValue(selectedT, txId3), true);
assertEquals(rg.getBooleanValue(selectedT, txId4), true);
rg.close();
// Occured Before
findCriteriaValuesList = new ArrayList<>();
dateTimeCriteriaValue = new DateTimeCriteriaValues("datetime", "DateTime", "Occured Before", formatDateTime(plus1YearTestTime));
findCriteriaValuesList.add(dateTimeCriteriaValue);
parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
rg = graph.getReadableGraph();
assertEquals(rg.getBooleanValue(selectedT, txId1), true);
assertEquals(rg.getBooleanValue(selectedT, txId2), true);
assertEquals(rg.getBooleanValue(selectedT, txId3), true);
assertEquals(rg.getBooleanValue(selectedT, txId4), false);
rg.close();
// Occured After
findCriteriaValuesList = new ArrayList<>();
dateTimeCriteriaValue = new DateTimeCriteriaValues("datetime", "DateTime", "Occured After", formatDateTime(plus1YearTestTime));
findCriteriaValuesList.add(dateTimeCriteriaValue);
parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
rg = graph.getReadableGraph();
assertEquals(rg.getBooleanValue(selectedT, txId1), false);
assertEquals(rg.getBooleanValue(selectedT, txId2), false);
assertEquals(rg.getBooleanValue(selectedT, txId3), true);
assertEquals(rg.getBooleanValue(selectedT, txId4), true);
rg.close();
// Occured Between
findCriteriaValuesList = new ArrayList<>();
dateTimeCriteriaValue = new DateTimeCriteriaValues("datetime", "DateTime", "Occured Between", formatDateTime(testTime), formatDateTime(plus2YearTestTime));
findCriteriaValuesList.add(dateTimeCriteriaValue);
parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
rg = graph.getReadableGraph();
assertEquals(rg.getBooleanValue(selectedT, txId1), false);
assertEquals(rg.getBooleanValue(selectedT, txId2), false);
assertEquals(rg.getBooleanValue(selectedT, txId3), true);
assertEquals(rg.getBooleanValue(selectedT, txId4), false);
rg.close();
// Test multiple criteria (any)
findCriteriaValuesList = new ArrayList<>();
stringCriteriaValue1 = new StringCriteriaValues("string", "Identifier", "Is", "identifer name", true, false);
iconCriteriaValue = new IconCriteriaValues("icon", "background_icon", "Is", IconManager.getIcon("Flag.Australia"));
findCriteriaValuesList.add(stringCriteriaValue1);
findCriteriaValuesList.add(iconCriteriaValue);
elementType = GraphElementType.VERTEX;
parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
rg = graph.getReadableGraph();
assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
assertEquals(rg.getBooleanValue(selectedV, vxId4), true);
assertEquals(rg.getBooleanValue(selectedV, vxId6), false);
rg.close();
// Test multiple criteria (any)
findCriteriaValuesList = new ArrayList<>();
stringCriteriaValue1 = new StringCriteriaValues("string", "Identifier", "Is", "a vertex", true, false);
iconCriteriaValue = new IconCriteriaValues("icon", "background_icon", "Is", IconManager.getIcon("Flag.England"));
findCriteriaValuesList.add(stringCriteriaValue1);
findCriteriaValuesList.add(iconCriteriaValue);
elementType = GraphElementType.VERTEX;
parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, all, ignore, searchAllGraphs);
advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
rg = graph.getReadableGraph();
assertEquals(rg.getBooleanValue(selectedV, vxId1), false);
assertEquals(rg.getBooleanValue(selectedV, vxId2), false);
assertEquals(rg.getBooleanValue(selectedV, vxId3), false);
assertEquals(rg.getBooleanValue(selectedV, vxId4), false);
assertEquals(rg.getBooleanValue(selectedV, vxId6), true);
assertEquals(rg.getBooleanValue(selectedV, vxId7), false);
rg.close();
// Test find next
findCriteriaValuesList = new ArrayList<>();
stringCriteriaValue1 = new StringCriteriaValues("string", "Identifier", "Is", "identifer name", true, false);
findCriteriaValuesList.add(stringCriteriaValue1);
elementType = GraphElementType.VERTEX;
parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
advancedSearchPlugin = new AdvancedSearchPlugin(parameters, false, true);
PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
rg = graph.getReadableGraph();
assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
assertEquals(rg.getBooleanValue(selectedV, vxId2), false);
assertEquals(rg.getBooleanValue(selectedV, vxId3), false);
rg.close();
advancedSearchPlugin = new AdvancedSearchPlugin(parameters, false, true);
PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
rg = graph.getReadableGraph();
assertEquals(rg.getBooleanValue(selectedV, vxId1), false);
assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
assertEquals(rg.getBooleanValue(selectedV, vxId3), false);
rg.close();
advancedSearchPlugin = new AdvancedSearchPlugin(parameters, false, true);
PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
rg = graph.getReadableGraph();
assertEquals(rg.getBooleanValue(selectedV, vxId1), false);
assertEquals(rg.getBooleanValue(selectedV, vxId2), false);
assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
rg.close();
// Test find prev
elementType = GraphElementType.VERTEX;
parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
advancedSearchPlugin = new AdvancedSearchPlugin(parameters, false, false);
PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
rg = graph.getReadableGraph();
assertEquals(rg.getBooleanValue(selectedV, vxId1), false);
assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
assertEquals(rg.getBooleanValue(selectedV, vxId3), false);
rg.close();
advancedSearchPlugin = new AdvancedSearchPlugin(parameters, false, false);
PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
rg = graph.getReadableGraph();
assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
assertEquals(rg.getBooleanValue(selectedV, vxId2), false);
assertEquals(rg.getBooleanValue(selectedV, vxId3), false);
rg.close();
// Test add to
elementType = GraphElementType.VERTEX;
parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, addTo, searchAllGraphs);
advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
WritableGraph wg = graph.getWritableGraph("", true);
wg.setBooleanValue(selectedV, vxId6, true);
wg.setBooleanValue(selectedV, vxId7, true);
wg.commit();
rg = graph.getReadableGraph();
assertEquals(rg.getBooleanValue(selectedV, vxId6), true);
assertEquals(rg.getBooleanValue(selectedV, vxId7), true);
assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
rg.close();
// Test Remove From
elementType = GraphElementType.VERTEX;
parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, removeFrom, searchAllGraphs);
advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
rg = graph.getReadableGraph();
// all but vxId6 match the criteria, so vxId6 remains selected
assertEquals(rg.getBooleanValue(selectedV, vxId6), true);
assertEquals(rg.getBooleanValue(selectedV, vxId7), false);
assertEquals(rg.getBooleanValue(selectedV, vxId1), false);
assertEquals(rg.getBooleanValue(selectedV, vxId2), false);
assertEquals(rg.getBooleanValue(selectedV, vxId3), false);
rg.close();
// Test Find In
elementType = GraphElementType.VERTEX;
parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, findIn, searchAllGraphs);
advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
wg = graph.getWritableGraph("", true);
wg.setBooleanValue(selectedV, vxId1, true);
wg.setBooleanValue(selectedV, vxId2, true);
wg.commit();
rg = graph.getReadableGraph();
// vxId3 is not selected so will not be considered in the
assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
assertEquals(rg.getBooleanValue(selectedV, vxId3), false);
rg.close();
}
use of au.gov.asd.tac.constellation.graph.WritableGraph in project constellation by constellation-app.
the class FindViewTopComponentNGTest method setupGraph.
private void setupGraph() {
graph = new DualGraph(SchemaFactoryUtilities.getSchemaFactory(VisualSchemaFactory.VISUAL_SCHEMA_ID).createSchema());
graphMap.put(graph.getId(), graph);
try {
WritableGraph wg = graph.getWritableGraph("", true);
final int stateId = FindViewConcept.MetaAttribute.FINDVIEW_STATE.ensure(wg);
ArrayList<Attribute> attributeList = new ArrayList<>();
BasicFindReplaceParameters parameters = new BasicFindReplaceParameters("label name", "", GraphElementType.GRAPH.VERTEX, attributeList, true, false, false, false, false, false, false, false, false);
FindResultsList foundResult = new FindResultsList(2, parameters, graph.getId());
wg.setObjectValue(stateId, 0, foundResult);
wg.commit();
} catch (final InterruptedException ex) {
Exceptions.printStackTrace(ex);
Thread.currentThread().interrupt();
}
}
use of au.gov.asd.tac.constellation.graph.WritableGraph in project constellation by constellation-app.
the class AdvancedFindTabNGTest method setupGraph.
private void setupGraph() {
graph = new DualGraph(SchemaFactoryUtilities.getSchemaFactory(VisualSchemaFactory.VISUAL_SCHEMA_ID).createSchema());
graph2 = new DualGraph(SchemaFactoryUtilities.getSchemaFactory(VisualSchemaFactory.VISUAL_SCHEMA_ID).createSchema());
graphMap.put(graph.getId(), graph);
graphMap.put(graph2.getId(), graph2);
try {
WritableGraph wg = graph.getWritableGraph("", true);
// Create Selected Attributes
selectedV = VisualConcept.VertexAttribute.SELECTED.ensure(wg);
labelV = VisualConcept.VertexAttribute.LABEL.ensure(wg);
identifierV = VisualConcept.VertexAttribute.IDENTIFIER.ensure(wg);
xV = VisualConcept.VertexAttribute.X.ensure(wg);
selectedT = VisualConcept.TransactionAttribute.SELECTED.ensure(wg);
labelT = VisualConcept.TransactionAttribute.LABEL.ensure(wg);
identiferT = VisualConcept.TransactionAttribute.IDENTIFIER.ensure(wg);
widthT = VisualConcept.TransactionAttribute.WIDTH.ensure(wg);
vxId1 = wg.addVertex();
wg.setBooleanValue(selectedV, vxId1, false);
wg.setStringValue(labelV, vxId1, "label name");
wg.setStringValue(identifierV, vxId1, "identifer name");
wg.setIntValue(xV, vxId1, 1);
wg.commit();
} catch (final InterruptedException ex) {
Exceptions.printStackTrace(ex);
Thread.currentThread().interrupt();
}
}
Aggregations