From e14b484ca5d6b85c663852948d07a75842835106 Mon Sep 17 00:00:00 2001 From: Willem Cazander Date: Sun, 24 Aug 2014 12:49:32 +0200 Subject: [PATCH] Removed old total fetch method. --- .../vasc/backend/AbstractVascBackend.java | 39 ++++--------------- .../backend/DefaultVascBackendResult.java | 6 ++- .../forwardfire/vasc/backend/VascBackend.java | 8 ---- .../jpa/XpqlHibernateVascBackend.java | 18 ++++----- .../jpa/XpqlPersistanceVascBackend.java | 17 ++++---- .../metamodel/MetaModelVascBackend.java | 16 ++++---- .../backend/mongodb/MongodbVascBackend.java | 14 +++---- .../proxy/AbstractVascBackendProxy.java | 25 ------------ .../backend/proxy/VascBackendProxyCache.java | 16 ++------ .../proxy/VascBackendProxyEventExecutor.java | 25 ++++-------- .../backend/proxy/VascBackendProxyFilter.java | 9 +---- .../backend/proxy/VascBackendProxyPaged.java | 11 +----- .../backend/proxy/VascBackendProxySearch.java | 5 --- .../proxy/VascBackendProxyTimerLogger.java | 23 +++-------- .../entry/VascEntryBackendEventListener.java | 2 - .../entry/SetParameterBackendListener.java | 3 +- .../frontend/DefaultVascFrontendActions.java | 27 ++++++------- .../web/export/VascExportServlet.java | 3 -- 18 files changed, 77 insertions(+), 190 deletions(-) diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackend.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackend.java index 4319b4b..40b4c1d 100644 --- a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackend.java +++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackend.java @@ -23,9 +23,10 @@ package net.forwardfire.vasc.backend; import java.io.Serializable; -import java.util.Map; /** + * AbstractVascBackend. + * * * @author Willem Cazander * @version 1.0 Aug 2, 2007 @@ -59,14 +60,14 @@ abstract public class AbstractVascBackend impl @Override public void startBackend() { } - + /** * @see net.forwardfire.vasc.backend.VascBackend#stopBackend() */ @Override public void stopBackend() { } - + /** * @see net.forwardfire.vasc.backend.VascBackend#isReadOnly() */ @@ -74,7 +75,7 @@ abstract public class AbstractVascBackend impl public boolean isReadOnly() { return false; } - + /** * @see net.forwardfire.vasc.backend.VascBackend#isPageable() */ @@ -83,14 +84,6 @@ abstract public class AbstractVascBackend impl return false; } - /** - * @see net.forwardfire.vasc.backend.VascBackend#fetchTotalExecuteSize(VascBackendState state) - */ - @Override - public long fetchTotalExecuteSize(VascBackendState state) { - return 0; - } - /** * @see net.forwardfire.vasc.backend.VascBackend#isSearchable() */ @@ -122,7 +115,7 @@ abstract public class AbstractVascBackend impl public long doRecordMoveDownById(VascBackendState state,Object primaryId) throws VascBackendException { return 0l; } - + /** * @see net.forwardfire.vasc.backend.VascBackend#doRecordMoveUpById(java.lang.Object) */ @@ -130,23 +123,7 @@ abstract public class AbstractVascBackend impl public long doRecordMoveUpById(VascBackendState state,Object primaryId) throws VascBackendException { return 0l; } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#executePageSummary() - */ - @Override - public Map executePageSummary() { - return null; - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#executeTotalSummary() - */ - @Override - public Map executeTotalSummary() { - return null; - } - + /** * @see net.forwardfire.vasc.backend.VascBackend#hasPageSummary() */ @@ -154,7 +131,7 @@ abstract public class AbstractVascBackend impl public boolean hasPageSummary() { return false; } - + /** * @see net.forwardfire.vasc.backend.VascBackend#hasTotalSummary() */ diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/DefaultVascBackendResult.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/DefaultVascBackendResult.java index 55a8867..68d113c 100644 --- a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/DefaultVascBackendResult.java +++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/DefaultVascBackendResult.java @@ -35,7 +35,11 @@ import java.util.Map; public final class DefaultVascBackendResult extends AbstractVascBackendResult { public DefaultVascBackendResult(List pageData) { - this(pageData,-1,null,null); + this(pageData,-1); + } + + public DefaultVascBackendResult(List pageData,long totalSize) { + this(pageData,totalSize,null,null); } public DefaultVascBackendResult(List pageData, long totalSize, diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackend.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackend.java index 5d666b6..76ce899 100644 --- a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackend.java +++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackend.java @@ -77,12 +77,6 @@ public interface VascBackend { * @return */ public boolean isPageable(); - - /** - * Returns the total amount of records. - * @return - */ - public long fetchTotalExecuteSize(VascBackendState state); /** * Defines if the backend supports pageing @@ -100,8 +94,6 @@ public interface VascBackend { public boolean hasPageSummary(); - public Map executePageSummary(); public boolean hasTotalSummary(); - public Map executeTotalSummary(); } diff --git a/vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/XpqlHibernateVascBackend.java b/vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/XpqlHibernateVascBackend.java index e744c18..c11610d 100644 --- a/vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/XpqlHibernateVascBackend.java +++ b/vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/XpqlHibernateVascBackend.java @@ -75,11 +75,13 @@ public class XpqlHibernateVascBackend extends Session getHibernateSession() { return hibernateSessionProvider.getHibernateSession(); } - - @SuppressWarnings("unchecked") + @Override public VascBackendResult execute(VascBackendState state) throws VascBackendException { - + return new DefaultVascBackendResult(executeList(state),fetchTotalExecuteSize(state)); + } + + private List executeList(VascBackendState state) throws VascBackendException { // Copy parameters for (String key:state.getDataParameterKeys()) { Object value = state.getDataParameter(key); @@ -111,7 +113,7 @@ public class XpqlHibernateVascBackend extends List data = q.list(); s.getTransaction().commit(); - return new DefaultVascBackendResult(data); + return data; } finally { if (s!=null) { //em.close(); @@ -202,12 +204,8 @@ public class XpqlHibernateVascBackend extends } return true; } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#fetchTotalExecuteSize(VascBackendState state) - */ - @Override - public long fetchTotalExecuteSize(VascBackendState state) { + + private long fetchTotalExecuteSize(VascBackendState state) { Session s = getHibernateSession(); try { s.getTransaction().begin(); diff --git a/vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/XpqlPersistanceVascBackend.java b/vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/XpqlPersistanceVascBackend.java index caf8cbf..1114fe8 100644 --- a/vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/XpqlPersistanceVascBackend.java +++ b/vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/XpqlPersistanceVascBackend.java @@ -76,9 +76,13 @@ public class XpqlPersistanceVascBackend extend return entityManagerProvider.getEntityManager(); } - @SuppressWarnings("unchecked") @Override public VascBackendResult execute(VascBackendState state) throws VascBackendException { + return new DefaultVascBackendResult(executeList(state),fetchTotalExecuteSize(state)); + } + + @SuppressWarnings("unchecked") + private List executeList(VascBackendState state) throws VascBackendException { // Copy parameters for (String key:state.getDataParameterKeys()) { @@ -112,8 +116,7 @@ public class XpqlPersistanceVascBackend extend if (emTransaction) { em.getTransaction().commit(); } - VascBackendResult result = new DefaultVascBackendResult(data); - return result; + return data; } finally { if (em!=null) { //em.close(); @@ -205,12 +208,8 @@ public class XpqlPersistanceVascBackend extend } return true; } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#fetchTotalExecuteSize(VascBackendState state) - */ - @Override - public long fetchTotalExecuteSize(VascBackendState state) { + + private long fetchTotalExecuteSize(VascBackendState state) { EntityManager em = getEntityManager(); try { Query q = em.createQuery(queryTotal.toPreparedSQL(queryTotal)); diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelVascBackend.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelVascBackend.java index 964beb2..07fa7be 100644 --- a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelVascBackend.java +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelVascBackend.java @@ -140,12 +140,8 @@ public class MetaModelVascBackend extends AbstractVascBackend { public boolean isSortable() { return true; } - - /** - * @see net.forwardfire.vasc.backend.AbstractVascBackend#fetchTotalExecuteSize(net.forwardfire.vasc.backend.VascBackendState) - */ - @Override - public long fetchTotalExecuteSize(VascBackendState state) { + + private long fetchTotalExecuteSize(VascBackendState state) { Schema schema = dataContext.getDefaultSchema(); Table t = schema.getTableByName(table); Query q = createFilterQuery(state,t,true); @@ -213,6 +209,10 @@ public class MetaModelVascBackend extends AbstractVascBackend { @Override public VascBackendResult execute(VascBackendState state) throws VascBackendException { + return new DefaultVascBackendResult(executeList(state),fetchTotalExecuteSize(state)); + } + + private List executeList(VascBackendState state) throws VascBackendException { Schema schema = dataContext.getDefaultSchema(); Table t = schema.getTableByName(table); if (t==null) { @@ -243,7 +243,7 @@ public class MetaModelVascBackend extends AbstractVascBackend { DataSet ds = crudDataContext.executeQuery(q); result.addAll(ds.toRows()); ds.close(); - return new DefaultVascBackendResult(result); + return result; } DataSet ds = dataContext.executeQuery(q); @@ -261,7 +261,7 @@ public class MetaModelVascBackend extends AbstractVascBackend { } ds.close(); - return new DefaultVascBackendResult(result); + return result; } @Override diff --git a/vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascBackend.java b/vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascBackend.java index 0cd6cb2..3dbe656 100644 --- a/vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascBackend.java +++ b/vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascBackend.java @@ -85,11 +85,7 @@ public class MongodbVascBackend extends AbstractVascBackend { return true; } - /** - * @see net.forwardfire.vasc.backend.AbstractVascBackend#fetchTotalExecuteSize(net.forwardfire.vasc.backend.VascBackendState) - */ - @Override - public long fetchTotalExecuteSize(VascBackendState state) { + private long fetchTotalExecuteSize(VascBackendState state) { DBCollection coll = getDBCollection(); DBObject query = createFilterQuery(state); long result = coll.count(query); @@ -105,9 +101,13 @@ public class MongodbVascBackend extends AbstractVascBackend { } return query; } - + @Override public VascBackendResult execute(VascBackendState state) throws VascBackendException { + return new DefaultVascBackendResult(executeList(state),fetchTotalExecuteSize(state)); + } + + private List executeList(VascBackendState state) throws VascBackendException { DBCollection coll = getDBCollection(); DBObject query = createFilterQuery(state); DBCursor cur = coll.find(query); @@ -120,7 +120,7 @@ public class MongodbVascBackend extends AbstractVascBackend { DBObject row = cur.next(); result.add((BasicDBObject)row); } - return new DefaultVascBackendResult(result); + return result; } @Override diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/AbstractVascBackendProxy.java b/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/AbstractVascBackendProxy.java index 6f78e1d..3091798 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/AbstractVascBackendProxy.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/AbstractVascBackendProxy.java @@ -23,7 +23,6 @@ package net.forwardfire.vasc.backend.proxy; import java.io.Serializable; -import java.util.Map; import net.forwardfire.vasc.backend.VascBackend; import net.forwardfire.vasc.backend.VascBackendException; @@ -94,14 +93,6 @@ abstract public class AbstractVascBackendProxy implements VascBackendProxy { return backend.isReadOnly(); } - /** - * @see net.forwardfire.vasc.backend.VascBackend#fetchTotalExecuteSize(VascBackendState state) - */ - @Override - public long fetchTotalExecuteSize(VascBackendState state) { - return backend.fetchTotalExecuteSize(state); - } - /** * @see net.forwardfire.vasc.backend.VascBackend#isSortable() */ @@ -215,22 +206,6 @@ abstract public class AbstractVascBackendProxy implements VascBackendProxy { return backend.isRecordMoveable(); } - /** - * @see net.forwardfire.vasc.backend.VascBackend#executePageSummary() - */ - @Override - public Map executePageSummary() { - return backend.executePageSummary(); - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#executeTotalSummary() - */ - @Override - public Map executeTotalSummary() { - return backend.executeTotalSummary(); - } - /** * @see net.forwardfire.vasc.backend.VascBackend#hasPageSummary() */ diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxyCache.java b/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxyCache.java index 597cccf..66f8b61 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxyCache.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxyCache.java @@ -38,7 +38,6 @@ import net.forwardfire.vasc.backend.VascBackendState; */ public class VascBackendProxyCache extends AbstractVascBackendProxy { - private Long records = null; private VascBackendResult data = null; private String searchString = null; private Map dataState = null; @@ -89,7 +88,7 @@ public class VascBackendProxyCache extends AbstractVascBackendProxy { changed = true; } sortDir = state.isSortAscending(); - + if (state.getPageSizeMax()==pageSizeMax) { changed = true; } @@ -139,15 +138,6 @@ public class VascBackendProxyCache extends AbstractVascBackendProxy { return data; } - @Override - public long fetchTotalExecuteSize(VascBackendState state) { - boolean changed = isStateChanged(state); - if (records==null | changed) { - records = backend.fetchTotalExecuteSize(state); - } - return records; - } - /** * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#delete(java.lang.Object) */ @@ -156,7 +146,7 @@ public class VascBackendProxyCache extends AbstractVascBackendProxy { requestFlush = true; super.delete(object); } - + /** * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#merge(java.lang.Object) */ @@ -165,7 +155,7 @@ public class VascBackendProxyCache extends AbstractVascBackendProxy { requestFlush = true; return super.merge(object); } - + /** * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#persist(java.lang.Object) */ diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxyEventExecutor.java b/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxyEventExecutor.java index 627bfe9..c394335 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxyEventExecutor.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxyEventExecutor.java @@ -72,7 +72,7 @@ public class VascBackendProxyEventExecutor extends AbstractVascBackendProxy { listeners.add(listener); } } - + public void addVascEntryBackendEventListener(VascEntryBackendEventListener listener) { listeners.add(listener); } @@ -113,7 +113,7 @@ public class VascBackendProxyEventExecutor extends AbstractVascBackendProxy { super.delete(object); fireVascEvent(VascBackendEventType.POST_DELETE,object); } - + /** * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#doRecordMoveDownById(net.forwardfire.vasc.backend.VascBackendState, java.lang.Object) */ @@ -124,7 +124,7 @@ public class VascBackendProxyEventExecutor extends AbstractVascBackendProxy { fireVascEvent(VascBackendEventType.POST_MOVE_DOWN,result); return result; } - + /** * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#doRecordMoveUpById(net.forwardfire.vasc.backend.VascBackendState, java.lang.Object) */ @@ -135,7 +135,7 @@ public class VascBackendProxyEventExecutor extends AbstractVascBackendProxy { fireVascEvent(VascBackendEventType.POST_MOVE_UP,result); return result; } - + /** * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#execute(net.forwardfire.vasc.backend.VascBackendState) */ @@ -146,18 +146,7 @@ public class VascBackendProxyEventExecutor extends AbstractVascBackendProxy { fireVascEvent(VascBackendEventType.POST_EXECUTE,result); return result; } - - /** - * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#fetchTotalExecuteSize(net.forwardfire.vasc.backend.VascBackendState) - */ - @Override - public long fetchTotalExecuteSize(VascBackendState state) { - fireVascEvent(VascBackendEventType.PRE_TOTAL_EXECUTE_SIZE,state); - Long result = super.fetchTotalExecuteSize(state); - fireVascEvent(VascBackendEventType.POST_TOTAL_EXECUTE_SIZE,result); - return result; - } - + /** * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#merge(java.lang.Object) */ @@ -168,7 +157,7 @@ public class VascBackendProxyEventExecutor extends AbstractVascBackendProxy { fireVascEvent(VascBackendEventType.POST_MERGE,result); return result; } - + /** * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#persist(java.lang.Object) */ @@ -177,5 +166,5 @@ public class VascBackendProxyEventExecutor extends AbstractVascBackendProxy { fireVascEvent(VascBackendEventType.PRE_PERSIST,object); super.persist(object); fireVascEvent(VascBackendEventType.POST_PERSIST,object); - } + } } \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxyFilter.java b/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxyFilter.java index 7ac36b2..aeb46b0 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxyFilter.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxyFilter.java @@ -41,7 +41,6 @@ import net.forwardfire.vasc.core.VascEntry; */ public class VascBackendProxyFilter extends AbstractVascBackendProxy { - private long records = 0; private List filters = null; /** @@ -97,12 +96,6 @@ public class VascBackendProxyFilter extends AbstractVascBackendProxy { } } } - records = search.size(); - return new DefaultVascBackendResult(search); - } - - @Override - public long fetchTotalExecuteSize(VascBackendState state) { - return records; + return new DefaultVascBackendResult(search,search.size()); } } \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxyPaged.java b/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxyPaged.java index f94fc1d..1cb5875 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxyPaged.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxyPaged.java @@ -39,8 +39,6 @@ import net.forwardfire.vasc.backend.VascBackendState; */ public class VascBackendProxyPaged extends AbstractVascBackendProxy { - private long records = 0; - /** * @see java.lang.Object#clone() */ @@ -77,7 +75,6 @@ public class VascBackendProxyPaged extends AbstractVascBackendProxy { VascBackendResult allData = backend.execute(state); int pageSize = state.getPageSize(); if (pageSize==0) { - records = allData.getPageData().size(); return allData; } List paged = new ArrayList(state.getPageSize()); @@ -90,12 +87,6 @@ public class VascBackendProxyPaged extends AbstractVascBackendProxy { Serializable o = allData.getPageData().get(i); paged.add(o); } - records = allData.getPageData().size(); - return new DefaultVascBackendResult(paged); - } - - @Override - public long fetchTotalExecuteSize(VascBackendState state) { - return records; + return new DefaultVascBackendResult(paged,allData.getPageData().size()); } } \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxySearch.java b/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxySearch.java index e09ffac..9e1f173 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxySearch.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxySearch.java @@ -137,9 +137,4 @@ public class VascBackendProxySearch extends AbstractVascBackendProxy { //records = search.size(); return new DefaultVascBackendResult(search); } - - @Override - public long fetchTotalExecuteSize(VascBackendState state) { - return backend.fetchTotalExecuteSize(state); - } } \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxyTimerLogger.java b/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxyTimerLogger.java index a486612..09ac070 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxyTimerLogger.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxyTimerLogger.java @@ -69,17 +69,6 @@ public class VascBackendProxyTimerLogger extends AbstractVascBackendProxy { } } - @Override - public long fetchTotalExecuteSize(VascBackendState state) { - long t1 = System.currentTimeMillis(); - try { - return backend.fetchTotalExecuteSize(state); - } finally { - long t2 = System.currentTimeMillis(); - logger.log(logLevel,"vasc-fetchTotalExecuteSize backend: "+getId()+" in "+(t2-t1)+" ms"); - } - } - /** * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#doRecordMoveDownById(net.forwardfire.vasc.backend.VascBackendState, java.lang.Object) */ @@ -93,7 +82,7 @@ public class VascBackendProxyTimerLogger extends AbstractVascBackendProxy { logger.log(logLevel,"vasc-doRecordMoveDownById backend: "+getId()+" in "+(t2-t1)+" ms"); } } - + /** * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#doRecordMoveUpById(net.forwardfire.vasc.backend.VascBackendState, java.lang.Object) */ @@ -107,7 +96,7 @@ public class VascBackendProxyTimerLogger extends AbstractVascBackendProxy { logger.log(logLevel,"vasc-doRecordMoveUpById backend: "+getId()+" in "+(t2-t1)+" ms"); } } - + /** * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#delete(java.lang.Object) */ @@ -121,7 +110,7 @@ public class VascBackendProxyTimerLogger extends AbstractVascBackendProxy { logger.log(logLevel,"vasc-delete backend: "+getId()+" in "+(t2-t1)+" ms"); } } - + /** * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#merge(java.lang.Object) */ @@ -135,7 +124,7 @@ public class VascBackendProxyTimerLogger extends AbstractVascBackendProxy { logger.log(logLevel,"vasc-merge backend: "+getId()+" in "+(t2-t1)+" ms"); } } - + /** * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#persist(java.lang.Object) */ @@ -149,14 +138,14 @@ public class VascBackendProxyTimerLogger extends AbstractVascBackendProxy { logger.log(logLevel,"vasc-persist backend: "+getId()+" in "+(t2-t1)+" ms"); } } - + /** * @return the logLevel */ public Level getLogLevel() { return logLevel; } - + /** * @param logLevel the logLevel to set */ diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/entry/VascEntryBackendEventListener.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/entry/VascEntryBackendEventListener.java index 9dde324..26f57ac 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/core/entry/VascEntryBackendEventListener.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/entry/VascEntryBackendEventListener.java @@ -42,7 +42,6 @@ public interface VascEntryBackendEventListener extends Serializable { PRE_DELETE, PRE_PROVIDE_FIELD_VALUE, PRE_PROVIDE_RECORD_CREATOR, - PRE_TOTAL_EXECUTE_SIZE, PRE_MOVE_DOWN, PRE_MOVE_UP, @@ -52,7 +51,6 @@ public interface VascEntryBackendEventListener extends Serializable { POST_DELETE, POST_PROVIDE_FIELD_VALUE, POST_PROVIDE_RECORD_CREATOR, - POST_TOTAL_EXECUTE_SIZE, POST_MOVE_DOWN, POST_MOVE_UP } diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/SetParameterBackendListener.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/SetParameterBackendListener.java index 19e5365..a998ace 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/SetParameterBackendListener.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/SetParameterBackendListener.java @@ -65,8 +65,7 @@ public class SetParameterBackendListener implements VascEntryBackendEventListene VascBackendEventType.PRE_MERGE, VascBackendEventType.PRE_MOVE_DOWN, VascBackendEventType.PRE_MOVE_UP, - VascBackendEventType.PRE_PERSIST, - VascBackendEventType.PRE_TOTAL_EXECUTE_SIZE + VascBackendEventType.PRE_PERSIST }; } diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendActions.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendActions.java index 3d79e3d..6c09c6f 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendActions.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendActions.java @@ -27,6 +27,7 @@ import java.util.Date; import java.util.logging.Logger; import net.forwardfire.vasc.backend.VascBackendException; +import net.forwardfire.vasc.backend.VascBackendResult; import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.proxy.VascProxyFilter; import net.forwardfire.vasc.core.VascEntry; @@ -225,25 +226,25 @@ public class DefaultVascFrontendActions implements VascFrontendActions { } } - // Always update total records - Long total = entry.getVascFrontendController().getVascEntryState().getVascBackend().fetchTotalExecuteSize(backendState); - entry.getVascFrontendController().getVascEntryState().setTotalBackendRecords(total); + VascBackendResult result; + try { + result = entry.getVascFrontendController().getVascEntryState().getVascBackend().execute(backendState); + } catch (VascBackendException ve) { + throw new VascFrontendException(ve); + } + + // Set data in frontend + entry.getVascFrontendController().getVascEntryState().setEntryDataList(result.getPageData()); + entry.getVascFrontendController().getVascEntryState().setTotalBackendRecords(result.getTotalSize()); // check if we need to change the current page if table size if changed in between - int pages = new Long(total/backendState.getPageSize()).intValue(); + int pages = new Long(result.getTotalSize()/backendState.getPageSize()).intValue(); if (backendState.getPageIndex() > pages) { backendState.setPageIndex(pages); } - try { - // Execute to get data. - entry.getVascFrontendController().getVascEntryState().setEntryDataList(entry.getVascFrontendController().getVascEntryState().getVascBackend().execute(backendState).getPageData()); - - // Fire event post read - entry.getVascFrontendController().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.POST_READ, null); - } catch (VascBackendException ve) { - throw new VascFrontendException(ve); - } + // Fire event post read + entry.getVascFrontendController().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.POST_READ, null); } @Override diff --git a/vasc-frontend/vasc-frontend-web-export/src/main/java/net/forwardfire/vasc/frontend/web/export/VascExportServlet.java b/vasc-frontend/vasc-frontend-web-export/src/main/java/net/forwardfire/vasc/frontend/web/export/VascExportServlet.java index 71491ae..c2f80cb 100644 --- a/vasc-frontend/vasc-frontend-web-export/src/main/java/net/forwardfire/vasc/frontend/web/export/VascExportServlet.java +++ b/vasc-frontend/vasc-frontend-web-export/src/main/java/net/forwardfire/vasc/frontend/web/export/VascExportServlet.java @@ -174,9 +174,6 @@ public class VascExportServlet extends HttpServlet { VascEntryLocal ve = (VascEntryLocal)vc.getVascEntryConfigController().configVascEntry(vc, entryId); vc.getVascEntryConfigController().configVascFrontendController(vc, ve); - // Update total every time first - Long total = ve.getVascFrontendController().getVascEntryState().getVascBackend().fetchTotalExecuteSize(ve.getVascFrontendController().getVascEntryState().getVascBackendState()); - ve.getVascFrontendController().getVascEntryState().setTotalBackendRecords(total); VascEntryExport ex = vc.getVascEntryConfigController().getVascEntryExporterById(exportId); VascEntryExportWriter exw = ex.createExportWriter(); exw.doInit(ex, ve);