diff --git a/pom.xml b/pom.xml
index f0608e1..0a0a07f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -14,7 +14,6 @@
UTF-8
github
https://repo.icatproject.org/repo/
- 5.3.0
@@ -62,12 +61,6 @@
-
- org.apache.lucene
- lucene-core
- ${luceneVersion}
-
-
javax
javaee-api
diff --git a/src/main/java/org/icatproject/icat/client/ICAT.java b/src/main/java/org/icatproject/icat/client/ICAT.java
index 5bcf592..2986acd 100644
--- a/src/main/java/org/icatproject/icat/client/ICAT.java
+++ b/src/main/java/org/icatproject/icat/client/ICAT.java
@@ -47,8 +47,6 @@
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
-import org.apache.lucene.document.DateTools;
-import org.apache.lucene.document.DateTools.Resolution;
import org.icatproject.icat.client.IcatException.IcatExceptionType;
import org.icatproject.icat.client.Session.Attributes;
import org.icatproject.icat.client.Session.DuplicateAction;
@@ -556,11 +554,10 @@ String searchInvestigations(String sessionId, String user, String text, Date low
gen.write("text", text);
}
if (lower != null) {
- // TODO Remove DateTools as it is from a Lucene library!
- gen.write("lower", DateTools.dateToString(lower, Resolution.MINUTE));
+ gen.write("lower", roundMinute(lower, 0));
}
if (upper != null) {
- gen.write("upper", DateTools.dateToString(upper, Resolution.MINUTE));
+ gen.write("upper", roundMinute(upper, 59999));
}
if (parameters != null && !parameters.isEmpty()) {
writeParameters(gen, parameters);
@@ -609,10 +606,10 @@ private String searchDocuments(String target, String sessionId, String user, Str
gen.write("text", text);
}
if (lower != null) {
- gen.write("lower", DateTools.dateToString(lower, Resolution.MINUTE));
+ gen.write("lower", roundMinute(lower, 0));
}
if (upper != null) {
- gen.write("upper", DateTools.dateToString(upper, Resolution.MINUTE));
+ gen.write("upper", roundMinute(upper, 59999));
}
if (parameters != null && !parameters.isEmpty()) {
writeParameters(gen, parameters);
@@ -665,10 +662,10 @@ String searchDatasets(String sessionId, String user, String text, Date lower, Da
gen.write("text", text);
}
if (lower != null) {
- gen.write("lower", DateTools.dateToString(lower, Resolution.MINUTE));
+ gen.write("lower", roundMinute(lower, 0));
}
if (upper != null) {
- gen.write("upper", DateTools.dateToString(upper, Resolution.MINUTE));
+ gen.write("upper", roundMinute(upper, 59999));
}
if (parameters != null && !parameters.isEmpty()) {
writeParameters(gen, parameters);
@@ -711,8 +708,8 @@ private void writeParameters(JsonGenerator gen, List paramet
if (parameter.getStringValue() != null) {
gen.write("stringValue", parameter.getStringValue());
} else if (parameter.getLowerDateValue() != null && parameter.getUpperDateValue() != null) {
- gen.write("lowerDateValue", DateTools.dateToString(parameter.getLowerDateValue(), Resolution.MINUTE));
- gen.write("upperDateValue", DateTools.dateToString(parameter.getUpperDateValue(), Resolution.MINUTE));
+ gen.write("lowerDateValue", roundMinute(parameter.getLowerDateValue(), 0));
+ gen.write("upperDateValue", roundMinute(parameter.getUpperDateValue(), 59999));
} else if (parameter.getLowerNumericValue() != null && parameter.getUpperNumericValue() != null) {
gen.write("lowerNumericValue", parameter.getLowerNumericValue());
gen.write("upperNumericValue", parameter.getUpperNumericValue());
@@ -851,10 +848,10 @@ String searchDatafiles(String sessionId, String user, String text, Date lower, D
gen.write("text", text);
}
if (lower != null) {
- gen.write("lower", DateTools.dateToString(lower, Resolution.MINUTE));
+ gen.write("lower", roundMinute(lower, 0));
}
if (upper != null) {
- gen.write("upper", DateTools.dateToString(upper, Resolution.MINUTE));
+ gen.write("upper", roundMinute(upper, 59999));
}
if (parameters != null && !parameters.isEmpty()) {
writeParameters(gen, parameters);
@@ -943,4 +940,13 @@ public String list(String sessionId, String path) throws IcatException {
}
}
+ /**
+ * @param date Date to round down to the minute
+ * @param offset Number of ms to be added to the returned value
+ * @return Rounded date, converted to ms with offset applied
+ */
+ private long roundMinute(Date date, long offset) {
+ return (date.getTime() / 60000) * 60000 + offset;
+ }
+
}
diff --git a/src/test/java/org/icatproject/icat/TestIcatClient.java b/src/test/java/org/icatproject/icat/TestIcatClient.java
index 43de411..6f0a160 100644
--- a/src/test/java/org/icatproject/icat/TestIcatClient.java
+++ b/src/test/java/org/icatproject/icat/TestIcatClient.java
@@ -106,7 +106,7 @@ public void testSession() throws Exception {
@Test
public void testInfo() throws Exception {
- assertTrue(icat.getVersion().startsWith("5.0."));
+ assertTrue(icat.getVersion().startsWith("5.1."));
}
}