Search in sources :

Example 6 with RecordStore

use of au.gov.asd.tac.constellation.graph.processing.RecordStore in project constellation by constellation-app.

the class QueryNameValidatorNGTest method testValidatePreQueryWhenNotBlank.

/**
 * Test of validatePreQuery method, of class QueryNameValidator.
 */
@Test
public void testValidatePreQueryWhenNotBlank() throws Exception {
    System.out.println("testValidatePreQueryWhenNotBlank");
    final RecordStoreQueryPlugin plugin = mock(RecordStoreQueryPlugin.class);
    final RecordStore recordStore = mock(RecordStore.class);
    final PluginInteraction interaction = mock(PluginInteraction.class);
    final PluginParameters parameters = mock(PluginParameters.class);
    final QueryNameValidator instance = new QueryNameValidator();
    when(parameters.getStringValue(CoreGlobalParameters.QUERY_NAME_PARAMETER_ID)).thenReturn("my query name");
    instance.validatePreQuery(plugin, recordStore, interaction, parameters);
    verify(parameters, times(1)).getStringValue(CoreGlobalParameters.QUERY_NAME_PARAMETER_ID);
}
Also used : PluginInteraction(au.gov.asd.tac.constellation.plugins.PluginInteraction) RecordStore(au.gov.asd.tac.constellation.graph.processing.RecordStore) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) Test(org.testng.annotations.Test)

Example 7 with RecordStore

use of au.gov.asd.tac.constellation.graph.processing.RecordStore in project constellation by constellation-app.

the class RecordStoreDropperNGTest method testRecordStoreDropperToGraphPlugin.

@Test
public void testRecordStoreDropperToGraphPlugin() throws InterruptedException, PluginException {
    final PluginInteraction interaction = mock(PluginInteraction.class);
    final PluginParameters parameters = mock(PluginParameters.class);
    final StoreGraph graph = new StoreGraph(new AnalyticSchemaFactory().createSchema());
    VisualConcept.VertexAttribute.X.ensure(graph);
    VisualConcept.VertexAttribute.Y.ensure(graph);
    VisualConcept.VertexAttribute.Z.ensure(graph);
    final RecordStore recordStore = new GraphRecordStore();
    recordStore.add();
    recordStore.set(GraphRecordStoreUtilities.SOURCE + VisualConcept.VertexAttribute.IDENTIFIER, "foo");
    recordStore.set(GraphRecordStoreUtilities.DESTINATION + VisualConcept.VertexAttribute.IDENTIFIER, "bar");
    final RecordStoreDropperToGraphPlugin plugin = new RecordStoreDropperToGraphPlugin(recordStore);
    final RecordStore expResult = plugin.query(recordStore, interaction, parameters);
    assertEquals(recordStore, expResult);
}
Also used : RecordStoreDropperToGraphPlugin(au.gov.asd.tac.constellation.views.dataaccess.templates.RecordStoreDropper.RecordStoreDropperToGraphPlugin) PluginInteraction(au.gov.asd.tac.constellation.plugins.PluginInteraction) AnalyticSchemaFactory(au.gov.asd.tac.constellation.graph.schema.analytic.AnalyticSchemaFactory) RecordStore(au.gov.asd.tac.constellation.graph.processing.RecordStore) GraphRecordStore(au.gov.asd.tac.constellation.graph.processing.GraphRecordStore) GraphRecordStore(au.gov.asd.tac.constellation.graph.processing.GraphRecordStore) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph) Test(org.testng.annotations.Test)

Example 8 with RecordStore

use of au.gov.asd.tac.constellation.graph.processing.RecordStore in project constellation by constellation-app.

the class RecordStoreQueryPluginNGTest method testGetResult.

/**
 * Test of getResult method, of class RecordStoreQueryPlugin.
 */
