← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13725: csd: if orgUnit.contactPerson exists, add as contact.person.commonName in facility

 

------------------------------------------------------------
revno: 13725
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-01-14 19:58:25 +0700
message:
  csd: if orgUnit.contactPerson exists, add as contact.person.commonName in facility
modified:
  dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/domain/csd/CommonName.java
  dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/domain/csd/Name.java
  dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/domain/csd/Person.java
  dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/webapi/CsdController.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-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/domain/csd/CommonName.java'
--- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/domain/csd/CommonName.java	2014-01-14 08:36:11 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/domain/csd/CommonName.java	2014-01-14 12:58:25 +0000
@@ -45,12 +45,17 @@
     private String language;
 
     @XmlValue
-    private String body;
+    private String value;
 
     public CommonName()
     {
     }
 
+    public CommonName( String value )
+    {
+        this.value = value;
+    }
+
     public String getLanguage()
     {
         return language;
@@ -61,13 +66,13 @@
         this.language = language;
     }
 
-    public String getBody()
+    public String getValue()
     {
-        return body;
+        return value;
     }
 
-    public void setBody( String body )
+    public void setValue( String value )
     {
-        this.body = body;
+        this.value = value;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/domain/csd/Name.java'
--- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/domain/csd/Name.java	2014-01-14 08:36:11 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/domain/csd/Name.java	2014-01-14 12:58:25 +0000
@@ -43,7 +43,7 @@
 public class Name
 {
     @XmlElement( name = "commonName", namespace = "urn:ihe:iti:csd:2013", required = true )
-    private List<CommonName> commonNames;
+    private List<CommonName> commonNames = new ArrayList<CommonName>();
 
     @XmlElement( name = "honorific", namespace = "urn:ihe:iti:csd:2013" )
     private String honorific;

=== modified file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/domain/csd/Person.java'
--- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/domain/csd/Person.java	2014-01-14 08:36:11 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/domain/csd/Person.java	2014-01-14 12:58:25 +0000
@@ -54,4 +54,34 @@
     public Person()
     {
     }
+
+    public Name getName()
+    {
+        return name;
+    }
+
+    public void setName( Name name )
+    {
+        this.name = name;
+    }
+
+    public List<Address> getAddresses()
+    {
+        return addresses;
+    }
+
+    public void setAddresses( List<Address> addresses )
+    {
+        this.addresses = addresses;
+    }
+
+    public String getGender()
+    {
+        return gender;
+    }
+
+    public void setGender( String gender )
+    {
+        this.gender = gender;
+    }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/webapi/CsdController.java'
--- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/webapi/CsdController.java	2014-01-14 12:35:08 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/webapi/CsdController.java	2014-01-14 12:58:25 +0000
@@ -33,11 +33,15 @@
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.web.csd.domain.Envelope;
 import org.hisp.dhis.web.csd.domain.csd.CodedType;
+import org.hisp.dhis.web.csd.domain.csd.CommonName;
+import org.hisp.dhis.web.csd.domain.csd.Contact;
 import org.hisp.dhis.web.csd.domain.csd.Csd;
 import org.hisp.dhis.web.csd.domain.csd.Facility;
 import org.hisp.dhis.web.csd.domain.csd.Geocode;
+import org.hisp.dhis.web.csd.domain.csd.Name;
 import org.hisp.dhis.web.csd.domain.csd.Organization;
 import org.hisp.dhis.web.csd.domain.csd.OtherID;
+import org.hisp.dhis.web.csd.domain.csd.Person;
 import org.hisp.dhis.web.csd.domain.csd.Record;
 import org.hisp.dhis.web.fred.webapi.v1.utils.GeoUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -101,6 +105,20 @@
 
             facility.setPrimaryName( organisationUnit.getDisplayName() );
 
+            if ( organisationUnit.getContactPerson() != null )
+            {
+                Contact contact = new Contact();
+                Person person = new Person();
+                Name name = new Name();
+
+                contact.setPerson( person );
+                person.setName( name );
+
+                name.getCommonNames().add( new CommonName( organisationUnit.getContactPerson() ) );
+
+                facility.getContacts().add( contact );
+            }
+
             for ( OrganisationUnitGroup organisationUnitGroup : organisationUnit.getGroups() )
             {
                 if ( organisationUnitGroup.getCode() == null )