← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18374: minor fix

 

------------------------------------------------------------
revno: 18374
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-02-23 11:59:43 +0700
message:
  minor fix
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/query/Query.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/query/Query.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/query/Query.java	2015-02-20 09:14:02 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/query/Query.java	2015-02-23 04:59:43 +0000
@@ -29,6 +29,8 @@
  */
 
 import com.google.common.base.MoreObjects;
+import com.google.common.base.Optional;
+import org.hisp.dhis.schema.Property;
 import org.hisp.dhis.schema.Schema;
 
 import java.util.ArrayList;
@@ -167,13 +169,16 @@
             return this;
         }
 
-        if ( schema.haveProperty( "name" ) && schema.getProperty( "name" ).isPersisted() )
+        Optional<Property> name = Optional.fromNullable( schema.getProperty( "name" ) );
+        Optional<Property> created = Optional.fromNullable( schema.getProperty( "created" ) );
+
+        if ( name.isPresent() )
         {
-            addOrder( Order.asc( schema.getProperty( "name" ) ) );
+            addOrder( Order.asc( name.get() ) );
         }
-        else
+        else if ( created.isPresent() )
         {
-            addOrder( Order.desc( schema.getProperty( "created" ) ) );
+            addOrder( Order.desc( created.get() ) );
         }
 
         return this;