← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5952: fixed paging for lock exceptions

 

------------------------------------------------------------
revno: 5952
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-02-14 14:51:50 +0700
message:
  fixed paging for lock exceptions
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/LockExceptionStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateLockExceptionStore.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/lockexception/GetLockExceptionListAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/lockException.vm


--
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/dataset/LockExceptionStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/LockExceptionStore.java	2012-02-14 02:58:08 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/LockExceptionStore.java	2012-02-14 07:51:50 +0000
@@ -40,6 +40,8 @@
 {
     String ID = LockExceptionStore.class.getName();
 
+    Collection<LockException> getBetween( int first, int max );
+
     Collection<LockException> getCombinations();
 
     void deleteCombination( DataSet dataSet, Period period );

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java	2012-02-14 02:58:08 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java	2012-02-14 07:51:50 +0000
@@ -376,8 +376,7 @@
     @Override
     public Collection<LockException> getLockExceptionsBetween( int first, int max )
     {
-        // FIXME extend lockExceptionStore to include HQL query for this
-        return getAllLockExceptions();
+        return lockExceptionStore.getBetween( first, max );
     }
 
     @Override

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateLockExceptionStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateLockExceptionStore.java	2012-02-14 02:58:08 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateLockExceptionStore.java	2012-02-14 07:51:50 +0000
@@ -27,6 +27,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import org.hibernate.Criteria;
 import org.hibernate.Query;
 import org.hibernate.Session;
 import org.hisp.dhis.dataset.DataSet;
@@ -116,4 +117,14 @@
 //        final String sql = "DELETE FROM LockException WHERE dataSetId=? AND periodId=?";
 //        jdbcTemplate.update( sql, new Object[]{dataSet.getId(), period.getId()} );
     }
+
+    @Override
+    public Collection<LockException> getBetween( int first, int max )
+    {
+        Criteria criteria = getCriteria();
+        criteria.setFirstResult( first );
+        criteria.setMaxResults( max );
+
+        return criteria.list();
+    }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/lockexception/GetLockExceptionListAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/lockexception/GetLockExceptionListAction.java	2012-02-14 07:18:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/lockexception/GetLockExceptionListAction.java	2012-02-14 07:51:50 +0000
@@ -72,17 +72,7 @@
         return lockExceptions;
     }
 
-    private String key;
-
-    public String getKey()
-    {
-        return key;
-    }
-
-    public void setKey( String key )
-    {
-        this.key = key;
-    }
+    private boolean usePaging = true;
 
     // -------------------------------------------------------------------------
     // Action implementation
@@ -91,21 +81,23 @@
     @Override
     public String execute()
     {
-        lockExceptions = new ArrayList<LockException>( dataSetService.getAllLockExceptions() );
+        if ( usePaging )
+        {
+            paging = createPaging( dataSetService.getLockExceptionCount() );
+            lockExceptions = new ArrayList<LockException>( dataSetService.getLockExceptionsBetween( paging.getStartPos(), paging.getEndPos() ) );
+        }
+        else
+        {
+            lockExceptions = new ArrayList<LockException>( dataSetService.getAllLockExceptions() );
+        }
+
+        Collections.sort( lockExceptions, new LockExceptionNameComparator() );
 
         for ( LockException lockException : lockExceptions )
         {
             lockException.getPeriod().setName( format.formatPeriod( lockException.getPeriod() ) );
         }
 
-        Collections.sort( lockExceptions, new LockExceptionNameComparator() );
-
-        if ( usePaging )
-        {
-            paging = createPaging( dataSetService.getLockExceptionCount() );
-            lockExceptions = lockExceptions.subList( paging.getStartPos(), paging.getEndPos() );
-        }
-
         return SUCCESS;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/lockException.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/lockException.vm	2012-02-14 02:58:08 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/lockException.vm	2012-02-14 07:51:50 +0000
@@ -30,7 +30,6 @@
 		<td style="vertical-align:top">
 			<table width="100%">
 				<tr>
-					<td>#filterDiv( "lockException" )</td>
 					<td colspan="4" style="text-align:right">
                         <input type="button" value="$i18n.getString( 'batch_delete' )" onclick="window.location.href='showLockExceptionBatchRemoval.action'" style="width:100px"/>
                         <input type="button" value="$i18n.getString( 'add_new' )" onclick="window.location.href='showAddLockExceptionForm.action'" style="width:80px"/>