Search in sources :

Example 16 with SqlgGraph

use of org.umlg.sqlg.structure.SqlgGraph in project sqlg by pietermartin.

the class TestLocalDateArray method testLocalDateArrayOnEdge.

@Test
public void testLocalDateArrayOnEdge() throws Exception {
    Assume.assumeTrue(this.sqlgGraph.getSqlDialect().supportsLocalDateArrayValues());
    LocalDate[] localDates = new LocalDate[] { LocalDate.now(), LocalDate.now().minusDays(1) };
    Vertex a1 = this.sqlgGraph.addVertex(T.label, "A", "localDates", localDates);
    Vertex a2 = this.sqlgGraph.addVertex(T.label, "A", "localDates", localDates);
    a1.addEdge("aa", a2, "localDates", localDates);
    this.sqlgGraph.tx().commit();
    // Create a new sqlgGraph
    try (SqlgGraph sqlgGraph1 = SqlgGraph.open(configuration)) {
        List<? extends Property<LocalDate[]>> properties = sqlgGraph1.traversal().E().hasLabel("aa").<LocalDate[]>properties("localDates").toList();
        Assert.assertEquals(1, properties.size());
        Assert.assertTrue(properties.get(0).isPresent());
        Assert.assertArrayEquals(localDates, properties.get(0).value());
    }
}
Also used : Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) SqlgGraph(org.umlg.sqlg.structure.SqlgGraph) BaseTest(org.umlg.sqlg.test.BaseTest) Test(org.junit.Test)

Example 17 with SqlgGraph

use of org.umlg.sqlg.structure.SqlgGraph in project sqlg by pietermartin.

the class TestLocalDateArray method testZonedDateTimeArrayOnEdge.

@Test
public void testZonedDateTimeArrayOnEdge() throws Exception {
    Assume.assumeTrue(this.sqlgGraph.getSqlDialect().supportsZonedDateTimeArrayValues());
    ZoneId zoneIdShanghai = ZoneId.of("Asia/Shanghai");
    ZonedDateTime zonedDateTimeAGT = ZonedDateTime.of(LocalDateTime.now(), zoneIdShanghai);
    ZoneId zoneIdHarare = ZoneId.of("Africa/Harare");
    ZonedDateTime zonedDateTimeAGTHarare = ZonedDateTime.of(LocalDateTime.now(), zoneIdHarare);
    ZonedDateTime[] zonedDateTimes = { zonedDateTimeAGT, zonedDateTimeAGTHarare };
    Vertex a1 = this.sqlgGraph.addVertex(T.label, "A", "zonedDateTimes", zonedDateTimes);
    Vertex a2 = this.sqlgGraph.addVertex(T.label, "A", "zonedDateTimes", zonedDateTimes);
    a1.addEdge("aa", a2, "zonedDateTimes", zonedDateTimes);
    this.sqlgGraph.tx().commit();
    // Create a new sqlgGraph
    try (SqlgGraph sqlgGraph1 = SqlgGraph.open(configuration)) {
        List<? extends Property<ZonedDateTime[]>> properties = sqlgGraph1.traversal().E().hasLabel("aa").<ZonedDateTime[]>properties("zonedDateTimes").toList();
        Assert.assertEquals(1, properties.size());
        Assert.assertTrue(properties.get(0).isPresent());
        ZonedDateTime[] localDateTimesFromDb = properties.get(0).value();
        Assert.assertArrayEquals(zonedDateTimes, localDateTimesFromDb);
    }
}
Also used : Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) SqlgGraph(org.umlg.sqlg.structure.SqlgGraph) BaseTest(org.umlg.sqlg.test.BaseTest) Test(org.junit.Test)

Example 18 with SqlgGraph

use of org.umlg.sqlg.structure.SqlgGraph in project sqlg by pietermartin.

the class TestLocalDateArray method testLocalDateTimeArray.

@Test
public void testLocalDateTimeArray() throws Exception {
    Assume.assumeTrue(this.sqlgGraph.getSqlDialect().supportsLocalDateTimeArrayValues());
    LocalDateTime[] localDateTimes = new LocalDateTime[] { LocalDateTime.now(), LocalDateTime.now() };
    this.sqlgGraph.addVertex(T.label, "A", "localDateTimes", localDateTimes);
    this.sqlgGraph.tx().commit();
    // Create a new sqlgGraph
    try (SqlgGraph sqlgGraph1 = SqlgGraph.open(configuration)) {
        List<? extends Property<LocalDateTime[]>> properties = sqlgGraph1.traversal().V().hasLabel("A").<LocalDateTime[]>properties("localDateTimes").toList();
        Assert.assertEquals(1, properties.size());
        Assert.assertTrue(properties.get(0).isPresent());
        LocalDateTime[] localDateTimesFromDb = properties.get(0).value();
        Assert.assertArrayEquals(localDateTimes, localDateTimesFromDb);
    }
}
Also used : SqlgGraph(org.umlg.sqlg.structure.SqlgGraph) BaseTest(org.umlg.sqlg.test.BaseTest) Test(org.junit.Test)

