Search in sources :

Example 6 with SchemaConcept

use of au.gov.asd.tac.constellation.graph.schema.concept.SchemaConcept 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 7 with SchemaConcept

use of au.gov.asd.tac.constellation.graph.schema.concept.SchemaConcept 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)

Aggregations

SchemaConcept (au.gov.asd.tac.constellation.graph.schema.concept.SchemaConcept)7 SchemaFactory (au.gov.asd.tac.constellation.graph.schema.SchemaFactory)4 SchemaTransactionType (au.gov.asd.tac.constellation.graph.schema.type.SchemaTransactionType)4 SchemaVertexType (au.gov.asd.tac.constellation.graph.schema.type.SchemaVertexType)4 ArrayList (java.util.ArrayList)4 PluginParameter (au.gov.asd.tac.constellation.plugins.parameters.PluginParameter)3 MultiChoiceParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue)3 Label (javafx.scene.control.Label)3 Graph (au.gov.asd.tac.constellation.graph.Graph)2 GraphElementType (au.gov.asd.tac.constellation.graph.GraphElementType)2 SchemaAttribute (au.gov.asd.tac.constellation.graph.schema.attribute.SchemaAttribute)2 Insets (javafx.geometry.Insets)2 ImageView (javafx.scene.image.ImageView)2 HBox (javafx.scene.layout.HBox)2 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)1 GraphManager (au.gov.asd.tac.constellation.graph.manager.GraphManager)1 GraphManagerListener (au.gov.asd.tac.constellation.graph.manager.GraphManagerListener)1 GraphNode (au.gov.asd.tac.constellation.graph.node.GraphNode)1 Schema (au.gov.asd.tac.constellation.graph.schema.Schema)1 SchemaConceptUtilities (au.gov.asd.tac.constellation.graph.schema.concept.SchemaConceptUtilities)1