use of au.gov.asd.tac.constellation.graph.WritableGraph in project constellation by constellation-app.
the class FindNGTest method setUpMethod.
@BeforeMethod
public void setUpMethod() throws Exception {
graph = new DualGraph(null);
WritableGraph wg = graph.getWritableGraph("add", true);
try {
attrX = wg.addAttribute(GraphElementType.VERTEX, FloatAttributeDescription.ATTRIBUTE_NAME, "x", "x", 0.0, null);
if (attrX == Graph.NOT_FOUND) {
fail();
}
attrY = wg.addAttribute(GraphElementType.VERTEX, FloatAttributeDescription.ATTRIBUTE_NAME, "y", "y", 0.0, null);
if (attrY == Graph.NOT_FOUND) {
fail();
}
attrZ = wg.addAttribute(GraphElementType.VERTEX, FloatAttributeDescription.ATTRIBUTE_NAME, "z", "z", 0.0, null);
if (attrZ == Graph.NOT_FOUND) {
fail();
}
vNameAttr = wg.addAttribute(GraphElementType.VERTEX, StringAttributeDescription.ATTRIBUTE_NAME, "name", "descr", "", null);
if (vNameAttr == Graph.NOT_FOUND) {
fail();
}
tNameAttr = wg.addAttribute(GraphElementType.TRANSACTION, StringAttributeDescription.ATTRIBUTE_NAME, "name", "descr", "", null);
if (tNameAttr == Graph.NOT_FOUND) {
fail();
}
vSelAttr = wg.addAttribute(GraphElementType.VERTEX, BooleanAttributeDescription.ATTRIBUTE_NAME, "selected", "selected", false, null);
if (vSelAttr == Graph.NOT_FOUND) {
fail();
}
tSelAttr = wg.addAttribute(GraphElementType.TRANSACTION, BooleanAttributeDescription.ATTRIBUTE_NAME, "selected", "selected", false, null);
if (tSelAttr == Graph.NOT_FOUND) {
fail();
}
vxId1 = wg.addVertex();
wg.setFloatValue(attrX, vxId1, 1.0f);
wg.setFloatValue(attrY, vxId1, 1.1f);
wg.setBooleanValue(vSelAttr, vxId1, false);
wg.setStringValue(vNameAttr, vxId1, "name1");
vxId2 = wg.addVertex();
wg.setFloatValue(attrX, vxId2, 2.0f);
wg.setFloatValue(attrY, vxId2, 2.2f);
wg.setBooleanValue(vSelAttr, vxId2, true);
wg.setStringValue(vNameAttr, vxId2, "name2");
vxId3 = wg.addVertex();
wg.setFloatValue(attrX, vxId3, 3.0f);
wg.setFloatValue(attrY, vxId3, 3.3f);
wg.setBooleanValue(vSelAttr, vxId3, false);
wg.setStringValue(vNameAttr, vxId3, "name3");
vxId4 = wg.addVertex();
wg.setFloatValue(attrX, vxId4, 4.0f);
wg.setFloatValue(attrY, vxId4, 4.4f);
wg.setBooleanValue(vSelAttr, vxId4, true);
wg.setStringValue(vNameAttr, vxId4, "name4");
vxId5 = wg.addVertex();
wg.setFloatValue(attrX, vxId5, 5.0f);
wg.setFloatValue(attrY, vxId5, 5.5f);
wg.setBooleanValue(vSelAttr, vxId5, false);
wg.setStringValue(vNameAttr, vxId5, "name5");
vxId6 = wg.addVertex();
wg.setFloatValue(attrX, vxId6, 6.0f);
wg.setFloatValue(attrY, vxId6, 6.60f);
wg.setBooleanValue(vSelAttr, vxId6, true);
wg.setStringValue(vNameAttr, vxId6, "name6");
vxId7 = wg.addVertex();
wg.setFloatValue(attrX, vxId7, 7.0f);
wg.setFloatValue(attrY, vxId7, 7.7f);
wg.setBooleanValue(vSelAttr, vxId7, false);
wg.setStringValue(vNameAttr, vxId7, "name7");
txId1 = wg.addTransaction(vxId1, vxId2, false);
wg.setBooleanValue(tSelAttr, txId1, false);
wg.setStringValue(tNameAttr, txId1, "name101");
txId2 = wg.addTransaction(vxId1, vxId3, false);
wg.setBooleanValue(tSelAttr, txId2, true);
wg.setStringValue(tNameAttr, txId2, "name102");
txId3 = wg.addTransaction(vxId2, vxId4, true);
wg.setBooleanValue(tSelAttr, txId3, false);
wg.setStringValue(tNameAttr, txId3, "name103");
txId4 = wg.addTransaction(vxId4, vxId2, true);
wg.setBooleanValue(tSelAttr, txId4, true);
wg.setStringValue(tNameAttr, txId4, "name104");
txId5 = wg.addTransaction(vxId5, vxId6, false);
wg.setBooleanValue(tSelAttr, txId5, false);
wg.setStringValue(tNameAttr, txId5, "name105");
} finally {
wg.commit();
}
}
use of au.gov.asd.tac.constellation.graph.WritableGraph in project constellation by constellation-app.
the class ColourCriteriaPanelNGTest 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);
colorV = VisualConcept.VertexAttribute.COLOR.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.setFloatValue(xV, vxId1, 1);
wg.setObjectValue(colorV, vxId1, ConstellationColor.BLUE);
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 FloatCriteriaPanelNGTest 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.setFloatValue(xV, vxId1, 1);
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 BasicFindTabNGTest 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);
/**
* Get the label and the identifier vertex attributes and add them
* to the attributes list
*/
GraphElementType elementType = GraphElementType.VERTEX;
// The label attribute
int attributeInt = wg.getAttribute(elementType, 1);
labelAttributeV = new GraphAttribute(wg, attributeInt);
basicFindTab.attributes.add(labelAttributeV);
// The identifier attribute
attributeInt = wg.getAttribute(elementType, 2);
identifierAttributeV = new GraphAttribute(wg, attributeInt);
basicFindTab.attributes.add(identifierAttributeV);
elementType = GraphElementType.TRANSACTION;
attributeInt = wg.getAttribute(elementType, 1);
labelAttributeT = new GraphAttribute(wg, attributeInt);
attributeInt = wg.getAttribute(elementType, 2);
identifierAttributeT = new GraphAttribute(wg, attributeInt);
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 BasicFindPluginNGTest method testEdit.
/**
* Test of edit method, of class BasicFindPlugin.
*/
@Test
public void testEdit() throws Exception {
System.out.println("edit");
setupGraph();
attributeList.addAll(getAttributes());
BasicFindPlugin basicFindPlugin = new BasicFindPlugin(parameters, true, false);
PluginExecution.withPlugin(basicFindPlugin).executeNow(graph);
ReadableGraph rg = graph.getReadableGraph();
/**
* Testing finding all elements with "label name", Should select
* vxId1,2,3,4
*/
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();
/**
* Testing finding all elements with "clear", should deselect all
* existing elements as no elements have clear in their name
*/
basicFindPlugin = new BasicFindPlugin(parametersClearSelections, true, false);
PluginExecution.withPlugin(basicFindPlugin).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();
/**
* Testing finding next element with "label name", Should select vxId1
*/
basicFindPlugin = new BasicFindPlugin(parameters, false, true);
PluginExecution.withPlugin(basicFindPlugin).executeNow(graph);
rg = graph.getReadableGraph();
assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
assertEquals(rg.getBooleanValue(selectedV, vxId2), false);
assertEquals(rg.getBooleanValue(selectedV, vxId3), false);
assertEquals(rg.getBooleanValue(selectedV, vxId4), false);
rg.close();
/**
* Testing finding next element with "label name", Should select vxId2
* and deselect vxId1
*/
PluginExecution.withPlugin(basicFindPlugin).executeNow(graph);
rg = graph.getReadableGraph();
assertEquals(rg.getBooleanValue(selectedV, vxId1), false);
assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
assertEquals(rg.getBooleanValue(selectedV, vxId3), false);
assertEquals(rg.getBooleanValue(selectedV, vxId4), false);
rg.close();
/**
* Testing finding previous element with "label name", Should select
* vxId1 and deselect vxId2
*/
basicFindPlugin = new BasicFindPlugin(parameters, false, false);
PluginExecution.withPlugin(basicFindPlugin).executeNow(graph);
rg = graph.getReadableGraph();
assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
assertEquals(rg.getBooleanValue(selectedV, vxId2), false);
assertEquals(rg.getBooleanValue(selectedV, vxId3), false);
assertEquals(rg.getBooleanValue(selectedV, vxId4), false);
rg.close();
/**
* Testing finding all transaction elements with "label name", Should
* select txId1,2,3,4
*/
basicFindPlugin = new BasicFindPlugin(parametersTransactionType, true, false);
PluginExecution.withPlugin(basicFindPlugin).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), true);
rg.close();
/**
* clear selection
*/
basicFindPlugin = new BasicFindPlugin(parametersClearSelections, true, false);
PluginExecution.withPlugin(basicFindPlugin).executeNow(graph);
/**
* Testing finding all elements with regEx "la*", should select
* vxId1,2,3,4
*/
basicFindPlugin = new BasicFindPlugin(parametersRegEx, true, false);
PluginExecution.withPlugin(basicFindPlugin).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();
/**
* clear selection
*/
basicFindPlugin = new BasicFindPlugin(parametersClearSelections, true, false);
PluginExecution.withPlugin(basicFindPlugin).executeNow(graph);
/**
* Testing finding all elements with ignoreCase "label name" should
* select vxId1,2,3,4,5UpperCase
*/
basicFindPlugin = new BasicFindPlugin(parametersIgnoreCase, true, false);
PluginExecution.withPlugin(basicFindPlugin).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, vxId5UpperCase), true);
rg.close();
/**
* clear selection
*/
basicFindPlugin = new BasicFindPlugin(parametersClearSelections, true, false);
PluginExecution.withPlugin(basicFindPlugin).executeNow(graph);
/**
* Testing finding all elements without ignoreCase "label name" should
* select vxId1,2,3,4
*/
basicFindPlugin = new BasicFindPlugin(parameters, true, false);
PluginExecution.withPlugin(basicFindPlugin).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, vxId5UpperCase), false);
rg.close();
/**
* clear selection
*/
basicFindPlugin = new BasicFindPlugin(parametersClearSelections, true, false);
PluginExecution.withPlugin(basicFindPlugin).executeNow(graph);
/**
* Testing finding all elements with exactMatch "label" shouldn't select
* anything
*/
basicFindPlugin = new BasicFindPlugin(parametersExactMatch, true, false);
PluginExecution.withPlugin(basicFindPlugin).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();
/**
* Testing finding all elements within the current selection that
* contain the word "test" should select vxId6 but not vxId8 since it
* isn't selected
*/
basicFindPlugin = new BasicFindPlugin(parametersFindIn, true, false);
WritableGraph wg = graph.getWritableGraph("", true);
wg.setBooleanValue(selectedV, vxId1, true);
wg.setBooleanValue(selectedV, vxId2, true);
wg.setBooleanValue(selectedV, vxId3, true);
wg.setBooleanValue(selectedV, vxId4, true);
wg.setBooleanValue(selectedV, vxId6, true);
wg.setBooleanValue(selectedV, vxId7, true);
wg.setBooleanValue(selectedV, vxId8, false);
wg.commit();
PluginExecution.withPlugin(basicFindPlugin).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);
assertEquals(rg.getBooleanValue(selectedV, vxId8), false);
rg.close();
/**
* Testing finding all elements with "label name" and adding them to the
* current selected items. vxId1,2,3,4 and 6 should be selected
*/
basicFindPlugin = new BasicFindPlugin(parametersAddTo, true, false);
PluginExecution.withPlugin(basicFindPlugin).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), true);
assertEquals(rg.getBooleanValue(selectedV, vxId7), false);
assertEquals(rg.getBooleanValue(selectedV, vxId8), false);
rg.close();
/**
* Testing removing all elements "label name" from the currently
* selected. Only vxId6 should remain selected
*/
basicFindPlugin = new BasicFindPlugin(parametersRemoveFrom, true, false);
PluginExecution.withPlugin(basicFindPlugin).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);
assertEquals(rg.getBooleanValue(selectedV, vxId8), false);
rg.close();
}
Aggregations