use of au.gov.asd.tac.constellation.graph.schema.Schema in project constellation by constellation-app.
the class HopFullNGTest method setUpMethod.
@BeforeMethod
public void setUpMethod() throws Exception {
final Schema ss = SchemaFactoryUtilities.getSchemaFactory(VisualSchemaFactory.VISUAL_SCHEMA_ID).createSchema();
graph = new StoreGraph(ss);
attrX = graph.addAttribute(GraphElementType.VERTEX, FloatAttributeDescription.ATTRIBUTE_NAME, "x", "x", 0.0, null);
if (attrX == Graph.NOT_FOUND) {
fail();
}
attrY = graph.addAttribute(GraphElementType.VERTEX, FloatAttributeDescription.ATTRIBUTE_NAME, "y", "y", 0.0, null);
if (attrY == Graph.NOT_FOUND) {
fail();
}
attrZ = graph.addAttribute(GraphElementType.VERTEX, FloatAttributeDescription.ATTRIBUTE_NAME, "z", "z", 0.0, null);
if (attrZ == Graph.NOT_FOUND) {
fail();
}
vAttrId = graph.addAttribute(GraphElementType.VERTEX, BooleanAttributeDescription.ATTRIBUTE_NAME, "selected", "selected", false, null);
if (vAttrId == Graph.NOT_FOUND) {
fail();
}
tAttrId = graph.addAttribute(GraphElementType.TRANSACTION, BooleanAttributeDescription.ATTRIBUTE_NAME, "selected", "selected", false, null);
if (tAttrId == Graph.NOT_FOUND) {
fail();
}
vxId1 = graph.addVertex();
graph.setFloatValue(attrX, vxId1, 1.0f);
graph.setFloatValue(attrY, vxId1, 1.0f);
graph.setBooleanValue(vAttrId, vxId1, false);
vxId2 = graph.addVertex();
graph.setFloatValue(attrX, vxId2, 5.0f);
graph.setFloatValue(attrY, vxId2, 1.0f);
graph.setBooleanValue(vAttrId, vxId2, false);
vxId3 = graph.addVertex();
graph.setFloatValue(attrX, vxId3, 1.0f);
graph.setFloatValue(attrY, vxId3, 5.0f);
graph.setBooleanValue(vAttrId, vxId3, false);
vxId4 = graph.addVertex();
graph.setFloatValue(attrX, vxId4, 5.0f);
graph.setFloatValue(attrY, vxId4, 5.0f);
graph.setBooleanValue(vAttrId, vxId4, false);
vxId5 = graph.addVertex();
graph.setFloatValue(attrX, vxId5, 10.0f);
graph.setFloatValue(attrY, vxId5, 10.0f);
graph.setBooleanValue(vAttrId, vxId5, false);
vxId6 = graph.addVertex();
graph.setFloatValue(attrX, vxId6, 15.0f);
graph.setFloatValue(attrY, vxId6, 15.0f);
graph.setBooleanValue(vAttrId, vxId6, false);
vxId7 = graph.addVertex();
graph.setFloatValue(attrX, vxId7, 100.0f);
graph.setFloatValue(attrY, vxId7, 100.0f);
graph.setBooleanValue(vAttrId, vxId7, false);
txId1 = graph.addTransaction(vxId1, vxId2, false);
txId2 = graph.addTransaction(vxId1, vxId3, false);
txId3 = graph.addTransaction(vxId2, vxId4, true);
txId4 = graph.addTransaction(vxId4, vxId2, true);
txId5 = graph.addTransaction(vxId5, vxId6, false);
}
use of au.gov.asd.tac.constellation.graph.schema.Schema in project constellation by constellation-app.
the class NewGraph method callService.
@Override
public void callService(final PluginParameters parameters, final InputStream in, final OutputStream out) throws IOException {
final String schemaParam = parameters.getStringValue(SCHEMA_PARAMETER_ID);
String schemaName = null;
for (final SchemaFactory schemaFactory : SchemaFactoryUtilities.getSchemaFactories().values()) {
if (schemaFactory.isPrimarySchema() && (schemaParam == null || schemaParam.equals(schemaFactory.getName()))) {
schemaName = schemaFactory.getName();
break;
}
}
if (schemaName == null) {
throw new RestServiceException(HTTP_UNPROCESSABLE_ENTITY, String.format("Unknown schema %s", schemaParam));
}
// Creating a new graph is asynchronous; we want to hide this from the client.
//
final Graph existingGraph = GraphManager.getDefault().getActiveGraph();
final String existingId = existingGraph != null ? existingGraph.getId() : null;
final Schema schema = SchemaFactoryUtilities.getSchemaFactory(schemaName).createSchema();
final StoreGraph sg = new StoreGraph(schema);
schema.newGraph(sg);
final Graph dualGraph = new DualGraph(sg, false);
final String graphName = SchemaFactoryUtilities.getSchemaFactory(schemaName).getLabel().trim().toLowerCase();
GraphOpener.getDefault().openGraph(dualGraph, graphName);
final String newId = RestServiceUtilities.waitForGraphChange(existingId);
final ObjectMapper mapper = new ObjectMapper();
final ObjectNode root = mapper.createObjectNode();
root.put("id", newId);
root.put("name", GraphNode.getGraphNode(newId).getDisplayName());
root.put("schema", schemaName);
mapper.writeValue(out, root);
}
use of au.gov.asd.tac.constellation.graph.schema.Schema in project constellation by constellation-app.
the class SphereGraphWelcomePlugin method run.
/**
* This method describes what action should be taken when the link is
* clicked on the Welcome Page
*/
@Override
public void run() {
final Schema schema = SchemaFactoryUtilities.getSchemaFactory(AnalyticSchemaFactory.ANALYTIC_SCHEMA_ID).createSchema();
final StoreGraph sg = new StoreGraph(schema);
schema.newGraph(sg);
final Graph dualGraph = new DualGraph(sg, false);
final Future<?> f = PluginExecutor.startWith(CoreTestingPluginRegistry.SPHERE_GRAPH_BUILDER).set(SphereGraphBuilderPlugin.ADD_CHARS_PARAMETER_ID, true).set(SphereGraphBuilderPlugin.DRAW_MANY_DECORATORS_PARAMETER_ID, true).set(SphereGraphBuilderPlugin.DRAW_MANY_TX_PARAMETER_ID, true).set(SphereGraphBuilderPlugin.N_PARAMETER_ID, 100).set(SphereGraphBuilderPlugin.OPTION_PARAMETER_ID, "Random vertices").set(SphereGraphBuilderPlugin.T_PARAMETER_ID, 50).set(SphereGraphBuilderPlugin.USE_ALL_DISPLAYABLE_CHARS_PARAMETER_ID, true).set(SphereGraphBuilderPlugin.USE_LABELS_PARAMETER_ID, true).set(SphereGraphBuilderPlugin.USE_RANDOM_ICONS_PARAMETER_ID, true).executeWriteLater(dualGraph);
try {
// ensure sphere graph has finished before opening the graph
f.get();
final String graphName = SchemaFactoryUtilities.getSchemaFactory(AnalyticSchemaFactory.ANALYTIC_SCHEMA_ID).getLabel().trim().toLowerCase();
GraphOpener.getDefault().openGraph(dualGraph, graphName);
} catch (final InterruptedException ex) {
Thread.currentThread().interrupt();
LOGGER.log(Level.SEVERE, "Sphere graph creation was interrupted", ex);
} catch (final ExecutionException ex) {
LOGGER.log(Level.SEVERE, ex.getLocalizedMessage(), ex);
}
}
use of au.gov.asd.tac.constellation.graph.schema.Schema in project constellation by constellation-app.
the class ClosenessCentralityPluginNGTest 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
vertexClosenessAttribute = SnaConcept.VertexAttribute.CLOSENESS_CENTRALITY.ensure(graph);
vertexInClosenessAttribute = SnaConcept.VertexAttribute.IN_CLOSENESS_CENTRALITY.ensure(graph);
vertexOutClosenessAttribute = SnaConcept.VertexAttribute.OUT_CLOSENESS_CENTRALITY.ensure(graph);
vertexHarmonicClosenessAttribute = SnaConcept.VertexAttribute.HARMONIC_CLOSENESS_CENTRALITY.ensure(graph);
vertexInHarmonicClosenessAttribute = SnaConcept.VertexAttribute.IN_HARMONIC_CLOSENESS_CENTRALITY.ensure(graph);
vertexOutHarmonicClosenessAttribute = SnaConcept.VertexAttribute.OUT_HARMONIC_CLOSENESS_CENTRALITY.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
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.schema.Schema in project constellation by constellation-app.
the class AdamicAdarIndexPluginNGTest 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
transactionAaiAttribute = SnaConcept.TransactionAttribute.ADAMIC_ADAR_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