diff --git a/vasc-backend/pom.xml b/vasc-backend/pom.xml index 2973ed4..e9168cc 100644 --- a/vasc-backend/pom.xml +++ b/vasc-backend/pom.xml @@ -17,5 +17,6 @@ vasc-backend-jdbc vasc-backend-metamodel vasc-backend-api + vasc-backend-test diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackendControllerLocal.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackendControllerLocal.java index dd32059..75bab90 100644 --- a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackendControllerLocal.java +++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackendControllerLocal.java @@ -22,6 +22,7 @@ package net.forwardfire.vasc.backend; +import java.io.Serializable; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -37,16 +38,16 @@ import java.util.Map; */ abstract public class AbstractVascBackendControllerLocal implements VascBackendControllerLocal { - private Map backends = null; + private Map> backends = null; public AbstractVascBackendControllerLocal() { - backends = new HashMap(1000); + backends = new HashMap>(1000); } /** * @see net.forwardfire.vasc.backend.VascBackendController#getVascBackendById(java.lang.String) */ - public VascBackend getVascBackendById(String id) { + public VascBackend getVascBackendById(String id) { return backends.get(id); } @@ -65,7 +66,8 @@ abstract public class AbstractVascBackendControllerLocal implements VascBackendC /** * @see net.forwardfire.vasc.backend.VascBackendControllerLocal#addVascBackend(net.forwardfire.vasc.backend.VascBackend) */ - public void addVascBackend(VascBackend backend) { + @SuppressWarnings("unchecked") + public void addVascBackend(VascBackend backend) { if (backend==null) { throw new NullPointerException("backend must not be null."); } @@ -73,14 +75,15 @@ abstract public class AbstractVascBackendControllerLocal implements VascBackendC throw new IllegalArgumentException("The backend must have an id."); } backend.startBackend(); - backends.put(backend.getId(), backend); + VascBackend castedBackend = (VascBackend) backend; + backends.put(backend.getId(), castedBackend); } /** * @see net.forwardfire.vasc.backend.VascBackendControllerLocal#removeVascBackendById(java.lang.String) */ public void removeVascBackendById(String backendId) { - VascBackend backend = getVascBackendById(backendId); + VascBackend backend = getVascBackendById(backendId); if (backend==null) { throw new NullPointerException("Could not find backend to remove with id: "+backendId); } 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 cc217db..5d666b6 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 @@ -40,15 +40,17 @@ public interface VascBackend { public void startBackend(); public void stopBackend(); - public List execute(VascBackendState state) throws VascBackendException; + public VascBackendResult execute(VascBackendState state) throws VascBackendException; public boolean isReadOnly(); - public void persist(DATA_OBJECT object) throws VascBackendException; + //public DATA_OBJECT fetch(Map pks) throws VascBackendException; - public DATA_OBJECT merge(DATA_OBJECT object) throws VascBackendException; + public void persist(DATA_OBJECT record) throws VascBackendException; - public void delete(DATA_OBJECT object) throws VascBackendException; + public DATA_OBJECT merge(DATA_OBJECT record) throws VascBackendException; + + public void delete(DATA_OBJECT record) throws VascBackendException; /** * Creates a new Field acces obj the the given field entry. @@ -102,10 +104,4 @@ public interface VascBackend { public boolean hasTotalSummary(); public Map executeTotalSummary(); - - /* - public boolean hasSettings(); - public Map getSettings(); - public void putSetting(String key,String value); - */ -} \ No newline at end of file +} diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendControllerLocal.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendControllerLocal.java index 06d2f71..c339edc 100644 --- a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendControllerLocal.java +++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendControllerLocal.java @@ -22,6 +22,8 @@ package net.forwardfire.vasc.backend; +import java.io.Serializable; + /** * @@ -30,7 +32,7 @@ package net.forwardfire.vasc.backend; */ public interface VascBackendControllerLocal extends VascBackendController { - public void addVascBackend(VascBackend backend); + public void addVascBackend(VascBackend backend); public void removeVascBackendById(String backendId); diff --git a/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcVascBackend.java b/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcVascBackend.java index 966ae52..9645190 100644 --- a/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcVascBackend.java +++ b/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcVascBackend.java @@ -31,7 +31,9 @@ import java.util.HashMap; import java.util.List; import net.forwardfire.vasc.backend.AbstractVascBackend; +import net.forwardfire.vasc.backend.DefaultVascBackendResult; import net.forwardfire.vasc.backend.VascBackendException; +import net.forwardfire.vasc.backend.VascBackendResult; import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.VascEntryFieldValue; import net.forwardfire.vasc.backend.VascEntryRecordCreator; @@ -79,7 +81,7 @@ public class JdbcVascBackend extends AbstractVascBackend> /** * @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state) */ - public List> execute(VascBackendState state) throws VascBackendException { + public VascBackendResult> execute(VascBackendState state) throws VascBackendException { JdbcConnectionProvider prov = getJdbcConnectionProvider(); List> result = new ArrayList>(50); Connection connection = null; @@ -108,16 +110,17 @@ public class JdbcVascBackend extends AbstractVascBackend> } } } - return result; + + return new DefaultVascBackendResult>(result); } - + /** * @see net.forwardfire.vasc.backend.VascBackend#merge(java.lang.Object) */ public HashMap merge(HashMap object) throws VascBackendException { return object; } - + /** * @see net.forwardfire.vasc.backend.VascBackend#persist(java.lang.Object) */ diff --git a/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcVascBackendXpql.java b/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcVascBackendXpql.java index c96b43a..b5a3f1a 100644 --- a/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcVascBackendXpql.java +++ b/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcVascBackendXpql.java @@ -31,7 +31,9 @@ import java.util.HashMap; import java.util.List; import net.forwardfire.vasc.backend.AbstractVascBackend; +import net.forwardfire.vasc.backend.DefaultVascBackendResult; import net.forwardfire.vasc.backend.VascBackendException; +import net.forwardfire.vasc.backend.VascBackendResult; import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.VascEntryFieldValue; import net.forwardfire.vasc.backend.VascEntryRecordCreator; @@ -90,7 +92,7 @@ public class JdbcVascBackendXpql extends AbstractVascBackend> execute(VascBackendState state) throws VascBackendException { + public VascBackendResult> execute(VascBackendState state) throws VascBackendException { // Copy parameters for (String key:state.getDataParameterKeys()) { Object value = state.getDataParameter(key); @@ -120,7 +122,7 @@ public class JdbcVascBackendXpql extends AbstractVascBackend>(result); } catch (SQLException e) { throw new VascBackendException(e); } finally { 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 3098926..f8994c2 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 @@ -23,9 +23,12 @@ package net.forwardfire.vasc.backends.jpa; import java.io.Serializable; +import java.util.HashMap; import java.util.List; +import net.forwardfire.vasc.backend.DefaultVascBackendResult; import net.forwardfire.vasc.backend.VascBackendException; +import net.forwardfire.vasc.backend.VascBackendResult; import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.VascEntryFieldValue; import net.forwardfire.vasc.backend.VascEntryRecordCreator; @@ -74,7 +77,7 @@ public class XpqlHibernateVascBackend extends } @SuppressWarnings("unchecked") - public List execute(VascBackendState state) throws VascBackendException { + public VascBackendResult execute(VascBackendState state) throws VascBackendException { // Copy parameters for (String key:state.getDataParameterKeys()) { @@ -106,7 +109,8 @@ public class XpqlHibernateVascBackend extends } List data = q.list(); s.getTransaction().commit(); - return data; + + return new DefaultVascBackendResult(data); } finally { if (s!=null) { //em.close(); 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 b98b343..83efac3 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 @@ -28,7 +28,9 @@ import java.util.List; import javax.persistence.EntityManager; import javax.persistence.Query; +import net.forwardfire.vasc.backend.DefaultVascBackendResult; import net.forwardfire.vasc.backend.VascBackendException; +import net.forwardfire.vasc.backend.VascBackendResult; import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.VascEntryFieldValue; import net.forwardfire.vasc.backend.VascEntryRecordCreator; @@ -77,7 +79,7 @@ public class XpqlPersistanceVascBackend extend @SuppressWarnings("unchecked") - public List execute(VascBackendState state) throws VascBackendException { + public VascBackendResult execute(VascBackendState state) throws VascBackendException { // Copy parameters for (String key:state.getDataParameterKeys()) { @@ -111,7 +113,8 @@ public class XpqlPersistanceVascBackend extend if (emTransaction) { em.getTransaction().commit(); } - return data; + VascBackendResult result = new DefaultVascBackendResult(data); + return result; } finally { if (em!=null) { //em.close(); diff --git a/vasc-backend/vasc-backend-ldap/src/main/java/net/forwardfire/vasc/backend/ldap/LdapVascBackend.java b/vasc-backend/vasc-backend-ldap/src/main/java/net/forwardfire/vasc/backend/ldap/LdapVascBackend.java index 400353b..de29d31 100644 --- a/vasc-backend/vasc-backend-ldap/src/main/java/net/forwardfire/vasc/backend/ldap/LdapVascBackend.java +++ b/vasc-backend/vasc-backend-ldap/src/main/java/net/forwardfire/vasc/backend/ldap/LdapVascBackend.java @@ -30,7 +30,9 @@ import java.util.Map; import java.util.logging.Logger; import net.forwardfire.vasc.backend.AbstractVascBackend; +import net.forwardfire.vasc.backend.DefaultVascBackendResult; import net.forwardfire.vasc.backend.VascBackendException; +import net.forwardfire.vasc.backend.VascBackendResult; import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.VascEntryFieldValue; import net.forwardfire.vasc.backend.VascEntryRecordCreator; @@ -80,7 +82,7 @@ public class LdapVascBackend extends AbstractVascBackend> /** * @see net.forwardfire.vasc.backend.VascBackend#execute() */ - public List> execute(VascBackendState state) throws VascBackendException { + public VascBackendResult> execute(VascBackendState state) throws VascBackendException { LdapConnectionProvider prov = getLdapConnectionProvider(); LDAPConnection connection = prov.getLdapConnection(); List> result = new ArrayList>(50); @@ -128,7 +130,7 @@ public class LdapVascBackend extends AbstractVascBackend> } finally { safeDisconnect(connection); } - return result; + return new DefaultVascBackendResult>(result); } /** 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 99ea687..f0adf24 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 @@ -43,7 +43,9 @@ import org.eobjects.metamodel.schema.Schema; import org.eobjects.metamodel.schema.Table; import net.forwardfire.vasc.backend.AbstractVascBackend; +import net.forwardfire.vasc.backend.DefaultVascBackendResult; import net.forwardfire.vasc.backend.VascBackendException; +import net.forwardfire.vasc.backend.VascBackendResult; import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.VascEntryRecordCreator; import net.forwardfire.vasc.backend.metamodel.crud.CrudDataContext; @@ -209,7 +211,7 @@ public class MetaModelVascBackend extends AbstractVascBackend { return q; } - public List execute(VascBackendState state) throws VascBackendException { + public VascBackendResult execute(VascBackendState state) throws VascBackendException { Schema schema = dataContext.getDefaultSchema(); Table t = schema.getTableByName(table); if (t==null) { @@ -240,7 +242,7 @@ public class MetaModelVascBackend extends AbstractVascBackend { DataSet ds = crudDataContext.executeQuery(q); result.addAll(ds.toRows()); ds.close(); - return result; + return new DefaultVascBackendResult(result); } DataSet ds = dataContext.executeQuery(q); @@ -258,7 +260,7 @@ public class MetaModelVascBackend extends AbstractVascBackend { } ds.close(); - return result; + return new DefaultVascBackendResult(result); } public void persist(Row object) throws VascBackendException { 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 bcfa772..1d399d3 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 @@ -27,7 +27,9 @@ import java.util.List; import java.util.logging.Logger; import net.forwardfire.vasc.backend.AbstractVascBackend; +import net.forwardfire.vasc.backend.DefaultVascBackendResult; import net.forwardfire.vasc.backend.VascBackendException; +import net.forwardfire.vasc.backend.VascBackendResult; import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.VascEntryRecordCreator; @@ -104,7 +106,7 @@ public class MongodbVascBackend extends AbstractVascBackend { return query; } - public List execute(VascBackendState state) throws VascBackendException { + public VascBackendResult execute(VascBackendState state) throws VascBackendException { DBCollection coll = getDBCollection(); DBObject query = createFilterQuery(state); DBCursor cur = coll.find(query); @@ -117,7 +119,7 @@ public class MongodbVascBackend extends AbstractVascBackend { DBObject row = cur.next(); result.add((BasicDBObject)row); } - return result; + return new DefaultVascBackendResult(result); } public void persist(BasicDBObject object) throws VascBackendException { diff --git a/vasc-core-ejb3-client/src/main/java/net/forwardfire/vasc/ejb3/VascServiceRemoteBackend.java b/vasc-core-ejb3-client/src/main/java/net/forwardfire/vasc/ejb3/VascServiceRemoteBackend.java index e382f42..60af2c2 100644 --- a/vasc-core-ejb3-client/src/main/java/net/forwardfire/vasc/ejb3/VascServiceRemoteBackend.java +++ b/vasc-core-ejb3-client/src/main/java/net/forwardfire/vasc/ejb3/VascServiceRemoteBackend.java @@ -28,6 +28,7 @@ import java.util.Map; import net.forwardfire.vasc.backend.VascBackend; import net.forwardfire.vasc.backend.VascBackendException; +import net.forwardfire.vasc.backend.VascBackendResult; import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.VascEntryFieldValue; import net.forwardfire.vasc.backend.VascEntryRecordCreator; @@ -90,11 +91,11 @@ public class VascServiceRemoteBackend implemen } @SuppressWarnings("unchecked") - public List execute(VascBackendState state) throws VascBackendException { + public VascBackendResult execute(VascBackendState state) throws VascBackendException { Object[] args = new Object[1]; args[0]=state; Object result = vascManager.invokeBackendMethod(backendId, "execute", args); - return (List)result; + return (VascBackendResult)result; } public long fetchTotalExecuteSize(VascBackendState state) { 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 7e35da7..cc715a8 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,11 +23,11 @@ package net.forwardfire.vasc.backend.proxy; import java.io.Serializable; -import java.util.List; import java.util.Map; import net.forwardfire.vasc.backend.VascBackend; import net.forwardfire.vasc.backend.VascBackendException; +import net.forwardfire.vasc.backend.VascBackendResult; import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.VascEntryFieldValue; import net.forwardfire.vasc.backend.VascEntryRecordCreator; @@ -106,7 +106,7 @@ abstract public class AbstractVascBackendProxy implements VascBackendProxy { * @throws Exception * @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state) */ - public List execute(VascBackendState state) throws VascBackendException { + public VascBackendResult execute(VascBackendState state) throws VascBackendException { return backend.execute(state); } 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 1daecfe..597cccf 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 @@ -24,10 +24,10 @@ package net.forwardfire.vasc.backend.proxy; import java.io.Serializable; import java.util.HashMap; -import java.util.List; import java.util.Map; import net.forwardfire.vasc.backend.VascBackendException; +import net.forwardfire.vasc.backend.VascBackendResult; import net.forwardfire.vasc.backend.VascBackendState; /** @@ -39,7 +39,7 @@ import net.forwardfire.vasc.backend.VascBackendState; public class VascBackendProxyCache extends AbstractVascBackendProxy { private Long records = null; - private List data = null; + private VascBackendResult data = null; private String searchString = null; private Map dataState = null; private int pageIndex = 0; @@ -122,7 +122,7 @@ public class VascBackendProxyCache extends AbstractVascBackendProxy { @Override public void stopBackend() { super.stopBackend(); - data.clear(); + data = null; dataState.clear(); requestFlush = true; } @@ -131,7 +131,7 @@ public class VascBackendProxyCache extends AbstractVascBackendProxy { * @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state) */ @Override - public List execute(VascBackendState state) throws VascBackendException { + public VascBackendResult execute(VascBackendState state) throws VascBackendException { boolean changed = isStateChanged(state); if (data==null | changed) { data = backend.execute(state); 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 c122e14..5c4b053 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 @@ -28,6 +28,7 @@ import java.util.List; import net.forwardfire.vasc.backend.VascBackend; import net.forwardfire.vasc.backend.VascBackendException; +import net.forwardfire.vasc.backend.VascBackendResult; import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.entry.VascEntryBackendEventListener; @@ -138,9 +139,9 @@ public class VascBackendProxyEventExecutor extends AbstractVascBackendProxy { * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#execute(net.forwardfire.vasc.backend.VascBackendState) */ @Override - public List execute(VascBackendState state) throws VascBackendException { + public VascBackendResult execute(VascBackendState state) throws VascBackendException { fireVascEvent(VascBackendEventType.PRE_EXECUTE,state); - List result = super.execute(state); + VascBackendResult result = super.execute(state); fireVascEvent(VascBackendEventType.POST_EXECUTE,result); return result; } 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 94a3bfd..4a98f67 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 @@ -26,8 +26,10 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.List; +import net.forwardfire.vasc.backend.DefaultVascBackendResult; import net.forwardfire.vasc.backend.VascBackend; import net.forwardfire.vasc.backend.VascBackendException; +import net.forwardfire.vasc.backend.VascBackendResult; import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.core.VascEntry; @@ -77,16 +79,16 @@ public class VascBackendProxyFilter extends AbstractVascBackendProxy { * @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state) */ @Override - public List execute(VascBackendState state) throws VascBackendException { - List result = backend.execute(state); + public VascBackendResult execute(VascBackendState state) throws VascBackendException { + VascBackendResult result = backend.execute(state); if (filters==null) { return result; } if (filters.isEmpty()) { return result; } - List search = new ArrayList(result.size()/2); - for (Serializable o:result) { + List search = new ArrayList(result.getPageData().size()/2); + for (Serializable o:result.getPageData()) { for (VascProxyFilter filter:filters) { Serializable r = filter.filterObject(o); if (r!=null) { @@ -95,7 +97,7 @@ public class VascBackendProxyFilter extends AbstractVascBackendProxy { } } records = search.size(); - return search; + return new DefaultVascBackendResult(search); } @Override 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 d68657a..f94fc1d 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 @@ -26,7 +26,9 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.List; +import net.forwardfire.vasc.backend.DefaultVascBackendResult; import net.forwardfire.vasc.backend.VascBackendException; +import net.forwardfire.vasc.backend.VascBackendResult; import net.forwardfire.vasc.backend.VascBackendState; /** @@ -71,25 +73,25 @@ public class VascBackendProxyPaged extends AbstractVascBackendProxy { * @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state) */ @Override - public List execute(VascBackendState state) throws VascBackendException { - List allData = backend.execute(state); + public VascBackendResult execute(VascBackendState state) throws VascBackendException { + VascBackendResult allData = backend.execute(state); int pageSize = state.getPageSize(); if (pageSize==0) { - records = allData.size(); + records = allData.getPageData().size(); return allData; } List paged = new ArrayList(state.getPageSize()); int off = state.getPageIndex()*pageSize; int offMax = off+state.getPageSize(); for (int i=off;i=allData.size()) { + if (i>=allData.getPageData().size()) { break; } - Serializable o = allData.get(i); + Serializable o = allData.getPageData().get(i); paged.add(o); } - records = allData.size(); - return paged; + records = allData.getPageData().size(); + return new DefaultVascBackendResult(paged); } @Override 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 597b194..e09ffac 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 @@ -26,7 +26,9 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.List; +import net.forwardfire.vasc.backend.DefaultVascBackendResult; import net.forwardfire.vasc.backend.VascBackendException; +import net.forwardfire.vasc.backend.VascBackendResult; import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.VascEntryFieldValue; import net.forwardfire.vasc.core.VascEntryField; @@ -71,8 +73,8 @@ public class VascBackendProxySearch extends AbstractVascBackendProxy { * @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state) */ @Override - public List execute(VascBackendState state) throws VascBackendException { - List result = backend.execute(state); + public VascBackendResult execute(VascBackendState state) throws VascBackendException { + VascBackendResult result = backend.execute(state); if (state.getSearchString()==null) { return result; } @@ -80,8 +82,8 @@ public class VascBackendProxySearch extends AbstractVascBackendProxy { return result; } String searchString = state.getSearchString().toLowerCase(); - List search = new ArrayList(result.size()/4); - for (Serializable record:result) { + List search = new ArrayList(result.getPageData().size()/4); + for (Serializable record:result.getPageData()) { for (VascEntryField field:entry.getVascEntryFields()) { VascEntryFieldValue fieldValue = backend.provideVascEntryFieldValue(); Serializable value = fieldValue.getValue(field.getBackendName(), record); @@ -133,7 +135,7 @@ public class VascBackendProxySearch extends AbstractVascBackendProxy { */ } //records = search.size(); - return search; + return new DefaultVascBackendResult(search); } @Override diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxySort.java b/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxySort.java index 122b285..7b1d943 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxySort.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxySort.java @@ -25,9 +25,9 @@ package net.forwardfire.vasc.backend.proxy; import java.io.Serializable; import java.util.Collections; import java.util.Comparator; -import java.util.List; import net.forwardfire.vasc.backend.VascBackendException; +import net.forwardfire.vasc.backend.VascBackendResult; import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.VascEntryFieldValue; import net.forwardfire.vasc.core.VascEntryField; @@ -74,14 +74,14 @@ public class VascBackendProxySort extends AbstractVascBackendProxy { */ @SuppressWarnings("unchecked") @Override - public List execute(final VascBackendState state) throws VascBackendException { - List result = backend.execute(state); + public VascBackendResult execute(final VascBackendState state) throws VascBackendException { + VascBackendResult result = backend.execute(state); if (state.getSortField()==null) { return result; } final VascEntryField field = getVascEntryFieldByBackendName(state.getSortField()); final VascEntryFieldValue fieldValue = backend.provideVascEntryFieldValue(); - Collections.sort(result, new Comparator() { + Collections.sort(result.getPageData(), new Comparator() { @SuppressWarnings("rawtypes") public int compare(Serializable o1, Serializable o2) { try { 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 87e1d8d..a486612 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 @@ -23,11 +23,11 @@ package net.forwardfire.vasc.backend.proxy; import java.io.Serializable; -import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; import net.forwardfire.vasc.backend.VascBackendException; +import net.forwardfire.vasc.backend.VascBackendResult; import net.forwardfire.vasc.backend.VascBackendState; /** @@ -59,7 +59,7 @@ public class VascBackendProxyTimerLogger extends AbstractVascBackendProxy { * @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state) */ @Override - public List execute(VascBackendState state) throws VascBackendException { + public VascBackendResult execute(VascBackendState state) throws VascBackendException { long t1 = System.currentTimeMillis(); try { return backend.execute(state); diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/frontend/VascFrontendUserSettingController.java b/vasc-core/src/main/java/net/forwardfire/vasc/frontend/VascFrontendUserSettingController.java index c5c82cd..7c2aa27 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/frontend/VascFrontendUserSettingController.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/frontend/VascFrontendUserSettingController.java @@ -37,5 +37,6 @@ import net.forwardfire.vasc.core.VascEntryField; */ public interface VascFrontendUserSettingController { - + //public Map getSettings(); + //public void putSetting(String key,String value); } \ No newline at end of file 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 fa7005f..60d1e18 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 @@ -231,7 +231,7 @@ public class DefaultVascFrontendActions implements VascFrontendActions { try { // Execute to get data. - entry.getVascFrontendController().getVascEntryState().setEntryDataList(entry.getVascFrontendController().getVascEntryState().getVascBackend().execute(backendState)); + entry.getVascFrontendController().getVascEntryState().setEntryDataList(entry.getVascFrontendController().getVascEntryState().getVascBackend().execute(backendState).getPageData()); // Fire event post read entry.getVascFrontendController().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.POST_READ, null); diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/ui/VascSelectItemModelEntry.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/ui/VascSelectItemModelEntry.java index 059bb1e..a709c32 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/ui/VascSelectItemModelEntry.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/ui/VascSelectItemModelEntry.java @@ -170,7 +170,7 @@ public class VascSelectItemModelEntry implements VascSelectItemModel { // execute - for (Serializable o:back.execute(state)) { + for (Serializable o:back.execute(state).getPageData()) { Serializable keyId = key.getVascEntryFieldValue().getValue(key.getBackendName(), o); String nameId = dis.getVascEntryFieldValue().getDisplayValue(dis.getBackendName(), o); if (returnKeyValue!=null && false==returnKeyValue) { diff --git a/vasc-opt/vasc-opt-editor/src/main/java/net/forwardfire/vasc/opt/editor/VirtualVascBackend.java b/vasc-opt/vasc-opt-editor/src/main/java/net/forwardfire/vasc/opt/editor/VirtualVascBackend.java index 9f01d86..267cb4e 100644 --- a/vasc-opt/vasc-opt-editor/src/main/java/net/forwardfire/vasc/opt/editor/VirtualVascBackend.java +++ b/vasc-opt/vasc-opt-editor/src/main/java/net/forwardfire/vasc/opt/editor/VirtualVascBackend.java @@ -5,7 +5,9 @@ import java.util.ArrayList; import java.util.List; import net.forwardfire.vasc.backend.AbstractVascBackend; +import net.forwardfire.vasc.backend.DefaultVascBackendResult; import net.forwardfire.vasc.backend.VascBackendException; +import net.forwardfire.vasc.backend.VascBackendResult; import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.VascEntryFieldValue; import net.forwardfire.vasc.backend.VascEntryRecordCreator; @@ -34,7 +36,7 @@ public class VirtualVascBackend extends AbstractVascBackend { private String vascType = "entry"; private String entryId = null; - public List execute(VascBackendState state) throws VascBackendException { + public VascBackendResult execute(VascBackendState state) throws VascBackendException { List result = new ArrayList(100); entryId = (String)state.getDataParameter("entry_id"); if ("entry".equals(vascType)) { @@ -63,7 +65,7 @@ public class VirtualVascBackend extends AbstractVascBackend { } } - return result; + return new DefaultVascBackendResult(result); } public void persist(Serializable object) throws VascBackendException { diff --git a/vasc-test/vasc-test-frontend/src/main/java/net/forwardfire/vasc/test/frontend/data/TestModelVascDataSource.java b/vasc-test/vasc-test-frontend/src/main/java/net/forwardfire/vasc/test/frontend/data/TestModelVascDataSource.java index 958c343..41586fe 100644 --- a/vasc-test/vasc-test-frontend/src/main/java/net/forwardfire/vasc/test/frontend/data/TestModelVascDataSource.java +++ b/vasc-test/vasc-test-frontend/src/main/java/net/forwardfire/vasc/test/frontend/data/TestModelVascDataSource.java @@ -31,7 +31,9 @@ import org.x4o.xml.element.DefaultElementObjectPropertyValue; import org.x4o.xml.element.ElementObjectPropertyValueException; import net.forwardfire.vasc.backend.AbstractVascBackend; +import net.forwardfire.vasc.backend.DefaultVascBackendResult; import net.forwardfire.vasc.backend.VascBackendException; +import net.forwardfire.vasc.backend.VascBackendResult; import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.VascEntryFieldValue; import net.forwardfire.vasc.backend.VascEntryRecordCreator; @@ -102,7 +104,7 @@ public class TestModelVascDataSource { return modelList; } - public List execute(VascBackendState state) throws VascBackendException { + public VascBackendResult execute(VascBackendState state) throws VascBackendException { if (state.getDataParameterKeys().isEmpty()==false) { List result = new ArrayList(modelList.size()/2); DefaultElementObjectPropertyValue helper = new DefaultElementObjectPropertyValue(); @@ -128,13 +130,13 @@ public class TestModelVascDataSource { result.add(row); } } - return result; + return new DefaultVascBackendResult(result); } else { List result = new ArrayList(modelList.size()); for (DATA_OBJECT row:modelList) { result.add(row); } - return result; + return new DefaultVascBackendResult(result); } }