← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13875: exposing attribute code through the web api

 

------------------------------------------------------------
revno: 13875
committer: Abyot Asalefew Gizaw abyota@xxxxxxxxx
branch nick: dhis2
timestamp: Tue 2014-01-28 11:01:16 +0100
message:
  exposing attribute code through the web api
modified:
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/Enrollment.java
  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/Attribute.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/enrollment/Enrollment.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/Enrollment.java	2014-01-02 13:13:21 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/Enrollment.java	2014-01-28 10:01:16 +0000
@@ -38,7 +38,7 @@
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
  */
-@JacksonXmlRootElement(localName = "enrollment", namespace = DxfNamespaces.DXF_2_0)
+@JacksonXmlRootElement( localName = "enrollment", namespace = DxfNamespaces.DXF_2_0 )
 public class Enrollment
 {
     private String enrollment;
@@ -57,8 +57,8 @@
     {
     }
 
-    @JsonProperty(required = true)
-    @JacksonXmlProperty(isAttribute = true)
+    @JsonProperty( required = true )
+    @JacksonXmlProperty( isAttribute = true )
     public String getPerson()
     {
         return person;
@@ -69,8 +69,8 @@
         this.person = person;
     }
 
-    @JsonProperty(required = true)
-    @JacksonXmlProperty(isAttribute = true)
+    @JsonProperty( required = true )
+    @JacksonXmlProperty( isAttribute = true )
     public String getEnrollment()
     {
         return enrollment;
@@ -81,8 +81,8 @@
         this.enrollment = enrollment;
     }
 
-    @JsonProperty(required = true)
-    @JacksonXmlProperty(isAttribute = true)
+    @JsonProperty( required = true )
+    @JacksonXmlProperty( isAttribute = true )
     public String getProgram()
     {
         return program;
@@ -93,8 +93,8 @@
         this.program = program;
     }
 
-    @JsonProperty(required = true)
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JsonProperty( required = true )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public EnrollmentStatus getStatus()
     {
         return status;
@@ -105,8 +105,8 @@
         this.status = status;
     }
 
-    @JsonProperty(required = true)
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JsonProperty( required = true )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public Date getDateOfEnrollment()
     {
         return dateOfEnrollment;
@@ -117,8 +117,8 @@
         this.dateOfEnrollment = dateOfEnrollment;
     }
 
-    @JsonProperty(required = true)
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JsonProperty( required = true )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public Date getDateOfIncident()
     {
         return dateOfIncident;
@@ -132,17 +132,26 @@
     @Override
     public boolean equals( Object o )
     {
-        if ( this == o ) return true;
-        if ( o == null || getClass() != o.getClass() ) return false;
+        if ( this == o )
+            return true;
+        if ( o == null || getClass() != o.getClass() )
+            return false;
 
         Enrollment that = (Enrollment) o;
 
-        if ( dateOfEnrollment != null ? !dateOfEnrollment.equals( that.dateOfEnrollment ) : that.dateOfEnrollment != null ) return false;
-        if ( dateOfIncident != null ? !dateOfIncident.equals( that.dateOfIncident ) : that.dateOfIncident != null ) return false;
-        if ( enrollment != null ? !enrollment.equals( that.enrollment ) : that.enrollment != null ) return false;
-        if ( person != null ? !person.equals( that.person ) : that.person != null ) return false;
-        if ( program != null ? !program.equals( that.program ) : that.program != null ) return false;
-        if ( status != that.status ) return false;
+        if ( dateOfEnrollment != null ? !dateOfEnrollment.equals( that.dateOfEnrollment )
+            : that.dateOfEnrollment != null )
+            return false;
+        if ( dateOfIncident != null ? !dateOfIncident.equals( that.dateOfIncident ) : that.dateOfIncident != null )
+            return false;
+        if ( enrollment != null ? !enrollment.equals( that.enrollment ) : that.enrollment != null )
+            return false;
+        if ( person != null ? !person.equals( that.person ) : that.person != null )
+            return false;
+        if ( program != null ? !program.equals( that.program ) : that.program != null )
+            return false;
+        if ( status != that.status )
+            return false;
 
         return true;
     }
@@ -162,13 +171,8 @@
     @Override
     public String toString()
     {
-        return "Enrollment{" +
-            "enrollment='" + enrollment + '\'' +
-            ", person='" + person + '\'' +
-            ", program='" + program + '\'' +
-            ", status=" + status +
-            ", dateOfEnrollment=" + dateOfEnrollment +
-            ", dateOfIncident=" + dateOfIncident +
-            '}';
+        return "Enrollment{" + "enrollment='" + enrollment + '\'' + ", person='" + person + '\'' + ", program='"
+            + program + '\'' + ", status=" + status + ", dateOfEnrollment=" + dateOfEnrollment + ", dateOfIncident="
+            + dateOfIncident + '}';
     }
 }

=== 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	2014-01-23 14:18:27 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/AbstractPersonService.java	2014-01-28 10:01:16 +0000
@@ -157,6 +157,7 @@
             attribute.setDisplayName( patientAttributeValue.getPatientAttribute().getDisplayName() );
             attribute.setAttribute( patientAttributeValue.getPatientAttribute().getUid() );
             attribute.setType( patientAttributeValue.getPatientAttribute().getValueType() );
+            attribute.setCode( patientAttributeValue.getPatientAttribute().getCode() );
             attribute.setValue( patientAttributeValue.getValue() );
 
             person.getAttributes().add( attribute );

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/Attribute.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/Attribute.java	2013-12-23 10:25:53 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/Attribute.java	2014-01-28 10:01:16 +0000
@@ -45,6 +45,8 @@
 
     private String type;
 
+    private String code;
+
     private String value;
 
     public Attribute()
@@ -101,6 +103,18 @@
 
     @JsonProperty
     @JacksonXmlProperty( isAttribute = true )
+    public String getCode()
+    {
+        return code;
+    }
+
+    public void setCode( String code )
+    {
+        this.code = code;
+    }
+
+    @JsonProperty
+    @JacksonXmlProperty( isAttribute = true )
     public String getValue()
     {
         return value;
@@ -114,15 +128,23 @@
     @Override
     public boolean equals( Object o )
     {
-        if ( this == o ) return true;
-        if ( o == null || getClass() != o.getClass() ) return false;
+        if ( this == o )
+            return true;
+        if ( o == null || getClass() != o.getClass() )
+            return false;
 
         Attribute attribute1 = (Attribute) o;
 
-        if ( attribute != null ? !attribute.equals( attribute1.attribute ) : attribute1.attribute != null ) return false;
-        if ( displayName != null ? !displayName.equals( attribute1.displayName ) : attribute1.displayName != null ) return false;
-        if ( type != null ? !type.equals( attribute1.type ) : attribute1.type != null ) return false;
-        if ( value != null ? !value.equals( attribute1.value ) : attribute1.value != null ) return false;
+        if ( attribute != null ? !attribute.equals( attribute1.attribute ) : attribute1.attribute != null )
+            return false;
+        if ( displayName != null ? !displayName.equals( attribute1.displayName ) : attribute1.displayName != null )
+            return false;
+        if ( type != null ? !type.equals( attribute1.type ) : attribute1.type != null )
+            return false;
+        if ( code != null ? !code.equals( attribute1.code ) : attribute1.code != null )
+            return false;
+        if ( value != null ? !value.equals( attribute1.value ) : attribute1.value != null )
+            return false;
 
         return true;
     }
@@ -133,6 +155,7 @@
         int result = displayName != null ? displayName.hashCode() : 0;
         result = 31 * result + (attribute != null ? attribute.hashCode() : 0);
         result = 31 * result + (type != null ? type.hashCode() : 0);
+        result = 31 * result + (code != null ? code.hashCode() : 0);
         result = 31 * result + (value != null ? value.hashCode() : 0);
         return result;
     }
@@ -140,11 +163,7 @@
     @Override
     public String toString()
     {
-        return "Attribute{" +
-            "displayName='" + displayName + '\'' +
-            ", attribute='" + attribute + '\'' +
-            ", type='" + type + '\'' +
-            ", value='" + value + '\'' +
-            '}';
+        return "Attribute{" + "displayName='" + displayName + '\'' + ", attribute='" + attribute + '\'' + ", type='"
+            + type + '\'' + ", code='" + code + '\'' + ", value='" + value + '\'' + '}';
     }
-}
+}
\ No newline at end of file