use of org.janusgraph.core.schema.JanusGraphManagement in project sdc by onap.
the class JanusGraphGenericDaoTest method testStringSearch.
@Test
public void testStringSearch() {
JanusGraph graph;
BaseConfiguration conf = new BaseConfiguration();
conf.setProperty("storage.backend", "inmemory");
graph = JanusGraphFactory.open(conf);
// JanusGraphManagement graphMgt = graph.getManagementSystem();
JanusGraphManagement graphMgt = graph.openManagement();
PropertyKey propKey = graphMgt.makePropertyKey("string1").dataType(String.class).make();
graphMgt.buildIndex("string1", Vertex.class).addKey(propKey).unique().buildCompositeIndex();
propKey = graphMgt.makePropertyKey("string2").dataType(String.class).make();
graphMgt.buildIndex("string2", Vertex.class).addKey(propKey).unique().buildCompositeIndex();
graphMgt.commit();
log.debug("**** predicat index search non case");
Iterable<JanusGraphVertex> vertices = graph.query().has("string1", Text.REGEX, "my new string 1").vertices();
Iterator<JanusGraphVertex> iter = vertices.iterator();
while (iter.hasNext()) {
Vertex ver = iter.next();
// System.out.println(com.tinkerpop.blueprints.util.ElementHelper.getProperties(ver));
log.debug("{}", janusGraphDao.getProperties(ver));
}
}
use of org.janusgraph.core.schema.JanusGraphManagement in project aai-graphadmin by onap.
the class ManageSchemaTest method addNewIndex.
@Test
public void addNewIndex() throws JsonParseException, JsonMappingException, IOException {
ObjectMapper mapper = new ObjectMapper();
String content = " {\r\n" + " \"name\" : \"equipment-name\",\r\n" + " \"unique\" : false,\r\n" + " \"properties\" : [ {\r\n" + " \"name\" : \"equipment-name\",\r\n" + " \"cardinality\" : \"SINGLE\",\r\n" + " \"typeClass\" : \"java.lang.String\"\r\n" + " } ]\r\n" + " }";
DBIndex index = mapper.readValue(content, DBIndex.class);
ManageJanusGraphSchema schema = new ManageJanusGraphSchema(graph, auditorFactory, schemaVersions, edgeIngestor);
JanusGraphManagement mgmt = graph.openManagement();
Set<String> instances = mgmt.getOpenInstances();
System.out.println(instances);
schema.updateIndex(index);
graph.close();
}
use of org.janusgraph.core.schema.JanusGraphManagement in project aai-graphadmin by onap.
the class ManageSchemaTest method closeRunningInstances.
/*
@Test
public void populateEmptyGraph() {
ManageJanusGraphSchema schema = new ManageJanusGraphSchema(graph);
schema.buildSchema();
}
@Test
public void modifyIndex() {
ManageJanusGraphSchema schema = new ManageJanusGraphSchema(graph);
schema.buildSchema();
Vertex v = graph.addVertex();
v.setProperty("aai-node-type", "pserver");
v.setProperty("hostname", "test1");
v.setProperty("internet-topology", "test2");
graph.commit();
DBIndex index = new DBIndex();
index.setName("internet-topology");
index.setUnique(false);
schema.updateIndex(index);
}
*/
@Test
public void closeRunningInstances() {
JanusGraphManagement mgmt = graph.openManagement();
Set<String> instances = mgmt.getOpenInstances();
for (String instance : instances) {
if (!instance.contains("(current)")) {
mgmt.forceCloseInstance(instance);
}
}
mgmt.commit();
graph.close();
}
use of org.janusgraph.core.schema.JanusGraphManagement in project aai-graphadmin by onap.
the class MigrateBadWidgetModelsPartOneTest method setUp.
@Before
public void setUp() throws Exception {
System.setProperty("BUNDLECONFIG_DIR", "src/test/resources");
JanusGraphManagement janusgraphManagement = graph.openManagement();
g = graph.traversal();
loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
dbEngine = new JanusGraphDBEngine(queryStyle, loader);
createFirstVertexAndRelatedVertexes();
TransactionalGraphEngine spy = spy(dbEngine);
TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
GraphTraversalSource traversal = g;
when(spy.asAdmin()).thenReturn(adminSpy);
when(adminSpy.getTraversalSource()).thenReturn(traversal);
Mockito.doReturn(janusgraphManagement).when(adminSpy).getManagementSystem();
migration = new MockMigrateBadWidgetModelsPartOne(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
migration.run();
}
use of org.janusgraph.core.schema.JanusGraphManagement in project aai-graphadmin by onap.
the class ContainmentDeleteOtherVPropertyMigrationTest method setUp.
@Before
public void setUp() throws Exception {
graph = JanusGraphFactory.build().set("storage.backend", "inmemory").open();
JanusGraphManagement janusgraphManagement = graph.openManagement();
tx = graph.newTransaction();
g = tx.traversal();
loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
dbEngine = new JanusGraphDBEngine(queryStyle, loader);
Vertex v = g.addV().property("aai-node-type", "generic-vnf").property("vnf-id", "delcontains-test-vnf").next();
Vertex v2 = g.addV().property("aai-node-type", "l-interface").property("interface-name", "delcontains-test-lint").next();
Edge e = v.addEdge("hasLInterface", v2, EdgeProperty.CONTAINS.toString(), AAIDirection.OUT.toString(), EdgeProperty.DELETE_OTHER_V.toString(), AAIDirection.NONE.toString());
Vertex v3 = g.addV().property("aai-node-type", "allotted-resource").next();
Edge e2 = v2.addEdge("uses", v3, EdgeProperty.CONTAINS.toString(), AAIDirection.NONE.toString(), EdgeProperty.DELETE_OTHER_V.toString(), AAIDirection.NONE.toString());
TransactionalGraphEngine spy = spy(dbEngine);
TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
GraphTraversalSource traversal = g;
when(spy.asAdmin()).thenReturn(adminSpy);
when(adminSpy.getTraversalSource()).thenReturn(traversal);
Mockito.doReturn(janusgraphManagement).when(adminSpy).getManagementSystem();
migration = new ContainmentDeleteOtherVPropertyMigration(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions, "/edgeMigrationTestRules.json");
migration.run();
}
Aggregations