← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9546: sharing for report, reportTable, wip

 

------------------------------------------------------------
revno: 9546
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-01-17 16:31:26 +0100
message:
  sharing for report, reportTable, wip
modified:
  dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/report/hibernate/Report.hbm.xml
  dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml
  dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SharingController.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewReportForm.vm
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewTableForm.vm


--
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-reporting/src/main/resources/org/hisp/dhis/report/hibernate/Report.hbm.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/report/hibernate/Report.hbm.xml	2013-01-16 10:31:12 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/report/hibernate/Report.hbm.xml	2013-01-17 15:31:26 +0000
@@ -42,4 +42,4 @@
     </set>
 
   </class>
-</hibernate-mapping>
\ No newline at end of file
+</hibernate-mapping>

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml	2012-11-07 13:38:42 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml	2013-01-17 15:31:26 +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.reporttable.ReportTable" table="reporttable">
@@ -24,7 +24,7 @@
       <key column="reporttableid" foreign-key="fk_reporttable_dataelements_reporttableid" />
       <list-index column="sort_order" base="0" />
       <many-to-many column="dataelementid" class="org.hisp.dhis.dataelement.DataElement"
-          foreign-key="fk_reporttable_dataelements_dataelementid" />
+        foreign-key="fk_reporttable_dataelements_dataelementid" />
     </list>
 
     <list name="indicators" table="reporttable_indicators">
@@ -32,7 +32,7 @@
       <key column="reporttableid" foreign-key="fk_reporttable_indicators_reporttableid" />
       <list-index column="sort_order" base="0" />
       <many-to-many column="indicatorid" class="org.hisp.dhis.indicator.Indicator"
-          foreign-key="fk_reporttable_indicators_indicatorid" />
+        foreign-key="fk_reporttable_indicators_indicatorid" />
     </list>
 
     <list name="dataSets" table="reporttable_datasets">
@@ -40,19 +40,19 @@
       <key column="reporttableid" foreign-key="fk_reporttable_datasets_reporttableid" />
       <list-index column="sort_order" base="0" />
       <many-to-many column="datasetid" class="org.hisp.dhis.dataset.DataSet"
-          foreign-key="fk_reporttable_datasets_datasetid" />
+        foreign-key="fk_reporttable_datasets_datasetid" />
     </list>
 
     <many-to-one name="categoryCombo" class="org.hisp.dhis.dataelement.DataElementCategoryCombo"
-        column="categorycomboid"
-        foreign-key="fk_reporttable_categorycombo" />
+      column="categorycomboid"
+      foreign-key="fk_reporttable_categorycombo" />
 
     <list name="periods" table="reporttable_periods">
       <cache usage="read-write" />
       <key column="reporttableid" foreign-key="fk_reporttable_periods_reporttableid" />
       <list-index column="sort_order" base="0" />
       <many-to-many column="periodid" class="org.hisp.dhis.period.Period"
-          foreign-key="fk_reporttable_periods_periodid" />
+        foreign-key="fk_reporttable_periods_periodid" />
     </list>
 
     <list name="units" table="reporttable_organisationunits">
@@ -60,7 +60,7 @@
       <key column="reporttableid" foreign-key="fk_reporttable_organisationunits_reporttableid" />
       <list-index column="sort_order" base="0" />
       <many-to-many column="organisationunitid" class="org.hisp.dhis.organisationunit.OrganisationUnit"
-          foreign-key="fk_reporttable_organisationunits_organisationunitid" />
+        foreign-key="fk_reporttable_organisationunits_organisationunitid" />
     </list>
 
     <list name="organisationUnitGroups" table="reporttable_orgunitgroups">
@@ -68,7 +68,7 @@
       <key column="reporttableid" foreign-key="fk_reporttable_orgunitunitgroups_reporttableid" />
       <list-index column="sort_order" base="0" />
       <many-to-many column="orgunitgroupid" class="org.hisp.dhis.organisationunit.OrganisationUnitGroup"
