Search in sources :

Example 26 with SchemaTransactionType

use of au.gov.asd.tac.constellation.graph.schema.type.SchemaTransactionType in project constellation by constellation-app.

the class SmallWorldGraphBuilderPlugin method updateParameters.

@Override
public void updateParameters(final Graph graph, final PluginParameters parameters) {
    final List<String> nAttributes = new ArrayList<>();
    final List<String> tAttributes = new ArrayList<>();
    final List<String> nChoices = new ArrayList<>();
    final List<String> tChoices = new ArrayList<>();
    if (graph != null) {
        final Set<Class<? extends SchemaConcept>> concepts = graph.getSchema().getFactory().getRegisteredConcepts();
        final Collection<SchemaVertexType> nodeTypes = SchemaVertexTypeUtilities.getTypes(concepts);
        for (final SchemaVertexType type : nodeTypes) {
            nAttributes.add(type.getName());
        }
        nAttributes.sort(String::compareTo);
        final Collection<SchemaTransactionType> transactionTypes = SchemaTransactionTypeUtilities.getTypes(concepts);
        for (final SchemaTransactionType type : transactionTypes) {
            tAttributes.add(type.getName());
        }
        tAttributes.sort(String::compareTo);
        nChoices.add(nAttributes.get(0));
        tChoices.add(tAttributes.get(0));
    }
    if (parameters != null && parameters.getParameters() != null) {
        // NODE_TYPES_PARAMETER will always be of type MultiChoiceParameter
        @SuppressWarnings("unchecked") final PluginParameter<MultiChoiceParameterValue> nAttribute = (PluginParameter<MultiChoiceParameterValue>) parameters.getParameters().get(NODE_TYPES_PARAMETER_ID);
        // TRANSACTION_TYPES_PARAMETER will always be of type MultiChoiceParameter
        @SuppressWarnings("unchecked") final PluginParameter<MultiChoiceParameterValue> tAttribute = (PluginParameter<MultiChoiceParameterValue>) parameters.getParameters().get(TRANSACTION_TYPES_PARAMETER_ID);
        MultiChoiceParameterType.setOptions(nAttribute, nAttributes);
        MultiChoiceParameterType.setOptions(tAttribute, tAttributes);
        MultiChoiceParameterType.setChoices(nAttribute, nChoices);
        MultiChoiceParameterType.setChoices(tAttribute, tChoices);
    }
}
Also used : SchemaVertexType(au.gov.asd.tac.constellation.graph.schema.type.SchemaVertexType) MultiChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue) ArrayList(java.util.ArrayList) SchemaConcept(au.gov.asd.tac.constellation.graph.schema.concept.SchemaConcept) SchemaTransactionType(au.gov.asd.tac.constellation.graph.schema.type.SchemaTransactionType) PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter)

Example 27 with SchemaTransactionType

use of au.gov.asd.tac.constellation.graph.schema.type.SchemaTransactionType in project constellation by constellation-app.

the class PreferentialAttachmentGraphBuilderPlugin method updateParameters.

@Override
public void updateParameters(final Graph graph, final PluginParameters parameters) {
    final List<String> nAttributes = new ArrayList<>();
    final List<String> tAttributes = new ArrayList<>();
    final List<String> nChoices = new ArrayList<>();
    final List<String> tChoices = new ArrayList<>();
    if (graph != null) {
        final Set<Class<? extends SchemaConcept>> concepts = graph.getSchema().getFactory().getRegisteredConcepts();
        final Collection<SchemaVertexType> nodeTypes = SchemaVertexTypeUtilities.getTypes(concepts);
        for (final SchemaVertexType type : nodeTypes) {
            nAttributes.add(type.getName());
        }
        nAttributes.sort(String::compareTo);
        final Collection<SchemaTransactionType> transactionTypes = SchemaTransactionTypeUtilities.getTypes(concepts);
        for (final SchemaTransactionType type : transactionTypes) {
            tAttributes.add(type.getName());
        }
        tAttributes.sort(String::compareTo);
        nChoices.add(nAttributes.get(0));
        tChoices.add(tAttributes.get(0));
    }
    if (parameters != null && parameters.getParameters() != null) {
        // NODE_TYPES_PARAMETER will always be of type MultiChoiceParameter
        @SuppressWarnings("unchecked") final PluginParameter<MultiChoiceParameterValue> nAttribute = (PluginParameter<MultiChoiceParameterValue>) parameters.getParameters().get(NODE_TYPES_PARAMETER_ID);
        // TRANSACTION_TYPES_PARAMETER will always be of type MultiChoiceParameter
        @SuppressWarnings("unchecked") final PluginParameter<MultiChoiceParameterValue> tAttribute = (PluginParameter<MultiChoiceParameterValue>) parameters.getParameters().get(TRANSACTION_TYPES_PARAMETER_ID);
        MultiChoiceParameterType.setOptions(nAttribute, nAttributes);
        MultiChoiceParameterType.setOptions(tAttribute, tAttributes);
        MultiChoiceParameterType.setChoices(nAttribute, nChoices);
        MultiChoiceParameterType.setChoices(tAttribute, tChoices);
    }
}
Also used : SchemaVertexType(au.gov.asd.tac.constellation.graph.schema.type.SchemaVertexType) MultiChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue) ArrayList(java.util.ArrayList) SchemaConcept(au.gov.asd.tac.constellation.graph.schema.concept.SchemaConcept) SchemaTransactionType(au.gov.asd.tac.constellation.graph.schema.type.SchemaTransactionType) PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter)

