Search in sources :

Example 21 with RecordStore

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

the class TSVDropperNGTest method testTSVDropperToGraphPlugin.

@Test
public void testTSVDropperToGraphPlugin() 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 File file = new File(TSVDropperNGTest.class.getResource("./resources/sample.tsv").getFile());
    final List<File> files = new ArrayList<>();
    files.add(file);
    final TSVDropperToGraphPlugin plugin = new TSVDropperToGraphPlugin(recordStore, files);
    final RecordStore expResult = plugin.query(recordStore, interaction, parameters);
    assertEquals(recordStore, expResult);
}
Also used : 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) ArrayList(java.util.ArrayList) GraphRecordStore(au.gov.asd.tac.constellation.graph.processing.GraphRecordStore) TSVDropperToGraphPlugin(au.gov.asd.tac.constellation.views.dataaccess.templates.TSVDropper.TSVDropperToGraphPlugin) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) File(java.io.File) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph) Test(org.testng.annotations.Test)

Example 22 with RecordStore

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

the class QueryNameValidatorNGTest method testValidatePreQueryWhenBlank.

/**
 * Test of validatePreQuery method, of class QueryNameValidator.
 */
@Test(expectedExceptions = PluginException.class)
public void testValidatePreQueryWhenBlank() throws Exception {
    System.out.println("testValidatePreQueryWhenBlank");
    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("");
    instance.validatePreQuery(plugin, recordStore, interaction, parameters);
}
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 23 with RecordStore

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

the class RecordStoreDropperNGTest method getRecordStoreAsStream.

private InputStream getRecordStoreAsStream() throws IOException {
    final RecordStore recordStore = new GraphRecordStore();
    recordStore.add();
    recordStore.set(GraphRecordStoreUtilities.SOURCE + VisualConcept.VertexAttribute.IDENTIFIER, "foo");
    recordStore.set(GraphRecordStoreUtilities.DESTINATION + VisualConcept.VertexAttribute.IDENTIFIER, "bar");
    final String RecordStoreAsJson = RecordStoreUtilities.toJson(recordStore);
    return new ByteArrayInputStream(("RecordStore=" + RecordStoreAsJson).getBytes());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) 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)

Example 24 with RecordStore

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

the class GraphCopyUtilities method copySelectedGraphElementsToClipboard.

/**
 * Copies the selected graph nodes and transactions, placing them on the
 * CONSTELLATION specific clipboard.
 *
 * @param rg The graph to copy elements from.
 * @return An array of length two containing a BitSet of the copied vertex
 * ids, followed by the copied transaction ids.
 */
public static BitSet[] copySelectedGraphElementsToClipboard(final GraphReadMethods rg) {
    // Copy the selected elements of the graph.
    final BitSet transactionEndPoints = new BitSet();
    final RecordStore copy = GraphRecordStoreUtilities.copySelectedTransactions(rg, null, transactionEndPoints);
    GraphRecordStoreUtilities.copySelectedVertices(rg, copy, transactionEndPoints);
    // Put the copy on the clipboard.
    final Transferable transferable = new RecordStoreTransferable(copy);
    final Clipboard cb = ConstellationClipboardOwner.getConstellationClipboard();
    cb.setContents(transferable, ConstellationClipboardOwner.getOwner());
    final GraphElementType nodes = GraphElementType.VERTEX;
    final int nodesCount = nodes.getElementCount(rg);
    final int nodeSelectedAttribute = rg.getAttribute(nodes, "selected");
    final GraphElementType transactions = GraphElementType.TRANSACTION;
    final int transactionsCount = transactions.getElementCount(rg);
    final int transactionSelectedAttribute = rg.getAttribute(transactions, "selected");
    final BitSet vxCopied = getVxCopied(nodesCount, nodeSelectedAttribute, nodes, rg);
    final BitSet txCopied = getSelectedTransactions(transactionsCount, transactionSelectedAttribute, transactions, rg);
    return new BitSet[] { vxCopied, txCopied };
}
Also used : RecordStore(au.gov.asd.tac.constellation.graph.processing.RecordStore) BitSet(java.util.BitSet) Transferable(java.awt.datatransfer.Transferable) Clipboard(java.awt.datatransfer.Clipboard) GraphElementType(au.gov.asd.tac.constellation.graph.GraphElementType)

Example 25 with RecordStore

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

the class PasteGraphPlugin method edit.

@Override
public void edit(final GraphWriteMethods wg, final PluginInteraction interaction, final PluginParameters parameters) throws InterruptedException, PluginException {
    final Object paramPaster = parameters.getParameters().get(RECORDSTORE_PARAMETER_ID).getObjectValue();
    if (!(paramPaster instanceof RecordStore)) {
        throw new IllegalArgumentException(Bundle.MSG_Param(RECORDSTORE_PARAMETER_ID));
    }
    final RecordStore paster = ((RecordStore) paramPaster);
    synchronized (paster) {
        GraphRecordStoreUtilities.addRecordStoreToGraph(wg, paster, false, false, null);
    }
    ConstellationLoggerHelper.createPropertyBuilder(this, paster.getAll(GraphRecordStoreUtilities.SOURCE + VisualConcept.VertexAttribute.LABEL), ConstellationLoggerHelper.SUCCESS);
}
Also used : RecordStore(au.gov.asd.tac.constellation.graph.processing.RecordStore)

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