dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #40827
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20781: multiple web-api updates, use render service where applicable, remove unused parameters (in non c...
------------------------------------------------------------
revno: 20781
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-10-20 11:15:40 +0700
message:
multiple web-api updates, use render service where applicable, remove unused parameters (in non crud controller classes)
modified:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ChartController.java
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/DashboardController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataApprovalController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataSetController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataValueSetController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/MessageConversationController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ReportTableController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SchedulingController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SharingController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EnrollmentController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventChartController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventReportController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/TrackedEntityInstanceController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/legend/LegendSetController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/mapping/MapController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/organisationunit/OrganisationUnitLocationController.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/ChartController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ChartController.java 2015-10-04 20:52:33 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ChartController.java 2015-10-20 04:15:40 +0000
@@ -28,20 +28,10 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import static org.hisp.dhis.common.DimensionalObjectUtils.getDimensions;
-
-import java.io.IOException;
-import java.util.Date;
-import java.util.Set;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
import org.hisp.dhis.chart.Chart;
import org.hisp.dhis.chart.ChartService;
import org.hisp.dhis.common.DimensionService;
import org.hisp.dhis.common.cache.CacheStrategy;
-import org.hisp.dhis.system.util.CodecUtils;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
import org.hisp.dhis.dataelement.DataElementCategoryService;
@@ -58,6 +48,7 @@
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodType;
import org.hisp.dhis.schema.descriptors.ChartSchemaDescriptor;
+import org.hisp.dhis.system.util.CodecUtils;
import org.hisp.dhis.webapi.utils.ContextUtils;
import org.hisp.dhis.webapi.utils.WebMessageUtils;
import org.jfree.chart.ChartUtilities;
@@ -69,6 +60,14 @@
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.Date;
+import java.util.Set;
+
+import static org.hisp.dhis.common.DimensionalObjectUtils.getDimensions;
+
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@@ -109,14 +108,14 @@
@RequestMapping( method = RequestMethod.POST, consumes = "application/json" )
public void postJsonObject( ImportOptions importOptions, HttpServletRequest request, HttpServletResponse response ) throws Exception
{
- Chart chart = JacksonUtils.fromJson( request.getInputStream(), Chart.class );
+ Chart chart = renderService.fromJson( request.getInputStream(), Chart.class );
mergeChart( chart );
chartService.addChart( chart );
response.addHeader( "Location", ChartSchemaDescriptor.API_ENDPOINT + "/" + chart.getUid() );
-
+
webMessageService.send( WebMessageUtils.created( "Chart created" ), response, request );
}
=== 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-10-01 11:35:44 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/CompleteDataSetRegistrationController.java 2015-10-20 04:15:40 +0000
@@ -38,7 +38,8 @@
import org.hisp.dhis.dataset.CompleteDataSetRegistrations;
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.utils.InputUtils;
import org.hisp.dhis.dxf2.webmessage.WebMessageException;
import org.hisp.dhis.i18n.I18nFormat;
import org.hisp.dhis.i18n.I18nManager;
@@ -48,7 +49,6 @@
import org.hisp.dhis.period.PeriodService;
import org.hisp.dhis.period.PeriodType;
import org.hisp.dhis.user.CurrentUserService;
-import org.hisp.dhis.dxf2.utils.InputUtils;
import org.hisp.dhis.webapi.utils.WebMessageUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@@ -102,6 +102,9 @@
@Autowired
private I18nManager i18nManager;
+ @Autowired
+ private RenderService renderService;
+
@RequestMapping( method = RequestMethod.GET, produces = CONTENT_TYPE_JSON )
public void getCompleteDataSetRegistrationsJson(
@RequestParam Set<String> dataSet,
@@ -116,7 +119,7 @@
CompleteDataSetRegistrations completeDataSetRegistrations = getCompleteDataSetRegistrations( dataSet, period,
startDate, endDate, orgUnit, children );
- JacksonUtils.toJson( response.getOutputStream(), completeDataSetRegistrations );
+ renderService.toJson( response.getOutputStream(), completeDataSetRegistrations );
}
private CompleteDataSetRegistrations getCompleteDataSetRegistrations( Set<String> dataSet, String period,
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DashboardController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DashboardController.java 2015-09-17 15:49:41 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DashboardController.java 2015-10-20 04:15:40 +0000
@@ -35,7 +35,6 @@
import org.hisp.dhis.dashboard.DashboardSearchResult;
import org.hisp.dhis.dashboard.DashboardService;
import org.hisp.dhis.dxf2.common.ImportOptions;
-import org.hisp.dhis.dxf2.common.JacksonUtils;
import org.hisp.dhis.dxf2.webmessage.WebMessageException;
import org.hisp.dhis.hibernate.exception.DeleteAccessDeniedException;
import org.hisp.dhis.hibernate.exception.UpdateAccessDeniedException;
@@ -90,7 +89,7 @@
@RequestMapping( method = RequestMethod.POST, consumes = "application/json" )
public void postJsonObject( ImportOptions importOptions, HttpServletRequest request, HttpServletResponse response ) throws Exception
{
- Dashboard dashboard = JacksonUtils.fromJson( request.getInputStream(), Dashboard.class );
+ Dashboard dashboard = renderService.fromJson( request.getInputStream(), Dashboard.class );
dashboardService.mergeDashboard( dashboard );
dashboardService.saveDashboard( dashboard );
@@ -115,7 +114,7 @@
throw new UpdateAccessDeniedException( "You don't have the proper permissions to update this dashboard." );
}
- Dashboard newDashboard = JacksonUtils.fromJson( request.getInputStream(), Dashboard.class );
+ Dashboard newDashboard = renderService.fromJson( request.getInputStream(), Dashboard.class );
dashboard.setName( newDashboard.getName() ); // TODO Name only for now
@@ -161,7 +160,7 @@
throw new UpdateAccessDeniedException( "You don't have the proper permissions to update this dashboard." );
}
- DashboardItem item = JacksonUtils.fromJson( request.getInputStream(), DashboardItem.class );
+ DashboardItem item = renderService.fromJson( request.getInputStream(), DashboardItem.class );
dashboardService.mergeDashboardItem( item );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataApprovalController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataApprovalController.java 2015-10-05 07:55:19 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataApprovalController.java 2015-10-20 04:15:40 +0000
@@ -28,20 +28,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import static com.google.common.collect.Lists.newArrayList;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
import org.hisp.dhis.common.IdentifiableObjectManager;
import org.hisp.dhis.dataapproval.DataApproval;
import org.hisp.dhis.dataapproval.DataApprovalLevel;
@@ -57,7 +43,7 @@
import org.hisp.dhis.dataelement.DataElementCategoryService;
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.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
@@ -79,6 +65,19 @@
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;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import static com.google.common.collect.Lists.newArrayList;
+
/**
* This controller uses both /dataApprovals and /dataAcceptances.
*
@@ -122,6 +121,9 @@
@Autowired
private DataElementCategoryService categoryService;
+ @Autowired
+ private RenderService renderService;
+
// -------------------------------------------------------------------------
// Get
// -------------------------------------------------------------------------
@@ -162,7 +164,7 @@
DataApprovalPermissions permissions = status.getPermissions();
permissions.setState( status.getState().toString() );
- JacksonUtils.toJson( response.getOutputStream(), status.getPermissions() );
+ renderService.toJson( response.getOutputStream(), status.getPermissions() );
}
@RequestMapping( value = STATUS_PATH, method = RequestMethod.GET, produces = ContextUtils.CONTENT_TYPE_JSON )
@@ -218,7 +220,7 @@
}
}
- JacksonUtils.toJson( response.getOutputStream(), dataApprovalStateResponses );
+ renderService.toJson( response.getOutputStream(), dataApprovalStateResponses );
}
private DataApprovalStateResponse getDataApprovalStateResponse( DataSet dataSet,
@@ -287,7 +289,7 @@
}
}
- JacksonUtils.toJson( response.getOutputStream(), list );
+ renderService.toJson( response.getOutputStream(), list );
}
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataSetController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataSetController.java 2015-09-17 15:49:41 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataSetController.java 2015-10-20 04:15:40 +0000
@@ -28,20 +28,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletResponse;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-
import org.hisp.dhis.common.DisplayDensity;
import org.hisp.dhis.common.view.ExportView;
import org.hisp.dhis.dataentryform.DataEntryForm;
@@ -77,6 +63,19 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
+import javax.servlet.http.HttpServletResponse;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@@ -140,7 +139,7 @@
Map<String, Integer> versionMap = new HashMap<>();
versionMap.put( "version", dataSet.getVersion() );
- JacksonUtils.toJson( response.getOutputStream(), versionMap );
+ renderService.toJson( response.getOutputStream(), versionMap );
}
@RequestMapping( value = "/{uid}/dataValueSet", method = RequestMethod.GET )
@@ -188,7 +187,7 @@
Form form = getForm( dataSets, ou, pe, metaData );
- JacksonUtils.toJson( response.getOutputStream(), form );
+ renderService.toJson( response.getOutputStream(), form );
}
@RequestMapping( value = "/{uid}/form", method = RequestMethod.GET, produces = { "application/xml", "text/xml" } )
@@ -216,7 +215,7 @@
Form form = getForm( dataSets, ou, pe, metaData );
- JacksonUtils.toXml( response.getOutputStream(), form );
+ renderService.toXml( response.getOutputStream(), form );
}
private Form getForm( List<DataSet> dataSets, OrganisationUnit ou, Period pe, boolean metaData )
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataValueSetController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataValueSetController.java 2015-07-10 19:12:53 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataValueSetController.java 2015-10-20 04:15:40 +0000
@@ -28,23 +28,12 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import static org.hisp.dhis.webapi.utils.ContextUtils.CONTENT_TYPE_CSV;
-import static org.hisp.dhis.webapi.utils.ContextUtils.CONTENT_TYPE_JSON;
-import static org.hisp.dhis.webapi.utils.ContextUtils.CONTENT_TYPE_XML;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Date;
-import java.util.Set;
-
-import javax.servlet.http.HttpServletResponse;
-
import org.hisp.dhis.dxf2.common.IdSchemes;
import org.hisp.dhis.dxf2.common.ImportOptions;
-import org.hisp.dhis.dxf2.common.JacksonUtils;
import org.hisp.dhis.dxf2.datavalueset.DataExportParams;
import org.hisp.dhis.dxf2.datavalueset.DataValueSetService;
import org.hisp.dhis.dxf2.importsummary.ImportSummary;
+import org.hisp.dhis.dxf2.render.RenderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
@@ -53,6 +42,14 @@
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Date;
+import java.util.Set;
+
+import static org.hisp.dhis.webapi.utils.ContextUtils.*;
+
/**
* @author Lars Helge Overland
*/
@@ -65,6 +62,9 @@
@Autowired
private DataValueSetService dataValueSetService;
+ @Autowired
+ private RenderService renderService;
+
// -------------------------------------------------------------------------
// Get
// -------------------------------------------------------------------------
@@ -142,7 +142,7 @@
ImportSummary summary = dataValueSetService.saveDataValueSet( in, importOptions );
response.setContentType( CONTENT_TYPE_XML );
- JacksonUtils.toXml( response.getOutputStream(), summary );
+ renderService.toXml( response.getOutputStream(), summary );
}
@RequestMapping( method = RequestMethod.POST, consumes = "application/json" )
@@ -153,7 +153,7 @@
ImportSummary summary = dataValueSetService.saveDataValueSetJson( in, importOptions );
response.setContentType( CONTENT_TYPE_JSON );
- JacksonUtils.toJson( response.getOutputStream(), summary );
+ renderService.toJson( response.getOutputStream(), summary );
}
@RequestMapping( method = RequestMethod.POST, consumes = "application/csv" )
@@ -164,6 +164,6 @@
ImportSummary summary = dataValueSetService.saveDataValueSetCsv( in, importOptions );
response.setContentType( CONTENT_TYPE_XML );
- JacksonUtils.toXml( response.getOutputStream(), summary );
+ renderService.toXml( response.getOutputStream(), summary );
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/MessageConversationController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/MessageConversationController.java 2015-09-14 17:57:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/MessageConversationController.java 2015-10-20 04:15:40 +0000
@@ -28,17 +28,9 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
+import com.google.common.collect.Lists;
import org.hisp.dhis.common.Pager;
import org.hisp.dhis.dxf2.common.ImportOptions;
-import org.hisp.dhis.dxf2.common.JacksonUtils;
import org.hisp.dhis.dxf2.common.TranslateParams;
import org.hisp.dhis.dxf2.webmessage.WebMessageException;
import org.hisp.dhis.hibernate.exception.DeleteAccessDeniedException;
@@ -72,7 +64,12 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
-import com.google.common.collect.Lists;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -161,14 +158,14 @@
@Override
public void postXmlObject( ImportOptions importOptions, HttpServletRequest request, HttpServletResponse response ) throws Exception
{
- MessageConversation messageConversation = JacksonUtils.fromXml( request.getInputStream(), MessageConversation.class );
+ MessageConversation messageConversation = renderService.fromXml( request.getInputStream(), MessageConversation.class );
postObject( response, request, messageConversation );
}
@Override
public void postJsonObject( ImportOptions importOptions, HttpServletRequest request, HttpServletResponse response ) throws Exception
{
- MessageConversation messageConversation = JacksonUtils.fromJson( request.getInputStream(), MessageConversation.class );
+ MessageConversation messageConversation = renderService.fromJson( request.getInputStream(), MessageConversation.class );
postObject( response, request, messageConversation );
}
@@ -532,9 +529,9 @@
/**
* Determines whether the current user has permission to modify the given user in a MessageConversation.
- * <p/>
+ * <p>
* The modification is either marking a conversation read/unread for the user or removing the user from the MessageConversation.
- * <p/>
+ * <p>
* Since there are no per-conversation authorities provided the permission is given if the current user equals the user
* or if the current user has update-permission to User objects.
*
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ReportTableController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ReportTableController.java 2015-10-04 20:52:33 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ReportTableController.java 2015-10-20 04:15:40 +0000
@@ -31,8 +31,8 @@
import org.hisp.dhis.common.DimensionService;
import org.hisp.dhis.common.Grid;
import org.hisp.dhis.common.MergeStrategy;
+import org.hisp.dhis.common.cache.CacheStrategy;
import org.hisp.dhis.dxf2.common.ImportOptions;
-import org.hisp.dhis.dxf2.common.JacksonUtils;
import org.hisp.dhis.dxf2.webmessage.WebMessageException;
import org.hisp.dhis.i18n.I18nFormat;
import org.hisp.dhis.i18n.I18nManager;
@@ -45,7 +45,6 @@
import org.hisp.dhis.schema.descriptors.ReportTableSchemaDescriptor;
import org.hisp.dhis.system.grid.GridUtils;
import org.hisp.dhis.webapi.utils.ContextUtils;
-import org.hisp.dhis.common.cache.CacheStrategy;
import org.hisp.dhis.webapi.utils.WebMessageUtils;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
@@ -99,14 +98,14 @@
@RequestMapping( method = RequestMethod.POST, consumes = "application/json" )
public void postJsonObject( ImportOptions importOptions, HttpServletRequest request, HttpServletResponse response ) throws Exception
{
- ReportTable reportTable = JacksonUtils.fromJson( request.getInputStream(), ReportTable.class );
+ ReportTable reportTable = renderService.fromJson( request.getInputStream(), ReportTable.class );
mergeReportTable( reportTable );
reportTableService.saveReportTable( reportTable );
response.addHeader( "Location", ReportTableSchemaDescriptor.API_ENDPOINT + "/" + reportTable.getUid() );
-
+
webMessageService.send( WebMessageUtils.created( "Report table created" ), response, request );
}
@@ -121,7 +120,7 @@
throw new WebMessageException( WebMessageUtils.notFound( "Report table does not exist: " + uid ) );
}
- ReportTable newReportTable = JacksonUtils.fromJson( request.getInputStream(), ReportTable.class );
+ ReportTable newReportTable = renderService.fromJson( request.getInputStream(), ReportTable.class );
mergeReportTable( newReportTable );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SchedulingController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SchedulingController.java 2015-07-08 05:42:56 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SchedulingController.java 2015-10-20 04:15:40 +0000
@@ -29,7 +29,7 @@
*/
import org.hisp.dhis.common.ListMap;
-import org.hisp.dhis.dxf2.common.JacksonUtils;
+import org.hisp.dhis.dxf2.render.RenderService;
import org.hisp.dhis.scheduling.SchedulingManager;
import org.hisp.dhis.webapi.utils.ContextUtils;
import org.hisp.dhis.webapi.webdomain.SchedulingStrategy;
@@ -63,13 +63,16 @@
@Autowired
private SchedulingManager schedulingManager;
+ @Autowired
+ private RenderService renderService;
+
@PreAuthorize( "hasRole('ALL') or hasRole('F_SCHEDULING_ADMIN')" )
@ResponseStatus( value = HttpStatus.OK )
@RequestMapping( method = { RequestMethod.POST, RequestMethod.PUT }, consumes = { ContextUtils.CONTENT_TYPE_JSON } )
public void schedule( HttpServletRequest request, HttpServletResponse response )
throws IOException
{
- SchedulingStrategy strategy = JacksonUtils.fromJson( request.getInputStream(), SchedulingStrategy.class );
+ SchedulingStrategy strategy = renderService.fromJson( request.getInputStream(), SchedulingStrategy.class );
ListMap<String, String> cronKeyMap = new ListMap<>();
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SharingController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SharingController.java 2015-10-20 03:28:57 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SharingController.java 2015-10-20 04:15:40 +0000
@@ -33,7 +33,6 @@
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.IdentifiableObject;
import org.hisp.dhis.common.IdentifiableObjectManager;
-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.security.acl.AccessStringHelper;
@@ -194,7 +193,7 @@
throw new AccessDeniedException( "You do not have manage access to this object." );
}
- Sharing sharing = JacksonUtils.fromJson( request.getInputStream(), Sharing.class );
+ Sharing sharing = renderService.fromJson( request.getInputStream(), Sharing.class );
// Ignore externalAccess if user is not allowed to make objects external
if ( aclService.canExternalize( user, object.getClass() ) )
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EnrollmentController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EnrollmentController.java 2015-10-01 10:05:20 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EnrollmentController.java 2015-10-20 04:15:40 +0000
@@ -29,17 +29,16 @@
*/
import com.google.common.collect.Lists;
-
import org.hisp.dhis.common.OrganisationUnitSelectionMode;
import org.hisp.dhis.commons.util.TextUtils;
-import org.hisp.dhis.dxf2.common.JacksonUtils;
import org.hisp.dhis.dxf2.events.enrollment.Enrollment;
import org.hisp.dhis.dxf2.events.enrollment.EnrollmentService;
import org.hisp.dhis.dxf2.events.enrollment.EnrollmentStatus;
-import org.hisp.dhis.fieldfilter.FieldFilterService;
import org.hisp.dhis.dxf2.importsummary.ImportStatus;
import org.hisp.dhis.dxf2.importsummary.ImportSummaries;
import org.hisp.dhis.dxf2.importsummary.ImportSummary;
+import org.hisp.dhis.dxf2.render.RenderService;
+import org.hisp.dhis.fieldfilter.FieldFilterService;
import org.hisp.dhis.importexport.ImportStrategy;
import org.hisp.dhis.node.NodeUtils;
import org.hisp.dhis.node.types.RootNode;
@@ -67,7 +66,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
@@ -99,6 +97,9 @@
@Autowired
private WebMessageService webMessageService;
+ @Autowired
+ private RenderService renderService;
+
// -------------------------------------------------------------------------
// READ
// -------------------------------------------------------------------------
@@ -128,7 +129,7 @@
}
Set<String> orgUnits = TextUtils.splitToArray( ou, TextUtils.SEMICOLON );
-
+
ProgramInstanceQueryParams params = programInstanceService.getFromUrl( orgUnits, ouMode, lastUpdated, program, programStatus, programStartDate,
programEndDate, trackedEntity, trackedEntityInstance, followUp, page, pageSize, totalPages, skipPaging );
@@ -167,7 +168,7 @@
if ( importSummaries.getImportSummaries().size() > 1 )
{
response.setStatus( HttpServletResponse.SC_CREATED );
- JacksonUtils.toXml( response.getOutputStream(), importSummaries );
+ renderService.toXml( response.getOutputStream(), importSummaries );
}
else
{
@@ -193,7 +194,7 @@
if ( importSummaries.getImportSummaries().size() > 1 )
{
response.setStatus( HttpServletResponse.SC_CREATED );
- JacksonUtils.toJson( response.getOutputStream(), importSummaries );
+ renderService.toJson( response.getOutputStream(), importSummaries );
}
else
{
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventChartController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventChartController.java 2015-10-04 20:52:33 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventChartController.java 2015-10-20 04:15:40 +0000
@@ -30,9 +30,8 @@
import org.hisp.dhis.chart.ChartService;
import org.hisp.dhis.common.DimensionService;
-import org.hisp.dhis.system.util.CodecUtils;
+import org.hisp.dhis.common.cache.CacheStrategy;
import org.hisp.dhis.dxf2.common.ImportOptions;
-import org.hisp.dhis.dxf2.common.JacksonUtils;
import org.hisp.dhis.dxf2.webmessage.WebMessageException;
import org.hisp.dhis.eventchart.EventChart;
import org.hisp.dhis.eventchart.EventChartService;
@@ -44,9 +43,9 @@
import org.hisp.dhis.program.ProgramService;
import org.hisp.dhis.program.ProgramStageService;
import org.hisp.dhis.schema.descriptors.EventChartSchemaDescriptor;
+import org.hisp.dhis.system.util.CodecUtils;
import org.hisp.dhis.webapi.controller.AbstractCrudController;
import org.hisp.dhis.webapi.utils.ContextUtils;
-import org.hisp.dhis.common.cache.CacheStrategy;
import org.hisp.dhis.webapi.utils.WebMessageUtils;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
@@ -105,7 +104,7 @@
@RequestMapping( method = RequestMethod.POST, consumes = "application/json" )
public void postJsonObject( ImportOptions importOptions, HttpServletRequest request, HttpServletResponse response ) throws Exception
{
- EventChart eventChart = JacksonUtils.fromJson( request.getInputStream(), EventChart.class );
+ EventChart eventChart = renderService.fromJson( request.getInputStream(), EventChart.class );
mergeEventChart( eventChart );
@@ -126,7 +125,7 @@
throw new WebMessageException( WebMessageUtils.notFound( "Event chart does not exist: " + uid ) );
}
- EventChart newEventChart = JacksonUtils.fromJson( request.getInputStream(), EventChart.class );
+ EventChart newEventChart = renderService.fromJson( request.getInputStream(), EventChart.class );
mergeEventChart( newEventChart );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventController.java 2015-10-13 02:15:59 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventController.java 2015-10-20 04:15:40 +0000
@@ -35,7 +35,6 @@
import org.hisp.dhis.dataelement.DataElementService;
import org.hisp.dhis.dxf2.common.IdSchemes;
import org.hisp.dhis.dxf2.common.ImportOptions;
-import org.hisp.dhis.dxf2.common.JacksonUtils;
import org.hisp.dhis.dxf2.events.event.Event;
import org.hisp.dhis.dxf2.events.event.EventSearchParams;
import org.hisp.dhis.dxf2.events.event.EventService;
@@ -48,6 +47,7 @@
import org.hisp.dhis.dxf2.importsummary.ImportStatus;
import org.hisp.dhis.dxf2.importsummary.ImportSummaries;
import org.hisp.dhis.dxf2.importsummary.ImportSummary;
+import org.hisp.dhis.dxf2.render.RenderService;
import org.hisp.dhis.dxf2.utils.InputUtils;
import org.hisp.dhis.dxf2.webmessage.WebMessageException;
import org.hisp.dhis.event.EventStatus;
@@ -98,7 +98,6 @@
// Dependencies
//--------------------------------------------------------------------------
-
@Autowired
private CurrentUserService currentUserService;
@@ -123,6 +122,9 @@
@Autowired
private InputUtils inputUtils;
+ @Autowired
+ private RenderService renderService;
+
// -------------------------------------------------------------------------
// READ
// -------------------------------------------------------------------------
@@ -447,7 +449,7 @@
throw new WebMessageException( WebMessageUtils.notFound( "Event not found for uid: " + uid ) );
}
- Event updatedEvent = JacksonUtils.fromXml( request.getInputStream(), Event.class );
+ Event updatedEvent = renderService.fromXml( request.getInputStream(), Event.class );
updatedEvent.setEvent( uid );
ImportSummary importSummary = eventService.updateEvent( updatedEvent, false, importOptions );
@@ -465,7 +467,7 @@
throw new WebMessageException( WebMessageUtils.notFound( "Event not found for uid: " + uid ) );
}
- Event updatedEvent = JacksonUtils.fromJson( request.getInputStream(), Event.class );
+ Event updatedEvent = renderService.fromJson( request.getInputStream(), Event.class );
updatedEvent.setEvent( uid );
ImportSummary importSummary = eventService.updateEvent( updatedEvent, false, importOptions );
@@ -490,7 +492,7 @@
throw new WebMessageException( WebMessageUtils.notFound( "DataElement not found for uid: " + dataElementUid ) );
}
- Event updatedEvent = JacksonUtils.fromJson( request.getInputStream(), Event.class );
+ Event updatedEvent = renderService.fromJson( request.getInputStream(), Event.class );
updatedEvent.setEvent( uid );
ImportSummary importSummary = eventService.updateEvent( updatedEvent, true );
@@ -508,7 +510,7 @@
throw new WebMessageException( WebMessageUtils.notFound( "Event not found for uid: " + uid ) );
}
- Event updatedEvent = JacksonUtils.fromJson( request.getInputStream(), Event.class );
+ Event updatedEvent = renderService.fromJson( request.getInputStream(), Event.class );
updatedEvent.setEvent( uid );
eventService.updateEventForNote( updatedEvent );
@@ -526,7 +528,7 @@
throw new WebMessageException( WebMessageUtils.notFound( "Event not found for uid: " + uid ) );
}
- Event updatedEvent = JacksonUtils.fromJson( request.getInputStream(), Event.class );
+ Event updatedEvent = renderService.fromJson( request.getInputStream(), Event.class );
updatedEvent.setEvent( uid );
eventService.updateEventForEventDate( updatedEvent );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventReportController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventReportController.java 2015-07-08 08:21:49 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventReportController.java 2015-10-20 04:15:40 +0000
@@ -30,7 +30,7 @@
import org.hisp.dhis.common.DimensionService;
import org.hisp.dhis.dxf2.common.ImportOptions;
-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.eventreport.EventReport;
import org.hisp.dhis.eventreport.EventReportService;
@@ -86,7 +86,7 @@
@RequestMapping( method = RequestMethod.POST, consumes = "application/json" )
public void postJsonObject( ImportOptions importOptions, HttpServletRequest request, HttpServletResponse response ) throws Exception
{
- EventReport report = JacksonUtils.fromJson( request.getInputStream(), EventReport.class );
+ EventReport report = renderService.fromJson( request.getInputStream(), EventReport.class );
mergeEventReport( report );
@@ -107,7 +107,7 @@
throw new WebMessageException( WebMessageUtils.notFound( "Event report does not exist: " + uid ) );
}
- EventReport newReport = JacksonUtils.fromJson( request.getInputStream(), EventReport.class );
+ EventReport newReport = renderService.fromJson( request.getInputStream(), EventReport.class );
mergeEventReport( newReport );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/TrackedEntityInstanceController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/TrackedEntityInstanceController.java 2015-10-08 13:12:38 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/TrackedEntityInstanceController.java 2015-10-20 04:15:40 +0000
@@ -29,20 +29,19 @@
*/
import com.google.common.collect.Lists;
-
import org.hisp.dhis.common.DxfNamespaces;
import org.hisp.dhis.common.Grid;
import org.hisp.dhis.common.OrganisationUnitSelectionMode;
import org.hisp.dhis.common.cache.CacheStrategy;
import org.hisp.dhis.commons.util.TextUtils;
-import org.hisp.dhis.dxf2.common.JacksonUtils;
import org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstance;
import org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstanceService;
-import org.hisp.dhis.fieldfilter.FieldFilterService;
import org.hisp.dhis.dxf2.importsummary.ImportStatus;
import org.hisp.dhis.dxf2.importsummary.ImportSummaries;
import org.hisp.dhis.dxf2.importsummary.ImportSummary;
+import org.hisp.dhis.dxf2.render.RenderService;
import org.hisp.dhis.event.EventStatus;
+import org.hisp.dhis.fieldfilter.FieldFilterService;
import org.hisp.dhis.importexport.ImportStrategy;
import org.hisp.dhis.node.NodeUtils;
import org.hisp.dhis.node.types.CollectionNode;
@@ -71,7 +70,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-
import java.io.IOException;
import java.util.Date;
import java.util.List;
@@ -103,6 +101,9 @@
@Autowired
private WebMessageService webMessageService;
+ @Autowired
+ private RenderService renderService;
+
// -------------------------------------------------------------------------
// READ
// -------------------------------------------------------------------------
@@ -326,7 +327,7 @@
if ( importSummaries.getImportSummaries().size() > 1 )
{
response.setStatus( HttpServletResponse.SC_CREATED );
- JacksonUtils.toXml( response.getOutputStream(), importSummaries );
+ renderService.toXml( response.getOutputStream(), importSummaries );
}
else
{
@@ -363,7 +364,7 @@
if ( importSummaries.getImportSummaries().size() > 1 )
{
response.setStatus( HttpServletResponse.SC_CREATED );
- JacksonUtils.toJson( response.getOutputStream(), importSummaries );
+ renderService.toJson( response.getOutputStream(), importSummaries );
}
else
{
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/legend/LegendSetController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/legend/LegendSetController.java 2015-07-08 08:24:28 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/legend/LegendSetController.java 2015-10-20 04:15:40 +0000
@@ -29,7 +29,6 @@
*/
import org.hisp.dhis.dxf2.common.ImportOptions;
-import org.hisp.dhis.dxf2.common.JacksonUtils;
import org.hisp.dhis.dxf2.webmessage.WebMessageException;
import org.hisp.dhis.legend.Legend;
import org.hisp.dhis.legend.LegendService;
@@ -64,12 +63,8 @@
@PreAuthorize( "hasRole('F_GIS_ADMIN') or hasRole('ALL')" )
public void postJsonObject( ImportOptions importOptions, HttpServletRequest request, HttpServletResponse response ) throws Exception
{
- LegendSet legendSet = JacksonUtils.fromJson( request.getInputStream(), LegendSet.class );
-
- for ( Legend legend : legendSet.getLegends() )
- {
- legendService.addLegend( legend );
- }
+ LegendSet legendSet = renderService.fromJson( request.getInputStream(), LegendSet.class );
+ legendSet.getLegends().forEach( legendService::addLegend );
legendService.addLegendSet( legendSet );
@@ -98,12 +93,8 @@
legendService.deleteLegend( legend );
}
- LegendSet newLegendSet = JacksonUtils.fromJson( request.getInputStream(), LegendSet.class );
-
- for ( Legend legend : newLegendSet.getLegends() )
- {
- legendService.addLegend( legend );
- }
+ LegendSet newLegendSet = renderService.fromJson( request.getInputStream(), LegendSet.class );
+ newLegendSet.getLegends().forEach( legendService::addLegend );
legendSet.mergeWith( newLegendSet, importOptions.getMergeStrategy() );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/mapping/MapController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/mapping/MapController.java 2015-09-14 17:57:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/mapping/MapController.java 2015-10-20 04:15:40 +0000
@@ -28,19 +28,9 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.awt.image.BufferedImage;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.imageio.ImageIO;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
import org.hisp.dhis.common.DimensionService;
import org.hisp.dhis.common.cache.CacheStrategy;
import org.hisp.dhis.dxf2.common.ImportOptions;
-import org.hisp.dhis.dxf2.common.JacksonUtils;
import org.hisp.dhis.dxf2.webmessage.WebMessageException;
import org.hisp.dhis.i18n.I18nFormat;
import org.hisp.dhis.i18n.I18nManager;
@@ -65,6 +55,14 @@
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
+import javax.imageio.ImageIO;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.awt.image.BufferedImage;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.Set;
+
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
* @author Lars Helge Overland
@@ -112,7 +110,7 @@
@RequestMapping( method = RequestMethod.POST, consumes = "application/json" )
public void postJsonObject( ImportOptions importOptions, HttpServletRequest request, HttpServletResponse response ) throws Exception
{
- Map map = JacksonUtils.fromJson( request.getInputStream(), Map.class );
+ Map map = renderService.fromJson( request.getInputStream(), Map.class );
mergeMap( map );
@@ -149,7 +147,7 @@
mappingService.deleteMapView( view );
}
- Map newMap = JacksonUtils.fromJson( request.getInputStream(), Map.class );
+ Map newMap = renderService.fromJson( request.getInputStream(), Map.class );
mergeMap( newMap );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/organisationunit/OrganisationUnitLocationController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/organisationunit/OrganisationUnitLocationController.java 2015-07-08 08:31:17 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/organisationunit/OrganisationUnitLocationController.java 2015-10-20 04:15:40 +0000
@@ -31,7 +31,7 @@
import org.hisp.dhis.attribute.Attribute;
import org.hisp.dhis.attribute.AttributeValue;
import org.hisp.dhis.commons.filter.FilterUtils;
-import org.hisp.dhis.dxf2.common.JacksonUtils;
+import org.hisp.dhis.dxf2.render.RenderService;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
@@ -39,16 +39,13 @@
import org.hisp.dhis.system.filter.OrganisationUnitPolygonCoveringCoordinateFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
-import org.springframework.ui.Model;
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.util.ArrayList;
import java.util.List;
-import java.util.Map;
import java.util.Set;
/**
@@ -65,6 +62,9 @@
@Autowired
private OrganisationUnitService organisationUnitService;
+ @Autowired
+ private RenderService renderService;
+
/**
* Get Organisation Units within a distance from a location
*/
@@ -73,9 +73,7 @@
@RequestParam Double longitude,
@RequestParam Double latitude,
@RequestParam Double distance,
- @RequestParam( required = false ) String orgUnitGroupSetId,
- Model model, HttpServletRequest request, HttpServletResponse response )
- throws Exception
+ @RequestParam( required = false ) String orgUnitGroupSetId, HttpServletResponse response ) throws Exception
{
List<OrganisationUnit> entityList = new ArrayList<>(
organisationUnitService.getOrganisationUnitWithinDistance( longitude, latitude, distance ) );
@@ -113,7 +111,7 @@
organisationUnit.removeAllOrganisationUnitGroups();
}
- JacksonUtils.toJson( response.getOutputStream(), entityList );
+ renderService.toJson( response.getOutputStream(), entityList );
}
/**
@@ -124,10 +122,7 @@
@RequestParam Double longitude,
@RequestParam Double latitude,
@RequestParam( required = false ) String topOrgUnit,
- @RequestParam( required = false ) Integer targetLevel,
- @RequestParam Map<String, String> parameters,
- Model model, HttpServletRequest request, HttpServletResponse response )
- throws Exception
+ @RequestParam( required = false ) Integer targetLevel, HttpServletResponse response ) throws Exception
{
List<OrganisationUnit> entityList = new ArrayList<>(
organisationUnitService.getOrganisationUnitByCoordinate( longitude, latitude, topOrgUnit, targetLevel ) );
@@ -143,19 +138,15 @@
organisationUnit.removeAllOrganisationUnitGroups();
}
- JacksonUtils.toJson( response.getOutputStream(), entityList );
+ renderService.toJson( response.getOutputStream(), entityList );
}
/**
* Check if the location lies within the organisation unit boundary
*/
@RequestMapping( value = "/locationWithinOrgUnitBoundary", method = RequestMethod.GET, produces = { "*/*", "application/json" } )
- public void checkLocationWithinOrgUnit(
- @RequestParam String orgUnitUid,
- @RequestParam Double longitude,
- @RequestParam Double latitude,
- Model model, HttpServletRequest request, HttpServletResponse response )
- throws Exception
+ public void checkLocationWithinOrgUnit( @RequestParam String orgUnitUid,
+ @RequestParam Double longitude, @RequestParam Double latitude, HttpServletResponse response ) throws Exception
{
boolean withinOrgUnit = false;
@@ -168,6 +159,6 @@
withinOrgUnit = true;
}
- JacksonUtils.toJson( response.getOutputStream(), withinOrgUnit );
+ renderService.toJson( response.getOutputStream(), withinOrgUnit );
}
}