WIP added backend generics so all is seriazible and started to make
execute return full result.
This commit is contained in:
parent
3bf185ad48
commit
90b81deb29
|
@ -17,5 +17,6 @@
|
|||
<module>vasc-backend-jdbc</module>
|
||||
<module>vasc-backend-metamodel</module>
|
||||
<module>vasc-backend-api</module>
|
||||
<module>vasc-backend-test</module>
|
||||
</modules>
|
||||
</project>
|
||||
|
|
|
@ -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<String,VascBackend> backends = null;
|
||||
private Map<String,VascBackend<Serializable>> backends = null;
|
||||
|
||||
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)
|
||||
*/
|
||||
public VascBackend getVascBackendById(String id) {
|
||||
public VascBackend<Serializable> 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<? extends Serializable> 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<Serializable> castedBackend = (VascBackend<Serializable>) 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<? extends Serializable> backend = getVascBackendById(backendId);
|
||||
if (backend==null) {
|
||||
throw new NullPointerException("Could not find backend to remove with id: "+backendId);
|
||||
}
|
||||
|
|
|
@ -40,15 +40,17 @@ public interface VascBackend<DATA_OBJECT extends Serializable> {
|
|||
public void startBackend();
|
||||
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 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.
|
||||
|
@ -102,10 +104,4 @@ public interface VascBackend<DATA_OBJECT extends Serializable> {
|
|||
|
||||
public boolean hasTotalSummary();
|
||||
public Map<String,Object> executeTotalSummary();
|
||||
|
||||
/*
|
||||
public boolean hasSettings();
|
||||
public Map<String,String> getSettings();
|
||||
public void putSetting(String key,String value);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<? extends Serializable> backend);
|
||||
|
||||
public void removeVascBackendById(String backendId);
|
||||
|
||||
|
|
|
@ -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<HashMap<String,Object>>
|
|||
/**
|
||||
* @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();
|
||||
List<HashMap<String,Object>> result = new ArrayList<HashMap<String,Object>>(50);
|
||||
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)
|
||||
*/
|
||||
public HashMap<String,Object> merge(HashMap<String,Object> object) throws VascBackendException {
|
||||
return object;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#persist(java.lang.Object)
|
||||
*/
|
||||
|
|
|
@ -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<HashMap<String,Obje
|
|||
/**
|
||||
* @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
|
||||
for (String key:state.getDataParameterKeys()) {
|
||||
Object value = state.getDataParameter(key);
|
||||
|
@ -120,7 +122,7 @@ public class JdbcVascBackendXpql extends AbstractVascBackend<HashMap<String,Obje
|
|||
}
|
||||
result.add(map);
|
||||
}
|
||||
return result;
|
||||
return new DefaultVascBackendResult<HashMap<String,Object>>(result);
|
||||
} catch (SQLException e) {
|
||||
throw new VascBackendException(e);
|
||||
} finally {
|
||||
|
|
|
@ -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<DATA_OBJECT extends Serializable> extends
|
|||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<DATA_OBJECT> execute(VascBackendState state) throws VascBackendException {
|
||||
public VascBackendResult<DATA_OBJECT> execute(VascBackendState state) throws VascBackendException {
|
||||
|
||||
// Copy parameters
|
||||
for (String key:state.getDataParameterKeys()) {
|
||||
|
@ -106,7 +109,8 @@ public class XpqlHibernateVascBackend<DATA_OBJECT extends Serializable> extends
|
|||
}
|
||||
List<DATA_OBJECT> data = q.list();
|
||||
s.getTransaction().commit();
|
||||
return data;
|
||||
|
||||
return new DefaultVascBackendResult<DATA_OBJECT>(data);
|
||||
} finally {
|
||||
if (s!=null) {
|
||||
//em.close();
|
||||
|
|
|
@ -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<DATA_OBJECT extends Serializable> extend
|
|||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<DATA_OBJECT> execute(VascBackendState state) throws VascBackendException {
|
||||
public VascBackendResult<DATA_OBJECT> execute(VascBackendState state) throws VascBackendException {
|
||||
|
||||
// Copy parameters
|
||||
for (String key:state.getDataParameterKeys()) {
|
||||
|
@ -111,7 +113,8 @@ public class XpqlPersistanceVascBackend<DATA_OBJECT extends Serializable> extend
|
|||
if (emTransaction) {
|
||||
em.getTransaction().commit();
|
||||
}
|
||||
return data;
|
||||
VascBackendResult<DATA_OBJECT> result = new DefaultVascBackendResult<DATA_OBJECT>(data);
|
||||
return result;
|
||||
} finally {
|
||||
if (em!=null) {
|
||||
//em.close();
|
||||
|
|
|
@ -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<HashMap<String,Object>>
|
|||
/**
|
||||
* @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();
|
||||
LDAPConnection connection = prov.getLdapConnection();
|
||||
List<HashMap<String,Object>> result = new ArrayList<HashMap<String,Object>>(50);
|
||||
|
@ -128,7 +130,7 @@ public class LdapVascBackend extends AbstractVascBackend<HashMap<String,Object>>
|
|||
} finally {
|
||||
safeDisconnect(connection);
|
||||
}
|
||||
return result;
|
||||
return new DefaultVascBackendResult<HashMap<String,Object>>(result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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<Row> {
|
|||
return q;
|
||||
}
|
||||
|
||||
public List<Row> execute(VascBackendState state) throws VascBackendException {
|
||||
public VascBackendResult<Row> 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<Row> {
|
|||
DataSet ds = crudDataContext.executeQuery(q);
|
||||
result.addAll(ds.toRows());
|
||||
ds.close();
|
||||
return result;
|
||||
return new DefaultVascBackendResult<Row>(result);
|
||||
}
|
||||
|
||||
DataSet ds = dataContext.executeQuery(q);
|
||||
|
@ -258,7 +260,7 @@ public class MetaModelVascBackend extends AbstractVascBackend<Row> {
|
|||
}
|
||||
ds.close();
|
||||
|
||||
return result;
|
||||
return new DefaultVascBackendResult<Row>(result);
|
||||
}
|
||||
|
||||
public void persist(Row object) throws VascBackendException {
|
||||
|
|
|
@ -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<BasicDBObject> {
|
|||
return query;
|
||||
}
|
||||
|
||||
public List<BasicDBObject> execute(VascBackendState state) throws VascBackendException {
|
||||
public VascBackendResult<BasicDBObject> 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<BasicDBObject> {
|
|||
DBObject row = cur.next();
|
||||
result.add((BasicDBObject)row);
|
||||
}
|
||||
return result;
|
||||
return new DefaultVascBackendResult<BasicDBObject>(result);
|
||||
}
|
||||
|
||||
public void persist(BasicDBObject object) throws VascBackendException {
|
||||
|
|
|
@ -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<DATA_OBJECT extends Serializable> implemen
|
|||
}
|
||||
|
||||
@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];
|
||||
args[0]=state;
|
||||
Object result = vascManager.invokeBackendMethod(backendId, "execute", args);
|
||||
return (List<DATA_OBJECT>)result;
|
||||
return (VascBackendResult<DATA_OBJECT>)result;
|
||||
}
|
||||
|
||||
public long fetchTotalExecuteSize(VascBackendState state) {
|
||||
|
|
|
@ -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<Serializable> execute(VascBackendState state) throws VascBackendException {
|
||||
public VascBackendResult<Serializable> execute(VascBackendState state) throws VascBackendException {
|
||||
return backend.execute(state);
|
||||
}
|
||||
|
||||
|
|
|
@ -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<Serializable> data = null;
|
||||
private VascBackendResult<Serializable> data = null;
|
||||
private String searchString = null;
|
||||
private Map<String,Object> 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<Serializable> execute(VascBackendState state) throws VascBackendException {
|
||||
public VascBackendResult<Serializable> execute(VascBackendState state) throws VascBackendException {
|
||||
boolean changed = isStateChanged(state);
|
||||
if (data==null | changed) {
|
||||
data = backend.execute(state);
|
||||
|
|
|
@ -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<Serializable> execute(VascBackendState state) throws VascBackendException {
|
||||
public VascBackendResult<Serializable> execute(VascBackendState state) throws VascBackendException {
|
||||
fireVascEvent(VascBackendEventType.PRE_EXECUTE,state);
|
||||
List<Serializable> result = super.execute(state);
|
||||
VascBackendResult<Serializable> result = super.execute(state);
|
||||
fireVascEvent(VascBackendEventType.POST_EXECUTE,result);
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -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<Serializable> execute(VascBackendState state) throws VascBackendException {
|
||||
List<Serializable> result = backend.execute(state);
|
||||
public VascBackendResult<Serializable> execute(VascBackendState state) throws VascBackendException {
|
||||
VascBackendResult<Serializable> result = backend.execute(state);
|
||||
if (filters==null) {
|
||||
return result;
|
||||
}
|
||||
if (filters.isEmpty()) {
|
||||
return result;
|
||||
}
|
||||
List<Serializable> search = new ArrayList<Serializable>(result.size()/2);
|
||||
for (Serializable o:result) {
|
||||
List<Serializable> search = new ArrayList<Serializable>(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<Serializable>(search);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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<Serializable> execute(VascBackendState state) throws VascBackendException {
|
||||
List<Serializable> allData = backend.execute(state);
|
||||
public VascBackendResult<Serializable> execute(VascBackendState state) throws VascBackendException {
|
||||
VascBackendResult<Serializable> allData = backend.execute(state);
|
||||
int pageSize = state.getPageSize();
|
||||
if (pageSize==0) {
|
||||
records = allData.size();
|
||||
records = allData.getPageData().size();
|
||||
return allData;
|
||||
}
|
||||
List<Serializable> paged = new ArrayList<Serializable>(state.getPageSize());
|
||||
int off = state.getPageIndex()*pageSize;
|
||||
int offMax = off+state.getPageSize();
|
||||
for (int i=off;i<offMax;i++) {
|
||||
if (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<Serializable>(paged);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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<Serializable> execute(VascBackendState state) throws VascBackendException {
|
||||
List<Serializable> result = backend.execute(state);
|
||||
public VascBackendResult<Serializable> execute(VascBackendState state) throws VascBackendException {
|
||||
VascBackendResult<Serializable> 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<Serializable> search = new ArrayList<Serializable>(result.size()/4);
|
||||
for (Serializable record:result) {
|
||||
List<Serializable> search = new ArrayList<Serializable>(result.getPageData().size()/4);
|
||||
for (Serializable record:result.getPageData()) {
|
||||
for (VascEntryField field:entry.getVascEntryFields()) {
|
||||
VascEntryFieldValue<Serializable> 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<Serializable>(search);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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<Serializable> execute(final VascBackendState state) throws VascBackendException {
|
||||
List<Serializable> result = backend.execute(state);
|
||||
public VascBackendResult<Serializable> execute(final VascBackendState state) throws VascBackendException {
|
||||
VascBackendResult<Serializable> result = backend.execute(state);
|
||||
if (state.getSortField()==null) {
|
||||
return result;
|
||||
}
|
||||
final VascEntryField field = getVascEntryFieldByBackendName(state.getSortField());
|
||||
final VascEntryFieldValue<Serializable> fieldValue = backend.provideVascEntryFieldValue();
|
||||
Collections.sort(result, new Comparator<Serializable>() {
|
||||
Collections.sort(result.getPageData(), new Comparator<Serializable>() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
public int compare(Serializable o1, Serializable o2) {
|
||||
try {
|
||||
|
|
|
@ -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<Serializable> execute(VascBackendState state) throws VascBackendException {
|
||||
public VascBackendResult<Serializable> execute(VascBackendState state) throws VascBackendException {
|
||||
long t1 = System.currentTimeMillis();
|
||||
try {
|
||||
return backend.execute(state);
|
||||
|
|
|
@ -37,5 +37,6 @@ import net.forwardfire.vasc.core.VascEntryField;
|
|||
*/
|
||||
public interface VascFrontendUserSettingController {
|
||||
|
||||
|
||||
//public Map<String,String> getSettings();
|
||||
//public void putSetting(String key,String value);
|
||||
}
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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<Serializable> {
|
|||
private String vascType = "entry";
|
||||
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);
|
||||
entryId = (String)state.getDataParameter("entry_id");
|
||||
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 {
|
||||
|
|
|
@ -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<DATA_OBJECT> execute(VascBackendState state) throws VascBackendException {
|
||||
public VascBackendResult<DATA_OBJECT> execute(VascBackendState state) throws VascBackendException {
|
||||
if (state.getDataParameterKeys().isEmpty()==false) {
|
||||
List<DATA_OBJECT> result = new ArrayList<DATA_OBJECT>(modelList.size()/2);
|
||||
DefaultElementObjectPropertyValue helper = new DefaultElementObjectPropertyValue();
|
||||
|
@ -128,13 +130,13 @@ public class TestModelVascDataSource {
|
|||
result.add(row);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return new DefaultVascBackendResult<DATA_OBJECT>(result);
|
||||
} else {
|
||||
List<DATA_OBJECT> result = new ArrayList<DATA_OBJECT>(modelList.size());
|
||||
for (DATA_OBJECT row:modelList) {
|
||||
result.add(row);
|
||||
}
|
||||
return result;
|
||||
return new DefaultVascBackendResult<DATA_OBJECT>(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue