towards MARMOTTA-543 (modular function support):
- modularized most functions, but they are currently not yet used


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

Branch: refs/heads/develop
Commit: 67c2b87802ae2bac611fc24654d0e2dc43823d4f
Parents: 564282f
Author: Sebastian Schaffert <[email protected]>
Authored: Fri Sep 19 16:45:45 2014 +0200
Committer: Sebastian Schaffert <[email protected]>
Committed: Fri Sep 19 16:45:45 2014 +0200

----------------------------------------------------------------------
 .../kiwi/sparql/function/NativeFunction.java    |  77 ++++++++++++
 .../kiwi/sparql/function/cast/NBooleanCast.java | 106 +++++++++++++++++
 .../sparql/function/cast/NDateTimeCast.java     | 106 +++++++++++++++++
 .../kiwi/sparql/function/cast/NDecimalCast.java |  99 ++++++++++++++++
 .../kiwi/sparql/function/cast/NDoubleCast.java  | 106 +++++++++++++++++
 .../kiwi/sparql/function/cast/NFloatCast.java   | 106 +++++++++++++++++
 .../kiwi/sparql/function/cast/NIntegerCast.java | 106 +++++++++++++++++
 .../kiwi/sparql/function/cast/NStringCast.java  |  99 ++++++++++++++++
 .../kiwi/sparql/function/datetime/NDay.java     | 106 +++++++++++++++++
 .../kiwi/sparql/function/datetime/NHours.java   | 106 +++++++++++++++++
 .../kiwi/sparql/function/datetime/NMinutes.java | 106 +++++++++++++++++
 .../kiwi/sparql/function/datetime/NMonth.java   | 106 +++++++++++++++++
 .../kiwi/sparql/function/datetime/NNow.java     |  99 ++++++++++++++++
 .../kiwi/sparql/function/datetime/NSeconds.java | 106 +++++++++++++++++
 .../kiwi/sparql/function/datetime/NYear.java    | 106 +++++++++++++++++
 .../kiwi/sparql/function/hash/NMD5.java         | 103 ++++++++++++++++
 .../kiwi/sparql/function/hash/NSHA1.java        | 103 ++++++++++++++++
 .../kiwi/sparql/function/hash/NSHA256.java      | 103 ++++++++++++++++
 .../kiwi/sparql/function/hash/NSHA384.java      | 103 ++++++++++++++++
 .../kiwi/sparql/function/hash/NSHA512.java      | 103 ++++++++++++++++
 .../kiwi/sparql/function/numeric/NAbs.java      |  99 ++++++++++++++++
 .../kiwi/sparql/function/numeric/NCeil.java     |  99 ++++++++++++++++
 .../kiwi/sparql/function/numeric/NFloor.java    |  99 ++++++++++++++++
 .../kiwi/sparql/function/numeric/NRand.java     | 104 +++++++++++++++++
 .../kiwi/sparql/function/numeric/NRound.java    |  99 ++++++++++++++++
 .../kiwi/sparql/function/rdfterm/NSTRUUID.java  | 103 ++++++++++++++++
 .../kiwi/sparql/function/rdfterm/NUUID.java     | 103 ++++++++++++++++
 .../kiwi/sparql/function/string/NConcat.java    | 105 +++++++++++++++++
 .../kiwi/sparql/function/string/NContains.java  | 106 +++++++++++++++++
 .../kiwi/sparql/function/string/NLowerCase.java |  99 ++++++++++++++++
 .../kiwi/sparql/function/string/NReplace.java   | 116 +++++++++++++++++++
 .../kiwi/sparql/function/string/NStrAfter.java  | 106 +++++++++++++++++
 .../kiwi/sparql/function/string/NStrBefore.java | 106 +++++++++++++++++
 .../kiwi/sparql/function/string/NStrEnds.java   | 106 +++++++++++++++++
 .../kiwi/sparql/function/string/NStrLen.java    |  99 ++++++++++++++++
 .../kiwi/sparql/function/string/NStrStarts.java | 106 +++++++++++++++++
 .../kiwi/sparql/function/string/NUpperCase.java |  99 ++++++++++++++++
 .../persistence/pgsql/PostgreSQLDialect.java    |   2 +-
 38 files changed, 3810 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/67c2b878/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/NativeFunction.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/NativeFunction.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/NativeFunction.java
