dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #41397
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21088: Moved support method getDisplayProperty from utils to BaseNameableObject
------------------------------------------------------------
revno: 21088
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-11-17 14:49:52 +0100
message:
Moved support method getDisplayProperty from utils to BaseNameableObject
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseNameableObject.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/NameableObject.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/NameableObjectUtils.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.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/common/BaseNameableObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseNameableObject.java 2015-10-05 17:45:17 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseNameableObject.java 2015-11-17 13:49:52 +0000
@@ -1,5 +1,7 @@
package org.hisp.dhis.common;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
/*
* Copyright (c) 2004-2015, University of Oslo
* All rights reserved.
@@ -97,10 +99,33 @@
}
// -------------------------------------------------------------------------
+ // Logic
+ // -------------------------------------------------------------------------
+
+ /**
+ * Returns the display property indicated by the given display property. Falls
+ * back to display name if display short name is null.
+ *
+ * @param displayProperty the display property.
+ * @return the display property.
+ */
+ @JsonIgnore
+ public String getDisplayProperty( DisplayProperty displayProperty )
+ {
+ if ( DisplayProperty.SHORTNAME.equals( displayProperty ) && getDisplayShortName() != null )
+ {
+ return getDisplayShortName();
+ }
+ else
+ {
+ return getDisplayName();
+ }
+ }
+
+ // -------------------------------------------------------------------------
// hashCode and equals
// -------------------------------------------------------------------------
-
@Override
public int hashCode()
{
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/NameableObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/NameableObject.java 2015-06-01 03:33:13 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/NameableObject.java 2015-11-17 13:49:52 +0000
@@ -45,4 +45,6 @@
String getDisplayShortName();
String getDisplayDescription();
+
+ String getDisplayProperty( DisplayProperty property );
}
\ No newline at end of file
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/NameableObjectUtils.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/NameableObjectUtils.java 2015-09-03 03:11:47 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/NameableObjectUtils.java 2015-11-17 13:49:52 +0000
@@ -204,7 +204,7 @@
{
for ( NameableObject object : objects )
{
- map.put( object.getUid(), getDisplayProperty( object, displayProperty ) );
+ map.put( object.getUid(), object.getDisplayProperty( displayProperty ) );
}
}
@@ -242,32 +242,7 @@
return map;
}
-
- /**
- * Returns the property of the given object indicated by the given display
- * property. Falls back to name if short name is null.
- *
- * @param object the object to read the property from.
- * @param displayProperty the display property to use.
- * @return a property value.
- */
- public static <T extends NameableObject> String getDisplayProperty( T object, DisplayProperty displayProperty )
- {
- if ( object != null )
- {
- if ( DisplayProperty.SHORTNAME.equals( displayProperty ) && object.getDisplayShortName() != null )
- {
- return object.getDisplayShortName();
- }
- else
- {
- return object.getDisplayName();
- }
- }
- return null;
- }
-
/**
* Returns a copy of the given list. Returns an empty list if the argument is null.
*
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java 2015-10-12 16:06:36 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java 2015-11-17 13:49:52 +0000
@@ -70,8 +70,6 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import static org.hisp.dhis.common.NameableObjectUtils.getDisplayProperty;
-
/**
* @author Kristian Nordal
*/
@@ -783,7 +781,7 @@
{
for ( OrganisationUnit unit : organisationUnits )
{
- map.put( getDisplayProperty( unit, displayProperty ), unit.getParentNameGraph( roots, includeThis ) );
+ map.put( unit.getDisplayProperty( displayProperty ), unit.getParentNameGraph( roots, includeThis ) );
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java 2015-11-05 02:57:57 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java 2015-11-17 13:49:52 +0000
@@ -958,7 +958,7 @@
}
else
{
- map.put( object.getUid(), NameableObjectUtils.getDisplayProperty( object, params.getDisplayProperty() ) );
+ map.put( object.getUid(), object.getDisplayProperty( params.getDisplayProperty() ) );
}
if ( DimensionType.ORGANISATIONUNIT.equals( dimension.getDimensionType() ) && params.isHierarchyMeta() )
@@ -969,7 +969,7 @@
}
}
- map.put( dimension.getDimension(), NameableObjectUtils.getDisplayProperty( dimension, params.getDisplayProperty() ) );
+ map.put( dimension.getDimension(), dimension.getDisplayProperty( params.getDisplayProperty() ) );
}
return map;
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java 2015-11-05 02:57:57 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java 2015-11-17 13:49:52 +0000
@@ -344,7 +344,7 @@
if ( params.hasValueDimension() )
{
- map.put( params.getValue().getUid(), NameableObjectUtils.getDisplayProperty( params.getValue(), params.getDisplayProperty() ) );
+ map.put( params.getValue().getUid(), params.getValue().getDisplayProperty( params.getDisplayProperty() ) );
}
map.putAll( getUidNameMap( params.getItems(), params.getDisplayProperty() ) );
@@ -362,7 +362,7 @@
for ( QueryItem item : queryItems )
{
- map.put( item.getItem().getUid(), NameableObjectUtils.getDisplayProperty( item.getItem(), displayProperty ) );
+ map.put( item.getItem().getUid(), item.getItem().getDisplayProperty( displayProperty ) );
}
return map;
@@ -390,7 +390,7 @@
map.putAll( NameableObjectUtils.getUidDisplayPropertyMap( objects, displayProperty ) );
}
- map.put( dimension.getDimension(), NameableObjectUtils.getDisplayProperty( dimension, displayProperty ) );
+ map.put( dimension.getDimension(), dimension.getDisplayProperty( displayProperty ) );
}
return map;