use of au.gov.asd.tac.constellation.graph.StoreGraph in project constellation by constellation-app.
the class CommonNeighboursPluginNGTest method setUpMethod.
@BeforeMethod
public void setUpMethod() throws Exception {
// create an analytic graph
final Schema schema = SchemaFactoryUtilities.getSchemaFactory(AnalyticSchemaFactory.ANALYTIC_SCHEMA_ID).createSchema();
graph = new StoreGraph(schema);
// add attributes
transactionCNAttribute = SnaConcept.TransactionAttribute.COMMON_NEIGHBOURS.ensure(graph);
vertexSelectedAttribute = VisualConcept.VertexAttribute.SELECTED.ensure(graph);
// add vertices
vxId0 = graph.addVertex();
vxId1 = graph.addVertex();
vxId2 = graph.addVertex();
vxId3 = graph.addVertex();
vxId4 = graph.addVertex();
// add transactions
graph.addTransaction(vxId0, vxId1, true);
graph.addTransaction(vxId0, vxId2, true);
graph.addTransaction(vxId0, vxId3, true);
graph.addTransaction(vxId0, vxId4, true);
graph.addTransaction(vxId1, vxId2, true);
graph.addTransaction(vxId1, vxId3, true);
graph.addTransaction(vxId1, vxId4, true);
graph.addTransaction(vxId2, vxId3, true);
graph.addTransaction(vxId2, vxId4, true);
graph.addTransaction(vxId3, vxId4, true);
}
use of au.gov.asd.tac.constellation.graph.StoreGraph in project constellation by constellation-app.
the class CosineSimilarityPluginNGTest method setUpMethod.
@BeforeMethod
public void setUpMethod() throws Exception {
// create an analytic graph
final Schema schema = SchemaFactoryUtilities.getSchemaFactory(AnalyticSchemaFactory.ANALYTIC_SCHEMA_ID).createSchema();
graph = new StoreGraph(schema);
// add attributes
transactionCosineAttribute = SnaConcept.TransactionAttribute.COSINE_SIMILARITY.ensure(graph);
vertexSelectedAttribute = VisualConcept.VertexAttribute.SELECTED.ensure(graph);
transactionIdentifier = VisualConcept.TransactionAttribute.IDENTIFIER.ensure(graph);
// add vertices
vxId0 = graph.addVertex();
vxId1 = graph.addVertex();
vxId2 = graph.addVertex();
vxId3 = graph.addVertex();
vxId4 = graph.addVertex();
// add transactions
txId0 = graph.addTransaction(vxId0, vxId1, true);
txId1 = graph.addTransaction(vxId1, vxId2, true);
txId2 = graph.addTransaction(vxId1, vxId3, true);
txId3 = graph.addTransaction(vxId2, vxId3, true);
txId4 = graph.addTransaction(vxId3, vxId4, true);
}
use of au.gov.asd.tac.constellation.graph.StoreGraph in project constellation by constellation-app.
the class FactAnalyticPlugin method edit.
@Override
protected final void edit(final GraphWriteMethods graph, final PluginInteraction interaction, final PluginParameters parameters) throws InterruptedException, PluginException {
try {
// prepare the graph
prepareGraph(graph, parameters);
// ensure the required analytic attributes exists on the graph
getAnalyticAttributes(parameters).forEach(schemaAttribute -> schemaAttribute.ensure(graph));
// TRANSACTION_TYPES_PARAMETER always of type MultiChoiceParameter
@SuppressWarnings("unchecked") final PluginParameter<MultiChoiceParameterValue> transactionTypesParameter = (PluginParameter<MultiChoiceParameterValue>) parameters.getParameters().get(TRANSACTION_TYPES_PARAMETER_ID);
final List<ParameterValue> allTransactionTypes = MultiChoiceParameterType.getOptionsData(transactionTypesParameter);
final List<? extends ParameterValue> chosenTransactionTypes = MultiChoiceParameterType.getChoicesData(transactionTypesParameter);
if (chosenTransactionTypes.equals(allTransactionTypes)) {
// run analytic plugin on the entire graph and compute results
PluginExecution.withPlugin(getAnalyticPlugin().getDeclaredConstructor().newInstance()).withParameters(parameters).executeNow(graph);
computeResultsFromGraph(graph, parameters);
} else {
// create subgraph
final Set<SchemaTransactionType> transactionTypes = new HashSet<>();
chosenTransactionTypes.forEach(parameterValue -> transactionTypes.add((SchemaTransactionType) ((TransactionTypeParameterValue) parameterValue).getObjectValue()));
assert transactionTypes.size() > 0 : "You must select at least one transaction type";
final StoreGraph subgraph = getSubgraph(graph, SchemaFactoryUtilities.getDefaultSchemaFactory(), transactionTypes);
// run analytic plugin on the subgraph and compute results
PluginExecution.withPlugin(getAnalyticPlugin().getDeclaredConstructor().newInstance()).withParameters(parameters).executeNow(subgraph);
copySubgraphToGraph(graph, subgraph);
computeResultsFromGraph(graph, parameters);
}
} catch (final IllegalAccessException | IllegalArgumentException | InstantiationException | NoSuchMethodException | SecurityException | InvocationTargetException ex) {
LOGGER.log(Level.SEVERE, ex.getLocalizedMessage(), ex);
}
}
use of au.gov.asd.tac.constellation.graph.StoreGraph in project constellation by constellation-app.
the class PreferentialAttachmentPluginNGTest method setUpMethod.
@BeforeMethod
public void setUpMethod() throws Exception {
// create an analytic graph
final Schema schema = SchemaFactoryUtilities.getSchemaFactory(AnalyticSchemaFactory.ANALYTIC_SCHEMA_ID).createSchema();
graph = new StoreGraph(schema);
// add attributes
transactionPAAttribute = SnaConcept.TransactionAttribute.PREFERENTIAL_ATTACHMENT.ensure(graph);
vertexSelectedAttribute = VisualConcept.VertexAttribute.SELECTED.ensure(graph);
// add vertices
vxId0 = graph.addVertex();
vxId1 = graph.addVertex();
vxId2 = graph.addVertex();
vxId3 = graph.addVertex();
vxId4 = graph.addVertex();
// add transactions
graph.addTransaction(vxId0, vxId1, true);
graph.addTransaction(vxId0, vxId2, true);
graph.addTransaction(vxId0, vxId3, true);
graph.addTransaction(vxId0, vxId4, true);
graph.addTransaction(vxId1, vxId2, true);
graph.addTransaction(vxId1, vxId3, true);
graph.addTransaction(vxId1, vxId4, true);
graph.addTransaction(vxId2, vxId3, true);
graph.addTransaction(vxId2, vxId4, true);
graph.addTransaction(vxId3, vxId4, true);
}
use of au.gov.asd.tac.constellation.graph.StoreGraph in project constellation by constellation-app.
the class ResourceAllocationIndexPluginNGTest method setUpMethod.
@BeforeMethod
public void setUpMethod() throws Exception {
// create an analytic graph
final Schema schema = SchemaFactoryUtilities.getSchemaFactory(AnalyticSchemaFactory.ANALYTIC_SCHEMA_ID).createSchema();
graph = new StoreGraph(schema);
// add attributes
transactionRaiAttribute = SnaConcept.TransactionAttribute.RESOURCE_ALLOCATION_INDEX.ensure(graph);
vertexSelectedAttribute = VisualConcept.VertexAttribute.SELECTED.ensure(graph);
// add vertices
vxId0 = graph.addVertex();
vxId1 = graph.addVertex();
vxId2 = graph.addVertex();
vxId3 = graph.addVertex();
vxId4 = graph.addVertex();
// add transactions
graph.addTransaction(vxId0, vxId1, true);
graph.addTransaction(vxId0, vxId2, true);
graph.addTransaction(vxId0, vxId3, true);
graph.addTransaction(vxId0, vxId4, true);
graph.addTransaction(vxId1, vxId2, true);
graph.addTransaction(vxId1, vxId3, true);
graph.addTransaction(vxId1, vxId4, true);
graph.addTransaction(vxId2, vxId3, true);
graph.addTransaction(vxId2, vxId4, true);
graph.addTransaction(vxId3, vxId4, true);
}
Aggregations