Search in sources :

Example 6 with ParameterValue

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

the class ExportToShapefilePlugin method exportGeo.

@Override
protected void exportGeo(final PluginParameters parameters, final String uuid, final Map<String, String> shapes, final Map<String, Map<String, Object>> attributes, final File output) throws IOException {
    final ParameterValue geometryTypePV = parameters.getSingleChoice(GEOMETRY_TYPE_PARAMETER_ID);
    assert (geometryTypePV instanceof GeometryTypeParameterValue);
    final GeometryType geometryType = ((GeometryTypeParameterValue) geometryTypePV).getGeometryType();
    final ParameterValue spatialReferencePV = parameters.getSingleChoice(SPATIAL_REFERENCE_PARAMETER_ID);
    assert (spatialReferencePV instanceof SpatialReferenceParameterValue);
    final SpatialReference spatialReference = ((SpatialReferenceParameterValue) spatialReferencePV).getSpatialReference();
    Shape.generateShapefile(uuid, geometryType, shapes, attributes, output, spatialReference);
}
Also used : GeometryType(au.gov.asd.tac.constellation.utilities.geospatial.Shape.GeometryType) ParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.ParameterValue) SingleChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue) SpatialReference(au.gov.asd.tac.constellation.utilities.geospatial.Shape.SpatialReference)

Example 7 with ParameterValue

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

the class SplitNodesPlugin method edit.

