=== modified file 'dhis-2/dhis-web/dhis-web-ohie/src/main/java/org/hisp/dhis/web/ohie/common/domain/wsa/Address.java' --- dhis-2/dhis-web/dhis-web-ohie/src/main/java/org/hisp/dhis/web/ohie/common/domain/wsa/Address.java 2014-01-16 15:26:39 +0000 +++ dhis-2/dhis-web/dhis-web-ohie/src/main/java/org/hisp/dhis/web/ohie/common/domain/wsa/Address.java 2014-01-21 07:35:08 +0000 @@ -36,8 +36,8 @@ /** * @author Morten Olav Hansen */ -@XmlAccessorType( XmlAccessType.FIELD ) -@XmlType( name = "Address", namespace = "http://www.w3.org/2005/08/addressing" ) +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "Address", namespace = "http://www.w3.org/2005/08/addressing") public class Address { @XmlValue @@ -47,6 +47,11 @@ { } + public Address( String value ) + { + this.value = value; + } + public String getValue() { return value; === modified file 'dhis-2/dhis-web/dhis-web-ohie/src/main/java/org/hisp/dhis/web/ohie/csd/domain/Address.java' --- dhis-2/dhis-web/dhis-web-ohie/src/main/java/org/hisp/dhis/web/ohie/csd/domain/Address.java 2014-01-16 15:26:39 +0000 +++ dhis-2/dhis-web/dhis-web-ohie/src/main/java/org/hisp/dhis/web/ohie/csd/domain/Address.java 2014-01-21 07:35:08 +0000 @@ -30,6 +30,7 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import java.util.ArrayList; @@ -42,7 +43,7 @@ @XmlRootElement( name = "address", namespace = "urn:ihe:iti:csd:2013" ) public class Address { - @XmlElement( name = "type", namespace = "urn:ihe:iti:csd:2013" ) + @XmlAttribute( name = "type" ) private String type; @XmlElement( name = "addressLine", namespace = "urn:ihe:iti:csd:2013" ) @@ -52,6 +53,11 @@ { } + public Address( String type ) + { + this.type = type; + } + public String getType() { return type; === modified file 'dhis-2/dhis-web/dhis-web-ohie/src/main/java/org/hisp/dhis/web/ohie/csd/webapi/CsdController.java' --- dhis-2/dhis-web/dhis-web-ohie/src/main/java/org/hisp/dhis/web/ohie/csd/webapi/CsdController.java 2014-01-17 07:59:42 +0000 +++ dhis-2/dhis-web/dhis-web-ohie/src/main/java/org/hisp/dhis/web/ohie/csd/webapi/CsdController.java 2014-01-21 07:35:08 +0000 @@ -28,6 +28,9 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import org.hisp.dhis.attribute.AttributeValue; import org.hisp.dhis.dataset.DataSet; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitGroup; @@ -36,6 +39,8 @@ import org.hisp.dhis.web.ohie.common.domain.soap.Fault; import org.hisp.dhis.web.ohie.common.domain.wsa.RelatesTo; import org.hisp.dhis.web.ohie.common.exception.SoapException; +import org.hisp.dhis.web.ohie.csd.domain.Address; +import org.hisp.dhis.web.ohie.csd.domain.AddressLine; import org.hisp.dhis.web.ohie.csd.domain.CodedType; import org.hisp.dhis.web.ohie.csd.domain.CommonName; import org.hisp.dhis.web.ohie.csd.domain.Contact; @@ -70,6 +75,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.Map; /** * @author Morten Olav Hansen @@ -304,6 +310,40 @@ facility.setRecord( record ); + Map> addressLines = Maps.newHashMap(); + + for ( AttributeValue attributeValue : organisationUnit.getAttributeValues() ) + { + if ( attributeValue.getAttribute().getName().startsWith( "Address_" ) ) + { + String[] attributeSplit = attributeValue.getAttribute().getName().split( "_" ); + + if ( attributeSplit.length > 3 ) + { + continue; + } + + if ( addressLines.get( attributeSplit[1] ) == null ) + { + addressLines.put( attributeSplit[1], Lists.newArrayList() ); + } + + AddressLine addressLine = new AddressLine(); + addressLine.setComponent( attributeSplit[2] ); + addressLine.setValue( attributeValue.getValue() ); + + addressLines.get( attributeSplit[1] ).add( addressLine ); + } + } + + for ( String key : addressLines.keySet() ) + { + Address address = new Address( key ); + address.setAddressLines( addressLines.get( key ) ); + + facility.getAddresses().add( address ); + } + csd.getFacilityDirectory().getFacilities().add( facility ); }