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