dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #36638
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18742: Analytics. Meta data org unit hierarchy names now respect display property.
------------------------------------------------------------
revno: 18742
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-03-30 12:16:10 +0200
message:
Analytics. Meta data org unit hierarchy names now respect display property.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectUtils.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
--
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/IdentifiableObjectUtils.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectUtils.java 2015-03-19 12:24:51 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectUtils.java 2015-03-30 10:16:10 +0000
@@ -28,14 +28,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import org.hisp.dhis.calendar.Calendar;
-import org.hisp.dhis.calendar.DateTimeUnit;
-import org.hisp.dhis.dataelement.DataElementCategory;
-import org.hisp.dhis.dataelement.DataElementCategoryCombo;
-import org.hisp.dhis.dataelement.DataElementCategoryOption;
-import org.hisp.dhis.period.Period;
-import org.hisp.dhis.period.PeriodType;
-
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
@@ -47,6 +39,14 @@
import java.util.ListIterator;
import java.util.Map;
+import org.hisp.dhis.calendar.Calendar;
+import org.hisp.dhis.calendar.DateTimeUnit;
+import org.hisp.dhis.dataelement.DataElementCategory;
+import org.hisp.dhis.dataelement.DataElementCategoryCombo;
+import org.hisp.dhis.dataelement.DataElementCategoryOption;
+import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.PeriodType;
+
/**
* @author Lars Helge Overland
*/
=== 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-03-07 16:16:41 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/NameableObjectUtils.java 2015-03-30 10:16:10 +0000
@@ -240,4 +240,29 @@
return map;
}
+
+ /**
+ * Returns the property of the given object indicated by the given display
+ * property.
+ *
+ * @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 getProperty( T object, DisplayProperty displayProperty )
+ {
+ if ( object != null )
+ {
+ if ( DisplayProperty.SHORTNAME.equals( displayProperty ) )
+ {
+ return object.getDisplayShortName();
+ }
+ else // NAME
+ {
+ return object.getDisplayName();
+ }
+ }
+
+ return 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-02-26 15:21:29 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java 2015-03-30 10:16:10 +0000
@@ -34,10 +34,12 @@
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+
import org.apache.commons.lang3.StringUtils;
import org.hisp.dhis.attribute.AttributeValue;
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.BaseNameableObject;
+import org.hisp.dhis.common.DisplayProperty;
import org.hisp.dhis.common.DxfNamespaces;
import org.hisp.dhis.common.IdentifiableObject;
import org.hisp.dhis.common.MergeStrategy;
@@ -69,6 +71,8 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import static org.hisp.dhis.common.NameableObjectUtils.getProperty;
+
/**
* @author Kristian Nordal
*/
@@ -757,7 +761,8 @@
* Returns a mapping between the uid and the uid parent graph of the given
* organisation units.
*/
- public static Map<String, String> getParentNameGraphMap( List<OrganisationUnit> organisationUnits, Collection<OrganisationUnit> roots, boolean includeThis )
+ public static Map<String, String> getParentNameGraphMap( List<OrganisationUnit> organisationUnits,
+ Collection<OrganisationUnit> roots, boolean includeThis, DisplayProperty displayProperty )
{
Map<String, String> map = new HashMap<>();
@@ -765,7 +770,7 @@
{
for ( OrganisationUnit unit : organisationUnits )
{
- map.put( unit.getName(), unit.getParentNameGraph( roots, includeThis ) );
+ map.put( getProperty( unit, 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-03-26 14:25:02 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java 2015-03-30 10:16:10 +0000
@@ -513,7 +513,7 @@
if ( params.isShowHierarchy() )
{
- metaData.put( OU_NAME_HIERARCHY_KEY, getParentNameGraphMap( organisationUnits, roots, true ) );
+ metaData.put( OU_NAME_HIERARCHY_KEY, getParentNameGraphMap( organisationUnits, roots, true, params.getDisplayProperty() ) );
}
grid.setMetaData( metaData );