Author: jens
Date: Tue Feb 28 07:30:10 2012
New Revision: 1294498
URL: http://svn.apache.org/viewvc?rev=1294498&view=rev
Log:
Fix NPE in order by on a system property for query [CMIS-510]
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/InMemoryQueryProcessor.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/EvalQueryTest.java
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/InMemoryQueryProcessor.java
URL:
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/InMemoryQueryProcessor.java?rev=1294498&r1=1294497&r2=1294498&view=diff
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/InMemoryQueryProcessor.java
(original)
+++
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/InMemoryQueryProcessor.java
Tue Feb 28 07:30:10 2012
@@ -183,8 +183,11 @@ public class InMemoryQueryProcessor {
if (sel instanceof ColumnReference) {
String propId = ((ColumnReference) sel).getPropertyId();
- Object propVal1 =
so1.getProperties().get(propId).getFirstValue();
- Object propVal2 =
so2.getProperties().get(propId).getFirstValue();
+ PropertyDefinition<?> pd = ((ColumnReference)
sel).getPropertyDefinition();
+
+ Object propVal1 = PropertyUtil.getProperty(so1, propId,
pd);
+ Object propVal2 = PropertyUtil.getProperty(so2, propId,
pd);
+
if (propVal1 == null && propVal2 == null) {
result = 0;
} else if (propVal1 == null) {
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/EvalQueryTest.java
URL:
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/EvalQueryTest.java?rev=1294498&r1=1294497&r2=1294498&view=diff
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/EvalQueryTest.java
(original)
+++
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/EvalQueryTest.java
Tue Feb 28 07:30:10 2012
@@ -473,7 +473,19 @@ public class EvalQueryTest extends Abstr
assertTrue(resultContainsAtPos("alpha", 2, res) ||
resultContainsAtPos("alpha", 1, res) || resultContainsAtPos("alpha", 0, res));
assertTrue(resultContainsAtPos("gamma", 2, res) ||
resultContainsAtPos("gamma", 1, res) || resultContainsAtPos("gamma", 0, res));
assertTrue(resultContainsAtPos("delta", 2, res) ||
resultContainsAtPos("delta", 1, res) || resultContainsAtPos("delta", 0, res));
-}
+ }
+
+ // reported JIRA issue CMIS-510
+ @Test
+ public void testOrderBySystemProperties() {
+ String statement = "SELECT * from cmis:document ORDER BY "+
PropertyIds.NAME;
+ ObjectList res = doQuery(statement);
+ assertEquals(5, res.getObjects().size());
+ statement = "SELECT * from cmis:document ORDER BY " +
PropertyIds.CREATION_DATE + " ASC";
+ assertEquals(5, res.getObjects().size());
+ statement = "SELECT * from cmis:document ORDER BY " +
PropertyIds.LAST_MODIFICATION_DATE + " DESC";
+ assertEquals(5, res.getObjects().size());
+ }
@Test
public void testIsNull() {