@Override
public void edit(final GraphWriteMethods graph, final PluginInteraction interaction, final PluginParameters parameters) throws InterruptedException, PluginException {
    final Map<String, PluginParameter<?>> splitParameters = parameters.getParameters();
    final String character = splitParameters.get(SPLIT_PARAMETER_ID) != null && splitParameters.get(SPLIT_PARAMETER_ID).getStringValue() != null ? splitParameters.get(SPLIT_PARAMETER_ID).getStringValue() : "";
    final ParameterValue transactionTypeChoice = splitParameters.get(TRANSACTION_TYPE_PARAMETER_ID).getSingleChoice();
    final String linkType = transactionTypeChoice != null ? transactionTypeChoice.toString() : AnalyticConcept.TransactionType.CORRELATION.getName();
    final boolean allOccurrences = splitParameters.get(ALL_OCCURRENCES_PARAMETER_ID).getBooleanValue();
    final boolean splitIntoSameLevel = splitParameters.get(DUPLICATE_TRANSACTIONS_PARAMETER_ID).getBooleanValue();
    final int vertexSelectedAttributeId = VisualConcept.VertexAttribute.SELECTED.ensure(graph);
    final int vertexIdentifierAttributeId = VisualConcept.VertexAttribute.IDENTIFIER.ensure(graph);
    final List<Integer> newVertices = new ArrayList<>();
    final int graphVertexCount = graph.getVertexCount();
    for (int position = 0; position < graphVertexCount; position++) {
        final int currentVertexId = graph.getVertex(position);
        if (graph.getBooleanValue(vertexSelectedAttributeId, currentVertexId)) {
            final String identifier = graph.getStringValue(vertexIdentifierAttributeId, currentVertexId);
            if (identifier != null && identifier.contains(character) && identifier.indexOf(character) < identifier.length() - character.length()) {
                String leftNodeIdentifier = "";
                if (allOccurrences) {
                    final String[] substrings = Arrays.stream(identifier.split(character)).filter(value -> value != null && value.length() > 0).toArray(size -> new String[size]);
                    if (substrings.length <= 0) {
                        continue;
                    }
                    leftNodeIdentifier = substrings[0];
                    for (int i = 1; i < substrings.length; i++) {
                        newVertices.add(createNewNode(graph, position, substrings[i], linkType, splitIntoSameLevel));
                    }
                } else {
                    final int i = identifier.indexOf(character);
                    leftNodeIdentifier = identifier.substring(0, i);
                    if (StringUtils.isNotBlank(leftNodeIdentifier)) {
                        newVertices.add(createNewNode(graph, position, identifier.substring(i + 1), linkType, splitIntoSameLevel));
                    } else {
                        leftNodeIdentifier = identifier.substring(i + 1);
                    }
                }
                // Rename the selected node
                if (StringUtils.isNotBlank(leftNodeIdentifier)) {
                    graph.setStringValue(vertexIdentifierAttributeId, currentVertexId, leftNodeIdentifier);
                    newVertices.add(currentVertexId);
                }
            }
        }
    }
    if (!newVertices.isEmpty()) {
        // Reset the view
        graph.validateKey(GraphElementType.VERTEX, true);
        graph.validateKey(GraphElementType.TRANSACTION, true);
        final PluginExecutor arrangement = completionArrangement();
        if (arrangement != null) {
            // run the arrangement
            final VertexListInclusionGraph vlGraph = new VertexListInclusionGraph(graph, AbstractInclusionGraph.Connections.NONE, newVertices);
            arrangement.executeNow(vlGraph.getInclusionGraph());
            vlGraph.retrieveCoords();
        }
        if (splitParameters.get(COMPLETE_WITH_SCHEMA_OPTION_ID).getBooleanValue()) {
            PluginExecution.withPlugin(VisualSchemaPluginRegistry.COMPLETE_SCHEMA).executeNow(graph);
        }
        PluginExecutor.startWith(InteractiveGraphPluginRegistry.RESET_VIEW).executeNow(graph);
    }
}
Also used : GraphWriteMethods(au.gov.asd.tac.constellation.graph.GraphWriteMethods) SchemaTransactionType(au.gov.asd.tac.constellation.graph.schema.type.SchemaTransactionType) Arrays(java.util.Arrays) StringParameterType(au.gov.asd.tac.constellation.plugins.parameters.types.StringParameterType) SchemaTransactionTypeUtilities(au.gov.asd.tac.constellation.graph.schema.type.SchemaTransactionTypeUtilities) ParameterChange(au.gov.asd.tac.constellation.plugins.parameters.ParameterChange) SingleChoiceParameterType(au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType) SimpleEditPlugin(au.gov.asd.tac.constellation.plugins.templates.SimpleEditPlugin) PluginType(au.gov.asd.tac.constellation.plugins.PluginType) VisualConcept(au.gov.asd.tac.constellation.graph.schema.visual.concept.VisualConcept) StringUtils(org.apache.commons.lang3.StringUtils) ArrayList(java.util.ArrayList) Graph(au.gov.asd.tac.constellation.graph.Graph) ArrangementPluginRegistry(au.gov.asd.tac.constellation.plugins.arrangements.ArrangementPluginRegistry) DataAccessPlugin(au.gov.asd.tac.constellation.views.dataaccess.plugins.DataAccessPlugin) Plugin(au.gov.asd.tac.constellation.plugins.Plugin) PluginInteraction(au.gov.asd.tac.constellation.plugins.PluginInteraction) ServiceProviders(org.openide.util.lookup.ServiceProviders) PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter) Map(java.util.Map) ServiceProvider(org.openide.util.lookup.ServiceProvider) PluginExecutor(au.gov.asd.tac.constellation.plugins.PluginExecutor) PluginTags(au.gov.asd.tac.constellation.plugins.templates.PluginTags) StringParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.StringParameterValue) PluginExecution(au.gov.asd.tac.constellation.plugins.PluginExecution) AbstractInclusionGraph(au.gov.asd.tac.constellation.plugins.arrangements.AbstractInclusionGraph) VertexListInclusionGraph(au.gov.asd.tac.constellation.plugins.arrangements.VertexListInclusionGraph) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) InteractiveGraphPluginRegistry(au.gov.asd.tac.constellation.graph.interaction.InteractiveGraphPluginRegistry) GraphElementType(au.gov.asd.tac.constellation.graph.GraphElementType) BooleanParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType.BooleanParameterValue) ParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.ParameterValue) PluginException(au.gov.asd.tac.constellation.plugins.PluginException) BooleanParameterType(au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType) PluginInfo(au.gov.asd.tac.constellation.plugins.PluginInfo) List(java.util.List) AnalyticConcept(au.gov.asd.tac.constellation.graph.schema.analytic.concept.AnalyticConcept) VisualSchemaPluginRegistry(au.gov.asd.tac.constellation.graph.schema.visual.VisualSchemaPluginRegistry) DataAccessPluginCoreType(au.gov.asd.tac.constellation.views.dataaccess.plugins.DataAccessPluginCoreType) NbBundle(org.openide.util.NbBundle) SingleChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue) StringParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.StringParameterValue) BooleanParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType.BooleanParameterValue) ParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.ParameterValue) SingleChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue) ArrayList(java.util.ArrayList) PluginExecutor(au.gov.asd.tac.constellation.plugins.PluginExecutor) VertexListInclusionGraph(au.gov.asd.tac.constellation.plugins.arrangements.VertexListInclusionGraph) PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter)

