dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #16043
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5979: Removed phone number param from DataValueSetController
------------------------------------------------------------
revno: 5979
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-02-16 10:03:14 +0100
message:
Removed phone number param from DataValueSetController
modified:
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/service/DataValueSetService.java
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/resources/templates/html/dataValueSets.xsl
--
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-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
- * <ul>
- * <li>No user has phone number
- * <li>More than one user has phone number
- * <li>User not associated with org unit
- * <li>User associated with multiple org units
- * </ul>
- */
- private String findOrgUnit( String phoneNumber )
- throws IllegalArgumentException
- {
- Collection<User> 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<OrganisationUnit> 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:
<dataValueSet xmlns="http://dhis2.org/schema/dxf/2.0" period="periodISODate" dataSet="dataSetID" orgUnit="orgUnitID">
- <dataValue dataElement="dataElementId" categoryOptionCombo="categoryOptionComboId" value="1" />
- <dataValue dataElement="dataElementId" categoryOptionCombo="categoryOptionComboId" value="2" />
- <dataValue dataElement="dataElementId" categoryOptionCombo="categoryOptionComboId" value="3" />
+ <dataValue dataElement="dataElementID" categoryOptionCombo="categoryOptionComboID" value="1" />
+ <dataValue dataElement="dataElementID" categoryOptionCombo="categoryOptionComboID" value="2" />
+ <dataValue dataElement="dataElementID" categoryOptionCombo="categoryOptionComboID" value="3" />
</dataValueSet>
]]>
</pre>