Search in sources :

Example 31 with DualGraph

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);
}
Also used : MultiChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter) DualGraph(au.gov.asd.tac.constellation.graph.locking.DualGraph) Test(org.testng.annotations.Test)

Example 32 with DualGraph

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);
}
Also used : Schema(au.gov.asd.tac.constellation.graph.schema.Schema) DualGraph(au.gov.asd.tac.constellation.graph.locking.DualGraph) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 33 with DualGraph

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);
}
Also used : SchemaFactory(au.gov.asd.tac.constellation.graph.schema.SchemaFactory) RestServiceException(au.gov.asd.tac.constellation.webserver.restapi.RestServiceException) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph) Graph(au.gov.asd.tac.constellation.graph.Graph) DualGraph(au.gov.asd.tac.constellation.graph.locking.DualGraph) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Schema(au.gov.asd.tac.constellation.graph.schema.Schema) DualGraph(au.gov.asd.tac.constellation.graph.locking.DualGraph) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph)

Example 34 with DualGraph

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);
}
Also used : ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) Graph(au.gov.asd.tac.constellation.graph.Graph) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph) DualGraph(au.gov.asd.tac.constellation.graph.locking.DualGraph) BitSet(java.util.BitSet) DualGraph(au.gov.asd.tac.constellation.graph.locking.DualGraph) Test(org.testng.annotations.Test)

Example 35 with DualGraph

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);
}
Also used : ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) Graph(au.gov.asd.tac.constellation.graph.Graph) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph) DualGraph(au.gov.asd.tac.constellation.graph.locking.DualGraph) BitSet(java.util.BitSet) DualGraph(au.gov.asd.tac.constellation.graph.locking.DualGraph) Test(org.testng.annotations.Test)

Aggregations

DualGraph (au.gov.asd.tac.constellation.graph.locking.DualGraph)66 WritableGraph (au.gov.asd.tac.constellation.graph.WritableGraph)41 Test (org.testng.annotations.Test)30 StoreGraph (au.gov.asd.tac.constellation.graph.StoreGraph)21 Graph (au.gov.asd.tac.constellation.graph.Graph)19 Schema (au.gov.asd.tac.constellation.graph.schema.Schema)18 ArrayList (java.util.ArrayList)13 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)10 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)10 BeforeMethod (org.testng.annotations.BeforeMethod)9 PluginException (au.gov.asd.tac.constellation.plugins.PluginException)7 GraphRecordStore (au.gov.asd.tac.constellation.graph.processing.GraphRecordStore)6 PluginParameter (au.gov.asd.tac.constellation.plugins.parameters.PluginParameter)5 ConstellationColor (au.gov.asd.tac.constellation.utilities.color.ConstellationColor)4 GraphElementType (au.gov.asd.tac.constellation.graph.GraphElementType)3 GraphWriteMethods (au.gov.asd.tac.constellation.graph.GraphWriteMethods)3 SchemaFactory (au.gov.asd.tac.constellation.graph.schema.SchemaFactory)3 VisualConcept (au.gov.asd.tac.constellation.graph.schema.visual.concept.VisualConcept)3 PluginInteraction (au.gov.asd.tac.constellation.plugins.PluginInteraction)3 MultiChoiceParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue)3