dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #40660
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20658: minor cleanup in EventController
------------------------------------------------------------
revno: 20658
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-10-13 09:15:59 +0700
message:
minor cleanup in EventController
modified:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventController.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/EventController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventController.java 2015-10-01 11:35:44 +0000
+++ 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
@@ -48,6 +48,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.utils.InputUtils;
import org.hisp.dhis.dxf2.webmessage.WebMessageException;
import org.hisp.dhis.event.EventStatus;
import org.hisp.dhis.importexport.ImportStrategy;
@@ -59,7 +60,6 @@
import org.hisp.dhis.user.CurrentUserService;
import org.hisp.dhis.webapi.service.WebMessageService;
import org.hisp.dhis.webapi.utils.ContextUtils;
-import org.hisp.dhis.dxf2.utils.InputUtils;
import org.hisp.dhis.webapi.utils.WebMessageUtils;
import org.hisp.dhis.webapi.webdomain.WebOptions;
import org.springframework.beans.factory.annotation.Autowired;
@@ -74,7 +74,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -120,7 +119,7 @@
@Autowired
private WebMessageService webMessageService;
-
+
@Autowired
private InputUtils inputUtils;
@@ -151,17 +150,17 @@
@RequestParam( required = false ) boolean skipPaging,
@RequestParam( required = false ) String attachment,
@RequestParam Map<String, String> parameters, IdSchemes idSchemes, Model model, HttpServletResponse response, HttpServletRequest request )
- throws WebMessageException
+ throws WebMessageException
{
WebOptions options = new WebOptions( parameters );
DataElementCategoryOptionCombo attributeOptionCombo = inputUtils.getAttributeOptionCombo( attributeCc, attributeCos );
-
+
if ( attributeOptionCombo == null )
{
throw new WebMessageException( WebMessageUtils.conflict( "Illegal attribute option combo identifier: " + attributeCc + " " + attributeCos ) );
}
-
+
EventSearchParams params = eventService.getFromUrl( program, programStage, programStatus, followUp, orgUnit, ouMode,
trackedEntityInstance, startDate, endDate, status, lastUpdated, attributeOptionCombo, idSchemes, page, pageSize, totalPages, skipPaging, false );
@@ -213,17 +212,15 @@
@RequestParam( required = false ) boolean skipPaging,
@RequestParam( required = false ) String attachment,
@RequestParam( required = false, defaultValue = "false" ) boolean skipHeader,
- @RequestParam Map<String, String> parameters,
- IdSchemes idSchemes, Model model, HttpServletResponse response, HttpServletRequest request ) throws IOException, WebMessageException
+ IdSchemes idSchemes, HttpServletResponse response, HttpServletRequest request ) throws IOException, WebMessageException
{
-
DataElementCategoryOptionCombo attributeOptionCombo = inputUtils.getAttributeOptionCombo( attributeCc, attributeCos );
-
+
if ( attributeOptionCombo == null )
{
throw new WebMessageException( WebMessageUtils.conflict( "Illegal attribute option combo identifier: " + attributeCc + " " + attributeCos ) );
}
-
+
EventSearchParams params = eventService.getFromUrl( program, programStage, programStatus, followUp, orgUnit, ouMode,
trackedEntityInstance, startDate, endDate, status, lastUpdated, attributeOptionCombo, idSchemes, page, pageSize, totalPages, skipPaging, false );
@@ -261,19 +258,19 @@
@RequestParam( required = false ) String attributeCos,
@RequestParam( required = false ) boolean totalPages,
@RequestParam( required = false ) boolean skipPaging,
- @RequestParam Map<String, String> parameters, Model model, HttpServletRequest request )
+ @RequestParam Map<String, String> parameters, Model model )
throws WebMessageException
-
+
{
WebOptions options = new WebOptions( parameters );
-
+
DataElementCategoryOptionCombo attributeOptionCombo = inputUtils.getAttributeOptionCombo( attributeCc, attributeCos );
-
+
if ( attributeOptionCombo == null )
{
throw new WebMessageException( WebMessageUtils.conflict( "Illegal attribute option combo identifier: " + attributeCc + " " + attributeCos ) );
}
-
+
EventSearchParams params = eventService.getFromUrl( program, null, programStatus, null,
orgUnit, ouMode, null, startDate, endDate, eventStatus, null, attributeOptionCombo, null, null, null, totalPages, skipPaging, true );
@@ -288,7 +285,7 @@
@RequestMapping( value = "/{uid}", method = RequestMethod.GET )
@PreAuthorize( "hasRole('ALL') or hasRole('F_TRACKED_ENTITY_DATAVALUE_ADD')" )
public String getEvent( @PathVariable( "uid" ) String uid, @RequestParam Map<String, String> parameters,
- Model model, HttpServletRequest request, HttpServletResponse response ) throws Exception
+ Model model, HttpServletRequest request ) throws Exception
{
WebOptions options = new WebOptions( parameters );
Event event = eventService.getEvent( uid );
@@ -343,16 +340,9 @@
{
ImportSummaries importSummaries = eventService.addEventsXml( inputStream, importOptions );
- for ( ImportSummary importSummary : importSummaries.getImportSummaries() )
- {
- if ( !importOptions.isDryRun() )
- {
- if ( !importSummary.getStatus().equals( ImportStatus.ERROR ) )
- {
- importSummary.setHref( ContextUtils.getRootPath( request ) + RESOURCE_PATH + "/" + importSummary.getReference() );
- }
- }
- }
+ importSummaries.getImportSummaries().stream()
+ .filter( importSummary -> !importOptions.isDryRun() && !importSummary.getStatus().equals( ImportStatus.ERROR ) )
+ .forEach( importSummary -> importSummary.setHref( ContextUtils.getRootPath( request ) + RESOURCE_PATH + "/" + importSummary.getReference() ) );
if ( importSummaries.getImportSummaries().size() == 1 )
{
@@ -389,16 +379,9 @@
{
ImportSummaries importSummaries = eventService.addEventsJson( inputStream, importOptions );
- for ( ImportSummary importSummary : importSummaries.getImportSummaries() )
- {
- if ( !importOptions.isDryRun() )
- {
- if ( !importSummary.getStatus().equals( ImportStatus.ERROR ) )
- {
- importSummary.setHref( ContextUtils.getRootPath( request ) + RESOURCE_PATH + "/" + importSummary.getReference() );
- }
- }
- }
+ importSummaries.getImportSummaries().stream()
+ .filter( importSummary -> !importOptions.isDryRun() && !importSummary.getStatus().equals( ImportStatus.ERROR ) )
+ .forEach( importSummary -> importSummary.setHref( ContextUtils.getRootPath( request ) + RESOURCE_PATH + "/" + importSummary.getReference() ) );
if ( importSummaries.getImportSummaries().size() == 1 )
{