[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-12 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16202446#comment-16202446
 ] 

ASF GitHub Bot commented on RYA-392:


Github user asfgit closed the pull request at:

https://github.com/apache/incubator-rya/pull/237


> Temporal Difference Function
> 
>
> Key: RYA-392
> URL: https://issues.apache.org/jira/browse/RYA-392
> Project: Rya
>  Issue Type: New Feature
>Affects Versions: 3.2.11
>Reporter: Caleb Meier
>Assignee: Caleb Meier
>
> Currently Rya does not provide a Function that determines whether two 
> temporal literals are within a given period of time of one another.  This is 
> extremely useful for filtering on query results that occurred within a fixed 
> period of time of a given instant.  Currently, if one attempts to form the 
> following filter Filter(?time1 - ?time2 < "24"^^xsd:hour), an exception will 
> be thrown if ?time1 and ?time2 are date time literals.  I propose 
> implementing a Function that takes in two temporal literals, an integer and a 
> time unit and determines whether the date times are within the prescribed 
> period of one another.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-10 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16198760#comment-16198760
 ] 

ASF GitHub Bot commented on RYA-392:


Github user jdasch commented on a diff in the pull request:

https://github.com/apache/incubator-rya/pull/237#discussion_r143750138
  
--- Diff: 
common/rya.api/src/test/java/org/apache/rya/api/functions/DateTimeWithinPeriodTest.java
 ---
@@ -0,0 +1,180 @@
+/*
+ * 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.rya.api.functions;
+
+import static org.junit.Assert.assertEquals;
+
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+
+import javax.xml.datatype.DatatypeConfigurationException;
+import javax.xml.datatype.DatatypeFactory;
+
+import org.junit.Test;
+import org.openrdf.model.Literal;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.impl.ValueFactoryImpl;
+import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException;
+
+public class DateTimeWithinPeriodTest {
+
+private static final ValueFactory vf = new ValueFactoryImpl();
+private static final Literal TRUE = vf.createLiteral(true);
+private static final Literal FALSE = vf.createLiteral(false);
+
+@Test
+public void testSeconds() throws DatatypeConfigurationException, 
ValueExprEvaluationException {
+DatatypeFactory dtf = DatatypeFactory.newInstance();
+
+ZonedDateTime zTime = ZonedDateTime.now();
+String time = zTime.format(DateTimeFormatter.ISO_INSTANT);
+
+ZonedDateTime zTime1 = zTime.minusSeconds(1);
+String time1 = zTime1.format(DateTimeFormatter.ISO_INSTANT);
+
+Literal now = vf.createLiteral(dtf.newXMLGregorianCalendar(time));
+Literal nowMinusOne = 
vf.createLiteral(dtf.newXMLGregorianCalendar(time1));
+
+DateTimeWithinPeriod func = new DateTimeWithinPeriod();
+
+assertEquals(TRUE, func.evaluate(vf, now, now, 
vf.createLiteral(1), OWLTime.SECONDS_URI));
+assertEquals(FALSE, func.evaluate(vf, now, 
nowMinusOne,vf.createLiteral(1), OWLTime.SECONDS_URI));
+assertEquals(TRUE, func.evaluate(vf, now, 
nowMinusOne,vf.createLiteral(2), OWLTime.SECONDS_URI));
+}
+
+@Test
+public void testMinutes() throws DatatypeConfigurationException, 
ValueExprEvaluationException {
+
+DatatypeFactory dtf = DatatypeFactory.newInstance();
+
+ZonedDateTime zTime = ZonedDateTime.now();
+String time = zTime.format(DateTimeFormatter.ISO_INSTANT);
+
+ZonedDateTime zTime1 = zTime.minusMinutes(1);
+String time1 = zTime1.format(DateTimeFormatter.ISO_INSTANT);
+
+Literal now = vf.createLiteral(dtf.newXMLGregorianCalendar(time));
+Literal nowMinusOne = 
vf.createLiteral(dtf.newXMLGregorianCalendar(time1));
+
+DateTimeWithinPeriod func = new DateTimeWithinPeriod();
+
+assertEquals(TRUE, func.evaluate(vf, now, 
now,vf.createLiteral(1),OWLTime.MINUTES_URI));
+assertEquals(FALSE, func.evaluate(vf, now, 
nowMinusOne,vf.createLiteral(1),OWLTime.MINUTES_URI));
+assertEquals(TRUE, func.evaluate(vf, now, 
nowMinusOne,vf.createLiteral(2),OWLTime.MINUTES_URI));
+}
+
+
+@Test
+public void testHours() throws DatatypeConfigurationException, 
ValueExprEvaluationException {
+DatatypeFactory dtf = DatatypeFactory.newInstance();
+
+ZonedDateTime zTime = ZonedDateTime.now();
+String time = zTime.format(DateTimeFormatter.ISO_INSTANT);
+
+ZonedDateTime zTime1 = zTime.minusHours(1);
+String time1 = zTime1.format(DateTimeFormatter.ISO_INSTANT);
+
+Literal now = vf.createLiteral(dtf.newXMLGregorianCalendar(time));
+Literal nowMinusOne = 

[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-10 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16198735#comment-16198735
 ] 

ASF GitHub Bot commented on RYA-392:


Github user jdasch commented on a diff in the pull request:

https://github.com/apache/incubator-rya/pull/237#discussion_r143742329
  
--- Diff: 
common/rya.api/src/main/java/org/apache/rya/api/functions/DateTimeWithinPeriod.java
 ---
@@ -0,0 +1,130 @@
+/*
+ * 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.rya.api.functions;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.time.Duration;
+import java.time.Instant;
+
+import org.openrdf.model.Literal;
+import org.openrdf.model.URI;
+import org.openrdf.model.Value;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.datatypes.XMLDatatypeUtil;
+import org.openrdf.model.vocabulary.FN;
+import org.openrdf.model.vocabulary.XMLSchema;
+import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException;
+import org.openrdf.query.algebra.evaluation.function.Function;
+
+/**
+ * This {@link Function} determines whether two {@link 
XMLSchema#DATETIME}s occur within a specified period of time of
+ * one another. The method {@link Function#evaluate(ValueFactory, 
Value...)} expects four values, where the first two
+ * values are the datetimes, the third value is an integer indicating the 
period, and the fourth value is a URI
+ * indicating the time unit of the period. The URI must be of Type 
DurationDescription in the OWL-Time ontology (see
+ * https://www.w3.org/TR/owl-time/;>https://www.w3.org/TR/owl-time/). 
Examples of valid time unit URIs can
+ * be found in the class {@link OWLTime} and below
+ * 
+ * http://www.w3.org/2006/time#days
+ * http://www.w3.org/2006/time#hours
+ * http://www.w3.org/2006/time#minutes
+ * http://www.w3.org/2006/time#seconds
+ * 
+ *
+ */
+public class DateTimeWithinPeriod implements Function {
+
+private static final String FUNCTION_URI = FN.NAMESPACE + 
"dateTimeWithin";
--- End diff --

Nit:  dateTimeWithinPeriod


> Temporal Difference Function
> 
>
> Key: RYA-392
> URL: https://issues.apache.org/jira/browse/RYA-392
> Project: Rya
>  Issue Type: New Feature
>Affects Versions: 3.2.11
>Reporter: Caleb Meier
>Assignee: Caleb Meier
>
> Currently Rya does not provide a Function that determines whether two 
> temporal literals are within a given period of time of one another.  This is 
> extremely useful for filtering on query results that occurred within a fixed 
> period of time of a given instant.  Currently, if one attempts to form the 
> following filter Filter(?time1 - ?time2 < "24"^^xsd:hour), an exception will 
> be thrown if ?time1 and ?time2 are date time literals.  I propose 
> implementing a Function that takes in two temporal literals, an integer and a 
> time unit and determines whether the date times are within the prescribed 
> period of one another.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-10 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16198733#comment-16198733
 ] 

ASF GitHub Bot commented on RYA-392:


Github user jdasch commented on a diff in the pull request:

https://github.com/apache/incubator-rya/pull/237#discussion_r143742007
  