new file mode 100644
index 0000000..f9f7fd3
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/NativeFunction.java
@@ -0,0 +1,77 @@
+/*
+ * 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.
+ */
+
+package org.apache.marmotta.kiwi.sparql.function;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.sparql.builder.OPTypes;
+import org.openrdf.query.algebra.evaluation.function.Function;
+
+/**
+ * Specification of extended native function support for KiWi. Subclasses 
represent Sesame SPARQL functions
+ * that can be translated into native SQL according to the different dialects.
+ *
+ * This interface extends Function because we want to ensure that every 
function really also corresponds
+ * to a Sesame function.
+ *
+ * @author Sebastian Schaffert ([email protected])
+ */
+public interface NativeFunction extends Function {
+
+    /**
+     * Return true if this function has available native support for the given 
dialect
+     * @param dialect
+     * @return
+     */
+    public boolean isSupported(KiWiDialect dialect);
+
+    /**
+     * Return a string representing how this function is translated into SQL 
in the given dialect
+     * @param dialect
+     * @param args
+     * @return
+     */
+    public String getNative(KiWiDialect dialect, String... args);
+
+    /**
+     * Get the return type of the function. This is needed for SQL type 
casting inside KiWi.
+     * @return
+     */
+    public OPTypes getReturnType();
+
+    /**
+     * Get the argument type of the function for the arg'th argument (starting 
to count at 0).
+     * This is needed for SQL type casting inside KiWi.
+     *
+     * @param arg
+     * @return
+     */
+    public OPTypes getArgumentType(int arg);
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     * @return
+     */
+    public int getMinArgs();
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    public int getMaxArgs();
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/67c2b878/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/cast/NBooleanCast.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/cast/NBooleanCast.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/cast/NBooleanCast.java
new file mode 100644
index 0000000..7edf93d
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/cast/NBooleanCast.java
@@ -0,0 +1,106 @@
+/*
+ * 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.
+ */
+
+package org.apache.marmotta.kiwi.sparql.function.cast;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.h2.H2Dialect;
+import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.OPTypes;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.openrdf.query.algebra.evaluation.function.BooleanCast;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert ([email protected])
+ */
+public class NBooleanCast extends BooleanCast implements NativeFunction {
+
+    /**
+     * Return true if this function has available native support for the given 
dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect || dialect instanceof 
H2Dialect || dialect instanceof MySQLDialect;
+    }
+
+    /**
+     * Return a string representing how this function is translated into SQL 
in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        if (dialect instanceof PostgreSQLDialect) {
+            return String.format("CAST(%s AS boolean)", args[0]);
+        } else if (dialect instanceof H2Dialect) {
+            return String.format("CAST(%s AS boolean)", args[0]);
+        } else if(dialect instanceof MySQLDialect) {
+            return String.format("(lower(%s) = 'true' OR %s > 0)", args[0]);
+        }
+        throw new UnsupportedOperationException("CAST not supported in dialect 
"+dialect);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type 
casting inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public OPTypes getReturnType() {
+        return OPTypes.BOOL;
+    }
+
+    /**
+     * Get the argument type of the function for the arg'th argument (starting 
to count at 0).
+     * This is needed for SQL type casting inside KiWi.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public OPTypes getArgumentType(int arg) {
+        return OPTypes.VALUE;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 1;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 1;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/67c2b878/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/cast/NDateTimeCast.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/cast/NDateTimeCast.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/cast/NDateTimeCast.java
new file mode 100644
index 0000000..4aa3233
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/cast/NDateTimeCast.java
@@ -0,0 +1,106 @@
+/*
+ * 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.
+ */
+
+package org.apache.marmotta.kiwi.sparql.function.cast;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.h2.H2Dialect;
+import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.OPTypes;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.openrdf.query.algebra.evaluation.function.DateTimeCast;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert ([email protected])
+ */
+public class NDateTimeCast extends DateTimeCast implements NativeFunction {
+
+    /**
+     * Return true if this function has available native support for the given 
dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect || dialect instanceof 
H2Dialect || dialect instanceof MySQLDialect;
+    }
+
+    /**
+     * Return a string representing how this function is translated into SQL 
in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        if (dialect instanceof PostgreSQLDialect) {
+            return String.format("CAST(%s AS timestamp)", args[0]);
+        } else if (dialect instanceof H2Dialect) {
+            return String.format("CAST(%s AS timestamp)", args[0]);
+        } else if(dialect instanceof MySQLDialect) {
+            return String.format("CAST(%s AS datetime)", args[0]);
+        }
+        throw new UnsupportedOperationException("CAST not supported in dialect 
"+dialect);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type 
casting inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public OPTypes getReturnType() {
+        return OPTypes.DATE;
+    }
+
+    /**
+     * Get the argument type of the function for the arg'th argument (starting 
to count at 0).
+     * This is needed for SQL type casting inside KiWi.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public OPTypes getArgumentType(int arg) {
+        return OPTypes.VALUE;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 1;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 1;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/67c2b878/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/cast/NDecimalCast.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/cast/NDecimalCast.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/cast/NDecimalCast.java
new file mode 100644
index 0000000..ad41251
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/cast/NDecimalCast.java
@@ -0,0 +1,99 @@
+/*
+ * 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.
+ */
+
+package org.apache.marmotta.kiwi.sparql.function.cast;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.h2.H2Dialect;
+import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.OPTypes;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.openrdf.query.algebra.evaluation.function.DecimalCast;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert ([email protected])
+ */
+public class NDecimalCast extends DecimalCast implements NativeFunction {
+
+    /**
+     * Return true if this function has available native support for the given 
dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect || dialect instanceof 
H2Dialect || dialect instanceof MySQLDialect;
+    }
+
+    /**
+     * Return a string representing how this function is translated into SQL 
in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        return String.format("CAST(%s AS decimal)", args[0]);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type 
casting inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public OPTypes getReturnType() {
+        return OPTypes.DATE;
+    }
+
+    /**
+     * Get the argument type of the function for the arg'th argument (starting 
to count at 0).
+     * This is needed for SQL type casting inside KiWi.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public OPTypes getArgumentType(int arg) {
+        return OPTypes.VALUE;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 1;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 1;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/67c2b878/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/cast/NDoubleCast.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/cast/NDoubleCast.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/cast/NDoubleCast.java
new file mode 100644
index 0000000..16956f7
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/cast/NDoubleCast.java
@@ -0,0 +1,106 @@
+/*
+ * 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.
+ */
+
+package org.apache.marmotta.kiwi.sparql.function.cast;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.h2.H2Dialect;
+import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.OPTypes;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.openrdf.query.algebra.evaluation.function.DoubleCast;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert ([email protected])
+ */
+public class NDoubleCast extends DoubleCast implements NativeFunction {
+
+    /**
+     * Return true if this function has available native support for the given 
dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect || dialect instanceof 
H2Dialect || dialect instanceof MySQLDialect;
+    }
+
+    /**
+     * Return a string representing how this function is translated into SQL 
in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        if (dialect instanceof PostgreSQLDialect) {
+            return String.format("CAST(%s AS double precision)", args[0]);
+        } else if (dialect instanceof H2Dialect) {
+            return String.format("CAST(%s AS double precision)", args[0]);
+        } else if(dialect instanceof MySQLDialect) {
+            return String.format("CAST(%s AS decimal)", args[0]);
+        }
+        throw new UnsupportedOperationException("CAST not supported in dialect 
"+dialect);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type 
casting inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public OPTypes getReturnType() {
+        return OPTypes.DATE;
+    }
+
+    /**
+     * Get the argument type of the function for the arg'th argument (starting 
to count at 0).
+     * This is needed for SQL type casting inside KiWi.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public OPTypes getArgumentType(int arg) {
+        return OPTypes.VALUE;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 1;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 1;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/67c2b878/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/cast/NFloatCast.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/cast/NFloatCast.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/cast/NFloatCast.java
new file mode 100644
index 0000000..d2345ce
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/cast/NFloatCast.java
@@ -0,0 +1,106 @@
+/*
+ * 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.
+ */
+
+package org.apache.marmotta.kiwi.sparql.function.cast;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.h2.H2Dialect;
+import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.OPTypes;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.openrdf.query.algebra.evaluation.function.FloatCast;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert ([email protected])
+ */
+public class NFloatCast extends FloatCast implements NativeFunction {
+
+    /**
+     * Return true if this function has available native support for the given 
dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect || dialect instanceof 
H2Dialect || dialect instanceof MySQLDialect;
+    }
+
+    /**
+     * Return a string representing how this function is translated into SQL 
in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        if (dialect instanceof PostgreSQLDialect) {
+            return String.format("CAST(%s AS double precision)", args[0]);
+        } else if (dialect instanceof H2Dialect) {
+            return String.format("CAST(%s AS double precision)", args[0]);
+        } else if(dialect instanceof MySQLDialect) {
+            return String.format("CAST(%s AS decimal)", args[0]);
+        }
+        throw new UnsupportedOperationException("CAST not supported in dialect 
"+dialect);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type 
casting inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public OPTypes getReturnType() {
+        return OPTypes.DATE;
+    }
+
+    /**
+     * Get the argument type of the function for the arg'th argument (starting 
to count at 0).
+     * This is needed for SQL type casting inside KiWi.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public OPTypes getArgumentType(int arg) {
+        return OPTypes.VALUE;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 1;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 1;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/67c2b878/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/cast/NIntegerCast.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/cast/NIntegerCast.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/cast/NIntegerCast.java
new file mode 100644
index 0000000..e9d4a4e
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/cast/NIntegerCast.java
@@ -0,0 +1,106 @@
+/*
+ * 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.
+ */
+
+package org.apache.marmotta.kiwi.sparql.function.cast;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.h2.H2Dialect;
+import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.OPTypes;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.openrdf.query.algebra.evaluation.function.IntegerCast;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert ([email protected])
+ */
+public class NIntegerCast extends IntegerCast implements NativeFunction {
+
+    /**
+     * Return true if this function has available native support for the given 
dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect || dialect instanceof 
H2Dialect || dialect instanceof MySQLDialect;
+    }
+
+    /**
+     * Return a string representing how this function is translated into SQL 
in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        if (dialect instanceof PostgreSQLDialect) {
+            return String.format("CAST(%s AS bigint)", args[0]);
+        } else if (dialect instanceof H2Dialect) {
+            return String.format("CAST(%s AS bigint)", args[0]);
+        } else if(dialect instanceof MySQLDialect) {
+            return String.format("CAST(%s AS signed)", args[0]);
+        }
+        throw new UnsupportedOperationException("CAST not supported in dialect 
"+dialect);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type 
casting inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public OPTypes getReturnType() {
+        return OPTypes.DATE;
+    }
+
+    /**
+     * Get the argument type of the function for the arg'th argument (starting 
to count at 0).
+     * This is needed for SQL type casting inside KiWi.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public OPTypes getArgumentType(int arg) {
+        return OPTypes.VALUE;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 1;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 1;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/67c2b878/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/cast/NStringCast.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/cast/NStringCast.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/cast/NStringCast.java
new file mode 100644
index 0000000..73dcd8c
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/cast/NStringCast.java
@@ -0,0 +1,99 @@
+/*
+ * 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.
+ */
+
+package org.apache.marmotta.kiwi.sparql.function.cast;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.h2.H2Dialect;
+import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.OPTypes;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.openrdf.query.algebra.evaluation.function.StringCast;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert ([email protected])
+ */
+public class NStringCast extends StringCast implements NativeFunction {
+
+    /**
+     * Return true if this function has available native support for the given 
dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect || dialect instanceof 
H2Dialect || dialect instanceof MySQLDialect;
+    }
+
+    /**
+     * Return a string representing how this function is translated into SQL 
in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        return args[0];
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type 
casting inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public OPTypes getReturnType() {
+        return OPTypes.DATE;
+    }
+
+    /**
+     * Get the argument type of the function for the arg'th argument (starting 
to count at 0).
+     * This is needed for SQL type casting inside KiWi.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public OPTypes getArgumentType(int arg) {
+        return OPTypes.VALUE;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 1;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 1;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/67c2b878/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/datetime/NDay.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/datetime/NDay.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/datetime/NDay.java
new file mode 100644
index 0000000..f0e87ff
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/datetime/NDay.java
@@ -0,0 +1,106 @@
+/*
+ * 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.
+ */
+
+package org.apache.marmotta.kiwi.sparql.function.datetime;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.h2.H2Dialect;
+import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.OPTypes;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.openrdf.query.algebra.evaluation.function.datetime.Day;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert ([email protected])
+ */
+public class NDay extends Day implements NativeFunction {
+
+    /**
+     * Return true if this function has available native support for the given 
dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect || dialect instanceof 
H2Dialect || dialect instanceof MySQLDialect;
+    }
+
+    /**
+     * Return a string representing how this function is translated into SQL 
in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        if (dialect instanceof PostgreSQLDialect) {
+            return String.format("extract(day from %s)", args[0]);
+        } else if (dialect instanceof H2Dialect) {
+            return String.format("DAY_OF_MONTH(%s)", args[0]);
+        } else if(dialect instanceof MySQLDialect) {
+            return String.format("DAYOFMONTH(%s)", args[0]);
+        }
+        throw new UnsupportedOperationException("DATE/TIME functions not 
supported in dialect "+dialect);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type 
casting inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public OPTypes getReturnType() {
+        return OPTypes.INT;
+    }
+
+    /**
+     * Get the argument type of the function for the arg'th argument (starting 
to count at 0).
+     * This is needed for SQL type casting inside KiWi.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public OPTypes getArgumentType(int arg) {
+        return OPTypes.DATE;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 1;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 1;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/67c2b878/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/datetime/NHours.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/datetime/NHours.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/datetime/NHours.java
new file mode 100644
index 0000000..00e44ef
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/datetime/NHours.java
@@ -0,0 +1,106 @@
+/*
+ * 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.
+ */
+
+package org.apache.marmotta.kiwi.sparql.function.datetime;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.h2.H2Dialect;
+import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.OPTypes;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.openrdf.query.algebra.evaluation.function.datetime.Hours;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert ([email protected])
+ */
+public class NHours extends Hours implements NativeFunction {
+
+    /**
+     * Return true if this function has available native support for the given 
dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect || dialect instanceof 
H2Dialect || dialect instanceof MySQLDialect;
+    }
+
+    /**
+     * Return a string representing how this function is translated into SQL 
in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        if (dialect instanceof PostgreSQLDialect) {
+            return String.format("extract(hour from %s)", args[0]);
+        } else if (dialect instanceof H2Dialect) {
+            return String.format("HOUR(%s)", args[0]);
+        } else if(dialect instanceof MySQLDialect) {
+            return String.format("HOUR(%s)", args[0]);
+        }
+        throw new UnsupportedOperationException("DATE/TIME functions not 
supported in dialect "+dialect);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type 
casting inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public OPTypes getReturnType() {
+        return OPTypes.INT;
+    }
+
+    /**
+     * Get the argument type of the function for the arg'th argument (starting 
to count at 0).
+     * This is needed for SQL type casting inside KiWi.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public OPTypes getArgumentType(int arg) {
+        return OPTypes.DATE;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 1;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 1;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/67c2b878/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/datetime/NMinutes.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/datetime/NMinutes.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/datetime/NMinutes.java
new file mode 100644
index 0000000..f8aaae6
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/datetime/NMinutes.java
@@ -0,0 +1,106 @@
+/*
+ * 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.
+ */
+
+package org.apache.marmotta.kiwi.sparql.function.datetime;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.h2.H2Dialect;
+import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.OPTypes;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.openrdf.query.algebra.evaluation.function.datetime.Minutes;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert ([email protected])
+ */
+public class NMinutes extends Minutes implements NativeFunction {
+
+    /**
+     * Return true if this function has available native support for the given 
dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect || dialect instanceof 
H2Dialect || dialect instanceof MySQLDialect;
+    }
+
+    /**
+     * Return a string representing how this function is translated into SQL 
in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        if (dialect instanceof PostgreSQLDialect) {
+            return String.format("extract(minute from %s)", args[0]);
+        } else if (dialect instanceof H2Dialect) {
+            return String.format("MINUTE(%s)", args[0]);
+        } else if(dialect instanceof MySQLDialect) {
+            return String.format("MINUTE(%s)", args[0]);
+        }
+        throw new UnsupportedOperationException("DATE/TIME functions not 
supported in dialect "+dialect);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type 
casting inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public OPTypes getReturnType() {
+        return OPTypes.INT;
+    }
+
+    /**
+     * Get the argument type of the function for the arg'th argument (starting 
to count at 0).
+     * This is needed for SQL type casting inside KiWi.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public OPTypes getArgumentType(int arg) {
+        return OPTypes.DATE;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 1;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 1;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/67c2b878/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/datetime/NMonth.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/datetime/NMonth.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/datetime/NMonth.java
new file mode 100644
index 0000000..d0a38e6
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/datetime/NMonth.java
@@ -0,0 +1,106 @@
+/*
+ * 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.
+ */
+
+package org.apache.marmotta.kiwi.sparql.function.datetime;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.h2.H2Dialect;
+import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.OPTypes;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.openrdf.query.algebra.evaluation.function.datetime.Month;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert ([email protected])
+ */
+public class NMonth extends Month implements NativeFunction {
+
+    /**
+     * Return true if this function has available native support for the given 
dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect || dialect instanceof 
H2Dialect || dialect instanceof MySQLDialect;
+    }
+
+    /**
+     * Return a string representing how this function is translated into SQL 
in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        if (dialect instanceof PostgreSQLDialect) {
+            return String.format("extract(month from %s)", args[0]);
+        } else if (dialect instanceof H2Dialect) {
+            return String.format("MONTH(%s)", args[0]);
+        } else if(dialect instanceof MySQLDialect) {
+            return String.format("MONTH(%s)", args[0]);
+        }
+        throw new UnsupportedOperationException("DATE/TIME functions not 
supported in dialect "+dialect);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type 
casting inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public OPTypes getReturnType() {
+        return OPTypes.INT;
+    }
+
+    /**
+     * Get the argument type of the function for the arg'th argument (starting 
to count at 0).
+     * This is needed for SQL type casting inside KiWi.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public OPTypes getArgumentType(int arg) {
+        return OPTypes.DATE;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 1;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 1;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/67c2b878/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/datetime/NNow.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/datetime/NNow.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/datetime/NNow.java
new file mode 100644
index 0000000..ef6d9be
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/datetime/NNow.java
@@ -0,0 +1,99 @@
+/*
+ * 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.
+ */
+
+package org.apache.marmotta.kiwi.sparql.function.datetime;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.h2.H2Dialect;
+import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.OPTypes;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.openrdf.query.algebra.evaluation.function.datetime.Now;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert ([email protected])
+ */
+public class NNow extends Now implements NativeFunction {
+
+    /**
+     * Return true if this function has available native support for the given 
dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect || dialect instanceof 
H2Dialect || dialect instanceof MySQLDialect;
+    }
+
+    /**
+     * Return a string representing how this function is translated into SQL 
in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        return "now()";
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type 
casting inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public OPTypes getReturnType() {
+        return OPTypes.DATE;
+    }
+
+    /**
+     * Get the argument type of the function for the arg'th argument (starting 
to count at 0).
+     * This is needed for SQL type casting inside KiWi.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public OPTypes getArgumentType(int arg) {
+        return OPTypes.ANY;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 0;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 0;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/67c2b878/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/datetime/NSeconds.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/datetime/NSeconds.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/datetime/NSeconds.java
new file mode 100644
index 0000000..72d01d4
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/datetime/NSeconds.java
@@ -0,0 +1,106 @@
+/*
+ * 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.
+ */
+
+package org.apache.marmotta.kiwi.sparql.function.datetime;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.h2.H2Dialect;
+import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.OPTypes;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.openrdf.query.algebra.evaluation.function.datetime.Seconds;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert ([email protected])
+ */
+public class NSeconds extends Seconds implements NativeFunction {
+
+    /**
+     * Return true if this function has available native support for the given 
dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect || dialect instanceof 
H2Dialect || dialect instanceof MySQLDialect;
+    }
+
+    /**
+     * Return a string representing how this function is translated into SQL 
in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        if (dialect instanceof PostgreSQLDialect) {
+            return String.format("extract(second from %s)", args[0]);
+        } else if (dialect instanceof H2Dialect) {
+            return String.format("MINUTE(%s) + EXTRACT(MILLISECOND FROM 
%s)/1000.0", args[0], args[0]);
+        } else if(dialect instanceof MySQLDialect) {
+            return String.format("SECOND(%s) + MICROSECOND(%s)/1000000.0", 
args[0], args[0]);
+        }
+        throw new UnsupportedOperationException("DATE/TIME functions not 
supported in dialect "+dialect);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type 
casting inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public OPTypes getReturnType() {
+        return OPTypes.DOUBLE;
+    }
+
+    /**
+     * Get the argument type of the function for the arg'th argument (starting 
to count at 0).
+     * This is needed for SQL type casting inside KiWi.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public OPTypes getArgumentType(int arg) {
+        return OPTypes.DATE;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 1;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 1;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/67c2b878/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/datetime/NYear.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/datetime/NYear.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/datetime/NYear.java
new file mode 100644
index 0000000..3846d9d
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/datetime/NYear.java
@@ -0,0 +1,106 @@
+/*
+ * 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.
+ */
+
+package org.apache.marmotta.kiwi.sparql.function.datetime;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.h2.H2Dialect;
+import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.OPTypes;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.openrdf.query.algebra.evaluation.function.datetime.Year;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert ([email protected])
+ */
+public class NYear extends Year implements NativeFunction {
+
+    /**
+     * Return true if this function has available native support for the given 
dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect || dialect instanceof 
H2Dialect || dialect instanceof MySQLDialect;
+    }
+
+    /**
+     * Return a string representing how this function is translated into SQL 
in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        if (dialect instanceof PostgreSQLDialect) {
+            return String.format("extract(year from %s)", args[0]);
+        } else if (dialect instanceof H2Dialect) {
+            return String.format("YEAR(%s)", args[0]);
+        } else if(dialect instanceof MySQLDialect) {
+            return String.format("YEAR(%s)", args[0]);
+        }
+        throw new UnsupportedOperationException("DATE/TIME functions not 
supported in dialect "+dialect);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type 
casting inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public OPTypes getReturnType() {
+        return OPTypes.INT;
+    }
+
+    /**
+     * Get the argument type of the function for the arg'th argument (starting 
to count at 0).
+     * This is needed for SQL type casting inside KiWi.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public OPTypes getArgumentType(int arg) {
+        return OPTypes.DATE;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 1;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 1;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/67c2b878/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/hash/NMD5.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/hash/NMD5.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/hash/NMD5.java
new file mode 100644
index 0000000..8aa9fc2
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/hash/NMD5.java
@@ -0,0 +1,103 @@
+/*
+ * 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.
+ */
+
+package org.apache.marmotta.kiwi.sparql.function.hash;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.OPTypes;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.openrdf.query.algebra.evaluation.function.hash.MD5;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert ([email protected])
+ */
+public class NMD5 extends MD5 implements NativeFunction {
+
+    /**
+     * Return true if this function has available native support for the given 
dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect || dialect instanceof 
MySQLDialect;
+    }
+
+    /**
+     * Return a string representing how this function is translated into SQL 
in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        if (dialect instanceof PostgreSQLDialect) {
+            return String.format("encode(digest(%s, 'md5'), 'hex')", args[0]);
+        } else if(dialect instanceof MySQLDialect) {
+            return String.format("MD5(%s)", args[0]);
+        }
+        throw new UnsupportedOperationException("MD5 not supported in dialect 
"+dialect);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type 
casting inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public OPTypes getReturnType() {
+        return OPTypes.STRING;
+    }
+
+    /**
+     * Get the argument type of the function for the arg'th argument (starting 
to count at 0).
+     * This is needed for SQL type casting inside KiWi.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public OPTypes getArgumentType(int arg) {
+        return OPTypes.STRING;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 1;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 1;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/67c2b878/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/hash/NSHA1.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/hash/NSHA1.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/hash/NSHA1.java
new file mode 100644
index 0000000..8c49ac3
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/hash/NSHA1.java
@@ -0,0 +1,103 @@
+/*
+ * 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.
+ */
+
+package org.apache.marmotta.kiwi.sparql.function.hash;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.OPTypes;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.openrdf.query.algebra.evaluation.function.hash.SHA1;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert ([email protected])
+ */
+public class NSHA1 extends SHA1 implements NativeFunction {
+
+    /**
+     * Return true if this function has available native support for the given 
dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect || dialect instanceof 
MySQLDialect;
+    }
+
+    /**
+     * Return a string representing how this function is translated into SQL 
in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        if (dialect instanceof PostgreSQLDialect) {
+            return String.format("encode(digest(%s, 'sha1'), 'hex')", args[0]);
+        } else if(dialect instanceof MySQLDialect) {
+            return String.format("SHA1(%s)", args[0]);
+        }
+        throw new UnsupportedOperationException("SHA1 not supported in dialect 
"+dialect);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type 
casting inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public OPTypes getReturnType() {
+        return OPTypes.STRING;
+    }
+
+    /**
+     * Get the argument type of the function for the arg'th argument (starting 
to count at 0).
+     * This is needed for SQL type casting inside KiWi.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public OPTypes getArgumentType(int arg) {
+        return OPTypes.STRING;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 1;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 1;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/67c2b878/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/hash/NSHA256.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/hash/NSHA256.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/hash/NSHA256.java
new file mode 100644
index 0000000..64e7e54
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/hash/NSHA256.java
@@ -0,0 +1,103 @@
+/*
+ * 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.
+ */
+
+package org.apache.marmotta.kiwi.sparql.function.hash;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.OPTypes;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.openrdf.query.algebra.evaluation.function.hash.SHA256;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert ([email protected])
+ */
+public class NSHA256 extends SHA256 implements NativeFunction {
+
+    /**
+     * Return true if this function has available native support for the given 
dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect || dialect instanceof 
MySQLDialect;
+    }
+
+    /**
+     * Return a string representing how this function is translated into SQL 
in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        if (dialect instanceof PostgreSQLDialect) {
+            return String.format("encode(digest(%s, 'sha256'), 'hex')", 
args[0]);
+        } else if(dialect instanceof MySQLDialect) {
+            return String.format("SHA2(%s, 256)", args[0]);
+        }
+        throw new UnsupportedOperationException("SHA256 not supported in 
dialect "+dialect);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type 
casting inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public OPTypes getReturnType() {
+        return OPTypes.STRING;
+    }
+
+    /**
+     * Get the argument type of the function for the arg'th argument (starting 
to count at 0).
+     * This is needed for SQL type casting inside KiWi.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public OPTypes getArgumentType(int arg) {
+        return OPTypes.STRING;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 1;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 1;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/67c2b878/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/hash/NSHA384.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/hash/NSHA384.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/hash/NSHA384.java
new file mode 100644
index 0000000..faaefdf
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/hash/NSHA384.java
@@ -0,0 +1,103 @@
+/*
+ * 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.
+ */
+
+package org.apache.marmotta.kiwi.sparql.function.hash;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.OPTypes;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.openrdf.query.algebra.evaluation.function.hash.SHA384;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert ([email protected])
+ */
+public class NSHA384 extends SHA384 implements NativeFunction {
+
+    /**
+     * Return true if this function has available native support for the given 
dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect || dialect instanceof 
MySQLDialect;
+    }
+
+    /**
+     * Return a string representing how this function is translated into SQL 
in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        if (dialect instanceof PostgreSQLDialect) {
+            return String.format("encode(digest(%s, 'sha384'), 'hex')", 
args[0]);
+        } else if(dialect instanceof MySQLDialect) {
+            return String.format("SHA2(%s, 384)", args[0]);
+        }
+        throw new UnsupportedOperationException("SHA384 not supported in 
dialect "+dialect);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type 
casting inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public OPTypes getReturnType() {
+        return OPTypes.STRING;
+    }
+
+    /**
+     * Get the argument type of the function for the arg'th argument (starting 
to count at 0).
+     * This is needed for SQL type casting inside KiWi.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public OPTypes getArgumentType(int arg) {
+        return OPTypes.STRING;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 1;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 1;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/67c2b878/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/hash/NSHA512.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/hash/NSHA512.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/hash/NSHA512.java
new file mode 100644
index 0000000..59a20f6
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/hash/NSHA512.java
@@ -0,0 +1,103 @@
+/*
+ * 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.
+ */
+
+package org.apache.marmotta.kiwi.sparql.function.hash;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.OPTypes;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.openrdf.query.algebra.evaluation.function.hash.SHA512;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert ([email protected])
+ */
+public class NSHA512 extends SHA512 implements NativeFunction {
+
+    /**
+     * Return true if this function has available native support for the given 
dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect || dialect instanceof 
MySQLDialect;
+    }
+
+    /**
+     * Return a string representing how this function is translated into SQL 
in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        if (dialect instanceof PostgreSQLDialect) {
+            return String.format("encode(digest(%s, 'sha512'), 'hex')", 
args[0]);
+        } else if(dialect instanceof MySQLDialect) {
+            return String.format("SHA2(%s, 512)", args[0]);
+        }
+        throw new UnsupportedOperationException("SHA512 not supported in 
dialect "+dialect);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type 
casting inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public OPTypes getReturnType() {
+        return OPTypes.STRING;
+    }
+
+    /**
+     * Get the argument type of the function for the arg'th argument (starting 
to count at 0).
+     * This is needed for SQL type casting inside KiWi.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public OPTypes getArgumentType(int arg) {
+        return OPTypes.STRING;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 1;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 1;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/67c2b878/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/numeric/NAbs.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/numeric/NAbs.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/numeric/NAbs.java
new file mode 100644
index 0000000..d1b913d
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/numeric/NAbs.java
@@ -0,0 +1,99 @@
+/*
+ * 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.
+ */
+
+package org.apache.marmotta.kiwi.sparql.function.numeric;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.h2.H2Dialect;
+import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.OPTypes;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.openrdf.query.algebra.evaluation.function.numeric.Abs;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert ([email protected])
+ */
+public class NAbs extends Abs implements NativeFunction {
+
+    /**
+     * Return true if this function has available native support for the given 
dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect || dialect instanceof 
H2Dialect || dialect instanceof MySQLDialect;
+    }
+
+    /**
+     * Return a string representing how this function is translated into SQL 
in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        return String.format("abs(%s)", args[0]);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type 
casting inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public OPTypes getReturnType() {
+        return OPTypes.DOUBLE;
+    }
+
+    /**
+     * Get the argument type of the function for the arg'th argument (starting 
to count at 0).
+     * This is needed for SQL type casting inside KiWi.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public OPTypes getArgumentType(int arg) {
+        return OPTypes.DOUBLE;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 1;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 1;
+    }
+}

Reply via email to