Example 8 with ParameterValue

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

the class FilterPluginNGTest method testCreateCopy.

/**
 * Test of createCopy method, of class FilterTypeParameterValue.
 */
@Test
public void testCreateCopy() {
    System.out.println("createCopy");
    final FilterTypeParameterValue instance = new FilterTypeParameterValue(FilterType.REMOVE_FILTER);
    final ParameterValue expResult = new FilterTypeParameterValue(FilterType.REMOVE_FILTER);
    final ParameterValue result = instance.createCopy();
    assertEquals(result, expResult);
}
Also used : FilterTypeParameterValue(au.gov.asd.tac.constellation.views.dataaccess.templates.FilterPlugin.FilterTypeParameterValue) ParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.ParameterValue) FilterTypeParameterValue(au.gov.asd.tac.constellation.views.dataaccess.templates.FilterPlugin.FilterTypeParameterValue) Test(org.testng.annotations.Test)

Example 9 with ParameterValue

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

the class ManageTemplatesPlugin method createParameters.

@Override
public PluginParameters createParameters() {
    final PluginParameters params = new PluginParameters();
    final Preferences prefs = NbPreferences.forModule(ApplicationPreferenceKeys.class);
    final PluginParameter<SingleChoiceParameterValue> templateParam = SingleChoiceParameterType.build(TEMPLATE_NAME_PARAMETER_ID);
    templateParam.setName(TEMPLATE_NAME_PARAMETER_ID_NAME);
    templateParam.setDescription(TEMPLATE_NAME_PARAMETER_ID_DESCRIPTION);
    final List<String> templateNames = new ArrayList<>(NewSchemaGraphAction.getTemplateNames().keySet());
    SingleChoiceParameterType.setOptions(templateParam, templateNames);
    templateParam.setStringValue(templateNames.isEmpty() ? "" : templateNames.get(0));
    params.addParameter(templateParam);
    final PluginParameter<ParameterValue> deleteParam = ActionParameterType.build(DELETE_TEMPLATE_PARAMETER_ID);
    params.addGroup(ACTIONS_GROUP_NAME, new PluginParametersPane.HorizontalParameterGroupLayout(false));
    deleteParam.setName(null);
    deleteParam.setDescription(null);
    deleteParam.setStringValue(DELETE_TEMPLATE_PARAMETER_ID_NAME);
    params.addParameter(deleteParam, ACTIONS_GROUP_NAME);
    params.addController(DELETE_TEMPLATE_PARAMETER_ID, (master, parameters, change) -> {
        if (change == ParameterChange.NO_CHANGE) {
            // button pressed
            final String deleteTemplateName = parameters.get(TEMPLATE_NAME_PARAMETER_ID).getStringValue();
            if (StringUtils.isNotBlank(deleteTemplateName)) {
                templateNames.remove(deleteTemplateName);
                deletedTemplates.add(deleteTemplateName);
                SingleChoiceParameterType.setOptions(templateParam, templateNames);
                templateParam.setStringValue("");
                if (deleteTemplateName.equals(parameters.get(CURRENT_DEFAULT_PARAMETER_ID).getStringValue())) {
                    parameters.get(CURRENT_DEFAULT_PARAMETER_ID).setStringValue(NO_DEFAULT);
                }
            }
        }
    });
    final PluginParameter<ParameterValue> defaultParam = ActionParameterType.build(DEFAULT_TEMPLATE_PARAMETER_ID);
    defaultParam.setName(null);
    defaultParam.setDescription(null);
    defaultParam.setStringValue(DEFAULT_TEMPLATE_PARAMETER_ID_NAME);
    params.addParameter(defaultParam, ACTIONS_GROUP_NAME);
    params.addController(DEFAULT_TEMPLATE_PARAMETER_ID, (master, parameters, change) -> {
        if (change == ParameterChange.NO_CHANGE) {
            // button pressed
            final String chosenTemplate = parameters.get(TEMPLATE_NAME_PARAMETER_ID).getStringValue();
            if (StringUtils.isNotBlank(chosenTemplate)) {
                parameters.get(CURRENT_DEFAULT_PARAMETER_ID).setStringValue(chosenTemplate);
            }
        }
    });
    final PluginParameter<ParameterValue> clearParam = ActionParameterType.build(CLEAR_DEFAULT_PARAMETER_ID);
    clearParam.setName(null);
    clearParam.setDescription(null);
    clearParam.setStringValue(CLEAR_DEFAULT_PARAMETER_ID_NAME);
    params.addParameter(clearParam, ACTIONS_GROUP_NAME);
    params.addController(CLEAR_DEFAULT_PARAMETER_ID, (master, parameters, change) -> {
        if (change == ParameterChange.NO_CHANGE) {
            // button pressed
            parameters.get(CURRENT_DEFAULT_PARAMETER_ID).setStringValue(NO_DEFAULT);
        }
    });
    final PluginParameter<StringParameterValue> currentDefaultParam = StringParameterType.build(CURRENT_DEFAULT_PARAMETER_ID);
    currentDefaultParam.setName(CURRENT_DEFAULT_PARAMETER_ID_NAME);
    StringParameterType.setIsLabel(currentDefaultParam, true);
    final String currentDefault = prefs.get(ApplicationPreferenceKeys.DEFAULT_TEMPLATE, ApplicationPreferenceKeys.DEFAULT_TEMPLATE_DEFAULT);
    currentDefaultParam.setStringValue(Objects.equals(ApplicationPreferenceKeys.DEFAULT_TEMPLATE_DEFAULT, currentDefault) ? NO_DEFAULT : currentDefault);
    params.addParameter(currentDefaultParam);
    return params;
}
Also used : StringParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.StringParameterValue) ParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.ParameterValue) SingleChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue) ArrayList(java.util.ArrayList) StringParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.StringParameterValue) PluginParametersPane(au.gov.asd.tac.constellation.plugins.gui.PluginParametersPane) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) Preferences(java.util.prefs.Preferences) NbPreferences(org.openide.util.NbPreferences) SingleChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue)