@Test
public void testGetResult() throws InterruptedException, PluginException {
    System.out.println("getResult");
    final RecordStoreQueryPlugin instance = new RecordStoreQueryPluginMockImpl();
    final GraphReadMethods graph = new StoreGraph();
    final PluginInteraction interaction = null;
    final PluginParameters parameters = null;
    instance.read(graph, interaction, parameters);
    instance.query(interaction, parameters);
    final RecordStore result = instance.getResult();
    assertEquals(result.size(), 2);
}
Also used : GraphReadMethods(au.gov.asd.tac.constellation.graph.GraphReadMethods) PluginInteraction(au.gov.asd.tac.constellation.plugins.PluginInteraction) RecordStore(au.gov.asd.tac.constellation.graph.processing.RecordStore) GraphRecordStore(au.gov.asd.tac.constellation.graph.processing.GraphRecordStore) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph) Test(org.testng.annotations.Test)

Example 9 with RecordStore

use of au.gov.asd.tac.constellation.graph.processing.RecordStore in project constellation by constellation-app.

the class VisualGraphTopComponent method init.

/**
 * Initialise the TopComponent state.
 */
private void init() {
    displayPanel.add(visualManager.getVisualComponent(), BorderLayout.CENTER);
    DropTargetAdapter dta = new DropTargetAdapter() {

        @Override
        public void dragEnter(DropTargetDragEvent dtde) {
            dtde.acceptDrag(DnDConstants.ACTION_COPY);
        }

        @Override
        public void drop(DropTargetDropEvent dtde) {
            final Transferable transferable = dtde.getTransferable();
            if (transferable.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
                try {
                    dtde.acceptDrop(DnDConstants.ACTION_COPY);
                    // files will be list of file which extends from object type
                    @SuppressWarnings("unchecked") final List<File> files = (List<File>) transferable.getTransferData(DataFlavor.javaFileListFlavor);
                    for (final File file : files) {
                        try (final InputStream in = StringUtils.endsWithIgnoreCase(file.getName(), FileExtensionConstants.GZIP) ? new GZIPInputStream(new FileInputStream(file)) : new FileInputStream(file)) {
                            final RecordStore recordStore = RecordStoreUtilities.fromTsv(in);
                            PluginExecution.withPlugin(new ImportRecordFile(recordStore)).executeLater(graph);
                        }
                    }
                } catch (final UnsupportedFlavorException | IOException ex) {
                    LOGGER.log(Level.SEVERE, ex.getLocalizedMessage(), ex);
                    dtde.rejectDrop();
                }
            } else {
                dtde.rejectDrop();
            }
        }
    };
    displayPanel.setDropTarget(new DropTarget(displayPanel, DnDConstants.ACTION_COPY, dta, true));
    content.add(getActionMap());
    savable = new MySavable();
    saveAs = new MySaveAs();
    content.add(saveAs);
    content.add(graphNode.getDataObject());
    content.add(graph);
    content.add(graphNode);
    associateLookup(new AbstractLookup(content));
    setActivatedNodes(new Node[] { graphNode });
    getActionMap().put("cut-to-clipboard", new CutToClipboardAction(graphNode));
    getActionMap().put("copy-to-clipboard", new CopyToClipboardAction(graphNode));
    getActionMap().put("paste-from-clipboard", new PasteFromClipboardAction(graphNode));
    // The actions below are per-graph.
    // NetBeans creates a single instance of an action and uses it globally, which doesn't do us any good,
    // because we want to have different toggle states on different graphs, for instance.
    // Therefore, we'll ignore NetBeans and create our own per-graph action instances.
    expandCompositesAction = new ExpandAllCompositesAction(graphNode);
    contractCompositesAction = new ContractAllCompositesAction(graphNode);
    drawNodesAction = new DrawNodesAction(graphNode);
    drawConnectionsAction = new DrawConnectionsAction(graphNode);
    drawNodeLabelsAction = new DrawNodeLabelsAction(graphNode);
    drawConnectionLabelsAction = new DrawConnectionLabelsAction(graphNode);
    drawBlazesAction = new DrawBlazesAction(graphNode);
    final ButtonGroup drawButtonGroup = new ButtonGroup();
    drawLinksAction = new DrawLinksAction(graphNode, drawButtonGroup);
    drawEdgesAction = new DrawEdgesAction(graphNode, drawButtonGroup);
    drawTransactionsAction = new DrawTransactionsAction(graphNode, drawButtonGroup);
    final ButtonGroup displayModeButtonGroup = new ButtonGroup();
    display3dAction = new Toggle3DAction(graphNode, displayModeButtonGroup);
    final ButtonGroup addModeButtonGroup = new ButtonGroup();
    toggleSelectModeAction = new ToggleSelectionModeAction(graphNode, addModeButtonGroup);
    final ButtonGroup directedModeButtonGroup = new ButtonGroup();
    toggleDrawDirectedAction = new ToggleDrawDirectedAction(graphNode, directedModeButtonGroup);
    toggleGraphVisibilityAction = new ToggleGraphVisibilityAction(graphNode);
    final JToolBar sidebar = new JToolBar(SwingConstants.VERTICAL);
    sidebar.setFloatable(false);
    sidebar.setRollover(true);
    sidebar.add(display3dAction.getToolbarPresenter());
    sidebar.addSeparator();
    sidebar.add(drawLinksAction.getToolbarPresenter());
    sidebar.add(drawEdgesAction.getToolbarPresenter());
    sidebar.add(drawTransactionsAction.getToolbarPresenter());
    sidebar.addSeparator();
    sidebar.add(drawNodesAction.getToolbarPresenter());
    sidebar.add(drawConnectionsAction.getToolbarPresenter());
    sidebar.add(drawNodeLabelsAction.getToolbarPresenter());
    sidebar.add(drawConnectionLabelsAction.getToolbarPresenter());
    sidebar.add(drawBlazesAction.getToolbarPresenter());
    sidebar.addSeparator();
    sidebar.add(toggleGraphVisibilityAction.getToolbarPresenter());
    sidebar.addSeparator();
    sidebar.add(expandCompositesAction.getToolbarPresenter());
    sidebar.add(contractCompositesAction.getToolbarPresenter());
    sidebar.addSeparator();
    sidebar.add(toggleSelectModeAction.getToolbarPresenter());
    sidebar.add(toggleDrawDirectedAction.getToolbarPresenter());
    // Add this so the side bar isn't too long.
    // Without this, the side bar has a height that extends past the icons and stops other TopComponents
    // from growing past it.
    sidebar.setMinimumSize(new Dimension(0, 0));
    // Set the modification counters to whatever they are now.
    // This causes any setup changes to be ignored.
    final ReadableGraph rg = graph.getReadableGraph();
    try {
        graphModificationCountBase = rg.getGlobalModificationCounter();
        graphModificationCount = graphModificationCountBase;
    } finally {
        rg.release();
    }
    // Initial update so that the sidebar actions are updated to match the graph.
    visualUpdate();
    this.add(sidebar, BorderLayout.WEST);
    // Listen to graph changes so we can update our modified flag. This will determine
    // whether or not we need to enable saving of the graph.
    graph.addGraphChangeListener(this);
    final InputMap keys = getInputMap(VisualGraphTopComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    final KeyStroke key = KeyStroke.getKeyStroke("Control W");
    final CloseAction ca = new CloseAction(graphNode);
    keys.put(key, ca);
    // Set the icon.
    final Schema schema = graph.getSchema();
    final Image image = getBufferedImageForSchema(schema, false);
    VisualGraphTopComponent.this.setIcon(getNebulaIcon(image));
    final UpdateComponent<GraphReadMethods> visualUpdateComponent = new UpdateComponent<GraphReadMethods>() {

        @Override
        protected boolean update(GraphReadMethods updateState) {
            visualUpdate();
            return true;
        }
    };
    visualUpdateComponent.dependOn(graphUpdateController.createAttributeUpdateComponent(VisualConcept.GraphAttribute.DRAW_FLAGS));
    visualUpdateComponent.dependOn(graphUpdateController.createAttributeUpdateComponent(VisualConcept.GraphAttribute.VISIBLE_ABOVE_THRESHOLD));
    visualUpdateComponent.dependOn(graphUpdateController.createAttributeUpdateComponent(VisualConcept.GraphAttribute.DISPLAY_MODE_3D));
    visualUpdateComponent.dependOn(graphUpdateController.createAttributeUpdateComponent(VisualConcept.GraphAttribute.DRAWING_MODE));
    visualUpdateComponent.dependOn(graphUpdateController.createAttributeUpdateComponent(VisualConcept.GraphAttribute.DRAW_DIRECTED_TRANSACTIONS));
    visualUpdateComponent.dependOn(graphUpdateController.createAttributeUpdateComponent(VisualConcept.GraphAttribute.CONNECTION_MODE));
    graphUpdateManager.setManaged(true);
}
Also used : ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) Schema(au.gov.asd.tac.constellation.graph.schema.Schema) DrawConnectionsAction(au.gov.asd.tac.constellation.graph.interaction.plugins.display.DrawConnectionsAction) PasteFromClipboardAction(au.gov.asd.tac.constellation.graph.interaction.plugins.clipboard.PasteFromClipboardAction) Image(java.awt.Image) BufferedImage(java.awt.image.BufferedImage) DrawTransactionsAction(au.gov.asd.tac.constellation.graph.interaction.plugins.display.DrawTransactionsAction) CutToClipboardAction(au.gov.asd.tac.constellation.graph.interaction.plugins.clipboard.CutToClipboardAction) ArrayList(java.util.ArrayList) List(java.util.List) DrawLinksAction(au.gov.asd.tac.constellation.graph.interaction.plugins.display.DrawLinksAction) ExpandAllCompositesAction(au.gov.asd.tac.constellation.graph.interaction.plugins.composite.ExpandAllCompositesAction) DrawNodesAction(au.gov.asd.tac.constellation.graph.interaction.plugins.display.DrawNodesAction) DropTargetDragEvent(java.awt.dnd.DropTargetDragEvent) AbstractLookup(org.openide.util.lookup.AbstractLookup) FileInputStream(java.io.FileInputStream) DropTargetAdapter(java.awt.dnd.DropTargetAdapter) RecordStore(au.gov.asd.tac.constellation.graph.processing.RecordStore) KeyStroke(javax.swing.KeyStroke) InputMap(javax.swing.InputMap) DropTarget(java.awt.dnd.DropTarget) DropTargetDropEvent(java.awt.dnd.DropTargetDropEvent) File(java.io.File) ContractAllCompositesAction(au.gov.asd.tac.constellation.graph.interaction.plugins.composite.ContractAllCompositesAction) CloseAction(au.gov.asd.tac.constellation.graph.interaction.plugins.io.CloseAction) DrawNodeLabelsAction(au.gov.asd.tac.constellation.graph.interaction.plugins.display.DrawNodeLabelsAction) GZIPInputStream(java.util.zip.GZIPInputStream) DrawEdgesAction(au.gov.asd.tac.constellation.graph.interaction.plugins.display.DrawEdgesAction) GraphReadMethods(au.gov.asd.tac.constellation.graph.GraphReadMethods) ToggleDrawDirectedAction(au.gov.asd.tac.constellation.graph.interaction.plugins.draw.ToggleDrawDirectedAction) DrawConnectionLabelsAction(au.gov.asd.tac.constellation.graph.interaction.plugins.display.DrawConnectionLabelsAction) Toggle3DAction(au.gov.asd.tac.constellation.graph.interaction.plugins.display.Toggle3DAction) ToggleGraphVisibilityAction(au.gov.asd.tac.constellation.graph.interaction.plugins.display.ToggleGraphVisibilityAction) ToggleSelectionModeAction(au.gov.asd.tac.constellation.graph.interaction.plugins.draw.ToggleSelectionModeAction) CopyToClipboardAction(au.gov.asd.tac.constellation.graph.interaction.plugins.clipboard.CopyToClipboardAction) GZIPInputStream(java.util.zip.GZIPInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Transferable(java.awt.datatransfer.Transferable) UpdateComponent(au.gov.asd.tac.constellation.plugins.update.UpdateComponent) IOException(java.io.IOException) JToolBar(javax.swing.JToolBar) Dimension(java.awt.Dimension) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException) ButtonGroup(javax.swing.ButtonGroup) DrawBlazesAction(au.gov.asd.tac.constellation.graph.interaction.plugins.display.DrawBlazesAction)

