=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/service/DataValueSetService.java' --- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/service/DataValueSetService.java 2012-01-06 09:42:17 +0000 +++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/service/DataValueSetService.java 2012-02-16 09:03:14 +0000 @@ -128,10 +128,10 @@ public void saveDataValueSet( DataValueSet dataValueSet ) throws IllegalArgumentException { - Date timestamp = new Date(); IdentificationStrategy idStrategy = dataValueSet.getIdScheme(); + if ( idStrategy != DataValueSet.DEFAULT_STRATEGY ) { throw new IllegalArgumentException( "Only UID id strategy supported currently." ); @@ -434,5 +434,4 @@ { this.currentUserService = currentUserService; } - } === 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 2012-01-11 09:02:20 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataValueSetController.java 2012-02-16 09:03:14 +0000 @@ -32,17 +32,12 @@ import org.hisp.dhis.api.webdomain.DataValueSets; import org.hisp.dhis.importexport.dxf2.model.DataValueSet; import org.hisp.dhis.importexport.dxf2.service.DataValueSetService; -import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.user.User; -import org.hisp.dhis.user.UserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.*; - -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.util.Collection; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; @Controller @RequestMapping( value = DataValueSetController.RESOURCE_PATH ) @@ -55,9 +50,6 @@ @Autowired private DataValueSetService dataValueSetService; - @Autowired - private UserService userService; - @RequestMapping( method = RequestMethod.GET ) public String getDataValueSet( Model model ) throws Exception { @@ -67,77 +59,11 @@ } @RequestMapping( method = RequestMethod.POST ) - public void storeDataValueSet( @RequestBody DataValueSet dataValueSet, @RequestParam( required = false ) String phoneNumber ) + public void storeDataValueSet( @RequestBody DataValueSet dataValueSet ) { - if ( phoneNumber != null && !phoneNumber.trim().isEmpty() ) - { - String unitId = findOrgUnit( phoneNumber ); - dataValueSet.setOrganisationUnitIdentifier( unitId ); - } - dataValueSetService.saveDataValueSet( dataValueSet ); - if ( log.isDebugEnabled() ) - { - String message = "Saved data value set for " + dataValueSet.getDataSetIdentifier() + ", " - + dataValueSet.getOrganisationUnitIdentifier() + ", " + dataValueSet.getPeriodIsoDate(); - - log.debug( message ); - } - } - - @ExceptionHandler - public void mapException( IllegalArgumentException exception, HttpServletResponse response ) - throws IOException - { - response.setStatus( HttpServletResponse.SC_CONFLICT ); - response.setContentType( "text/plain" ); - response.getWriter().write( "Problem with input: " + exception.getMessage() ); - } - - /** - * Find orgunit corresponding to the registered phone number. - * - * @param phoneNumber The phone number to look up - * @return the organisation unit uid - * @throws IllegalArgumentException if - * - */ - private String findOrgUnit( String phoneNumber ) - throws IllegalArgumentException - { - Collection users = userService.getUsersByPhoneNumber( phoneNumber ); - - if ( users == null || users.isEmpty() ) - { - throw new IllegalArgumentException( "Phone number '" + phoneNumber + "' not associated with any user" ); - } - else if ( users.size() > 1 ) - { - throw new IllegalArgumentException( "Phone number '" + phoneNumber + "' associated with multiple users" ); - } - - User user = users.iterator().next(); - - Collection organisationUnits = user.getOrganisationUnits(); - - if ( organisationUnits == null || organisationUnits.isEmpty() ) - { - throw new IllegalArgumentException( "User '" + user.getName() - + "' not associated with any organisation unit" ); - } - else if ( organisationUnits.size() > 1 ) - { - throw new IllegalArgumentException( "User '" + user.getName() - + "' associated with multiple organisation units" ); - } - - return organisationUnits.iterator().next().getUid(); - + log.debug( "Saved data value set for data set: " + dataValueSet.getDataSetIdentifier() + + ", org unit: " + dataValueSet.getOrganisationUnitIdentifier() + ", period: " + dataValueSet.getPeriodIsoDate() ); } } === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/dataValueSets.xsl' --- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/dataValueSets.xsl 2012-02-15 18:21:05 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/dataValueSets.xsl 2012-02-16 09:03:14 +0000 @@ -18,9 +18,9 @@ Period values are given in ISO format. A complete example of a data value set would be: - - - + + + ]]>