=== 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 2015-01-17 07:41:26 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateIdentifiableObjectStore.java 2015-02-09 09:52:30 +0000 @@ -28,12 +28,6 @@ * 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 java.util.Set; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hibernate.Query; @@ -48,6 +42,12 @@ import org.hisp.dhis.hibernate.HibernateGenericStore; import org.hisp.dhis.hibernate.exception.ReadAccessDeniedException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.Set; + /** * @author bobj */ @@ -136,9 +136,9 @@ public final T getByName( String name ) { List list = getList( Restrictions.eq( "name", name ) ); - + T object = list != null && !list.isEmpty() ? list.get( 0 ) : null; - + if ( !isReadAllowed( object ) ) { AuditLogUtil.infoWrapper( log, currentUserService.getCurrentUsername(), object, AuditLogUtil.ACTION_READ_DENIED ); @@ -157,7 +157,7 @@ List list = getList( Restrictions.eq( "shortName", shortName ) ); T object = list != null && !list.isEmpty() ? list.get( 0 ) : null; - + if ( !isReadAllowed( object ) ) { AuditLogUtil.infoWrapper( log, currentUserService.getCurrentUsername(), object, AuditLogUtil.ACTION_READ_DENIED ); @@ -187,7 +187,7 @@ } @Override - @SuppressWarnings("unchecked") + @SuppressWarnings( "unchecked" ) public List getAllEqName( String name ) { return getSharingCriteria() @@ -197,7 +197,7 @@ } @Override - @SuppressWarnings("unchecked") + @SuppressWarnings( "unchecked" ) public List getAllEqNameIgnoreCase( String name ) { return getSharingCriteria() @@ -207,7 +207,7 @@ } @Override - @SuppressWarnings("unchecked") + @SuppressWarnings( "unchecked" ) public List getAllEqShortName( String shortName ) { return getSharingCriteria() @@ -217,7 +217,7 @@ } @Override - @SuppressWarnings("unchecked") + @SuppressWarnings( "unchecked" ) public List getAllEqShortNameIgnoreCase( String shortName ) { return getSharingCriteria() @@ -227,7 +227,7 @@ } @Override - @SuppressWarnings("unchecked") + @SuppressWarnings( "unchecked" ) public List getAllLikeName( String name ) { return getSharingCriteria() @@ -237,7 +237,7 @@ } @Override - @SuppressWarnings("unchecked") + @SuppressWarnings( "unchecked" ) public List getAllLikeName( String name, int first, int max ) { return getSharingCriteria() @@ -249,16 +249,16 @@ } @Override - @SuppressWarnings("unchecked") + @SuppressWarnings( "unchecked" ) public List getAllLikeName( Set nameWords, int first, int max ) { Conjunction conjunction = Restrictions.conjunction(); - + for ( String word : nameWords ) { conjunction.add( Restrictions.like( "name", "%" + word + "%" ).ignoreCase() ); } - + return getSharingCriteria() .add( conjunction ) .addOrder( Order.asc( "name" ) ) @@ -268,7 +268,7 @@ } @Override - @SuppressWarnings("unchecked") + @SuppressWarnings( "unchecked" ) public List getAllLikeShortName( String shortName ) { if ( NameableObject.class.isAssignableFrom( clazz ) ) @@ -283,7 +283,7 @@ } @Override - @SuppressWarnings("unchecked") + @SuppressWarnings( "unchecked" ) public List getAllOrderedName() { return getSharingCriteria() @@ -292,7 +292,7 @@ } @Override - @SuppressWarnings("unchecked") + @SuppressWarnings( "unchecked" ) public List getAllOrderedName( int first, int max ) { return getSharingCriteria() @@ -302,7 +302,7 @@ } @Override - @SuppressWarnings("unchecked") + @SuppressWarnings( "unchecked" ) public List getAllOrderedLastUpdated() { return getSharingCriteria() @@ -311,7 +311,7 @@ } @Override - @SuppressWarnings("unchecked") + @SuppressWarnings( "unchecked" ) public List getAllOrderedLastUpdated( int first, int max ) { return getSharingCriteria() @@ -366,7 +366,7 @@ } @Override - @SuppressWarnings("unchecked") + @SuppressWarnings( "unchecked" ) public List getAllGeLastUpdated( Date lastUpdated ) { return getSharingCriteria() @@ -385,7 +385,7 @@ } @Override - @SuppressWarnings("unchecked") + @SuppressWarnings( "unchecked" ) public List getAllGeCreated( Date created ) { return getSharingCriteria() @@ -395,7 +395,7 @@ } @Override - @SuppressWarnings("unchecked") + @SuppressWarnings( "unchecked" ) public List getAllGeCreatedOrderedName( Date created ) { return getSharingCriteria() @@ -405,7 +405,7 @@ } @Override - @SuppressWarnings("unchecked") + @SuppressWarnings( "unchecked" ) public List getAllGeLastUpdatedOrderedName( Date lastUpdated ) { return getSharingCriteria() @@ -420,11 +420,11 @@ return (Date) getClazzCriteria().setProjection( Projections.property( "lastUpdated" ) ) .addOrder( Order.desc( "lastUpdated" ) ) .setMaxResults( 1 ) - .setCacheable( true ).uniqueResult(); + .setCacheable( true ).uniqueResult(); } @Override - @SuppressWarnings("unchecked") + @SuppressWarnings( "unchecked" ) public List getByDataDimension( boolean dataDimension ) { return getSharingCriteria() @@ -432,24 +432,15 @@ } @Override + @SuppressWarnings( "unchecked" ) public List getByUid( Collection uids ) { - List list = new ArrayList<>(); - - if ( uids != null ) + if ( uids == null ) { - for ( String uid : uids ) - { - T object = getByUid( uid ); - - if ( object != null ) - { - list.add( object ); - } - } + return new ArrayList<>(); } - return list; + return getSharingCriteria().add( Restrictions.in( "uid", uids ) ).list(); } @Override