dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #19800
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8785: Adding transient property parentGraph to MapView
------------------------------------------------------------
revno: 8785
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-10-31 11:03:54 +0300
message:
Adding transient property parentGraph to MapView
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapView.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractCrudController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapController.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/mapping/MapView.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapView.java 2012-10-25 17:18:52 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapView.java 2012-10-31 08:03:54 +0000
@@ -112,6 +112,8 @@
private OrganisationUnitGroupSet organisationUnitGroupSet;
+ private transient String parentGraph;
+
public MapView()
{
}
@@ -420,6 +422,19 @@
this.organisationUnitGroupSet = organisationUnitGroupSet;
}
+ @JsonProperty
+ @JsonView( {DetailedView.class, ExportView.class} )
+ @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
+ public String getParentGraph()
+ {
+ return parentGraph;
+ }
+
+ public void setParentGraph( String parentGraph )
+ {
+ this.parentGraph = parentGraph;
+ }
+
@Override
public String toString()
{
=== 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 2012-10-25 12:07:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java 2012-10-31 08:03:54 +0000
@@ -135,7 +135,7 @@
private transient List<String> groupNames = new ArrayList<String>();
private transient Double value;
-
+
// -------------------------------------------------------------------------
// Constructors
// -------------------------------------------------------------------------
@@ -545,6 +545,20 @@
{
return featureType.equals( FEATURETYPE_POINT );
}
+
+ public String getParentGraph()
+ {
+ StringBuilder builder = new StringBuilder();
+
+ List<OrganisationUnit> anchestors = getAncestors();
+
+ for ( OrganisationUnit unit : anchestors )
+ {
+ builder.append( "/" ).append( unit.getUid() );
+ }
+
+ return builder.toString();
+ }
// -------------------------------------------------------------------------
// hashCode, equals and toString
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractCrudController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractCrudController.java 2012-10-26 17:22:12 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractCrudController.java 2012-10-31 08:03:54 +0000
@@ -224,6 +224,10 @@
{
}
+ /**
+ * Override to process a single entity after it has been retrieved from
+ * storage and before it is returned to the view. Entity is null-safe.
+ */
public void postProcessEntity( T entity, Map<String, String> parameters ) throws Exception
{
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapController.java 2012-10-31 06:11:09 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapController.java 2012-10-31 08:03:54 +0000
@@ -174,6 +174,18 @@
mappingService.deleteMap( map );
}
+
+ @Override
+ public void postProcessEntity( Map map )
+ {
+ for ( MapView view : map.getMapViews() )
+ {
+ if ( view != null && view.getParentOrganisationUnit() != null )
+ {
+ view.setParentGraph( view.getParentOrganisationUnit().getParentGraph() );
+ }
+ }
+ }
//--------------------------------------------------------------------------
// Supportive methods