=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/AbstractPersonService.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/AbstractPersonService.java 2013-09-13 08:27:37 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/AbstractPersonService.java 2013-09-13 09:21:02 +0000 @@ -31,11 +31,14 @@ import org.hisp.dhis.common.IdentifiableObjectManager; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.patient.Patient; +import org.hisp.dhis.patient.PatientAttribute; import org.hisp.dhis.patient.PatientIdentifier; import org.hisp.dhis.patient.PatientIdentifierService; import org.hisp.dhis.patient.PatientIdentifierType; import org.hisp.dhis.patient.PatientService; import org.hisp.dhis.patient.util.PatientIdentifierGenerator; +import org.hisp.dhis.patientattributevalue.PatientAttributeValue; +import org.hisp.dhis.patientattributevalue.PatientAttributeValueService; import org.hisp.dhis.program.Program; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; @@ -66,6 +69,9 @@ private PatientIdentifierService patientIdentifierService; @Autowired + private PatientAttributeValueService patientAttributeValueService; + + @Autowired private IdentifiableObjectManager manager; // ------------------------------------------------------------------------- @@ -202,6 +208,17 @@ person.getIdentifiers().add( identifier ); } + for ( PatientAttribute patientAttribute : patient.getAttributes() ) + { + PatientAttributeValue patientAttributeValue = patientAttributeValueService.getPatientAttributeValue( patient, patientAttribute ); + + Attribute attribute = new Attribute(); + attribute.setType( patientAttribute.getUid() ); + attribute.setValue( patientAttributeValue.getValue() ); + + person.getAttributes().add( attribute ); + } + return person; } === added file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/Attribute.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/Attribute.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/Attribute.java 2013-09-13 09:21:02 +0000 @@ -0,0 +1,114 @@ +package org.hisp.dhis.dxf2.event.person; + +/* + * Copyright (c) 2004-2013, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import org.hisp.dhis.common.DxfNamespaces; + +/** + * @author Morten Olav Hansen + */ +@JacksonXmlRootElement( localName = "attribute", namespace = DxfNamespaces.DXF_2_0 ) +public class Attribute +{ + private String type; + + private String value; + + public Attribute() + { + } + + public Attribute( String value ) + { + this.value = value; + } + + public Attribute( String type, String value ) + { + this.type = type; + this.value = value; + } + + @JsonProperty + @JacksonXmlProperty( isAttribute = true ) + public String getType() + { + return type; + } + + public void setType( String type ) + { + this.type = type; + } + + @JsonProperty + @JacksonXmlProperty( isAttribute = true ) + public String getValue() + { + return value; + } + + public void setValue( String value ) + { + this.value = value; + } + + @Override + public boolean equals( Object o ) + { + if ( this == o ) return true; + if ( o == null || getClass() != o.getClass() ) return false; + + Attribute attribute = (Attribute) o; + + if ( type != null ? !type.equals( attribute.type ) : attribute.type != null ) return false; + if ( value != null ? !value.equals( attribute.value ) : attribute.value != null ) return false; + + return true; + } + + @Override + public int hashCode() + { + int result = type != null ? type.hashCode() : 0; + result = 31 * result + (value != null ? value.hashCode() : 0); + return result; + } + + @Override public String toString() + { + return "Attribute{" + + "type='" + type + '\'' + + ", value='" + value + '\'' + + '}'; + } +} === modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/Person.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/Person.java 2013-09-12 13:21:17 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/Person.java 2013-09-13 09:21:02 +0000 @@ -63,6 +63,8 @@ private List identifiers = new ArrayList(); + private List attributes = new ArrayList(); + public Person() { } @@ -187,6 +189,18 @@ this.identifiers = identifiers; } + @JsonProperty + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) + public List getAttributes() + { + return attributes; + } + + public void setAttributes( List attributes ) + { + this.attributes = attributes; + } + @Override public boolean equals( Object o ) {