@Test public void createSchema() throws ConfigurationException { final JanusGraphApp app = new JanusGraphApp(CONF_FILE); final GraphTraversalSource g = app.openGraph(); app.createSchema(); final JanusGraph janusGraph = (JanusGraph) g.getGraph(); final JanusGraphManagement management = janusGraph.openManagement(); final List<String> vertexLabels = StreamSupport.stream(management.getVertexLabels().spliterator(), false) .map(Namifiable::name).collect(Collectors.toList()); final List<String> expectedVertexLabels = Stream.of("titan", "location", "god", "demigod", "human", "monster") .collect(Collectors.toList()); assertTrue(vertexLabels.containsAll(expectedVertexLabels)); final List<String> edgeLabels = StreamSupport .stream(management.getRelationTypes(EdgeLabel.class).spliterator(), false).map(Namifiable::name) .collect(Collectors.toList()); final List<String> expectedEdgeLabels = Stream.of("father", "mother", "brother", "pet", "lives", "battled") .collect(Collectors.toList()); assertTrue(edgeLabels.containsAll(expectedEdgeLabels)); final EdgeLabel father = management.getEdgeLabel("father"); assertTrue(father.isDirected()); assertFalse(father.isUnidirected()); assertEquals(Multiplicity.MANY2ONE, father.multiplicity()); final List<String> propertyKeys = StreamSupport .stream(management.getRelationTypes(PropertyKey.class).spliterator(), false).map(Namifiable::name) .collect(Collectors.toList()); final List<String> expectedPropertyKeys = Stream.of("name", "age", "time", "place", "reason") .collect(Collectors.toList()); assertTrue(propertyKeys.containsAll(expectedPropertyKeys)); final PropertyKey place = management.getPropertyKey("place"); assertEquals(Cardinality.SINGLE, place.cardinality()); assertEquals(Geoshape.class, place.dataType()); final JanusGraphIndex nameIndex = management.getGraphIndex("nameIndex"); assertTrue(nameIndex.isCompositeIndex()); assertEquals(nameIndex.getIndexedElement(), JanusGraphVertex.class); final PropertyKey[] nameIndexKeys = nameIndex.getFieldKeys(); assertEquals(1, nameIndexKeys.length); assertEquals("name", nameIndexKeys[0].name()); }
@Override public void createSchema() { final JanusGraphManagement management = getJanusGraph().openManagement(); try { if (management.getRelationTypes(RelationType.class).iterator().hasNext()) { management.rollback(); return; } LOGGER.info("creating schema"); createProperties(management); createVertexLabels(management); createEdgeLabels(management); createCompositeIndexes(management); createMixedIndexes(management); management.commit(); } catch (Exception e) { management.rollback(); } }
JanusGraphApp extends GraphApp { @Override public void createSchema() { final JanusGraphManagement management = getJanusGraph().openManagement(); try { if (management.getRelationTypes(RelationType.class).iterator().hasNext()) { management.rollback(); return; } LOGGER.info("creating schema"); createProperties(management); createVertexLabels(management); createEdgeLabels(management); createCompositeIndexes(management); createMixedIndexes(management); management.commit(); } catch (Exception e) { management.rollback(); } } }
JanusGraphApp extends GraphApp { @Override public void createSchema() { final JanusGraphManagement management = getJanusGraph().openManagement(); try { if (management.getRelationTypes(RelationType.class).iterator().hasNext()) { management.rollback(); return; } LOGGER.info("creating schema"); createProperties(management); createVertexLabels(management); createEdgeLabels(management); createCompositeIndexes(management); createMixedIndexes(management); management.commit(); } catch (Exception e) { management.rollback(); } } JanusGraphApp(final String fileName); }
JanusGraphApp extends GraphApp { @Override public void createSchema() { final JanusGraphManagement management = getJanusGraph().openManagement(); try { if (management.getRelationTypes(RelationType.class).iterator().hasNext()) { management.rollback(); return; } LOGGER.info("creating schema"); createProperties(management); createVertexLabels(management); createEdgeLabels(management); createCompositeIndexes(management); createMixedIndexes(management); management.commit(); } catch (Exception e) { management.rollback(); } } JanusGraphApp(final String fileName); @Override GraphTraversalSource openGraph(); @Override void dropGraph(); @Override void createElements(); @Override void createSchema(); static void main(String[] args); }
JanusGraphApp extends GraphApp { @Override public void createSchema() { final JanusGraphManagement management = getJanusGraph().openManagement(); try { if (management.getRelationTypes(RelationType.class).iterator().hasNext()) { management.rollback(); return; } LOGGER.info("creating schema"); createProperties(management); createVertexLabels(management); createEdgeLabels(management); createCompositeIndexes(management); createMixedIndexes(management); management.commit(); } catch (Exception e) { management.rollback(); } } JanusGraphApp(final String fileName); @Override GraphTraversalSource openGraph(); @Override void dropGraph(); @Override void createElements(); @Override void createSchema(); static void main(String[] args);  }