Example 19 with SqlgGraph

use of org.umlg.sqlg.structure.SqlgGraph in project sqlg by pietermartin.

the class TestLocalDateArray method testZonedDateTimeArray.

@Test
public void testZonedDateTimeArray() throws Exception {
    Assume.assumeTrue(this.sqlgGraph.getSqlDialect().supportsZonedDateTimeArrayValues());
    ZoneId zoneIdShanghai = ZoneId.of("Asia/Shanghai");
    ZonedDateTime zonedDateTimeAGT = ZonedDateTime.of(LocalDateTime.now(), zoneIdShanghai);
    ZoneId zoneIdHarare = ZoneId.of("Africa/Harare");
    ZonedDateTime zonedDateTimeAGTHarare = ZonedDateTime.of(LocalDateTime.now(), zoneIdHarare);
    ZonedDateTime[] zonedDateTimes = { zonedDateTimeAGT, zonedDateTimeAGTHarare };
    this.sqlgGraph.addVertex(T.label, "A", "zonedDateTimes", zonedDateTimes);
    this.sqlgGraph.tx().commit();
    // noinspection Duplicates
    try (SqlgGraph sqlgGraph1 = SqlgGraph.open(configuration)) {
        List<? extends Property<ZonedDateTime[]>> properties = sqlgGraph1.traversal().V().hasLabel("A").<ZonedDateTime[]>properties("zonedDateTimes").toList();
        Assert.assertEquals(1, properties.size());
        Assert.assertTrue(properties.get(0).isPresent());
        ZonedDateTime[] value = properties.get(0).<ZonedDateTime[]>value();
        Assert.assertArrayEquals(zonedDateTimes, value);
    }
}
Also used : SqlgGraph(org.umlg.sqlg.structure.SqlgGraph) BaseTest(org.umlg.sqlg.test.BaseTest) Test(org.junit.Test)

Example 20 with SqlgGraph

use of org.umlg.sqlg.structure.SqlgGraph in project sqlg by pietermartin.

the class TestLocalDateArray method testDurationArray.

@Test
public void testDurationArray() throws Exception {
    Assume.assumeTrue(this.sqlgGraph.getSqlDialect().supportsIntegerArrayValues());
    Duration[] durations = new Duration[] { Duration.ofHours(1), Duration.ofHours(5) };
    this.sqlgGraph.addVertex(T.label, "A", "durations", durations);
    this.sqlgGraph.tx().commit();
    // Create a new sqlgGraph
    try (SqlgGraph sqlgGraph1 = SqlgGraph.open(configuration)) {
        List<? extends Property<Duration[]>> properties = sqlgGraph1.traversal().V().hasLabel("A").<Duration[]>properties("durations").toList();
        Assert.assertEquals(1, properties.size());
        Assert.assertTrue(properties.get(0).isPresent());
        Duration[] durationsFromDb = properties.get(0).value();
        Assert.assertArrayEquals(durations, durationsFromDb);
    }
}
Also used : SqlgGraph(org.umlg.sqlg.structure.SqlgGraph) BaseTest(org.umlg.sqlg.test.BaseTest) Test(org.junit.Test)

Aggregations

SqlgGraph (org.umlg.sqlg.structure.SqlgGraph)75 Test (org.junit.Test)68 BaseTest (org.umlg.sqlg.test.BaseTest)64 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)44 ConfigurationException (org.apache.commons.configuration.ConfigurationException)10 PropertyVetoException (java.beans.PropertyVetoException)9 IOException (java.io.IOException)9 Connection (java.sql.Connection)7 Edge (org.apache.tinkerpop.gremlin.structure.Edge)6 ResultSet (java.sql.ResultSet)4 Configuration (org.apache.commons.configuration.Configuration)4 Traversal (org.apache.tinkerpop.gremlin.process.traversal.Traversal)4 ReducingBarrierStep (org.apache.tinkerpop.gremlin.process.traversal.step.util.ReducingBarrierStep)4 Statement (java.sql.Statement)3 PropertyType (org.umlg.sqlg.structure.PropertyType)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 URL (java.net.URL)2 DatabaseMetaData (java.sql.DatabaseMetaData)2 PreparedStatement (java.sql.PreparedStatement)2