← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15598: add back support for links in web-api, included by default in identifiable, nameable presets

 

------------------------------------------------------------
revno: 15598
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-06-09 12:57:14 +0200
message:
  add back support for links in web-api, included by default in identifiable, nameable presets
modified:
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/filter/DefaultFilterService.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/filter/FilterService.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/DataElementOperandController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/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-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/filter/DefaultFilterService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/filter/DefaultFilterService.java	2014-06-09 10:11:03 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/filter/DefaultFilterService.java	2014-06-09 10:57:14 +0000
@@ -29,13 +29,12 @@
  */
 
 import com.google.common.base.Joiner;
+import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
 import org.hisp.dhis.common.IdentifiableObject;
 import org.hisp.dhis.dxf2.filter.ops.Op;
-import org.hisp.dhis.dxf2.timer.SystemNanoTimer;
-import org.hisp.dhis.dxf2.timer.Timer;
 import org.hisp.dhis.node.types.CollectionNode;
 import org.hisp.dhis.node.types.ComplexNode;
 import org.hisp.dhis.node.types.SimpleNode;
@@ -54,6 +53,12 @@
  */
 public class DefaultFilterService implements FilterService
 {
+    static final ImmutableMap<String, List<String>> FIELD_PRESETS = ImmutableMap.<String, List<String>>builder()
+        .put( "all", Lists.newArrayList( "*" ) )
+        .put( "identifiable", Lists.newArrayList( "id", "name", "code", "created", "lastUpdated", "href" ) )
+        .put( "nameable", Lists.newArrayList( "id", "name", "shortName", "description", "code", "created", "lastUpdated", "href" ) )
+        .build();
+
     @Autowired
     private ParserService parserService;
 
@@ -161,7 +166,7 @@
 
             if ( fieldValue.isEmpty() )
             {
-                List<String> fields = FilterService.FIELD_PRESETS.get( "identifiable" );
+                List<String> fields = FIELD_PRESETS.get( "identifiable" );
 
                 if ( property.isCollection() )
                 {
@@ -280,7 +285,7 @@
             }
             else if ( fieldKey.startsWith( ":" ) )
             {
-                List<String> fields = FilterService.FIELD_PRESETS.get( fieldKey.substring( 1 ) );
+                List<String> fields = FIELD_PRESETS.get( fieldKey.substring( 1 ) );
 
                 for ( String field : fields )
                 {

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/filter/FilterService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/filter/FilterService.java	2014-06-06 07:40:49 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/filter/FilterService.java	2014-06-09 10:57:14 +0000
@@ -28,8 +28,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
 import org.hisp.dhis.common.IdentifiableObject;
 import org.hisp.dhis.node.types.CollectionNode;
 
@@ -40,12 +38,6 @@
  */
 public interface FilterService
 {
-    static final ImmutableMap<String, List<String>> FIELD_PRESETS = ImmutableMap.<String, List<String>>builder()
-        .put( "all", Lists.newArrayList( "*" ) )
-        .put( "identifiable", Lists.newArrayList( "id", "name", "code", "created", "lastUpdated" ) )
-        .put( "nameable", Lists.newArrayList( "id", "name", "shortName", "description", "code", "created", "lastUpdated" ) )
-        .build();
-
     /**
      * Filter a list of objects based on un-parsed filter string.
      *

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java	2014-06-06 11:09:36 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java	2014-06-09 10:57:14 +0000
@@ -41,7 +41,6 @@
 import org.hisp.dhis.dxf2.metadata.ImportService;
 import org.hisp.dhis.dxf2.metadata.ImportTypeSummary;
 import org.hisp.dhis.dxf2.render.RenderService;
-import org.hisp.dhis.dxf2.utils.JacksonUtils;
 import org.hisp.dhis.hibernate.exception.CreateAccessDeniedException;
 import org.hisp.dhis.hibernate.exception.DeleteAccessDeniedException;
 import org.hisp.dhis.hibernate.exception.UpdateAccessDeniedException;
@@ -169,7 +168,7 @@
             options.getOptions().put( "viewClass", "sharing" );
         }
 
-        handleLinksAndAccess( options, metaData, entityList );
+        handleLinksAndAccess( options, entityList );
 
         RootNode rootNode = new RootNode( "metadata" );
         rootNode.setDefaultNamespace( DxfNamespaces.DXF_2_0 );
@@ -441,16 +440,11 @@
         ((BaseIdentifiableObject) object).setAccess( access );
     }
 
-    protected void handleLinksAndAccess( WebOptions options, WebMetaData metaData, List<T> entityList )
+    protected void handleLinksAndAccess( WebOptions options, List<T> entityList )
     {
         if ( options != null && options.hasLinks() )
         {
-            linkService.generateLinks( metaData );
-        }
-
-        if ( !JacksonUtils.isSharingView( options.getViewClass( "basic" ) ) )
-        {
-            return;
+            linkService.generateLinks( entityList );
         }
 
         if ( entityList != null && aclService.isSupported( getEntityClass() ) )

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/DataElementOperandController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/DataElementOperandController.java	2014-06-03 15:40:25 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/DataElementOperandController.java	2014-06-09 10:57:14 +0000
@@ -133,7 +133,7 @@
 
         String viewClass = options.getViewClass( "basic" );
 
-        handleLinksAndAccess( options, metaData, dataElementOperands );
+        handleLinksAndAccess( options, dataElementOperands );
 
         postProcessEntities( dataElementOperands );
         postProcessEntities( dataElementOperands, options, parameters );

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/DefaultLinkService.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/DefaultLinkService.java	2014-05-31 16:27:04 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/DefaultLinkService.java	2014-06-09 10:57:14 +0000
@@ -32,6 +32,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.hibernate.collection.spi.PersistentCollection;
+import org.hisp.dhis.common.LinkableObject;
 import org.hisp.dhis.schema.Property;
 import org.hisp.dhis.schema.Schema;
 import org.hisp.dhis.schema.SchemaService;