dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #33993
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17429: remove custom crud for TEA, TEAG, use default CRUD impl in ACC instead
------------------------------------------------------------
revno: 17429
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-11-11 17:56:24 +0545
message:
remove custom crud for TEA, TEAG, use default CRUD impl in ACC instead
modified:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/TrackedEntityAttributeController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/TrackedEntityAttributeGroupController.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/event/TrackedEntityAttributeController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/TrackedEntityAttributeController.java 2014-10-23 08:23:55 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/TrackedEntityAttributeController.java 2014-11-11 12:11:24 +0000
@@ -30,7 +30,6 @@
import com.google.common.collect.Lists;
import org.hisp.dhis.common.Pager;
-import org.hisp.dhis.dxf2.utils.JacksonUtils;
import org.hisp.dhis.program.Program;
import org.hisp.dhis.program.ProgramService;
import org.hisp.dhis.schema.descriptors.TrackedEntityAttributeSchemaDescriptor;
@@ -39,18 +38,10 @@
import org.hisp.dhis.webapi.controller.AbstractCrudController;
import org.hisp.dhis.webapi.webdomain.WebMetaData;
import org.hisp.dhis.webapi.webdomain.WebOptions;
-import org.hisp.dhis.webapi.utils.ContextUtils;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
-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;
import java.util.ArrayList;
import java.util.List;
@@ -58,7 +49,7 @@
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@Controller
-@RequestMapping( value = TrackedEntityAttributeSchemaDescriptor.API_ENDPOINT )
+@RequestMapping(value = TrackedEntityAttributeSchemaDescriptor.API_ENDPOINT)
public class TrackedEntityAttributeController
extends AbstractCrudController<TrackedEntityAttribute>
{
@@ -112,94 +103,4 @@
return entityList;
}
-
- //--------------------------------------------------------------------------
- // POST
- //--------------------------------------------------------------------------
-
- @Override
- @RequestMapping( method = RequestMethod.POST, consumes = { "application/xml", "text/xml" } )
- @ResponseStatus( HttpStatus.CREATED )
- public void postXmlObject( HttpServletResponse response, HttpServletRequest request, InputStream input ) throws Exception
- {
- TrackedEntityAttribute trackedEntityAttribute = JacksonUtils.fromXml( input, TrackedEntityAttribute.class );
- trackedEntityAttributeService.addTrackedEntityAttribute( trackedEntityAttribute );
-
- response.setHeader( "Location", ContextUtils.getRootPath( request ) + TrackedEntityAttributeSchemaDescriptor.API_ENDPOINT + "/" + trackedEntityAttribute.getUid() );
- }
-
- @Override
- @RequestMapping( method = RequestMethod.POST, consumes = "application/json" )
- @ResponseStatus( HttpStatus.CREATED )
- public void postJsonObject( HttpServletResponse response, HttpServletRequest request, InputStream input ) throws Exception
- {
- TrackedEntityAttribute trackedEntityAttribute = JacksonUtils.fromJson( input, TrackedEntityAttribute.class );
- trackedEntityAttributeService.addTrackedEntityAttribute( trackedEntityAttribute );
-
- response.setHeader( "Location", ContextUtils.getRootPath( request ) + TrackedEntityAttributeSchemaDescriptor.API_ENDPOINT + "/" + trackedEntityAttribute.getUid() );
- }
-
- //--------------------------------------------------------------------------
- // PUT
- //--------------------------------------------------------------------------
-
- @Override
- @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, consumes = { "application/xml", "text/xml" } )
- public void putXmlObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
- {
- TrackedEntityAttribute trackedEntityAttribute = trackedEntityAttributeService.getTrackedEntityAttribute( uid );
-
- if ( trackedEntityAttribute == null )
- {
- ContextUtils.conflictResponse( response, "TrackedEntityAttribute does not exist: " + uid );
- return;
- }
-
- TrackedEntityAttribute newTrackedEntityAttribute = JacksonUtils.fromXml( input, TrackedEntityAttribute.class );
- newTrackedEntityAttribute.setUid( trackedEntityAttribute.getUid() );
- trackedEntityAttribute.mergeWith( newTrackedEntityAttribute );
-
- response.setStatus( HttpServletResponse.SC_NO_CONTENT );
- trackedEntityAttributeService.updateTrackedEntityAttribute( trackedEntityAttribute );
- }
-
- @Override
- @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, consumes = "application/json" )
- public void putJsonObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
- {
- TrackedEntityAttribute trackedEntityAttribute = trackedEntityAttributeService.getTrackedEntityAttribute( uid );
-
- if ( trackedEntityAttribute == null )
- {
- ContextUtils.conflictResponse( response, "TrackedEntityAttribute does not exist: " + uid );
- return;
- }
-
- TrackedEntityAttribute newTrackedEntityAttribute = JacksonUtils.fromJson( input, TrackedEntityAttribute.class );
- newTrackedEntityAttribute.setUid( trackedEntityAttribute.getUid() );
- trackedEntityAttribute.mergeWith( newTrackedEntityAttribute );
-
- response.setStatus( HttpServletResponse.SC_NO_CONTENT );
- trackedEntityAttributeService.updateTrackedEntityAttribute( trackedEntityAttribute );
- }
-
- //--------------------------------------------------------------------------
- // DELETE
- //--------------------------------------------------------------------------
-
- @Override
- @RequestMapping( value = "/{uid}", method = RequestMethod.DELETE )
- public void deleteObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid ) throws Exception
- {
- TrackedEntityAttribute trackedEntityAttribute = trackedEntityAttributeService.getTrackedEntityAttribute( uid );
-
- if ( trackedEntityAttribute == null )
- {
- ContextUtils.conflictResponse( response, "TrackedEntityAttribute does not exist: " + uid );
- return;
- }
-
- response.setStatus( HttpServletResponse.SC_NO_CONTENT );
- trackedEntityAttributeService.deleteTrackedEntityAttribute( trackedEntityAttribute );
- }
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/TrackedEntityAttributeGroupController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/TrackedEntityAttributeGroupController.java 2014-10-21 13:31:06 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/TrackedEntityAttributeGroupController.java 2014-11-11 12:11:24 +0000
@@ -28,119 +28,18 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import org.hisp.dhis.dxf2.utils.JacksonUtils;
import org.hisp.dhis.schema.descriptors.TrackedEntityAttributeGroupSchemaDescriptor;
import org.hisp.dhis.trackedentity.TrackedEntityAttributeGroup;
-import org.hisp.dhis.trackedentity.TrackedEntityAttributeGroupService;
import org.hisp.dhis.webapi.controller.AbstractCrudController;
-import org.hisp.dhis.webapi.utils.ContextUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
-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>
*/
@Controller
-@RequestMapping( value = TrackedEntityAttributeGroupSchemaDescriptor.API_ENDPOINT )
+@RequestMapping(value = TrackedEntityAttributeGroupSchemaDescriptor.API_ENDPOINT)
public class TrackedEntityAttributeGroupController
extends AbstractCrudController<TrackedEntityAttributeGroup>
{
- @Autowired
- private TrackedEntityAttributeGroupService trackedEntityAttributeGroupService;
-
- //--------------------------------------------------------------------------
- // POST
- //--------------------------------------------------------------------------
-
- @Override
- @RequestMapping( method = RequestMethod.POST, consumes = { "application/xml", "text/xml" } )
- @ResponseStatus( HttpStatus.CREATED )
- public void postXmlObject( HttpServletResponse response, HttpServletRequest request, InputStream input ) throws Exception
- {
- TrackedEntityAttributeGroup trackedEntityAttributeGroup = JacksonUtils.fromXml( input, TrackedEntityAttributeGroup.class );
- trackedEntityAttributeGroupService.addTrackedEntityAttributeGroup( trackedEntityAttributeGroup );
-
- response.setHeader( "Location", ContextUtils.getRootPath( request ) + TrackedEntityAttributeGroupSchemaDescriptor.API_ENDPOINT + "/" + trackedEntityAttributeGroup.getUid() );
- }
-
- @Override
- @RequestMapping( method = RequestMethod.POST, consumes = "application/json" )
- @ResponseStatus( HttpStatus.CREATED )
- public void postJsonObject( HttpServletResponse response, HttpServletRequest request, InputStream input ) throws Exception
- {
- TrackedEntityAttributeGroup trackedEntityAttributeGroup = JacksonUtils.fromJson( input, TrackedEntityAttributeGroup.class );
- trackedEntityAttributeGroupService.addTrackedEntityAttributeGroup( trackedEntityAttributeGroup );
-
- response.setHeader( "Location", ContextUtils.getRootPath( request ) + TrackedEntityAttributeGroupSchemaDescriptor.API_ENDPOINT + "/" + trackedEntityAttributeGroup.getUid() );
- }
-
- //--------------------------------------------------------------------------
- // PUT
- //--------------------------------------------------------------------------
-
- @Override
- @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, consumes = { "application/xml", "text/xml" } )
- public void putXmlObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
- {
- TrackedEntityAttributeGroup trackedEntityAttributeGroup = trackedEntityAttributeGroupService.getTrackedEntityAttributeGroup( uid );
-
- if ( trackedEntityAttributeGroup == null )
- {
- ContextUtils.conflictResponse( response, "TrackedEntityAttributeGroup does not exist: " + uid );
- return;
- }
-
- TrackedEntityAttributeGroup newTrackedEntityAttributeGroup = JacksonUtils.fromXml( input, TrackedEntityAttributeGroup.class );
- newTrackedEntityAttributeGroup.setUid( trackedEntityAttributeGroup.getUid() );
- trackedEntityAttributeGroup.mergeWith( newTrackedEntityAttributeGroup );
-
- trackedEntityAttributeGroupService.updateTrackedEntityAttributeGroup( trackedEntityAttributeGroup );
- }
-
- @Override
- @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, consumes = "application/json" )
- public void putJsonObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
- {
- TrackedEntityAttributeGroup trackedEntityAttributeGroup = trackedEntityAttributeGroupService.getTrackedEntityAttributeGroup( uid );
-
- if ( trackedEntityAttributeGroup == null )
- {
- ContextUtils.conflictResponse( response, "TrackedEntityAttributeGroup does not exist: " + uid );
- return;
- }
-
- TrackedEntityAttributeGroup newTrackedEntityAttributeGroup = JacksonUtils.fromJson( input, TrackedEntityAttributeGroup.class );
- newTrackedEntityAttributeGroup.setUid( trackedEntityAttributeGroup.getUid() );
- trackedEntityAttributeGroup.mergeWith( newTrackedEntityAttributeGroup );
-
- trackedEntityAttributeGroupService.updateTrackedEntityAttributeGroup( trackedEntityAttributeGroup );
- }
-
- //--------------------------------------------------------------------------
- // DELETE
- //--------------------------------------------------------------------------
-
- @Override
- @RequestMapping( value = "/{uid}", method = RequestMethod.DELETE )
- public void deleteObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid ) throws Exception
- {
- TrackedEntityAttributeGroup trackedEntityAttributeGroup = trackedEntityAttributeGroupService.getTrackedEntityAttributeGroup( uid );
-
- if ( trackedEntityAttributeGroup == null )
- {
- ContextUtils.conflictResponse( response, "TrackedEntityAttributeGroup does not exist: " + uid );
- return;
- }
-
- trackedEntityAttributeGroupService.deleteTrackedEntityAttributeGroup( trackedEntityAttributeGroup );
- }
}