=== modified file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/controller/FacilityController.java' --- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/controller/FacilityController.java 2013-01-31 02:31:35 +0000 +++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/controller/FacilityController.java 2013-01-31 03:22:50 +0000 @@ -449,8 +449,6 @@ public ResponseEntity updateFacility( @PathVariable String id, @RequestBody Facility facility ) throws IOException { facility.setId( id ); - OrganisationUnit organisationUnit = conversionService.convert( facility, OrganisationUnit.class ); - Set> constraintViolations = validator.validate( facility, Default.class, Update.class ); String json = ValidationUtils.constraintViolationsToJson( constraintViolations ); @@ -460,6 +458,7 @@ if ( constraintViolations.isEmpty() ) { + OrganisationUnit organisationUnit = conversionService.convert( facility, OrganisationUnit.class ); OrganisationUnit ou = organisationUnitService.getOrganisationUnit( facility.getId() ); if ( ou == null ) === modified file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/domain/Facility.java' --- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/domain/Facility.java 2012-12-11 13:34:09 +0000 +++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/domain/Facility.java 2013-01-31 03:22:50 +0000 @@ -34,7 +34,11 @@ import javax.validation.constraints.NotNull; import javax.validation.constraints.Null; -import java.util.*; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** * @author Morten Olav Hansen @@ -42,8 +46,8 @@ public class Facility { // Internal system identifier - @Null( groups = Create.class ) - @NotNull( groups = Update.class ) + @Null(groups = Create.class) + @NotNull(groups = Update.class) @Length(min = 11, max = 11) private String id; === modified file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/FacilityToOrganisationUnitConverter.java' --- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/FacilityToOrganisationUnitConverter.java 2012-12-13 17:04:35 +0000 +++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/FacilityToOrganisationUnitConverter.java 2013-01-31 03:22:50 +0000 @@ -47,11 +47,11 @@ public class FacilityToOrganisationUnitConverter implements Converter { @Autowired - @Qualifier( "org.hisp.dhis.organisationunit.OrganisationUnitService" ) + @Qualifier("org.hisp.dhis.organisationunit.OrganisationUnitService") private OrganisationUnitService organisationUnitService; @Autowired - @Qualifier( "org.hisp.dhis.dataset.DataSetService" ) + @Qualifier("org.hisp.dhis.dataset.DataSetService") private DataSetService dataSetService; @Override @@ -62,7 +62,7 @@ organisationUnit.setUid( facility.getId() ); organisationUnit.setName( facility.getName() ); - if ( facility.getName().length() > 49 ) + if ( facility.getName() != null && facility.getName().length() > 49 ) { organisationUnit.setShortName( facility.getName().substring( 0, 49 ) ); } @@ -72,18 +72,6 @@ } organisationUnit.setActive( facility.getActive() ); - organisationUnit.setParent( organisationUnitService.getOrganisationUnit( (String) facility.getProperties().get( "parent" ) ) ); - - Collection dataSets = (Collection) facility.getProperties().get( "dataSets" ); - - if ( dataSets != null ) - { - for ( String uid : dataSets ) - { - DataSet dataSet = dataSetService.getDataSet( uid ); - organisationUnit.getDataSets().add( dataSet ); - } - } if ( facility.getIdentifiers() != null ) { @@ -107,7 +95,23 @@ } catch ( NumberFormatException err ) { - organisationUnit.setCoordinates( "" ); + organisationUnit.setCoordinates( null ); + } + + if ( facility.getProperties() != null ) + { + organisationUnit.setParent( organisationUnitService.getOrganisationUnit( (String) facility.getProperties().get( "parent" ) ) ); + + Collection dataSets = (Collection) facility.getProperties().get( "dataSets" ); + + if ( dataSets != null ) + { + for ( String uid : dataSets ) + { + DataSet dataSet = dataSetService.getDataSet( uid ); + organisationUnit.getDataSets().add( dataSet ); + } + } } return organisationUnit; === modified file 'dhis-2/pom.xml' --- dhis-2/pom.xml 2012-12-18 17:12:07 +0000 +++ dhis-2/pom.xml 2013-01-31 03:22:50 +0000 @@ -394,7 +394,7 @@ org.springframework.hateoas spring-hateoas - 0.3.0.RELEASE + 0.4.0.RELEASE cglib