dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #24712
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12160: expose Relationships in Person (only read)
------------------------------------------------------------
revno: 12160
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-09-19 10:51:41 +0200
message:
expose Relationships in Person (only read)
modified:
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/AbstractPersonService.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/Person.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/Relationship.java
--
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-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/AbstractPersonService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/AbstractPersonService.java 2013-09-19 07:57:50 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/AbstractPersonService.java 2013-09-19 08:51:41 +0000
@@ -43,6 +43,8 @@
import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
import org.hisp.dhis.patientattributevalue.PatientAttributeValueService;
import org.hisp.dhis.program.Program;
+import org.hisp.dhis.relationship.Relationship;
+import org.hisp.dhis.relationship.RelationshipService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
@@ -79,6 +81,9 @@
private PatientAttributeValueService patientAttributeValueService;
@Autowired
+ private RelationshipService relationshipService;
+
+ @Autowired
private IdentifiableObjectManager manager;
// -------------------------------------------------------------------------
@@ -212,6 +217,17 @@
person.setDateOfRegistration( patient.getRegistrationDate() );
+ Collection<Relationship> relationshipsForPatient = relationshipService.getRelationshipsForPatient( patient );
+
+ for ( Relationship relationshipPatient : relationshipsForPatient )
+ {
+ org.hisp.dhis.dxf2.events.person.Relationship relationship = new org.hisp.dhis.dxf2.events.person.Relationship();
+ relationship.setPerson( relationshipPatient.getPatientA().getUid() );
+ relationship.setType( relationshipPatient.getRelationshipType().getUid() );
+
+ person.getRelationships().add( relationship );
+ }
+
for ( PatientIdentifier patientIdentifier : patient.getIdentifiers() )
{
String identifierType = patientIdentifier.getIdentifierType() == null ? null : patientIdentifier.getIdentifierType().getUid();
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/Person.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/Person.java 2013-09-17 12:15:39 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/Person.java 2013-09-19 08:51:41 +0000
@@ -40,7 +40,7 @@
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
-@JacksonXmlRootElement(localName = "person", namespace = DxfNamespaces.DXF_2_0)
+@JacksonXmlRootElement( localName = "person", namespace = DxfNamespaces.DXF_2_0 )
public class Person
{
private String person;
@@ -61,6 +61,8 @@
private Contact contact;
+ private List<Relationship> relationships = new ArrayList<Relationship>();
+
private List<Identifier> identifiers = new ArrayList<Identifier>();
private List<Attribute> attributes = new ArrayList<Attribute>();
@@ -179,6 +181,18 @@
@JsonProperty
@JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ public List<Relationship> getRelationships()
+ {
+ return relationships;
+ }
+
+ public void setRelationships( List<Relationship> relationships )
+ {
+ this.relationships = relationships;
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
public List<Identifier> getIdentifiers()
{
return identifiers;
@@ -221,6 +235,7 @@
if ( name != null ? !name.equals( person1.name ) : person1.name != null ) return false;
if ( orgUnit != null ? !orgUnit.equals( person1.orgUnit ) : person1.orgUnit != null ) return false;
if ( person != null ? !person.equals( person1.person ) : person1.person != null ) return false;
+ if ( relationships != null ? !relationships.equals( person1.relationships ) : person1.relationships != null ) return false;
return true;
}
@@ -237,6 +252,7 @@
result = 31 * result + (dateOfDeath != null ? dateOfDeath.hashCode() : 0);
result = 31 * result + (dateOfRegistration != null ? dateOfRegistration.hashCode() : 0);
result = 31 * result + (contact != null ? contact.hashCode() : 0);
+ result = 31 * result + (relationships != null ? relationships.hashCode() : 0);
result = 31 * result + (identifiers != null ? identifiers.hashCode() : 0);
result = 31 * result + (attributes != null ? attributes.hashCode() : 0);
return result;
@@ -254,6 +270,7 @@
", dateOfDeath=" + dateOfDeath +
", dateOfRegistration=" + dateOfRegistration +
", contact=" + contact +
+ ", relationships=" + relationships +
", identifiers=" + identifiers +
", attributes=" + attributes +
'}';
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/Relationship.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/Relationship.java 2013-09-19 08:38:29 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/Relationship.java 2013-09-19 08:51:41 +0000
@@ -39,9 +39,7 @@
@JacksonXmlRootElement( localName = "relationship", namespace = DxfNamespaces.DXF_2_0 )
public class Relationship
{
- private String personA;
-
- private String personB;
+ private String person;
private String type;
@@ -51,26 +49,14 @@
@JsonProperty
@JacksonXmlProperty( isAttribute = true )
- public String getPersonA()
- {
- return personA;
- }
-
- public void setPersonA( String personA )
- {
- this.personA = personA;
- }
-
- @JsonProperty
- @JacksonXmlProperty( isAttribute = true )
- public String getPersonB()
- {
- return personB;
- }
-
- public void setPersonB( String personB )
- {
- this.personB = personB;
+ public String getPerson()
+ {
+ return person;
+ }
+
+ public void setPerson( String person )
+ {
+ this.person = person;
}
@JsonProperty
@@ -84,4 +70,34 @@
{
this.type = type;
}
+
+ @Override
+ public boolean equals( Object o )
+ {
+ if ( this == o ) return true;
+ if ( o == null || getClass() != o.getClass() ) return false;
+
+ Relationship that = (Relationship) o;
+
+ if ( person != null ? !person.equals( that.person ) : that.person != null ) return false;
+ if ( type != null ? !type.equals( that.type ) : that.type != null ) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = person != null ? person.hashCode() : 0;
+ result = 31 * result + (type != null ? type.hashCode() : 0);
+ return result;
+ }
+
+ @Override public String toString()
+ {
+ return "Relationship{" +
+ "person='" + person + '\'' +
+ ", type='" + type + '\'' +
+ '}';
+ }
}