dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #42369
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21661: Minor fixes to controllers
------------------------------------------------------------
revno: 21661
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2016-01-08 17:14:46 +0700
message:
Minor fixes to controllers
removed:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/program/
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/program/ProgramDataElementController.java
added:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/ProgramDataElementController.java
modified:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/ProgramStageController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/sms/SmsController.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
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/ProgramDataElementController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/ProgramDataElementController.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/ProgramDataElementController.java 2016-01-08 10:14:46 +0000
@@ -0,0 +1,75 @@
+package org.hisp.dhis.webapi.controller.event;
+
+/*
+ * Copyright (c) 2004-2016, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.hisp.dhis.program.ProgramDataElement;
+import org.hisp.dhis.program.ProgramService;
+import org.hisp.dhis.query.Order;
+import org.hisp.dhis.query.Query;
+import org.hisp.dhis.query.QueryParserException;
+import org.hisp.dhis.webapi.controller.AbstractCrudController;
+import org.hisp.dhis.webapi.webdomain.WebMetaData;
+import org.hisp.dhis.webapi.webdomain.WebOptions;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import java.util.List;
+
+/**
+ * @author Lars Helge Overland
+ */
+@Controller
+@RequestMapping( value = "/programDataElements" )
+public class ProgramDataElementController
+ extends AbstractCrudController<ProgramDataElement>
+{
+ @Autowired
+ private ProgramService programService;
+
+ @Override
+ @SuppressWarnings( "unchecked" )
+ protected List<ProgramDataElement> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters, List<Order> orders ) throws QueryParserException
+ {
+ List<ProgramDataElement> programDataElements;
+ Query query = queryService.getQueryFromUrl( ProgramDataElement.class, filters, orders );
+ query.setDefaultOrder();
+
+ if ( options.contains( "program" ) )
+ {
+ String programUid = options.get( "program" );
+ programDataElements = programService.getGeneratedProgramDataElements( programUid );
+ query.setObjects( programDataElements );
+ }
+
+ programDataElements = (List<ProgramDataElement>) queryService.query( query );
+
+ return programDataElements;
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/ProgramStageController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/ProgramStageController.java 2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/ProgramStageController.java 2016-01-08 10:14:46 +0000
@@ -28,24 +28,12 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import com.google.common.collect.Lists;
-import org.hisp.dhis.program.Program;
-import org.hisp.dhis.program.ProgramService;
import org.hisp.dhis.program.ProgramStage;
-import org.hisp.dhis.query.Order;
-import org.hisp.dhis.query.Query;
-import org.hisp.dhis.query.QueryParserException;
import org.hisp.dhis.schema.descriptors.ProgramStageSchemaDescriptor;
import org.hisp.dhis.webapi.controller.AbstractCrudController;
-import org.hisp.dhis.webapi.webdomain.WebMetaData;
-import org.hisp.dhis.webapi.webdomain.WebOptions;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
-import java.util.ArrayList;
-import java.util.List;
-
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@@ -54,41 +42,4 @@
public class ProgramStageController
extends AbstractCrudController<ProgramStage>
{
- private ProgramService programService;
-
- @Autowired
- public void setProgramService( ProgramService programService )
- {
- this.programService = programService;
- }
-
- @Override
- @SuppressWarnings( "unchecked" )
- protected List<ProgramStage> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters, List<Order> orders ) throws QueryParserException
- {
- List<ProgramStage> entityList = new ArrayList<>();
- Query query = queryService.getQueryFromUrl( getEntityClass(), filters, orders );
- query.setDefaultOrder();
-
- if ( options.getOptions().containsKey( "query" ) )
- {
- entityList = Lists.newArrayList( manager.filter( getEntityClass(), options.getOptions().get( "query" ) ) );
- }
- else if ( options.getOptions().containsKey( "program" ) )
- {
- String programId = options.getOptions().get( "program" );
- Program program = programService.getProgram( programId );
-
- if ( program != null )
- {
- entityList = new ArrayList<>( program.getProgramStages() );
- }
- }
- else
- {
- entityList = (List<ProgramStage>) queryService.query( query );
- }
-
- return entityList;
- }
}
=== removed directory 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/program'
=== removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/program/ProgramDataElementController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/program/ProgramDataElementController.java 2016-01-06 02:52:09 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/program/ProgramDataElementController.java 1970-01-01 00:00:00 +0000
@@ -1,75 +0,0 @@
-package org.hisp.dhis.webapi.controller.program;
-
-/*
- * Copyright (c) 2004-2016, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import org.hisp.dhis.program.ProgramDataElement;
-import org.hisp.dhis.program.ProgramService;
-import org.hisp.dhis.query.Order;
-import org.hisp.dhis.query.Query;
-import org.hisp.dhis.query.QueryParserException;
-import org.hisp.dhis.webapi.controller.AbstractCrudController;
-import org.hisp.dhis.webapi.webdomain.WebMetaData;
-import org.hisp.dhis.webapi.webdomain.WebOptions;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import java.util.List;
-
-/**
- * @author Lars Helge Overland
- */
-@Controller
-@RequestMapping( value = "/programDataElements" )
-public class ProgramDataElementController
- extends AbstractCrudController<ProgramDataElement>
-{
- @Autowired
- private ProgramService programService;
-
- @Override
- @SuppressWarnings( "unchecked" )
- protected List<ProgramDataElement> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters, List<Order> orders ) throws QueryParserException
- {
- List<ProgramDataElement> programDataElements;
- Query query = queryService.getQueryFromUrl( ProgramDataElement.class, filters, orders );
- query.setDefaultOrder();
-
- if ( options.contains( "program" ) )
- {
- String programUid = options.get( "program" );
- programDataElements = programService.getGeneratedProgramDataElements( programUid );
- query.setObjects( programDataElements );
- }
-
- programDataElements = (List<ProgramDataElement>) queryService.query( query );
-
- return programDataElements;
- }
-}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/sms/SmsController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/sms/SmsController.java 2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/sms/SmsController.java 2016-01-08 10:14:46 +0000
@@ -28,13 +28,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.text.ParseException;
-import java.util.Date;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
import org.hisp.dhis.dxf2.webmessage.WebMessageException;
import org.hisp.dhis.sms.SmsSender;
import org.hisp.dhis.sms.incoming.IncomingSmsService;
@@ -48,6 +41,12 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.text.ParseException;
+import java.util.Date;
+import java.util.Map;
+
/**
* Zubair <rajazubair.asghar@xxxxxxxxx>
*/
@@ -76,7 +75,7 @@
@RequestMapping( value = "/outbound", method = RequestMethod.POST )
public void sendSMSMessage( @RequestParam String recipient, @RequestParam String message,
HttpServletResponse response, HttpServletRequest request )
- throws WebMessageException
+ throws WebMessageException
{
if ( recipient == null || recipient.length() <= 0 )
{
@@ -104,7 +103,7 @@
@RequestMapping( value = "/outbound", method = RequestMethod.POST, consumes = "application/json" )
public void sendSMSMessage( @RequestBody Map<String, Object> jsonMessage, HttpServletResponse response,
HttpServletRequest request )
- throws WebMessageException
+ throws WebMessageException
{
if ( jsonMessage == null )
{
@@ -128,8 +127,8 @@
@PreAuthorize( "hasRole('ALL') or hasRole('F_MOBILE_SETTINGS')" )
public void receiveSMSMessage( @RequestParam String originator, @RequestParam( required = false ) Date receivedTime,
@RequestParam String message, @RequestParam( defaultValue = "Unknown", required = false ) String gateway,
- HttpServletRequest request, HttpServletResponse response)
- throws WebMessageException, ParseException
+ HttpServletRequest request, HttpServletResponse response )
+ throws WebMessageException, ParseException
{
if ( originator == null || originator.length() <= 0 )
{
@@ -151,7 +150,7 @@
@PreAuthorize( "hasRole('ALL') or hasRole('F_MOBILE_SETTINGS')" )
public void receiveSMSMessage( @RequestBody Map<String, Object> jsonMassage, HttpServletRequest request,
HttpServletResponse response )
- throws WebMessageException, ParseException
+ throws WebMessageException, ParseException
{
if ( jsonMassage == null )
{