=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectUtils.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectUtils.java 2013-08-23 15:56:19 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectUtils.java 2013-09-04 08:34:55 +0000 @@ -29,7 +29,12 @@ */ import java.text.SimpleDateFormat; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; /** * @author Lars Helge Overland @@ -66,17 +71,17 @@ return null; } - + /** * Returns a list of uids for the given collection of IdentifiableObjects. - * + * * @param objects the list of IdentifiableObjects. * @return a list of uids. */ public static List getUids( Collection objects ) { List uids = new ArrayList(); - + if ( objects != null ) { for ( T object : objects ) @@ -84,10 +89,10 @@ uids.add( object.getUid() ); } } - + return uids; } - + /** * Filters the given list of IdentifiableObjects based on the given key. * @@ -97,7 +102,7 @@ * @return a filtered list of IdentifiableObjects. */ public static List filterNameByKey( List identifiableObjects, String key, - boolean ignoreCase ) + boolean ignoreCase ) { List objects = new ArrayList(); ListIterator iterator = identifiableObjects.listIterator(); @@ -120,17 +125,17 @@ return objects; } - + /** * Returns a list of IdentifiableObjects. - * + * * @param objects the IdentifiableObjects to include in the list. * @return a list of IdentifiableObjects. */ public static List getList( IdentifiableObject... objects ) { List list = new ArrayList(); - + if ( objects != null ) { for ( IdentifiableObject object : objects ) @@ -138,13 +143,13 @@ list.add( object ); } } - + return list; } - + /** * Returns a list with erasure IdentifiableObject based on the given collection. - * + * * @param collection the collection. * @return a list of IdentifiableObjects. */ @@ -154,12 +159,12 @@ list.addAll( collection ); return list; } - + /** * Returns a list typed with the desired erasure based on the given collection. * This operation implies an unchecked cast and it is the responsibility of * the caller to make sure the cast is valid. - * + * * @param collection the collection. * @return a list. */ @@ -167,7 +172,7 @@ public static List asTypedList( Collection collection ) { List list = new ArrayList(); - + if ( collection != null ) { for ( IdentifiableObject object : collection ) @@ -175,13 +180,13 @@ list.add( (T) object ); } } - + return list; } /** * Removes duplicates from the given list while maintaining the order. - * + * * @param list the list. */ public static List removeDuplicates( List list ) @@ -215,7 +220,7 @@ { for ( IdentifiableObject object : objects ) { - if ( object != null && object.getLastUpdated() != null && ( latest == null || object.getLastUpdated().after( latest ) ) ) + if ( object != null && object.getLastUpdated() != null && (latest == null || object.getLastUpdated().after( latest )) ) { latest = object.getLastUpdated(); } @@ -224,10 +229,10 @@ return latest != null && objects != null ? objects.size() + SEPARATOR + LONG_DATE_FORMAT.format( latest ) : null; } - + /** * Generates a tag reflecting the date of when the object was last updated. - * + * * @param object the identifiable object. * @return a string tag. */ @@ -235,4 +240,22 @@ { return object != null ? LONG_DATE_FORMAT.format( object.getLastUpdated() ) : null; } + + /** + * Returns a list of database identifiers from a list of idObjects + * + * @param identifiableObjects Collection of idObjects + * @return List of database identifiers for idObjects + */ + public static List getIdList( Collection identifiableObjects ) + { + List integers = new ArrayList(); + + for ( IdentifiableObject identifiableObject : identifiableObjects ) + { + integers.add( identifiableObject.getId() ); + } + + return integers; + } } === modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/DefaultEventStore.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/DefaultEventStore.java 2013-09-03 18:28:38 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/DefaultEventStore.java 2013-09-04 08:34:55 +0000 @@ -42,6 +42,8 @@ import java.util.Date; import java.util.List; +import static org.hisp.dhis.common.IdentifiableObjectUtils.getIdList; + /** * @author Morten Olav Hansen */ @@ -138,18 +140,6 @@ return events; } - private List getIdList( List identifiableObjects ) - { - List integers = new ArrayList(); - - for ( IdentifiableObject identifiableObject : identifiableObjects ) - { - integers.add( identifiableObject.getId() ); - } - - return integers; - } - private String buildSql( List programIds, List programStageIds, List orgUnitIds, Date startDate, Date endDate ) { String sql = "select p.uid as p_uid, ps.uid as ps_uid, psi.uid as psi_uid, ou.uid as ou_uid, psi.executiondate as psi_executiondate," +