dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #24649
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12122: Moved IdentifiableObject-relevant methods in HibernateGenericStore to HibernateIdentifiableObject...
------------------------------------------------------------
revno: 12122
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-09-17 20:07:42 +0200
message:
Moved IdentifiableObject-relevant methods in HibernateGenericStore to HibernateIdentifiableObjectStore. Fixed some invalid bean definitions which appeared as a result.
added:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingStore.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/setting/hibernate/
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/setting/hibernate/HibernateSystemSettingStore.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericNameableObjectStore.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeOptionStore.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateIdentifiableObjectStore.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/setting/DefaultSystemSettingManager.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/setting/SystemSettingStoreTest.java
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientAttributeOptionStore.java
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientIdentifierStore.java
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientcomment/DefaultPatientCommentService.java
dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java
dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/style/dashboard.css
--
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/GenericNameableObjectStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericNameableObjectStore.java 2013-08-23 15:56:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericNameableObjectStore.java 2013-09-17 18:07:42 +0000
@@ -32,7 +32,6 @@
/**
* @author Lars Helge Overland
- * @version $Id$
*/
public interface GenericNameableObjectStore<T>
extends GenericIdentifiableObjectStore<T>
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeOptionStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeOptionStore.java 2013-08-23 15:56:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeOptionStore.java 2013-09-17 18:07:42 +0000
@@ -30,15 +30,13 @@
import java.util.Collection;
-import org.hisp.dhis.common.GenericNameableObjectStore;
+import org.hisp.dhis.common.GenericStore;
/**
* @author Viet
- *
- * @version $Id$
*/
public interface PatientAttributeOptionStore
- extends GenericNameableObjectStore<PatientAttributeOption>
+ extends GenericStore<PatientAttributeOption>
{
String ID = PatientAttributeOption.class.getName();
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingStore.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingStore.java 2013-09-17 18:07:42 +0000
@@ -0,0 +1,40 @@
+package org.hisp.dhis.setting;
+
+/*
+ * 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 org.hisp.dhis.common.GenericStore;
+
+/**
+ * @author Lars Helge Overland
+ */
+public interface SystemSettingStore
+ extends GenericStore<SystemSetting>
+{
+ SystemSetting getByName( String name );
+}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateIdentifiableObjectStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateIdentifiableObjectStore.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateIdentifiableObjectStore.java 2013-09-17 18:07:42 +0000
@@ -28,15 +28,31 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hibernate.Query;
+import org.hibernate.criterion.Restrictions;
+import org.hisp.dhis.common.AuditLogUtil;
import org.hisp.dhis.common.BaseIdentifiableObject;
+import org.hisp.dhis.common.GenericNameableObjectStore;
+import org.hisp.dhis.common.NameableObject;
import org.hisp.dhis.hibernate.HibernateGenericStore;
+import org.hisp.dhis.hibernate.exception.ReadAccessDeniedException;
+import org.hisp.dhis.user.User;
/**
* @author bobj
*/
public class HibernateIdentifiableObjectStore<T extends BaseIdentifiableObject>
- extends HibernateGenericStore<T>
+ extends HibernateGenericStore<T> implements GenericNameableObjectStore<T>
{
+ private static final Log log = LogFactory.getLog( HibernateIdentifiableObjectStore.class );
+
@Override
public int save( T object )
{
@@ -50,4 +66,588 @@
object.setAutoFields();
super.update( object );
}
+
+ @Override
+ public final T getByUid( String uid )
+ {
+ T object = getObject( Restrictions.eq( "uid", uid ) );
+
+ if ( !isReadAllowed( object ) )
+ {
+ AuditLogUtil.infoWrapper( log, currentUserService.getCurrentUsername(), object, AuditLogUtil.ACTION_READ_DENIED );
+ throw new ReadAccessDeniedException( object.toString() );
+ }
+
+ return object;
+ }
+
+ @Override
+ public final T getByUidNoAcl( String uid )
+ {
+ return getObject( Restrictions.eq( "uid", uid ) );
+ }
+
+ @Override
+ public final void updateNoAcl( T object )
+ {
+ sessionFactory.getCurrentSession().update( object );
+ }
+
+ @Override
+ @Deprecated
+ public final T getByName( String name )
+ {
+ T object = getObject( Restrictions.eq( "name", name ) );
+
+ if ( !isReadAllowed( object ) )
+ {
+ AuditLogUtil.infoWrapper( log, currentUserService.getCurrentUsername(), object, AuditLogUtil.ACTION_READ_DENIED );
+ throw new ReadAccessDeniedException( object.toString() );
+ }
+
+ return object;
+ }
+
+ @Override
+ @Deprecated
+ public final T getByShortName( String shortName )
+ {
+ T object = getObject( Restrictions.eq( "shortName", shortName ) );
+
+ if ( !isReadAllowed( object ) )
+ {
+ AuditLogUtil.infoWrapper( log, currentUserService.getCurrentUsername(), object, AuditLogUtil.ACTION_READ_DENIED );
+ throw new ReadAccessDeniedException( object.toString() );
+ }
+
+ return object;
+ }
+
+ @Override
+ public final T getByCode( String code )
+ {
+ T object = getObject( Restrictions.eq( "code", code ) );
+
+ if ( !isReadAllowed( object ) )
+ {
+ AuditLogUtil.infoWrapper( log, currentUserService.getCurrentUsername(), object, AuditLogUtil.ACTION_READ_DENIED );
+ throw new ReadAccessDeniedException( object.toString() );
+ }
+
+ return object;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public List<T> getAllEqName( String name )
+ {
+ Query query = sharingEnabled() ? getQueryAllEqNameAcl( name ) : getQueryAllEqName( name );
+
+ return query.list();
+ }
+
+ private Query getQueryAllEqNameAcl( String name )
+ {
+ String hql = "select distinct c from " + clazz.getName() + " c"
+ + " where name = :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";
+
+ Query query = getQuery( hql );
+ query.setEntity( "user", currentUserService.getCurrentUser() );
+ query.setString( "name", name );
+
+ return query;
+ }
+
+ private Query getQueryAllEqName( String name )
+ {
+ Query query = getQuery( "from " + clazz.getName() + " c where name = :name order by c.name" );
+ query.setString( "name", name );
+
+ return query;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public List<T> getAllEqNameIgnoreCase( String name )
+ {
+ Query query = sharingEnabled() ? getQueryAllEqNameAclIgnoreCase( name ) : getQueryAllEqNameIgnoreCase( name );
+
+ return query.list();
+ }
+
+ private Query getQueryAllEqNameAclIgnoreCase( String name )
+ {
+ String hql = "select distinct c from " + clazz.getName() + " c"
+ + " where lower(name) = :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";
+
+ Query query = getQuery( hql );
+ query.setEntity( "user", currentUserService.getCurrentUser() );
+ query.setString( "name", name.toLowerCase() );
+
+ return query;
+ }
+
+ private Query getQueryAllEqNameIgnoreCase( String name )
+ {
+ Query query = getQuery( "from " + clazz.getName() + " c where lower(name) = :name order by c.name" );
+ query.setString( "name", name.toLowerCase() );
+
+ return query;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public List<T> getAllEqShortName( String shortName )
+ {
+ Query query = sharingEnabled() ? getQueryAllEqShortNameAcl( shortName ) : getQueryAllEqShortName( shortName );
+
+ return query.list();
+ }
+
+ private Query getQueryAllEqShortNameAcl( String shortName )
+ {
+ String hql = "select distinct c from " + clazz.getName() + " c"
+ + " where shortName = :shortName 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.shortName";
+
+ Query query = getQuery( hql );
+ query.setEntity( "user", currentUserService.getCurrentUser() );
+ query.setString( "shortName", shortName );
+
+ return query;
+ }
+
+ private Query getQueryAllEqShortName( String shortName )
+ {
+ Query query = getQuery( "from " + clazz.getName() + " c where shortName = :shortName order by c.shortName" );
+ query.setString( "shortName", shortName );
+
+ return query;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public List<T> getAllEqShortNameIgnoreCase( String shortName )
+ {
+ Query query = sharingEnabled() ? getQueryAllEqShortNameAclIgnoreCase( shortName ) : getQueryAllEqShortNameIgnoreCase( shortName );
+
+ return query.list();
+ }
+
+ private Query getQueryAllEqShortNameAclIgnoreCase( String shortName )
+ {
+ String hql = "select distinct c from " + clazz.getName() + " c"
+ + " where lower(shortName) = :shortName 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.shortName";
+
+ Query query = getQuery( hql );
+ query.setEntity( "user", currentUserService.getCurrentUser() );
+ query.setString( "shortName", shortName.toLowerCase() );
+
+ return query;
+ }
+
+ private Query getQueryAllEqShortNameIgnoreCase( String shortName )
+ {
+ Query query = getQuery( "from " + clazz.getName() + " c where lower(shortName) = :shortName order by c.shortName" );
+ query.setString( "shortName", shortName.toLowerCase() );
+
+ return query;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public List<T> getAllLikeName( String name )
+ {
+ Query query = sharingEnabled() ? getQueryAllLikeNameAcl( name ) : getQueryAllLikeName( name );
+
+ return query.list();
+ }
+
+ 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 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";
+
+ Query query = getQuery( hql );
+ query.setEntity( "user", currentUserService.getCurrentUser() );
+ query.setString( "name", "%" + name.toLowerCase() + "%" );
+
+ return query;
+ }
+
+ private Query getQueryAllLikeName( String name )
+ {
+ Query query = getQuery( "from " + clazz.getName() + " c where lower(name) like :name order by c.name" );
+ query.setString( "name", "%" + name.toLowerCase() + "%" );
+
+ return query;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public List<T> getAllLikeShortName( String shortName )
+ {
+ if ( NameableObject.class.isAssignableFrom( clazz ) )
+ {
+ Query query = sharingEnabled() ? getQueryAllLikeShortNameAcl( shortName ) : getQueryAllLikeShortName( shortName );
+ return query.list();
+ }
+
+ // fallback to using name
+ return getAllLikeName( shortName );
+ }
+
+ private Query getQueryAllLikeShortNameAcl( String shortName )
+ {
+ String hql = "select distinct c from " + clazz.getName() + " c"
+ + " where lower(shortName) like :shortName 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.shortName";
+
+ Query query = getQuery( hql );
+ query.setEntity( "user", currentUserService.getCurrentUser() );
+ query.setString( "shortName", "%" + shortName.toLowerCase() + "%" );
+
+ return query;
+ }
+
+ private Query getQueryAllLikeShortName( String shortName )
+ {
+ Query query = getQuery( "from " + clazz.getName() + " c where lower(shortName) like :shortName order by c.shortName" );
+ query.setString( "shortName", "%" + shortName.toLowerCase() + "%" );
+
+ return query;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public final List<T> getAllOrderedName()
+ {
+ Query query = sharingEnabled() ? getQueryAllOrderedNameAcl() : getQueryAllOrderedName();
+
+ return query.list();
+ }
+
+ private Query getQueryAllOrderedNameAcl()
+ {
+ String hql = "select distinct c from " + clazz.getName() + " c"
+ + " 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";
+
+ Query query = getQuery( hql );
+ query.setEntity( "user", currentUserService.getCurrentUser() );
+
+ return query;
+ }
+
+ private Query getQueryAllOrderedName()
+ {
+ return getQuery( "from " + clazz.getName() + " c order by c.name" );
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public List<T> getAllOrderedName( int first, int max )
+ {
+ Query query = sharingEnabled() ? getQueryAllOrderedNameAcl() : getQueryAllOrderedName();
+
+ query.setFirstResult( first );
+ query.setMaxResults( max );
+
+ return query.list();
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public List<T> getAllOrderedLastUpdated( int first, int max )
+ {
+ Query query = sharingEnabled() ? getQueryAllOrderedLastUpdatedAcl() : getQueryAllOrderedLastUpdated();
+
+ query.setFirstResult( first );
+ query.setMaxResults( max );
+
+ return query.list();
+ }
+
+ private Query getQueryAllOrderedLastUpdatedAcl()
+ {
+ String hql = "select distinct c from " + clazz.getName() + " c"
+ + " 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";
+
+ Query query = getQuery( hql );
+ query.setEntity( "user", currentUserService.getCurrentUser() );
+
+ return query;
+ }
+
+ private Query getQueryAllOrderedLastUpdated()
+ {
+ return getQuery( "from " + clazz.getName() + " c order by lastUpdated desc" );
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public List<T> getAllLikeNameOrderedName( String name, int first, int max )
+ {
+ Query query = sharingEnabled() ? getQueryAllLikeNameOrderedNameAcl( name ) : getQueryAllLikeNameOrderedName( name );
+
+ query.setFirstResult( first );
+ query.setMaxResults( max );
+
+ return query.list();
+ }
+
+ 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 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";
+
+ Query query = getQuery( hql );
+ query.setString( "name", "%" + name.toLowerCase() + "%" );
+ query.setEntity( "user", currentUserService.getCurrentUser() );
+
+ return query;
+ }
+
+ private Query getQueryAllLikeNameOrderedName( String name )
+ {
+ Query query = getQuery( "from " + clazz.getName() + " c where lower(name) like :name order by name" );
+ query.setString( "name", "%" + name.toLowerCase() + "%" );
+
+ return query;
+ }
+
+ @Override
+ public int getCountLikeName( String name )
+ {
+ Query query = sharingEnabled() ? getQueryCountLikeNameAcl( name ) : getQueryCountLikeName( name );
+
+ return ((Long) query.uniqueResult()).intValue();
+ }
+
+ 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 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%')"
+ + " )";
+
+ Query query = getQuery( hql );
+ query.setEntity( "user", currentUserService.getCurrentUser() );
+ query.setString( "name", "%" + name.toLowerCase() + "%" );
+
+ return query;
+ }
+
+ private Query getQueryCountLikeName( String name )
+ {
+ Query query = getQuery( "select count(distinct c) from " + clazz.getName() + " c where lower(name) like :name" );
+ query.setString( "name", "%" + name.toLowerCase() + "%" );
+
+ return query;
+ }
+
+ @Override
+ public long getCountGeLastUpdated( Date lastUpdated )
+ {
+ Query query = sharingEnabled() ? getQueryCountGeLastUpdatedAcl( lastUpdated ) : getQueryCountGeLastUpdated( lastUpdated );
+
+ return ((Long) query.uniqueResult()).intValue();
+ }
+
+ 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 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%')"
+ + " )";
+
+ Query query = getQuery( hql );
+ query.setEntity( "user", currentUserService.getCurrentUser() );
+ query.setTimestamp( "lastUpdated", lastUpdated );
+
+ return query;
+ }
+
+ private Query getQueryCountGeLastUpdated( Date lastUpdated )
+ {
+ Query query = getQuery( "select count(distinct c) from " + clazz.getName() + " c where lastUpdated >= :lastUpdated" );
+ query.setTimestamp( "lastUpdated", lastUpdated );
+
+ return query;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public List<T> getAllGeLastUpdated( Date lastUpdated )
+ {
+ Query query = sharingEnabled() ? getQueryAllGeLastUpdatedAcl( lastUpdated ) : getQueryAllGeLastUpdated( lastUpdated );
+
+ return query.list();
+ }
+
+ 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 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%')"
+ + " )";
+
+ Query query = getQuery( hql );
+ query.setEntity( "user", currentUserService.getCurrentUser() );
+ query.setTimestamp( "lastUpdated", lastUpdated );
+
+ return query;
+ }
+
+ private Query getQueryAllGeLastUpdated( Date lastUpdated )
+ {
+ Query query = getQuery( "from " + clazz.getName() + " c where c.lastUpdated >= :lastUpdated" );
+ query.setTimestamp( "lastUpdated", lastUpdated );
+
+ return query;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public List<T> getAllGeCreated( Date created )
+ {
+ Query query = sharingEnabled() ? getQueryAllGeCreatedAcl( created ) : getQueryAllGeCreated( created );
+
+ return query.list();
+ }
+
+ 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 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";
+
+ Query query = getQuery( hql );
+ query.setEntity( "user", currentUserService.getCurrentUser() );
+ query.setTimestamp( "created", created );
+
+ return query;
+ }
+
+ private Query getQueryAllGeCreated( Date created )
+ {
+ Query query = getQuery( "from " + clazz.getName() + " c where c.created >= :created" );
+ query.setTimestamp( "created", created );
+
+ return query;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public List<T> getAllGeLastUpdatedOrderedName( Date lastUpdated )
+ {
+ Query query = sharingEnabled() ? getQueryAllGeLastUpdatedOrderedNameAcl( lastUpdated ) : getQueryAllGeLastUpdatedOrderedName( lastUpdated );
+
+ return query.list();
+ }
+
+ 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 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";
+
+ Query query = getQuery( hql );
+ query.setEntity( "user", currentUserService.getCurrentUser() );
+ query.setTimestamp( "lastUpdated", lastUpdated );
+
+ return query;
+ }
+
+ private Query getQueryAllGeLastUpdatedOrderedName( Date lastUpdated )
+ {
+ Query query = getQuery( "from " + clazz.getName() + " c where c.lastUpdated >= :lastUpdated order by c.name" );
+ query.setTimestamp( "lastUpdated", lastUpdated );
+
+ return query;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public List<T> getByUser( User user )
+ {
+ Query query = getQuery( "from " + clazz.getName() + " c where user = :user" );
+ query.setEntity( "user", user );
+
+ return query.list();
+ }
+
+ @Override
+ public List<T> getByUid( Collection<String> uids )
+ {
+ List<T> list = new ArrayList<T>();
+
+ if ( uids != null )
+ {
+ for ( String uid : uids )
+ {
+ T object = getByUid( uid );
+
+ if ( object != null )
+ {
+ list.add( object );
+ }
+ }
+ }
+
+ return list;
+ }
+
+ //----------------------------------------------------------------------------------------------------------------
+ // No ACL (unfiltered methods)
+ //----------------------------------------------------------------------------------------------------------------
+
+ @Override
+ public int getCountEqNameNoAcl( String name )
+ {
+ Query query = getQuery( "select count(distinct c) from " + clazz.getName() + " c where c.name = :name" );
+ query.setParameter( "name", name );
+
+ return ((Long) query.uniqueResult()).intValue();
+ }
+
+ @Override
+ public int getCountEqShortNameNoAcl( String shortName )
+ {
+ Query query = getQuery( "select count(distinct c) from " + clazz.getName() + " c where c.shortName = :shortName" );
+ query.setParameter( "shortName", shortName );
+
+ return ((Long) query.uniqueResult()).intValue();
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/setting/DefaultSystemSettingManager.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/setting/DefaultSystemSettingManager.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/setting/DefaultSystemSettingManager.java 2013-09-17 18:07:42 +0000
@@ -34,7 +34,6 @@
import java.util.List;
import org.apache.commons.lang.StringUtils;
-import org.hisp.dhis.common.GenericIdentifiableObjectStore;
import org.springframework.transaction.annotation.Transactional;
/**
@@ -49,9 +48,9 @@
// Dependencies
// -------------------------------------------------------------------------
- private GenericIdentifiableObjectStore<SystemSetting> systemSettingStore;
+ private SystemSettingStore systemSettingStore;
- public void setSystemSettingStore( GenericIdentifiableObjectStore<SystemSetting> systemSettingStore )
+ public void setSystemSettingStore( SystemSettingStore systemSettingStore )
{
this.systemSettingStore = systemSettingStore;
}
=== added directory 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/setting/hibernate'
=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/setting/hibernate/HibernateSystemSettingStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/setting/hibernate/HibernateSystemSettingStore.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/setting/hibernate/HibernateSystemSettingStore.java 2013-09-17 18:07:42 +0000
@@ -0,0 +1,47 @@
+package org.hisp.dhis.setting.hibernate;
+
+/*
+ * 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 org.hibernate.criterion.Restrictions;
+import org.hisp.dhis.hibernate.HibernateGenericStore;
+import org.hisp.dhis.setting.SystemSetting;
+import org.hisp.dhis.setting.SystemSettingStore;
+
+/**
+ * @author Lars Helge Overland
+ */
+public class HibernateSystemSettingStore
+ extends HibernateGenericStore<SystemSetting> implements SystemSettingStore
+{
+ @Override
+ public SystemSetting getByName( String name )
+ {
+ return (SystemSetting) getCriteria( Restrictions.eq( "name", name ) ).uniqueResult();
+ }
+}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2013-09-17 16:22:09 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2013-09-17 18:07:42 +0000
@@ -125,7 +125,7 @@
<property name="cacheable" value="true" />
</bean>
- <bean id="org.hisp.dhis.validation.ValidationRuleGroupStore" class="org.hisp.dhis.hibernate.HibernateGenericStore">
+ <bean id="org.hisp.dhis.validation.ValidationRuleGroupStore" class="org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore">
<property name="clazz" value="org.hisp.dhis.validation.ValidationRuleGroup" />
<property name="sessionFactory" ref="sessionFactory" />
<property name="cacheable" value="true" />
@@ -144,8 +144,7 @@
<property name="cacheable" value="true" />
</bean>
- <bean id="org.hisp.dhis.dataelement.DataElementCategoryComboStore"
- class="org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore">
+ <bean id="org.hisp.dhis.dataelement.DataElementCategoryComboStore" class="org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore">
<property name="clazz" value="org.hisp.dhis.dataelement.DataElementCategoryCombo" />
<property name="sessionFactory" ref="sessionFactory" />
<property name="cacheable" value="true" />
@@ -294,7 +293,7 @@
<property name="cacheable" value="true" />
</bean>
- <bean id="org.hisp.dhis.setting.SystemSettingStore" class="org.hisp.dhis.hibernate.HibernateGenericStore">
+ <bean id="org.hisp.dhis.setting.SystemSettingStore" class="org.hisp.dhis.setting.hibernate.HibernateSystemSettingStore">
<property name="clazz" value="org.hisp.dhis.setting.SystemSetting" />
<property name="sessionFactory" ref="sessionFactory" />
<property name="cacheable" value="true" />
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/setting/SystemSettingStoreTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/setting/SystemSettingStoreTest.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/setting/SystemSettingStoreTest.java 2013-09-17 18:07:42 +0000
@@ -35,29 +35,25 @@
import java.util.Collection;
import org.hisp.dhis.DhisSpringTest;
-import org.hisp.dhis.common.GenericIdentifiableObjectStore;
-import org.hisp.dhis.setting.SystemSetting;
import org.junit.Test;
/**
* @author Stian Strandli
- * @version $Id: SystemSettingStoreTest.java 4866 2008-04-11 10:40:35Z larshelg $
*/
public class SystemSettingStoreTest
extends DhisSpringTest
{
- private GenericIdentifiableObjectStore<SystemSetting> systemSettingStore;
+ private SystemSettingStore systemSettingStore;
private SystemSetting settingA;
private SystemSetting settingB;
private SystemSetting settingC;
@Override
- @SuppressWarnings( "unchecked" )
public void setUpTest()
throws Exception
{
- systemSettingStore = (GenericIdentifiableObjectStore<SystemSetting>) getBean( "org.hisp.dhis.setting.SystemSettingStore" );
+ systemSettingStore = (SystemSettingStore) getBean( "org.hisp.dhis.setting.SystemSettingStore" );
settingA = new SystemSetting();
settingA.setName( "Setting1" );
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientAttributeOptionStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientAttributeOptionStore.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientAttributeOptionStore.java 2013-09-17 18:07:42 +0000
@@ -38,8 +38,6 @@
/**
* @author Viet
- *
- * @version $Id$
*/
public class HibernatePatientAttributeOptionStore
extends HibernateGenericStore<PatientAttributeOption>
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientIdentifierStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientIdentifierStore.java 2013-09-17 06:08:16 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientIdentifierStore.java 2013-09-17 18:07:42 +0000
@@ -33,7 +33,7 @@
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;
-import org.hisp.dhis.hibernate.HibernateGenericStore;
+import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.patient.Patient;
import org.hisp.dhis.patient.PatientIdentifier;
@@ -50,7 +50,7 @@
* @version $Id$
*/
public class HibernatePatientIdentifierStore
- extends HibernateGenericStore<PatientIdentifier>
+ extends HibernateIdentifiableObjectStore<PatientIdentifier>
implements PatientIdentifierStore
{
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientcomment/DefaultPatientCommentService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientcomment/DefaultPatientCommentService.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientcomment/DefaultPatientCommentService.java 2013-09-17 18:07:42 +0000
@@ -30,7 +30,7 @@
import java.util.Collection;
-import org.hisp.dhis.common.GenericIdentifiableObjectStore;
+import org.hisp.dhis.common.GenericStore;
/**
* @author Chau Thu Tran
@@ -44,9 +44,9 @@
// Dependencies
// -------------------------------------------------------------------------
- private GenericIdentifiableObjectStore<PatientComment> patientCommentStore;
+ private GenericStore<PatientComment> patientCommentStore;
- public void setPatientCommentStore( GenericIdentifiableObjectStore<PatientComment> patientCommentStore )
+ public void setPatientCommentStore( GenericStore<PatientComment> patientCommentStore )
{
this.patientCommentStore = patientCommentStore;
}
@@ -84,5 +84,4 @@
{
return patientCommentStore.getAll();
}
-
}
=== 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-09-13 11:51:49 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java 2013-09-17 18:07:42 +0000
@@ -28,6 +28,9 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import java.util.HashSet;
+import java.util.List;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Criteria;
@@ -36,13 +39,11 @@
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Criterion;
-import org.hibernate.criterion.Restrictions;
import org.hisp.dhis.common.AccessStringHelper;
import org.hisp.dhis.common.AuditLogUtil;
import org.hisp.dhis.common.BaseIdentifiableObject;
-import org.hisp.dhis.common.GenericNameableObjectStore;
+import org.hisp.dhis.common.GenericStore;
import org.hisp.dhis.common.IdentifiableObject;
-import org.hisp.dhis.common.NameableObject;
import org.hisp.dhis.common.SharingUtils;
import org.hisp.dhis.dashboard.Dashboard;
import org.hisp.dhis.hibernate.exception.CreateAccessDeniedException;
@@ -50,24 +51,17 @@
import org.hisp.dhis.hibernate.exception.ReadAccessDeniedException;
import org.hisp.dhis.hibernate.exception.UpdateAccessDeniedException;
import org.hisp.dhis.user.CurrentUserService;
-import org.hisp.dhis.user.User;
import org.hisp.dhis.user.UserGroupAccess;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.util.CollectionUtils;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-
/**
* @author Lars Helge Overland
*/
public class HibernateGenericStore<T>
- implements GenericNameableObjectStore<T>
+ implements GenericStore<T>
{
private static final Log log = LogFactory.getLog( HibernateGenericStore.class );
@@ -87,9 +81,9 @@
}
@Autowired
- private CurrentUserService currentUserService;
+ protected CurrentUserService currentUserService;
- private Class<T> clazz;
+ protected Class<T> clazz;
/**
* Could be overridden programmatically.
@@ -108,7 +102,7 @@
this.clazz = clazz;
}
- private boolean cacheable = false;
+ protected boolean cacheable = false;
/**
* Could be overridden programmatically.
@@ -318,76 +312,6 @@
}
@Override
- public final T getByUid( String uid )
- {
- T object = getObject( Restrictions.eq( "uid", uid ) );
-
- if ( !isReadAllowed( object ) )
- {
- AuditLogUtil.infoWrapper( log, currentUserService.getCurrentUsername(), object, AuditLogUtil.ACTION_READ_DENIED );
- throw new ReadAccessDeniedException( object.toString() );
- }
-
- return object;
- }
-
- @Override
- public final T getByUidNoAcl( String uid )
- {
- return getObject( Restrictions.eq( "uid", uid ) );
- }
-
- @Override
- public final void updateNoAcl( T object )
- {
- sessionFactory.getCurrentSession().update( object );
- }
-
- @Override
- @Deprecated
- public final T getByName( String name )
- {
- T object = getObject( Restrictions.eq( "name", name ) );
-
- if ( !isReadAllowed( object ) )
- {
- AuditLogUtil.infoWrapper( log, currentUserService.getCurrentUsername(), object, AuditLogUtil.ACTION_READ_DENIED );
- throw new ReadAccessDeniedException( object.toString() );
- }
-
- return object;
- }
-
- @Override
- @Deprecated
- public final T getByShortName( String shortName )
- {
- T object = getObject( Restrictions.eq( "shortName", shortName ) );
-
- if ( !isReadAllowed( object ) )
- {
- AuditLogUtil.infoWrapper( log, currentUserService.getCurrentUsername(), object, AuditLogUtil.ACTION_READ_DENIED );
- throw new ReadAccessDeniedException( object.toString() );
- }
-
- return object;
- }
-
- @Override
- public final T getByCode( String code )
- {
- T object = getObject( Restrictions.eq( "code", code ) );
-
- if ( !isReadAllowed( object ) )
- {
- AuditLogUtil.infoWrapper( log, currentUserService.getCurrentUsername(), object, AuditLogUtil.ACTION_READ_DENIED );
- throw new ReadAccessDeniedException( object.toString() );
- }
-
- return object;
- }
-
- @Override
public final void delete( T object )
{
if ( !isDeleteAllowed( object ) )
@@ -428,309 +352,6 @@
}
@Override
- @SuppressWarnings("unchecked")
- public List<T> getAllEqName( String name )
- {
- Query query = sharingEnabled() ? getQueryAllEqNameAcl( name ) : getQueryAllEqName( name );
-
- return query.list();
- }
-
- private Query getQueryAllEqNameAcl( String name )
- {
- String hql = "select distinct c from " + clazz.getName() + " c"
- + " where name = :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";
-
- Query query = getQuery( hql );
- query.setEntity( "user", currentUserService.getCurrentUser() );
- query.setString( "name", name );
-
- return query;
- }
-
- private Query getQueryAllEqName( String name )
- {
- Query query = getQuery( "from " + clazz.getName() + " c where name = :name order by c.name" );
- query.setString( "name", name );
-
- return query;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public List<T> getAllEqNameIgnoreCase( String name )
- {
- Query query = sharingEnabled() ? getQueryAllEqNameAclIgnoreCase( name ) : getQueryAllEqNameIgnoreCase( name );
-
- return query.list();
- }
-
- private Query getQueryAllEqNameAclIgnoreCase( String name )
- {
- String hql = "select distinct c from " + clazz.getName() + " c"
- + " where lower(name) = :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";
-
- Query query = getQuery( hql );
- query.setEntity( "user", currentUserService.getCurrentUser() );
- query.setString( "name", name.toLowerCase() );
-
- return query;
- }
-
- private Query getQueryAllEqNameIgnoreCase( String name )
- {
- Query query = getQuery( "from " + clazz.getName() + " c where lower(name) = :name order by c.name" );
- query.setString( "name", name.toLowerCase() );
-
- return query;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public List<T> getAllEqShortName( String shortName )
- {
- Query query = sharingEnabled() ? getQueryAllEqShortNameAcl( shortName ) : getQueryAllEqShortName( shortName );
-
- return query.list();
- }
-
- private Query getQueryAllEqShortNameAcl( String shortName )
- {
- String hql = "select distinct c from " + clazz.getName() + " c"
- + " where shortName = :shortName 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.shortName";
-
- Query query = getQuery( hql );
- query.setEntity( "user", currentUserService.getCurrentUser() );
- query.setString( "shortName", shortName );
-
- return query;
- }
-
- private Query getQueryAllEqShortName( String shortName )
- {
- Query query = getQuery( "from " + clazz.getName() + " c where shortName = :shortName order by c.shortName" );
- query.setString( "shortName", shortName );
-
- return query;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public List<T> getAllEqShortNameIgnoreCase( String shortName )
- {
- Query query = sharingEnabled() ? getQueryAllEqShortNameAclIgnoreCase( shortName ) : getQueryAllEqShortNameIgnoreCase( shortName );
-
- return query.list();
- }
-
- private Query getQueryAllEqShortNameAclIgnoreCase( String shortName )
- {
- String hql = "select distinct c from " + clazz.getName() + " c"
- + " where lower(shortName) = :shortName 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.shortName";
-
- Query query = getQuery( hql );
- query.setEntity( "user", currentUserService.getCurrentUser() );
- query.setString( "shortName", shortName.toLowerCase() );
-
- return query;
- }
-
- private Query getQueryAllEqShortNameIgnoreCase( String shortName )
- {
- Query query = getQuery( "from " + clazz.getName() + " c where lower(shortName) = :shortName order by c.shortName" );
- query.setString( "shortName", shortName.toLowerCase() );
-
- return query;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public List<T> getAllLikeName( String name )
- {
- Query query = sharingEnabled() ? getQueryAllLikeNameAcl( name ) : getQueryAllLikeName( name );
-
- return query.list();
- }
-
- 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 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";
-
- Query query = getQuery( hql );
- query.setEntity( "user", currentUserService.getCurrentUser() );
- query.setString( "name", "%" + name.toLowerCase() + "%" );
-
- return query;
- }
-
- private Query getQueryAllLikeName( String name )
- {
- Query query = getQuery( "from " + clazz.getName() + " c where lower(name) like :name order by c.name" );
- query.setString( "name", "%" + name.toLowerCase() + "%" );
-
- return query;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public List<T> getAllLikeShortName( String shortName )
- {
- if ( NameableObject.class.isAssignableFrom( clazz ) )
- {
- Query query = sharingEnabled() ? getQueryAllLikeShortNameAcl( shortName ) : getQueryAllLikeShortName( shortName );
- return query.list();
- }
-
- // fallback to using name
- return getAllLikeName( shortName );
- }
-
- private Query getQueryAllLikeShortNameAcl( String shortName )
- {
- String hql = "select distinct c from " + clazz.getName() + " c"
- + " where lower(shortName) like :shortName 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.shortName";
-
- Query query = getQuery( hql );
- query.setEntity( "user", currentUserService.getCurrentUser() );
- query.setString( "shortName", "%" + shortName.toLowerCase() + "%" );
-
- return query;
- }
-
- private Query getQueryAllLikeShortName( String shortName )
- {
- Query query = getQuery( "from " + clazz.getName() + " c where lower(shortName) like :shortName order by c.shortName" );
- query.setString( "shortName", "%" + shortName.toLowerCase() + "%" );
-
- return query;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public final List<T> getAllOrderedName()
- {
- Query query = sharingEnabled() ? getQueryAllOrderedNameAcl() : getQueryAllOrderedName();
-
- return query.list();
- }
-
- private Query getQueryAllOrderedNameAcl()
- {
- String hql = "select distinct c from " + clazz.getName() + " c"
- + " 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";
-
- Query query = getQuery( hql );
- query.setEntity( "user", currentUserService.getCurrentUser() );
-
- return query;
- }
-
- private Query getQueryAllOrderedName()
- {
- return getQuery( "from " + clazz.getName() + " c order by c.name" );
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public List<T> getAllOrderedName( int first, int max )
- {
- Query query = sharingEnabled() ? getQueryAllOrderedNameAcl() : getQueryAllOrderedName();
-
- query.setFirstResult( first );
- query.setMaxResults( max );
-
- return query.list();
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public List<T> getAllOrderedLastUpdated( int first, int max )
- {
- Query query = sharingEnabled() ? getQueryAllOrderedLastUpdatedAcl() : getQueryAllOrderedLastUpdated();
-
- query.setFirstResult( first );
- query.setMaxResults( max );
-
- return query.list();
- }
-
- private Query getQueryAllOrderedLastUpdatedAcl()
- {
- String hql = "select distinct c from " + clazz.getName() + " c"
- + " 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";
-
- Query query = getQuery( hql );
- query.setEntity( "user", currentUserService.getCurrentUser() );
-
- return query;
- }
-
- private Query getQueryAllOrderedLastUpdated()
- {
- return getQuery( "from " + clazz.getName() + " c order by lastUpdated desc" );
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public List<T> getAllLikeNameOrderedName( String name, int first, int max )
- {
- Query query = sharingEnabled() ? getQueryAllLikeNameOrderedNameAcl( name ) : getQueryAllLikeNameOrderedName( name );
-
- query.setFirstResult( first );
- query.setMaxResults( max );
-
- return query.list();
- }
-
- 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 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";
-
- Query query = getQuery( hql );
- query.setString( "name", "%" + name.toLowerCase() + "%" );
- query.setEntity( "user", currentUserService.getCurrentUser() );
-
- return query;
- }
-
- private Query getQueryAllLikeNameOrderedName( String name )
- {
- Query query = getQuery( "from " + clazz.getName() + " c where lower(name) like :name order by name" );
- query.setString( "name", "%" + name.toLowerCase() + "%" );
-
- return query;
- }
-
- @Override
public int getCount()
{
Query query = sharingEnabled() ? getQueryCountAcl() : getQueryCount();
@@ -756,217 +377,6 @@
return getQuery( "select count(distinct c) from " + clazz.getName() + " c" );
}
- @Override
- public int getCountLikeName( String name )
- {
- Query query = sharingEnabled() ? getQueryCountLikeNameAcl( name ) : getQueryCountLikeName( name );
-
- return ((Long) query.uniqueResult()).intValue();
- }
-
- 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 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%')"
- + " )";
-
- Query query = getQuery( hql );
- query.setEntity( "user", currentUserService.getCurrentUser() );
- query.setString( "name", "%" + name.toLowerCase() + "%" );
-
- return query;
- }
-
- private Query getQueryCountLikeName( String name )
- {
- Query query = getQuery( "select count(distinct c) from " + clazz.getName() + " c where lower(name) like :name" );
- query.setString( "name", "%" + name.toLowerCase() + "%" );
-
- return query;
- }
-
- @Override
- public long getCountGeLastUpdated( Date lastUpdated )
- {
- Query query = sharingEnabled() ? getQueryCountGeLastUpdatedAcl( lastUpdated ) : getQueryCountGeLastUpdated( lastUpdated );
-
- return ((Long) query.uniqueResult()).intValue();
- }
-
- 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 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%')"
- + " )";
-
- Query query = getQuery( hql );
- query.setEntity( "user", currentUserService.getCurrentUser() );
- query.setTimestamp( "lastUpdated", lastUpdated );
-
- return query;
- }
-
- private Query getQueryCountGeLastUpdated( Date lastUpdated )
- {
- Query query = getQuery( "select count(distinct c) from " + clazz.getName() + " c where lastUpdated >= :lastUpdated" );
- query.setTimestamp( "lastUpdated", lastUpdated );
-
- return query;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public List<T> getAllGeLastUpdated( Date lastUpdated )
- {
- Query query = sharingEnabled() ? getQueryAllGeLastUpdatedAcl( lastUpdated ) : getQueryAllGeLastUpdated( lastUpdated );
-
- return query.list();
- }
-
- 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 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%')"
- + " )";
-
- Query query = getQuery( hql );
- query.setEntity( "user", currentUserService.getCurrentUser() );
- query.setTimestamp( "lastUpdated", lastUpdated );
-
- return query;
- }
-
- private Query getQueryAllGeLastUpdated( Date lastUpdated )
- {
- Query query = getQuery( "from " + clazz.getName() + " c where c.lastUpdated >= :lastUpdated" );
- query.setTimestamp( "lastUpdated", lastUpdated );
-
- return query;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public List<T> getAllGeCreated( Date created )
- {
- Query query = sharingEnabled() ? getQueryAllGeCreatedAcl( created ) : getQueryAllGeCreated( created );
-
- return query.list();
- }
-
- 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 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";
-
- Query query = getQuery( hql );
- query.setEntity( "user", currentUserService.getCurrentUser() );
- query.setTimestamp( "created", created );
-
- return query;
- }
-
- private Query getQueryAllGeCreated( Date created )
- {
- Query query = getQuery( "from " + clazz.getName() + " c where c.created >= :created" );
- query.setTimestamp( "created", created );
-
- return query;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public List<T> getAllGeLastUpdatedOrderedName( Date lastUpdated )
- {
- Query query = sharingEnabled() ? getQueryAllGeLastUpdatedOrderedNameAcl( lastUpdated ) : getQueryAllGeLastUpdatedOrderedName( lastUpdated );
-
- return query.list();
- }
-
- 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 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";
-
- Query query = getQuery( hql );
- query.setEntity( "user", currentUserService.getCurrentUser() );
- query.setTimestamp( "lastUpdated", lastUpdated );
-
- return query;
- }
-
- private Query getQueryAllGeLastUpdatedOrderedName( Date lastUpdated )
- {
- Query query = getQuery( "from " + clazz.getName() + " c where c.lastUpdated >= :lastUpdated order by c.name" );
- query.setTimestamp( "lastUpdated", lastUpdated );
-
- return query;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public List<T> getByUser( User user )
- {
- Query query = getQuery( "from " + clazz.getName() + " c where user = :user" );
- query.setEntity( "user", user );
-
- return query.list();
- }
-
- @Override
- public List<T> getByUid( Collection<String> uids )
- {
- List<T> list = new ArrayList<T>();
-
- if ( uids != null )
- {
- for ( String uid : uids )
- {
- T object = getByUid( uid );
-
- if ( object != null )
- {
- list.add( object );
- }
- }
- }
-
- return list;
- }
-
- //----------------------------------------------------------------------------------------------------------------
- // No ACL (unfiltered methods)
- //----------------------------------------------------------------------------------------------------------------
-
- @Override
- public int getCountEqNameNoAcl( String name )
- {
- Query query = getQuery( "select count(distinct c) from " + clazz.getName() + " c where c.name = :name" );
- query.setParameter( "name", name );
-
- return ((Long) query.uniqueResult()).intValue();
- }
-
- @Override
- public int getCountEqShortNameNoAcl( String shortName )
- {
- Query query = getQuery( "select count(distinct c) from " + clazz.getName() + " c where c.shortName = :shortName" );
- query.setParameter( "shortName", shortName );
-
- return ((Long) query.uniqueResult()).intValue();
- }
-
//----------------------------------------------------------------------------------------------------------------
// Helpers
//----------------------------------------------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/style/dashboard.css'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/style/dashboard.css 2013-09-17 17:15:10 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/style/dashboard.css 2013-09-17 18:07:42 +0000
@@ -474,7 +474,7 @@
{
color: #777;
font-size: 11pt;
- margin-bottom: 9px;
+ margin-bottom: 15px;
}
.interpretationContainer
@@ -530,7 +530,7 @@
.commentArea
{
height: 18px;
- width: 360px;
+ width: 390px;
border: 1px solid #ccc;
resize: none;
overflow: auto;