Aggregations

ParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.ParameterValue)9 PluginParameter (au.gov.asd.tac.constellation.plugins.parameters.PluginParameter)5 SingleChoiceParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue)5 ArrayList (java.util.ArrayList)5 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)4 MultiChoiceParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue)4 GraphElementType (au.gov.asd.tac.constellation.graph.GraphElementType)3 SchemaTransactionType (au.gov.asd.tac.constellation.graph.schema.type.SchemaTransactionType)3 ParameterChange (au.gov.asd.tac.constellation.plugins.parameters.ParameterChange)3 BooleanParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType.BooleanParameterValue)3 Map (java.util.Map)3 Graph (au.gov.asd.tac.constellation.graph.Graph)2 VisualConcept (au.gov.asd.tac.constellation.graph.schema.visual.concept.VisualConcept)2 PluginException (au.gov.asd.tac.constellation.plugins.PluginException)2 PluginInteraction (au.gov.asd.tac.constellation.plugins.PluginInteraction)2 BooleanParameterType (au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType)2 FileParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.FileParameterType.FileParameterValue)2 StringParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.StringParameterValue)2 Shape (au.gov.asd.tac.constellation.utilities.geospatial.Shape)2 GeometryType (au.gov.asd.tac.constellation.utilities.geospatial.Shape.GeometryType)2