@Test public void createElements() throws ConfigurationException { app.createElements(); assertEquals(12L, g.V().count().next().longValue()); assertEquals(1L, g.V().hasLabel("titan").count().next().longValue()); assertEquals(1L, g.V().hasLabel("demigod").count().next().longValue()); assertEquals(1L, g.V().hasLabel("human").count().next().longValue()); assertEquals(3L, g.V().hasLabel("location").count().next().longValue()); assertEquals(3L, g.V().hasLabel("god").count().next().longValue()); assertEquals(3L, g.V().hasLabel("monster").count().next().longValue()); assertEquals(17L, g.E().count().next().longValue()); assertEquals(2L, g.E().hasLabel("father").count().next().longValue()); assertEquals(1L, g.E().hasLabel("mother").count().next().longValue()); assertEquals(6L, g.E().hasLabel("brother").count().next().longValue()); assertEquals(1L, g.E().hasLabel("pet").count().next().longValue()); assertEquals(4L, g.E().hasLabel("lives").count().next().longValue()); assertEquals(3L, g.E().hasLabel("battled").count().next().longValue()); final float[] place = (float[]) g.V().has("name", "hercules").outE("battled").has("time", 12).values("place") .next(); assertNotNull(place); assertEquals(2, place.length); assertEquals(Float.valueOf(39f), Float.valueOf(place[0])); assertEquals(Float.valueOf(22f), Float.valueOf(place[1])); }
public void createElements() { try { if (g.V().has("name", "saturn").hasNext()) { if (supportsTransactions) { g.tx().rollback(); } return; } LOGGER.info("creating elements"); final Vertex saturn = g.addV("titan").property("name", "saturn").property("age", 10000).next(); final Vertex sky = g.addV("location").property("name", "sky").next(); final Vertex sea = g.addV("location").property("name", "sea").next(); final Vertex jupiter = g.addV("god").property("name", "jupiter").property("age", 5000).next(); final Vertex neptune = g.addV("god").property("name", "neptune").property("age", 4500).next(); final Vertex hercules = g.addV("demigod").property("name", "hercules").property("age", 30).next(); final Vertex alcmene = g.addV("human").property("name", "alcmene").property("age", 45).next(); final Vertex pluto = g.addV("god").property("name", "pluto").property("age", 4000).next(); final Vertex nemean = g.addV("monster").property("name", "nemean").next(); final Vertex hydra = g.addV("monster").property("name", "hydra").next(); final Vertex cerberus = g.addV("monster").property("name", "cerberus").next(); final Vertex tartarus = g.addV("location").property("name", "tartarus").next(); g.V(jupiter).as("a").V(saturn).addE("father").from("a").next(); g.V(jupiter).as("a").V(sky).addE("lives").property("reason", "loves fresh breezes").from("a").next(); g.V(jupiter).as("a").V(neptune).addE("brother").from("a").next(); g.V(jupiter).as("a").V(pluto).addE("brother").from("a").next(); g.V(neptune).as("a").V(sea).addE("lives").property("reason", "loves waves").from("a").next(); g.V(neptune).as("a").V(jupiter).addE("brother").from("a").next(); g.V(neptune).as("a").V(pluto).addE("brother").from("a").next(); g.V(hercules).as("a").V(jupiter).addE("father").from("a").next(); g.V(hercules).as("a").V(alcmene).addE("mother").from("a").next(); if (supportsGeoshape) { g.V(hercules).as("a").V(nemean).addE("battled").property("time", 1) .property("place", Geoshape.point(38.1f, 23.7f)).from("a").next(); g.V(hercules).as("a").V(hydra).addE("battled").property("time", 2) .property("place", Geoshape.point(37.7f, 23.9f)).from("a").next(); g.V(hercules).as("a").V(cerberus).addE("battled").property("time", 12) .property("place", Geoshape.point(39f, 22f)).from("a").next(); } else { g.V(hercules).as("a").V(nemean).addE("battled").property("time", 1) .property("place", getGeoFloatArray(38.1f, 23.7f)).from("a").next(); g.V(hercules).as("a").V(hydra).addE("battled").property("time", 2) .property("place", getGeoFloatArray(37.7f, 23.9f)).from("a").next(); g.V(hercules).as("a").V(cerberus).addE("battled").property("time", 12) .property("place", getGeoFloatArray(39f, 22f)).from("a").next(); } g.V(pluto).as("a").V(jupiter).addE("brother").from("a").next(); g.V(pluto).as("a").V(neptune).addE("brother").from("a").next(); g.V(pluto).as("a").V(tartarus).addE("lives").property("reason", "no fear of death").from("a").next(); g.V(pluto).as("a").V(cerberus).addE("pet").from("a").next(); g.V(cerberus).as("a").V(tartarus).addE("lives").from("a").next(); if (supportsTransactions) { g.tx().commit(); } } catch (Exception e) { LOGGER.error(e.getMessage(), e); if (supportsTransactions) { g.tx().rollback(); } } }
GraphApp { public void createElements() { try { if (g.V().has("name", "saturn").hasNext()) { if (supportsTransactions) { g.tx().rollback(); } return; } LOGGER.info("creating elements"); final Vertex saturn = g.addV("titan").property("name", "saturn").property("age", 10000).next(); final Vertex sky = g.addV("location").property("name", "sky").next(); final Vertex sea = g.addV("location").property("name", "sea").next(); final Vertex jupiter = g.addV("god").property("name", "jupiter").property("age", 5000).next(); final Vertex neptune = g.addV("god").property("name", "neptune").property("age", 4500).next(); final Vertex hercules = g.addV("demigod").property("name", "hercules").property("age", 30).next(); final Vertex alcmene = g.addV("human").property("name", "alcmene").property("age", 45).next(); final Vertex pluto = g.addV("god").property("name", "pluto").property("age", 4000).next(); final Vertex nemean = g.addV("monster").property("name", "nemean").next(); final Vertex hydra = g.addV("monster").property("name", "hydra").next(); final Vertex cerberus = g.addV("monster").property("name", "cerberus").next(); final Vertex tartarus = g.addV("location").property("name", "tartarus").next(); g.V(jupiter).as("a").V(saturn).addE("father").from("a").next(); g.V(jupiter).as("a").V(sky).addE("lives").property("reason", "loves fresh breezes").from("a").next(); g.V(jupiter).as("a").V(neptune).addE("brother").from("a").next(); g.V(jupiter).as("a").V(pluto).addE("brother").from("a").next(); g.V(neptune).as("a").V(sea).addE("lives").property("reason", "loves waves").from("a").next(); g.V(neptune).as("a").V(jupiter).addE("brother").from("a").next(); g.V(neptune).as("a").V(pluto).addE("brother").from("a").next(); g.V(hercules).as("a").V(jupiter).addE("father").from("a").next(); g.V(hercules).as("a").V(alcmene).addE("mother").from("a").next(); if (supportsGeoshape) { g.V(hercules).as("a").V(nemean).addE("battled").property("time", 1) .property("place", Geoshape.point(38.1f, 23.7f)).from("a").next(); g.V(hercules).as("a").V(hydra).addE("battled").property("time", 2) .property("place", Geoshape.point(37.7f, 23.9f)).from("a").next(); g.V(hercules).as("a").V(cerberus).addE("battled").property("time", 12) .property("place", Geoshape.point(39f, 22f)).from("a").next(); } else { g.V(hercules).as("a").V(nemean).addE("battled").property("time", 1) .property("place", getGeoFloatArray(38.1f, 23.7f)).from("a").next(); g.V(hercules).as("a").V(hydra).addE("battled").property("time", 2) .property("place", getGeoFloatArray(37.7f, 23.9f)).from("a").next(); g.V(hercules).as("a").V(cerberus).addE("battled").property("time", 12) .property("place", getGeoFloatArray(39f, 22f)).from("a").next(); } g.V(pluto).as("a").V(jupiter).addE("brother").from("a").next(); g.V(pluto).as("a").V(neptune).addE("brother").from("a").next(); g.V(pluto).as("a").V(tartarus).addE("lives").property("reason", "no fear of death").from("a").next(); g.V(pluto).as("a").V(cerberus).addE("pet").from("a").next(); g.V(cerberus).as("a").V(tartarus).addE("lives").from("a").next(); if (supportsTransactions) { g.tx().commit(); } } catch (Exception e) { LOGGER.error(e.getMessage(), e); if (supportsTransactions) { g.tx().rollback(); } } } }
GraphApp { public void createElements() { try { if (g.V().has("name", "saturn").hasNext()) { if (supportsTransactions) { g.tx().rollback(); } return; } LOGGER.info("creating elements"); final Vertex saturn = g.addV("titan").property("name", "saturn").property("age", 10000).next(); final Vertex sky = g.addV("location").property("name", "sky").next(); final Vertex sea = g.addV("location").property("name", "sea").next(); final Vertex jupiter = g.addV("god").property("name", "jupiter").property("age", 5000).next(); final Vertex neptune = g.addV("god").property("name", "neptune").property("age", 4500).next(); final Vertex hercules = g.addV("demigod").property("name", "hercules").property("age", 30).next(); final Vertex alcmene = g.addV("human").property("name", "alcmene").property("age", 45).next(); final Vertex pluto = g.addV("god").property("name", "pluto").property("age", 4000).next(); final Vertex nemean = g.addV("monster").property("name", "nemean").next(); final Vertex hydra = g.addV("monster").property("name", "hydra").next(); final Vertex cerberus = g.addV("monster").property("name", "cerberus").next(); final Vertex tartarus = g.addV("location").property("name", "tartarus").next(); g.V(jupiter).as("a").V(saturn).addE("father").from("a").next(); g.V(jupiter).as("a").V(sky).addE("lives").property("reason", "loves fresh breezes").from("a").next(); g.V(jupiter).as("a").V(neptune).addE("brother").from("a").next(); g.V(jupiter).as("a").V(pluto).addE("brother").from("a").next(); g.V(neptune).as("a").V(sea).addE("lives").property("reason", "loves waves").from("a").next(); g.V(neptune).as("a").V(jupiter).addE("brother").from("a").next(); g.V(neptune).as("a").V(pluto).addE("brother").from("a").next(); g.V(hercules).as("a").V(jupiter).addE("father").from("a").next(); g.V(hercules).as("a").V(alcmene).addE("mother").from("a").next(); if (supportsGeoshape) { g.V(hercules).as("a").V(nemean).addE("battled").property("time", 1) .property("place", Geoshape.point(38.1f, 23.7f)).from("a").next(); g.V(hercules).as("a").V(hydra).addE("battled").property("time", 2) .property("place", Geoshape.point(37.7f, 23.9f)).from("a").next(); g.V(hercules).as("a").V(cerberus).addE("battled").property("time", 12) .property("place", Geoshape.point(39f, 22f)).from("a").next(); } else { g.V(hercules).as("a").V(nemean).addE("battled").property("time", 1) .property("place", getGeoFloatArray(38.1f, 23.7f)).from("a").next(); g.V(hercules).as("a").V(hydra).addE("battled").property("time", 2) .property("place", getGeoFloatArray(37.7f, 23.9f)).from("a").next(); g.V(hercules).as("a").V(cerberus).addE("battled").property("time", 12) .property("place", getGeoFloatArray(39f, 22f)).from("a").next(); } g.V(pluto).as("a").V(jupiter).addE("brother").from("a").next(); g.V(pluto).as("a").V(neptune).addE("brother").from("a").next(); g.V(pluto).as("a").V(tartarus).addE("lives").property("reason", "no fear of death").from("a").next(); g.V(pluto).as("a").V(cerberus).addE("pet").from("a").next(); g.V(cerberus).as("a").V(tartarus).addE("lives").from("a").next(); if (supportsTransactions) { g.tx().commit(); } } catch (Exception e) { LOGGER.error(e.getMessage(), e); if (supportsTransactions) { g.tx().rollback(); } } } GraphApp(final String fileName); }
GraphApp { public void createElements() { try { if (g.V().has("name", "saturn").hasNext()) { if (supportsTransactions) { g.tx().rollback(); } return; } LOGGER.info("creating elements"); final Vertex saturn = g.addV("titan").property("name", "saturn").property("age", 10000).next(); final Vertex sky = g.addV("location").property("name", "sky").next(); final Vertex sea = g.addV("location").property("name", "sea").next(); final Vertex jupiter = g.addV("god").property("name", "jupiter").property("age", 5000).next(); final Vertex neptune = g.addV("god").property("name", "neptune").property("age", 4500).next(); final Vertex hercules = g.addV("demigod").property("name", "hercules").property("age", 30).next(); final Vertex alcmene = g.addV("human").property("name", "alcmene").property("age", 45).next(); final Vertex pluto = g.addV("god").property("name", "pluto").property("age", 4000).next(); final Vertex nemean = g.addV("monster").property("name", "nemean").next(); final Vertex hydra = g.addV("monster").property("name", "hydra").next(); final Vertex cerberus = g.addV("monster").property("name", "cerberus").next(); final Vertex tartarus = g.addV("location").property("name", "tartarus").next(); g.V(jupiter).as("a").V(saturn).addE("father").from("a").next(); g.V(jupiter).as("a").V(sky).addE("lives").property("reason", "loves fresh breezes").from("a").next(); g.V(jupiter).as("a").V(neptune).addE("brother").from("a").next(); g.V(jupiter).as("a").V(pluto).addE("brother").from("a").next(); g.V(neptune).as("a").V(sea).addE("lives").property("reason", "loves waves").from("a").next(); g.V(neptune).as("a").V(jupiter).addE("brother").from("a").next(); g.V(neptune).as("a").V(pluto).addE("brother").from("a").next(); g.V(hercules).as("a").V(jupiter).addE("father").from("a").next(); g.V(hercules).as("a").V(alcmene).addE("mother").from("a").next(); if (supportsGeoshape) { g.V(hercules).as("a").V(nemean).addE("battled").property("time", 1) .property("place", Geoshape.point(38.1f, 23.7f)).from("a").next(); g.V(hercules).as("a").V(hydra).addE("battled").property("time", 2) .property("place", Geoshape.point(37.7f, 23.9f)).from("a").next(); g.V(hercules).as("a").V(cerberus).addE("battled").property("time", 12) .property("place", Geoshape.point(39f, 22f)).from("a").next(); } else { g.V(hercules).as("a").V(nemean).addE("battled").property("time", 1) .property("place", getGeoFloatArray(38.1f, 23.7f)).from("a").next(); g.V(hercules).as("a").V(hydra).addE("battled").property("time", 2) .property("place", getGeoFloatArray(37.7f, 23.9f)).from("a").next(); g.V(hercules).as("a").V(cerberus).addE("battled").property("time", 12) .property("place", getGeoFloatArray(39f, 22f)).from("a").next(); } g.V(pluto).as("a").V(jupiter).addE("brother").from("a").next(); g.V(pluto).as("a").V(neptune).addE("brother").from("a").next(); g.V(pluto).as("a").V(tartarus).addE("lives").property("reason", "no fear of death").from("a").next(); g.V(pluto).as("a").V(cerberus).addE("pet").from("a").next(); g.V(cerberus).as("a").V(tartarus).addE("lives").from("a").next(); if (supportsTransactions) { g.tx().commit(); } } catch (Exception e) { LOGGER.error(e.getMessage(), e); if (supportsTransactions) { g.tx().rollback(); } } } GraphApp(final String fileName); GraphTraversalSource openGraph(); void closeGraph(); void dropGraph(); void createSchema(); void createElements(); void readElements(); void updateElements(); void deleteElements(); void runApp(); }
GraphApp { public void createElements() { try { if (g.V().has("name", "saturn").hasNext()) { if (supportsTransactions) { g.tx().rollback(); } return; } LOGGER.info("creating elements"); final Vertex saturn = g.addV("titan").property("name", "saturn").property("age", 10000).next(); final Vertex sky = g.addV("location").property("name", "sky").next(); final Vertex sea = g.addV("location").property("name", "sea").next(); final Vertex jupiter = g.addV("god").property("name", "jupiter").property("age", 5000).next(); final Vertex neptune = g.addV("god").property("name", "neptune").property("age", 4500).next(); final Vertex hercules = g.addV("demigod").property("name", "hercules").property("age", 30).next(); final Vertex alcmene = g.addV("human").property("name", "alcmene").property("age", 45).next(); final Vertex pluto = g.addV("god").property("name", "pluto").property("age", 4000).next(); final Vertex nemean = g.addV("monster").property("name", "nemean").next(); final Vertex hydra = g.addV("monster").property("name", "hydra").next(); final Vertex cerberus = g.addV("monster").property("name", "cerberus").next(); final Vertex tartarus = g.addV("location").property("name", "tartarus").next(); g.V(jupiter).as("a").V(saturn).addE("father").from("a").next(); g.V(jupiter).as("a").V(sky).addE("lives").property("reason", "loves fresh breezes").from("a").next(); g.V(jupiter).as("a").V(neptune).addE("brother").from("a").next(); g.V(jupiter).as("a").V(pluto).addE("brother").from("a").next(); g.V(neptune).as("a").V(sea).addE("lives").property("reason", "loves waves").from("a").next(); g.V(neptune).as("a").V(jupiter).addE("brother").from("a").next(); g.V(neptune).as("a").V(pluto).addE("brother").from("a").next(); g.V(hercules).as("a").V(jupiter).addE("father").from("a").next(); g.V(hercules).as("a").V(alcmene).addE("mother").from("a").next(); if (supportsGeoshape) { g.V(hercules).as("a").V(nemean).addE("battled").property("time", 1) .property("place", Geoshape.point(38.1f, 23.7f)).from("a").next(); g.V(hercules).as("a").V(hydra).addE("battled").property("time", 2) .property("place", Geoshape.point(37.7f, 23.9f)).from("a").next(); g.V(hercules).as("a").V(cerberus).addE("battled").property("time", 12) .property("place", Geoshape.point(39f, 22f)).from("a").next(); } else { g.V(hercules).as("a").V(nemean).addE("battled").property("time", 1) .property("place", getGeoFloatArray(38.1f, 23.7f)).from("a").next(); g.V(hercules).as("a").V(hydra).addE("battled").property("time", 2) .property("place", getGeoFloatArray(37.7f, 23.9f)).from("a").next(); g.V(hercules).as("a").V(cerberus).addE("battled").property("time", 12) .property("place", getGeoFloatArray(39f, 22f)).from("a").next(); } g.V(pluto).as("a").V(jupiter).addE("brother").from("a").next(); g.V(pluto).as("a").V(neptune).addE("brother").from("a").next(); g.V(pluto).as("a").V(tartarus).addE("lives").property("reason", "no fear of death").from("a").next(); g.V(pluto).as("a").V(cerberus).addE("pet").from("a").next(); g.V(cerberus).as("a").V(tartarus).addE("lives").from("a").next(); if (supportsTransactions) { g.tx().commit(); } } catch (Exception e) { LOGGER.error(e.getMessage(), e); if (supportsTransactions) { g.tx().rollback(); } } } GraphApp(final String fileName); GraphTraversalSource openGraph(); void closeGraph(); void dropGraph(); void createSchema(); void createElements(); void readElements(); void updateElements(); void deleteElements(); void runApp();  }