Example 10 with RecordStore

use of au.gov.asd.tac.constellation.graph.processing.RecordStore in project constellation by constellation-app.

the class PasteFromClipboardPlugin method edit.

@Override
protected void edit(final GraphWriteMethods wg, final PluginInteraction interaction, final PluginParameters parameters) throws InterruptedException, PluginException {
    try {
        final Clipboard cb = ConstellationClipboardOwner.getConstellationClipboard();
        if (cb.isDataFlavorAvailable(RecordStoreTransferable.RECORDSTORE_FLAVOR)) {
            final RecordStoreTransferable rt = (RecordStoreTransferable) cb.getContents(null);
            final RecordStore cbRecordStore = (RecordStore) rt.getTransferData(RecordStoreTransferable.RECORDSTORE_FLAVOR);
            if (cbRecordStore != null) {
                // There is a graph on the local clipboard.
                PluginExecution.withPlugin(InteractiveGraphPluginRegistry.PASTE_GRAPH).withParameter(PasteGraphPlugin.RECORDSTORE_PARAMETER_ID, cbRecordStore).executeNow(wg);
            }
        }
    } catch (final UnsupportedFlavorException | IOException ex) {
        LOGGER.log(Level.SEVERE, ex.getLocalizedMessage(), ex);
    }
}
Also used : RecordStore(au.gov.asd.tac.constellation.graph.processing.RecordStore) Clipboard(java.awt.datatransfer.Clipboard) IOException(java.io.IOException) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException)

