use of au.gov.asd.tac.constellation.graph.locking.DualGraph in project constellation by constellation-app.
the class CompleteGraphBuilderPluginNGTest method testUpdateParameters.
/**
* Test of updateParameters method, of class CompleteGraphBuilderPlugin.
*/
@Test
public void testUpdateParameters() {
System.out.println("updateParameters");
final CompleteGraphBuilderPlugin instance = new CompleteGraphBuilderPlugin();
final PluginParameters params = instance.createParameters();
final PluginParameter<MultiChoiceParameterValue> nAttribute = (PluginParameter<MultiChoiceParameterValue>) params.getParameters().get(NODE_TYPES_PARAMETER_ID);
final PluginParameter<MultiChoiceParameterValue> tAttribute = (PluginParameter<MultiChoiceParameterValue>) params.getParameters().get(TRANSACTION_TYPES_PARAMETER_ID);
assertTrue(MultiChoiceParameterType.getOptions(nAttribute).isEmpty());
assertTrue(MultiChoiceParameterType.getOptions(tAttribute).isEmpty());
instance.updateParameters(new DualGraph(graph.getSchema(), graph), params);
assertEquals(MultiChoiceParameterType.getOptions(nAttribute).size(), 27);
assertEquals(MultiChoiceParameterType.getChoices(nAttribute).size(), 1);
assertEquals(MultiChoiceParameterType.getOptions(tAttribute).size(), 9);
assertEquals(MultiChoiceParameterType.getChoices(tAttribute).size(), 1);
}
use of au.gov.asd.tac.constellation.graph.locking.DualGraph in project constellation by constellation-app.
the class GraphVisualAccessNGTest method setUpMethod.
@BeforeMethod
public void setUpMethod() throws Exception {
final Schema schema = SchemaFactoryUtilities.getSchemaFactory(AnalyticSchemaFactory.ANALYTIC_SCHEMA_ID).createSchema();
sGraph = new StoreGraph();
vxId1 = sGraph.addVertex();
vxId2 = sGraph.addVertex();
tId1 = sGraph.addTransaction(vxId1, vxId2, true);
graph = new DualGraph(schema, sGraph);
}
use of au.gov.asd.tac.constellation.graph.locking.DualGraph in project constellation by constellation-app.
the class NewGraph method callService.
@Override
public void callService(final PluginParameters parameters, final InputStream in, final OutputStream out) throws IOException {
final String schemaParam = parameters.getStringValue(SCHEMA_PARAMETER_ID);
String schemaName = null;
for (final SchemaFactory schemaFactory : SchemaFactoryUtilities.getSchemaFactories().values()) {
if (schemaFactory.isPrimarySchema() && (schemaParam == null || schemaParam.equals(schemaFactory.getName()))) {
schemaName = schemaFactory.getName();
break;
}
}
if (schemaName == null) {
throw new RestServiceException(HTTP_UNPROCESSABLE_ENTITY, String.format("Unknown schema %s", schemaParam));
}
// Creating a new graph is asynchronous; we want to hide this from the client.
//
final Graph existingGraph = GraphManager.getDefault().getActiveGraph();
final String existingId = existingGraph != null ? existingGraph.getId() : null;
final Schema schema = SchemaFactoryUtilities.getSchemaFactory(schemaName).createSchema();
final StoreGraph sg = new StoreGraph(schema);
schema.newGraph(sg);
final Graph dualGraph = new DualGraph(sg, false);
final String graphName = SchemaFactoryUtilities.getSchemaFactory(schemaName).getLabel().trim().toLowerCase();
GraphOpener.getDefault().openGraph(dualGraph, graphName);
final String newId = RestServiceUtilities.waitForGraphChange(existingId);
final ObjectMapper mapper = new ObjectMapper();
final ObjectNode root = mapper.createObjectNode();
root.put("id", newId);
root.put("name", GraphNode.getGraphNode(newId).getDisplayName());
root.put("schema", schemaName);
mapper.writeValue(out, root);
}
use of au.gov.asd.tac.constellation.graph.locking.DualGraph in project constellation by constellation-app.
the class BlazeUtilitiesNGTest method testGetSelectionNoBlazes.
/**
* Test of getSelection method, of class BlazeUtilities. No blazes on the graph
*/
@Test
public void testGetSelectionNoBlazes() {
System.out.println("getSelectionNoBlazes");
graph.setObjectValue(vertexBlazeAttribute, vxId3, null);
graph.setObjectValue(vertexBlazeAttribute, vxId4, null);
final Graph g = new DualGraph(schema, graph);
final Pair<BitSet, ConstellationColor> result = BlazeUtilities.getSelection(g, null);
final BitSet resultBitSet = result.getKey();
final ConstellationColor resultColour = result.getValue();
assertEquals(resultBitSet.cardinality(), 3);
assertTrue(resultBitSet.get(vxId1));
assertFalse(resultBitSet.get(vxId2));
assertTrue(resultBitSet.get(vxId3));
assertTrue(resultBitSet.get(vxId4));
assertEquals(resultColour, ConstellationColor.LIGHT_BLUE);
}
use of au.gov.asd.tac.constellation.graph.locking.DualGraph in project constellation by constellation-app.
the class BlazeUtilitiesNGTest method testGetSelection.
/**
* Test of getSelection method, of class BlazeUtilities. Blazes on the graph
*/
@Test
public void testGetSelection() {
System.out.println("getSelection");
final Graph g = new DualGraph(schema, graph);
final Pair<BitSet, ConstellationColor> result = BlazeUtilities.getSelection(g, null);
final BitSet resultBitSet = result.getKey();
final ConstellationColor resultColour = result.getValue();
assertEquals(resultBitSet.cardinality(), 3);
assertTrue(resultBitSet.get(vxId1));
assertFalse(resultBitSet.get(vxId2));
assertTrue(resultBitSet.get(vxId3));
assertTrue(resultBitSet.get(vxId4));
assertEquals(resultColour, ConstellationColor.BLUE);
}
Aggregations