← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19508: add back OU.program <=> Program.OU association

 

------------------------------------------------------------
revno: 19508
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-06-24 13:17:15 +0700
message:
  add back OU.program <=> Program.OU association
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/organisationunit/hibernate/OrganisationUnit.hbm.xml


--
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-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java	2015-06-13 11:43:28 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java	2015-06-24 06:17:15 +0000
@@ -49,6 +49,7 @@
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.period.PeriodType;
+import org.hisp.dhis.program.Program;
 import org.hisp.dhis.schema.PropertyType;
 import org.hisp.dhis.schema.annotation.Property;
 import org.hisp.dhis.schema.annotation.PropertyRange;
@@ -130,6 +131,8 @@
 
     private Set<DataSet> dataSets = new HashSet<>();
 
+    private Set<Program> programs = new HashSet<>();
+
     private Set<User> users = new HashSet<>();
 
     /**
@@ -544,14 +547,14 @@
     public String getAncestorNames()
     {
         List<OrganisationUnit> units = getAncestors();
-        
+
         StringBuilder builder = new StringBuilder();
 
         for ( OrganisationUnit unit : units )
         {
             builder.append( unit.getName() ).append( NAME_SEPARATOR );
         }
-        
+
         return builder.toString();
     }
 
@@ -1025,6 +1028,21 @@
     @JsonProperty
     @JsonSerialize( contentAs = BaseIdentifiableObject.class )
     @JsonView( { DetailedView.class } )
+    @JacksonXmlElementWrapper( localName = "programs", namespace = DxfNamespaces.DXF_2_0 )
+    @JacksonXmlProperty( localName = "program", namespace = DxfNamespaces.DXF_2_0 )
+    public Set<Program> getPrograms()
+    {
+        return programs;
+    }
+
+    public void setPrograms( Set<Program> programs )
+    {
+        this.programs = programs;
+    }
+
+    @JsonProperty
+    @JsonSerialize( contentAs = BaseIdentifiableObject.class )
+    @JsonView( { DetailedView.class } )
     @JacksonXmlElementWrapper( localName = "users", namespace = DxfNamespaces.DXF_2_0 )
     @JacksonXmlProperty( localName = "userItem", namespace = DxfNamespaces.DXF_2_0 )
     public Set<User> getUsers()
@@ -1136,6 +1154,7 @@
             groups.clear();
             users.clear();
             dataSets.clear();
+            programs.clear();
 
             attributeValues.clear();
             attributeValues.addAll( organisationUnit.getAttributeValues() );

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/organisationunit/hibernate/OrganisationUnit.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/organisationunit/hibernate/OrganisationUnit.hbm.xml	2015-05-26 03:06:44 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/organisationunit/hibernate/OrganisationUnit.hbm.xml	2015-06-24 06:17:15 +0000
@@ -1,9 +1,9 @@
 <?xml version="1.0"?>
 <!DOCTYPE hibernate-mapping PUBLIC
-    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-    "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd";
-    [<!ENTITY identifiableProperties SYSTEM "classpath://org/hisp/dhis/common/identifiableProperties.hbm">]
-    >
+  "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+  "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd";
+  [<!ENTITY identifiableProperties SYSTEM "classpath://org/hisp/dhis/common/identifiableProperties.hbm">]
+  >
 
 <hibernate-mapping>
   <class name="org.hisp.dhis.organisationunit.OrganisationUnit" table="organisationunit">
@@ -26,9 +26,9 @@
     </set>
 
     <many-to-one name="parent" class="org.hisp.dhis.organisationunit.OrganisationUnit" column="parentid"
-        foreign-key="fk_parentid" index="in_parentid" />
+      foreign-key="fk_parentid" index="in_parentid" />
 
-    <property name="uuid" unique="true" length="36"/>
+    <property name="uuid" unique="true" length="36" />
 
     <property name="description" type="text" />
 
@@ -50,6 +50,12 @@
       <many-to-many class="org.hisp.dhis.dataset.DataSet" column="datasetid" />
     </set>
 
+    <set name="programs" table="program_organisationunits" inverse="true">
+      <cache usage="read-write" />
+      <key column="organisationunitid" />
+      <many-to-many class="org.hisp.dhis.program.Program" column="programid" />
+    </set>
+
     <set name="groups" table="orgunitgroupmembers" inverse="true">
       <cache usage="read-write" />
       <key column="organisationunitid" />