------------------------------------------------------------ revno: 16519 committer: Morten Olav Hansen <morte...@gmail.com> 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(); + } }
_______________________________________________ Mailing list: https://launchpad.net/~dhis2-devs Post to : dhis2-devs@lists.launchpad.net Unsubscribe : https://launchpad.net/~dhis2-devs More help : https://help.launchpad.net/ListHelp