← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14073: Added association OrganisationUnit.dataViewOrganisationUnits. Step 1 in defining data access in a...

 

------------------------------------------------------------
revno: 14073
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-02-19 10:12:17 +0100
message:
  Added association OrganisationUnit.dataViewOrganisationUnits. Step 1 in defining data access in analysis modules.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/user/hibernate/User.hbm.xml
  dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/ehcache.xml
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/organisationunit/OrganisationUnitController.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-api/src/main/java/org/hisp/dhis/user/User.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java	2014-02-03 14:40:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java	2014-02-19 09:12:17 +0000
@@ -108,6 +108,9 @@
      */
     @Scanned
     private Set<OrganisationUnit> organisationUnits = new HashSet<OrganisationUnit>();
+    
+    @Scanned
+    private Set<OrganisationUnit> dataViewOrganisationUnits = new HashSet<OrganisationUnit>();
 
     /**
      * Set of the dynamic attributes values that belong to this User.
@@ -439,6 +442,21 @@
         this.organisationUnits = organisationUnits;
     }
 
+    @JsonProperty
+    @JsonSerialize( contentAs = BaseIdentifiableObject.class )
+    @JsonView( { DetailedView.class, ExportView.class } )
+    @JacksonXmlElementWrapper( localName = "dataViewOrganisationUnits", namespace = DxfNamespaces.DXF_2_0 )
+    @JacksonXmlProperty( localName = "organisationUnit", namespace = DxfNamespaces.DXF_2_0 )
+    public Set<OrganisationUnit> getDataViewOrganisationUnits()
+    {
+        return dataViewOrganisationUnits;
+    }
+
+    public void setDataViewOrganisationUnits( Set<OrganisationUnit> dataViewOrganisationUnits )
+    {
+        this.dataViewOrganisationUnits = dataViewOrganisationUnits;
+    }
+
     @JsonProperty( value = "attributeValues" )
     @JsonView( { DetailedView.class, ExportView.class } )
     @JacksonXmlElementWrapper( localName = "attributeValues", namespace = DxfNamespaces.DXF_2_0)

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/user/hibernate/User.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/user/hibernate/User.hbm.xml	2012-12-13 11:53:32 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/user/hibernate/User.hbm.xml	2014-02-19 09:12:17 +0000
@@ -63,6 +63,13 @@
         foreign-key="fk_userinfo_organisationunitid" />
     </set>
 
+    <set name="dataViewOrganisationUnits" table="userdatavieworgunits">
+      <cache usage="read-write" />
+      <key column="userinfoid" foreign-key="fk_userdatavieworgunits_userinfoid" />
+      <many-to-many class="org.hisp.dhis.organisationunit.OrganisationUnit" column="organisationunitid"
+        foreign-key="fk_userdatavieworgunits_organisationunitid" />
+    </set>
+
     <!-- Dynamic attribute values -->
 
     <set name="attributeValues" table="userattributevalues">

=== modified file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/ehcache.xml'
--- dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/ehcache.xml	2014-01-19 05:53:05 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/ehcache.xml	2014-02-19 09:12:17 +0000
@@ -299,6 +299,8 @@
   <cache name="org.hisp.dhis.interpretation.Interpretation.userGroupAccesses" maxElementsInMemory="200" />
 
   <cache name="org.hisp.dhis.user.User.organisationUnits" maxElementsInMemory="20000" />
+  
+  <cache name="org.hisp.dhis.user.User.dataViewOrganisationUnits" maxElementsInMemory="20000" />
 
   <cache name="org.hisp.dhis.user.User.attributeValues" maxElementsInMemory="1000" />
 

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/organisationunit/OrganisationUnitController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/organisationunit/OrganisationUnitController.java	2013-12-09 18:33:36 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/organisationunit/OrganisationUnitController.java	2014-02-19 09:12:17 +0000
@@ -116,6 +116,10 @@
         {
             entityList = new ArrayList<OrganisationUnit>( currentUserService.getCurrentUser().getOrganisationUnits() );
         }
+        if ( "true".equals( options.getOptions().get( "userDataViewOnly" ) ) )
+        {
+            entityList = new ArrayList<OrganisationUnit>( currentUserService.getCurrentUser().getDataViewOrganisationUnits() );
+        }
         else if ( lastUpdated != null )
         {
             entityList = new ArrayList<OrganisationUnit>( manager.getByLastUpdatedSorted( getEntityClass(), lastUpdated ) );