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);
}
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);
}
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);
}
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);
}
});
}
}
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);
}
}
Aggregations