← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19005: minor fix in LinkService, support collections of references also for apiEndpoints

 

------------------------------------------------------------
revno: 19005
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-04-24 13:56:02 +0700
message:
  minor fix in LinkService, support collections of references also for apiEndpoints
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/service/DefaultLinkService.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/service/DefaultLinkService.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/service/DefaultLinkService.java	2015-04-24 06:48:37 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/service/DefaultLinkService.java	2015-04-24 06:56:02 +0000
@@ -145,17 +145,27 @@
     {
         for ( Property property : schema.getProperties() )
         {
-            Schema klassSchema = schemaService.getDynamicSchema( property.getKlass() );
-
-            if ( property.is( PropertyType.REFERENCE ) )
-            {
-                property.setHref( hrefBase + "/schemas/" + klassSchema.getSingular() );
-
-                if ( klassSchema.haveApiEndpoint() )
-                {
-                    property.setApiEndpoint( hrefBase + klassSchema.getApiEndpoint() );
-                }
-            }
+            if ( PropertyType.REFERENCE == property.getPropertyType() )
+            {
+                Schema klassSchema = schemaService.getDynamicSchema( property.getKlass() );
+                property.setHref( hrefBase + "/schemas/" + klassSchema.getSingular() );
+
+                if ( klassSchema.haveApiEndpoint() )
+                {
+                    property.setApiEndpoint( hrefBase + klassSchema.getApiEndpoint() );
+                }
+            }
+            else if ( PropertyType.REFERENCE == property.getItemPropertyType() )
+            {
+                Schema klassSchema = schemaService.getDynamicSchema( property.getItemKlass() );
+                property.setHref( hrefBase + "/schemas/" + klassSchema.getSingular() );
+
+                if ( klassSchema.haveApiEndpoint() )
+                {
+                    property.setApiEndpoint( hrefBase + klassSchema.getApiEndpoint() );
+                }
+            }
+
         }
     }