← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14247: minor rename from saveTrackedEntityAttributeGroup to addTrackedEntityAttributeGroup, also added m...

 

------------------------------------------------------------
revno: 14247
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-03-17 14:09:26 +0100
message:
  minor rename from saveTrackedEntityAttributeGroup to addTrackedEntityAttributeGroup, also added method for getting by uid
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeGroupService.java
  dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAttributeGroupService.java
  dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeGroupServiceTest.java
  dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeServiceTest.java
  dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeStoreTest.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/TrackedEntityAttributeController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/TrackedEntityAttributeGroupController.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattributegroup/AddAttributeGroupAction.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-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeGroupService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeGroupService.java	2014-02-07 20:25:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeGroupService.java	2014-03-17 13:09:26 +0000
@@ -46,7 +46,7 @@
      * 
      * @return A generated unique id of the added {@link TrackedEntityAttributeGroup}.
      */
-    int saveTrackedEntityAttributeGroup( TrackedEntityAttributeGroup TrackedEntityAttributeGroup );
+    int addTrackedEntityAttributeGroup( TrackedEntityAttributeGroup TrackedEntityAttributeGroup );
 
     /**
      * Deletes a {@link TrackedEntityAttributeGroup}.
@@ -72,6 +72,15 @@
     TrackedEntityAttributeGroup getTrackedEntityAttributeGroup( int id );
 
     /**
+     * Returns a {@link TrackedEntityAttributeGroup}.
+     *
+     * @param uid the id of the TrackedEntityAttributeGroup to return.
+     *
+     * @return the TrackedEntityAttributeGroup with the given id
+     */
+    TrackedEntityAttributeGroup getTrackedEntityAttributeGroup( String uid );
+
+    /**
      * Returns a {@link TrackedEntityAttributeGroup} with a given name.
      * 
      * @param name the name of the TrackedEntityAttributeGroup to return.

=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAttributeGroupService.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAttributeGroupService.java	2014-02-07 20:25:49 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAttributeGroupService.java	2014-03-17 13:09:26 +0000
@@ -28,18 +28,15 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import static org.hisp.dhis.i18n.I18nUtils.i18n;
+import org.hisp.dhis.common.GenericIdentifiableObjectStore;
+import org.hisp.dhis.i18n.I18nService;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
-import org.hisp.dhis.common.GenericIdentifiableObjectStore;
-import org.hisp.dhis.i18n.I18nService;
-import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
-import org.hisp.dhis.trackedentity.TrackedEntityAttributeGroup;
-import org.hisp.dhis.trackedentity.TrackedEntityAttributeGroupService;
-import org.springframework.transaction.annotation.Transactional;
+import static org.hisp.dhis.i18n.I18nUtils.i18n;
 
 /**
  * @author Chau Thu Tran
@@ -72,7 +69,7 @@
     // -------------------------------------------------------------------------
 
     @Override
-    public int saveTrackedEntityAttributeGroup( TrackedEntityAttributeGroup attributeGroup )
+    public int addTrackedEntityAttributeGroup( TrackedEntityAttributeGroup attributeGroup )
     {
         return attributeGroupStore.save( attributeGroup );
     }
@@ -90,12 +87,18 @@
     }
 
     @Override
-     public TrackedEntityAttributeGroup getTrackedEntityAttributeGroup( int id )
+    public TrackedEntityAttributeGroup getTrackedEntityAttributeGroup( int id )
     {
         return i18n( i18nService, attributeGroupStore.get( id ) );
     }
 
     @Override
+    public TrackedEntityAttributeGroup getTrackedEntityAttributeGroup( String uid )
+    {
+        return i18n( i18nService, attributeGroupStore.getByUid( uid ) );
+    }
+
+    @Override
     public TrackedEntityAttributeGroup getTrackedEntityAttributeGroupByName( String name )
     {
         return i18n( i18nService, attributeGroupStore.getByName( name ) );
@@ -108,7 +111,7 @@
     }
 
     @Override
-     public List<TrackedEntityAttribute> getTrackedEntityAttributes( TrackedEntityAttributeGroup attributeGroup )
+    public List<TrackedEntityAttribute> getTrackedEntityAttributes( TrackedEntityAttributeGroup attributeGroup )
     {
         return new ArrayList<TrackedEntityAttribute>( i18n( i18nService, attributeGroup.getAttributes() ) );
     }

=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeGroupServiceTest.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeGroupServiceTest.java	2014-02-07 20:25:49 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeGroupServiceTest.java	2014-03-17 13:09:26 +0000
@@ -36,10 +36,6 @@
 import java.util.List;
 
 import org.hisp.dhis.DhisSpringTest;
-import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
-import org.hisp.dhis.trackedentity.TrackedEntityAttributeGroup;
-import org.hisp.dhis.trackedentity.TrackedEntityAttributeGroupService;
-import org.hisp.dhis.trackedentity.TrackedEntityAttributeService;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 
@@ -86,8 +82,8 @@
     @Test
     public void testsaveTrackedEntityAttributeGroup()
     {
-        int idA = attributeGroupService.saveTrackedEntityAttributeGroup( attributeGroupA );
-        int idB = attributeGroupService.saveTrackedEntityAttributeGroup( attributeGroupB );
+        int idA = attributeGroupService.addTrackedEntityAttributeGroup( attributeGroupA );
+        int idB = attributeGroupService.addTrackedEntityAttributeGroup( attributeGroupB );
 
         assertNotNull( attributeGroupService.getTrackedEntityAttributeGroup( idA ) );
         assertNotNull( attributeGroupService.getTrackedEntityAttributeGroup( idB ) );
@@ -96,8 +92,8 @@
     @Test
     public void testdeleteTrackedEntityAttributeGroup()
     {
-        int idA = attributeGroupService.saveTrackedEntityAttributeGroup( attributeGroupA );
-        int idB = attributeGroupService.saveTrackedEntityAttributeGroup( attributeGroupB );
+        int idA = attributeGroupService.addTrackedEntityAttributeGroup( attributeGroupA );
+        int idB = attributeGroupService.addTrackedEntityAttributeGroup( attributeGroupB );
 
         assertNotNull( attributeGroupService.getTrackedEntityAttributeGroup( idA ) );
         assertNotNull( attributeGroupService.getTrackedEntityAttributeGroup( idB ) );
@@ -116,7 +112,7 @@
     @Test
     public void testUpdateEntityInstanceAttributeGroup()
     {
-        int idA = attributeGroupService.saveTrackedEntityAttributeGroup( attributeGroupA );
+        int idA = attributeGroupService.addTrackedEntityAttributeGroup( attributeGroupA );
 
         assertNotNull( attributeGroupService.getTrackedEntityAttributeGroup( idA ) );
 
@@ -129,8 +125,8 @@
     @Test
     public void testgetTrackedEntityAttributeGroupById()
     {
-        int idA = attributeGroupService.saveTrackedEntityAttributeGroup( attributeGroupA );
-        int idB = attributeGroupService.saveTrackedEntityAttributeGroup( attributeGroupB );
+        int idA = attributeGroupService.addTrackedEntityAttributeGroup( attributeGroupA );
+        int idB = attributeGroupService.addTrackedEntityAttributeGroup( attributeGroupB );
 
         assertEquals( attributeGroupA, attributeGroupService.getTrackedEntityAttributeGroup( idA ) );
         assertEquals( attributeGroupB, attributeGroupService.getTrackedEntityAttributeGroup( idB ) );
@@ -139,7 +135,7 @@
     @Test
     public void testgetTrackedEntityAttributeGroupByName()
     {
-        int idA = attributeGroupService.saveTrackedEntityAttributeGroup( attributeGroupA );
+        int idA = attributeGroupService.addTrackedEntityAttributeGroup( attributeGroupA );
 
         assertNotNull( attributeGroupService.getTrackedEntityAttributeGroup( idA ) );
         assertEquals( attributeGroupA.getName(),
@@ -149,8 +145,8 @@
     @Test
     public void testGetAllTrackedEntityAttributeGroups()
     {
-        attributeGroupService.saveTrackedEntityAttributeGroup( attributeGroupA );
-        attributeGroupService.saveTrackedEntityAttributeGroup( attributeGroupB );
+        attributeGroupService.addTrackedEntityAttributeGroup( attributeGroupA );
+        attributeGroupService.addTrackedEntityAttributeGroup( attributeGroupB );
 
         assertTrue( equals( attributeGroupService.getAllTrackedEntityAttributeGroups(), attributeGroupA, attributeGroupB ) );
     }

=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeServiceTest.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeServiceTest.java	2014-02-07 20:25:49 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeServiceTest.java	2014-03-17 13:09:26 +0000
@@ -35,10 +35,6 @@
 import java.util.List;
 
 import org.hisp.dhis.DhisSpringTest;
-import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
-import org.hisp.dhis.trackedentity.TrackedEntityAttributeGroup;
-import org.hisp.dhis.trackedentity.TrackedEntityAttributeGroupService;
-import org.hisp.dhis.trackedentity.TrackedEntityAttributeStore;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 
@@ -133,7 +129,7 @@
         attributeStore.save( attributeB );
         attributeStore.save( attributeC );
 
-        attributeGroupService.saveTrackedEntityAttributeGroup( attributeGroup );
+        attributeGroupService.addTrackedEntityAttributeGroup( attributeGroup );
 
         Collection<TrackedEntityAttribute> attributes = attributeStore.getOptionalAttributesWithoutGroup();
         assertEquals( 1, attributes.size() );

=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeStoreTest.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeStoreTest.java	2014-02-07 20:25:49 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeStoreTest.java	2014-03-17 13:09:26 +0000
@@ -37,10 +37,6 @@
 import java.util.List;
 
 import org.hisp.dhis.DhisSpringTest;
-import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
-import org.hisp.dhis.trackedentity.TrackedEntityAttributeGroup;
-import org.hisp.dhis.trackedentity.TrackedEntityAttributeGroupService;
-import org.hisp.dhis.trackedentity.TrackedEntityAttributeService;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 
@@ -216,7 +212,7 @@
         attributeService.saveTrackedEntityAttribute( attributeB );
         attributeService.saveTrackedEntityAttribute( attributeC );
 
-        attributeGroupService.saveTrackedEntityAttributeGroup( attributeGroup );
+        attributeGroupService.addTrackedEntityAttributeGroup( attributeGroup );
 
         Collection<TrackedEntityAttribute> attributes = attributeService.getOptionalAttributesWithoutGroup();
         assertEquals( 1, attributes.size() );

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/TrackedEntityAttributeController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/TrackedEntityAttributeController.java	2014-03-17 12:31:06 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/TrackedEntityAttributeController.java	2014-03-17 13:09:26 +0000
@@ -28,6 +28,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -40,8 +41,16 @@
 import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
 import org.hisp.dhis.trackedentity.TrackedEntityAttributeService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
 import org.springframework.stereotype.Controller;
+import org.springframework.web.HttpRequestMethodNotSupportedException;
+import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseStatus;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -101,4 +110,48 @@
 
         return entityList;
     }
+
+    //--------------------------------------------------------------------------
+    // POST
+    //--------------------------------------------------------------------------
+
+    @RequestMapping( method = RequestMethod.POST, consumes = { "application/xml", "text/xml" } )
+    public void postXmlObject( HttpServletResponse response, HttpServletRequest request, InputStream input ) throws Exception
+    {
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+    }
+
+    @RequestMapping( method = RequestMethod.POST, consumes = "application/json" )
+    public void postJsonObject( HttpServletResponse response, HttpServletRequest request, InputStream input ) throws Exception
+    {
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+    }
+    //--------------------------------------------------------------------------
+    // PUT
+    //--------------------------------------------------------------------------
+
+    @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, consumes = { "application/xml", "text/xml" } )
+    @ResponseStatus( value = HttpStatus.NO_CONTENT )
+    public void putXmlObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+    {
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
+    }
+
+    @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, consumes = "application/json" )
+    @ResponseStatus( value = HttpStatus.NO_CONTENT )
+    public void putJsonObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+    {
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
+    }
+
+    //--------------------------------------------------------------------------
+    // DELETE
+    //--------------------------------------------------------------------------
+
+    @RequestMapping( value = "/{uid}", method = RequestMethod.DELETE )
+    @ResponseStatus( value = HttpStatus.NO_CONTENT )
+    public void deleteObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid ) throws Exception
+    {
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+    }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/TrackedEntityAttributeGroupController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/TrackedEntityAttributeGroupController.java	2014-03-17 12:24:16 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/TrackedEntityAttributeGroupController.java	2014-03-17 13:09:26 +0000
@@ -30,8 +30,19 @@
 
 import org.hisp.dhis.api.controller.AbstractCrudController;
 import org.hisp.dhis.trackedentity.TrackedEntityAttributeGroup;
+import org.hisp.dhis.trackedentity.TrackedEntityAttributeGroupService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
 import org.springframework.stereotype.Controller;
+import org.springframework.web.HttpRequestMethodNotSupportedException;
+import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseStatus;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.InputStream;
 
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -41,4 +52,51 @@
 public class TrackedEntityAttributeGroupController extends AbstractCrudController<TrackedEntityAttributeGroup>
 {
     public static final String RESOURCE_PATH = "/trackedEntityAttributeGroups";
+
+    @Autowired
+    private TrackedEntityAttributeGroupService trackedEntityAttributeGroupService;
+
+    //--------------------------------------------------------------------------
+    // POST
+    //--------------------------------------------------------------------------
+
+    @RequestMapping( method = RequestMethod.POST, consumes = { "application/xml", "text/xml" } )
+    public void postXmlObject( HttpServletResponse response, HttpServletRequest request, InputStream input ) throws Exception
+    {
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+    }
+
+    @RequestMapping( method = RequestMethod.POST, consumes = "application/json" )
+    public void postJsonObject( HttpServletResponse response, HttpServletRequest request, InputStream input ) throws Exception
+    {
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+    }
+    //--------------------------------------------------------------------------
+    // PUT
+    //--------------------------------------------------------------------------
+
+    @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, consumes = { "application/xml", "text/xml" } )
+    @ResponseStatus( value = HttpStatus.NO_CONTENT )
+    public void putXmlObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+    {
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
+    }
+
+    @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, consumes = "application/json" )
+    @ResponseStatus( value = HttpStatus.NO_CONTENT )
+    public void putJsonObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+    {
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
+    }
+
+    //--------------------------------------------------------------------------
+    // DELETE
+    //--------------------------------------------------------------------------
+
+    @RequestMapping( value = "/{uid}", method = RequestMethod.DELETE )
+    @ResponseStatus( value = HttpStatus.NO_CONTENT )
+    public void deleteObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid ) throws Exception
+    {
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+    }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattributegroup/AddAttributeGroupAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattributegroup/AddAttributeGroupAction.java	2014-02-07 20:25:49 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattributegroup/AddAttributeGroupAction.java	2014-03-17 13:09:26 +0000
@@ -113,7 +113,7 @@
         }
         attributeGroup.setAttributes( attributes );
 
-        attributeGroupService.saveTrackedEntityAttributeGroup( attributeGroup );
+        attributeGroupService.addTrackedEntityAttributeGroup( attributeGroup );
 
         return SUCCESS;
     }