=== modified file 'dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/SixMonthlyAprilPeriodTypeTest.java' --- dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/SixMonthlyAprilPeriodTypeTest.java 2014-02-08 18:09:18 +0000 +++ dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/SixMonthlyAprilPeriodTypeTest.java 2014-02-12 16:59:24 +0000 @@ -30,10 +30,8 @@ import static org.junit.Assert.assertEquals; -import java.util.Calendar; import java.util.List; -import org.hisp.dhis.period.Cal; import org.junit.Before; import org.junit.Test; === modified file 'dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/SixMonthlyPeriodTypeTest.java' --- dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/SixMonthlyPeriodTypeTest.java 2014-02-08 18:09:18 +0000 +++ dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/SixMonthlyPeriodTypeTest.java 2014-02-12 16:59:24 +0000 @@ -30,10 +30,8 @@ import static org.junit.Assert.assertEquals; -import java.util.Calendar; import java.util.List; -import org.hisp.dhis.period.Cal; import org.junit.Before; import org.junit.Test; === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataValueController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataValueController.java 2014-02-11 15:34:53 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataValueController.java 2014-02-12 16:59:24 +0000 @@ -28,7 +28,9 @@ * 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; @@ -51,6 +53,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; 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; @@ -329,4 +332,104 @@ dataValueService.deleteDataValue( dataValue ); } + + @RequestMapping( method = RequestMethod.GET ) + public String getDataValue( + @RequestParam String de, + @RequestParam( required = false ) String co, + @RequestParam( required = false ) String cc, + @RequestParam( required = false ) String cp, + @RequestParam String pe, + @RequestParam String ou, + Model model, HttpServletResponse response ) + { + // --------------------------------------------------------------------- + // Input validation + // --------------------------------------------------------------------- + + DataElement dataElement = dataElementService.getDataElement( de ); + + if ( dataElement == null ) + { + ContextUtils.conflictResponse( response, "Illegal data element identifier: " + de ); + return null; + } + + DataElementCategoryOptionCombo categoryOptionCombo = null; + + if ( co != null ) + { + categoryOptionCombo = categoryService.getDataElementCategoryOptionCombo( co ); + } + else + { + categoryOptionCombo = categoryService.getDefaultDataElementCategoryOptionCombo(); + } + + if ( categoryOptionCombo == null ) + { + ContextUtils.conflictResponse( response, "Illegal category option combo identifier: " + co ); + return null; + } + + DataElementCategoryOptionCombo attributeOptionCombo = inputUtils.getAttributeOptionCombo( response, cc, cp ); + + if ( attributeOptionCombo == null ) + { + return null; + } + + Period period = PeriodType.getPeriodFromIsoString( pe ); + + if ( period == null ) + { + ContextUtils.conflictResponse( response, "Illegal period identifier: " + pe ); + return null; + } + + OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( ou ); + + if ( organisationUnit == null ) + { + ContextUtils.conflictResponse( response, "Illegal organisation unit identifier: " + ou ); + return null; + } + + boolean isInHierarchy = organisationUnitService.isInUserHierarchy( organisationUnit ); + + if ( !isInHierarchy ) + { + ContextUtils.conflictResponse( response, "Organisation unit is not in the hierarchy of the current user: " + ou ); + return null; + } + + // --------------------------------------------------------------------- + // Locking validation + // --------------------------------------------------------------------- + + if ( dataSetService.isLocked( dataElement, period, organisationUnit, null ) ) + { + ContextUtils.conflictResponse( response, "Data set is locked" ); + return null; + } + + // --------------------------------------------------------------------- + // Get data value + // --------------------------------------------------------------------- + + DataValue dataValue = dataValueService.getDataValue( dataElement, period, organisationUnit, categoryOptionCombo, attributeOptionCombo ); + + if ( dataValue == null ) + { + ContextUtils.conflictResponse( response, "Data value does not exist" ); + return null; + } + + List value = new ArrayList(); + value.add( dataValue.getValue() ); + + model.addAttribute( "model", value ); + + return "value"; + } } === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataValueSetController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataValueSetController.java 2014-01-08 11:47:35 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataValueSetController.java 2014-02-12 16:59:24 +0000 @@ -136,7 +136,7 @@ } @RequestMapping(method = RequestMethod.GET, produces = CONTENT_TYPE_CSV) - public void getDataValuesCsv( + public void getDataValueSetCsv( @RequestParam Set dataSet, @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate, @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate, === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/GetDataElementCategoryOptionAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/GetDataElementCategoryOptionAction.java 2014-02-12 16:09:47 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/GetDataElementCategoryOptionAction.java 2014-02-12 16:59:24 +0000 @@ -28,13 +28,9 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.util.ArrayList; -import java.util.Collections; import java.util.List; -import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator; import org.hisp.dhis.concept.Concept; -import org.hisp.dhis.concept.ConceptService; import org.hisp.dhis.dataelement.DataElementCategoryOption; import org.hisp.dhis.dataelement.DataElementCategoryService; import org.hisp.dhis.paging.ActionPagingSupport;