marmotta-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sschaff...@apache.org
Subject git commit: more SPARQL functions in native SQL (MARMOTTA-493)
Date Tue, 16 Sep 2014 13:53:25 GMT
Repository: marmotta
Updated Branches:
  refs/heads/develop 5be6ef2eb -> 0c899417a


more SPARQL functions in native SQL (MARMOTTA-493)


Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/0c899417
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/0c899417
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/0c899417

Branch: refs/heads/develop
Commit: 0c899417a9992c1e87b72cbfe0f5a031948c105f
Parents: 5be6ef2
Author: Sebastian Schaffert <sschaffert@apache.org>
Authored: Tue Sep 16 15:53:44 2014 +0200
Committer: Sebastian Schaffert <sschaffert@apache.org>
Committed: Tue Sep 16 15:53:44 2014 +0200

----------------------------------------------------------------------
 .../persistence/pgsql/PostgreSQLDialect.java    | 42 ++++++++++++++++++++
 1 file changed, 42 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/0c899417/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/pgsql/PostgreSQLDialect.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/pgsql/PostgreSQLDialect.java
b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/pgsql/PostgreSQLDialect.java
index 42940ea..63a4db7 100644
--- a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/pgsql/PostgreSQLDialect.java
+++ b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/pgsql/PostgreSQLDialect.java
@@ -68,6 +68,12 @@ public class PostgreSQLDialect extends KiWiDialect {
         supportedFunctions.put(FN_MARMOTTA.QUERY_FULLTEXT);
 
         supportedFunctions.put(FN_MARMOTTA.NOW);
+        supportedFunctions.put(FN_MARMOTTA.YEAR);
+        supportedFunctions.put(FN_MARMOTTA.MONTH);
+        supportedFunctions.put(FN_MARMOTTA.DAY);
+        supportedFunctions.put(FN_MARMOTTA.HOURS);
+        supportedFunctions.put(FN_MARMOTTA.MINUTES);
+        supportedFunctions.put(FN_MARMOTTA.SECONDS);
 
         supportedFunctions.put(FN_MARMOTTA.RAND);
         supportedFunctions.put(FN_MARMOTTA.UUID);
@@ -311,6 +317,42 @@ public class PostgreSQLDialect extends KiWiDialect {
             } else {
                 throw new IllegalArgumentException("SHA512() takes exactly 1 argument");
             }
+        } else if(FN_MARMOTTA.YEAR.equals(fnUri)) {
+            if(args.length == 1) {
+                return String.format("extract(year from %s)", args[0]);
+            } else {
+                throw new IllegalArgumentException("YEAR() takes exactly 1 argument");
+            }
+        } else if(FN_MARMOTTA.MONTH.equals(fnUri)) {
+            if(args.length == 1) {
+                return String.format("extract(month from %s)", args[0]);
+            } else {
+                throw new IllegalArgumentException("MONTH() takes exactly 1 argument");
+            }
+        } else if(FN_MARMOTTA.DAY.equals(fnUri)) {
+            if(args.length == 1) {
+                return String.format("extract(day from %s)", args[0]);
+            } else {
+                throw new IllegalArgumentException("DAY() takes exactly 1 argument");
+            }
+        } else if(FN_MARMOTTA.HOURS.equals(fnUri)) {
+            if(args.length == 1) {
+                return String.format("extract(hour from %s)", args[0]);
+            } else {
+                throw new IllegalArgumentException("HOURS() takes exactly 1 argument");
+            }
+        } else if(FN_MARMOTTA.MINUTES.equals(fnUri)) {
+            if(args.length == 1) {
+                return String.format("extract(minute from %s)", args[0]);
+            } else {
+                throw new IllegalArgumentException("MINUTES() takes exactly 1 argument");
+            }
+        } else if(FN_MARMOTTA.SECONDS.equals(fnUri)) {
+            if(args.length == 1) {
+                return String.format("extract(second from %s)", args[0]);
+            } else {
+                throw new IllegalArgumentException("SECONDS() takes exactly 1 argument");
+            }
         }
         throw new UnsupportedOperationException("operation "+fnUri+" not supported");
     }


Mime
View raw message