http://git-wip-us.apache.org/repos/asf/marmotta/blob/7a824559/libraries/kiwi/kiwi-triplestore/src/main/resources/org/apache/marmotta/kiwi/persistence/pgsql/statements.properties ---------------------------------------------------------------------- diff --git a/libraries/kiwi/kiwi-triplestore/src/main/resources/org/apache/marmotta/kiwi/persistence/pgsql/statements.properties b/libraries/kiwi/kiwi-triplestore/src/main/resources/org/apache/marmotta/kiwi/persistence/pgsql/statements.properties index 7ed1e51..99a6ffb 100644 --- a/libraries/kiwi/kiwi-triplestore/src/main/resources/org/apache/marmotta/kiwi/persistence/pgsql/statements.properties +++ b/libraries/kiwi/kiwi-triplestore/src/main/resources/org/apache/marmotta/kiwi/persistence/pgsql/statements.properties @@ -24,21 +24,21 @@ meta.get = SELECT mvalue FROM metadata WHERE mkey = ?; meta.version = SELECT mvalue FROM metadata WHERE mkey = 'version'; # load entities -load.node_by_id = SELECT id,ntype,svalue,ivalue,dvalue,tvalue,bvalue,lang,ltype,createdAt FROM nodes WHERE id = ? -load.nodes_by_ids = SELECT id,ntype,svalue,ivalue,dvalue,tvalue,bvalue,lang,ltype,createdAt FROM nodes WHERE id IN(%s) LIMIT %d +load.node_by_id = SELECT id,ntype,svalue,ivalue,dvalue,tvalue,tzoffset,bvalue,lang,ltype,createdAt FROM nodes WHERE id = ? +load.nodes_by_ids = SELECT id,ntype,svalue,ivalue,dvalue,tvalue,tzoffset,bvalue,lang,ltype,createdAt FROM nodes WHERE id IN(%s) LIMIT %d -load.uri_by_uri = SELECT id,ntype,svalue,ivalue,dvalue,tvalue,bvalue,lang,ltype,createdAt FROM nodes WHERE ntype = 'uri' AND svalue = ? +load.uri_by_uri = SELECT id,ntype,svalue,ivalue,dvalue,tvalue,tzoffset,bvalue,lang,ltype,createdAt FROM nodes WHERE ntype = 'uri' AND svalue = ? -load.bnode_by_anonid = SELECT id,ntype,svalue,ivalue,dvalue,tvalue,bvalue,lang,ltype,createdAt FROM nodes WHERE ntype = 'bnode' AND svalue = ? +load.bnode_by_anonid = SELECT id,ntype,svalue,ivalue,dvalue,tvalue,tzoffset,bvalue,lang,ltype,createdAt FROM nodes WHERE ntype = 'bnode' AND svalue = ? -load.literal_by_v = SELECT id,ntype,svalue,ivalue,dvalue,tvalue,bvalue,lang,ltype,createdAt FROM nodes WHERE ntype = 'string' AND svalue = ? AND (lang IS NULL OR lang = '') AND ltype IS NULL -load.literal_by_vl = SELECT id,ntype,svalue,ivalue,dvalue,tvalue,bvalue,lang,ltype,createdAt FROM nodes WHERE svalue = ? AND lang = ? -load.literal_by_vt = SELECT id,ntype,svalue,ivalue,dvalue,tvalue,bvalue,lang,ltype,createdAt FROM nodes WHERE svalue = ? AND ltype = ? +load.literal_by_v = SELECT id,ntype,svalue,ivalue,dvalue,tvalue,tzoffset,bvalue,lang,ltype,createdAt FROM nodes WHERE ntype = 'string' AND svalue = ? AND (lang IS NULL OR lang = '') AND ltype IS NULL +load.literal_by_vl = SELECT id,ntype,svalue,ivalue,dvalue,tvalue,tzoffset,bvalue,lang,ltype,createdAt FROM nodes WHERE svalue = ? AND lang = ? +load.literal_by_vt = SELECT id,ntype,svalue,ivalue,dvalue,tvalue,tzoffset,bvalue,lang,ltype,createdAt FROM nodes WHERE svalue = ? AND ltype = ? -load.literal_by_iv = SELECT id,ntype,svalue,ivalue,dvalue,tvalue,bvalue,lang,ltype,createdAt FROM nodes WHERE ivalue = ? AND (lang IS NULL OR lang = '') AND ltype = ? -load.literal_by_dv = SELECT id,ntype,svalue,ivalue,dvalue,tvalue,bvalue,lang,ltype,createdAt FROM nodes WHERE dvalue = ? AND (lang IS NULL OR lang = '') AND ltype = ? -load.literal_by_tv = SELECT id,ntype,svalue,ivalue,dvalue,tvalue,bvalue,lang,ltype,createdAt FROM nodes WHERE tvalue = ? AND (lang IS NULL OR lang = '') AND ltype = ? -load.literal_by_bv = SELECT id,ntype,svalue,ivalue,dvalue,tvalue,bvalue,lang,ltype,createdAt FROM nodes WHERE bvalue = ? AND (lang IS NULL OR lang = '') AND ltype = ? +load.literal_by_iv = SELECT id,ntype,svalue,ivalue,dvalue,tvalue,tzoffset,bvalue,lang,ltype,createdAt FROM nodes WHERE ivalue = ? AND (lang IS NULL OR lang = '') AND ltype = ? +load.literal_by_dv = SELECT id,ntype,svalue,ivalue,dvalue,tvalue,tzoffset,bvalue,lang,ltype,createdAt FROM nodes WHERE dvalue = ? AND (lang IS NULL OR lang = '') AND ltype = ? +load.literal_by_tv = SELECT id,ntype,svalue,ivalue,dvalue,tvalue,tzoffset,bvalue,lang,ltype,createdAt FROM nodes WHERE tvalue = ? AND tzoffset = ? AND (lang IS NULL OR lang = '') AND ltype = ? +load.literal_by_bv = SELECT id,ntype,svalue,ivalue,dvalue,tvalue,tzoffset,bvalue,lang,ltype,createdAt FROM nodes WHERE bvalue = ? AND (lang IS NULL OR lang = '') AND ltype = ? load.namespace_prefix = SELECT id,prefix,uri,createdAt FROM namespaces WHERE prefix = ?; load.namespace_uri = SELECT id,prefix,uri,createdAt FROM namespaces WHERE uri = ?; @@ -53,7 +53,7 @@ store.sliteral = INSERT INTO nodes (id,ntype,svalue,dvalue,ivalue,lang,lty store.iliteral = INSERT INTO nodes (id,ntype,svalue,dvalue,ivalue,ltype,createdAt) VALUES (?,'int',?,?,?,?,?) store.dliteral = INSERT INTO nodes (id,ntype,svalue,dvalue,ltype,createdAt) VALUES (?,'double',?,?,?,?) store.bliteral = INSERT INTO nodes (id,ntype,svalue,bvalue,ltype,createdAt) VALUES (?,'boolean',?,?,?,?) -store.tliteral = INSERT INTO nodes (id,ntype,svalue,tvalue,ltype,createdAt) VALUES (?,'date',?,?,?,?) +store.tliteral = INSERT INTO nodes (id,ntype,svalue,tvalue,tzoffset,ltype,createdAt) VALUES (?,'date',?,?,?,?,?) store.namespace = INSERT INTO namespaces (id,prefix,uri,createdAt) VALUES (?,?,?,?)
http://git-wip-us.apache.org/repos/asf/marmotta/blob/7a824559/libraries/kiwi/kiwi-triplestore/src/main/resources/org/apache/marmotta/kiwi/persistence/pgsql/upgrade_base_003_004.sql ---------------------------------------------------------------------- diff --git a/libraries/kiwi/kiwi-triplestore/src/main/resources/org/apache/marmotta/kiwi/persistence/pgsql/upgrade_base_003_004.sql b/libraries/kiwi/kiwi-triplestore/src/main/resources/org/apache/marmotta/kiwi/persistence/pgsql/upgrade_base_003_004.sql new file mode 100644 index 0000000..6404445 --- /dev/null +++ b/libraries/kiwi/kiwi-triplestore/src/main/resources/org/apache/marmotta/kiwi/persistence/pgsql/upgrade_base_003_004.sql @@ -0,0 +1,16 @@ +-- Licensed to the Apache Software Foundation (ASF) under one or more +-- contributor license agreements. See the NOTICE file distributed with +-- this work for additional information regarding copyright ownership. +-- The ASF licenses this file to You under the Apache License, Version 2.0 +-- (the "License"); you may not use this file except in compliance with +-- the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. + +ALTER TABLE nodes ADD COLUMN tzoffset int4 default 0; http://git-wip-us.apache.org/repos/asf/marmotta/blob/7a824559/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/DialectTest.java ---------------------------------------------------------------------- diff --git a/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/DialectTest.java b/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/DialectTest.java index ed47cee..357263f 100644 --- a/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/DialectTest.java +++ b/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/DialectTest.java @@ -16,10 +16,6 @@ */ package org.apache.marmotta.kiwi.test; -import static org.hamcrest.Matchers.hasItem; - -import java.util.Set; - import org.apache.marmotta.kiwi.config.KiWiConfiguration; import org.apache.marmotta.kiwi.persistence.KiWiDialect; import org.apache.marmotta.kiwi.test.junit.KiWiDatabaseRunner; @@ -29,6 +25,10 @@ import org.junit.runner.RunWith; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Set; + +import static org.hamcrest.Matchers.hasItem; + /** * Test if the dialects returns correct values * <p/> @@ -77,7 +77,7 @@ public class DialectTest { Assert.assertNotNull(migrateScript); Assert.assertFalse("".equals(migrateScript)); - String migrateScript2 = dialect.getMigrationScript(2,"base"); + String migrateScript2 = dialect.getMigrationScript(4,"base"); Assert.assertNotNull(migrateScript2); Assert.assertTrue("".equals(migrateScript2)); http://git-wip-us.apache.org/repos/asf/marmotta/blob/7a824559/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/PersistenceTest.java ---------------------------------------------------------------------- diff --git a/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/PersistenceTest.java b/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/PersistenceTest.java index bdc82f8..3aa3842 100644 --- a/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/PersistenceTest.java +++ b/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/PersistenceTest.java @@ -19,12 +19,13 @@ package org.apache.marmotta.kiwi.test; import info.aduna.iteration.Iterations; import org.apache.commons.lang3.RandomStringUtils; import org.apache.marmotta.commons.sesame.model.Namespaces; -import org.apache.marmotta.commons.util.DateUtils; import org.apache.marmotta.kiwi.config.KiWiConfiguration; import org.apache.marmotta.kiwi.model.rdf.*; import org.apache.marmotta.kiwi.persistence.KiWiConnection; +import org.apache.marmotta.kiwi.persistence.KiWiDialect; import org.apache.marmotta.kiwi.persistence.KiWiPersistence; import org.apache.marmotta.kiwi.test.junit.KiWiDatabaseRunner; +import org.joda.time.DateTime; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -35,10 +36,7 @@ import org.openrdf.model.Statement; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.Date; -import java.util.List; -import java.util.Locale; -import java.util.Random; +import java.util.*; import static org.apache.marmotta.commons.sesame.model.LiteralCommons.getRDFLangStringType; import static org.hamcrest.Matchers.hasItem; @@ -84,7 +82,7 @@ public class PersistenceTest { KiWiConnection connection = persistence.getConnection(); try { Assert.assertThat(connection.getDatabaseTables(),hasItems("nodes","triples","namespaces")); - Assert.assertEquals(3, connection.getDatabaseVersion()); + Assert.assertEquals(KiWiDialect.VERSION, connection.getDatabaseVersion()); connection.commit(); } finally { @@ -895,7 +893,7 @@ public class PersistenceTest { KiWiUriResource uri = new KiWiUriResource(Namespaces.NS_XSD + "dateTime"); - Date value = new Date(); + DateTime value = DateTime.now().withMillisOfSecond(0); // add a new URI to the triple store and check if it exists afterwards, before and after commit KiWiDateLiteral literal = new KiWiDateLiteral(value, uri); connection.storeNode(literal); @@ -973,7 +971,7 @@ public class PersistenceTest { Assert.assertTrue(result.next()); Assert.assertEquals((long) literal.getId(), result.getLong("id")); Assert.assertEquals(literal.stringValue(),result.getString("svalue")); - Assert.assertEquals(DateUtils.getDateWithoutFraction(value).getTime(),result.getTimestamp("tvalue").getTime()); + Assert.assertEquals(value.getMillis(), result.getTimestamp("tvalue", Calendar.getInstance(TimeZone.getTimeZone("UTC"))).getTime()); Assert.assertEquals("date",result.getString("ntype")); Assert.assertNull(result.getString("lang")); Assert.assertEquals((long) uri.getId(), result.getLong("ltype")); http://git-wip-us.apache.org/repos/asf/marmotta/blob/7a824559/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/TestValueFactory.java ---------------------------------------------------------------------- diff --git a/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/TestValueFactory.java b/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/TestValueFactory.java index 3c68fb9..9d54cb2 100644 --- a/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/TestValueFactory.java +++ b/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/TestValueFactory.java @@ -21,6 +21,7 @@ import com.google.common.base.Preconditions; import org.apache.marmotta.commons.sesame.model.LiteralCommons; import org.apache.marmotta.kiwi.generator.SnowflakeIDGenerator; import org.apache.marmotta.kiwi.model.rdf.*; +import org.joda.time.DateTime; import org.openrdf.model.*; import javax.xml.datatype.XMLGregorianCalendar; @@ -260,9 +261,10 @@ public class TestValueFactory implements ValueFactory { */ @Override public Literal createLiteral(XMLGregorianCalendar calendar) { - Date value = calendar.toGregorianCalendar().getTime(); + KiWiLiteral l = new KiWiDateLiteral(new DateTime(calendar.toGregorianCalendar()), (KiWiUriResource) createURI(LiteralCommons.getXSDType(Date.class)), new Date()); + l.setId(idGenerator.getId()); - return createLiteral(value); + return l; } /** @@ -274,7 +276,7 @@ public class TestValueFactory implements ValueFactory { */ @Override public Literal createLiteral(Date date) { - KiWiLiteral l = new KiWiDateLiteral(date, (KiWiUriResource) createURI(LiteralCommons.getXSDType(Date.class)), new Date()); + KiWiLiteral l = new KiWiDateLiteral(new DateTime(date), (KiWiUriResource) createURI(LiteralCommons.getXSDType(Date.class)), new Date()); l.setId(idGenerator.getId()); return l; http://git-wip-us.apache.org/repos/asf/marmotta/blob/7a824559/parent/pom.xml ---------------------------------------------------------------------- diff --git a/parent/pom.xml b/parent/pom.xml index 742c476..c70c7f2 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -737,6 +737,14 @@ </exclusions> </dependency> <dependency> + <groupId>joda-time</groupId> + <artifactId>joda-time</artifactId> + <version>2.5</version> + </dependency> + + + <!-- XML Processing --> + <dependency> <groupId>xerces</groupId> <artifactId>xercesImpl</artifactId> <version>2.10.0</version> @@ -746,8 +754,6 @@ <artifactId>xml-apis</artifactId> <version>1.4.01</version> </dependency> - - <!-- XML Processing --> <dependency> <groupId>org.jdom</groupId> <artifactId>jdom2</artifactId>
