← Back to team overview

dhis2-devs team mailing list archive

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

 

------------------------------------------------------------
revno: 18644
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-03-20 10:13:40 +0700
message:
  minor fix
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/query/Query.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Schema.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-03-20 03:00:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/query/Query.java	2015-03-20 03:13:40 +0000
@@ -169,14 +169,14 @@
             return this;
         }
 
-        Optional<Property> name = Optional.fromNullable( schema.getProperty( "name" ) );
-        Optional<Property> created = Optional.fromNullable( schema.getProperty( "created" ) );
+        Optional<Property> name = Optional.fromNullable( schema.getPersistedProperty( "name" ) );
+        Optional<Property> created = Optional.fromNullable( schema.getPersistedProperty( "created" ) );
 
-        if ( name.isPresent() && name.get().isPersisted() )
+        if ( name.isPresent() )
         {
             addOrder( Order.asc( name.get() ) );
         }
-        else if ( created.isPresent() && created.get().isPersisted() )
+        else if ( created.isPresent() )
         {
             addOrder( Order.desc( created.get() ) );
         }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Schema.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Schema.java	2015-03-06 07:00:14 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Schema.java	2015-03-20 03:13:40 +0000
@@ -328,6 +328,11 @@
         return getPropertyMap().containsKey( propertyName );
     }
 
+    public boolean havePersistedProperty( String propertyName )
+    {
+        return haveProperty( propertyName ) && getProperty( propertyName ).isPersisted();
+    }
+
     public Property propertyByRole( String role )
     {
         if ( !StringUtils.isEmpty( role ) )
@@ -376,6 +381,19 @@
         return null;
     }
 
+    @JsonIgnore
+    public Property getPersistedProperty( String name )
+    {
+        Property property = getProperty( name );
+
+        if ( property != null && property.isPersisted() )
+        {
+            return property;
+        }
+
+        return null;
+    }
+
     private Map<AuthorityType, List<String>> authorityMap = Maps.newHashMap();
 
     public List<String> getAuthorityByType( AuthorityType type )