--- Diff: 
common/rya.api/src/main/java/org/apache/rya/api/functions/OWLTime.java ---
@@ -0,0 +1,111 @@
+/*
+ * 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.rya.api.functions;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.time.temporal.ChronoUnit;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+
+import org.openrdf.model.URI;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.impl.ValueFactoryImpl;
+
+/**
+ * Constants for OWL-Time primitives in the OWL-Time namespace.
+ *
+ */
+public class OWLTime {
+
+private static final ValueFactory FACTORY = 
ValueFactoryImpl.getInstance();
+
+/**
+ * Indicates namespace of OWL-Time ontology
+ */
+public static final String NAMESPACE = "http://www.w3.org/2006/time#;;
+/**
+ * Seconds class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI SECONDS_URI = FACTORY.createURI(NAMESPACE, 
"seconds");
+/**
+ * Minutes class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI MINUTES_URI = FACTORY.createURI(NAMESPACE, 
"minutes");
+/**
+ * Hours class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI HOURS_URI = FACTORY.createURI(NAMESPACE, 
"hours");
+/**
+ * Days class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI DAYS_URI = FACTORY.createURI(NAMESPACE, 
"days");
+/**
+ * Weeks class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI WEEKS_URI = FACTORY.createURI(NAMESPACE, 
"weeks");
+
+private static final Map DURATION_MAP = new 
HashMap<>();
--- End diff --

Nit: Using an ImmutableMap would make your intent here clearer.


> Temporal Difference Function
> 
>
> Key: RYA-392
> URL: https://issues.apache.org/jira/browse/RYA-392
> Project: Rya
>  Issue Type: New Feature
>Affects Versions: 3.2.11
>Reporter: Caleb Meier
>Assignee: Caleb Meier
>
> Currently Rya does not provide a Function that determines whether two 
> temporal literals are within a given period of time of one another.  This is 
> extremely useful for filtering on query results that occurred within a fixed 
> period of time of a given instant.  Currently, if one attempts to form the 
> following filter Filter(?time1 - ?time2 < "24"^^xsd:hour), an exception will 
> be thrown if ?time1 and ?time2 are date time literals.  I propose 
> implementing a Function that takes in two temporal literals, an integer and a 
> time unit and determines whether the date times are within the prescribed 
> period of one another.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-09 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16197113#comment-16197113
 ] 

ASF GitHub Bot commented on RYA-392:


Github user asfgit commented on the issue:

https://github.com/apache/incubator-rya/pull/237
  

Refer to this link for build results (access rights to CI server needed): 

https://builds.apache.org/job/incubator-rya-master-with-optionals-pull-requests/519/



> Temporal Difference Function
> 
>
> Key: RYA-392
> URL: https://issues.apache.org/jira/browse/RYA-392
> Project: Rya
>  Issue Type: New Feature
>Affects Versions: 3.2.11
>Reporter: Caleb Meier
>Assignee: Caleb Meier
>
> Currently Rya does not provide a Function that determines whether two 
> temporal literals are within a given period of time of one another.  This is 
> extremely useful for filtering on query results that occurred within a fixed 
> period of time of a given instant.  Currently, if one attempts to form the 
> following filter Filter(?time1 - ?time2 < "24"^^xsd:hour), an exception will 
> be thrown if ?time1 and ?time2 are date time literals.  I propose 
> implementing a Function that takes in two temporal literals, an integer and a 
> time unit and determines whether the date times are within the prescribed 
> period of one another.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-09 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16197055#comment-16197055
 ] 

ASF GitHub Bot commented on RYA-392:


Github user meiercaleb commented on a diff in the pull request:

https://github.com/apache/incubator-rya/pull/237#discussion_r143482636
  
--- Diff: 
common/rya.api/src/main/java/org/apache/rya/api/functions/OWLTime.java ---
@@ -0,0 +1,114 @@
+/*
+ * 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.rya.api.functions;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.time.temporal.ChronoUnit;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+
+import org.openrdf.model.URI;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.impl.ValueFactoryImpl;
+
+/**
+ * Constants for OWL-Time primitives in the OWL-Time namespace.
+ *
+ */
+public class OWLTime {
+
+private static final ValueFactory FACTORY = 
ValueFactoryImpl.getInstance();
+
+/**
+ * Indicates namespace of OWL-Time ontology
+ */
+public static final String NAMESPACE = "http://www.w3.org/2006/time#;;
+/**
+ * Seconds class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI SECONDS_URI = FACTORY.createURI(NAMESPACE, 
"seconds");
+/**
+ * Minutes class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI MINUTES_URI = FACTORY.createURI(NAMESPACE, 
"minutes");
+/**
+ * Hours class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI HOURS_URI = FACTORY.createURI(NAMESPACE, 
"hours");
+/**
+ * Days class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI DAYS_URI = FACTORY.createURI(NAMESPACE, 
"days");
+/**
+ * Weeks class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI WEEKS_URI = FACTORY.createURI(NAMESPACE, 
"weeks");
+
+private static final Map DURATION_MAP = new 
HashMap<>();
+
+static {
+DURATION_MAP.put(SECONDS_URI, ChronoUnit.SECONDS);
+DURATION_MAP.put(MINUTES_URI, ChronoUnit.MINUTES);
+DURATION_MAP.put(HOURS_URI, ChronoUnit.HOURS);
+DURATION_MAP.put(DAYS_URI, ChronoUnit.DAYS);
+DURATION_MAP.put(WEEKS_URI, ChronoUnit.WEEKS);
+}
+
+/**
+ * Verifies whether URI is a valid OWL-Time URI that is supported by 
this class.
+ * @param durationURI - OWLTime URI indicating the time unit
--- End diff --

Done.


> Temporal Difference Function
> 
>
> Key: RYA-392
> URL: https://issues.apache.org/jira/browse/RYA-392
> Project: Rya
>  Issue Type: New Feature
>Affects Versions: 3.2.11
>Reporter: Caleb Meier
>Assignee: Caleb Meier
>
> Currently Rya does not provide a Function that determines whether two 
> temporal literals are within a given period of time of one another.  This is 
> extremely useful for filtering on query results that occurred within a fixed 
> period of time of a given instant.  Currently, if one attempts to form the 
> following filter Filter(?time1 - ?time2 < "24"^^xsd:hour), an exception will 
> be thrown if ?time1 and ?time2 are date time literals.  I propose 
> implementing a Function that takes in two temporal literals, an integer and a 
> time unit and determines whether the date times are within the prescribed 
> period of one another.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-09 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16197053#comment-16197053
 ] 

ASF GitHub Bot commented on RYA-392:


Github user meiercaleb commented on a diff in the pull request:

https://github.com/apache/incubator-rya/pull/237#discussion_r143482605
  
--- Diff: 
common/rya.api/src/main/java/org/apache/rya/api/functions/DateTimeWithinPeriod.java
 ---
@@ -0,0 +1,128 @@
+/*
+ * 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.rya.api.functions;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
+import java.time.Duration;
+import java.time.Instant;
+
+import org.openrdf.model.Literal;
+import org.openrdf.model.URI;
+import org.openrdf.model.Value;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.datatypes.XMLDatatypeUtil;
+import org.openrdf.model.vocabulary.FN;
+import org.openrdf.model.vocabulary.XMLSchema;
+import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException;
+import org.openrdf.query.algebra.evaluation.function.Function;
+
+/**
+ * This {@link Function} determines whether two {@link 
XMLSchema#DATETIME}s occur within a specified period of time of
+ * one another. The method {@link Function#evaluate(ValueFactory, 
Value...)} expects four values, where the first two
+ * values are the datetimes, the third value is an integer indicating the 
period, and the fourth value is a URI
+ * indicating the time unit of the period. The URI must be of Type 
DurationDescription in the OWL-Time ontology (see
+ * https://www.w3.org/TR/owl-time/;>https://www.w3.org/TR/owl-time/). 
Examples of valid time unit URIs can
+ * be found in the class {@link OWLTime} and below
+ * 
+ * http://www.w3.org/2006/time#days
+ * http://www.w3.org/2006/time#hours
+ * http://www.w3.org/2006/time#minutes
+ * http://www.w3.org/2006/time#seconds
+ * 
+ *
+ */
+public class DateTimeWithinPeriod implements Function {
+
+private static final String FUNCTION_URI = FN.NAMESPACE + 
"dateTimeWithin";
+
+@Override
+public String getURI() {
+return FUNCTION_URI;
+}
+
+/**
+ * Determines whether two datetimes occur within a specified period of 
time of one another. This method expects four
+ * values, where the first two values are the datetimes, the third 
value is an integer indicating the period, and
+ * the fourth value is a URI indicating the time unit of the period. 
The URI must be of Type DurationDescription in
+ * the OWL-Time ontology (see https://www.w3.org/TR/owl-time/;>https://www.w3.org/TR/owl-time/).
+ * Examples of valid time unit URIs can be found in the class {@link 
OWLTime} and below
+ * 
+ * http://www.w3.org/2006/time#days
+ * http://www.w3.org/2006/time#hours
+ * http://www.w3.org/2006/time#minutes
+ * http://www.w3.org/2006/time#seconds
+ * 
+ *
+ * @param valueFactory - factory for creating values
+ * @param values - array of Value arguments for this Function.
+ */
+@Override
+public Value evaluate(ValueFactory valueFactory, Value... values) 
throws ValueExprEvaluationException {
--- End diff --

Done.


> Temporal Difference Function
> 
>
> Key: RYA-392
> URL: https://issues.apache.org/jira/browse/RYA-392
> Project: Rya
>  Issue Type: New Feature
>Affects Versions: 3.2.11
>Reporter: Caleb Meier
>Assignee: Caleb Meier
>
> Currently Rya does not provide a Function that determines whether two 
> temporal literals are within a given period of time of one another.  This is 
> extremely useful for filtering on query results that occurred within a fixed 
> period of time of a given instant.  Currently, if one attempts to form the 
> following filter Filter(?time1 - 

[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-06 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16195225#comment-16195225
 ] 

ASF GitHub Bot commented on RYA-392:


Github user kchilton2 commented on a diff in the pull request:

https://github.com/apache/incubator-rya/pull/237#discussion_r143288947
  
--- Diff: 
common/rya.api/src/main/java/org/apache/rya/api/functions/OWLTime.java ---
@@ -0,0 +1,114 @@
+/*
+ * 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.rya.api.functions;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.time.temporal.ChronoUnit;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+
+import org.openrdf.model.URI;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.impl.ValueFactoryImpl;
+
+/**
+ * Constants for OWL-Time primitives in the OWL-Time namespace.
+ *
+ */
+public class OWLTime {
+
+private static final ValueFactory FACTORY = 
ValueFactoryImpl.getInstance();
+
+/**
+ * Indicates namespace of OWL-Time ontology
+ */
+public static final String NAMESPACE = "http://www.w3.org/2006/time#;;
+/**
+ * Seconds class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI SECONDS_URI = FACTORY.createURI(NAMESPACE, 
"seconds");
+/**
+ * Minutes class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI MINUTES_URI = FACTORY.createURI(NAMESPACE, 
"minutes");
+/**
+ * Hours class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI HOURS_URI = FACTORY.createURI(NAMESPACE, 
"hours");
+/**
+ * Days class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI DAYS_URI = FACTORY.createURI(NAMESPACE, 
"days");
+/**
+ * Weeks class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI WEEKS_URI = FACTORY.createURI(NAMESPACE, 
"weeks");
+
+private static final Map DURATION_MAP = new 
HashMap<>();
+
+static {
+DURATION_MAP.put(SECONDS_URI, ChronoUnit.SECONDS);
+DURATION_MAP.put(MINUTES_URI, ChronoUnit.MINUTES);
+DURATION_MAP.put(HOURS_URI, ChronoUnit.HOURS);
+DURATION_MAP.put(DAYS_URI, ChronoUnit.DAYS);
+DURATION_MAP.put(WEEKS_URI, ChronoUnit.WEEKS);
+}
+
+/**
+ * Verifies whether URI is a valid OWL-Time URI that is supported by 
this class.
+ * @param durationURI - OWLTime URI indicating the time unit
--- End diff --

This is a general comment through out the code in this review.


> Temporal Difference Function
> 
>
> Key: RYA-392
> URL: https://issues.apache.org/jira/browse/RYA-392
> Project: Rya
>  Issue Type: New Feature
>Affects Versions: 3.2.11
>Reporter: Caleb Meier
>Assignee: Caleb Meier
>
> Currently Rya does not provide a Function that determines whether two 
> temporal literals are within a given period of time of one another.  This is 
> extremely useful for filtering on query results that occurred within a fixed 
> period of time of a given instant.  Currently, if one attempts to form the 
> following filter Filter(?time1 - ?time2 < "24"^^xsd:hour), an exception will 
> be thrown if ?time1 and ?time2 are date time literals.  I propose 
> implementing a Function that takes in two temporal literals, an integer and a 
> time unit and determines whether the date times are within the prescribed 
> period of one another.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-06 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16195224#comment-16195224
 ] 

ASF GitHub Bot commented on RYA-392:


Github user kchilton2 commented on a diff in the pull request:

https://github.com/apache/incubator-rya/pull/237#discussion_r143286416
  
--- Diff: 
common/rya.api/src/main/java/org/apache/rya/api/functions/DateTimeWithinPeriod.java
 ---
@@ -0,0 +1,128 @@
+/*
+ * 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.rya.api.functions;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
+import java.time.Duration;
+import java.time.Instant;
+
+import org.openrdf.model.Literal;
+import org.openrdf.model.URI;
+import org.openrdf.model.Value;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.datatypes.XMLDatatypeUtil;
+import org.openrdf.model.vocabulary.FN;
+import org.openrdf.model.vocabulary.XMLSchema;
+import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException;
+import org.openrdf.query.algebra.evaluation.function.Function;
+
+/**
+ * This {@link Function} determines whether two {@link 
XMLSchema#DATETIME}s occur within a specified period of time of
+ * one another. The method {@link Function#evaluate(ValueFactory, 
Value...)} expects four values, where the first two
+ * values are the datetimes, the third value is an integer indicating the 
period, and the fourth value is a URI
+ * indicating the time unit of the period. The URI must be of Type 
DurationDescription in the OWL-Time ontology (see
+ * https://www.w3.org/TR/owl-time/;>https://www.w3.org/TR/owl-time/). 
Examples of valid time unit URIs can
+ * be found in the class {@link OWLTime} and below
+ * 
+ * http://www.w3.org/2006/time#days
+ * http://www.w3.org/2006/time#hours
+ * http://www.w3.org/2006/time#minutes
+ * http://www.w3.org/2006/time#seconds
+ * 
+ *
+ */
+public class DateTimeWithinPeriod implements Function {
+
+private static final String FUNCTION_URI = FN.NAMESPACE + 
"dateTimeWithin";
+
+@Override
+public String getURI() {
+return FUNCTION_URI;
+}
+
+/**
+ * Determines whether two datetimes occur within a specified period of 
time of one another. This method expects four
+ * values, where the first two values are the datetimes, the third 
value is an integer indicating the period, and
+ * the fourth value is a URI indicating the time unit of the period. 
The URI must be of Type DurationDescription in
+ * the OWL-Time ontology (see https://www.w3.org/TR/owl-time/;>https://www.w3.org/TR/owl-time/).
+ * Examples of valid time unit URIs can be found in the class {@link 
OWLTime} and below
+ * 
+ * http://www.w3.org/2006/time#days
+ * http://www.w3.org/2006/time#hours
+ * http://www.w3.org/2006/time#minutes
+ * http://www.w3.org/2006/time#seconds
+ * 
+ *
+ * @param valueFactory - factory for creating values
+ * @param values - array of Value arguments for this Function.
+ */
+@Override
+public Value evaluate(ValueFactory valueFactory, Value... values) 
throws ValueExprEvaluationException {
--- End diff --

Add null checks.


> Temporal Difference Function
> 
>
> Key: RYA-392
> URL: https://issues.apache.org/jira/browse/RYA-392
> Project: Rya
>  Issue Type: New Feature
>Affects Versions: 3.2.11
>Reporter: Caleb Meier
>Assignee: Caleb Meier
>
> Currently Rya does not provide a Function that determines whether two 
> temporal literals are within a given period of time of one another.  This is 
> extremely useful for filtering on query results that occurred within a fixed 
> period of time of a given instant.  Currently, if one attempts to form the 
> following filter 

[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-06 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16195226#comment-16195226
 ] 

ASF GitHub Bot commented on RYA-392:


Github user kchilton2 commented on a diff in the pull request:

https://github.com/apache/incubator-rya/pull/237#discussion_r143288900
  
--- Diff: 
common/rya.api/src/main/java/org/apache/rya/api/functions/OWLTime.java ---
@@ -0,0 +1,114 @@
+/*
+ * 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.rya.api.functions;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.time.temporal.ChronoUnit;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+
+import org.openrdf.model.URI;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.impl.ValueFactoryImpl;
+
+/**
+ * Constants for OWL-Time primitives in the OWL-Time namespace.
+ *
+ */
+public class OWLTime {
+
+private static final ValueFactory FACTORY = 
ValueFactoryImpl.getInstance();
+
+/**
+ * Indicates namespace of OWL-Time ontology
+ */
+public static final String NAMESPACE = "http://www.w3.org/2006/time#;;
+/**
+ * Seconds class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI SECONDS_URI = FACTORY.createURI(NAMESPACE, 
"seconds");
+/**
+ * Minutes class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI MINUTES_URI = FACTORY.createURI(NAMESPACE, 
"minutes");
+/**
+ * Hours class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI HOURS_URI = FACTORY.createURI(NAMESPACE, 
"hours");
+/**
+ * Days class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI DAYS_URI = FACTORY.createURI(NAMESPACE, 
"days");
+/**
+ * Weeks class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI WEEKS_URI = FACTORY.createURI(NAMESPACE, 
"weeks");
+
+private static final Map DURATION_MAP = new 
HashMap<>();
+
+static {
+DURATION_MAP.put(SECONDS_URI, ChronoUnit.SECONDS);
+DURATION_MAP.put(MINUTES_URI, ChronoUnit.MINUTES);
+DURATION_MAP.put(HOURS_URI, ChronoUnit.HOURS);
+DURATION_MAP.put(DAYS_URI, ChronoUnit.DAYS);
+DURATION_MAP.put(WEEKS_URI, ChronoUnit.WEEKS);
+}
+
+/**
+ * Verifies whether URI is a valid OWL-Time URI that is supported by 
this class.
+ * @param durationURI - OWLTime URI indicating the time unit
--- End diff --

Document your nullness contract. 

```
@param durationURI - OWLTime URI indicating the time unit. (not null)
```


> Temporal Difference Function
> 
>
> Key: RYA-392
> URL: https://issues.apache.org/jira/browse/RYA-392
> Project: Rya
>  Issue Type: New Feature
>Affects Versions: 3.2.11
>Reporter: Caleb Meier
>Assignee: Caleb Meier
>
> Currently Rya does not provide a Function that determines whether two 
> temporal literals are within a given period of time of one another.  This is 
> extremely useful for filtering on query results that occurred within a fixed 
> period of time of a given instant.  Currently, if one attempts to form the 
> following filter Filter(?time1 - ?time2 < "24"^^xsd:hour), an exception will 
> be thrown if ?time1 and ?time2 are date time literals.  I propose 
> implementing a Function that takes in two temporal literals, an integer and a 
> time unit and determines whether the date times are within the prescribed 
> period of one another.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-06 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16195147#comment-16195147
 ] 

ASF GitHub Bot commented on RYA-392:


Github user asfgit commented on the issue:

https://github.com/apache/incubator-rya/pull/237
  

Refer to this link for build results (access rights to CI server needed): 

https://builds.apache.org/job/incubator-rya-master-with-optionals-pull-requests/518/



> Temporal Difference Function
> 
>
> Key: RYA-392
> URL: https://issues.apache.org/jira/browse/RYA-392
> Project: Rya
>  Issue Type: New Feature
>Affects Versions: 3.2.11
>Reporter: Caleb Meier
>Assignee: Caleb Meier
>
> Currently Rya does not provide a Function that determines whether two 
> temporal literals are within a given period of time of one another.  This is 
> extremely useful for filtering on query results that occurred within a fixed 
> period of time of a given instant.  Currently, if one attempts to form the 
> following filter Filter(?time1 - ?time2 < "24"^^xsd:hour), an exception will 
> be thrown if ?time1 and ?time2 are date time literals.  I propose 
> implementing a Function that takes in two temporal literals, an integer and a 
> time unit and determines whether the date times are within the prescribed 
> period of one another.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-06 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16194815#comment-16194815
 ] 

ASF GitHub Bot commented on RYA-392:


Github user asfgit commented on the issue:

https://github.com/apache/incubator-rya/pull/237
  

Refer to this link for build results (access rights to CI server needed): 

https://builds.apache.org/job/incubator-rya-master-with-optionals-pull-requests/517/



> Temporal Difference Function
> 
>
> Key: RYA-392
> URL: https://issues.apache.org/jira/browse/RYA-392
> Project: Rya
>  Issue Type: New Feature
>Affects Versions: 3.2.11
>Reporter: Caleb Meier
>Assignee: Caleb Meier
>
> Currently Rya does not provide a Function that determines whether two 
> temporal literals are within a given period of time of one another.  This is 
> extremely useful for filtering on query results that occurred within a fixed 
> period of time of a given instant.  Currently, if one attempts to form the 
> following filter Filter(?time1 - ?time2 < "24"^^xsd:hour), an exception will 
> be thrown if ?time1 and ?time2 are date time literals.  I propose 
> implementing a Function that takes in two temporal literals, an integer and a 
> time unit and determines whether the date times are within the prescribed 
> period of one another.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-06 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16194782#comment-16194782
 ] 

ASF GitHub Bot commented on RYA-392:


Github user meiercaleb commented on a diff in the pull request:

https://github.com/apache/incubator-rya/pull/237#discussion_r143230685
  
--- Diff: 
common/rya.api/src/main/java/org/apache/rya/api/functions/OWLTime.java ---
@@ -0,0 +1,147 @@
+/*
+ * 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.rya.api.functions;
+
+import org.openrdf.model.URI;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.impl.ValueFactoryImpl;
+
+/**
+ * Constants for OWL-Time primitives in the OWL-Time namespace.
+ *
+ */
+public class OWLTime {
+
+/**
+ * Indicates namespace of OWL-Time ontology
+ */
+public static final String NAMESPACE = "http://www.w3.org/2006/time#;;
+/**
+ * Seconds class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI SECONDS_URI;
+/**
+ * Minutes class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI MINUTES_URI;
+/**
+ * Hours class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI HOURS_URI;
+/**
+ * Days class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI DAYS_URI;
+/**
+ * Weeks class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI WEEKS_URI;
+/**
+ * Months class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI MONTHS_URI;
+/**
+ * Years class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI YEARS_URI;
+
+public static boolean isValidDurationType(URI duration) {
+return (duration.equals(SECONDS_URI) || 
duration.equals(MINUTES_URI) || duration.equals(HOURS_URI) || 
duration.equals(DAYS_URI)
+|| duration.equals(WEEKS_URI) || 
duration.equals(MONTHS_URI) || duration.equals(YEARS_URI));
+}
+
+static {
+ValueFactory factory = ValueFactoryImpl.getInstance();
+SECONDS_URI = factory.createURI(NAMESPACE, "seconds");
+MINUTES_URI = factory.createURI(NAMESPACE, "minutes");
+HOURS_URI = factory.createURI(NAMESPACE, "hours");
+DAYS_URI = factory.createURI(NAMESPACE, "days");
+WEEKS_URI = factory.createURI(NAMESPACE, "weeks");
+MONTHS_URI = factory.createURI(NAMESPACE, "months");
+YEARS_URI = factory.createURI(NAMESPACE, "years");
+}
+
+public static enum Duration {
+SECONDS(1000, SECONDS_URI), 
+MINUTES(6, MINUTES_URI), 
+HOURS(360, HOURS_URI), 
+DAYS(8640, DAYS_URI), 
+WEEKS(60480, WEEKS_URI), 
+MONTHS(259200L, MONTHS_URI), 
+YEARS(3153600L, YEARS_URI);
+
+private final URI uri;
+private final long millisConversion;
--- End diff --

Using ChronoUnit now.


> Temporal Difference Function
> 
>
> Key: RYA-392
> URL: https://issues.apache.org/jira/browse/RYA-392
> Project: Rya
>  Issue Type: New Feature
>Affects Versions: 3.2.11
>Reporter: Caleb Meier
>Assignee: Caleb Meier
>
> Currently Rya does not provide a Function that determines whether two 
> temporal literals are within a given period of time of one another.  This is 
> extremely useful for filtering on query results that occurred within a fixed 
> period of time of a given instant.  Currently, if one attempts to form the 
> following filter Filter(?time1 - ?time2 < "24"^^xsd:hour), an exception will 
> be thrown if 

[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-06 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16194762#comment-16194762
 ] 

ASF GitHub Bot commented on RYA-392:


Github user meiercaleb commented on a diff in the pull request:

https://github.com/apache/incubator-rya/pull/237#discussion_r143227137
  
--- Diff: 
common/rya.api/src/main/java/org/apache/rya/api/functions/OWLTime.java ---
@@ -0,0 +1,147 @@
+/*
+ * 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.rya.api.functions;
+
+import org.openrdf.model.URI;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.impl.ValueFactoryImpl;
+
+/**
+ * Constants for OWL-Time primitives in the OWL-Time namespace.
+ *
+ */
+public class OWLTime {
+
+/**
+ * Indicates namespace of OWL-Time ontology
+ */
+public static final String NAMESPACE = "http://www.w3.org/2006/time#;;
+/**
+ * Seconds class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI SECONDS_URI;
+/**
+ * Minutes class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI MINUTES_URI;
+/**
+ * Hours class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI HOURS_URI;
+/**
+ * Days class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI DAYS_URI;
+/**
+ * Weeks class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI WEEKS_URI;
+/**
+ * Months class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI MONTHS_URI;
+/**
+ * Years class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI YEARS_URI;
+
+public static boolean isValidDurationType(URI duration) {
+return (duration.equals(SECONDS_URI) || 
duration.equals(MINUTES_URI) || duration.equals(HOURS_URI) || 
duration.equals(DAYS_URI)
+|| duration.equals(WEEKS_URI) || 
duration.equals(MONTHS_URI) || duration.equals(YEARS_URI));
+}
+
+static {
+ValueFactory factory = ValueFactoryImpl.getInstance();
+SECONDS_URI = factory.createURI(NAMESPACE, "seconds");
+MINUTES_URI = factory.createURI(NAMESPACE, "minutes");
+HOURS_URI = factory.createURI(NAMESPACE, "hours");
+DAYS_URI = factory.createURI(NAMESPACE, "days");
+WEEKS_URI = factory.createURI(NAMESPACE, "weeks");
+MONTHS_URI = factory.createURI(NAMESPACE, "months");
+YEARS_URI = factory.createURI(NAMESPACE, "years");
+}
+
+public static enum Duration {
+SECONDS(1000, SECONDS_URI), 
+MINUTES(6, MINUTES_URI), 
+HOURS(360, HOURS_URI), 
+DAYS(8640, DAYS_URI), 
+WEEKS(60480, WEEKS_URI), 
+MONTHS(259200L, MONTHS_URI), 
+YEARS(3153600L, YEARS_URI);
+
+private final URI uri;
+private final long millisConversion;
+
+Duration(long millisConversion, URI uri) {
+this.uri = uri;
+this.millisConversion = millisConversion;
+}
+
+public long millisConversion() {
+return millisConversion;
+}
+
+public URI uri() {
+return uri;
+}
+
+/**
+ * Returns the duration in milliseconds
+ * 
+ * @param duration - amount of time in the units indicated by the 
provided {@link OWLTime} URI
+ * @param uri - OWLTime URI indicating the time unit of duration
+ * @return - the amount of time in milliseconds 
+ */
+public static long getMillis(int duration, URI uri) {
+  

[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-06 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16194758#comment-16194758
 ] 

ASF GitHub Bot commented on RYA-392:


Github user meiercaleb commented on a diff in the pull request:

https://github.com/apache/incubator-rya/pull/237#discussion_r143226973
  
--- Diff: 
common/rya.api/src/main/java/org/apache/rya/api/functions/OWLTime.java ---
@@ -0,0 +1,147 @@
+/*
+ * 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.rya.api.functions;
+
+import org.openrdf.model.URI;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.impl.ValueFactoryImpl;
+
+/**
+ * Constants for OWL-Time primitives in the OWL-Time namespace.
+ *
+ */
+public class OWLTime {
+
+/**
+ * Indicates namespace of OWL-Time ontology
+ */
+public static final String NAMESPACE = "http://www.w3.org/2006/time#;;
+/**
+ * Seconds class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI SECONDS_URI;
+/**
+ * Minutes class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI MINUTES_URI;
+/**
+ * Hours class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI HOURS_URI;
+/**
+ * Days class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI DAYS_URI;
+/**
+ * Weeks class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI WEEKS_URI;
+/**
+ * Months class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI MONTHS_URI;
+/**
+ * Years class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI YEARS_URI;
+
+public static boolean isValidDurationType(URI duration) {
+return (duration.equals(SECONDS_URI) || 
duration.equals(MINUTES_URI) || duration.equals(HOURS_URI) || 
duration.equals(DAYS_URI)
+|| duration.equals(WEEKS_URI) || 
duration.equals(MONTHS_URI) || duration.equals(YEARS_URI));
+}
+
+static {
+ValueFactory factory = ValueFactoryImpl.getInstance();
+SECONDS_URI = factory.createURI(NAMESPACE, "seconds");
+MINUTES_URI = factory.createURI(NAMESPACE, "minutes");
+HOURS_URI = factory.createURI(NAMESPACE, "hours");
+DAYS_URI = factory.createURI(NAMESPACE, "days");
+WEEKS_URI = factory.createURI(NAMESPACE, "weeks");
+MONTHS_URI = factory.createURI(NAMESPACE, "months");
+YEARS_URI = factory.createURI(NAMESPACE, "years");
+}
+
+public static enum Duration {
--- End diff --

This class has been removed.


> Temporal Difference Function
> 
>
> Key: RYA-392
> URL: https://issues.apache.org/jira/browse/RYA-392
> Project: Rya
>  Issue Type: New Feature
>Affects Versions: 3.2.11
>Reporter: Caleb Meier
>Assignee: Caleb Meier
>
> Currently Rya does not provide a Function that determines whether two 
> temporal literals are within a given period of time of one another.  This is 
> extremely useful for filtering on query results that occurred within a fixed 
> period of time of a given instant.  Currently, if one attempts to form the 
> following filter Filter(?time1 - ?time2 < "24"^^xsd:hour), an exception will 
> be thrown if ?time1 and ?time2 are date time literals.  I propose 
> implementing a Function that takes in two temporal literals, an integer and a 
> time unit and determines whether the date times are within the prescribed 
> period of one another.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-06 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16194759#comment-16194759
 ] 

ASF GitHub Bot commented on RYA-392:


Github user meiercaleb commented on a diff in the pull request:

https://github.com/apache/incubator-rya/pull/237#discussion_r143227030
  
--- Diff: 
common/rya.api/src/main/java/org/apache/rya/api/functions/OWLTime.java ---
@@ -0,0 +1,147 @@
+/*
+ * 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.rya.api.functions;
+
+import org.openrdf.model.URI;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.impl.ValueFactoryImpl;
+
+/**
+ * Constants for OWL-Time primitives in the OWL-Time namespace.
+ *
+ */
+public class OWLTime {
+
+/**
+ * Indicates namespace of OWL-Time ontology
+ */
+public static final String NAMESPACE = "http://www.w3.org/2006/time#;;
+/**
+ * Seconds class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI SECONDS_URI;
+/**
+ * Minutes class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI MINUTES_URI;
+/**
+ * Hours class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI HOURS_URI;
+/**
+ * Days class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI DAYS_URI;
+/**
+ * Weeks class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI WEEKS_URI;
+/**
+ * Months class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI MONTHS_URI;
+/**
+ * Years class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI YEARS_URI;
+
+public static boolean isValidDurationType(URI duration) {
+return (duration.equals(SECONDS_URI) || 
duration.equals(MINUTES_URI) || duration.equals(HOURS_URI) || 
duration.equals(DAYS_URI)
+|| duration.equals(WEEKS_URI) || 
duration.equals(MONTHS_URI) || duration.equals(YEARS_URI));
+}
+
+static {
+ValueFactory factory = ValueFactoryImpl.getInstance();
+SECONDS_URI = factory.createURI(NAMESPACE, "seconds");
+MINUTES_URI = factory.createURI(NAMESPACE, "minutes");
+HOURS_URI = factory.createURI(NAMESPACE, "hours");
+DAYS_URI = factory.createURI(NAMESPACE, "days");
+WEEKS_URI = factory.createURI(NAMESPACE, "weeks");
+MONTHS_URI = factory.createURI(NAMESPACE, "months");
+YEARS_URI = factory.createURI(NAMESPACE, "years");
+}
+
+public static enum Duration {
+SECONDS(1000, SECONDS_URI), 
+MINUTES(6, MINUTES_URI), 
+HOURS(360, HOURS_URI), 
+DAYS(8640, DAYS_URI), 
+WEEKS(60480, WEEKS_URI), 
+MONTHS(259200L, MONTHS_URI), 
+YEARS(3153600L, YEARS_URI);
+
+private final URI uri;
+private final long millisConversion;
+
+Duration(long millisConversion, URI uri) {
+this.uri = uri;
+this.millisConversion = millisConversion;
+}
+
+public long millisConversion() {
+return millisConversion;
+}
+
+public URI uri() {
+return uri;
+}
+
+/**
+ * Returns the duration in milliseconds
+ * 
+ * @param duration - amount of time in the units indicated by the 
provided {@link OWLTime} URI
+ * @param uri - OWLTime URI indicating the time unit of duration
+ * @return - the amount of time in milliseconds 
+ */
+public static long getMillis(int duration, URI uri) {
+  

[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-06 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16194756#comment-16194756
 ] 

ASF GitHub Bot commented on RYA-392:


Github user meiercaleb commented on a diff in the pull request:

https://github.com/apache/incubator-rya/pull/237#discussion_r143226896
  
--- Diff: 
common/rya.api/src/main/java/org/apache/rya/api/functions/OWLTime.java ---
@@ -0,0 +1,147 @@
+/*
+ * 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.rya.api.functions;
+
+import org.openrdf.model.URI;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.impl.ValueFactoryImpl;
+
+/**
+ * Constants for OWL-Time primitives in the OWL-Time namespace.
+ *
+ */
+public class OWLTime {
+
+/**
+ * Indicates namespace of OWL-Time ontology
+ */
+public static final String NAMESPACE = "http://www.w3.org/2006/time#;;
+/**
+ * Seconds class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI SECONDS_URI;
+/**
+ * Minutes class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI MINUTES_URI;
+/**
+ * Hours class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI HOURS_URI;
+/**
+ * Days class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI DAYS_URI;
+/**
+ * Weeks class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI WEEKS_URI;
+/**
+ * Months class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI MONTHS_URI;
+/**
+ * Years class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI YEARS_URI;
+
+public static boolean isValidDurationType(URI duration) {
+return (duration.equals(SECONDS_URI) || 
duration.equals(MINUTES_URI) || duration.equals(HOURS_URI) || 
duration.equals(DAYS_URI)
+|| duration.equals(WEEKS_URI) || 
duration.equals(MONTHS_URI) || duration.equals(YEARS_URI));
+}
+
+static {
--- End diff --

Done.


> Temporal Difference Function
> 
>
> Key: RYA-392
> URL: https://issues.apache.org/jira/browse/RYA-392
> Project: Rya
>  Issue Type: New Feature
>Affects Versions: 3.2.11
>Reporter: Caleb Meier
>Assignee: Caleb Meier
>
> Currently Rya does not provide a Function that determines whether two 
> temporal literals are within a given period of time of one another.  This is 
> extremely useful for filtering on query results that occurred within a fixed 
> period of time of a given instant.  Currently, if one attempts to form the 
> following filter Filter(?time1 - ?time2 < "24"^^xsd:hour), an exception will 
> be thrown if ?time1 and ?time2 are date time literals.  I propose 
> implementing a Function that takes in two temporal literals, an integer and a 
> time unit and determines whether the date times are within the prescribed 
> period of one another.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-06 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16194755#comment-16194755
 ] 

ASF GitHub Bot commented on RYA-392:


Github user meiercaleb commented on a diff in the pull request:

https://github.com/apache/incubator-rya/pull/237#discussion_r143226837
  
--- Diff: 
common/rya.api/src/main/java/org/apache/rya/api/functions/OWLTime.java ---
@@ -0,0 +1,147 @@
+/*
+ * 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.rya.api.functions;
+
+import org.openrdf.model.URI;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.impl.ValueFactoryImpl;
+
+/**
+ * Constants for OWL-Time primitives in the OWL-Time namespace.
+ *
+ */
+public class OWLTime {
+
+/**
+ * Indicates namespace of OWL-Time ontology
+ */
+public static final String NAMESPACE = "http://www.w3.org/2006/time#;;
+/**
+ * Seconds class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI SECONDS_URI;
+/**
+ * Minutes class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI MINUTES_URI;
+/**
+ * Hours class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI HOURS_URI;
+/**
+ * Days class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI DAYS_URI;
+/**
+ * Weeks class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI WEEKS_URI;
+/**
+ * Months class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI MONTHS_URI;
+/**
+ * Years class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI YEARS_URI;
+
+public static boolean isValidDurationType(URI duration) {
--- End diff --

Done.


> Temporal Difference Function
> 
>
> Key: RYA-392
> URL: https://issues.apache.org/jira/browse/RYA-392
> Project: Rya
>  Issue Type: New Feature
>Affects Versions: 3.2.11
>Reporter: Caleb Meier
>Assignee: Caleb Meier
>
> Currently Rya does not provide a Function that determines whether two 
> temporal literals are within a given period of time of one another.  This is 
> extremely useful for filtering on query results that occurred within a fixed 
> period of time of a given instant.  Currently, if one attempts to form the 
> following filter Filter(?time1 - ?time2 < "24"^^xsd:hour), an exception will 
> be thrown if ?time1 and ?time2 are date time literals.  I propose 
> implementing a Function that takes in two temporal literals, an integer and a 
> time unit and determines whether the date times are within the prescribed 
> period of one another.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-05 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16193731#comment-16193731
 ] 

ASF GitHub Bot commented on RYA-392:


Github user meiercaleb commented on a diff in the pull request:

https://github.com/apache/incubator-rya/pull/237#discussion_r143054724
  
--- Diff: 
common/rya.api/src/main/java/org/apache/rya/api/functions/DateTimeWithinPeriod.java
 ---
@@ -0,0 +1,121 @@
+/*
+ * 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.rya.api.functions;
+
+import org.apache.rya.api.functions.OWLTime.Duration;
+import org.openrdf.model.Literal;
+import org.openrdf.model.URI;
+import org.openrdf.model.Value;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.datatypes.XMLDatatypeUtil;
+import org.openrdf.model.vocabulary.FN;
+import org.openrdf.model.vocabulary.XMLSchema;
+import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException;
+import org.openrdf.query.algebra.evaluation.function.Function;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * This {@link Function} determines whether two datetimes occur within a 
specified period of time of one another. The
+ * method {@link Function#evaluate(ValueFactory, Value...)} expects four 
values, where the first two values are the
+ * datetimes, the third value is an integer indicating the period, and the 
fourth value is a URI indicating the time
+ * unit of the period. The URI must be of Type DurationDescription in the 
OWL-Time ontology (see
+ * https://www.w3.org/TR/owl-time/;>https://www.w3.org/TR/owl-time/). 
Examples of valid time unit URIs
+ * can be found in the class {@link OWLTime} and below
+ * 
+ * http://www.w3.org/2006/time#days
+ * http://www.w3.org/2006/time#hours
+ * http://www.w3.org/2006/time#minutes
+ * http://www.w3.org/2006/time#seconds
+ * 
+ * 
+ */
+public class DateTimeWithinPeriod implements Function {
+
+private static final String DATE_TIME_WITHIN = "dateTimeWithin";
+
+@Override
+public String getURI() {
+return FN.NAMESPACE.toString() + DATE_TIME_WITHIN;
+}
+
+/**
+ * Determines whether two datetimes occur within a specified period of 
time of one another. This method expects four
+ * values, where the first two values are the datetimes, the third 
value is an integer indicating the period, and
+ * the fourth value is a URI indicating the time unit of the period. 
The URI must be of Type DurationDescription in
+ * the OWL-Time ontology (see https://www.w3.org/TR/owl-time/;>https://www.w3.org/TR/owl-time/).
+ * Examples of valid time unit URIs can be found in the class {@link 
OWLTime} and below
+ * 
+ * http://www.w3.org/2006/time#days
+ * http://www.w3.org/2006/time#hours
+ * http://www.w3.org/2006/time#minutes
+ * http://www.w3.org/2006/time#seconds
+ * 
+ * 
+ * @param valueFactory - factory for creating values
+ * @param values - array of Value arguments for this Function.
+ */
+@Override
+public Value evaluate(ValueFactory valueFactory, Value... values) 
throws ValueExprEvaluationException {
+
+// general validation of input
+Preconditions.checkArgument(values.length == 4);
--- End diff --

Done


> Temporal Difference Function
> 
>
> Key: RYA-392
> URL: https://issues.apache.org/jira/browse/RYA-392
> Project: Rya
>  Issue Type: New Feature
>Affects Versions: 3.2.11
>Reporter: Caleb Meier
>Assignee: Caleb Meier
>
> Currently Rya does not provide a Function that determines whether two 
> temporal literals are within a given period of time of one another.  This is 
> extremely useful for filtering on query results that occurred within a fixed 
> period of time of a given 

[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-05 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16193732#comment-16193732
 ] 

ASF GitHub Bot commented on RYA-392:


Github user meiercaleb commented on a diff in the pull request:

https://github.com/apache/incubator-rya/pull/237#discussion_r143060815
  
--- Diff: 
common/rya.api/src/test/java/org/apache/rya/api/functions/DateTimeWithinTest.java
 ---
@@ -0,0 +1,184 @@
+/*
+ * 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.rya.api.functions;
+
+import static org.junit.Assert.assertEquals;
+
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+
+import javax.xml.datatype.DatatypeConfigurationException;
+import javax.xml.datatype.DatatypeFactory;
+
+import org.junit.Test;
+import org.openrdf.model.Literal;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.impl.ValueFactoryImpl;
+import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException;
+
+public class DateTimeWithinTest {
+
+private static final ValueFactory vf = new ValueFactoryImpl();
+private static final Literal TRUE = vf.createLiteral(true);
+private static final Literal FALSE = vf.createLiteral(false);
+
+@Test 
+public void testSeconds() throws DatatypeConfigurationException, 
ValueExprEvaluationException {
+DatatypeFactory dtf = DatatypeFactory.newInstance();
+
+ZonedDateTime zTime = ZonedDateTime.now();
+String time = zTime.format(DateTimeFormatter.ISO_INSTANT);
+
+ZonedDateTime zTime1 = zTime.minusSeconds(1);
--- End diff --

Updated names.


> Temporal Difference Function
> 
>
> Key: RYA-392
> URL: https://issues.apache.org/jira/browse/RYA-392
> Project: Rya
>  Issue Type: New Feature
>Affects Versions: 3.2.11
>Reporter: Caleb Meier
>Assignee: Caleb Meier
>
> Currently Rya does not provide a Function that determines whether two 
> temporal literals are within a given period of time of one another.  This is 
> extremely useful for filtering on query results that occurred within a fixed 
> period of time of a given instant.  Currently, if one attempts to form the 
> following filter Filter(?time1 - ?time2 < "24"^^xsd:hour), an exception will 
> be thrown if ?time1 and ?time2 are date time literals.  I propose 
> implementing a Function that takes in two temporal literals, an integer and a 
> time unit and determines whether the date times are within the prescribed 
> period of one another.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-05 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16193728#comment-16193728
 ] 

ASF GitHub Bot commented on RYA-392:


Github user meiercaleb commented on a diff in the pull request:

https://github.com/apache/incubator-rya/pull/237#discussion_r143049589
  
--- Diff: common/rya.api/pom.xml ---
@@ -95,5 +95,20 @@ under the License.
 test
 
 
+
+
+
+org.apache.rat
+apache-rat-plugin
+
+
+
+
src/main/resources/META-INF/services/org.openrdf.query.algebra.evaluation.function.Function
--- End diff --

Done.


> Temporal Difference Function
> 
>
> Key: RYA-392
> URL: https://issues.apache.org/jira/browse/RYA-392
> Project: Rya
>  Issue Type: New Feature
>Affects Versions: 3.2.11
>Reporter: Caleb Meier
>Assignee: Caleb Meier
>
> Currently Rya does not provide a Function that determines whether two 
> temporal literals are within a given period of time of one another.  This is 
> extremely useful for filtering on query results that occurred within a fixed 
> period of time of a given instant.  Currently, if one attempts to form the 
> following filter Filter(?time1 - ?time2 < "24"^^xsd:hour), an exception will 
> be thrown if ?time1 and ?time2 are date time literals.  I propose 
> implementing a Function that takes in two temporal literals, an integer and a 
> time unit and determines whether the date times are within the prescribed 
> period of one another.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-05 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16193735#comment-16193735
 ] 

ASF GitHub Bot commented on RYA-392:


Github user meiercaleb commented on a diff in the pull request:

https://github.com/apache/incubator-rya/pull/237#discussion_r143054683
  
--- Diff: 
common/rya.api/src/main/java/org/apache/rya/api/functions/DateTimeWithinPeriod.java
 ---
@@ -0,0 +1,121 @@
+/*
+ * 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.rya.api.functions;
+
+import org.apache.rya.api.functions.OWLTime.Duration;
+import org.openrdf.model.Literal;
+import org.openrdf.model.URI;
+import org.openrdf.model.Value;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.datatypes.XMLDatatypeUtil;
+import org.openrdf.model.vocabulary.FN;
+import org.openrdf.model.vocabulary.XMLSchema;
+import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException;
+import org.openrdf.query.algebra.evaluation.function.Function;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * This {@link Function} determines whether two datetimes occur within a 
specified period of time of one another. The
+ * method {@link Function#evaluate(ValueFactory, Value...)} expects four 
values, where the first two values are the
+ * datetimes, the third value is an integer indicating the period, and the 
fourth value is a URI indicating the time
+ * unit of the period. The URI must be of Type DurationDescription in the 
OWL-Time ontology (see
+ * https://www.w3.org/TR/owl-time/;>https://www.w3.org/TR/owl-time/). 
Examples of valid time unit URIs
+ * can be found in the class {@link OWLTime} and below
+ * 
+ * http://www.w3.org/2006/time#days
+ * http://www.w3.org/2006/time#hours
+ * http://www.w3.org/2006/time#minutes
+ * http://www.w3.org/2006/time#seconds
+ * 
+ * 
+ */
+public class DateTimeWithinPeriod implements Function {
--- End diff --

Done


> Temporal Difference Function
> 
>
> Key: RYA-392
> URL: https://issues.apache.org/jira/browse/RYA-392
> Project: Rya
>  Issue Type: New Feature
>Affects Versions: 3.2.11
>Reporter: Caleb Meier
>Assignee: Caleb Meier
>
> Currently Rya does not provide a Function that determines whether two 
> temporal literals are within a given period of time of one another.  This is 
> extremely useful for filtering on query results that occurred within a fixed 
> period of time of a given instant.  Currently, if one attempts to form the 
> following filter Filter(?time1 - ?time2 < "24"^^xsd:hour), an exception will 
> be thrown if ?time1 and ?time2 are date time literals.  I propose 
> implementing a Function that takes in two temporal literals, an integer and a 
> time unit and determines whether the date times are within the prescribed 
> period of one another.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-05 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16193729#comment-16193729
 ] 

ASF GitHub Bot commented on RYA-392:


Github user meiercaleb commented on a diff in the pull request:

https://github.com/apache/incubator-rya/pull/237#discussion_r143050918
  
--- Diff: 
common/rya.api/src/main/java/org/apache/rya/api/functions/DateTimeWithinPeriod.java
 ---
@@ -0,0 +1,121 @@
+/*
+ * 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.rya.api.functions;
+
+import org.apache.rya.api.functions.OWLTime.Duration;
+import org.openrdf.model.Literal;
+import org.openrdf.model.URI;
+import org.openrdf.model.Value;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.datatypes.XMLDatatypeUtil;
+import org.openrdf.model.vocabulary.FN;
+import org.openrdf.model.vocabulary.XMLSchema;
+import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException;
+import org.openrdf.query.algebra.evaluation.function.Function;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * This {@link Function} determines whether two datetimes occur within a 
specified period of time of one another. The
+ * method {@link Function#evaluate(ValueFactory, Value...)} expects four 
values, where the first two values are the
+ * datetimes, the third value is an integer indicating the period, and the 
fourth value is a URI indicating the time
+ * unit of the period. The URI must be of Type DurationDescription in the 
OWL-Time ontology (see
+ * https://www.w3.org/TR/owl-time/;>https://www.w3.org/TR/owl-time/). 
Examples of valid time unit URIs
+ * can be found in the class {@link OWLTime} and below
+ * 
+ * http://www.w3.org/2006/time#days
+ * http://www.w3.org/2006/time#hours
+ * http://www.w3.org/2006/time#minutes
+ * http://www.w3.org/2006/time#seconds
+ * 
+ * 
+ */
+public class DateTimeWithinPeriod implements Function {
+
+private static final String DATE_TIME_WITHIN = "dateTimeWithin";
+
+@Override
+public String getURI() {
+return FN.NAMESPACE.toString() + DATE_TIME_WITHIN;
+}
+
--- End diff --

Done.


> Temporal Difference Function
> 
>
> Key: RYA-392
> URL: https://issues.apache.org/jira/browse/RYA-392
> Project: Rya
>  Issue Type: New Feature
>Affects Versions: 3.2.11
>Reporter: Caleb Meier
>Assignee: Caleb Meier
>
> Currently Rya does not provide a Function that determines whether two 
> temporal literals are within a given period of time of one another.  This is 
> extremely useful for filtering on query results that occurred within a fixed 
> period of time of a given instant.  Currently, if one attempts to form the 
> following filter Filter(?time1 - ?time2 < "24"^^xsd:hour), an exception will 
> be thrown if ?time1 and ?time2 are date time literals.  I propose 
> implementing a Function that takes in two temporal literals, an integer and a 
> time unit and determines whether the date times are within the prescribed 
> period of one another.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-05 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16193730#comment-16193730
 ] 

ASF GitHub Bot commented on RYA-392:


Github user meiercaleb commented on a diff in the pull request:

https://github.com/apache/incubator-rya/pull/237#discussion_r143060603
  
--- Diff: 
common/rya.api/src/main/java/org/apache/rya/api/functions/DateTimeWithinPeriod.java
 ---
@@ -0,0 +1,121 @@
+/*
+ * 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.rya.api.functions;
+
+import org.apache.rya.api.functions.OWLTime.Duration;
+import org.openrdf.model.Literal;
+import org.openrdf.model.URI;
+import org.openrdf.model.Value;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.datatypes.XMLDatatypeUtil;
+import org.openrdf.model.vocabulary.FN;
+import org.openrdf.model.vocabulary.XMLSchema;
+import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException;
+import org.openrdf.query.algebra.evaluation.function.Function;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * This {@link Function} determines whether two datetimes occur within a 
specified period of time of one another. The
+ * method {@link Function#evaluate(ValueFactory, Value...)} expects four 
values, where the first two values are the
+ * datetimes, the third value is an integer indicating the period, and the 
fourth value is a URI indicating the time
+ * unit of the period. The URI must be of Type DurationDescription in the 
OWL-Time ontology (see
+ * https://www.w3.org/TR/owl-time/;>https://www.w3.org/TR/owl-time/). 
Examples of valid time unit URIs
+ * can be found in the class {@link OWLTime} and below
+ * 
+ * http://www.w3.org/2006/time#days
+ * http://www.w3.org/2006/time#hours
+ * http://www.w3.org/2006/time#minutes
+ * http://www.w3.org/2006/time#seconds
+ * 
+ * 
+ */
+public class DateTimeWithinPeriod implements Function {
+
+private static final String DATE_TIME_WITHIN = "dateTimeWithin";
+
+@Override
+public String getURI() {
+return FN.NAMESPACE.toString() + DATE_TIME_WITHIN;
+}
+
+/**
+ * Determines whether two datetimes occur within a specified period of 
time of one another. This method expects four
+ * values, where the first two values are the datetimes, the third 
value is an integer indicating the period, and
+ * the fourth value is a URI indicating the time unit of the period. 
The URI must be of Type DurationDescription in
+ * the OWL-Time ontology (see https://www.w3.org/TR/owl-time/;>https://www.w3.org/TR/owl-time/).
+ * Examples of valid time unit URIs can be found in the class {@link 
OWLTime} and below
+ * 
+ * http://www.w3.org/2006/time#days
+ * http://www.w3.org/2006/time#hours
+ * http://www.w3.org/2006/time#minutes
+ * http://www.w3.org/2006/time#seconds
+ * 
+ * 
+ * @param valueFactory - factory for creating values
+ * @param values - array of Value arguments for this Function.
+ */
+@Override
+public Value evaluate(ValueFactory valueFactory, Value... values) 
throws ValueExprEvaluationException {
+
+// general validation of input
+Preconditions.checkArgument(values.length == 4);
+Preconditions.checkArgument(values[0] instanceof Literal);
--- End diff --

Point taken.  I think the comments clearly explain the order of the 
arguments.


> Temporal Difference Function
> 
>
> Key: RYA-392
> URL: https://issues.apache.org/jira/browse/RYA-392
> Project: Rya
>  Issue Type: New Feature
>Affects Versions: 3.2.11
>Reporter: Caleb Meier
>Assignee: Caleb Meier
>
> Currently Rya does not provide a Function that determines whether two 
> temporal literals are within a given period 

[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-05 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16193733#comment-16193733
 ] 

ASF GitHub Bot commented on RYA-392:


Github user meiercaleb commented on a diff in the pull request:

https://github.com/apache/incubator-rya/pull/237#discussion_r143060791
  
--- Diff: 
common/rya.api/src/test/java/org/apache/rya/api/functions/DateTimeWithinTest.java
 ---
@@ -0,0 +1,184 @@
+/*
+ * 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.rya.api.functions;
+
+import static org.junit.Assert.assertEquals;
+
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+
+import javax.xml.datatype.DatatypeConfigurationException;
+import javax.xml.datatype.DatatypeFactory;
+
+import org.junit.Test;
+import org.openrdf.model.Literal;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.impl.ValueFactoryImpl;
+import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException;
+
+public class DateTimeWithinTest {
+
+private static final ValueFactory vf = new ValueFactoryImpl();
+private static final Literal TRUE = vf.createLiteral(true);
+private static final Literal FALSE = vf.createLiteral(false);
+
+@Test 
+public void testSeconds() throws DatatypeConfigurationException, 
ValueExprEvaluationException {
+DatatypeFactory dtf = DatatypeFactory.newInstance();
+
+ZonedDateTime zTime = ZonedDateTime.now();
--- End diff --

Changed names.


> Temporal Difference Function
> 
>
> Key: RYA-392
> URL: https://issues.apache.org/jira/browse/RYA-392
> Project: Rya
>  Issue Type: New Feature
>Affects Versions: 3.2.11
>Reporter: Caleb Meier
>Assignee: Caleb Meier
>
> Currently Rya does not provide a Function that determines whether two 
> temporal literals are within a given period of time of one another.  This is 
> extremely useful for filtering on query results that occurred within a fixed 
> period of time of a given instant.  Currently, if one attempts to form the 
> following filter Filter(?time1 - ?time2 < "24"^^xsd:hour), an exception will 
> be thrown if ?time1 and ?time2 are date time literals.  I propose 
> implementing a Function that takes in two temporal literals, an integer and a 
> time unit and determines whether the date times are within the prescribed 
> period of one another.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-05 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16193662#comment-16193662
 ] 

ASF GitHub Bot commented on RYA-392:


Github user kchilton2 commented on a diff in the pull request:

https://github.com/apache/incubator-rya/pull/237#discussion_r143055190
  
--- Diff: 
common/rya.api/src/main/java/org/apache/rya/api/functions/OWLTime.java ---
@@ -0,0 +1,147 @@
+/*
+ * 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.rya.api.functions;
+
+import org.openrdf.model.URI;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.impl.ValueFactoryImpl;
+
+/**
+ * Constants for OWL-Time primitives in the OWL-Time namespace.
+ *
+ */
+public class OWLTime {
+
+/**
+ * Indicates namespace of OWL-Time ontology
+ */
+public static final String NAMESPACE = "http://www.w3.org/2006/time#;;
+/**
+ * Seconds class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI SECONDS_URI;
+/**
+ * Minutes class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI MINUTES_URI;
+/**
+ * Hours class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI HOURS_URI;
+/**
+ * Days class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI DAYS_URI;
+/**
+ * Weeks class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI WEEKS_URI;
+/**
+ * Months class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI MONTHS_URI;
+/**
+ * Years class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI YEARS_URI;
+
+public static boolean isValidDurationType(URI duration) {
+return (duration.equals(SECONDS_URI) || 
duration.equals(MINUTES_URI) || duration.equals(HOURS_URI) || 
duration.equals(DAYS_URI)
+|| duration.equals(WEEKS_URI) || 
duration.equals(MONTHS_URI) || duration.equals(YEARS_URI));
+}
+
+static {
+ValueFactory factory = ValueFactoryImpl.getInstance();
+SECONDS_URI = factory.createURI(NAMESPACE, "seconds");
+MINUTES_URI = factory.createURI(NAMESPACE, "minutes");
+HOURS_URI = factory.createURI(NAMESPACE, "hours");
+DAYS_URI = factory.createURI(NAMESPACE, "days");
+WEEKS_URI = factory.createURI(NAMESPACE, "weeks");
+MONTHS_URI = factory.createURI(NAMESPACE, "months");
+YEARS_URI = factory.createURI(NAMESPACE, "years");
+}
+
+public static enum Duration {
+SECONDS(1000, SECONDS_URI), 
+MINUTES(6, MINUTES_URI), 
+HOURS(360, HOURS_URI), 
+DAYS(8640, DAYS_URI), 
+WEEKS(60480, WEEKS_URI), 
+MONTHS(259200L, MONTHS_URI), 
+YEARS(3153600L, YEARS_URI);
+
+private final URI uri;
+private final long millisConversion;
--- End diff --

Checkout TimeUnits.


> Temporal Difference Function
> 
>
> Key: RYA-392
> URL: https://issues.apache.org/jira/browse/RYA-392
> Project: Rya
>  Issue Type: New Feature
>Affects Versions: 3.2.11
>Reporter: Caleb Meier
>Assignee: Caleb Meier
>
> Currently Rya does not provide a Function that determines whether two 
> temporal literals are within a given period of time of one another.  This is 
> extremely useful for filtering on query results that occurred within a fixed 
> period of time of a given instant.  Currently, if one attempts to form the 
> following filter Filter(?time1 - ?time2 < "24"^^xsd:hour), an exception will 
> be thrown if ?time1 

[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-05 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16193647#comment-16193647
 ] 

ASF GitHub Bot commented on RYA-392:


Github user kchilton2 commented on a diff in the pull request:

https://github.com/apache/incubator-rya/pull/237#discussion_r143049513
  
--- Diff: 
common/rya.api/src/main/java/org/apache/rya/api/functions/OWLTime.java ---
@@ -0,0 +1,147 @@
+/*
+ * 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.rya.api.functions;
+
+import org.openrdf.model.URI;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.impl.ValueFactoryImpl;
+
+/**
+ * Constants for OWL-Time primitives in the OWL-Time namespace.
+ *
+ */
+public class OWLTime {
+
+/**
+ * Indicates namespace of OWL-Time ontology
+ */
+public static final String NAMESPACE = "http://www.w3.org/2006/time#;;
+/**
+ * Seconds class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI SECONDS_URI;
+/**
+ * Minutes class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI MINUTES_URI;
+/**
+ * Hours class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI HOURS_URI;
+/**
+ * Days class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI DAYS_URI;
+/**
+ * Weeks class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI WEEKS_URI;
+/**
+ * Months class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI MONTHS_URI;
+/**
+ * Years class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI YEARS_URI;
+
+public static boolean isValidDurationType(URI duration) {
+return (duration.equals(SECONDS_URI) || 
duration.equals(MINUTES_URI) || duration.equals(HOURS_URI) || 
duration.equals(DAYS_URI)
+|| duration.equals(WEEKS_URI) || 
duration.equals(MONTHS_URI) || duration.equals(YEARS_URI));
+}
+
+static {
+ValueFactory factory = ValueFactoryImpl.getInstance();
+SECONDS_URI = factory.createURI(NAMESPACE, "seconds");
+MINUTES_URI = factory.createURI(NAMESPACE, "minutes");
+HOURS_URI = factory.createURI(NAMESPACE, "hours");
+DAYS_URI = factory.createURI(NAMESPACE, "days");
+WEEKS_URI = factory.createURI(NAMESPACE, "weeks");
+MONTHS_URI = factory.createURI(NAMESPACE, "months");
+YEARS_URI = factory.createURI(NAMESPACE, "years");
+}
+
+public static enum Duration {
--- End diff --

This class could use some javadocs.


> Temporal Difference Function
> 
>
> Key: RYA-392
> URL: https://issues.apache.org/jira/browse/RYA-392
> Project: Rya
>  Issue Type: New Feature
>Affects Versions: 3.2.11
>Reporter: Caleb Meier
>Assignee: Caleb Meier
>
> Currently Rya does not provide a Function that determines whether two 
> temporal literals are within a given period of time of one another.  This is 
> extremely useful for filtering on query results that occurred within a fixed 
> period of time of a given instant.  Currently, if one attempts to form the 
> following filter Filter(?time1 - ?time2 < "24"^^xsd:hour), an exception will 
> be thrown if ?time1 and ?time2 are date time literals.  I propose 
> implementing a Function that takes in two temporal literals, an integer and a 
> time unit and determines whether the date times are within the prescribed 
> period of one another.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-05 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16193655#comment-16193655
 ] 

ASF GitHub Bot commented on RYA-392:


Github user kchilton2 commented on a diff in the pull request:

https://github.com/apache/incubator-rya/pull/237#discussion_r143049174
  
--- Diff: 
common/rya.api/src/main/java/org/apache/rya/api/functions/OWLTime.java ---
@@ -0,0 +1,147 @@
+/*
+ * 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.rya.api.functions;
+
+import org.openrdf.model.URI;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.impl.ValueFactoryImpl;
+
+/**
+ * Constants for OWL-Time primitives in the OWL-Time namespace.
+ *
+ */
+public class OWLTime {
+
+/**
+ * Indicates namespace of OWL-Time ontology
+ */
+public static final String NAMESPACE = "http://www.w3.org/2006/time#;;
+/**
+ * Seconds class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI SECONDS_URI;
+/**
+ * Minutes class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI MINUTES_URI;
+/**
+ * Hours class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI HOURS_URI;
+/**
+ * Days class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI DAYS_URI;
+/**
+ * Weeks class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI WEEKS_URI;
+/**
+ * Months class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI MONTHS_URI;
+/**
+ * Years class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI YEARS_URI;
+
+public static boolean isValidDurationType(URI duration) {
+return (duration.equals(SECONDS_URI) || 
duration.equals(MINUTES_URI) || duration.equals(HOURS_URI) || 
duration.equals(DAYS_URI)
+|| duration.equals(WEEKS_URI) || 
duration.equals(MONTHS_URI) || duration.equals(YEARS_URI));
+}
+
+static {
+ValueFactory factory = ValueFactoryImpl.getInstance();
+SECONDS_URI = factory.createURI(NAMESPACE, "seconds");
+MINUTES_URI = factory.createURI(NAMESPACE, "minutes");
+HOURS_URI = factory.createURI(NAMESPACE, "hours");
+DAYS_URI = factory.createURI(NAMESPACE, "days");
+WEEKS_URI = factory.createURI(NAMESPACE, "weeks");
+MONTHS_URI = factory.createURI(NAMESPACE, "months");
+YEARS_URI = factory.createURI(NAMESPACE, "years");
+}
+
+public static enum Duration {
+SECONDS(1000, SECONDS_URI), 
+MINUTES(6, MINUTES_URI), 
+HOURS(360, HOURS_URI), 
+DAYS(8640, DAYS_URI), 
+WEEKS(60480, WEEKS_URI), 
+MONTHS(259200L, MONTHS_URI), 
+YEARS(3153600L, YEARS_URI);
+
+private final URI uri;
+private final long millisConversion;
+
+Duration(long millisConversion, URI uri) {
+this.uri = uri;
+this.millisConversion = millisConversion;
+}
+
+public long millisConversion() {
+return millisConversion;
+}
+
+public URI uri() {
+return uri;
+}
+
+/**
+ * Returns the duration in milliseconds
+ * 
+ * @param duration - amount of time in the units indicated by the 
provided {@link OWLTime} URI
+ * @param uri - OWLTime URI indicating the time unit of duration
+ * @return - the amount of time in milliseconds 
+ */
+public static long getMillis(int duration, URI uri) {
+   

[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-05 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16193656#comment-16193656
 ] 

ASF GitHub Bot commented on RYA-392:


Github user kchilton2 commented on a diff in the pull request:

https://github.com/apache/incubator-rya/pull/237#discussion_r143048091
  
--- Diff: 
common/rya.api/src/main/java/org/apache/rya/api/functions/OWLTime.java ---
@@ -0,0 +1,147 @@
+/*
+ * 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.rya.api.functions;
+
+import org.openrdf.model.URI;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.impl.ValueFactoryImpl;
+
+/**
+ * Constants for OWL-Time primitives in the OWL-Time namespace.
+ *
+ */
+public class OWLTime {
+
+/**
+ * Indicates namespace of OWL-Time ontology
+ */
+public static final String NAMESPACE = "http://www.w3.org/2006/time#;;
+/**
+ * Seconds class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI SECONDS_URI;
+/**
+ * Minutes class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI MINUTES_URI;
+/**
+ * Hours class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI HOURS_URI;
+/**
+ * Days class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI DAYS_URI;
+/**
+ * Weeks class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI WEEKS_URI;
+/**
+ * Months class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI MONTHS_URI;
+/**
+ * Years class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI YEARS_URI;
+
+public static boolean isValidDurationType(URI duration) {
--- End diff --

Missing javadocs.


> Temporal Difference Function
> 
>
> Key: RYA-392
> URL: https://issues.apache.org/jira/browse/RYA-392
> Project: Rya
>  Issue Type: New Feature
>Affects Versions: 3.2.11
>Reporter: Caleb Meier
>Assignee: Caleb Meier
>
> Currently Rya does not provide a Function that determines whether two 
> temporal literals are within a given period of time of one another.  This is 
> extremely useful for filtering on query results that occurred within a fixed 
> period of time of a given instant.  Currently, if one attempts to form the 
> following filter Filter(?time1 - ?time2 < "24"^^xsd:hour), an exception will 
> be thrown if ?time1 and ?time2 are date time literals.  I propose 
> implementing a Function that takes in two temporal literals, an integer and a 
> time unit and determines whether the date times are within the prescribed 
> period of one another.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-05 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16193651#comment-16193651
 ] 

ASF GitHub Bot commented on RYA-392:


Github user kchilton2 commented on a diff in the pull request:

https://github.com/apache/incubator-rya/pull/237#discussion_r143050856
  
--- Diff: 
common/rya.api/src/test/java/org/apache/rya/api/functions/DateTimeWithinTest.java
 ---
@@ -0,0 +1,184 @@
+/*
+ * 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.rya.api.functions;
+
+import static org.junit.Assert.assertEquals;
+
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+
+import javax.xml.datatype.DatatypeConfigurationException;
+import javax.xml.datatype.DatatypeFactory;
+
+import org.junit.Test;
+import org.openrdf.model.Literal;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.impl.ValueFactoryImpl;
+import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException;
+
+public class DateTimeWithinTest {
+
+private static final ValueFactory vf = new ValueFactoryImpl();
+private static final Literal TRUE = vf.createLiteral(true);
+private static final Literal FALSE = vf.createLiteral(false);
+
+@Test 
+public void testSeconds() throws DatatypeConfigurationException, 
ValueExprEvaluationException {
+DatatypeFactory dtf = DatatypeFactory.newInstance();
+
+ZonedDateTime zTime = ZonedDateTime.now();
--- End diff --

This test is a little hard to follow. Maybe call this variable nowZTime?


> Temporal Difference Function
> 
>
> Key: RYA-392
> URL: https://issues.apache.org/jira/browse/RYA-392
> Project: Rya
>  Issue Type: New Feature
>Affects Versions: 3.2.11
>Reporter: Caleb Meier
>Assignee: Caleb Meier
>
> Currently Rya does not provide a Function that determines whether two 
> temporal literals are within a given period of time of one another.  This is 
> extremely useful for filtering on query results that occurred within a fixed 
> period of time of a given instant.  Currently, if one attempts to form the 
> following filter Filter(?time1 - ?time2 < "24"^^xsd:hour), an exception will 
> be thrown if ?time1 and ?time2 are date time literals.  I propose 
> implementing a Function that takes in two temporal literals, an integer and a 
> time unit and determines whether the date times are within the prescribed 
> period of one another.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-05 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16193654#comment-16193654
 ] 

ASF GitHub Bot commented on RYA-392:


Github user kchilton2 commented on a diff in the pull request:

https://github.com/apache/incubator-rya/pull/237#discussion_r143051029
  
--- Diff: 
common/rya.api/src/test/java/org/apache/rya/api/functions/DateTimeWithinTest.java
 ---
@@ -0,0 +1,184 @@
+/*
+ * 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.rya.api.functions;
+
+import static org.junit.Assert.assertEquals;
+
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+
+import javax.xml.datatype.DatatypeConfigurationException;
+import javax.xml.datatype.DatatypeFactory;
+
+import org.junit.Test;
+import org.openrdf.model.Literal;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.impl.ValueFactoryImpl;
+import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException;
+
+public class DateTimeWithinTest {
+
+private static final ValueFactory vf = new ValueFactoryImpl();
+private static final Literal TRUE = vf.createLiteral(true);
+private static final Literal FALSE = vf.createLiteral(false);
+
+@Test 
+public void testSeconds() throws DatatypeConfigurationException, 
ValueExprEvaluationException {
+DatatypeFactory dtf = DatatypeFactory.newInstance();
+
+ZonedDateTime zTime = ZonedDateTime.now();
+String time = zTime.format(DateTimeFormatter.ISO_INSTANT);
+
+ZonedDateTime zTime1 = zTime.minusSeconds(1);
--- End diff --

Maybe call this oneSecondEarlierZTime?


> Temporal Difference Function
> 
>
> Key: RYA-392
> URL: https://issues.apache.org/jira/browse/RYA-392
> Project: Rya
>  Issue Type: New Feature
>Affects Versions: 3.2.11
>Reporter: Caleb Meier
>Assignee: Caleb Meier
>
> Currently Rya does not provide a Function that determines whether two 
> temporal literals are within a given period of time of one another.  This is 
> extremely useful for filtering on query results that occurred within a fixed 
> period of time of a given instant.  Currently, if one attempts to form the 
> following filter Filter(?time1 - ?time2 < "24"^^xsd:hour), an exception will 
> be thrown if ?time1 and ?time2 are date time literals.  I propose 
> implementing a Function that takes in two temporal literals, an integer and a 
> time unit and determines whether the date times are within the prescribed 
> period of one another.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-05 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16193649#comment-16193649
 ] 

ASF GitHub Bot commented on RYA-392:


Github user kchilton2 commented on a diff in the pull request:

https://github.com/apache/incubator-rya/pull/237#discussion_r143054711
  
--- Diff: 
common/rya.api/src/main/java/org/apache/rya/api/functions/DateTimeWithinPeriod.java
 ---
@@ -0,0 +1,121 @@
+/*
+ * 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.rya.api.functions;
+
+import org.apache.rya.api.functions.OWLTime.Duration;
+import org.openrdf.model.Literal;
+import org.openrdf.model.URI;
+import org.openrdf.model.Value;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.datatypes.XMLDatatypeUtil;
+import org.openrdf.model.vocabulary.FN;
+import org.openrdf.model.vocabulary.XMLSchema;
+import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException;
+import org.openrdf.query.algebra.evaluation.function.Function;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * This {@link Function} determines whether two datetimes occur within a 
specified period of time of one another. The
+ * method {@link Function#evaluate(ValueFactory, Value...)} expects four 
values, where the first two values are the
+ * datetimes, the third value is an integer indicating the period, and the 
fourth value is a URI indicating the time
+ * unit of the period. The URI must be of Type DurationDescription in the 
OWL-Time ontology (see
+ * https://www.w3.org/TR/owl-time/;>https://www.w3.org/TR/owl-time/). 
Examples of valid time unit URIs
+ * can be found in the class {@link OWLTime} and below
+ * 
+ * http://www.w3.org/2006/time#days
+ * http://www.w3.org/2006/time#hours
+ * http://www.w3.org/2006/time#minutes
+ * http://www.w3.org/2006/time#seconds
+ * 
+ * 
+ */
+public class DateTimeWithinPeriod implements Function {
+
+private static final String DATE_TIME_WITHIN = "dateTimeWithin";
+
+@Override
+public String getURI() {
+return FN.NAMESPACE.toString() + DATE_TIME_WITHIN;
+}
+
+/**
+ * Determines whether two datetimes occur within a specified period of 
time of one another. This method expects four
+ * values, where the first two values are the datetimes, the third 
value is an integer indicating the period, and
+ * the fourth value is a URI indicating the time unit of the period. 
The URI must be of Type DurationDescription in
+ * the OWL-Time ontology (see https://www.w3.org/TR/owl-time/;>https://www.w3.org/TR/owl-time/).
+ * Examples of valid time unit URIs can be found in the class {@link 
OWLTime} and below
+ * 
+ * http://www.w3.org/2006/time#days
+ * http://www.w3.org/2006/time#hours
+ * http://www.w3.org/2006/time#minutes
+ * http://www.w3.org/2006/time#seconds
+ * 
+ * 
+ * @param valueFactory - factory for creating values
+ * @param values - array of Value arguments for this Function.
+ */
+@Override
+public Value evaluate(ValueFactory valueFactory, Value... values) 
throws ValueExprEvaluationException {
+
+// general validation of input
+Preconditions.checkArgument(values.length == 4);
+Preconditions.checkArgument(values[0] instanceof Literal);
--- End diff --

This is a style comment. It would be a little easier to understand that 
this code is doing if these array indices were descriptive of what was stored 
in the array at that position.

for exmple:
private static final int DATE_TIME_1 = 0;
private static final int DATE_TIME_2 = 1;
private static final int PERIOD = 2;
private static final int PERIOD_UNITS = 3;

Then the rest of the code could look like:
long epochTime1 = convertDatetimeToMillis((Literal) values[DATE_TIME_1]);
long 

[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-05 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16193650#comment-16193650
 ] 

ASF GitHub Bot commented on RYA-392:


Github user kchilton2 commented on a diff in the pull request:

https://github.com/apache/incubator-rya/pull/237#discussion_r143049693
  
--- Diff: 
common/rya.api/src/main/java/org/apache/rya/api/functions/OWLTime.java ---
@@ -0,0 +1,147 @@
+/*
+ * 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.rya.api.functions;
+
+import org.openrdf.model.URI;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.impl.ValueFactoryImpl;
+
+/**
+ * Constants for OWL-Time primitives in the OWL-Time namespace.
+ *
+ */
+public class OWLTime {
+
+/**
+ * Indicates namespace of OWL-Time ontology
+ */
+public static final String NAMESPACE = "http://www.w3.org/2006/time#;;
+/**
+ * Seconds class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI SECONDS_URI;
+/**
+ * Minutes class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI MINUTES_URI;
+/**
+ * Hours class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI HOURS_URI;
+/**
+ * Days class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI DAYS_URI;
+/**
+ * Weeks class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI WEEKS_URI;
+/**
+ * Months class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI MONTHS_URI;
+/**
+ * Years class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI YEARS_URI;
+
+public static boolean isValidDurationType(URI duration) {
--- End diff --

This method could also be on the Duration enumeration. Or just get and if 
it doesn't find a value for the provided URI, then it is implicitly not a valid 
Duration type.


> Temporal Difference Function
> 
>
> Key: RYA-392
> URL: https://issues.apache.org/jira/browse/RYA-392
> Project: Rya
>  Issue Type: New Feature
>Affects Versions: 3.2.11
>Reporter: Caleb Meier
>Assignee: Caleb Meier
>
> Currently Rya does not provide a Function that determines whether two 
> temporal literals are within a given period of time of one another.  This is 
> extremely useful for filtering on query results that occurred within a fixed 
> period of time of a given instant.  Currently, if one attempts to form the 
> following filter Filter(?time1 - ?time2 < "24"^^xsd:hour), an exception will 
> be thrown if ?time1 and ?time2 are date time literals.  I propose 
> implementing a Function that takes in two temporal literals, an integer and a 
> time unit and determines whether the date times are within the prescribed 
> period of one another.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-05 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16193652#comment-16193652
 ] 

ASF GitHub Bot commented on RYA-392:


Github user kchilton2 commented on a diff in the pull request:

https://github.com/apache/incubator-rya/pull/237#discussion_r143049467
  
--- Diff: 
common/rya.api/src/main/java/org/apache/rya/api/functions/OWLTime.java ---
@@ -0,0 +1,147 @@
+/*
+ * 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.rya.api.functions;
+
+import org.openrdf.model.URI;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.impl.ValueFactoryImpl;
+
+/**
+ * Constants for OWL-Time primitives in the OWL-Time namespace.
+ *
+ */
+public class OWLTime {
+
+/**
+ * Indicates namespace of OWL-Time ontology
+ */
+public static final String NAMESPACE = "http://www.w3.org/2006/time#;;
+/**
+ * Seconds class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI SECONDS_URI;
+/**
+ * Minutes class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI MINUTES_URI;
+/**
+ * Hours class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI HOURS_URI;
+/**
+ * Days class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI DAYS_URI;
+/**
+ * Weeks class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI WEEKS_URI;
+/**
+ * Months class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI MONTHS_URI;
+/**
+ * Years class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI YEARS_URI;
+
+public static boolean isValidDurationType(URI duration) {
+return (duration.equals(SECONDS_URI) || 
duration.equals(MINUTES_URI) || duration.equals(HOURS_URI) || 
duration.equals(DAYS_URI)
+|| duration.equals(WEEKS_URI) || 
duration.equals(MONTHS_URI) || duration.equals(YEARS_URI));
+}
+
+static {
--- End diff --

It would be nice if you didn't have this static method or the static fields 
up top.

You could have a private static final ValueFatory that you use within the 
Duration enum to build the URIs.


> Temporal Difference Function
> 
>
> Key: RYA-392
> URL: https://issues.apache.org/jira/browse/RYA-392
> Project: Rya
>  Issue Type: New Feature
>Affects Versions: 3.2.11
>Reporter: Caleb Meier
>Assignee: Caleb Meier
>
> Currently Rya does not provide a Function that determines whether two 
> temporal literals are within a given period of time of one another.  This is 
> extremely useful for filtering on query results that occurred within a fixed 
> period of time of a given instant.  Currently, if one attempts to form the 
> following filter Filter(?time1 - ?time2 < "24"^^xsd:hour), an exception will 
> be thrown if ?time1 and ?time2 are date time literals.  I propose 
> implementing a Function that takes in two temporal literals, an integer and a 
> time unit and determines whether the date times are within the prescribed 
> period of one another.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-05 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16193653#comment-16193653
 ] 

ASF GitHub Bot commented on RYA-392:


Github user kchilton2 commented on a diff in the pull request:

https://github.com/apache/incubator-rya/pull/237#discussion_r143048147
  
--- Diff: 
common/rya.api/src/main/java/org/apache/rya/api/functions/OWLTime.java ---
@@ -0,0 +1,147 @@
+/*
+ * 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.rya.api.functions;
+
+import org.openrdf.model.URI;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.impl.ValueFactoryImpl;
+
+/**
+ * Constants for OWL-Time primitives in the OWL-Time namespace.
+ *
+ */
+public class OWLTime {
+
+/**
+ * Indicates namespace of OWL-Time ontology
+ */
+public static final String NAMESPACE = "http://www.w3.org/2006/time#;;
+/**
+ * Seconds class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI SECONDS_URI;
+/**
+ * Minutes class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI MINUTES_URI;
+/**
+ * Hours class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI HOURS_URI;
+/**
+ * Days class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI DAYS_URI;
+/**
+ * Weeks class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI WEEKS_URI;
+/**
+ * Months class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI MONTHS_URI;
+/**
+ * Years class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI YEARS_URI;
+
+public static boolean isValidDurationType(URI duration) {
--- End diff --

Also, null check?


> Temporal Difference Function
> 
>
> Key: RYA-392
> URL: https://issues.apache.org/jira/browse/RYA-392
> Project: Rya
>  Issue Type: New Feature
>Affects Versions: 3.2.11
>Reporter: Caleb Meier
>Assignee: Caleb Meier
>
> Currently Rya does not provide a Function that determines whether two 
> temporal literals are within a given period of time of one another.  This is 
> extremely useful for filtering on query results that occurred within a fixed 
> period of time of a given instant.  Currently, if one attempts to form the 
> following filter Filter(?time1 - ?time2 < "24"^^xsd:hour), an exception will 
> be thrown if ?time1 and ?time2 are date time literals.  I propose 
> implementing a Function that takes in two temporal literals, an integer and a 
> time unit and determines whether the date times are within the prescribed 
> period of one another.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-05 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16193648#comment-16193648
 ] 

ASF GitHub Bot commented on RYA-392:


Github user kchilton2 commented on a diff in the pull request:

https://github.com/apache/incubator-rya/pull/237#discussion_r143049987
  
--- Diff: 
common/rya.api/src/main/java/org/apache/rya/api/functions/OWLTime.java ---
@@ -0,0 +1,147 @@
+/*
+ * 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.rya.api.functions;
+
+import org.openrdf.model.URI;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.impl.ValueFactoryImpl;
+
+/**
+ * Constants for OWL-Time primitives in the OWL-Time namespace.
+ *
+ */
+public class OWLTime {
+
+/**
+ * Indicates namespace of OWL-Time ontology
+ */
+public static final String NAMESPACE = "http://www.w3.org/2006/time#;;
+/**
+ * Seconds class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI SECONDS_URI;
+/**
+ * Minutes class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI MINUTES_URI;
+/**
+ * Hours class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI HOURS_URI;
+/**
+ * Days class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI DAYS_URI;
+/**
+ * Weeks class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI WEEKS_URI;
+/**
+ * Months class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI MONTHS_URI;
+/**
+ * Years class of type DurationDescription in OWL-Time ontology
+ */
+public static final URI YEARS_URI;
+
+public static boolean isValidDurationType(URI duration) {
+return (duration.equals(SECONDS_URI) || 
duration.equals(MINUTES_URI) || duration.equals(HOURS_URI) || 
duration.equals(DAYS_URI)
+|| duration.equals(WEEKS_URI) || 
duration.equals(MONTHS_URI) || duration.equals(YEARS_URI));
+}
+
+static {
+ValueFactory factory = ValueFactoryImpl.getInstance();
+SECONDS_URI = factory.createURI(NAMESPACE, "seconds");
+MINUTES_URI = factory.createURI(NAMESPACE, "minutes");
+HOURS_URI = factory.createURI(NAMESPACE, "hours");
+DAYS_URI = factory.createURI(NAMESPACE, "days");
+WEEKS_URI = factory.createURI(NAMESPACE, "weeks");
+MONTHS_URI = factory.createURI(NAMESPACE, "months");
+YEARS_URI = factory.createURI(NAMESPACE, "years");
+}
+
+public static enum Duration {
+SECONDS(1000, SECONDS_URI), 
+MINUTES(6, MINUTES_URI), 
+HOURS(360, HOURS_URI), 
+DAYS(8640, DAYS_URI), 
+WEEKS(60480, WEEKS_URI), 
+MONTHS(259200L, MONTHS_URI), 
+YEARS(3153600L, YEARS_URI);
+
+private final URI uri;
+private final long millisConversion;
+
+Duration(long millisConversion, URI uri) {
+this.uri = uri;
+this.millisConversion = millisConversion;
+}
+
+public long millisConversion() {
+return millisConversion;
+}
+
+public URI uri() {
+return uri;
+}
+
+/**
+ * Returns the duration in milliseconds
+ * 
+ * @param duration - amount of time in the units indicated by the 
provided {@link OWLTime} URI
+ * @param uri - OWLTime URI indicating the time unit of duration
+ * @return - the amount of time in milliseconds 
+ */
+public static long getMillis(int duration, URI uri) {
+   

[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-05 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16193612#comment-16193612
 ] 

ASF GitHub Bot commented on RYA-392:


Github user jdasch commented on a diff in the pull request:

https://github.com/apache/incubator-rya/pull/237#discussion_r143051442
  
--- Diff: 
common/rya.api/src/main/java/org/apache/rya/api/functions/DateTimeWithinPeriod.java
 ---
@@ -0,0 +1,121 @@
+/*
+ * 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.rya.api.functions;
+
+import org.apache.rya.api.functions.OWLTime.Duration;
+import org.openrdf.model.Literal;
+import org.openrdf.model.URI;
+import org.openrdf.model.Value;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.datatypes.XMLDatatypeUtil;
+import org.openrdf.model.vocabulary.FN;
+import org.openrdf.model.vocabulary.XMLSchema;
+import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException;
+import org.openrdf.query.algebra.evaluation.function.Function;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * This {@link Function} determines whether two datetimes occur within a 
specified period of time of one another. The
+ * method {@link Function#evaluate(ValueFactory, Value...)} expects four 
values, where the first two values are the
+ * datetimes, the third value is an integer indicating the period, and the 
fourth value is a URI indicating the time
+ * unit of the period. The URI must be of Type DurationDescription in the 
OWL-Time ontology (see
+ * https://www.w3.org/TR/owl-time/;>https://www.w3.org/TR/owl-time/). 
Examples of valid time unit URIs
+ * can be found in the class {@link OWLTime} and below
+ * 
+ * http://www.w3.org/2006/time#days
+ * http://www.w3.org/2006/time#hours
+ * http://www.w3.org/2006/time#minutes
+ * http://www.w3.org/2006/time#seconds
+ * 
+ * 
+ */
+public class DateTimeWithinPeriod implements Function {
--- End diff --

Rename `DateTimeWithinPeriod` to `DateTimeWithin`
or
Rename `DateTimeWithinTest` to `DateTimeWithinPeriodTest`


> Temporal Difference Function
> 
>
> Key: RYA-392
> URL: https://issues.apache.org/jira/browse/RYA-392
> Project: Rya
>  Issue Type: New Feature
>Affects Versions: 3.2.11
>Reporter: Caleb Meier
>Assignee: Caleb Meier
>
> Currently Rya does not provide a Function that determines whether two 
> temporal literals are within a given period of time of one another.  This is 
> extremely useful for filtering on query results that occurred within a fixed 
> period of time of a given instant.  Currently, if one attempts to form the 
> following filter Filter(?time1 - ?time2 < "24"^^xsd:hour), an exception will 
> be thrown if ?time1 and ?time2 are date time literals.  I propose 
> implementing a Function that takes in two temporal literals, an integer and a 
> time unit and determines whether the date times are within the prescribed 
> period of one another.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-05 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16193596#comment-16193596
 ] 

ASF GitHub Bot commented on RYA-392:


Github user jdasch commented on a diff in the pull request:

https://github.com/apache/incubator-rya/pull/237#discussion_r143049674
  
--- Diff: 
common/rya.api/src/main/java/org/apache/rya/api/functions/DateTimeWithinPeriod.java
 ---
@@ -0,0 +1,121 @@
+/*
+ * 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.rya.api.functions;
+
+import org.apache.rya.api.functions.OWLTime.Duration;
+import org.openrdf.model.Literal;
+import org.openrdf.model.URI;
+import org.openrdf.model.Value;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.datatypes.XMLDatatypeUtil;
+import org.openrdf.model.vocabulary.FN;
+import org.openrdf.model.vocabulary.XMLSchema;
+import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException;
+import org.openrdf.query.algebra.evaluation.function.Function;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * This {@link Function} determines whether two datetimes occur within a 
specified period of time of one another. The
+ * method {@link Function#evaluate(ValueFactory, Value...)} expects four 
values, where the first two values are the
+ * datetimes, the third value is an integer indicating the period, and the 
fourth value is a URI indicating the time
+ * unit of the period. The URI must be of Type DurationDescription in the 
OWL-Time ontology (see
+ * https://www.w3.org/TR/owl-time/;>https://www.w3.org/TR/owl-time/). 
Examples of valid time unit URIs
+ * can be found in the class {@link OWLTime} and below
+ * 
+ * http://www.w3.org/2006/time#days
+ * http://www.w3.org/2006/time#hours
+ * http://www.w3.org/2006/time#minutes
+ * http://www.w3.org/2006/time#seconds
+ * 
+ * 
+ */
+public class DateTimeWithinPeriod implements Function {
+
+private static final String DATE_TIME_WITHIN = "dateTimeWithin";
+
+@Override
+public String getURI() {
+return FN.NAMESPACE.toString() + DATE_TIME_WITHIN;
+}
+
--- End diff --

Change to 
```
private static final String FUNCTION_URI = FN.NAMESPACE + 
"dateTimeWithin";

@Override
public String getURI() {
return FUNCTION_URI;
}
```


> Temporal Difference Function
> 
>
> Key: RYA-392
> URL: https://issues.apache.org/jira/browse/RYA-392
> Project: Rya
>  Issue Type: New Feature
>Affects Versions: 3.2.11
>Reporter: Caleb Meier
>Assignee: Caleb Meier
>
> Currently Rya does not provide a Function that determines whether two 
> temporal literals are within a given period of time of one another.  This is 
> extremely useful for filtering on query results that occurred within a fixed 
> period of time of a given instant.  Currently, if one attempts to form the 
> following filter Filter(?time1 - ?time2 < "24"^^xsd:hour), an exception will 
> be thrown if ?time1 and ?time2 are date time literals.  I propose 
> implementing a Function that takes in two temporal literals, an integer and a 
> time unit and determines whether the date times are within the prescribed 
> period of one another.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-05 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16193588#comment-16193588
 ] 

ASF GitHub Bot commented on RYA-392:


Github user jdasch commented on a diff in the pull request:

https://github.com/apache/incubator-rya/pull/237#discussion_r143047847
  
--- Diff: 
common/rya.api/src/main/java/org/apache/rya/api/functions/DateTimeWithinPeriod.java
 ---
@@ -0,0 +1,121 @@
+/*
+ * 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.rya.api.functions;
+
+import org.apache.rya.api.functions.OWLTime.Duration;
+import org.openrdf.model.Literal;
+import org.openrdf.model.URI;
+import org.openrdf.model.Value;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.datatypes.XMLDatatypeUtil;
+import org.openrdf.model.vocabulary.FN;
+import org.openrdf.model.vocabulary.XMLSchema;
+import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException;
+import org.openrdf.query.algebra.evaluation.function.Function;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * This {@link Function} determines whether two datetimes occur within a 
specified period of time of one another. The
+ * method {@link Function#evaluate(ValueFactory, Value...)} expects four 
values, where the first two values are the
+ * datetimes, the third value is an integer indicating the period, and the 
fourth value is a URI indicating the time
+ * unit of the period. The URI must be of Type DurationDescription in the 
OWL-Time ontology (see
+ * https://www.w3.org/TR/owl-time/;>https://www.w3.org/TR/owl-time/). 
Examples of valid time unit URIs
+ * can be found in the class {@link OWLTime} and below
+ * 
+ * http://www.w3.org/2006/time#days
+ * http://www.w3.org/2006/time#hours
+ * http://www.w3.org/2006/time#minutes
+ * http://www.w3.org/2006/time#seconds
+ * 
+ * 
+ */
+public class DateTimeWithinPeriod implements Function {
+
+private static final String DATE_TIME_WITHIN = "dateTimeWithin";
+
+@Override
+public String getURI() {
+return FN.NAMESPACE.toString() + DATE_TIME_WITHIN;
+}
+
+/**
+ * Determines whether two datetimes occur within a specified period of 
time of one another. This method expects four
+ * values, where the first two values are the datetimes, the third 
value is an integer indicating the period, and
+ * the fourth value is a URI indicating the time unit of the period. 
The URI must be of Type DurationDescription in
+ * the OWL-Time ontology (see https://www.w3.org/TR/owl-time/;>https://www.w3.org/TR/owl-time/).
+ * Examples of valid time unit URIs can be found in the class {@link 
OWLTime} and below
+ * 
+ * http://www.w3.org/2006/time#days
+ * http://www.w3.org/2006/time#hours
+ * http://www.w3.org/2006/time#minutes
+ * http://www.w3.org/2006/time#seconds
+ * 
+ * 
+ * @param valueFactory - factory for creating values
+ * @param values - array of Value arguments for this Function.
+ */
+@Override
+public Value evaluate(ValueFactory valueFactory, Value... values) 
throws ValueExprEvaluationException {
+
+// general validation of input
+Preconditions.checkArgument(values.length == 4);
--- End diff --

Do you want these to throw a ValueExprEvaluationException in order to 
follow the Function interface contract?


> Temporal Difference Function
> 
>
> Key: RYA-392
> URL: https://issues.apache.org/jira/browse/RYA-392
> Project: Rya
>  Issue Type: New Feature
>Affects Versions: 3.2.11
>Reporter: Caleb Meier
>Assignee: Caleb Meier
>
> Currently Rya does not provide a Function that determines whether two 
> temporal literals are within a given period of time of one another.  This is 
> extremely 

[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-05 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16193585#comment-16193585
 ] 

ASF GitHub Bot commented on RYA-392:


Github user jdasch commented on a diff in the pull request:

https://github.com/apache/incubator-rya/pull/237#discussion_r143046845
  
--- Diff: 
common/rya.api/src/main/java/org/apache/rya/api/functions/DateTimeWithinPeriod.java
 ---
@@ -0,0 +1,121 @@
+/*
+ * 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.rya.api.functions;
+
+import org.apache.rya.api.functions.OWLTime.Duration;
+import org.openrdf.model.Literal;
+import org.openrdf.model.URI;
+import org.openrdf.model.Value;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.datatypes.XMLDatatypeUtil;
+import org.openrdf.model.vocabulary.FN;
+import org.openrdf.model.vocabulary.XMLSchema;
+import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException;
+import org.openrdf.query.algebra.evaluation.function.Function;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * This {@link Function} determines whether two datetimes occur within a 
specified period of time of one another. The
--- End diff --

change to XMLSchema.DATETIME


> Temporal Difference Function
> 
>
> Key: RYA-392
> URL: https://issues.apache.org/jira/browse/RYA-392
> Project: Rya
>  Issue Type: New Feature
>Affects Versions: 3.2.11
>Reporter: Caleb Meier
>Assignee: Caleb Meier
>
> Currently Rya does not provide a Function that determines whether two 
> temporal literals are within a given period of time of one another.  This is 
> extremely useful for filtering on query results that occurred within a fixed 
> period of time of a given instant.  Currently, if one attempts to form the 
> following filter Filter(?time1 - ?time2 < "24"^^xsd:hour), an exception will 
> be thrown if ?time1 and ?time2 are date time literals.  I propose 
> implementing a Function that takes in two temporal literals, an integer and a 
> time unit and determines whether the date times are within the prescribed 
> period of one another.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-05 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16193580#comment-16193580
 ] 

ASF GitHub Bot commented on RYA-392:


Github user kchilton2 commented on a diff in the pull request:

https://github.com/apache/incubator-rya/pull/237#discussion_r143046354
  
--- Diff: common/rya.api/pom.xml ---
@@ -95,5 +95,20 @@ under the License.
 test
 
 
+
+
+
+org.apache.rat
+apache-rat-plugin
+
+
+
+
src/main/resources/META-INF/services/org.openrdf.query.algebra.evaluation.function.Function
--- End diff --

This file needs a license header.


> Temporal Difference Function
> 
>
> Key: RYA-392
> URL: https://issues.apache.org/jira/browse/RYA-392
> Project: Rya
>  Issue Type: New Feature
>Affects Versions: 3.2.11
>Reporter: Caleb Meier
>Assignee: Caleb Meier
>
> Currently Rya does not provide a Function that determines whether two 
> temporal literals are within a given period of time of one another.  This is 
> extremely useful for filtering on query results that occurred within a fixed 
> period of time of a given instant.  Currently, if one attempts to form the 
> following filter Filter(?time1 - ?time2 < "24"^^xsd:hour), an exception will 
> be thrown if ?time1 and ?time2 are date time literals.  I propose 
> implementing a Function that takes in two temporal literals, an integer and a 
> time unit and determines whether the date times are within the prescribed 
> period of one another.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-05 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16193579#comment-16193579
 ] 

ASF GitHub Bot commented on RYA-392:


Github user jdasch commented on a diff in the pull request:

https://github.com/apache/incubator-rya/pull/237#discussion_r143046217
  
--- Diff: common/rya.api/pom.xml ---
@@ -95,5 +95,20 @@ under the License.
 test
 
 
+
+
+
+org.apache.rat
+apache-rat-plugin
+
+
+
+
src/main/resources/META-INF/services/org.openrdf.query.algebra.evaluation.function.Function
--- End diff --

Remove this.  Add the license to the service loader.  # is the comment 
character
http://docs.oracle.com/javase/7/docs/api/java/util/ServiceLoader.html


> Temporal Difference Function
> 
>
> Key: RYA-392
> URL: https://issues.apache.org/jira/browse/RYA-392
> Project: Rya
>  Issue Type: New Feature
>Affects Versions: 3.2.11
>Reporter: Caleb Meier
>Assignee: Caleb Meier
>
> Currently Rya does not provide a Function that determines whether two 
> temporal literals are within a given period of time of one another.  This is 
> extremely useful for filtering on query results that occurred within a fixed 
> period of time of a given instant.  Currently, if one attempts to form the 
> following filter Filter(?time1 - ?time2 < "24"^^xsd:hour), an exception will 
> be thrown if ?time1 and ?time2 are date time literals.  I propose 
> implementing a Function that takes in two temporal literals, an integer and a 
> time unit and determines whether the date times are within the prescribed 
> period of one another.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-04 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16191939#comment-16191939
 ] 

ASF GitHub Bot commented on RYA-392:


Github user asfgit commented on the issue:

https://github.com/apache/incubator-rya/pull/237
  

Refer to this link for build results (access rights to CI server needed): 

https://builds.apache.org/job/incubator-rya-master-with-optionals-pull-requests/513/Failed
 Tests: 1incubator-rya-master-with-optionals-pull-requests/org.apache.rya:rya.indexing:
 1org.apache.rya.indexing.mongo.MongoEntityIndexTest.org.apache.rya.indexing.mongo.MongoEntityIndexTest



> Temporal Difference Function
> 
>
> Key: RYA-392
> URL: https://issues.apache.org/jira/browse/RYA-392
> Project: Rya
>  Issue Type: New Feature
>Affects Versions: 3.2.11
>Reporter: Caleb Meier
>Assignee: Caleb Meier
>
> Currently Rya does not provide a Function that determines whether two 
> temporal literals are within a given period of time of one another.  This is 
> extremely useful for filtering on query results that occurred within a fixed 
> period of time of a given instant.  Currently, if one attempts to form the 
> following filter Filter(?time1 - ?time2 < "24"^^xsd:hour), an exception will 
> be thrown if ?time1 and ?time2 are date time literals.  I propose 
> implementing a Function that takes in two temporal literals, an integer and a 
> time unit and determines whether the date times are within the prescribed 
> period of one another.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-04 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16191857#comment-16191857
 ] 

ASF GitHub Bot commented on RYA-392:


Github user asfgit commented on the issue:

https://github.com/apache/incubator-rya/pull/237
  

Refer to this link for build results (access rights to CI server needed): 

https://builds.apache.org/job/incubator-rya-master-with-optionals-pull-requests/512/



> Temporal Difference Function
> 
>
> Key: RYA-392
> URL: https://issues.apache.org/jira/browse/RYA-392
> Project: Rya
>  Issue Type: New Feature
>Affects Versions: 3.2.11
>Reporter: Caleb Meier
>Assignee: Caleb Meier
>
> Currently Rya does not provide a Function that determines whether two 
> temporal literals are within a given period of time of one another.  This is 
> extremely useful for filtering on query results that occurred within a fixed 
> period of time of a given instant.  Currently, if one attempts to form the 
> following filter Filter(?time1 - ?time2 < "24"^^xsd:hour), an exception will 
> be thrown if ?time1 and ?time2 are date time literals.  I propose 
> implementing a Function that takes in two temporal literals, an integer and a 
> time unit and determines whether the date times are within the prescribed 
> period of one another.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (RYA-392) Temporal Difference Function

2017-10-04 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16191856#comment-16191856
 ] 

ASF GitHub Bot commented on RYA-392:


GitHub user meiercaleb opened a pull request:

https://github.com/apache/incubator-rya/pull/237

RYA-392-Datetime-Within


## Description
Added a Function DateTimeWithinPeriod to determine whether two datetimes 
were within a
specified period of time of one another.

### Tests
Added unit tests to test the Function and added integration tests to verify 
that the Function
is correctly utilized during query evaluation.

### Links
[Jira](https://issues.apache.org/jira/browse/RYA-392)

### Checklist
- [ ] Code Review
- [x] Squash Commits

 People To Reivew
@jdasch @kchilton2 


You can merge this pull request into a Git repository by running:

$ git pull https://github.com/meiercaleb/incubator-rya RYA-392

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/incubator-rya/pull/237.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #237


commit e82688730e94140c9a5c2e83959c1e0f97af7a24
Author: Caleb Meier 
Date:   2017-10-04T19:06:55Z

RYA-392-Datetime-Within




> Temporal Difference Function
> 
>
> Key: RYA-392
> URL: https://issues.apache.org/jira/browse/RYA-392
> Project: Rya
>  Issue Type: New Feature
>Affects Versions: 3.2.11
>Reporter: Caleb Meier
>Assignee: Caleb Meier
>
> Currently Rya does not provide a Function that determines whether two 
> temporal literals are within a given period of time of one another.  This is 
> extremely useful for filtering on query results that occurred within a fixed 
> period of time of a given instant.  Currently, if one attempts to form the 
> following filter Filter(?time1 - ?time2 < "24"^^xsd:hour), an exception will 
> be thrown if ?time1 and ?time2 are date time literals.  I propose 
> implementing a Function that takes in two temporal literals, an integer and a 
> time unit and determines whether the date times are within the prescribed 
> period of one another.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)