chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1356211 - in /chemistry/opencmis/trunk/chemistry-opencmis-client: chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/ chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runti...
Date Mon, 02 Jul 2012 13:18:33 GMT
Author: fmui
Date: Mon Jul  2 13:18:32 2012
New Revision: 1356211

URL: http://svn.apache.org/viewvc?rev=1356211&view=rev
Log:
CMIS-546: added setDateTimeTimestamp()

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/QueryStatement.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/QueryStatementImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/QueryStatementTest.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/QueryStatement.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/QueryStatement.java?rev=1356211&r1=1356210&r2=1356211&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/QueryStatement.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/QueryStatement.java
Mon Jul  2 13:18:32 2012
@@ -114,19 +114,34 @@ public interface QueryStatement extends 
     void setBoolean(int parameterIndex, boolean... bool);
 
     /**
-     * Sets the designated parameter to the given timestamp.
+     * Sets the designated parameter to the given DateTime value.
      */
     void setDateTime(int parameterIndex, Calendar... cal);
 
     /**
-     * Sets the designated parameter to the given timestamp.
+     * Sets the designated parameter to the given DateTime value.
      */
     void setDateTime(int parameterIndex, Date... date);
 
     /**
-     * Sets the designated parameter to the given timestamp.
+     * Sets the designated parameter to the given DateTime value.
      */
     void setDateTime(int parameterIndex, long... ms);
+    
+    /**
+     * Sets the designated parameter to the given DateTime value with the prefix 'TIMESTAMP
'.
+     */
+    void setDateTimeTimestamp(int parameterIndex, Calendar... cal);
+
+    /**
+     * Sets the designated parameter to the given DateTime value with the prefix 'TIMESTAMP
'.
+     */
+    void setDateTimeTimestamp(int parameterIndex, Date... date);
+
+    /**
+     * Sets the designated parameter to the given DateTime value with the prefix 'TIMESTAMP
'.
+     */
+    void setDateTimeTimestamp(int parameterIndex, long... ms);
 
     /**
      * Returns the query statement.

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/QueryStatementImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/QueryStatementImpl.java?rev=1356211&r1=1356210&r2=1356211&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/QueryStatementImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/QueryStatementImpl.java
Mon Jul  2 13:18:32 2012
@@ -231,6 +231,14 @@ public class QueryStatementImpl implemen
     }
 
     public void setDateTime(int parameterIndex, Calendar... cal) {
+        setDateTime(parameterIndex, false, cal);
+    }
+
+    public void setDateTimeTimestamp(int parameterIndex, Calendar... cal) {
+        setDateTime(parameterIndex, true, cal);
+    }
+
+    protected void setDateTime(int parameterIndex, boolean prefix, Calendar... cal) {
         if (cal == null || cal.length == 0) {
             throw new IllegalArgumentException("Calendar must be set!");
         }
@@ -245,6 +253,10 @@ public class QueryStatementImpl implemen
                 sb.append(",");
             }
 
+            if (prefix) {
+                sb.append("TIMESTAMP ");
+            }
+
             sb.append(convert(c.getTime()));
         }
 
@@ -252,6 +264,14 @@ public class QueryStatementImpl implemen
     }
 
     public void setDateTime(int parameterIndex, Date... date) {
+        setDateTime(parameterIndex, false, date);
+    }
+
+    public void setDateTimeTimestamp(int parameterIndex, Date... date) {
+        setDateTime(parameterIndex, true, date);
+    }
+
+    protected void setDateTime(int parameterIndex, boolean prefix, Date... date) {
         if (date == null || date.length == 0) {
             throw new IllegalArgumentException("Date must be set!");
         }
@@ -266,6 +286,10 @@ public class QueryStatementImpl implemen
                 sb.append(",");
             }
 
+            if (prefix) {
+                sb.append("TIMESTAMP ");
+            }
+
             sb.append(convert(d));
         }
 
@@ -273,6 +297,14 @@ public class QueryStatementImpl implemen
     }
 
     public void setDateTime(int parameterIndex, long... ms) {
+        setDateTime(parameterIndex, false, ms);
+    }
+
+    public void setDateTimeTimestamp(int parameterIndex, long... ms) {
+        setDateTime(parameterIndex, true, ms);
+    }
+
+    protected void setDateTime(int parameterIndex, boolean prefix, long... ms) {
         if (ms == null || ms.length == 0) {
             throw new IllegalArgumentException("Timestamp must be set!");
         }
@@ -283,6 +315,10 @@ public class QueryStatementImpl implemen
                 sb.append(",");
             }
 
+            if (prefix) {
+                sb.append("TIMESTAMP ");
+            }
+
             sb.append(convert(new Date(l)));
         }
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/QueryStatementTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/QueryStatementTest.java?rev=1356211&r1=1356210&r2=1356211&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/QueryStatementTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/QueryStatementTest.java
Mon Jul  2 13:18:32 2012
@@ -43,7 +43,7 @@ public class QueryStatementTest {
         query = "SELECT * FROM cmis:document WHERE cmis:createdBy = \'admin\' AND abc:int
= 42";
         st = new QueryStatementImpl(session, query);
         assertEquals(query, st.toQueryString());
-        
+
         query = "SELECT * FROM cmis:document WHERE abc:test = 'x?z'";
         st = new QueryStatementImpl(session, query);
         st.setString(1, "y");
@@ -112,5 +112,25 @@ public class QueryStatementTest {
         st.setDateTime(1, cal.getTimeInMillis());
         assertEquals("SELECT * FROM cmis:document WHERE abc:dateTime = TIMESTAMP '2012-02-02T03:04:05.000Z'",
                 st.toQueryString());
+
+        // dateTime Timestamp
+        query = "SELECT * FROM cmis:document WHERE abc:dateTime = ?";
+
+        st = new QueryStatementImpl(session, query);
+        st.setDateTimeTimestamp(1, cal);
+        assertEquals("SELECT * FROM cmis:document WHERE abc:dateTime = TIMESTAMP '2012-02-02T03:04:05.000Z'",
+                st.toQueryString());
+
+        st = new QueryStatementImpl(session, query);
+        st.setDateTimeTimestamp(1, cal.getTimeInMillis());
+        assertEquals("SELECT * FROM cmis:document WHERE abc:dateTime = TIMESTAMP '2012-02-02T03:04:05.000Z'",
+                st.toQueryString());
+
+        query = "SELECT * FROM cmis:document WHERE abc:dateTime IN (?)";
+
+        st = new QueryStatementImpl(session, query);
+        st.setDateTimeTimestamp(1, cal.getTime(), cal.getTime());
+        assertEquals("SELECT * FROM cmis:document WHERE abc:dateTime "
+                + "IN (TIMESTAMP '2012-02-02T03:04:05.000Z',TIMESTAMP '2012-02-02T03:04:05.000Z')",
st.toQueryString());
     }
 }



Mime
View raw message