dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #36344
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18611: Data value controller, performance fixes
------------------------------------------------------------
revno: 18611
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-03-16 14:49:22 +0100
message:
Data value controller, performance fixes
modified:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataValueController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/InputUtils.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/DataValueController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataValueController.java 2015-02-19 09:18:17 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataValueController.java 2015-03-16 13:49:22 +0000
@@ -28,11 +28,17 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import javax.servlet.http.HttpServletResponse;
+
import org.apache.commons.lang3.StringUtils;
+import org.hisp.dhis.common.IdentifiableObjectManager;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
import org.hisp.dhis.dataelement.DataElementCategoryService;
-import org.hisp.dhis.dataelement.DataElementService;
import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.datavalue.DataValue;
import org.hisp.dhis.datavalue.DataValueService;
@@ -52,11 +58,6 @@
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
-import javax.servlet.http.HttpServletResponse;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
/**
* @author Lars Helge Overland
*/
@@ -74,9 +75,6 @@
private CurrentUserService currentUserService;
@Autowired
- private DataElementService dataElementService;
-
- @Autowired
private DataElementCategoryService categoryService;
@Autowired
@@ -89,6 +87,9 @@
private DataSetService dataSetService;
@Autowired
+ private IdentifiableObjectManager idObjectManager;
+
+ @Autowired
private InputUtils inputUtils;
// ---------------------------------------------------------------------
@@ -112,7 +113,7 @@
// Input validation
// ---------------------------------------------------------------------
- DataElement dataElement = dataElementService.getDataElement( de );
+ DataElement dataElement = idObjectManager.get( DataElement.class, de );
if ( dataElement == null )
{
@@ -152,7 +153,7 @@
return;
}
- OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( ou );
+ OrganisationUnit organisationUnit = idObjectManager.get( OrganisationUnit.class, ou );
if ( organisationUnit == null )
{
@@ -277,7 +278,7 @@
// Input validation
// ---------------------------------------------------------------------
- DataElement dataElement = dataElementService.getDataElement( de );
+ DataElement dataElement = idObjectManager.get( DataElement.class, de );
if ( dataElement == null )
{
@@ -317,7 +318,7 @@
return;
}
- OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( ou );
+ OrganisationUnit organisationUnit = idObjectManager.get( OrganisationUnit.class, ou );
if ( organisationUnit == null )
{
@@ -376,7 +377,7 @@
// Input validation
// ---------------------------------------------------------------------
- DataElement dataElement = dataElementService.getDataElement( de );
+ DataElement dataElement = idObjectManager.get( DataElement.class, de );
if ( dataElement == null )
{
@@ -416,7 +417,7 @@
return null;
}
- OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( ou );
+ OrganisationUnit organisationUnit = idObjectManager.get( OrganisationUnit.class, ou );
if ( organisationUnit == null )
{
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/InputUtils.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/InputUtils.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/InputUtils.java 2015-03-16 13:49:22 +0000
@@ -33,6 +33,7 @@
import javax.servlet.http.HttpServletResponse;
+import org.hisp.dhis.common.IdentifiableObjectManager;
import org.hisp.dhis.dataelement.CategoryOptionGroup;
import org.hisp.dhis.dataelement.DataElementCategoryCombo;
import org.hisp.dhis.dataelement.DataElementCategoryOption;
@@ -48,6 +49,9 @@
@Autowired
private DataElementCategoryService categoryService;
+ @Autowired
+ private IdentifiableObjectManager idObjectManager;
+
/**
* Validates and retrieves the attribute option combo. 409 conflict as status
* code along with a textual message will be set on the response in case of
@@ -75,7 +79,7 @@
DataElementCategoryCombo categoryCombo = null;
- if ( cc != null && ( categoryCombo = categoryService.getDataElementCategoryCombo( cc ) ) == null )
+ if ( cc != null && ( categoryCombo = idObjectManager.get( DataElementCategoryCombo.class, cc ) ) == null )
{
ContextUtils.conflictResponse( response, "Illegal category combo identifier: " + cc );
return null;
@@ -91,13 +95,13 @@
{
Set<DataElementCategoryOption> categoryOptions = new HashSet<>();
- for ( String id : opts )
+ for ( String uid : opts )
{
- DataElementCategoryOption categoryOption = categoryService.getDataElementCategoryOption( id );
+ DataElementCategoryOption categoryOption = idObjectManager.get( DataElementCategoryOption.class, uid );
if ( categoryOption == null )
{
- ContextUtils.conflictResponse( response, "Illegal category option identifier: " + id );
+ ContextUtils.conflictResponse( response, "Illegal category option identifier: " + uid );
return null;
}