Search in sources :

Example 16 with MultiChoiceParameterValue

use of au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue in project constellation by constellation-app.

the class CompleteGraphBuilderPlugin 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 17 with MultiChoiceParameterValue

use of au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue in project constellation by constellation-app.

the class CompleteGraphBuilderPlugin method createParameters.

@Override
public PluginParameters createParameters() {
    final PluginParameters params = new PluginParameters();
    final PluginParameter<IntegerParameterValue> n = IntegerParameterType.build(N_PARAMETER_ID);
    n.setName("Number of nodes");
    n.setDescription("The number of nodes on the graph");
    n.setIntegerValue(5);
    IntegerParameterType.setMinimum(n, 0);
    params.addParameter(n);
    final PluginParameter<BooleanParameterValue> randomWeights = BooleanParameterType.build(RANDOM_WEIGHTS_PARAMETER_ID);
    randomWeights.setName("Random edge weight/direction");
    randomWeights.setDescription("Edges have a random number of transactions going in random directions");
    randomWeights.setBooleanValue(true);
    params.addParameter(randomWeights);
    final PluginParameter<MultiChoiceParameterValue> nodeTypes = MultiChoiceParameterType.build(NODE_TYPES_PARAMETER_ID);
    nodeTypes.setName("Node Types");
    nodeTypes.setDescription("Node types to add to the graph");
    params.addParameter(nodeTypes);
    final PluginParameter<MultiChoiceParameterValue> transactionTypes = MultiChoiceParameterType.build(TRANSACTION_TYPES_PARAMETER_ID);
    transactionTypes.setName("Transaction Types");
    transactionTypes.setDescription("Transaction types to add to the graph");
    params.addParameter(transactionTypes);
    return params;
}
Also used : BooleanParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType.BooleanParameterValue) IntegerParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.IntegerParameterType.IntegerParameterValue) MultiChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)

Example 18 with MultiChoiceParameterValue

use of au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue in project constellation by constellation-app.

the class PreferentialAttachmentGraphBuilderPluginNGTest method testUpdateParameters.

/**
 * Test of updateParameters method, of class PreferentialAttachmentGraphBuilderPlugin.
 */
@Test
public void testUpdateParameters() {
    System.out.println("updateParameters");
    final PreferentialAttachmentGraphBuilderPlugin instance = new PreferentialAttachmentGraphBuilderPlugin();
    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 19 with MultiChoiceParameterValue

use of au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue in project constellation by constellation-app.

the class PreferentialAttachmentGraphBuilderPluginNGTest method testUpdateParametersNullGraph.

/**
 * Test of updateParameters method, of class PreferentialAttachmentGraphBuilderPlugin. Null graph
 */
@Test
public void testUpdateParametersNullGraph() {
    System.out.println("updateParametersNullGraph");
    final PreferentialAttachmentGraphBuilderPlugin instance = new PreferentialAttachmentGraphBuilderPlugin();
    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(null, params);
    assertTrue(MultiChoiceParameterType.getOptions(nAttribute).isEmpty());
    assertTrue(MultiChoiceParameterType.getOptions(tAttribute).isEmpty());
}
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) Test(org.testng.annotations.Test)

Example 20 with MultiChoiceParameterValue

use of au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue in project constellation by constellation-app.

the class SmallWorldGraphBuilderPluginNGTest method testUpdateParametersNullGraph.

/**
 * Test of updateParameters method, of class SmallWorldGraphBuilderPlugin. Null graph
 */
@Test
public void testUpdateParametersNullGraph() {
    System.out.println("updateParametersNullGraph");
    final SmallWorldGraphBuilderPlugin instance = new SmallWorldGraphBuilderPlugin();
    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(null, params);
    assertTrue(MultiChoiceParameterType.getOptions(nAttribute).isEmpty());
    assertTrue(MultiChoiceParameterType.getOptions(tAttribute).isEmpty());
}
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) Test(org.testng.annotations.Test)

Aggregations

MultiChoiceParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue)34 PluginParameter (au.gov.asd.tac.constellation.plugins.parameters.PluginParameter)25 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)19 ArrayList (java.util.ArrayList)16 Test (org.testng.annotations.Test)12 SchemaTransactionType (au.gov.asd.tac.constellation.graph.schema.type.SchemaTransactionType)9 StoreGraph (au.gov.asd.tac.constellation.graph.StoreGraph)8 PluginInteraction (au.gov.asd.tac.constellation.plugins.PluginInteraction)7 SingleChoiceParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue)6 TextPluginInteraction (au.gov.asd.tac.constellation.plugins.text.TextPluginInteraction)6 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)5 BooleanParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType.BooleanParameterValue)5 IntegerParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.IntegerParameterType.IntegerParameterValue)5 SchemaVertexType (au.gov.asd.tac.constellation.graph.schema.type.SchemaVertexType)4 ParameterChange (au.gov.asd.tac.constellation.plugins.parameters.ParameterChange)4 ParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.ParameterValue)4 HashSet (java.util.HashSet)4 Map (java.util.Map)4 Graph (au.gov.asd.tac.constellation.graph.Graph)3 DualGraph (au.gov.asd.tac.constellation.graph.locking.DualGraph)3