← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16519: add displayName to /api/resources, gives an automatic 'beautified' version of the plural name, wi...

 

------------------------------------------------------------
revno: 16519
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-08-26 17:16:54 +0700
message:
  add displayName to /api/resources, gives an automatic 'beautified' version of the plural name, will probably replaced with proper i18n naming of resources later
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/IndexController.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-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/IndexController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/IndexController.java	2014-06-28 05:52:57 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/IndexController.java	2014-08-26 10:16:54 +0000
@@ -28,6 +28,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import org.apache.commons.lang.StringUtils;
 import org.hisp.dhis.common.DxfNamespaces;
 import org.hisp.dhis.node.types.CollectionNode;
 import org.hisp.dhis.node.types.ComplexNode;
@@ -97,6 +98,8 @@
             {
                 ComplexNode complexNode = collectionNode.addChild( new ComplexNode( "resource" ) );
 
+                // TODO add i18n to this
+                complexNode.addChild( new SimpleNode( "displayName", beautify( schema.getPlural() ) ) );
                 complexNode.addChild( new SimpleNode( "singular", schema.getSingular() ) );
                 complexNode.addChild( new SimpleNode( "plural", schema.getPlural() ) );
                 complexNode.addChild( new SimpleNode( "href", contextService.getContextPath() + "/api" + schema.getApiEndpoint() ) );
@@ -105,4 +108,10 @@
 
         return rootNode;
     }
+
+    private String beautify( String name )
+    {
+        String[] camelCaseWords = StringUtils.capitalize( name ).split( "(?=[A-Z])" );
+        return StringUtils.join( camelCaseWords, " " ).trim();
+    }
 }