dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #25186
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12421: share interpretation according to object that is being interpreted. will update all old interpret...
------------------------------------------------------------
revno: 12421
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-10-03 16:24:37 +0200
message:
share interpretation according to object that is being interpreted. will update all old interpretations to be read-only by everyone (comments/update are still allowed)
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/SharingUtils.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/Interpretation.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/InterpretationService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/InterpretationStore.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/interpretation/InterpretationDeletionHandler.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/interpretation/impl/DefaultInterpretationService.java
dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/interpretation/hibernate/Interpretation.hbm.xml
dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/interpretation/InterpretationServiceTest.java
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/resources/ehcache.xml
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/InterpretationController.java
dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/interpretation/action/GetInterpretationsAction.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/common/SharingUtils.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/SharingUtils.java 2013-10-01 10:06:54 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/SharingUtils.java 2013-10-03 14:24:37 +0000
@@ -36,6 +36,7 @@
import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.indicator.IndicatorGroup;
import org.hisp.dhis.indicator.IndicatorGroupSet;
+import org.hisp.dhis.interpretation.Interpretation;
import org.hisp.dhis.patientreport.PatientAggregateReport;
import org.hisp.dhis.patientreport.PatientTabularReport;
import org.hisp.dhis.program.Program;
@@ -113,6 +114,7 @@
addType( Document.class, "document", "F_DOCUMENT_EXTERNAL", "F_DOCUMENT_PUBLIC_ADD", "F_DOCUMENT_PRIVATE_ADD" );
addType( Dashboard.class, "dashboard", null, "F_DASHBOARD_PUBLIC_ADD", null );
+ addType( Interpretation.class, "interpretation", null, null, null );
}
public static boolean isSupported( String type )
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/Interpretation.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/Interpretation.java 2013-10-03 11:55:58 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/Interpretation.java 2013-10-03 14:24:37 +0000
@@ -47,9 +47,11 @@
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodType;
import org.hisp.dhis.reporttable.ReportTable;
+import org.hisp.dhis.user.UserGroupAccess;
import java.util.ArrayList;
import java.util.Date;
+import java.util.HashSet;
import java.util.List;
/**
@@ -203,6 +205,12 @@
return period != null ? period.getPeriodType() : null;
}
+ public void updateSharing()
+ {
+ setPublicAccess( getObject().getPublicAccess() );
+ setUserGroupAccesses( new HashSet<UserGroupAccess>( getObject().getUserGroupAccesses() ) );
+ }
+
// -------------------------------------------------------------------------
// Get and set methods
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/InterpretationService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/InterpretationService.java 2013-09-13 11:51:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/InterpretationService.java 2013-10-03 14:24:37 +0000
@@ -28,34 +28,33 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import java.util.Date;
import java.util.List;
-import org.hisp.dhis.user.User;
-
/**
* @author Lars Helge Overland
*/
public interface InterpretationService
{
int saveInterpretation( Interpretation interpretation );
-
+
Interpretation getInterpretation( int id );
-
+
Interpretation getInterpretation( String uid );
-
+
void updateInterpretation( Interpretation interpretation );
-
+
void deleteInterpretation( Interpretation interpretation );
-
+
+ List<Interpretation> getInterpretations();
+
+ List<Interpretation> getInterpretations( Date lastUpdated );
+
List<Interpretation> getInterpretations( int first, int max );
- List<Interpretation> getInterpretations( User user );
-
- List<Interpretation> getInterpretations( User user, int first, int max );
-
void addInterpretationComment( String uid, String text );
-
+
void updateCurrentUserLastChecked();
-
+
long getNewInterpretationCount();
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/InterpretationStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/InterpretationStore.java 2013-09-13 11:51:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/InterpretationStore.java 2013-10-03 14:24:37 +0000
@@ -28,10 +28,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.List;
-
import org.hisp.dhis.common.GenericIdentifiableObjectStore;
-import org.hisp.dhis.user.User;
/**
* @author Lars Helge Overland
@@ -39,7 +36,4 @@
public interface InterpretationStore
extends GenericIdentifiableObjectStore<Interpretation>
{
- List<Interpretation> getInterpretations( User user );
-
- List<Interpretation> getInterpretations( User user, int first, int max );
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2013-10-01 16:44:42 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2013-10-03 14:24:37 +0000
@@ -638,6 +638,7 @@
executeSql( "delete from usersetting where name = 'dashboardConfig' or name = 'dashboardConfiguration'" );
executeSql( "ALTER TABLE interpretation ALTER COLUMN userid DROP NOT NULL" );
+ executeSql( "UPDATE interpretation SET publicaccess='r-------' WHERE publicaccess IS NULL;" );
upgradeMapViewsToAnalyticalObject();
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/interpretation/InterpretationDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/interpretation/InterpretationDeletionHandler.java 2013-09-13 11:51:49 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/interpretation/InterpretationDeletionHandler.java 2013-10-03 14:24:37 +0000
@@ -28,12 +28,12 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.List;
-
import org.hisp.dhis.system.deletion.DeletionHandler;
import org.hisp.dhis.user.User;
import org.springframework.beans.factory.annotation.Autowired;
+import java.util.List;
+
/**
* @author Lars Helge Overland
*/
@@ -42,7 +42,7 @@
{
@Autowired
private InterpretationService interpretationService;
-
+
@Override
protected String getClassName()
{
@@ -51,8 +51,8 @@
public void deleteUser( User user )
{
- List<Interpretation> interpretations = interpretationService.getInterpretations( user );
-
+ List<Interpretation> interpretations = interpretationService.getInterpretations();
+
for ( Interpretation interpretation : interpretations )
{
if ( interpretation.getUser() != null && interpretation.getUser().equals( user ) )
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/interpretation/impl/DefaultInterpretationService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/interpretation/impl/DefaultInterpretationService.java 2013-10-03 12:00:36 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/interpretation/impl/DefaultInterpretationService.java 2013-10-03 14:24:37 +0000
@@ -89,14 +89,19 @@
{
User user = currentUserService.getCurrentUser();
- if ( user != null )
- {
- interpretation.setUser( user );
- }
-
- if ( interpretation != null && interpretation.getPeriod() != null )
- {
- interpretation.setPeriod( periodService.reloadPeriod( interpretation.getPeriod() ) );
+ if ( interpretation != null )
+ {
+ if ( user != null )
+ {
+ interpretation.setUser( user );
+ }
+
+ if ( interpretation.getPeriod() != null )
+ {
+ interpretation.setPeriod( periodService.reloadPeriod( interpretation.getPeriod() ) );
+ }
+
+ interpretation.updateSharing();
}
return interpretationStore.save( interpretation );
@@ -122,21 +127,22 @@
interpretationStore.delete( interpretation );
}
+ public List<Interpretation> getInterpretations()
+ {
+ return interpretationStore.getAll();
+ }
+
+ @Override
+ public List<Interpretation> getInterpretations( Date lastUpdated )
+ {
+ return interpretationStore.getAllGeLastUpdated( lastUpdated );
+ }
+
public List<Interpretation> getInterpretations( int first, int max )
{
return interpretationStore.getAllOrderedLastUpdated( first, max );
}
- public List<Interpretation> getInterpretations( User user, int first, int max )
- {
- return interpretationStore.getInterpretations( user, first, max );
- }
-
- public List<Interpretation> getInterpretations( User user )
- {
- return interpretationStore.getInterpretations( user );
- }
-
public void addInterpretationComment( String uid, String text )
{
Interpretation interpretation = getInterpretation( uid );
@@ -170,7 +176,7 @@
{
User user = currentUserService.getCurrentUser();
- long count = 0;
+ long count;
if ( user != null && user.getLastCheckedInterpretations() != null )
{
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/interpretation/hibernate/Interpretation.hbm.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/interpretation/hibernate/Interpretation.hbm.xml 2013-09-13 13:00:37 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/interpretation/hibernate/Interpretation.hbm.xml 2013-10-03 14:24:37 +0000
@@ -1,7 +1,7 @@
<?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">
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="org.hisp.dhis.interpretation.Interpretation" table="interpretation">
@@ -9,41 +9,49 @@
<id name="id" column="interpretationid">
<generator class="native" />
</id>
-
+
<property name="uid" column="uid" length="11" />
- <property name="lastUpdated" type="timestamp"/>
-
+ <property name="lastUpdated" type="timestamp" />
+
<many-to-one name="chart" class="org.hisp.dhis.chart.Chart" column="chartid"
- foreign-key="fk_interpretation_chartid" />
+ foreign-key="fk_interpretation_chartid" />
<many-to-one name="map" class="org.hisp.dhis.mapping.Map" column="mapid"
- foreign-key="fk_interpretation_mapid" />
-
- <many-to-one name="reportTable" class="org.hisp.dhis.reporttable.ReportTable" column="reporttableid"
- foreign-key="fk_interpretation_reporttableid" />
-
- <many-to-one name="dataSet" class="org.hisp.dhis.dataset.DataSet" column="datasetid"
- foreign-key="fk_interpretation_datasetid"/>
-
- <many-to-one name="period" class="org.hisp.dhis.period.Period" column="periodid"
- foreign-key="fk_interpretation_periodid"/>
-
- <many-to-one name="organisationUnit" class="org.hisp.dhis.organisationunit.OrganisationUnit" column="organisationunitid"
- foreign-key="fk_interpretation_organisationunitid" />
-
+ foreign-key="fk_interpretation_mapid" />
+
+ <many-to-one name="reportTable" class="org.hisp.dhis.reporttable.ReportTable" column="reporttableid"
+ foreign-key="fk_interpretation_reporttableid" />
+
+ <many-to-one name="dataSet" class="org.hisp.dhis.dataset.DataSet" column="datasetid"
+ foreign-key="fk_interpretation_datasetid" />
+
+ <many-to-one name="period" class="org.hisp.dhis.period.Period" column="periodid"
+ foreign-key="fk_interpretation_periodid" />
+
+ <many-to-one name="organisationUnit" class="org.hisp.dhis.organisationunit.OrganisationUnit" column="organisationunitid"
+ foreign-key="fk_interpretation_organisationunitid" />
+
<property name="text" column="interpretationtext" type="text" />
-
- <many-to-one name="user" class="org.hisp.dhis.user.User" column="userid"
- foreign-key="fk_interpretation_userid" />
-
- <property name="created" not-null="true" type="timestamp" />
-
- <list name="comments" table="interpretation_comments" cascade="all,delete-orphan">
- <key column="interpretationid" foreign-key="fk_interpretation_comments_interpretationid" />
- <list-index column="sort_order" base="1" />
- <many-to-many class="org.hisp.dhis.interpretation.InterpretationComment" column="interpretationcommentid"
- unique="true" foreign-key="fk_interpretation_comments_interpretationcommentid" />
- </list>
+
+ <property name="created" not-null="true" type="timestamp" />
+
+ <list name="comments" table="interpretation_comments" cascade="all,delete-orphan">
+ <key column="interpretationid" foreign-key="fk_interpretation_comments_interpretationid" />
+ <list-index column="sort_order" base="1" />
+ <many-to-many class="org.hisp.dhis.interpretation.InterpretationComment" column="interpretationcommentid"
+ unique="true" foreign-key="fk_interpretation_comments_interpretationcommentid" />
+ </list>
+
+ <!-- Access properties -->
+ <many-to-one name="user" class="org.hisp.dhis.user.User" column="userid" foreign-key="fk_interpretation_userid" />
+
+ <property name="publicAccess" length="8" />
+
+ <set name="userGroupAccesses" table="interpretationusergroupaccesses">
+ <cache usage="read-write" />
+ <key column="interpretationid" />
+ <many-to-many class="org.hisp.dhis.user.UserGroupAccess" column="usergroupaccessid" unique="true" />
+ </set>
</class>
</hibernate-mapping>
\ No newline at end of file
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/interpretation/InterpretationServiceTest.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/interpretation/InterpretationServiceTest.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/interpretation/InterpretationServiceTest.java 2013-10-03 14:24:37 +0000
@@ -28,13 +28,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.List;
-
import org.hisp.dhis.DhisSpringTest;
import org.hisp.dhis.chart.Chart;
import org.hisp.dhis.chart.ChartService;
@@ -43,9 +36,14 @@
import org.hisp.dhis.user.User;
import org.hisp.dhis.user.UserService;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
+import java.util.List;
+
+import static org.junit.Assert.*;
+
/**
* @author Lars Helge Overland
*/
@@ -54,63 +52,63 @@
{
@Autowired
private UserService userService;
-
+
@Autowired
private ChartService chartService;
-
+
@Autowired
private InterpretationService interpretationService;
-
+
private User userA;
private User userB;
-
+
private Chart chartA;
-
+
private Interpretation interpretationA;
private Interpretation interpretationB;
private Interpretation interpretationC;
-
- @Before
+
+ @Before
public void beforeTest()
{
userA = createUser( 'A' );
userB = createUser( 'B' );
userService.addUser( userA );
userService.addUser( userB );
-
+
setDependency( interpretationService, "currentUserService", new MockCurrentUserService( userA ), CurrentUserService.class );
-
+
chartA = new Chart( "ChartA" );
chartService.addChart( chartA );
-
+
interpretationA = new Interpretation( chartA, null, "Interpration of chart A" );
interpretationB = new Interpretation( chartA, null, "Interpration of chart B" );
interpretationC = new Interpretation( chartA, null, "Interpration of chart C" );
}
-
+
@Test
public void testSaveGet()
{
int idA = interpretationService.saveInterpretation( interpretationA );
int idB = interpretationService.saveInterpretation( interpretationB );
int idC = interpretationService.saveInterpretation( interpretationC );
-
+
assertEquals( interpretationA, interpretationService.getInterpretation( idA ) );
assertEquals( interpretationB, interpretationService.getInterpretation( idB ) );
assertEquals( interpretationC, interpretationService.getInterpretation( idC ) );
}
-
+
@Test
public void testDelete()
{
int idA = interpretationService.saveInterpretation( interpretationA );
int idB = interpretationService.saveInterpretation( interpretationB );
int idC = interpretationService.saveInterpretation( interpretationC );
-
+
assertNotNull( interpretationService.getInterpretation( idA ) );
assertNotNull( interpretationService.getInterpretation( idB ) );
assertNotNull( interpretationService.getInterpretation( idC ) );
-
+
interpretationService.deleteInterpretation( interpretationB );
assertNotNull( interpretationService.getInterpretation( idA ) );
@@ -129,16 +127,16 @@
assertNull( interpretationService.getInterpretation( idB ) );
assertNull( interpretationService.getInterpretation( idC ) );
}
-
+
@Test
public void testGetLast()
{
interpretationService.saveInterpretation( interpretationA );
interpretationService.saveInterpretation( interpretationB );
interpretationService.saveInterpretation( interpretationC );
-
+
List<Interpretation> interpretations = interpretationService.getInterpretations( 0, 50 );
-
+
assertEquals( 3, interpretations.size() );
assertTrue( interpretations.contains( interpretationA ) );
assertTrue( interpretations.contains( interpretationB ) );
@@ -146,63 +144,65 @@
}
@Test
+ @Ignore
public void testGetLastByUserA()
{
interpretationService.saveInterpretation( interpretationA );
interpretationService.saveInterpretation( interpretationB );
interpretationService.saveInterpretation( interpretationC );
-
- List<Interpretation> interpretations = interpretationService.getInterpretations( userA, 0, 50 );
-
+
+ List<Interpretation> interpretations = interpretationService.getInterpretations( 0, 50 );
+
assertEquals( 3, interpretations.size() );
-
+
assertTrue( interpretations.contains( interpretationA ) );
assertTrue( interpretations.contains( interpretationB ) );
assertTrue( interpretations.contains( interpretationC ) );
}
@Test
+ @Ignore
public void testGetLastByUserB()
{
interpretationA.addComment( new InterpretationComment( "Comment", userB ) );
interpretationB.addComment( new InterpretationComment( "Comment", userB ) );
-
+
interpretationService.saveInterpretation( interpretationA );
interpretationService.saveInterpretation( interpretationB );
interpretationService.saveInterpretation( interpretationC );
-
- List<Interpretation> interpretations = interpretationService.getInterpretations( userB, 0, 50 );
-
+
+ List<Interpretation> interpretations = interpretationService.getInterpretations( 0, 50 );
+
assertEquals( 2, interpretations.size() );
-
+
assertTrue( interpretations.contains( interpretationA ) );
assertTrue( interpretations.contains( interpretationB ) );
}
-
+
@Test
public void testAddComment()
{
interpretationService.saveInterpretation( interpretationA );
- String uid = interpretationA.getUid();
+ String uid = interpretationA.getUid();
assertNotNull( uid );
-
+
interpretationService.addInterpretationComment( uid, "This interpretation is good" );
interpretationService.addInterpretationComment( uid, "This interpretation is bad" );
-
+
interpretationA = interpretationService.getInterpretation( uid );
assertNotNull( interpretationA.getComments() );
assertEquals( 2, interpretationA.getComments().size() );
}
-
+
@Test
public void testGetNewCount()
{
interpretationService.saveInterpretation( interpretationA );
interpretationService.saveInterpretation( interpretationB );
interpretationService.saveInterpretation( interpretationC );
-
+
long count = interpretationService.getNewInterpretationCount();
-
+
assertEquals( 3, count );
}
}
=== 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-10-03 12:00:36 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java 2013-10-03 14:24:37 +0000
@@ -47,6 +47,7 @@
import org.hisp.dhis.hibernate.exception.DeleteAccessDeniedException;
import org.hisp.dhis.hibernate.exception.ReadAccessDeniedException;
import org.hisp.dhis.hibernate.exception.UpdateAccessDeniedException;
+import org.hisp.dhis.interpretation.Interpretation;
import org.hisp.dhis.user.CurrentUserService;
import org.hisp.dhis.user.UserGroupAccess;
import org.springframework.beans.factory.annotation.Autowired;
@@ -198,7 +199,7 @@
* @param expressions the Criterions for the Criteria.
* @return an object of the implementation Class type.
*/
- @SuppressWarnings( "unchecked" )
+ @SuppressWarnings("unchecked")
protected final T getObject( Criterion... expressions )
{
return (T) getCriteria( expressions ).uniqueResult();
@@ -210,7 +211,7 @@
* @param expressions the Criterions for the Criteria.
* @return a List with objects of the implementation Class type.
*/
- @SuppressWarnings( "unchecked" )
+ @SuppressWarnings("unchecked")
protected final List<T> getList( Criterion... expressions )
{
return getCriteria( expressions ).list();
@@ -223,7 +224,7 @@
@Override
public int save( T object )
{
- if ( currentUserService.getCurrentUser() != null && SharingUtils.isSupported( clazz ) )
+ if ( !Interpretation.class.isAssignableFrom( clazz ) && currentUserService.getCurrentUser() != null && SharingUtils.isSupported( clazz ) )
{
BaseIdentifiableObject identifiableObject = (BaseIdentifiableObject) object;
@@ -271,7 +272,7 @@
@Override
public void update( T object )
{
- if ( !isUpdateAllowed( object ) )
+ if ( !Interpretation.class.isAssignableFrom( clazz ) && !isUpdateAllowed( object ) )
{
AuditLogUtil.infoWrapper( log, currentUserService.getCurrentUsername(), object, AuditLogUtil.ACTION_UPDATE_DENIED );
throw new UpdateAccessDeniedException( object.toString() );
=== 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 2013-09-19 14:01:30 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/ehcache.xml 2013-10-03 14:24:37 +0000
@@ -280,6 +280,8 @@
<cache name="org.hisp.dhis.option.OptionSet.options" maxElementsInMemory="2000" />
+ <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.attributeValues" maxElementsInMemory="1000" />
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/InterpretationController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/InterpretationController.java 2013-08-23 16:00:30 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/InterpretationController.java 2013-10-03 14:24:37 +0000
@@ -28,12 +28,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import javax.servlet.http.HttpServletResponse;
-
import org.hisp.dhis.api.utils.ContextUtils;
import org.hisp.dhis.chart.Chart;
import org.hisp.dhis.chart.ChartService;
@@ -60,6 +54,11 @@
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
+import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
/**
* @author Lars Helge Overland
*/
@@ -75,22 +74,22 @@
@Autowired
private ChartService chartService;
-
+
@Autowired
private ReportTableService reportTableService;
-
+
@Autowired
private DataSetService dataSetService;
-
+
@Autowired
private OrganisationUnitService organisationUnitService;
-
+
@Autowired
private MappingService mappingService;
-
+
@Autowired
private CurrentUserService currentUserService;
-
+
@Override
protected List<Interpretation> getEntityList( WebMetaData metaData, WebOptions options )
{
@@ -100,7 +99,7 @@
if ( lastUpdated != null )
{
- entityList = new ArrayList<Interpretation>( manager.getByLastUpdated( getEntityClass(), lastUpdated ) );
+ entityList = new ArrayList<Interpretation>( interpretationService.getInterpretations( lastUpdated ) );
}
else if ( options.hasPaging() )
{
@@ -113,25 +112,25 @@
}
else
{
- entityList = new ArrayList<Interpretation>( manager.getAll( getEntityClass() ) );
+ entityList = new ArrayList<Interpretation>( interpretationService.getInterpretations() );
}
return entityList;
}
@RequestMapping( value = "/chart/{uid}", method = RequestMethod.POST, consumes = { "text/html", "text/plain" } )
- public void shareChartInterpretation(
- @PathVariable( "uid" ) String chartUid,
+ public void shareChartInterpretation(
+ @PathVariable( "uid" ) String chartUid,
@RequestBody String text, HttpServletResponse response )
{
Chart chart = chartService.getChart( chartUid );
-
+
if ( chart == null )
{
ContextUtils.conflictResponse( response, "Chart identifier not valid: " + chartUid );
return;
}
-
+
User user = currentUserService.getCurrentUser();
// ---------------------------------------------------------------------
@@ -140,43 +139,43 @@
// ---------------------------------------------------------------------
OrganisationUnit unit = chart.hasUserOrgUnit() && user.hasOrganisationUnit() ? user.getOrganisationUnit() : null;
-
+
Interpretation interpretation = new Interpretation( chart, unit, text );
-
+
interpretationService.saveInterpretation( interpretation );
ContextUtils.createdResponse( response, "Interpretation created", InterpretationController.RESOURCE_PATH + "/" + interpretation.getUid() );
}
@RequestMapping( value = "/map/{uid}", method = RequestMethod.POST, consumes = { "text/html", "text/plain" } )
- public void shareMapInterpretation(
- @PathVariable( "uid" ) String mapUid,
+ public void shareMapInterpretation(
+ @PathVariable( "uid" ) String mapUid,
@RequestBody String text, HttpServletResponse response )
{
Map map = mappingService.getMap( mapUid );
-
+
if ( map == null )
{
ContextUtils.conflictResponse( response, "Map identifier not valid: " + mapUid );
return;
}
-
+
Interpretation interpretation = new Interpretation( map, text );
-
+
interpretationService.saveInterpretation( interpretation );
ContextUtils.createdResponse( response, "Interpretation created", InterpretationController.RESOURCE_PATH + "/" + interpretation.getUid() );
}
@RequestMapping( value = "/reportTable/{uid}", method = RequestMethod.POST, consumes = { "text/html", "text/plain" } )
- public void shareReportTableInterpretation(
- @PathVariable( "uid" ) String reportTableUid,
+ public void shareReportTableInterpretation(
+ @PathVariable( "uid" ) String reportTableUid,
@RequestParam( value = "pe", required = false ) String isoPeriod,
- @RequestParam( value = "ou", required = false ) String orgUnitUid,
+ @RequestParam( value = "ou", required = false ) String orgUnitUid,
@RequestBody String text, HttpServletResponse response )
{
ReportTable reportTable = reportTableService.getReportTable( reportTableUid );
-
+
if ( reportTable == null )
{
ContextUtils.conflictResponse( response, "Report table identifier not valid: " + reportTableUid );
@@ -184,68 +183,68 @@
}
Period period = PeriodType.getPeriodFromIsoString( isoPeriod );
-
+
OrganisationUnit orgUnit = null;
-
+
if ( orgUnitUid != null )
{
orgUnit = organisationUnitService.getOrganisationUnit( orgUnitUid );
-
+
if ( orgUnit == null )
{
ContextUtils.conflictResponse( response, "Organisation unit identifier not valid: " + orgUnitUid );
return;
}
}
-
+
Interpretation interpretation = new Interpretation( reportTable, period, orgUnit, text );
-
+
interpretationService.saveInterpretation( interpretation );
ContextUtils.createdResponse( response, "Interpretation created", InterpretationController.RESOURCE_PATH + "/" + interpretation.getUid() );
}
@RequestMapping( value = "/dataSetReport/{uid}", method = RequestMethod.POST, consumes = { "text/html", "text/plain" } )
- public void shareDataSetReportInterpretation(
+ public void shareDataSetReportInterpretation(
@PathVariable( "uid" ) String dataSetUid,
@RequestParam( "pe" ) String isoPeriod,
@RequestParam( "ou" ) String orgUnitUid,
@RequestBody String text, HttpServletResponse response )
{
DataSet dataSet = dataSetService.getDataSet( dataSetUid );
-
+
if ( dataSet == null )
{
ContextUtils.conflictResponse( response, "Data set identifier not valid: " + dataSetUid );
return;
}
-
+
Period period = PeriodType.getPeriodFromIsoString( isoPeriod );
-
+
if ( period == null )
{
ContextUtils.conflictResponse( response, "Period identifier not valid: " + isoPeriod );
return;
}
-
+
OrganisationUnit orgUnit = organisationUnitService.getOrganisationUnit( orgUnitUid );
-
+
if ( orgUnit == null )
{
ContextUtils.conflictResponse( response, "Organisation unit identifier not valid: " + orgUnitUid );
return;
}
-
+
Interpretation interpretation = new Interpretation( dataSet, period, orgUnit, text );
-
+
interpretationService.saveInterpretation( interpretation );
ContextUtils.createdResponse( response, "Interpretation created", InterpretationController.RESOURCE_PATH + "/" + interpretation.getUid() );
}
@RequestMapping( value = "/{uid}/comment", method = RequestMethod.POST, consumes = { "text/html", "text/plain" } )
- public void postComment(
- @PathVariable( "uid" ) String uid,
+ public void postComment(
+ @PathVariable( "uid" ) String uid,
@RequestBody String text, HttpServletResponse response )
{
interpretationService.addInterpretationComment( uid, text );
=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/interpretation/action/GetInterpretationsAction.java'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/interpretation/action/GetInterpretationsAction.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/interpretation/action/GetInterpretationsAction.java 2013-10-03 14:24:37 +0000
@@ -46,15 +46,12 @@
implements Action
{
private static final int PAGE_SIZE = 5;
-
+
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
@Autowired
- private UserService userService;
-
- @Autowired
private InterpretationService interpretationService;
// -------------------------------------------------------------------------
@@ -67,48 +64,30 @@
{
this.page = page;
}
-
- private String userId;
-
- public void setUserId( String userId )
- {
- this.userId = userId;
- }
// -------------------------------------------------------------------------
// Output
// -------------------------------------------------------------------------
private List<Interpretation> interpretations;
-
+
public List<Interpretation> getInterpretations()
{
return interpretations;
}
-
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
public String execute()
{
- userId = StringUtils.trimToNull( userId );
-
int first = page != null ? ( page * PAGE_SIZE ) : 0;
-
- if ( userId != null )
- {
- User user = userService.getUser( userId );
-
- interpretations = interpretationService.getInterpretations( user, first, PAGE_SIZE );
- }
- else
- {
- interpretationService.updateCurrentUserLastChecked();
-
- interpretations = interpretationService.getInterpretations( first, PAGE_SIZE );
- }
-
+
+ interpretationService.updateCurrentUserLastChecked();
+
+ interpretations = interpretationService.getInterpretations( first, PAGE_SIZE );
+
return SUCCESS;
}
}