Search in sources :

Example 36 with PluginParameter

use of au.gov.asd.tac.constellation.plugins.parameters.PluginParameter in project constellation by constellation-app.

the class StringParameterTypeNGTest method testSetLines.

/**
 * Test of setLines method, of class StringParameterType.
 */
@Test
public void testSetLines() {
    System.out.println("setLines");
    PluginParameter instance = StringParameterType.build("stringParameter");
    // check the expected result and result equal when postivie integers
    Integer expResult = 5;
    StringParameterType.setLines(instance, expResult);
    Integer result = StringParameterType.getLines(instance);
    assertEquals(instance.getProperty(StringParameterType.LINES), expResult);
    assertEquals(result, expResult);
    // check the expected result and result equal when 0
    expResult = 0;
    StringParameterType.setLines(instance, expResult);
    result = StringParameterType.getLines(instance);
    assertEquals(instance.getProperty(StringParameterType.LINES), expResult);
    assertEquals(result, expResult);
    // check the expected result and result equal when negative integers
    expResult = -1;
    StringParameterType.setLines(instance, expResult);
    result = StringParameterType.getLines(instance);
    assertEquals(instance.getProperty(StringParameterType.LINES), expResult);
    assertEquals(result, expResult);
}
Also used : PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter) Test(org.testng.annotations.Test)

Example 37 with PluginParameter

use of au.gov.asd.tac.constellation.plugins.parameters.PluginParameter in project constellation by constellation-app.

the class StringParameterTypeNGTest method testBuild_String.

/**
 * Test of build method, of class StringParameterType.
 */
@Test
public void testBuild_String() {
    System.out.println("build string");
    String id = "stringParameter";
    PluginParameter result = StringParameterType.build(id);
    StringParameterValue expResult = new StringParameterValue();
    System.out.println(expResult.toString());
    assertEquals(result.getId(), id);
    assertTrue(result.getType() instanceof StringParameterType);
    assertEquals(result.getParameterValue(), expResult);
}
Also used : PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter) Test(org.testng.annotations.Test)

Example 38 with PluginParameter

use of au.gov.asd.tac.constellation.plugins.parameters.PluginParameter in project constellation by constellation-app.

the class StringParameterTypeNGTest method testSetIsLabel.

/**
 * Test of setIsLabel method, of class StringParameterType.
 */
@Test
public void testSetIsLabel() {
    System.out.println("setIsLabel");
    PluginParameter instance = StringParameterType.build("stringParameter");
    // check if when set to true it reamains true
    boolean expResult = true;
    StringParameterType.setIsLabel(instance, expResult);
    boolean result = StringParameterType.isLabel(instance);
    assertEquals(instance.getProperty(StringParameterType.IS_LABEL), expResult);
    assertEquals(result, expResult);
    // check if when set to false it reamains false
    expResult = false;
    StringParameterType.setIsLabel(instance, expResult);
    result = StringParameterType.isLabel(instance);
    assertEquals(instance.getProperty(StringParameterType.IS_LABEL), expResult);
    assertEquals(result, expResult);
    // check if when set to false it doesn't think its true
    expResult = true;
    StringParameterType.setIsLabel(instance, false);
    result = StringParameterType.isLabel(instance);
    assertFalse(result);
    assertNotEquals(instance.getProperty(StringParameterType.IS_LABEL), expResult);
    assertNotEquals(result, expResult);
    // check if when set to true it doesn't think its false
    expResult = false;
    StringParameterType.setIsLabel(instance, true);
    result = StringParameterType.isLabel(instance);
    assertTrue(result);
    assertNotEquals(instance.getProperty(StringParameterType.IS_LABEL), expResult);
    assertNotEquals(result, expResult);
}
Also used : PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter) Test(org.testng.annotations.Test)

Example 39 with PluginParameter

use of au.gov.asd.tac.constellation.plugins.parameters.PluginParameter in project constellation by constellation-app.

the class PluginsNodeProvider method exportPluginsToCsv.

