← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11484: (web-api) added shortName/description if object is Nameable. Added pdf/xls/csv to link listings.

 

------------------------------------------------------------
revno: 11484
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-07-23 14:24:20 +0700
message:
  (web-api) added shortName/description if object is Nameable. Added pdf/xls/csv to link listings.
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/AbstractGridView.java
  dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/identifiable-row.xsl


--
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-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/AbstractGridView.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/AbstractGridView.java	2013-07-22 12:08:33 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/AbstractGridView.java	2013-07-23 07:24:20 +0000
@@ -31,6 +31,7 @@
 import org.hisp.dhis.common.Grid;
 import org.hisp.dhis.common.GridHeader;
 import org.hisp.dhis.common.IdentifiableObject;
+import org.hisp.dhis.common.NameableObject;
 import org.hisp.dhis.system.grid.ListGrid;
 import org.hisp.dhis.system.util.PredicateUtils;
 import org.hisp.dhis.system.util.ReflectionUtils;
@@ -76,8 +77,17 @@
                 Grid grid = new ListGrid();
                 grid.setTitle( identifiableObjects.get( 0 ).getClass().getSimpleName() + "s" );
 
+                boolean nameable = false;
+
                 grid.addHeader( new GridHeader( "UID", false, false ) );
                 grid.addHeader( new GridHeader( "Name", false, false ) );
+
+                if ( NameableObject.class.isAssignableFrom( identifiableObjects.get( 0 ).getClass() ) )
+                {
+                    grid.addHeader( new GridHeader( "ShortName", false, false ) );
+                    nameable = true;
+                }
+
                 grid.addHeader( new GridHeader( "Code", false, false ) );
 
                 for ( IdentifiableObject identifiableObject : identifiableObjects )
@@ -85,6 +95,12 @@
                     grid.addRow();
                     grid.addValue( identifiableObject.getUid() );
                     grid.addValue( identifiableObject.getName() );
+
+                    if ( nameable )
+                    {
+                        grid.addValue( ((NameableObject) identifiableObject).getShortName() );
+                    }
+
                     grid.addValue( identifiableObject.getCode() );
                 }
 
@@ -101,6 +117,13 @@
 
             grid.addRow().addValue( "UID" ).addValue( identifiableObject.getUid() );
             grid.addRow().addValue( "Name" ).addValue( identifiableObject.getName() );
+
+            if ( NameableObject.class.isAssignableFrom( identifiableObject.getClass() ) )
+            {
+                grid.addRow().addValue( "ShortName" ).addValue( ((NameableObject) identifiableObject).getShortName() );
+                grid.addRow().addValue( "Description" ).addValue( ((NameableObject) identifiableObject).getDescription() );
+            }
+
             grid.addRow().addValue( "Code" ).addValue( identifiableObject.getCode() );
 
             grids.add( grid );

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/identifiable-row.xsl'
--- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/identifiable-row.xsl	2012-07-20 10:15:43 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/identifiable-row.xsl	2013-07-23 07:24:20 +0000
@@ -9,6 +9,9 @@
       <td> <a href="{@href}.xml">xml</a> </td>
       <td> <a href="{@href}.json">json</a> </td>
       <td> <a href="{@href}.jsonp">jsonp</a> </td>
+      <td> <a href="{@href}.pdf">pdf</a> </td>
+      <td> <a href="{@href}.xls">xls</a> </td>
+      <td> <a href="{@href}.csv">csv</a> </td>
     </tr>
   </xsl:template>