-          foreign-key="fk_reporttable_orgunitgroups_orgunitgroupid" />
+        foreign-key="fk_reporttable_orgunitgroups_orgunitgroupid" />
     </list>
 
     <property name="doIndicators" />
@@ -109,5 +109,16 @@
 
     <property name="topLimit" />
 
+    <!-- Access properties -->
+    <many-to-one name="user" class="org.hisp.dhis.user.User" column="userid" foreign-key="fk_reporttable_userid" />
+
+    <property name="publicAccess" length="8" />
+
+    <set name="userGroupAccesses" table="reporttableusergroupaccesses">
+      <cache usage="read-write" />
+      <key column="reportid" />
+      <many-to-many class="org.hisp.dhis.user.UserGroupAccess" column="usergroupaccessid" unique="true" />
+    </set>
+
   </class>
 </hibernate-mapping>

=== modified file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java'
--- dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java	2013-01-16 13:25:48 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java	2013-01-17 15:31:26 +0000
@@ -349,7 +349,7 @@
     private Query getQueryAllACL()
     {
         String hql = "select distinct c from " + clazz.getName() + " c"
-            + " where c.publicAccess like 'r%' or c.user=:user"
+            + " where c.publicAccess like 'r%' or c.user IS NULL or c.user=:user"
             + " or exists "
             + "     (from c.userGroupAccesses uga join uga.userGroup ug join ug.members ugm where ugm = :user and uga.access like 'r%')";
 
@@ -376,7 +376,7 @@
     private Query getQueryAllLikeNameACL( String name )
     {
         String hql = "select distinct c from " + clazz.getName() + " c"
-            + " where lower(name) like :name and ( c.publicAccess like 'r%' or c.user=:user"
+            + " where lower(name) like :name and ( c.publicAccess like 'r%' or c.user IS NULL or c.user=:user"
             + " or exists "
             + "     (from c.userGroupAccesses uga join uga.userGroup ug join ug.members ugm where ugm = :user and uga.access like 'r%')"
             + " ) order by c.name";
@@ -408,7 +408,7 @@
     private Query getQueryAllOrderedNameACL()
     {
         String hql = "select distinct c from " + clazz.getName() + " c"
-            + " where c.publicAccess like 'r%' or c.user=:user"
+            + " where c.publicAccess like 'r%' or c.user IS NULL or c.user=:user"
             + " or exists "
             + "     (from c.userGroupAccesses uga join uga.userGroup ug join ug.members ugm where ugm = :user and uga.access like 'r%')"
             + " order by c.name";
@@ -451,7 +451,7 @@
     private Query getQueryAllOrderedLastUpdatedACL()
     {
         String hql = "select distinct c from " + clazz.getName() + " c"
-            + " where c.publicAccess like 'r%' or c.user=:user"
+            + " where c.publicAccess like 'r%' or c.user IS NULL or c.user=:user"
             + " or exists "
             + "     (from c.userGroupAccesses uga join uga.userGroup ug join ug.members ugm where ugm = :user and uga.access like 'r%')"
             + " order by c.lastUpdated desc";
@@ -482,7 +482,7 @@
     private Query getQueryAllLikeNameOrderedNameACL( String name )
     {
         String hql = "select distinct c from " + clazz.getName() + " c"
-            + " where lower(c.name) like :name and ( c.publicAccess like 'r%' or c.user=:user"
+            + " where lower(c.name) like :name and ( c.publicAccess like 'r%' or c.user IS NULL or c.user=:user"
             + " or exists "
             + "     (from c.userGroupAccesses uga join uga.userGroup ug join ug.members ugm where ugm = :user and uga.access like 'r%')"
             + " ) order by c.name";
@@ -513,7 +513,7 @@
     private Query getQueryCountACL()
     {
         String hql = "select count(distinct c) from " + clazz.getName() + " c"
-            + " where c.publicAccess like 'r%' or c.user=:user"
+            + " where c.publicAccess like 'r%' or c.user IS NULL or c.user=:user"
             + " or exists "
             + "     (from c.userGroupAccesses uga join uga.userGroup ug join ug.members ugm where ugm = :user and uga.access like 'r%')";
 
@@ -539,7 +539,7 @@
     private Query getQueryCountLikeNameACL( String name )
     {
         String hql = "select count(distinct c) from " + clazz.getName() + " c"
-            + " where lower(name) like :name and (c.publicAccess like 'r%' or c.user=:user"
+            + " where lower(name) like :name and (c.publicAccess like 'r%' or c.user IS NULL or c.user=:user"
             + " or exists "
             + "     (from c.userGroupAccesses uga join uga.userGroup ug join ug.members ugm where ugm = :user and uga.access like 'r%')"
             + " )";
@@ -570,7 +570,7 @@
     private Query getQueryCountGeLastUpdatedACL( Date lastUpdated )
     {
         String hql = "select count(distinct c) from " + clazz.getName() + " c"
-            + " where c.lastUpdated >= :lastUpdated and (c.publicAccess like 'r%' or c.user=:user"
+            + " where c.lastUpdated >= :lastUpdated and (c.publicAccess like 'r%' or c.user IS NULL or c.user=:user"
             + " or exists "
             + "     (from c.userGroupAccesses uga join uga.userGroup ug join ug.members ugm where ugm = :user and uga.access like 'r%')"
             + " )";
@@ -602,7 +602,7 @@
     private Query getQueryAllGeLastUpdatedACL( Date lastUpdated )
     {
         String hql = "select distinct c from " + clazz.getName() + " c"
-            + " where c.lastUpdated >= :lastUpdated and ( c.publicAccess like 'r%' or c.user=:user"
+            + " where c.lastUpdated >= :lastUpdated and ( c.publicAccess like 'r%' or c.user IS NULL or c.user=:user"
             + " or exists "
             + "     (from c.userGroupAccesses uga join uga.userGroup ug join ug.members ugm where ugm = :user and uga.access like 'r%')"
             + " )";
@@ -634,7 +634,7 @@
     private Query getQueryAllGeCreatedACL( Date created )
     {
         String hql = "select distinct c from " + clazz.getName() + " c"
-            + " where c.created >= :created and ( c.publicAccess like 'r%' or c.user=:user"
+            + " where c.created >= :created and ( c.publicAccess like 'r%' or c.user IS NULL or c.user=:user"
             + " or exists "
             + "     (from c.userGroupAccesses uga join uga.userGroup ug join ug.members ugm where ugm = :user and uga.access like 'r%')"
             + " ) order by c.name";
@@ -666,7 +666,7 @@
     private Query getQueryAllGeLastUpdatedOrderedNameACL( Date lastUpdated )
     {
         String hql = "select distinct c from " + clazz.getName() + " c"
-            + " where c.lastUpdated >= :lastUpdated and ( c.publicAccess like 'r%' or c.user=:user"
+            + " where c.lastUpdated >= :lastUpdated and ( c.publicAccess like 'r%' or c.user IS NULL or c.user=:user"
             + " or exists "
             + "     (from c.userGroupAccesses uga join uga.userGroup ug join ug.members ugm where ugm = :user and uga.access like 'r%')"
             + " ) order by c.name";

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SharingController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SharingController.java	2013-01-16 10:31:12 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SharingController.java	2013-01-17 15:31:26 +0000
@@ -37,6 +37,7 @@
 import org.hisp.dhis.document.Document;
 import org.hisp.dhis.dxf2.utils.JacksonUtils;
 import org.hisp.dhis.report.Report;
+import org.hisp.dhis.reporttable.ReportTable;
 import org.hisp.dhis.security.SecurityService;
 import org.hisp.dhis.user.CurrentUserService;
 import org.hisp.dhis.user.UserGroup;
@@ -72,6 +73,7 @@
     {
         TYPE_MAP.put( "document", Document.class );
         TYPE_MAP.put( "report", Report.class );
+        TYPE_MAP.put( "reportTable", ReportTable.class );
     }
 
     @Autowired

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewReportForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewReportForm.vm	2013-01-16 10:31:12 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewReportForm.vm	2013-01-17 15:31:26 +0000
@@ -59,7 +59,7 @@
 
 						<a href="javascript:addToDashboard( '$report.id' )" title="$i18n.getString( 'add_to_dashboard' )"><img src="../images/add_to_dashboard.png" alt="$i18n.getString( 'add_to_dashboard' )"></a>
 
-						#if( $auth.hasAccess( "dhis-web-reporting", "removeReport" ) )
+						#if( $auth.hasAccess( "dhis-web-reporting", "removeReport" ) && $security.canDelete( $report ))
 						<a href="javascript:removeReport( $report.id )" title="$i18n.getString( 'remove_report' )"><img src="../images/delete.png" alt="$i18n.getString( 'remove_report' )"></a>
 						#else <img src="../images/delete-denied.png"> #end
 						<a href="javascript:showReportDetails( $report.id )" title="$i18n.getString( 'show_details' )"><img src="../images/information.png" alt="$i18n.getString( 'show_details' )"/></a>

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewTableForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewTableForm.vm	2012-10-18 13:27:17 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewTableForm.vm	2013-01-17 15:31:26 +0000
@@ -1,3 +1,6 @@
+
+#sharingDialog()
+
 <script type="text/javascript">
 	jQuery(document).ready(function(){		
 		tableSorter( 'listTable' );	
@@ -26,7 +29,7 @@
 			</table>
 			<table class="listTable" id="listTable">
 				<col>
-				<col width="150">				
+				<col width="175">
                 <thead>		       
 				<tr>
 					<th>$i18n.getString( "name" )</th>
@@ -39,12 +42,26 @@
 					<td onclick="showTableDetails( $table.id )">$encoder.htmlEncode( $table.name )</td>
 					<td style="text-align:right">
 						<a href="getReportParams.action?uid=${table.uid}&mode=table" title="$i18n.getString( "create" )"><img src="../images/start_process.png" alt="$i18n.getString( "create" )"></a>
-						<a href="displayAddTableForm.action?id=${table.id}&dimension=${table.isDimensional()}" title="$i18n.getString( "edit" )"><img src="../images/edit.png" alt="$i18n.getString( "edit" )"></a>						
+
+                        #if ( $security.canManage( $table ) )
+                        <a href="javascript:showSharingDialog('reportTable', '$table.uid');"><img src="../images/relationship.png" alt="$i18n.getString( 'sharing_settings' )"></a>
+                        #else
+                        <img src="../images/relationship-denied.png">
+                        #end
+
+                        #if( $security.canUpdate( $table ) )
+                        <a href="displayAddTableForm.action?id=${table.id}&dimension=${table.isDimensional()}" title="$i18n.getString( "edit" )"><img src="../images/edit.png" alt="$i18n.getString( "edit" )"></a>
+                        #else
+                        <img src="../images/edit-denied.png">
+                        #end
+
 						<a href="javascript:addReportTableToDashboard( '$table.id' )" title="$i18n.getString( 'add_to_dashboard' )"><img src="../images/add_to_dashboard.png" alt="$i18n.getString( 'add_to_dashboard' )"></a>
-						#if( $auth.hasAccess( "dhis-web-reporting", "removeTable" ) )
+
+						#if( $auth.hasAccess( "dhis-web-reporting", "removeTable" ) && $security.canDelete( $table ))
 						<a href="javascript:removeTable( $table.id, '$encoder.jsEncode( $table.name )' )" title="$i18n.getString( "remove" )"><img src="../images/delete.png" alt="$i18n.getString( "remove" )"></a>
 						#else <img src="../images/delete-denied.png"> #end
 						<a href="javascript:showTableDetails( $table.id )" title="$i18n.getString( "show_details" )"><img src="../images/information.png" alt="$i18n.getString( "show_details" )"></a>
+
 					</td>
 				</tr>
 				#end