private static void exportPluginsToCsv(final Window window) {
    final DirectoryChooser directoryChooser = new DirectoryChooser();
    directoryChooser.setTitle("Select a location to save the CSV file");
    final File dir = directoryChooser.showDialog(window);
    if (dir != null) {
        final StringBuilder sb = new StringBuilder();
        // heading
        sb.append("Plugin class path").append(SeparatorConstants.COMMA).append("Plugin Alias").append(SeparatorConstants.COMMA).append("Parameter Name").append(SeparatorConstants.COMMA).append("Parameter Type").append(SeparatorConstants.COMMA).append("Parameter Label").append(SeparatorConstants.COMMA).append("Parameter Description").append(SeparatorConstants.COMMA).append("Parameter Default Value").append(SeparatorConstants.NEWLINE);
        // details
        PluginRegistry.getPluginClassNames().stream().forEach((final String pname) -> {
            final Plugin plugin = PluginRegistry.get(pname);
            final String name = plugin.getName();
            final Map<String, List<PluginParameter<?>>> params = new HashMap<>();
            try {
                final PluginParameters pp = plugin.createParameters();
                if (pp != null) {
                    final List<PluginParameter<?>> paramList = new ArrayList<>();
                    pp.getParameters().entrySet().stream().forEach(entry -> {
                        final PluginParameter<?> param = entry.getValue();
                        paramList.add(param);
                    });
                    Collections.sort(paramList, (a, b) -> a.getId().compareToIgnoreCase(b.getId()));
                    paramList.stream().forEach(p -> sb.append(plugin.getClass().getName()).append(SeparatorConstants.COMMA).append(PluginRegistry.getAlias(pname)).append(SeparatorConstants.COMMA).append(p.getId()).append(SeparatorConstants.COMMA).append(p.getType().getId()).append(SeparatorConstants.COMMA).append(p.getName()).append(SeparatorConstants.COMMA).append("\"").append(p.getDescription()).append("\"").append(SeparatorConstants.COMMA).append("\"").append(p.getStringValue()).append("\"").append(SeparatorConstants.NEWLINE));
                } else {
                    sb.append(plugin.getClass().getName()).append(SeparatorConstants.COMMA).append(PluginRegistry.getAlias(pname)).append(SeparatorConstants.COMMA).append(SeparatorConstants.NEWLINE);
                }
            } catch (final Exception ex) {
                LOGGER.log(Level.SEVERE, "plugin " + pname + " created an exception", ex);
            }
            final DateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd");
            final File file = new File(dir, String.format("Plugin Details - %s.csv", dateFormatter.format(new Date())));
            try (final FileOutputStream fileOutputStream = new FileOutputStream(file)) {
                fileOutputStream.write(sb.toString().getBytes(StandardCharsets.UTF_8.name()));
            } catch (IOException ex) {
                LOGGER.log(Level.SEVERE, "Error during export of plugin details to csv", ex);
            }
        });
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) IOException(java.io.IOException) IOException(java.io.IOException) Date(java.util.Date) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) FileOutputStream(java.io.FileOutputStream) List(java.util.List) ObservableList(javafx.collections.ObservableList) ArrayList(java.util.ArrayList) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter) File(java.io.File) SimpleDateFormat(java.text.SimpleDateFormat) DirectoryChooser(javafx.stage.DirectoryChooser) DataAccessPlugin(au.gov.asd.tac.constellation.views.dataaccess.plugins.DataAccessPlugin) Plugin(au.gov.asd.tac.constellation.plugins.Plugin)

Example 40 with PluginParameter

use of au.gov.asd.tac.constellation.plugins.parameters.PluginParameter 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)

Aggregations

PluginParameter (au.gov.asd.tac.constellation.plugins.parameters.PluginParameter)93 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)53 Test (org.testng.annotations.Test)52 ArrayList (java.util.ArrayList)36 MultiChoiceParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue)25 SingleChoiceParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue)21 Map (java.util.Map)16 PluginInteraction (au.gov.asd.tac.constellation.plugins.PluginInteraction)15 IntegerParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.IntegerParameterType.IntegerParameterValue)13 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)12 SchemaTransactionType (au.gov.asd.tac.constellation.graph.schema.type.SchemaTransactionType)11 ParameterChange (au.gov.asd.tac.constellation.plugins.parameters.ParameterChange)11 Graph (au.gov.asd.tac.constellation.graph.Graph)10 Plugin (au.gov.asd.tac.constellation.plugins.Plugin)10 BooleanParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType.BooleanParameterValue)10 HashMap (java.util.HashMap)10 PluginException (au.gov.asd.tac.constellation.plugins.PluginException)9 List (java.util.List)9 GraphWriteMethods (au.gov.asd.tac.constellation.graph.GraphWriteMethods)8 StringParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.StringParameterValue)8