Aggregations

RecordStore (au.gov.asd.tac.constellation.graph.processing.RecordStore)29 GraphRecordStore (au.gov.asd.tac.constellation.graph.processing.GraphRecordStore)20 Test (org.testng.annotations.Test)13 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)10 PluginInteraction (au.gov.asd.tac.constellation.plugins.PluginInteraction)9 ArrayList (java.util.ArrayList)9 HashMap (java.util.HashMap)6 File (java.io.File)4 StoreGraph (au.gov.asd.tac.constellation.graph.StoreGraph)3 PluginException (au.gov.asd.tac.constellation.plugins.PluginException)3 UnsupportedFlavorException (java.awt.datatransfer.UnsupportedFlavorException)3 IOException (java.io.IOException)3 Graph (au.gov.asd.tac.constellation.graph.Graph)2 GraphAttribute (au.gov.asd.tac.constellation.graph.GraphAttribute)2 GraphReadMethods (au.gov.asd.tac.constellation.graph.GraphReadMethods)2 AnalyticSchemaFactory (au.gov.asd.tac.constellation.graph.schema.analytic.AnalyticSchemaFactory)2 CompositeNodeState (au.gov.asd.tac.constellation.graph.schema.analytic.attribute.objects.CompositeNodeState)2 ExpandedCompositeNodeState (au.gov.asd.tac.constellation.graph.schema.analytic.attribute.objects.ExpandedCompositeNodeState)2 SchemaTransactionType (au.gov.asd.tac.constellation.graph.schema.type.SchemaTransactionType)2 DateTimeRange (au.gov.asd.tac.constellation.plugins.parameters.types.DateTimeRange)2