2
0
Fork 0

WIP added backend generics so all is seriazible and started to make

execute return full result.
This commit is contained in:
Willem Cazander 2014-08-23 16:58:42 +02:00
parent 3bf185ad48
commit 90b81deb29
25 changed files with 109 additions and 76 deletions

View file

@ -17,5 +17,6 @@
<module>vasc-backend-jdbc</module> <module>vasc-backend-jdbc</module>
<module>vasc-backend-metamodel</module> <module>vasc-backend-metamodel</module>
<module>vasc-backend-api</module> <module>vasc-backend-api</module>
<module>vasc-backend-test</module>
</modules> </modules>
</project> </project>

View file

@ -22,6 +22,7 @@
package net.forwardfire.vasc.backend; package net.forwardfire.vasc.backend;
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
@ -37,16 +38,16 @@ import java.util.Map;
*/ */
abstract public class AbstractVascBackendControllerLocal implements VascBackendControllerLocal { abstract public class AbstractVascBackendControllerLocal implements VascBackendControllerLocal {
private Map<String,VascBackend> backends = null; private Map<String,VascBackend<Serializable>> backends = null;
public AbstractVascBackendControllerLocal() { public AbstractVascBackendControllerLocal() {
backends = new HashMap<String,VascBackend>(1000); backends = new HashMap<String,VascBackend<Serializable>>(1000);
} }
/** /**
* @see net.forwardfire.vasc.backend.VascBackendController#getVascBackendById(java.lang.String) * @see net.forwardfire.vasc.backend.VascBackendController#getVascBackendById(java.lang.String)
*/ */
public VascBackend getVascBackendById(String id) { public VascBackend<Serializable> getVascBackendById(String id) {
return backends.get(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) * @see net.forwardfire.vasc.backend.VascBackendControllerLocal#addVascBackend(net.forwardfire.vasc.backend.VascBackend)
*/ */
public void addVascBackend(VascBackend backend) { @SuppressWarnings("unchecked")
public void addVascBackend(VascBackend<? extends Serializable> backend) {
if (backend==null) { if (backend==null) {
throw new NullPointerException("backend must not be 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."); throw new IllegalArgumentException("The backend must have an id.");
} }
backend.startBackend(); backend.startBackend();
backends.put(backend.getId(), backend); VascBackend<Serializable> castedBackend = (VascBackend<Serializable>) backend;
backends.put(backend.getId(), castedBackend);
} }
/** /**
* @see net.forwardfire.vasc.backend.VascBackendControllerLocal#removeVascBackendById(java.lang.String) * @see net.forwardfire.vasc.backend.VascBackendControllerLocal#removeVascBackendById(java.lang.String)
*/ */
public void removeVascBackendById(String backendId) { public void removeVascBackendById(String backendId) {
VascBackend backend = getVascBackendById(backendId); VascBackend<? extends Serializable> backend = getVascBackendById(backendId);
if (backend==null) { if (backend==null) {
throw new NullPointerException("Could not find backend to remove with id: "+backendId); throw new NullPointerException("Could not find backend to remove with id: "+backendId);
} }

View file

@ -40,15 +40,17 @@ public interface VascBackend<DATA_OBJECT extends Serializable> {
public void startBackend(); public void startBackend();
public void stopBackend(); public void stopBackend();
public List<DATA_OBJECT> execute(VascBackendState state) throws VascBackendException; public VascBackendResult<DATA_OBJECT> execute(VascBackendState state) throws VascBackendException;
public boolean isReadOnly(); public boolean isReadOnly();
public void persist(DATA_OBJECT object) throws VascBackendException; //public DATA_OBJECT fetch(Map<String,Serializable> 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. * Creates a new Field acces obj the the given field entry.
@ -102,10 +104,4 @@ public interface VascBackend<DATA_OBJECT extends Serializable> {
public boolean hasTotalSummary(); public boolean hasTotalSummary();
public Map<String,Object> executeTotalSummary(); public Map<String,Object> executeTotalSummary();
}
/*
public boolean hasSettings();
public Map<String,String> getSettings();
public void putSetting(String key,String value);
*/
}

View file

@ -22,6 +22,8 @@
package net.forwardfire.vasc.backend; package net.forwardfire.vasc.backend;
import java.io.Serializable;
/** /**
* *
@ -30,7 +32,7 @@ package net.forwardfire.vasc.backend;
*/ */
public interface VascBackendControllerLocal extends VascBackendController { public interface VascBackendControllerLocal extends VascBackendController {
public void addVascBackend(VascBackend backend); public void addVascBackend(VascBackend<? extends Serializable> backend);
public void removeVascBackendById(String backendId); public void removeVascBackendById(String backendId);

View file

@ -31,7 +31,9 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import net.forwardfire.vasc.backend.AbstractVascBackend; import net.forwardfire.vasc.backend.AbstractVascBackend;
import net.forwardfire.vasc.backend.DefaultVascBackendResult;
import net.forwardfire.vasc.backend.VascBackendException; import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascBackendResult;
import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.VascBackendState;
import net.forwardfire.vasc.backend.VascEntryFieldValue; import net.forwardfire.vasc.backend.VascEntryFieldValue;
import net.forwardfire.vasc.backend.VascEntryRecordCreator; import net.forwardfire.vasc.backend.VascEntryRecordCreator;
@ -79,7 +81,7 @@ public class JdbcVascBackend extends AbstractVascBackend<HashMap<String,Object>>
/** /**
* @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state) * @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state)
*/ */
public List<HashMap<String,Object>> execute(VascBackendState state) throws VascBackendException { public VascBackendResult<HashMap<String,Object>> execute(VascBackendState state) throws VascBackendException {
JdbcConnectionProvider prov = getJdbcConnectionProvider(); JdbcConnectionProvider prov = getJdbcConnectionProvider();
List<HashMap<String,Object>> result = new ArrayList<HashMap<String,Object>>(50); List<HashMap<String,Object>> result = new ArrayList<HashMap<String,Object>>(50);
Connection connection = null; Connection connection = null;
@ -108,16 +110,17 @@ public class JdbcVascBackend extends AbstractVascBackend<HashMap<String,Object>>
} }
} }
} }
return result;
return new DefaultVascBackendResult<HashMap<String,Object>>(result);
} }
/** /**
* @see net.forwardfire.vasc.backend.VascBackend#merge(java.lang.Object) * @see net.forwardfire.vasc.backend.VascBackend#merge(java.lang.Object)
*/ */
public HashMap<String,Object> merge(HashMap<String,Object> object) throws VascBackendException { public HashMap<String,Object> merge(HashMap<String,Object> object) throws VascBackendException {
return object; return object;
} }
/** /**
* @see net.forwardfire.vasc.backend.VascBackend#persist(java.lang.Object) * @see net.forwardfire.vasc.backend.VascBackend#persist(java.lang.Object)
*/ */

View file

@ -31,7 +31,9 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import net.forwardfire.vasc.backend.AbstractVascBackend; import net.forwardfire.vasc.backend.AbstractVascBackend;
import net.forwardfire.vasc.backend.DefaultVascBackendResult;
import net.forwardfire.vasc.backend.VascBackendException; import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascBackendResult;
import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.VascBackendState;
import net.forwardfire.vasc.backend.VascEntryFieldValue; import net.forwardfire.vasc.backend.VascEntryFieldValue;
import net.forwardfire.vasc.backend.VascEntryRecordCreator; import net.forwardfire.vasc.backend.VascEntryRecordCreator;
@ -90,7 +92,7 @@ public class JdbcVascBackendXpql extends AbstractVascBackend<HashMap<String,Obje
/** /**
* @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state) * @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state)
*/ */
public List<HashMap<String,Object>> execute(VascBackendState state) throws VascBackendException { public VascBackendResult<HashMap<String,Object>> execute(VascBackendState state) throws VascBackendException {
// Copy parameters // Copy parameters
for (String key:state.getDataParameterKeys()) { for (String key:state.getDataParameterKeys()) {
Object value = state.getDataParameter(key); Object value = state.getDataParameter(key);
@ -120,7 +122,7 @@ public class JdbcVascBackendXpql extends AbstractVascBackend<HashMap<String,Obje
} }
result.add(map); result.add(map);
} }
return result; return new DefaultVascBackendResult<HashMap<String,Object>>(result);
} catch (SQLException e) { } catch (SQLException e) {
throw new VascBackendException(e); throw new VascBackendException(e);
} finally { } finally {

View file

@ -23,9 +23,12 @@
package net.forwardfire.vasc.backends.jpa; package net.forwardfire.vasc.backends.jpa;
import java.io.Serializable; import java.io.Serializable;
import java.util.HashMap;
import java.util.List; import java.util.List;
import net.forwardfire.vasc.backend.DefaultVascBackendResult;
import net.forwardfire.vasc.backend.VascBackendException; import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascBackendResult;
import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.VascBackendState;
import net.forwardfire.vasc.backend.VascEntryFieldValue; import net.forwardfire.vasc.backend.VascEntryFieldValue;
import net.forwardfire.vasc.backend.VascEntryRecordCreator; import net.forwardfire.vasc.backend.VascEntryRecordCreator;
@ -74,7 +77,7 @@ public class XpqlHibernateVascBackend<DATA_OBJECT extends Serializable> extends
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public List<DATA_OBJECT> execute(VascBackendState state) throws VascBackendException { public VascBackendResult<DATA_OBJECT> execute(VascBackendState state) throws VascBackendException {
// Copy parameters // Copy parameters
for (String key:state.getDataParameterKeys()) { for (String key:state.getDataParameterKeys()) {
@ -106,7 +109,8 @@ public class XpqlHibernateVascBackend<DATA_OBJECT extends Serializable> extends
} }
List<DATA_OBJECT> data = q.list(); List<DATA_OBJECT> data = q.list();
s.getTransaction().commit(); s.getTransaction().commit();
return data;
return new DefaultVascBackendResult<DATA_OBJECT>(data);
} finally { } finally {
if (s!=null) { if (s!=null) {
//em.close(); //em.close();

View file

@ -28,7 +28,9 @@ import java.util.List;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.persistence.Query; import javax.persistence.Query;
import net.forwardfire.vasc.backend.DefaultVascBackendResult;
import net.forwardfire.vasc.backend.VascBackendException; import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascBackendResult;
import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.VascBackendState;
import net.forwardfire.vasc.backend.VascEntryFieldValue; import net.forwardfire.vasc.backend.VascEntryFieldValue;
import net.forwardfire.vasc.backend.VascEntryRecordCreator; import net.forwardfire.vasc.backend.VascEntryRecordCreator;
@ -77,7 +79,7 @@ public class XpqlPersistanceVascBackend<DATA_OBJECT extends Serializable> extend
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public List<DATA_OBJECT> execute(VascBackendState state) throws VascBackendException { public VascBackendResult<DATA_OBJECT> execute(VascBackendState state) throws VascBackendException {
// Copy parameters // Copy parameters
for (String key:state.getDataParameterKeys()) { for (String key:state.getDataParameterKeys()) {
@ -111,7 +113,8 @@ public class XpqlPersistanceVascBackend<DATA_OBJECT extends Serializable> extend
if (emTransaction) { if (emTransaction) {
em.getTransaction().commit(); em.getTransaction().commit();
} }
return data; VascBackendResult<DATA_OBJECT> result = new DefaultVascBackendResult<DATA_OBJECT>(data);
return result;
} finally { } finally {
if (em!=null) { if (em!=null) {
//em.close(); //em.close();

View file

@ -30,7 +30,9 @@ import java.util.Map;
import java.util.logging.Logger; import java.util.logging.Logger;
import net.forwardfire.vasc.backend.AbstractVascBackend; import net.forwardfire.vasc.backend.AbstractVascBackend;
import net.forwardfire.vasc.backend.DefaultVascBackendResult;
import net.forwardfire.vasc.backend.VascBackendException; import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascBackendResult;
import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.VascBackendState;
import net.forwardfire.vasc.backend.VascEntryFieldValue; import net.forwardfire.vasc.backend.VascEntryFieldValue;
import net.forwardfire.vasc.backend.VascEntryRecordCreator; import net.forwardfire.vasc.backend.VascEntryRecordCreator;
@ -80,7 +82,7 @@ public class LdapVascBackend extends AbstractVascBackend<HashMap<String,Object>>
/** /**
* @see net.forwardfire.vasc.backend.VascBackend#execute() * @see net.forwardfire.vasc.backend.VascBackend#execute()
*/ */
public List<HashMap<String,Object>> execute(VascBackendState state) throws VascBackendException { public VascBackendResult<HashMap<String,Object>> execute(VascBackendState state) throws VascBackendException {
LdapConnectionProvider prov = getLdapConnectionProvider(); LdapConnectionProvider prov = getLdapConnectionProvider();
LDAPConnection connection = prov.getLdapConnection(); LDAPConnection connection = prov.getLdapConnection();
List<HashMap<String,Object>> result = new ArrayList<HashMap<String,Object>>(50); List<HashMap<String,Object>> result = new ArrayList<HashMap<String,Object>>(50);
@ -128,7 +130,7 @@ public class LdapVascBackend extends AbstractVascBackend<HashMap<String,Object>>
} finally { } finally {
safeDisconnect(connection); safeDisconnect(connection);
} }
return result; return new DefaultVascBackendResult<HashMap<String,Object>>(result);
} }
/** /**

View file

@ -43,7 +43,9 @@ import org.eobjects.metamodel.schema.Schema;
import org.eobjects.metamodel.schema.Table; import org.eobjects.metamodel.schema.Table;
import net.forwardfire.vasc.backend.AbstractVascBackend; import net.forwardfire.vasc.backend.AbstractVascBackend;
import net.forwardfire.vasc.backend.DefaultVascBackendResult;
import net.forwardfire.vasc.backend.VascBackendException; import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascBackendResult;
import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.VascBackendState;
import net.forwardfire.vasc.backend.VascEntryRecordCreator; import net.forwardfire.vasc.backend.VascEntryRecordCreator;
import net.forwardfire.vasc.backend.metamodel.crud.CrudDataContext; import net.forwardfire.vasc.backend.metamodel.crud.CrudDataContext;
@ -209,7 +211,7 @@ public class MetaModelVascBackend extends AbstractVascBackend<Row> {
return q; return q;
} }
public List<Row> execute(VascBackendState state) throws VascBackendException { public VascBackendResult<Row> execute(VascBackendState state) throws VascBackendException {
Schema schema = dataContext.getDefaultSchema(); Schema schema = dataContext.getDefaultSchema();
Table t = schema.getTableByName(table); Table t = schema.getTableByName(table);
if (t==null) { if (t==null) {
@ -240,7 +242,7 @@ public class MetaModelVascBackend extends AbstractVascBackend<Row> {
DataSet ds = crudDataContext.executeQuery(q); DataSet ds = crudDataContext.executeQuery(q);
result.addAll(ds.toRows()); result.addAll(ds.toRows());
ds.close(); ds.close();
return result; return new DefaultVascBackendResult<Row>(result);
} }
DataSet ds = dataContext.executeQuery(q); DataSet ds = dataContext.executeQuery(q);
@ -258,7 +260,7 @@ public class MetaModelVascBackend extends AbstractVascBackend<Row> {
} }
ds.close(); ds.close();
return result; return new DefaultVascBackendResult<Row>(result);
} }
public void persist(Row object) throws VascBackendException { public void persist(Row object) throws VascBackendException {

View file

@ -27,7 +27,9 @@ import java.util.List;
import java.util.logging.Logger; import java.util.logging.Logger;
import net.forwardfire.vasc.backend.AbstractVascBackend; import net.forwardfire.vasc.backend.AbstractVascBackend;
import net.forwardfire.vasc.backend.DefaultVascBackendResult;
import net.forwardfire.vasc.backend.VascBackendException; import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascBackendResult;
import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.VascBackendState;
import net.forwardfire.vasc.backend.VascEntryRecordCreator; import net.forwardfire.vasc.backend.VascEntryRecordCreator;
@ -104,7 +106,7 @@ public class MongodbVascBackend extends AbstractVascBackend<BasicDBObject> {
return query; return query;
} }
public List<BasicDBObject> execute(VascBackendState state) throws VascBackendException { public VascBackendResult<BasicDBObject> execute(VascBackendState state) throws VascBackendException {
DBCollection coll = getDBCollection(); DBCollection coll = getDBCollection();
DBObject query = createFilterQuery(state); DBObject query = createFilterQuery(state);
DBCursor cur = coll.find(query); DBCursor cur = coll.find(query);
@ -117,7 +119,7 @@ public class MongodbVascBackend extends AbstractVascBackend<BasicDBObject> {
DBObject row = cur.next(); DBObject row = cur.next();
result.add((BasicDBObject)row); result.add((BasicDBObject)row);
} }
return result; return new DefaultVascBackendResult<BasicDBObject>(result);
} }
public void persist(BasicDBObject object) throws VascBackendException { public void persist(BasicDBObject object) throws VascBackendException {

View file

@ -28,6 +28,7 @@ import java.util.Map;
import net.forwardfire.vasc.backend.VascBackend; import net.forwardfire.vasc.backend.VascBackend;
import net.forwardfire.vasc.backend.VascBackendException; import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascBackendResult;
import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.VascBackendState;
import net.forwardfire.vasc.backend.VascEntryFieldValue; import net.forwardfire.vasc.backend.VascEntryFieldValue;
import net.forwardfire.vasc.backend.VascEntryRecordCreator; import net.forwardfire.vasc.backend.VascEntryRecordCreator;
@ -90,11 +91,11 @@ public class VascServiceRemoteBackend<DATA_OBJECT extends Serializable> implemen
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public List<DATA_OBJECT> execute(VascBackendState state) throws VascBackendException { public VascBackendResult<DATA_OBJECT> execute(VascBackendState state) throws VascBackendException {
Object[] args = new Object[1]; Object[] args = new Object[1];
args[0]=state; args[0]=state;
Object result = vascManager.invokeBackendMethod(backendId, "execute", args); Object result = vascManager.invokeBackendMethod(backendId, "execute", args);
return (List<DATA_OBJECT>)result; return (VascBackendResult<DATA_OBJECT>)result;
} }
public long fetchTotalExecuteSize(VascBackendState state) { public long fetchTotalExecuteSize(VascBackendState state) {

View file

@ -23,11 +23,11 @@
package net.forwardfire.vasc.backend.proxy; package net.forwardfire.vasc.backend.proxy;
import java.io.Serializable; import java.io.Serializable;
import java.util.List;
import java.util.Map; import java.util.Map;
import net.forwardfire.vasc.backend.VascBackend; import net.forwardfire.vasc.backend.VascBackend;
import net.forwardfire.vasc.backend.VascBackendException; import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascBackendResult;
import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.VascBackendState;
import net.forwardfire.vasc.backend.VascEntryFieldValue; import net.forwardfire.vasc.backend.VascEntryFieldValue;
import net.forwardfire.vasc.backend.VascEntryRecordCreator; import net.forwardfire.vasc.backend.VascEntryRecordCreator;
@ -106,7 +106,7 @@ abstract public class AbstractVascBackendProxy implements VascBackendProxy {
* @throws Exception * @throws Exception
* @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state) * @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state)
*/ */
public List<Serializable> execute(VascBackendState state) throws VascBackendException { public VascBackendResult<Serializable> execute(VascBackendState state) throws VascBackendException {
return backend.execute(state); return backend.execute(state);
} }

View file

@ -24,10 +24,10 @@ package net.forwardfire.vasc.backend.proxy;
import java.io.Serializable; import java.io.Serializable;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import net.forwardfire.vasc.backend.VascBackendException; import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascBackendResult;
import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.VascBackendState;
/** /**
@ -39,7 +39,7 @@ import net.forwardfire.vasc.backend.VascBackendState;
public class VascBackendProxyCache extends AbstractVascBackendProxy { public class VascBackendProxyCache extends AbstractVascBackendProxy {
private Long records = null; private Long records = null;
private List<Serializable> data = null; private VascBackendResult<Serializable> data = null;
private String searchString = null; private String searchString = null;
private Map<String,Object> dataState = null; private Map<String,Object> dataState = null;
private int pageIndex = 0; private int pageIndex = 0;
@ -122,7 +122,7 @@ public class VascBackendProxyCache extends AbstractVascBackendProxy {
@Override @Override
public void stopBackend() { public void stopBackend() {
super.stopBackend(); super.stopBackend();
data.clear(); data = null;
dataState.clear(); dataState.clear();
requestFlush = true; requestFlush = true;
} }
@ -131,7 +131,7 @@ public class VascBackendProxyCache extends AbstractVascBackendProxy {
* @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state) * @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state)
*/ */
@Override @Override
public List<Serializable> execute(VascBackendState state) throws VascBackendException { public VascBackendResult<Serializable> execute(VascBackendState state) throws VascBackendException {
boolean changed = isStateChanged(state); boolean changed = isStateChanged(state);
if (data==null | changed) { if (data==null | changed) {
data = backend.execute(state); data = backend.execute(state);

View file

@ -28,6 +28,7 @@ import java.util.List;
import net.forwardfire.vasc.backend.VascBackend; import net.forwardfire.vasc.backend.VascBackend;
import net.forwardfire.vasc.backend.VascBackendException; import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascBackendResult;
import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.VascBackendState;
import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntry;
import net.forwardfire.vasc.core.entry.VascEntryBackendEventListener; 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) * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#execute(net.forwardfire.vasc.backend.VascBackendState)
*/ */
@Override @Override
public List<Serializable> execute(VascBackendState state) throws VascBackendException { public VascBackendResult<Serializable> execute(VascBackendState state) throws VascBackendException {
fireVascEvent(VascBackendEventType.PRE_EXECUTE,state); fireVascEvent(VascBackendEventType.PRE_EXECUTE,state);
List<Serializable> result = super.execute(state); VascBackendResult<Serializable> result = super.execute(state);
fireVascEvent(VascBackendEventType.POST_EXECUTE,result); fireVascEvent(VascBackendEventType.POST_EXECUTE,result);
return result; return result;
} }

View file

@ -26,8 +26,10 @@ import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.forwardfire.vasc.backend.DefaultVascBackendResult;
import net.forwardfire.vasc.backend.VascBackend; import net.forwardfire.vasc.backend.VascBackend;
import net.forwardfire.vasc.backend.VascBackendException; import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascBackendResult;
import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.VascBackendState;
import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntry;
@ -77,16 +79,16 @@ public class VascBackendProxyFilter extends AbstractVascBackendProxy {
* @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state) * @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state)
*/ */
@Override @Override
public List<Serializable> execute(VascBackendState state) throws VascBackendException { public VascBackendResult<Serializable> execute(VascBackendState state) throws VascBackendException {
List<Serializable> result = backend.execute(state); VascBackendResult<Serializable> result = backend.execute(state);
if (filters==null) { if (filters==null) {
return result; return result;
} }
if (filters.isEmpty()) { if (filters.isEmpty()) {
return result; return result;
} }
List<Serializable> search = new ArrayList<Serializable>(result.size()/2); List<Serializable> search = new ArrayList<Serializable>(result.getPageData().size()/2);
for (Serializable o:result) { for (Serializable o:result.getPageData()) {
for (VascProxyFilter filter:filters) { for (VascProxyFilter filter:filters) {
Serializable r = filter.filterObject(o); Serializable r = filter.filterObject(o);
if (r!=null) { if (r!=null) {
@ -95,7 +97,7 @@ public class VascBackendProxyFilter extends AbstractVascBackendProxy {
} }
} }
records = search.size(); records = search.size();
return search; return new DefaultVascBackendResult<Serializable>(search);
} }
@Override @Override

View file

@ -26,7 +26,9 @@ import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.forwardfire.vasc.backend.DefaultVascBackendResult;
import net.forwardfire.vasc.backend.VascBackendException; import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascBackendResult;
import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.VascBackendState;
/** /**
@ -71,25 +73,25 @@ public class VascBackendProxyPaged extends AbstractVascBackendProxy {
* @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state) * @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state)
*/ */
@Override @Override
public List<Serializable> execute(VascBackendState state) throws VascBackendException { public VascBackendResult<Serializable> execute(VascBackendState state) throws VascBackendException {
List<Serializable> allData = backend.execute(state); VascBackendResult<Serializable> allData = backend.execute(state);
int pageSize = state.getPageSize(); int pageSize = state.getPageSize();
if (pageSize==0) { if (pageSize==0) {
records = allData.size(); records = allData.getPageData().size();
return allData; return allData;
} }
List<Serializable> paged = new ArrayList<Serializable>(state.getPageSize()); List<Serializable> paged = new ArrayList<Serializable>(state.getPageSize());
int off = state.getPageIndex()*pageSize; int off = state.getPageIndex()*pageSize;
int offMax = off+state.getPageSize(); int offMax = off+state.getPageSize();
for (int i=off;i<offMax;i++) { for (int i=off;i<offMax;i++) {
if (i>=allData.size()) { if (i>=allData.getPageData().size()) {
break; break;
} }
Serializable o = allData.get(i); Serializable o = allData.getPageData().get(i);
paged.add(o); paged.add(o);
} }
records = allData.size(); records = allData.getPageData().size();
return paged; return new DefaultVascBackendResult<Serializable>(paged);
} }
@Override @Override

View file

@ -26,7 +26,9 @@ import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.forwardfire.vasc.backend.DefaultVascBackendResult;
import net.forwardfire.vasc.backend.VascBackendException; import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascBackendResult;
import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.VascBackendState;
import net.forwardfire.vasc.backend.VascEntryFieldValue; import net.forwardfire.vasc.backend.VascEntryFieldValue;
import net.forwardfire.vasc.core.VascEntryField; import net.forwardfire.vasc.core.VascEntryField;
@ -71,8 +73,8 @@ public class VascBackendProxySearch extends AbstractVascBackendProxy {
* @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state) * @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state)
*/ */
@Override @Override
public List<Serializable> execute(VascBackendState state) throws VascBackendException { public VascBackendResult<Serializable> execute(VascBackendState state) throws VascBackendException {
List<Serializable> result = backend.execute(state); VascBackendResult<Serializable> result = backend.execute(state);
if (state.getSearchString()==null) { if (state.getSearchString()==null) {
return result; return result;
} }
@ -80,8 +82,8 @@ public class VascBackendProxySearch extends AbstractVascBackendProxy {
return result; return result;
} }
String searchString = state.getSearchString().toLowerCase(); String searchString = state.getSearchString().toLowerCase();
List<Serializable> search = new ArrayList<Serializable>(result.size()/4); List<Serializable> search = new ArrayList<Serializable>(result.getPageData().size()/4);
for (Serializable record:result) { for (Serializable record:result.getPageData()) {
for (VascEntryField field:entry.getVascEntryFields()) { for (VascEntryField field:entry.getVascEntryFields()) {
VascEntryFieldValue<Serializable> fieldValue = backend.provideVascEntryFieldValue(); VascEntryFieldValue<Serializable> fieldValue = backend.provideVascEntryFieldValue();
Serializable value = fieldValue.getValue(field.getBackendName(), record); Serializable value = fieldValue.getValue(field.getBackendName(), record);
@ -133,7 +135,7 @@ public class VascBackendProxySearch extends AbstractVascBackendProxy {
*/ */
} }
//records = search.size(); //records = search.size();
return search; return new DefaultVascBackendResult<Serializable>(search);
} }
@Override @Override

View file

@ -25,9 +25,9 @@ package net.forwardfire.vasc.backend.proxy;
import java.io.Serializable; import java.io.Serializable;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.List;
import net.forwardfire.vasc.backend.VascBackendException; import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascBackendResult;
import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.VascBackendState;
import net.forwardfire.vasc.backend.VascEntryFieldValue; import net.forwardfire.vasc.backend.VascEntryFieldValue;
import net.forwardfire.vasc.core.VascEntryField; import net.forwardfire.vasc.core.VascEntryField;
@ -74,14 +74,14 @@ public class VascBackendProxySort extends AbstractVascBackendProxy {
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public List<Serializable> execute(final VascBackendState state) throws VascBackendException { public VascBackendResult<Serializable> execute(final VascBackendState state) throws VascBackendException {
List<Serializable> result = backend.execute(state); VascBackendResult<Serializable> result = backend.execute(state);
if (state.getSortField()==null) { if (state.getSortField()==null) {
return result; return result;
} }
final VascEntryField field = getVascEntryFieldByBackendName(state.getSortField()); final VascEntryField field = getVascEntryFieldByBackendName(state.getSortField());
final VascEntryFieldValue<Serializable> fieldValue = backend.provideVascEntryFieldValue(); final VascEntryFieldValue<Serializable> fieldValue = backend.provideVascEntryFieldValue();
Collections.sort(result, new Comparator<Serializable>() { Collections.sort(result.getPageData(), new Comparator<Serializable>() {
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
public int compare(Serializable o1, Serializable o2) { public int compare(Serializable o1, Serializable o2) {
try { try {

View file

@ -23,11 +23,11 @@
package net.forwardfire.vasc.backend.proxy; package net.forwardfire.vasc.backend.proxy;
import java.io.Serializable; import java.io.Serializable;
import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import net.forwardfire.vasc.backend.VascBackendException; import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascBackendResult;
import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.VascBackendState;
/** /**
@ -59,7 +59,7 @@ public class VascBackendProxyTimerLogger extends AbstractVascBackendProxy {
* @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state) * @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state)
*/ */
@Override @Override
public List<Serializable> execute(VascBackendState state) throws VascBackendException { public VascBackendResult<Serializable> execute(VascBackendState state) throws VascBackendException {
long t1 = System.currentTimeMillis(); long t1 = System.currentTimeMillis();
try { try {
return backend.execute(state); return backend.execute(state);

View file

@ -37,5 +37,6 @@ import net.forwardfire.vasc.core.VascEntryField;
*/ */
public interface VascFrontendUserSettingController { public interface VascFrontendUserSettingController {
//public Map<String,String> getSettings();
//public void putSetting(String key,String value);
} }

View file

@ -231,7 +231,7 @@ public class DefaultVascFrontendActions implements VascFrontendActions {
try { try {
// Execute to get data. // 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 // Fire event post read
entry.getVascFrontendController().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.POST_READ, null); entry.getVascFrontendController().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.POST_READ, null);

View file

@ -170,7 +170,7 @@ public class VascSelectItemModelEntry implements VascSelectItemModel {
// execute // execute
for (Serializable o:back.execute(state)) { for (Serializable o:back.execute(state).getPageData()) {
Serializable keyId = key.getVascEntryFieldValue().getValue(key.getBackendName(), o); Serializable keyId = key.getVascEntryFieldValue().getValue(key.getBackendName(), o);
String nameId = dis.getVascEntryFieldValue().getDisplayValue(dis.getBackendName(), o); String nameId = dis.getVascEntryFieldValue().getDisplayValue(dis.getBackendName(), o);
if (returnKeyValue!=null && false==returnKeyValue) { if (returnKeyValue!=null && false==returnKeyValue) {

View file

@ -5,7 +5,9 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.forwardfire.vasc.backend.AbstractVascBackend; import net.forwardfire.vasc.backend.AbstractVascBackend;
import net.forwardfire.vasc.backend.DefaultVascBackendResult;
import net.forwardfire.vasc.backend.VascBackendException; import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascBackendResult;
import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.VascBackendState;
import net.forwardfire.vasc.backend.VascEntryFieldValue; import net.forwardfire.vasc.backend.VascEntryFieldValue;
import net.forwardfire.vasc.backend.VascEntryRecordCreator; import net.forwardfire.vasc.backend.VascEntryRecordCreator;
@ -34,7 +36,7 @@ public class VirtualVascBackend extends AbstractVascBackend<Serializable> {
private String vascType = "entry"; private String vascType = "entry";
private String entryId = null; private String entryId = null;
public List<Serializable> execute(VascBackendState state) throws VascBackendException { public VascBackendResult<Serializable> execute(VascBackendState state) throws VascBackendException {
List<Serializable> result = new ArrayList<Serializable>(100); List<Serializable> result = new ArrayList<Serializable>(100);
entryId = (String)state.getDataParameter("entry_id"); entryId = (String)state.getDataParameter("entry_id");
if ("entry".equals(vascType)) { if ("entry".equals(vascType)) {
@ -63,7 +65,7 @@ public class VirtualVascBackend extends AbstractVascBackend<Serializable> {
} }
} }
return result; return new DefaultVascBackendResult<Serializable>(result);
} }
public void persist(Serializable object) throws VascBackendException { public void persist(Serializable object) throws VascBackendException {

View file

@ -31,7 +31,9 @@ import org.x4o.xml.element.DefaultElementObjectPropertyValue;
import org.x4o.xml.element.ElementObjectPropertyValueException; import org.x4o.xml.element.ElementObjectPropertyValueException;
import net.forwardfire.vasc.backend.AbstractVascBackend; import net.forwardfire.vasc.backend.AbstractVascBackend;
import net.forwardfire.vasc.backend.DefaultVascBackendResult;
import net.forwardfire.vasc.backend.VascBackendException; import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascBackendResult;
import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.VascBackendState;
import net.forwardfire.vasc.backend.VascEntryFieldValue; import net.forwardfire.vasc.backend.VascEntryFieldValue;
import net.forwardfire.vasc.backend.VascEntryRecordCreator; import net.forwardfire.vasc.backend.VascEntryRecordCreator;
@ -102,7 +104,7 @@ public class TestModelVascDataSource {
return modelList; return modelList;
} }
public List<DATA_OBJECT> execute(VascBackendState state) throws VascBackendException { public VascBackendResult<DATA_OBJECT> execute(VascBackendState state) throws VascBackendException {
if (state.getDataParameterKeys().isEmpty()==false) { if (state.getDataParameterKeys().isEmpty()==false) {
List<DATA_OBJECT> result = new ArrayList<DATA_OBJECT>(modelList.size()/2); List<DATA_OBJECT> result = new ArrayList<DATA_OBJECT>(modelList.size()/2);
DefaultElementObjectPropertyValue helper = new DefaultElementObjectPropertyValue(); DefaultElementObjectPropertyValue helper = new DefaultElementObjectPropertyValue();
@ -128,13 +130,13 @@ public class TestModelVascDataSource {
result.add(row); result.add(row);
} }
} }
return result; return new DefaultVascBackendResult<DATA_OBJECT>(result);
} else { } else {
List<DATA_OBJECT> result = new ArrayList<DATA_OBJECT>(modelList.size()); List<DATA_OBJECT> result = new ArrayList<DATA_OBJECT>(modelList.size());
for (DATA_OBJECT row:modelList) { for (DATA_OBJECT row:modelList) {
result.add(row); result.add(row);
} }
return result; return new DefaultVascBackendResult<DATA_OBJECT>(result);
} }
} }