=== 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-08-23 15:56:19 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/InterpretationService.java 2013-09-13 11:51:49 +0000 @@ -49,6 +49,8 @@ List getInterpretations( int first, int max ); + List getInterpretations( User user ); + List getInterpretations( User user, int first, int max ); void addInterpretationComment( String uid, String text ); === 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-08-23 15:56:19 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/InterpretationStore.java 2013-09-13 11:51:49 +0000 @@ -39,5 +39,7 @@ public interface InterpretationStore extends GenericIdentifiableObjectStore { + List getInterpretations( User user ); + List getInterpretations( User user, int first, int max ); } === added 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 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/interpretation/InterpretationDeletionHandler.java 2013-09-13 11:51:49 +0000 @@ -0,0 +1,65 @@ +package org.hisp.dhis.interpretation; + +/* + * Copyright (c) 2004-2013, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * 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; + +/** + * @author Lars Helge Overland + */ +public class InterpretationDeletionHandler + extends DeletionHandler +{ + @Autowired + private InterpretationService interpretationService; + + @Override + protected String getClassName() + { + return DeletionHandler.class.getSimpleName(); + } + + public void deleteUser( User user ) + { + List interpretations = interpretationService.getInterpretations( user ); + + for ( Interpretation interpretation : interpretations ) + { + if ( interpretation.getUser() != null && interpretation.getUser().equals( user ) ) + { + interpretation.setUser( null ); + interpretationService.updateInterpretation( interpretation ); + } + } + } +} === modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/interpretation/hibernate/HibernateInterpretationStore.java' --- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/interpretation/hibernate/HibernateInterpretationStore.java 2013-08-23 16:05:01 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/interpretation/hibernate/HibernateInterpretationStore.java 2013-09-13 11:51:49 +0000 @@ -41,7 +41,19 @@ */ public class HibernateInterpretationStore extends HibernateIdentifiableObjectStore implements InterpretationStore -{ +{ + @SuppressWarnings("unchecked") + public List getInterpretations( User user ) + { + String hql = "select distinct i from Interpretation i left join i.comments c " + + "where i.user = :user or c.user = :user order by i.lastUpdated desc"; + + Query query = getQuery( hql ); + query.setEntity( "user", user ); + + return query.list(); + } + @SuppressWarnings("unchecked") public List getInterpretations( User user, int first, int max ) { === 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-08-23 16:05:01 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/interpretation/impl/DefaultInterpretationService.java 2013-09-13 11:51:49 +0000 @@ -132,6 +132,11 @@ return interpretationStore.getInterpretations( user, first, max ); } + public List getInterpretations( User user ) + { + return interpretationStore.getInterpretations( user ); + } + public void addInterpretationComment( String uid, String text ) { Interpretation interpretation = getInterpretation( uid ); === modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml 2013-08-29 18:09:46 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml 2013-09-13 11:51:49 +0000 @@ -210,6 +210,8 @@ + + @@ -221,6 +223,7 @@ + === 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-08-27 10:49:43 +0000 +++ dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java 2013-09-13 11:51:49 +0000 @@ -33,6 +33,7 @@ import org.hibernate.Criteria; import org.hibernate.Query; import org.hibernate.SQLQuery; +import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.criterion.Criterion; import org.hibernate.criterion.Restrictions; @@ -130,6 +131,16 @@ // ------------------------------------------------------------------------- /** + * Returns the current session. + * + * @return the current session. + */ + protected final Session getSession() + { + return sessionFactory.getCurrentSession(); + } + + /** * Creates a Query. * * @param hql the hql query. === modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java' --- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java 2013-08-23 16:05:01 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java 2013-09-13 11:51:49 +0000 @@ -54,6 +54,7 @@ import org.hisp.dhis.indicator.IndicatorGroup; import org.hisp.dhis.indicator.IndicatorGroupSet; import org.hisp.dhis.indicator.IndicatorType; +import org.hisp.dhis.interpretation.Interpretation; import org.hisp.dhis.mapping.Map; import org.hisp.dhis.mapping.MapLegend; import org.hisp.dhis.mapping.MapLegendSet; @@ -714,5 +715,13 @@ { return null; } - + + public void deleteIntepretation( Interpretation interpretation ) + { + } + + public String allowDeleteInterpretation( Interpretation interpretation ) + { + return null; + } }