Example 28 with SchemaTransactionType

use of au.gov.asd.tac.constellation.graph.schema.type.SchemaTransactionType in project constellation by constellation-app.

the class GraphRecordStoreUtilitiesNGTest method addedRecordStoreSupportsTypesWithOverriddenDirectionWithInitialiseAndCompleteWithSchema.

@Test
public void addedRecordStoreSupportsTypesWithOverriddenDirectionWithInitialiseAndCompleteWithSchema() {
    final RecordStore recordStore = new GraphRecordStore();
    recordStore.add();
    recordStore.set(GraphRecordStoreUtilities.SOURCE + VisualConcept.VertexAttribute.IDENTIFIER, "vx0");
    recordStore.set(GraphRecordStoreUtilities.DESTINATION + VisualConcept.VertexAttribute.IDENTIFIER, "vx1");
    recordStore.set(GraphRecordStoreUtilities.TRANSACTION + GraphRecordStoreUtilities.DIRECTED_KEY, false);
    // the communication type is directed
    recordStore.set(GraphRecordStoreUtilities.TRANSACTION + AnalyticConcept.TransactionAttribute.TYPE, AnalyticConcept.TransactionType.COMMUNICATION);
    final boolean initializeWithSchema = true;
    final boolean completeWithSchema = true;
    final List<String> vertexIdAttributes = new ArrayList<>();
    final Map<String, Integer> vertexMap = new HashMap<>();
    final Map<String, Integer> transactionMap = new HashMap<>();
    final List<Integer> veritices = GraphRecordStoreUtilities.addRecordStoreToGraph(graph, recordStore, initializeWithSchema, completeWithSchema, vertexIdAttributes, vertexMap, transactionMap);
    assertEquals(2, veritices.size());
    assertEquals(2, graph.getVertexCount());
    assertEquals(1, graph.getTransactionCount());
    // try {
    // SaveGraphUtilities.saveGraphToTemporaryDirectory(graph, "testAddedRecordStoreSupportsTypesWithOverriddenDirectionWithInitialiseAndCompleteWithSchema");
    // } catch (IOException ex) {
    // Assert.fail(ex.getLocalizedMessage());
    // }
    final int transactionTypeId = AnalyticConcept.TransactionAttribute.TYPE.get(graph);
    SchemaTransactionType type = (SchemaTransactionType) graph.getObjectValue(transactionTypeId, 0);
    Assert.assertFalse(type.isDirected());
}
Also used : SchemaTransactionType(au.gov.asd.tac.constellation.graph.schema.type.SchemaTransactionType) HashMap(java.util.HashMap) RecordStore(au.gov.asd.tac.constellation.graph.processing.RecordStore) GraphRecordStore(au.gov.asd.tac.constellation.graph.processing.GraphRecordStore) ArrayList(java.util.ArrayList) GraphRecordStore(au.gov.asd.tac.constellation.graph.processing.GraphRecordStore) Test(org.testng.annotations.Test)

Example 29 with SchemaTransactionType

use of au.gov.asd.tac.constellation.graph.schema.type.SchemaTransactionType in project constellation by constellation-app.

