Search in sources :

Example 1 with PluginExecutor

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

the class RecordStoreQueryPlugin method edit.

@Override
protected void edit(final GraphWriteMethods wg, final PluginInteraction interaction, final PluginParameters parameters) throws InterruptedException, PluginException {
    for (final RecordStoreValidator validator : getValidators()) {
        validator.validatePreEdit(this, result, wg, interaction, parameters);
    }
    if (result != null) {
        // TODO: try to see if its worth setting this to init with schema to true - it did cause issues with it sometimes generating vertex # nodes
        final List<Integer> newVertices = GraphRecordStoreUtilities.addRecordStoreToGraph(wg, result, false, true, null);
        wg.validateKey(GraphElementType.VERTEX, true);
        wg.validateKey(GraphElementType.TRANSACTION, true);
        // Only arrange if there are new vertices, otherwise everything will be arranged.
        if (!newVertices.isEmpty()) {
            final PluginExecutor arrangement = completionArrangement();
            if (arrangement != null) {
                final float[] xOriginal = new float[wg.getVertexCount()];
                final float[] yOriginal = new float[wg.getVertexCount()];
                final float[] zOriginal = new float[wg.getVertexCount()];
                // save original positions
                if (wg.isRecordingEdit()) {
                    saveOriginalPositionCoordinates(wg, xOriginal, yOriginal, zOriginal);
                }
                // run the arrangement
                final VertexListInclusionGraph vlGraph = new VertexListInclusionGraph(wg, Connections.NONE, newVertices);
                arrangement.executeNow(vlGraph.getInclusionGraph());
                vlGraph.retrieveCoords();
                // restore the original positions
                if (wg.isRecordingEdit()) {
                    restoreOriginalPositionCoordinates(wg, xOriginal, yOriginal, zOriginal);
                }
            }
        }
        // Reset the view
        PluginExecutor.startWith(InteractiveGraphPluginRegistry.RESET_VIEW).executeNow(wg);
    }
}
Also used : PluginExecutor(au.gov.asd.tac.constellation.plugins.PluginExecutor) VertexListInclusionGraph(au.gov.asd.tac.constellation.plugins.arrangements.VertexListInclusionGraph)

Example 2 with PluginExecutor

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

the class AddRecordStore method addToGraph.

private static void addToGraph(final Graph graph, final RecordStore recordStore, final boolean completeWithSchema, final String arrange, final boolean resetView) {
    final Plugin p = new ImportFromRestApiPlugin(recordStore, completeWithSchema, arrange);
    PluginExecutor pe = PluginExecutor.startWith(p);
    if (resetView) {
        pe = pe.followedBy(InteractiveGraphPluginRegistry.RESET_VIEW);
    }
    try {
        pe.executeNow(graph);
    } catch (final InterruptedException ex) {
        Thread.currentThread().interrupt();
        throw new RestServiceException(ex);
    } catch (final PluginException ex) {
        throw new RestServiceException(ex);
    }
}
Also used : RestServiceException(au.gov.asd.tac.constellation.webserver.restapi.RestServiceException) PluginExecutor(au.gov.asd.tac.constellation.plugins.PluginExecutor) PluginException(au.gov.asd.tac.constellation.plugins.PluginException) SimpleEditPlugin(au.gov.asd.tac.constellation.plugins.templates.SimpleEditPlugin) Plugin(au.gov.asd.tac.constellation.plugins.Plugin)

Example 3 with PluginExecutor

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

the class PluginSequenceEditOperation method performEdit.

@Override
public void performEdit(final Object value) {
    PluginExecutor executor = preEdit == null ? PluginExecutor.startWith(mainEdit(value)) : PluginExecutor.startWith(preEdit).followedBy(mainEdit(value));
    if (postEdit != null) {
        executor = executor.followedBy(postEdit);
    }
    executor.executeWriteLater(GraphManager.getDefault().getActiveGraph());
}
Also used : PluginExecutor(au.gov.asd.tac.constellation.plugins.PluginExecutor)

Example 4 with PluginExecutor

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

Aggregations

PluginExecutor (au.gov.asd.tac.constellation.plugins.PluginExecutor)4 Plugin (au.gov.asd.tac.constellation.plugins.Plugin)2 PluginException (au.gov.asd.tac.constellation.plugins.PluginException)2 VertexListInclusionGraph (au.gov.asd.tac.constellation.plugins.arrangements.VertexListInclusionGraph)2 SimpleEditPlugin (au.gov.asd.tac.constellation.plugins.templates.SimpleEditPlugin)2 Graph (au.gov.asd.tac.constellation.graph.Graph)1 GraphElementType (au.gov.asd.tac.constellation.graph.GraphElementType)1 GraphWriteMethods (au.gov.asd.tac.constellation.graph.GraphWriteMethods)1 InteractiveGraphPluginRegistry (au.gov.asd.tac.constellation.graph.interaction.InteractiveGraphPluginRegistry)1 AnalyticConcept (au.gov.asd.tac.constellation.graph.schema.analytic.concept.AnalyticConcept)1 SchemaTransactionType (au.gov.asd.tac.constellation.graph.schema.type.SchemaTransactionType)1 SchemaTransactionTypeUtilities (au.gov.asd.tac.constellation.graph.schema.type.SchemaTransactionTypeUtilities)1 VisualSchemaPluginRegistry (au.gov.asd.tac.constellation.graph.schema.visual.VisualSchemaPluginRegistry)1 VisualConcept (au.gov.asd.tac.constellation.graph.schema.visual.concept.VisualConcept)1 PluginExecution (au.gov.asd.tac.constellation.plugins.PluginExecution)1 PluginInfo (au.gov.asd.tac.constellation.plugins.PluginInfo)1 PluginInteraction (au.gov.asd.tac.constellation.plugins.PluginInteraction)1 PluginType (au.gov.asd.tac.constellation.plugins.PluginType)1 AbstractInclusionGraph (au.gov.asd.tac.constellation.plugins.arrangements.AbstractInclusionGraph)1 ArrangementPluginRegistry (au.gov.asd.tac.constellation.plugins.arrangements.ArrangementPluginRegistry)1