← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19627: Cleanup in CompleteDataSetRegistrationController, removed old style json/xml type payloads for se...

 

------------------------------------------------------------
revno: 19627
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-07-13 15:40:46 +0700
message:
  Cleanup in CompleteDataSetRegistrationController, removed old style json/xml type payloads for setting completeness
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/CompleteDataSetRegistrationController.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/CompleteDataSetRegistrationController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/CompleteDataSetRegistrationController.java	2015-07-10 05:22:40 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/CompleteDataSetRegistrationController.java	2015-07-13 08:40:46 +0000
@@ -29,9 +29,7 @@
  */
 
 import org.apache.commons.lang3.StringUtils;
-import org.hisp.dhis.common.IdentifiableObject;
 import org.hisp.dhis.common.IdentifiableObjectManager;
-import org.hisp.dhis.common.view.BasicView;
 import org.hisp.dhis.datacompletion.CompleteDataSetRegistrationRequest;
 import org.hisp.dhis.datacompletion.CompleteDataSetRegistrationRequests;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
@@ -41,7 +39,6 @@
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.dataset.DataSetService;
 import org.hisp.dhis.dxf2.common.JacksonUtils;
-import org.hisp.dhis.dxf2.render.RenderService;
 import org.hisp.dhis.dxf2.webmessage.WebMessageException;
 import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.i18n.I18nManager;
@@ -54,14 +51,12 @@
 import org.hisp.dhis.webapi.utils.InputUtils;
 import org.hisp.dhis.webapi.utils.WebMessageUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.MediaType;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
 
-import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.util.ArrayList;
@@ -71,7 +66,6 @@
 import java.util.Set;
 
 import static org.hisp.dhis.webapi.utils.ContextUtils.CONTENT_TYPE_JSON;
-import static org.hisp.dhis.webapi.utils.ContextUtils.CONTENT_TYPE_XML;
 
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -108,26 +102,6 @@
     @Autowired
     private I18nManager i18nManager;
 
-    @Autowired
-    private RenderService renderService;
-
-    @RequestMapping( method = RequestMethod.GET, produces = CONTENT_TYPE_XML )
-    public void getCompleteDataSetRegistrationsXml(
-        @RequestParam Set<String> dataSet,
-        @RequestParam( required = false ) String period,
-        @RequestParam Date startDate,
-        @RequestParam Date endDate,
-        @RequestParam Set<String> orgUnit,
-        @RequestParam( required = false ) boolean children,
-        HttpServletResponse response ) throws IOException
-    {
-        response.setContentType( CONTENT_TYPE_XML );
-        CompleteDataSetRegistrations completeDataSetRegistrations = getCompleteDataSetRegistrations( dataSet, period,
-            startDate, endDate, orgUnit, children );
-
-        JacksonUtils.toXmlWithView( response.getOutputStream(), completeDataSetRegistrations, BasicView.class );
-    }
-
     @RequestMapping( method = RequestMethod.GET, produces = CONTENT_TYPE_JSON )
     public void getCompleteDataSetRegistrationsJson(
         @RequestParam Set<String> dataSet,
@@ -186,66 +160,6 @@
         return completeDataSetRegistrations;
     }
 
-    @RequestMapping( method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE )
-    public void saveCompleteDataSetRegistrationsJson( HttpServletRequest request, HttpServletResponse response ) throws IOException, WebMessageException
-    {
-        CompleteDataSetRegistrations completeDataSetRegistrations = renderService.fromJson( request.getInputStream(),
-            CompleteDataSetRegistrations.class );
-
-        saveCompleteDataSetRegistrations( completeDataSetRegistrations );
-    }
-
-    @RequestMapping( method = RequestMethod.POST, consumes = MediaType.APPLICATION_XML_VALUE )
-    public void saveCompleteDataSetRegistrationsXml( HttpServletRequest request, HttpServletResponse response ) throws IOException, WebMessageException
-    {
-        CompleteDataSetRegistrations completeDataSetRegistrations = renderService.fromXml( request.getInputStream(),
-            CompleteDataSetRegistrations.class );
-
-        saveCompleteDataSetRegistrations( completeDataSetRegistrations );
-    }
-
-    private void saveCompleteDataSetRegistrations( CompleteDataSetRegistrations completeDataSetRegistrations ) throws WebMessageException
-    {
-        for ( CompleteDataSetRegistration completeDataSetRegistration : completeDataSetRegistrations.getCompleteDataSetRegistrations() )
-        {
-            Period period = getObject( completeDataSetRegistration.getPeriod() );
-            DataSet dataSet = getObject( completeDataSetRegistration.getDataSet() );
-            DataElementCategoryOptionCombo attributeOptionCombo = getObject( completeDataSetRegistration.getAttributeOptionCombo() );
-            OrganisationUnit organisationUnit = getObject( completeDataSetRegistration.getSource() );
-
-            Date date = completeDataSetRegistration.getDate();
-            String storedBy = completeDataSetRegistration.getStoredBy();
-
-            registerCompleteDataSet( dataSet, period, organisationUnit, attributeOptionCombo, storedBy, date );
-        }
-    }
-
-    @SuppressWarnings( "unchecked" )
-    private <T extends IdentifiableObject> T getObject( T object )
-    {
-        if ( object == null )
-        {
-            return null;
-        }
-
-        if ( Period.class.isInstance( object ) )
-        {
-            return (T) periodService.reloadIsoPeriod( ((Period) object).getRealUid() );
-        }
-
-        if ( object.getUid() != null )
-        {
-            return (T) manager.get( object.getClass(), object.getUid() );
-        }
-
-        if ( object.getCode() != null )
-        {
-            return (T) manager.get( object.getClass(), object.getCode() );
-        }
-
-        return null;
-    }
-
     @RequestMapping( method = RequestMethod.POST, produces = "text/plain" )
     public void saveCompleteDataSetRegistration(
         @RequestParam String ds,