the class GraphRecordStoreUtilitiesNGTest method addedRecordStoreSupportsTypesWithOverriddenDirectionWithInitialiseSchema.

@Test
public void addedRecordStoreSupportsTypesWithOverriddenDirectionWithInitialiseSchema() {
    final RecordStore recordStore = new GraphRecordStore();
    recordStore.add();
    recordStore.set(GraphRecordStoreUtilities.SOURCE + VisualConcept.VertexAttribute.IDENTIFIER, "vx0");
    recordStore.set(GraphRecordStoreUtilities.DESTINATION + VisualConcept.VertexAttribute.IDENTIFIER, "vx1");
    recordStore.set(GraphRecordStoreUtilities.TRANSACTION + GraphRecordStoreUtilities.DIRECTED_KEY, false);
    // the communication type is directed
    recordStore.set(GraphRecordStoreUtilities.TRANSACTION + AnalyticConcept.TransactionAttribute.TYPE, AnalyticConcept.TransactionType.COMMUNICATION);
    final boolean initializeWithSchema = true;
    final boolean completeWithSchema = false;
    final List<String> vertexIdAttributes = new ArrayList<>();
    final Map<String, Integer> vertexMap = new HashMap<>();
    final Map<String, Integer> transactionMap = new HashMap<>();
    final List<Integer> veritices = GraphRecordStoreUtilities.addRecordStoreToGraph(graph, recordStore, initializeWithSchema, completeWithSchema, vertexIdAttributes, vertexMap, transactionMap);
    assertEquals(2, veritices.size());
    assertEquals(2, graph.getVertexCount());
    assertEquals(1, graph.getTransactionCount());
    // try {
    // SaveGraphUtilities.saveGraphToTemporaryDirectory(graph, "testAddedRecordStoreSupportsTypesWithOverriddenDirectionWithInitialiseSchema");
    // } catch (IOException ex) {
    // Assert.fail(ex.getLocalizedMessage());
    // }
    final int transactionTypeId = AnalyticConcept.TransactionAttribute.TYPE.get(graph);
    SchemaTransactionType type = (SchemaTransactionType) graph.getObjectValue(transactionTypeId, 0);
    Assert.assertFalse(type.isDirected());
}
Also used : SchemaTransactionType(au.gov.asd.tac.constellation.graph.schema.type.SchemaTransactionType) HashMap(java.util.HashMap) RecordStore(au.gov.asd.tac.constellation.graph.processing.RecordStore) GraphRecordStore(au.gov.asd.tac.constellation.graph.processing.GraphRecordStore) ArrayList(java.util.ArrayList) GraphRecordStore(au.gov.asd.tac.constellation.graph.processing.GraphRecordStore) Test(org.testng.annotations.Test)

Aggregations

SchemaTransactionType (au.gov.asd.tac.constellation.graph.schema.type.SchemaTransactionType)29 PluginParameter (au.gov.asd.tac.constellation.plugins.parameters.PluginParameter)11 ArrayList (java.util.ArrayList)11 MultiChoiceParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue)10 SchemaVertexType (au.gov.asd.tac.constellation.graph.schema.type.SchemaVertexType)8 HashMap (java.util.HashMap)8 HashSet (java.util.HashSet)7 StoreGraph (au.gov.asd.tac.constellation.graph.StoreGraph)5 SchemaConcept (au.gov.asd.tac.constellation.graph.schema.concept.SchemaConcept)4 Map (java.util.Map)4 RecordStore (au.gov.asd.tac.constellation.graph.processing.RecordStore)3 AnalyticConcept (au.gov.asd.tac.constellation.graph.schema.analytic.concept.AnalyticConcept)3 SchemaTransactionTypeUtilities (au.gov.asd.tac.constellation.graph.schema.type.SchemaTransactionTypeUtilities)3 SchemaVertexTypeUtilities (au.gov.asd.tac.constellation.graph.schema.type.SchemaVertexTypeUtilities)3 VisualConcept (au.gov.asd.tac.constellation.graph.schema.visual.concept.VisualConcept)3 SingleChoiceParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue)3 List (java.util.List)3 Graph (au.gov.asd.tac.constellation.graph.Graph)2 GraphWriteMethods (au.gov.asd.tac.constellation.graph.GraphWriteMethods)2 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)2