Upgraded backend api with generics.
This commit is contained in:
parent
9a6227be5b
commit
1b3e65fa83
|
@ -22,6 +22,7 @@
|
|||
|
||||
package net.forwardfire.vasc.backend;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
@ -29,7 +30,7 @@ import java.util.Map;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 Aug 2, 2007
|
||||
*/
|
||||
abstract public class AbstractVascBackend implements VascBackend {
|
||||
abstract public class AbstractVascBackend<DATA_OBJECT extends Serializable> implements VascBackend<DATA_OBJECT> {
|
||||
|
||||
private String id = null;
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
package net.forwardfire.vasc.backend;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -31,7 +32,7 @@ import java.util.Map;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 21, 2007
|
||||
*/
|
||||
public interface VascBackend {
|
||||
public interface VascBackend<DATA_OBJECT extends Serializable> {
|
||||
|
||||
public String getId();
|
||||
public void setId(String id);
|
||||
|
@ -39,15 +40,15 @@ public interface VascBackend {
|
|||
public void startBackend();
|
||||
public void stopBackend();
|
||||
|
||||
public List<Object> execute(VascBackendState state) throws VascBackendException;
|
||||
public List<DATA_OBJECT> execute(VascBackendState state) throws VascBackendException;
|
||||
|
||||
public boolean isReadOnly();
|
||||
|
||||
public void persist(Object object) throws VascBackendException;
|
||||
public void persist(DATA_OBJECT object) throws VascBackendException;
|
||||
|
||||
public Object merge(Object object) throws VascBackendException;
|
||||
public DATA_OBJECT merge(DATA_OBJECT object) throws VascBackendException;
|
||||
|
||||
public void delete(Object object) throws VascBackendException;
|
||||
public void delete(DATA_OBJECT object) throws VascBackendException;
|
||||
|
||||
/**
|
||||
* Creates a new Field acces obj the the given field entry.
|
||||
|
@ -61,7 +62,7 @@ public interface VascBackend {
|
|||
* note: Do not use inline class here because it needs to be seriabable and the backend is not seriabbzle.
|
||||
* @return
|
||||
*/
|
||||
public VascEntryRecordCreator provideVascEntryRecordCreator();
|
||||
public VascEntryRecordCreator<DATA_OBJECT> provideVascEntryRecordCreator();
|
||||
|
||||
/**
|
||||
* Defines if the backend supports sorting
|
||||
|
|
|
@ -30,9 +30,7 @@ import java.io.Serializable;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 21, 2007
|
||||
*/
|
||||
public interface VascEntryRecordCreator extends Serializable {
|
||||
public interface VascEntryRecordCreator<DATA_OBJECT extends Serializable> extends Serializable {
|
||||
|
||||
public Object newRecord() throws VascBackendException;
|
||||
|
||||
public Class<?> getObjectClass();
|
||||
public DATA_OBJECT newRecord() throws VascBackendException;
|
||||
}
|
|
@ -22,6 +22,8 @@
|
|||
|
||||
package net.forwardfire.vasc.backend.data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackendException;
|
||||
import net.forwardfire.vasc.backend.VascEntryRecordCreator;
|
||||
|
||||
|
@ -32,7 +34,7 @@ import net.forwardfire.vasc.backend.VascEntryRecordCreator;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 Dec 05, 2009
|
||||
*/
|
||||
public class BeanVascEntryRecordCreator implements VascEntryRecordCreator {
|
||||
public class BeanVascEntryRecordCreator<DATA_OBJECT extends Serializable> implements VascEntryRecordCreator<DATA_OBJECT> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Class<?> resultClass = null;
|
||||
|
@ -43,14 +45,11 @@ public class BeanVascEntryRecordCreator implements VascEntryRecordCreator {
|
|||
}
|
||||
this.resultClass=resultClass;
|
||||
}
|
||||
|
||||
public Class<?> getObjectClass() {
|
||||
return resultClass;
|
||||
}
|
||||
|
||||
public Object newRecord() throws VascBackendException {
|
||||
@SuppressWarnings("unchecked")
|
||||
public DATA_OBJECT newRecord() throws VascBackendException {
|
||||
try {
|
||||
return resultClass.newInstance();
|
||||
return (DATA_OBJECT)resultClass.newInstance();
|
||||
} catch (InstantiationException e) {
|
||||
throw new VascBackendException(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
|
|
|
@ -34,7 +34,7 @@ import net.forwardfire.vasc.backend.VascEntryFieldValue;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 Dec 05, 2009
|
||||
*/
|
||||
public class MapVascEntryFieldValue implements VascEntryFieldValue {
|
||||
public class HashMapVascEntryFieldValue implements VascEntryFieldValue {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
|
@ -23,27 +23,21 @@
|
|||
package net.forwardfire.vasc.backend.data;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackendException;
|
||||
import net.forwardfire.vasc.backend.VascEntryRecordCreator;
|
||||
|
||||
|
||||
/**
|
||||
* MapVascEntryRecordCreator creates a new HashMap for Map based record backends.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Dec 05, 2009
|
||||
*/
|
||||
public class MapVascEntryRecordCreator implements VascEntryRecordCreator {
|
||||
public class HashMapVascEntryRecordCreator implements VascEntryRecordCreator<HashMap<String,Object>> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Class<?> getObjectClass() {
|
||||
return Map.class;
|
||||
}
|
||||
|
||||
public Object newRecord() throws VascBackendException {
|
||||
public HashMap<String,Object> newRecord() throws VascBackendException {
|
||||
return new HashMap<String,Object>(10);
|
||||
}
|
||||
}
|
|
@ -24,20 +24,19 @@ package net.forwardfire.vasc.backend.jdbc;
|
|||
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.forwardfire.vasc.backend.AbstractVascBackend;
|
||||
import net.forwardfire.vasc.backend.VascBackendException;
|
||||
import net.forwardfire.vasc.backend.VascBackendState;
|
||||
import net.forwardfire.vasc.backend.VascEntryFieldValue;
|
||||
import net.forwardfire.vasc.backend.VascEntryRecordCreator;
|
||||
import net.forwardfire.vasc.backend.data.MapVascEntryFieldValue;
|
||||
import net.forwardfire.vasc.backend.data.MapVascEntryRecordCreator;
|
||||
|
||||
import net.forwardfire.vasc.backend.data.HashMapVascEntryFieldValue;
|
||||
import net.forwardfire.vasc.backend.data.HashMapVascEntryRecordCreator;
|
||||
|
||||
/**
|
||||
* JdbcVascBackend Simple jdbc vasc backend.
|
||||
|
@ -45,7 +44,7 @@ import net.forwardfire.vasc.backend.data.MapVascEntryRecordCreator;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 Sep 5, 2008
|
||||
*/
|
||||
public class JdbcVascBackend extends AbstractVascBackend {
|
||||
public class JdbcVascBackend extends AbstractVascBackend<HashMap<String,Object>> {
|
||||
|
||||
private JdbcConnectionProvider jdbcConnectionProvider = null;
|
||||
private String sqlList = null;
|
||||
|
@ -80,9 +79,9 @@ public class JdbcVascBackend extends AbstractVascBackend {
|
|||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state)
|
||||
*/
|
||||
public List<Object> execute(VascBackendState state) throws VascBackendException {
|
||||
public List<HashMap<String,Object>> execute(VascBackendState state) throws VascBackendException {
|
||||
JdbcConnectionProvider prov = getJdbcConnectionProvider();
|
||||
List<Object> result = new ArrayList<Object>(50);
|
||||
List<HashMap<String,Object>> result = new ArrayList<HashMap<String,Object>>(50);
|
||||
Connection connection = null;
|
||||
try {
|
||||
connection = prov.getJdbcConnection();
|
||||
|
@ -91,7 +90,7 @@ public class JdbcVascBackend extends AbstractVascBackend {
|
|||
ResultSet rs = s.getResultSet();
|
||||
int cols = rs.getMetaData().getColumnCount();
|
||||
while (rs.next()) {
|
||||
Map<String,Object> map = new HashMap<String,Object>(cols);
|
||||
HashMap<String,Object> map = new HashMap<String,Object>(cols);
|
||||
for (int i=1;i<=cols;i++) {
|
||||
String columnName = rs.getMetaData().getColumnName(i);
|
||||
Object columnObject = rs.getObject(i);
|
||||
|
@ -99,7 +98,7 @@ public class JdbcVascBackend extends AbstractVascBackend {
|
|||
}
|
||||
result.add(map);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (SQLException e) {
|
||||
throw new VascBackendException(e);
|
||||
} finally {
|
||||
if (connection!=null) {
|
||||
|
@ -115,34 +114,34 @@ public class JdbcVascBackend extends AbstractVascBackend {
|
|||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#merge(java.lang.Object)
|
||||
*/
|
||||
public Object merge(Object object) throws VascBackendException {
|
||||
public HashMap<String,Object> merge(HashMap<String,Object> object) throws VascBackendException {
|
||||
return object;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#persist(java.lang.Object)
|
||||
*/
|
||||
public void persist(Object object) throws VascBackendException {
|
||||
public void persist(HashMap<String,Object> object) throws VascBackendException {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#delete(java.lang.Object)
|
||||
*/
|
||||
public void delete(Object object) throws VascBackendException {
|
||||
public void delete(HashMap<String,Object> object) throws VascBackendException {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryFieldValue(net.forwardfire.vasc.core.VascEntryField)
|
||||
*/
|
||||
public VascEntryFieldValue provideVascEntryFieldValue() {
|
||||
return new MapVascEntryFieldValue();
|
||||
return new HashMapVascEntryFieldValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryRecordCreator(net.forwardfire.vasc.core.VascEntry)
|
||||
*/
|
||||
public VascEntryRecordCreator provideVascEntryRecordCreator() {
|
||||
return new MapVascEntryRecordCreator();
|
||||
return new HashMapVascEntryRecordCreator();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -25,29 +25,27 @@ package net.forwardfire.vasc.backend.jdbc;
|
|||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.forwardfire.vasc.backend.AbstractVascBackend;
|
||||
import net.forwardfire.vasc.backend.VascBackendException;
|
||||
import net.forwardfire.vasc.backend.VascBackendState;
|
||||
import net.forwardfire.vasc.backend.VascEntryFieldValue;
|
||||
import net.forwardfire.vasc.backend.VascEntryRecordCreator;
|
||||
import net.forwardfire.vasc.backend.data.MapVascEntryFieldValue;
|
||||
import net.forwardfire.vasc.backend.data.MapVascEntryRecordCreator;
|
||||
import net.forwardfire.vasc.backend.data.HashMapVascEntryFieldValue;
|
||||
import net.forwardfire.vasc.backend.data.HashMapVascEntryRecordCreator;
|
||||
import net.forwardfire.vasc.xpql.query.QueryParameterValue;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* JdbcVascBackendXpql jdbc vasc backend with xpql query support.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Sep 5, 2008
|
||||
*/
|
||||
public class JdbcVascBackendXpql extends AbstractVascBackend {
|
||||
public class JdbcVascBackendXpql extends AbstractVascBackend<HashMap<String,Object>> {
|
||||
|
||||
private JdbcConnectionProvider jdbcConnectionProvider = null;
|
||||
|
||||
|
@ -92,7 +90,7 @@ public class JdbcVascBackendXpql extends AbstractVascBackend {
|
|||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state)
|
||||
*/
|
||||
public List<Object> execute(VascBackendState state) throws VascBackendException {
|
||||
public List<HashMap<String,Object>> execute(VascBackendState state) throws VascBackendException {
|
||||
// Copy parameters
|
||||
for (String key:state.getDataParameterKeys()) {
|
||||
Object value = state.getDataParameter(key);
|
||||
|
@ -112,9 +110,9 @@ public class JdbcVascBackendXpql extends AbstractVascBackend {
|
|||
q.execute();
|
||||
ResultSet rs = q.getResultSet();
|
||||
int cols = rs.getMetaData().getColumnCount();
|
||||
List<Object> result = new ArrayList<Object>(50);
|
||||
List<HashMap<String,Object>> result = new ArrayList<HashMap<String,Object>>(50);
|
||||
while (rs.next()) {
|
||||
Map<String,Object> map = new HashMap<String,Object>(cols);
|
||||
HashMap<String,Object> map = new HashMap<String,Object>(cols);
|
||||
for (int i=1;i<=cols;i++) {
|
||||
String columnName = rs.getMetaData().getColumnName(i);
|
||||
Object columnObject = rs.getObject(i);
|
||||
|
@ -123,7 +121,7 @@ public class JdbcVascBackendXpql extends AbstractVascBackend {
|
|||
result.add(map);
|
||||
}
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
} catch (SQLException e) {
|
||||
throw new VascBackendException(e);
|
||||
} finally {
|
||||
if (c!=null) {
|
||||
|
@ -138,33 +136,33 @@ public class JdbcVascBackendXpql extends AbstractVascBackend {
|
|||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#merge(java.lang.Object)
|
||||
*/
|
||||
public Object merge(Object object) throws VascBackendException {
|
||||
public HashMap<String,Object> merge(HashMap<String,Object> object) throws VascBackendException {
|
||||
return object;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#persist(java.lang.Object)
|
||||
*/
|
||||
public void persist(Object object) throws VascBackendException {
|
||||
public void persist(HashMap<String,Object> object) throws VascBackendException {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#delete(java.lang.Object)
|
||||
*/
|
||||
public void delete(Object object) throws VascBackendException {
|
||||
public void delete(HashMap<String,Object> object) throws VascBackendException {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryFieldValue()
|
||||
*/
|
||||
public VascEntryFieldValue provideVascEntryFieldValue() {
|
||||
return new MapVascEntryFieldValue();
|
||||
return new HashMapVascEntryFieldValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryRecordCreator()
|
||||
*/
|
||||
public VascEntryRecordCreator provideVascEntryRecordCreator() {
|
||||
return new MapVascEntryRecordCreator();
|
||||
return new HashMapVascEntryRecordCreator();
|
||||
}
|
||||
}
|
|
@ -22,6 +22,8 @@
|
|||
|
||||
package net.forwardfire.vasc.backends.jpa;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import net.forwardfire.vasc.backend.AbstractVascBackend;
|
||||
import net.forwardfire.vasc.backend.VascBackendException;
|
||||
|
||||
|
@ -33,7 +35,7 @@ import org.hibernate.Session;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 21, 2007
|
||||
*/
|
||||
abstract public class AbstractHibernateVascBackend extends AbstractVascBackend {
|
||||
abstract public class AbstractHibernateVascBackend<DATA_OBJECT extends Serializable> extends AbstractVascBackend<DATA_OBJECT> {
|
||||
|
||||
/**
|
||||
* Provides a hibernate session which is closed !! when transaction is compleeted.
|
||||
|
@ -41,7 +43,7 @@ abstract public class AbstractHibernateVascBackend extends AbstractVascBackend
|
|||
*/
|
||||
abstract Session getHibernateSession();
|
||||
|
||||
public void persist(Object object) throws VascBackendException {
|
||||
public void persist(DATA_OBJECT object) throws VascBackendException {
|
||||
Session s = getHibernateSession();
|
||||
try {
|
||||
s.getTransaction().begin();
|
||||
|
@ -57,11 +59,11 @@ abstract public class AbstractHibernateVascBackend extends AbstractVascBackend
|
|||
}
|
||||
}
|
||||
|
||||
public Object merge(Object object) throws VascBackendException {
|
||||
public DATA_OBJECT merge(DATA_OBJECT object) throws VascBackendException {
|
||||
Session s = getHibernateSession();
|
||||
try {
|
||||
s.getTransaction().begin();
|
||||
Object result = s.merge(object);
|
||||
DATA_OBJECT result = (DATA_OBJECT)s.merge(object);
|
||||
s.getTransaction().commit();
|
||||
return result;
|
||||
} finally {
|
||||
|
@ -74,7 +76,7 @@ abstract public class AbstractHibernateVascBackend extends AbstractVascBackend
|
|||
}
|
||||
}
|
||||
|
||||
public void delete(Object object) throws VascBackendException {
|
||||
public void delete(DATA_OBJECT object) throws VascBackendException {
|
||||
Session s = getHibernateSession();
|
||||
try {
|
||||
s.getTransaction().begin();
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
|
||||
package net.forwardfire.vasc.backends.jpa;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
|
||||
import net.forwardfire.vasc.backend.AbstractVascBackend;
|
||||
|
@ -32,13 +34,13 @@ import net.forwardfire.vasc.backend.VascBackendException;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 21, 2007
|
||||
*/
|
||||
abstract public class AbstractPersistenceVascBackend extends AbstractVascBackend {
|
||||
abstract public class AbstractPersistenceVascBackend<DATA_OBJECT extends Serializable> extends AbstractVascBackend<DATA_OBJECT> {
|
||||
|
||||
protected boolean emTransaction = true;
|
||||
|
||||
abstract EntityManager getEntityManager();
|
||||
|
||||
public void persist(Object object) throws VascBackendException {
|
||||
public void persist(DATA_OBJECT object) throws VascBackendException {
|
||||
EntityManager s = getEntityManager();
|
||||
try {
|
||||
if (emTransaction) {
|
||||
|
@ -55,13 +57,13 @@ abstract public class AbstractPersistenceVascBackend extends AbstractVascBackend
|
|||
}
|
||||
}
|
||||
|
||||
public Object merge(Object object) throws VascBackendException {
|
||||
public DATA_OBJECT merge(DATA_OBJECT object) throws VascBackendException {
|
||||
EntityManager s = getEntityManager();
|
||||
try {
|
||||
if (emTransaction) {
|
||||
s.getTransaction().begin();
|
||||
}
|
||||
Object result = s.merge(object);
|
||||
DATA_OBJECT result = (DATA_OBJECT)s.merge(object);
|
||||
if (emTransaction) {
|
||||
s.getTransaction().commit();
|
||||
}
|
||||
|
@ -73,7 +75,7 @@ abstract public class AbstractPersistenceVascBackend extends AbstractVascBackend
|
|||
}
|
||||
}
|
||||
|
||||
public void delete(Object object) throws VascBackendException {
|
||||
public void delete(DATA_OBJECT object) throws VascBackendException {
|
||||
EntityManager s = getEntityManager();
|
||||
try {
|
||||
if (emTransaction) {
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
package net.forwardfire.vasc.backends.jpa;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackendException;
|
||||
|
@ -43,7 +44,7 @@ import org.hibernate.Session;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 17, 2009
|
||||
*/
|
||||
public class XpqlHibernateVascBackend extends AbstractHibernateVascBackend {
|
||||
public class XpqlHibernateVascBackend<DATA_OBJECT extends Serializable> extends AbstractHibernateVascBackend<DATA_OBJECT> {
|
||||
|
||||
private HibernateSessionProvider hibernateSessionProvider = null;
|
||||
|
||||
|
@ -73,7 +74,7 @@ public class XpqlHibernateVascBackend extends AbstractHibernateVascBackend {
|
|||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Object> execute(VascBackendState state) throws VascBackendException {
|
||||
public List<DATA_OBJECT> execute(VascBackendState state) throws VascBackendException {
|
||||
|
||||
// Copy parameters
|
||||
for (String key:state.getDataParameterKeys()) {
|
||||
|
@ -103,7 +104,7 @@ public class XpqlHibernateVascBackend extends AbstractHibernateVascBackend {
|
|||
q.setFirstResult(state.getPageIndex()*state.getPageSize());
|
||||
q.setMaxResults(state.getPageSize());
|
||||
}
|
||||
List<Object> data = q.list();
|
||||
List<DATA_OBJECT> data = q.list();
|
||||
s.getTransaction().commit();
|
||||
return data;
|
||||
} finally {
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
package net.forwardfire.vasc.backends.jpa;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
|
@ -43,7 +44,7 @@ import net.forwardfire.vasc.xpql.query.QueryParameterValue;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 17, 2009
|
||||
*/
|
||||
public class XpqlPersistanceVascBackend extends AbstractPersistenceVascBackend {
|
||||
public class XpqlPersistanceVascBackend<DATA_OBJECT extends Serializable> extends AbstractPersistenceVascBackend<DATA_OBJECT> {
|
||||
|
||||
private EntityManagerProvider entityManagerProvider = null;
|
||||
|
||||
|
@ -76,7 +77,7 @@ public class XpqlPersistanceVascBackend extends AbstractPersistenceVascBackend
|
|||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Object> execute(VascBackendState state) throws VascBackendException {
|
||||
public List<DATA_OBJECT> execute(VascBackendState state) throws VascBackendException {
|
||||
|
||||
// Copy parameters
|
||||
for (String key:state.getDataParameterKeys()) {
|
||||
|
@ -84,7 +85,7 @@ public class XpqlPersistanceVascBackend extends AbstractPersistenceVascBackend
|
|||
//System.out.println("Set para pame: "+key+" value: "+value);
|
||||
query.setQueryParameter(key, value);
|
||||
if (queryTotal!=null) {
|
||||
queryTotal.setQueryParameter(key, value);
|
||||
queryTotal.setQueryParameter(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,7 +107,7 @@ public class XpqlPersistanceVascBackend extends AbstractPersistenceVascBackend
|
|||
if (emTransaction) {
|
||||
em.getTransaction().begin();
|
||||
}
|
||||
List<Object> data = q.getResultList();
|
||||
List<DATA_OBJECT> data = q.getResultList();
|
||||
if (emTransaction) {
|
||||
em.getTransaction().commit();
|
||||
}
|
||||
|
|
|
@ -34,8 +34,8 @@ import net.forwardfire.vasc.backend.VascBackendException;
|
|||
import net.forwardfire.vasc.backend.VascBackendState;
|
||||
import net.forwardfire.vasc.backend.VascEntryFieldValue;
|
||||
import net.forwardfire.vasc.backend.VascEntryRecordCreator;
|
||||
import net.forwardfire.vasc.backend.data.MapVascEntryFieldValue;
|
||||
import net.forwardfire.vasc.backend.data.MapVascEntryRecordCreator;
|
||||
import net.forwardfire.vasc.backend.data.HashMapVascEntryFieldValue;
|
||||
import net.forwardfire.vasc.backend.data.HashMapVascEntryRecordCreator;
|
||||
|
||||
import com.novell.ldap.LDAPAttribute;
|
||||
import com.novell.ldap.LDAPAttributeSet;
|
||||
|
@ -52,7 +52,7 @@ import com.novell.ldap.LDAPSearchResults;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 Sep 4, 2008
|
||||
*/
|
||||
public class LdapVascBackend extends AbstractVascBackend {
|
||||
public class LdapVascBackend extends AbstractVascBackend<HashMap<String,Object>> {
|
||||
|
||||
private Logger logger = Logger.getLogger(LdapVascBackend.class.getName());
|
||||
private LdapConnectionProvider ldapConnectionProvider = null;
|
||||
|
@ -80,10 +80,10 @@ public class LdapVascBackend extends AbstractVascBackend {
|
|||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#execute()
|
||||
*/
|
||||
public List<Object> execute(VascBackendState state) throws VascBackendException {
|
||||
public List<HashMap<String,Object>> execute(VascBackendState state) throws VascBackendException {
|
||||
LdapConnectionProvider prov = getLdapConnectionProvider();
|
||||
LDAPConnection connection = prov.getLdapConnection();
|
||||
List<Object> result = new ArrayList<Object>(50);
|
||||
List<HashMap<String,Object>> result = new ArrayList<HashMap<String,Object>>(50);
|
||||
try {
|
||||
|
||||
LDAPSearchConstraints cons = new LDAPSearchConstraints();
|
||||
|
@ -104,7 +104,7 @@ public class LdapVascBackend extends AbstractVascBackend {
|
|||
|
||||
while (searchResults.hasMore()) {
|
||||
LDAPEntry entry = searchResults.next();
|
||||
Map<String,Object> map = new HashMap<String,Object>(10);
|
||||
HashMap<String,Object> map = new HashMap<String,Object>(10);
|
||||
|
||||
LDAPAttributeSet attributeSet = entry.getAttributeSet();
|
||||
Iterator<LDAPAttribute> i = attributeSet.iterator();
|
||||
|
@ -134,11 +134,10 @@ public class LdapVascBackend extends AbstractVascBackend {
|
|||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#merge(java.lang.Object)
|
||||
*/
|
||||
public Object merge(Object object) throws VascBackendException {
|
||||
public HashMap<String,Object> merge(HashMap<String,Object> map) throws VascBackendException {
|
||||
LdapConnectionProvider prov = getLdapConnectionProvider();
|
||||
LDAPConnection connection = prov.getLdapConnection();
|
||||
try {
|
||||
Map<String,Object> map = (Map)object;
|
||||
String keyValue = (String)map.get(keyAttribute);
|
||||
LDAPSearchConstraints cons = new LDAPSearchConstraints();
|
||||
cons.setBatchSize( 0 );
|
||||
|
@ -157,7 +156,7 @@ public class LdapVascBackend extends AbstractVascBackend {
|
|||
|
||||
if (searchResults.hasMore()==false) {
|
||||
// no result to mod
|
||||
return object;
|
||||
return map;
|
||||
}
|
||||
LDAPEntry entry = searchResults.next();
|
||||
List<LDAPModification> mods = new ArrayList<LDAPModification>(20);
|
||||
|
@ -204,7 +203,7 @@ public class LdapVascBackend extends AbstractVascBackend {
|
|||
m = mods.toArray(m);
|
||||
connection.modify(entry.getDN(), m);
|
||||
|
||||
return object;
|
||||
return map;
|
||||
} catch (LDAPException e) {
|
||||
throw new VascBackendException(e);
|
||||
} finally {
|
||||
|
@ -215,8 +214,7 @@ public class LdapVascBackend extends AbstractVascBackend {
|
|||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#persist(java.lang.Object)
|
||||
*/
|
||||
public void persist(Object object) throws VascBackendException {
|
||||
Map<String,Object> map = (Map)object;
|
||||
public void persist(HashMap<String,Object> map) throws VascBackendException {
|
||||
LdapConnectionProvider prov = getLdapConnectionProvider();
|
||||
LDAPConnection connection = prov.getLdapConnection();
|
||||
try {
|
||||
|
@ -250,11 +248,10 @@ public class LdapVascBackend extends AbstractVascBackend {
|
|||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#delete(java.lang.Object)
|
||||
*/
|
||||
public void delete(Object object) throws VascBackendException {
|
||||
public void delete(HashMap<String,Object> map) throws VascBackendException {
|
||||
LdapConnectionProvider prov = getLdapConnectionProvider();
|
||||
LDAPConnection connection = prov.getLdapConnection();
|
||||
try {
|
||||
Map<String,Object> map = (Map)object;
|
||||
String keyValue = (String)map.get(keyAttribute);
|
||||
int searchScope = LDAPConnection.SCOPE_ONE;
|
||||
String searchBase = baseDN;
|
||||
|
@ -294,14 +291,14 @@ public class LdapVascBackend extends AbstractVascBackend {
|
|||
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryRecordCreator()
|
||||
*/
|
||||
public VascEntryRecordCreator provideVascEntryRecordCreator() {
|
||||
return new MapVascEntryRecordCreator();
|
||||
return new HashMapVascEntryRecordCreator();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryFieldValue()
|
||||
*/
|
||||
public VascEntryFieldValue provideVascEntryFieldValue() {
|
||||
return new MapVascEntryFieldValue();
|
||||
return new HashMapVascEntryFieldValue();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -58,7 +58,7 @@ import net.forwardfire.vasc.backend.metamodel.crud.UpdateableRowMapImpl;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 Dec 31, 2011
|
||||
*/
|
||||
public class MetaModelVascBackend extends AbstractVascBackend {
|
||||
public class MetaModelVascBackend extends AbstractVascBackend<Row> {
|
||||
|
||||
private Logger logger = Logger.getLogger(MetaModelVascBackend.class.getName());
|
||||
private MetaModelDataContextProvider dataContextProvider = null;
|
||||
|
@ -210,7 +210,7 @@ public class MetaModelVascBackend extends AbstractVascBackend {
|
|||
return q;
|
||||
}
|
||||
|
||||
public List<Object> execute(VascBackendState state) throws VascBackendException {
|
||||
public List<Row> execute(VascBackendState state) throws VascBackendException {
|
||||
Schema schema = dataContext.getDefaultSchema();
|
||||
Table t = schema.getTableByName(table);
|
||||
if (t==null) {
|
||||
|
@ -236,16 +236,15 @@ public class MetaModelVascBackend extends AbstractVascBackend {
|
|||
}
|
||||
q.setMaxRows(state.getPageSize());
|
||||
}
|
||||
List<Row> result = new ArrayList<Row>(50);
|
||||
if (crudDataContext!=null) {
|
||||
DataSet ds = crudDataContext.executeQuery(q);
|
||||
List<Object> result = new ArrayList<Object>(50);
|
||||
result.addAll(ds.toRows());
|
||||
ds.close();
|
||||
return result;
|
||||
}
|
||||
|
||||
DataSet ds = dataContext.executeQuery(q);
|
||||
List<Object> result = new ArrayList<Object>(50);
|
||||
while (ds.next()) {
|
||||
Row row = ds.getRow();
|
||||
SelectItem[] cols = row.getSelectItems();
|
||||
|
@ -263,21 +262,21 @@ public class MetaModelVascBackend extends AbstractVascBackend {
|
|||
return result;
|
||||
}
|
||||
|
||||
public void persist(Object object) throws VascBackendException {
|
||||
public void persist(Row object) throws VascBackendException {
|
||||
if (crudDataContext==null) {
|
||||
return;
|
||||
}
|
||||
crudDataContext.persist((UpdateableRow) object);
|
||||
}
|
||||
|
||||
public Object merge(Object object) throws VascBackendException {
|
||||
public Row merge(Row object) throws VascBackendException {
|
||||
if (crudDataContext==null) {
|
||||
return object;
|
||||
}
|
||||
return crudDataContext.merge((UpdateableRow) object);
|
||||
}
|
||||
|
||||
public void delete(Object object) throws VascBackendException {
|
||||
public void delete(Row object) throws VascBackendException {
|
||||
if (crudDataContext==null) {
|
||||
return;
|
||||
}
|
||||
|
@ -288,7 +287,7 @@ public class MetaModelVascBackend extends AbstractVascBackend {
|
|||
return new RowVascEntryFieldValue();
|
||||
}
|
||||
|
||||
public VascEntryRecordCreator provideVascEntryRecordCreator() {
|
||||
public VascEntryRecordCreator<Row> provideVascEntryRecordCreator() {
|
||||
return new RowVascEntryRecordCreator(crudDataContext,crudDataContext.getDefaultSchema().getTableByName(table));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package net.forwardfire.vasc.backend.metamodel;
|
||||
|
||||
import org.eobjects.metamodel.data.Row;
|
||||
import org.eobjects.metamodel.schema.Table;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackendException;
|
||||
import net.forwardfire.vasc.backend.VascEntryRecordCreator;
|
||||
import net.forwardfire.vasc.backend.metamodel.crud.CrudDataContext;
|
||||
import net.forwardfire.vasc.backend.metamodel.crud.UpdateableRow;
|
||||
|
||||
public class RowVascEntryRecordCreator implements VascEntryRecordCreator {
|
||||
public class RowVascEntryRecordCreator implements VascEntryRecordCreator<Row> {
|
||||
|
||||
private static final long serialVersionUID = -1182678362367989090L;
|
||||
private CrudDataContext dataContext = null;
|
||||
|
@ -17,12 +17,8 @@ public class RowVascEntryRecordCreator implements VascEntryRecordCreator {
|
|||
this.dataContext=dataContext;
|
||||
this.table=table;
|
||||
}
|
||||
|
||||
public Class<?> getObjectClass() {
|
||||
return UpdateableRow.class;
|
||||
}
|
||||
|
||||
public Object newRecord() throws VascBackendException {
|
||||
public Row newRecord() throws VascBackendException {
|
||||
return dataContext.createRow(table);
|
||||
}
|
||||
}
|
|
@ -48,6 +48,9 @@ abstract public class AbstractCrudDataContext implements CrudDataContext {
|
|||
RowInsertionBuilder query = backendImpl.insertInto(row.getTable());
|
||||
for (int i=0;i<row.size();i++) {
|
||||
SelectItem si = row.getSelectItem(i);
|
||||
if (si.getColumn().isPrimaryKey()) {
|
||||
continue; // insert null will only work with correct default sequence attacted to column.
|
||||
}
|
||||
Object value = row.getValue(i);
|
||||
query.value(si.getColumn(), value);
|
||||
}
|
||||
|
@ -56,7 +59,7 @@ abstract public class AbstractCrudDataContext implements CrudDataContext {
|
|||
});
|
||||
}
|
||||
|
||||
public Object merge(final UpdateableRow row) {
|
||||
public UpdateableRow merge(final UpdateableRow row) {
|
||||
for (String column:row.getPrimaryKeys()) {
|
||||
if (row.getValue(column)==null) {
|
||||
throw new IllegalStateException("Can't update row where primary key: "+column+" value is null.");
|
||||
|
|
|
@ -26,7 +26,7 @@ public interface CrudDataContext extends UpdateableDataContext {
|
|||
/**
|
||||
* Merges row with table.
|
||||
*/
|
||||
public Object merge(UpdateableRow row);
|
||||
public UpdateableRow merge(UpdateableRow row);
|
||||
|
||||
/**
|
||||
* Deletes row from table.
|
||||
|
|
|
@ -46,7 +46,7 @@ import com.mongodb.WriteResult;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 Dec 30, 2011
|
||||
*/
|
||||
public class MongodbVascBackend extends AbstractVascBackend {
|
||||
public class MongodbVascBackend extends AbstractVascBackend<BasicDBObject> {
|
||||
|
||||
private Logger logger = null;
|
||||
private MongodbConnectionProvider connectionProvider = null;
|
||||
|
@ -105,7 +105,7 @@ public class MongodbVascBackend extends AbstractVascBackend {
|
|||
return query;
|
||||
}
|
||||
|
||||
public List<Object> execute(VascBackendState state) throws VascBackendException {
|
||||
public List<BasicDBObject> execute(VascBackendState state) throws VascBackendException {
|
||||
DBCollection coll = getDBCollection();
|
||||
DBObject query = createFilterQuery(state);
|
||||
DBCursor cur = coll.find(query);
|
||||
|
@ -113,33 +113,32 @@ public class MongodbVascBackend extends AbstractVascBackend {
|
|||
cur.limit(state.getPageSize());
|
||||
cur.skip(state.getPageIndex());
|
||||
}
|
||||
List<Object> result = new ArrayList<Object>(cur.count());
|
||||
List<BasicDBObject> result = new ArrayList<BasicDBObject>(cur.count());
|
||||
while (cur.hasNext()) {
|
||||
DBObject row = cur.next();
|
||||
result.add(row);
|
||||
result.add((BasicDBObject)row);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void persist(Object object) throws VascBackendException {
|
||||
public void persist(BasicDBObject object) throws VascBackendException {
|
||||
DBCollection coll = getDBCollection();
|
||||
coll.insert((DBObject)object);
|
||||
coll.insert(object);
|
||||
}
|
||||
|
||||
public Object merge(Object object) throws VascBackendException {
|
||||
public BasicDBObject merge(BasicDBObject row) throws VascBackendException {
|
||||
DBCollection coll = getDBCollection();
|
||||
DBObject row = (DBObject)object;
|
||||
DBObject query = new BasicDBObject();
|
||||
query.put("_id",row.get("_id"));
|
||||
WriteResult wr = coll.update(query,row,false,false,WriteConcern.SAFE);
|
||||
logger.info("WriteResult: "+wr);
|
||||
return object;
|
||||
return row;
|
||||
}
|
||||
|
||||
public void delete(Object object) throws VascBackendException {
|
||||
public void delete(BasicDBObject object) throws VascBackendException {
|
||||
DBCollection coll = getDBCollection();
|
||||
DBObject query = new BasicDBObject();
|
||||
query.put("_id",((DBObject)object).get("_id"));
|
||||
query.put("_id",object.get("_id"));
|
||||
coll.remove(query); // remove by _id
|
||||
}
|
||||
|
||||
|
@ -147,7 +146,7 @@ public class MongodbVascBackend extends AbstractVascBackend {
|
|||
return new MongodbVascEntryFieldValue();
|
||||
}
|
||||
|
||||
public VascEntryRecordCreator provideVascEntryRecordCreator() {
|
||||
public VascEntryRecordCreator<BasicDBObject> provideVascEntryRecordCreator() {
|
||||
return new MongodbVascEntryRecordCreator();
|
||||
}
|
||||
|
||||
|
|
|
@ -34,15 +34,11 @@ import com.mongodb.BasicDBObject;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 Dec 30, 2011
|
||||
*/
|
||||
public class MongodbVascEntryRecordCreator implements VascEntryRecordCreator {
|
||||
public class MongodbVascEntryRecordCreator implements VascEntryRecordCreator<BasicDBObject> {
|
||||
|
||||
private static final long serialVersionUID = -9213830731796787384L;
|
||||
|
||||
public Object newRecord() throws VascBackendException {
|
||||
|
||||
public BasicDBObject newRecord() throws VascBackendException {
|
||||
return new BasicDBObject();
|
||||
}
|
||||
|
||||
public Class<?> getObjectClass() {
|
||||
return BasicDBObject.class;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
package net.forwardfire.vasc.ejb3;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -37,7 +38,7 @@ import net.forwardfire.vasc.backend.VascEntryRecordCreator;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 18 Nov 2012
|
||||
*/
|
||||
public class VascServiceRemoteBackend implements VascBackend {
|
||||
public class VascServiceRemoteBackend<DATA_OBJECT extends Serializable> implements VascBackend<DATA_OBJECT> {
|
||||
|
||||
private String backendId = null;
|
||||
private VascServiceManager vascManager = null;
|
||||
|
@ -66,7 +67,7 @@ public class VascServiceRemoteBackend implements VascBackend {
|
|||
// we cant change id
|
||||
}
|
||||
|
||||
public void delete(Object object) throws VascBackendException {
|
||||
public void delete(DATA_OBJECT object) throws VascBackendException {
|
||||
Object[] args = new Object[1];
|
||||
args[0]=object;
|
||||
vascManager.invokeBackendMethod(backendId, "delete", args);
|
||||
|
@ -89,11 +90,11 @@ public class VascServiceRemoteBackend implements VascBackend {
|
|||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Object> execute(VascBackendState state) throws VascBackendException {
|
||||
public List<DATA_OBJECT> execute(VascBackendState state) throws VascBackendException {
|
||||
Object[] args = new Object[1];
|
||||
args[0]=state;
|
||||
Object result = vascManager.invokeBackendMethod(backendId, "execute", args);
|
||||
return (List<Object>)result;
|
||||
return (List<DATA_OBJECT>)result;
|
||||
}
|
||||
|
||||
public long fetchTotalExecuteSize(VascBackendState state) {
|
||||
|
@ -127,14 +128,15 @@ public class VascServiceRemoteBackend implements VascBackend {
|
|||
return (Boolean)result;
|
||||
}
|
||||
|
||||
public Object merge(Object object) throws VascBackendException {
|
||||
@SuppressWarnings("unchecked")
|
||||
public DATA_OBJECT merge(DATA_OBJECT object) throws VascBackendException {
|
||||
Object[] args = new Object[1];
|
||||
args[0]=object;
|
||||
Object result = vascManager.invokeBackendMethod(backendId, "merge", args);
|
||||
return result;
|
||||
return (DATA_OBJECT)result;
|
||||
}
|
||||
|
||||
public void persist(Object object) throws VascBackendException {
|
||||
public void persist(DATA_OBJECT object) throws VascBackendException {
|
||||
Object[] args = new Object[1];
|
||||
args[0]=object;
|
||||
vascManager.invokeBackendMethod(backendId, "delete", args);
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
package net.forwardfire.vasc.backend.proxy;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -40,7 +41,7 @@ import net.forwardfire.vasc.core.VascEntry;
|
|||
*/
|
||||
abstract public class AbstractVascBackendProxy implements VascBackendProxy {
|
||||
|
||||
protected VascBackend backend = null;
|
||||
protected VascBackend<Serializable> backend = null;
|
||||
protected VascEntry entry = null;
|
||||
|
||||
abstract public VascBackendProxy clone() throws CloneNotSupportedException;
|
||||
|
@ -48,7 +49,7 @@ abstract public class AbstractVascBackendProxy implements VascBackendProxy {
|
|||
/**
|
||||
* @see net.forwardfire.vasc.backend.proxy.VascBackendProxy#initProxy(net.forwardfire.vasc.backend.VascBackend, net.forwardfire.vasc.core.VascEntry)
|
||||
*/
|
||||
public void initProxy(VascBackend backend, VascEntry entry) {
|
||||
public void initProxy(VascBackend<Serializable> backend, VascEntry entry) {
|
||||
if (backend==null) {
|
||||
throw new NullPointerException("backend object may not be null.");
|
||||
}
|
||||
|
@ -105,14 +106,14 @@ abstract public class AbstractVascBackendProxy implements VascBackendProxy {
|
|||
* @throws Exception
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state)
|
||||
*/
|
||||
public List<Object> execute(VascBackendState state) throws VascBackendException {
|
||||
public List<Serializable> execute(VascBackendState state) throws VascBackendException {
|
||||
return backend.execute(state);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#delete(java.lang.Object)
|
||||
*/
|
||||
public void delete(Object object) throws VascBackendException {
|
||||
public void delete(Serializable object) throws VascBackendException {
|
||||
backend.delete(object);
|
||||
}
|
||||
|
||||
|
@ -133,14 +134,14 @@ abstract public class AbstractVascBackendProxy implements VascBackendProxy {
|
|||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#merge(java.lang.Object)
|
||||
*/
|
||||
public Object merge(Object object) throws VascBackendException {
|
||||
public Serializable merge(Serializable object) throws VascBackendException {
|
||||
return backend.merge(object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#persist(java.lang.Object)
|
||||
*/
|
||||
public void persist(Object object) throws VascBackendException {
|
||||
public void persist(Serializable object) throws VascBackendException {
|
||||
backend.persist(object);
|
||||
}
|
||||
|
||||
|
@ -154,7 +155,7 @@ abstract public class AbstractVascBackendProxy implements VascBackendProxy {
|
|||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryRecordCreator()
|
||||
*/
|
||||
public VascEntryRecordCreator provideVascEntryRecordCreator() {
|
||||
public VascEntryRecordCreator<Serializable> provideVascEntryRecordCreator() {
|
||||
return backend.provideVascEntryRecordCreator();
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
|
||||
package net.forwardfire.vasc.backend.proxy;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackend;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
|
||||
|
@ -31,9 +33,9 @@ import net.forwardfire.vasc.core.VascEntry;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 May 9, 2012
|
||||
*/
|
||||
public interface VascBackendProxy extends VascBackend,Cloneable {
|
||||
public interface VascBackendProxy extends VascBackend<Serializable>,Cloneable {
|
||||
|
||||
public void initProxy(VascBackend backend,VascEntry entry);
|
||||
public void initProxy(VascBackend<Serializable> backend,VascEntry entry);
|
||||
|
||||
public boolean isProxyNeeded();
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
package net.forwardfire.vasc.backend.proxy;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -38,7 +39,7 @@ import net.forwardfire.vasc.backend.VascBackendState;
|
|||
public class VascBackendProxyCache extends AbstractVascBackendProxy {
|
||||
|
||||
private Long records = null;
|
||||
private List<Object> data = null;
|
||||
private List<Serializable> data = null;
|
||||
private String searchString = null;
|
||||
private Map<String,Object> dataState = null;
|
||||
private int pageIndex = 0;
|
||||
|
@ -130,7 +131,7 @@ public class VascBackendProxyCache extends AbstractVascBackendProxy {
|
|||
* @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state)
|
||||
*/
|
||||
@Override
|
||||
public List<Object> execute(VascBackendState state) throws VascBackendException {
|
||||
public List<Serializable> execute(VascBackendState state) throws VascBackendException {
|
||||
boolean changed = isStateChanged(state);
|
||||
if (data==null | changed) {
|
||||
data = backend.execute(state);
|
||||
|
@ -151,7 +152,7 @@ public class VascBackendProxyCache extends AbstractVascBackendProxy {
|
|||
* @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#delete(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void delete(Object object) throws VascBackendException {
|
||||
public void delete(Serializable object) throws VascBackendException {
|
||||
requestFlush = true;
|
||||
super.delete(object);
|
||||
}
|
||||
|
@ -160,7 +161,7 @@ public class VascBackendProxyCache extends AbstractVascBackendProxy {
|
|||
* @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#merge(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public Object merge(Object object) throws VascBackendException {
|
||||
public Serializable merge(Serializable object) throws VascBackendException {
|
||||
requestFlush = true;
|
||||
return super.merge(object);
|
||||
}
|
||||
|
@ -169,7 +170,7 @@ public class VascBackendProxyCache extends AbstractVascBackendProxy {
|
|||
* @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#persist(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void persist(Object object) throws VascBackendException {
|
||||
public void persist(Serializable object) throws VascBackendException {
|
||||
requestFlush = true;
|
||||
super.persist(object);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
package net.forwardfire.vasc.backend.proxy;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -51,7 +52,7 @@ public class VascBackendProxyEventExecutor extends AbstractVascBackendProxy {
|
|||
return result;
|
||||
}
|
||||
|
||||
public void initProxy(VascBackend backend,VascEntry entry) {
|
||||
public void initProxy(VascBackend<Serializable> backend,VascEntry entry) {
|
||||
super.initProxy(backend, entry);
|
||||
this.entry=entry;
|
||||
this.listeners=new ArrayList<VascEntryBackendEventListener>(10);
|
||||
|
@ -95,7 +96,7 @@ public class VascBackendProxyEventExecutor extends AbstractVascBackendProxy {
|
|||
for (int t=0;t<types.length;t++) {
|
||||
VascBackendEventType typeListener = types[t];
|
||||
if (typeListener==type) {
|
||||
l.vascEvent(entry, data);
|
||||
l.vascEvent(entry, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -105,7 +106,7 @@ public class VascBackendProxyEventExecutor extends AbstractVascBackendProxy {
|
|||
* @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#delete(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void delete(Object object) throws VascBackendException {
|
||||
public void delete(Serializable object) throws VascBackendException {
|
||||
fireVascEvent(VascBackendEventType.PRE_DELETE,object);
|
||||
super.delete(object);
|
||||
fireVascEvent(VascBackendEventType.POST_DELETE,object);
|
||||
|
@ -137,9 +138,9 @@ public class VascBackendProxyEventExecutor extends AbstractVascBackendProxy {
|
|||
* @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#execute(net.forwardfire.vasc.backend.VascBackendState)
|
||||
*/
|
||||
@Override
|
||||
public List<Object> execute(VascBackendState state) throws VascBackendException {
|
||||
public List<Serializable> execute(VascBackendState state) throws VascBackendException {
|
||||
fireVascEvent(VascBackendEventType.PRE_EXECUTE,state);
|
||||
List<Object> result = super.execute(state);
|
||||
List<Serializable> result = super.execute(state);
|
||||
fireVascEvent(VascBackendEventType.POST_EXECUTE,result);
|
||||
return result;
|
||||
}
|
||||
|
@ -159,9 +160,9 @@ public class VascBackendProxyEventExecutor extends AbstractVascBackendProxy {
|
|||
* @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#merge(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public Object merge(Object object) throws VascBackendException {
|
||||
public Serializable merge(Serializable object) throws VascBackendException {
|
||||
fireVascEvent(VascBackendEventType.PRE_MERGE,object);
|
||||
Object result = super.merge(object);
|
||||
Serializable result = super.merge(object);
|
||||
fireVascEvent(VascBackendEventType.POST_MERGE,result);
|
||||
return result;
|
||||
}
|
||||
|
@ -170,7 +171,7 @@ public class VascBackendProxyEventExecutor extends AbstractVascBackendProxy {
|
|||
* @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#persist(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void persist(Object object) throws VascBackendException {
|
||||
public void persist(Serializable object) throws VascBackendException {
|
||||
fireVascEvent(VascBackendEventType.PRE_PERSIST,object);
|
||||
super.persist(object);
|
||||
fireVascEvent(VascBackendEventType.POST_PERSIST,object);
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
package net.forwardfire.vasc.backend.proxy;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -53,7 +54,7 @@ public class VascBackendProxyFilter extends AbstractVascBackendProxy {
|
|||
/**
|
||||
* @see net.forwardfire.vasc.backend.proxy.VascBackendProxy#initProxy(net.forwardfire.vasc.backend.VascBackend, net.forwardfire.vasc.core.VascEntry)
|
||||
*/
|
||||
public void initProxy(VascBackend backend, VascEntry entry) {
|
||||
public void initProxy(VascBackend<Serializable> backend, VascEntry entry) {
|
||||
super.initProxy(backend,entry);
|
||||
filters = entry.getVascBackendFilters();
|
||||
for (VascProxyFilter filter:filters) {
|
||||
|
@ -76,18 +77,18 @@ public class VascBackendProxyFilter extends AbstractVascBackendProxy {
|
|||
* @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state)
|
||||
*/
|
||||
@Override
|
||||
public List<Object> execute(VascBackendState state) throws VascBackendException {
|
||||
List<Object> result = backend.execute(state);
|
||||
public List<Serializable> execute(VascBackendState state) throws VascBackendException {
|
||||
List<Serializable> result = backend.execute(state);
|
||||
if (filters==null) {
|
||||
return result;
|
||||
}
|
||||
if (filters.isEmpty()) {
|
||||
return result;
|
||||
}
|
||||
List<Object> search = new ArrayList<Object>(result.size()/2);
|
||||
for (Object o:result) {
|
||||
List<Serializable> search = new ArrayList<Serializable>(result.size()/2);
|
||||
for (Serializable o:result) {
|
||||
for (VascProxyFilter filter:filters) {
|
||||
Object r = filter.filterObject(o);
|
||||
Serializable r = filter.filterObject(o);
|
||||
if (r!=null) {
|
||||
search.add(r);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
package net.forwardfire.vasc.backend.proxy;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -70,21 +71,21 @@ public class VascBackendProxyPaged extends AbstractVascBackendProxy {
|
|||
* @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state)
|
||||
*/
|
||||
@Override
|
||||
public List<Object> execute(VascBackendState state) throws VascBackendException {
|
||||
List<Object> allData = backend.execute(state);
|
||||
public List<Serializable> execute(VascBackendState state) throws VascBackendException {
|
||||
List<Serializable> allData = backend.execute(state);
|
||||
int pageSize = state.getPageSize();
|
||||
if (pageSize==0) {
|
||||
records = allData.size();
|
||||
return allData;
|
||||
}
|
||||
List<Object> paged = new ArrayList<Object>(state.getPageSize());
|
||||
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()) {
|
||||
break;
|
||||
}
|
||||
Object o = allData.get(i);
|
||||
Serializable o = allData.get(i);
|
||||
paged.add(o);
|
||||
}
|
||||
records = allData.size();
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
package net.forwardfire.vasc.backend.proxy;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -70,8 +71,8 @@ public class VascBackendProxySearch extends AbstractVascBackendProxy {
|
|||
* @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state)
|
||||
*/
|
||||
@Override
|
||||
public List<Object> execute(VascBackendState state) throws VascBackendException {
|
||||
List<Object> result = backend.execute(state);
|
||||
public List<Serializable> execute(VascBackendState state) throws VascBackendException {
|
||||
List<Serializable> result = backend.execute(state);
|
||||
if (state.getSearchString()==null) {
|
||||
return result;
|
||||
}
|
||||
|
@ -79,8 +80,8 @@ public class VascBackendProxySearch extends AbstractVascBackendProxy {
|
|||
return result;
|
||||
}
|
||||
String searchString = state.getSearchString().toLowerCase();
|
||||
List<Object> search = new ArrayList<Object>(result.size()/4);
|
||||
for (Object record:result) {
|
||||
List<Serializable> search = new ArrayList<Serializable>(result.size()/4);
|
||||
for (Serializable record:result) {
|
||||
for (VascEntryField field:entry.getVascEntryFields()) {
|
||||
VascEntryFieldValue fieldValue = backend.provideVascEntryFieldValue();
|
||||
Object value = fieldValue.getValue(field.getBackendName(), record);
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
package net.forwardfire.vasc.backend.proxy;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
@ -73,8 +74,8 @@ public class VascBackendProxySort extends AbstractVascBackendProxy {
|
|||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public List<Object> execute(final VascBackendState state) throws VascBackendException {
|
||||
List<Object> result = backend.execute(state);
|
||||
public List<Serializable> execute(final VascBackendState state) throws VascBackendException {
|
||||
List<Serializable> result = backend.execute(state);
|
||||
if (state.getSortField()==null) {
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
package net.forwardfire.vasc.backend.proxy;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
@ -58,7 +59,7 @@ public class VascBackendProxyTimerLogger extends AbstractVascBackendProxy {
|
|||
* @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state)
|
||||
*/
|
||||
@Override
|
||||
public List<Object> execute(VascBackendState state) throws VascBackendException {
|
||||
public List<Serializable> execute(VascBackendState state) throws VascBackendException {
|
||||
long t1 = System.currentTimeMillis();
|
||||
try {
|
||||
return backend.execute(state);
|
||||
|
@ -111,7 +112,7 @@ public class VascBackendProxyTimerLogger extends AbstractVascBackendProxy {
|
|||
* @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#delete(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void delete(Object object) throws VascBackendException {
|
||||
public void delete(Serializable object) throws VascBackendException {
|
||||
long t1 = System.currentTimeMillis();
|
||||
try {
|
||||
backend.delete(object);
|
||||
|
@ -125,7 +126,7 @@ public class VascBackendProxyTimerLogger extends AbstractVascBackendProxy {
|
|||
* @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#merge(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public Object merge(Object object) throws VascBackendException {
|
||||
public Serializable merge(Serializable object) throws VascBackendException {
|
||||
long t1 = System.currentTimeMillis();
|
||||
try {
|
||||
return backend.merge(object);
|
||||
|
@ -139,7 +140,7 @@ public class VascBackendProxyTimerLogger extends AbstractVascBackendProxy {
|
|||
* @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#persist(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void persist(Object object) throws VascBackendException {
|
||||
public void persist(Serializable object) throws VascBackendException {
|
||||
long t1 = System.currentTimeMillis();
|
||||
try {
|
||||
backend.persist(object);
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
|
||||
package net.forwardfire.vasc.backend.proxy;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
|
||||
|
||||
|
@ -41,7 +43,7 @@ public interface VascProxyFilter {
|
|||
/**
|
||||
* Only filters 1 object.
|
||||
*/
|
||||
public Object filterObject(Object object);
|
||||
public Serializable filterObject(Serializable object);
|
||||
|
||||
/**
|
||||
* Force impl to have public clone methode
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
package net.forwardfire.vasc.core;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -39,46 +40,46 @@ import net.forwardfire.vasc.backend.VascBackendState;
|
|||
@SuppressWarnings("serial")
|
||||
abstract public class AbstractVascEntryState implements VascEntryState {
|
||||
|
||||
private List<Object> entryDataList = null;
|
||||
private Object entryDataObject = null;
|
||||
private List<Serializable> entryDataList = null;
|
||||
private Serializable entryDataObject = null;
|
||||
private Long totalBackendRecords = null;
|
||||
private VascBackendState vascBackendState = null;
|
||||
private VascEntryState state = null;
|
||||
private Map<Integer,Boolean> multiActionSelection = null;
|
||||
private boolean isEditCreate = false;
|
||||
private VascBackend vascBackend = null;
|
||||
private VascBackend<Serializable> vascBackend = null;
|
||||
private VascEntry vascEntry = null;
|
||||
|
||||
public AbstractVascEntryState() {
|
||||
entryDataList = new ArrayList<Object>(0);
|
||||
entryDataList = new ArrayList<Serializable>(0);
|
||||
multiActionSelection = new HashMap<Integer,Boolean>(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the entryDataList
|
||||
*/
|
||||
public List<Object> getEntryDataList() {
|
||||
public List<Serializable> getEntryDataList() {
|
||||
return entryDataList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param entryDataList the entryDataList to set
|
||||
*/
|
||||
public void setEntryDataList(List<Object> entryDataList) {
|
||||
public void setEntryDataList(List<Serializable> entryDataList) {
|
||||
this.entryDataList = entryDataList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the entryDataObject
|
||||
*/
|
||||
public Object getEntryDataObject() {
|
||||
public Serializable getEntryDataObject() {
|
||||
return entryDataObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param entryDataObject the entryDataObject to set
|
||||
*/
|
||||
public void setEntryDataObject(Object entryDataObject) {
|
||||
public void setEntryDataObject(Serializable entryDataObject) {
|
||||
this.entryDataObject = entryDataObject;
|
||||
}
|
||||
|
||||
|
@ -128,14 +129,14 @@ abstract public class AbstractVascEntryState implements VascEntryState {
|
|||
/**
|
||||
* @return the vascBackend
|
||||
*/
|
||||
public VascBackend getVascBackend() {
|
||||
public VascBackend<Serializable> getVascBackend() {
|
||||
return vascBackend;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param vascBackend the vascBackend to set
|
||||
*/
|
||||
public void setVascBackend(VascBackend vascBackend) {
|
||||
public void setVascBackend(VascBackend<Serializable> vascBackend) {
|
||||
this.vascBackend = vascBackend;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
package net.forwardfire.vasc.core;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackend;
|
||||
|
@ -45,9 +46,9 @@ public interface VascEntryConfigController {
|
|||
|
||||
public void configVascEntry(VascController vascController,VascEntryLocal vascEntry) throws VascException;
|
||||
|
||||
public VascBackend configVascBackendProxied(VascController vascController,VascEntry vascEntry) throws VascException;
|
||||
public VascBackend<Serializable> configVascBackendProxied(VascController vascController,VascEntry vascEntry) throws VascException;
|
||||
|
||||
public VascBackend configVascBackendProxied(VascController vascController,VascEntry vascEntry,VascBackend realBackend) throws VascException;
|
||||
public VascBackend<Serializable> configVascBackendProxied(VascController vascController,VascEntry vascEntry,VascBackend<Serializable> realBackend) throws VascException;
|
||||
|
||||
public List<String> getVascEntryExporterIds();
|
||||
|
||||
|
|
|
@ -41,22 +41,22 @@ public interface VascEntryState extends Serializable {
|
|||
/**
|
||||
* @return the entryDataList
|
||||
*/
|
||||
public List<Object> getEntryDataList();
|
||||
public List<Serializable> getEntryDataList();
|
||||
|
||||
/**
|
||||
* @param entryDataList the entryDataList to set
|
||||
*/
|
||||
public void setEntryDataList(List<Object> entryDataList);
|
||||
public void setEntryDataList(List<Serializable> entryDataList);
|
||||
|
||||
/**
|
||||
* @return the entryDataObject
|
||||
*/
|
||||
public Object getEntryDataObject();
|
||||
public Serializable getEntryDataObject();
|
||||
|
||||
/**
|
||||
* @param entryDataObject the entryDataObject to set
|
||||
*/
|
||||
public void setEntryDataObject(Object entryDataObject);
|
||||
public void setEntryDataObject(Serializable entryDataObject);
|
||||
|
||||
/**
|
||||
* @return the vascBackendState
|
||||
|
@ -97,12 +97,12 @@ public interface VascEntryState extends Serializable {
|
|||
/**
|
||||
* @return the vascBackend
|
||||
*/
|
||||
public VascBackend getVascBackend();
|
||||
public VascBackend<Serializable> getVascBackend();
|
||||
|
||||
/**
|
||||
* @param vascBackend the vascBackend to set
|
||||
*/
|
||||
public void setVascBackend(VascBackend vascBackend);
|
||||
public void setVascBackend(VascBackend<Serializable> vascBackend);
|
||||
|
||||
/**
|
||||
* @return the isEditCreate
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
|
||||
package net.forwardfire.vasc.core.actions;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
|
||||
|
@ -34,6 +36,6 @@ public interface RowVascAction extends VascAction {
|
|||
|
||||
public boolean isMultiRowAction();
|
||||
|
||||
public void doRowAction(VascEntry vascEntry,Object rowObject) throws VascException;
|
||||
public void doRowAction(VascEntry vascEntry,Serializable rowObject) throws VascException;
|
||||
|
||||
}
|
|
@ -22,6 +22,8 @@
|
|||
|
||||
package net.forwardfire.vasc.frontend;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
|
||||
/**
|
||||
|
@ -34,7 +36,7 @@ public interface VascFrontendActions extends VascFrontendEntry {
|
|||
|
||||
public void refreshData() throws VascFrontendException;
|
||||
|
||||
public Object createObject() throws VascFrontendException;
|
||||
public Serializable createObject() throws VascFrontendException;
|
||||
|
||||
public void deleteObject() throws VascFrontendException;
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
|
||||
package net.forwardfire.vasc.impl.actions;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.actions.AbstractVascRowActionLocal;
|
||||
|
@ -42,9 +44,9 @@ public class AddRowAction extends AbstractVascRowActionLocal {
|
|||
}
|
||||
|
||||
|
||||
public void doRowAction(VascEntry entry,Object rowObject) throws VascException {
|
||||
public void doRowAction(VascEntry entry,Serializable rowObject) throws VascException {
|
||||
entry.getVascFrontendController().getVascEntryState().setEditCreate(true);
|
||||
Object object = entry.getVascFrontendController().getVascFrontendActions().createObject();
|
||||
Serializable object = entry.getVascFrontendController().getVascFrontendActions().createObject();
|
||||
entry.getVascFrontendController().getVascEntryState().setEntryDataObject(object);
|
||||
entry.getVascFrontendController().getVascFrontend().renderEdit();
|
||||
}
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
|
||||
package net.forwardfire.vasc.impl.actions;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.actions.AbstractVascRowActionLocal;
|
||||
|
@ -41,7 +43,7 @@ public class DeleteRowAction extends AbstractVascRowActionLocal {
|
|||
return ACTION_ID;
|
||||
}
|
||||
|
||||
public void doRowAction(VascEntry entry,Object rowObject) throws VascException {
|
||||
public void doRowAction(VascEntry entry,Serializable rowObject) throws VascException {
|
||||
if (rowObject==null) {
|
||||
return; // nothing selected
|
||||
}
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
|
||||
package net.forwardfire.vasc.impl.actions;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.actions.AbstractVascRowActionLocal;
|
||||
|
@ -43,7 +45,7 @@ public class EditRowAction extends AbstractVascRowActionLocal {
|
|||
}
|
||||
|
||||
|
||||
public void doRowAction(VascEntry entry,Object rowObject) throws VascException {
|
||||
public void doRowAction(VascEntry entry,Serializable rowObject) throws VascException {
|
||||
if (rowObject==null) {
|
||||
return; // nothing selected
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
package net.forwardfire.vasc.impl.frontend;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
@ -55,9 +56,9 @@ public class DefaultVascFrontendActions implements VascFrontendActions {
|
|||
/**
|
||||
* @see net.forwardfire.vasc.frontend.VascFrontendHelper#initEditObject(net.forwardfire.vasc.core.VascEntry)
|
||||
*/
|
||||
public Object createObject() throws VascFrontendException {
|
||||
public Serializable createObject() throws VascFrontendException {
|
||||
entry.getVascFrontendController().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.PRE_CREATE, null);
|
||||
Object object;
|
||||
Serializable object;
|
||||
try {
|
||||
object = entry.getVascFrontendController().getVascEntryState().getVascBackend().provideVascEntryRecordCreator().newRecord();
|
||||
} catch (VascBackendException e) {
|
||||
|
@ -146,8 +147,8 @@ public class DefaultVascFrontendActions implements VascFrontendActions {
|
|||
|
||||
protected Object saveObject(boolean persist) throws VascException {
|
||||
try {
|
||||
Object object = entry.getVascFrontendController().getVascEntryState().getEntryDataObject();
|
||||
Object result = null;
|
||||
Serializable object = entry.getVascFrontendController().getVascEntryState().getEntryDataObject();
|
||||
Serializable result = null;
|
||||
|
||||
entry.getVascFrontendController().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.PRE_UPDATE,object);
|
||||
int index = removeObjectFromDataList(object);
|
||||
|
@ -183,7 +184,7 @@ public class DefaultVascFrontendActions implements VascFrontendActions {
|
|||
*/
|
||||
public void deleteObject() throws VascFrontendException {
|
||||
try {
|
||||
Object object = entry.getVascFrontendController().getVascEntryState().getEntryDataObject();
|
||||
Serializable object = entry.getVascFrontendController().getVascEntryState().getEntryDataObject();
|
||||
entry.getVascFrontendController().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.PRE_DELETE, object);
|
||||
entry.getVascFrontendController().getVascEntryState().getVascBackend().delete(object);
|
||||
|
||||
|
|
|
@ -156,7 +156,11 @@ public class VascControllerService {
|
|||
|
||||
@Override
|
||||
public void controllerEvent(VascEventControllerType type,Object eventObject) {
|
||||
generateRequest = System.currentTimeMillis();
|
||||
if (bootDone > 0) {
|
||||
generateRequest = System.currentTimeMillis();
|
||||
} else {
|
||||
generateBundle();
|
||||
}
|
||||
}
|
||||
|
||||
public void generateBundle() {
|
||||
|
|
|
@ -27,6 +27,7 @@ import java.awt.FlowLayout;
|
|||
import java.awt.Font;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JButton;
|
||||
|
@ -56,14 +57,14 @@ public class SwingVascEditDialog extends JPanel {
|
|||
private static final long serialVersionUID = 10L;
|
||||
private String headerText = null;
|
||||
private String headerTextValue = null;
|
||||
private Object result = null;
|
||||
private Object bean = null;
|
||||
private Serializable result = null;
|
||||
private Serializable bean = null;
|
||||
private VascEntry entry = null;
|
||||
private SwingVascFrontend swingFrontend = null;
|
||||
private SwingPanelIntegration panels = null;
|
||||
private JPanel editView = null;
|
||||
|
||||
public SwingVascEditDialog(SwingVascFrontend swingFrontend,JPanel editView,VascEntry entry,Object bean,String beanValue,SwingPanelIntegration panels) throws VascException {
|
||||
public SwingVascEditDialog(SwingVascFrontend swingFrontend,JPanel editView,VascEntry entry,Serializable bean,String beanValue,SwingPanelIntegration panels) throws VascException {
|
||||
super();
|
||||
this.headerText = "vasc.dialog.edit.message";
|
||||
this.headerTextValue = beanValue;
|
||||
|
|
|
@ -33,6 +33,7 @@ import java.awt.event.MouseEvent;
|
|||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
@ -156,7 +157,7 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
public void renderEdit() throws VascFrontendException {
|
||||
logger.fine("Rending Edit View");
|
||||
try {
|
||||
Object rowBean = entry.getVascFrontendController().getVascEntryState().getEntryDataObject();
|
||||
Serializable rowBean = entry.getVascFrontendController().getVascEntryState().getEntryDataObject();
|
||||
String beanValue = rowBean.toString();
|
||||
if (entry.getDisplayNameFieldId()!=null) {
|
||||
VascEntryField v = entry.getVascEntryFieldById(entry.getDisplayNameFieldId());
|
||||
|
@ -503,7 +504,7 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
if (rowIndex!=-1) {
|
||||
// temp; gets index by sorter
|
||||
//rowIndex = tableSorter.modelIndex(rowIndex);
|
||||
Object data = entry.getVascFrontendController().getVascEntryState().getEntryDataList().get(rowIndex);
|
||||
Serializable data = entry.getVascFrontendController().getVascEntryState().getEntryDataList().get(rowIndex);
|
||||
entry.getVascFrontendController().getVascEntryState().setEntryDataObject(data);
|
||||
} else {
|
||||
entry.getVascFrontendController().getVascEntryState().setEntryDataObject(null);
|
||||
|
|
|
@ -45,19 +45,19 @@
|
|||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.forwardfire.vasc</groupId>
|
||||
<groupId>net.forwardfire.vasc.backend</groupId>
|
||||
<artifactId>vasc-backend-ldap</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.forwardfire.vasc</groupId>
|
||||
<groupId>net.forwardfire.vasc.backend</groupId>
|
||||
<artifactId>vasc-backend-mongodb</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.forwardfire.vasc</groupId>
|
||||
<groupId>net.forwardfire.vasc.backend</groupId>
|
||||
<artifactId>vasc-backend-jdbc</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
|
|
|
@ -25,6 +25,7 @@ package net.forwardfire.vasc.frontend.swt;
|
|||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
@ -440,7 +441,7 @@ public class SwtVascFrontend extends AbstractVascFrontend {
|
|||
* @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
|
||||
*/
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
Object data = e.item.getData();
|
||||
Serializable data = (Serializable) e.item.getData();
|
||||
logger.fine("Slecting data: "+data);
|
||||
entry.getVascFrontendController().getVascEntryState().setEntryDataObject(data);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
package net.forwardfire.vasc.frontend.web.jsf;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -50,7 +51,7 @@ public abstract class AbstractJSFVascFacesControllerBase {
|
|||
/**
|
||||
*
|
||||
*/
|
||||
public List<Object> executeVascList(String entryId,Map<String,Object> para) {
|
||||
public List<Serializable> executeVascList(String entryId,Map<String,Object> para) {
|
||||
try {
|
||||
// plug all object
|
||||
VascEntryLocal entry = (VascEntryLocal)getVascController().getVascEntryController().getVascEntryById(entryId);
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
package net.forwardfire.vasc.frontend.web.jsf;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -78,10 +79,10 @@ public class JSFVascEntryEventListener implements VascEntryFrontendEventListener
|
|||
throw new RuntimeException(e);
|
||||
}
|
||||
*/
|
||||
List<Object> data = entry.getVascFrontendController().getVascEntryState().getEntryDataList();
|
||||
List<Serializable> data = entry.getVascFrontendController().getVascEntryState().getEntryDataList();
|
||||
List<Object> result = new ArrayList<Object>(data.size());
|
||||
int index = 0;
|
||||
for (Object o:data) {
|
||||
for (Serializable o:data) {
|
||||
VascDataBackendBean b = new VascDataBackendBean(entry,o,index);
|
||||
result.add(b);
|
||||
index++;
|
||||
|
|
|
@ -318,7 +318,7 @@ public class JSFVascEntrySupportBean implements Serializable {
|
|||
VascEntry parent = entry.getVascFrontendController().getVascEntryState().getParent().getVascEntry();
|
||||
|
||||
RowVascAction action = parent.getRowActionById(actionIdString);
|
||||
Object parentSelected = entry.getVascFrontendController().getVascEntryState().getParent().getEntryDataObject();
|
||||
Serializable parentSelected = entry.getVascFrontendController().getVascEntryState().getParent().getEntryDataObject();
|
||||
logger.fine("parentCustomRowaction do on: "+action+" parentSelection: "+parentSelected);
|
||||
try {
|
||||
action.doRowAction(parent,parentSelected);
|
||||
|
@ -401,7 +401,7 @@ public class JSFVascEntrySupportBean implements Serializable {
|
|||
Boolean value = state.getMultiActionSelection().get(rowId);
|
||||
logger.fine("multiRow selected: "+rowId+" value: "+value);
|
||||
if (value!=null && value==true) {
|
||||
Object row = state.getEntryDataList().get(rowId);
|
||||
Serializable row = state.getEntryDataList().get(rowId);
|
||||
logger.finer("row: "+row);
|
||||
action.doRowAction(vascEntry, row);
|
||||
if (action.getId().equals(DeleteRowAction.ACTION_ID)) {
|
||||
|
@ -468,7 +468,7 @@ public class JSFVascEntrySupportBean implements Serializable {
|
|||
VascEntry entry = getVascEntry();
|
||||
|
||||
// select record to edit
|
||||
Object rowObject = entry.getVascFrontendController().getVascEntryState().getParent().getEntryDataObject();
|
||||
Serializable rowObject = entry.getVascFrontendController().getVascEntryState().getParent().getEntryDataObject();
|
||||
comp.initGoto(entry.getVascFrontendController().getVascEntryState().getParent(),rowObject);
|
||||
}
|
||||
|
||||
|
@ -613,7 +613,7 @@ public class JSFVascEntrySupportBean implements Serializable {
|
|||
VascEntryLink link = comp.getVascEntry().getVascFrontendController().getVascEntryState().getParent().getVascEntry().getVascEntryLinkById(linkId);
|
||||
comp.initGoto(link,comp.getVascEntry().getVascFrontendController().getVascEntryState().getParent());
|
||||
|
||||
Object o = comp.getVascEntry().getVascFrontendController().getVascEntryState().getParent().getEntryDataObject();
|
||||
Serializable o = comp.getVascEntry().getVascFrontendController().getVascEntryState().getParent().getEntryDataObject();
|
||||
int index = comp.getVascEntry().getVascFrontendController().getVascEntryState().getParent().getEntryDataList().indexOf(o);
|
||||
VascDataBackendBean selected = new VascDataBackendBean(entry,o,index);
|
||||
this.selected=selected;
|
||||
|
@ -668,17 +668,17 @@ public class JSFVascEntrySupportBean implements Serializable {
|
|||
VascEntry entry = comp.getVascEntry();
|
||||
VascEntryState state = entry.getVascFrontendController().getVascEntryState();
|
||||
|
||||
List<Object> sels = new ArrayList<Object>(5);
|
||||
List<Serializable> sels = new ArrayList<Serializable>(5);
|
||||
for (Integer rowId:state.getMultiActionSelection().keySet()) {
|
||||
Boolean value = state.getMultiActionSelection().get(rowId);
|
||||
logger.fine("multiRow delete: "+rowId+" value: "+value);
|
||||
if (value!=null && value==true) {
|
||||
Object row = state.getEntryDataList().get(rowId);
|
||||
Serializable row = state.getEntryDataList().get(rowId);
|
||||
sels.add(row);
|
||||
}
|
||||
}
|
||||
if (sels.isEmpty()==false) {
|
||||
for (Object row:sels) {
|
||||
for (Serializable row:sels) {
|
||||
entry.getVascFrontendController().getVascEntryState().setEntryDataObject(row);
|
||||
entry.getVascFrontendController().getVascFrontendActions().deleteObject();
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
package net.forwardfire.vasc.frontend.web.jsf;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
@ -72,7 +73,7 @@ public class JSFVascUIComponent extends UIComponentBase {
|
|||
private VascEntryLink link = null;
|
||||
private VascEntryState linkState = null;
|
||||
private VascEntryState state = null;
|
||||
private Object stateEditId = null;
|
||||
private Serializable stateEditId = null;
|
||||
private Logger logger = null;
|
||||
private Boolean initClear = null;
|
||||
private String injectTableOptionOnChange = null;
|
||||
|
@ -182,7 +183,7 @@ public class JSFVascUIComponent extends UIComponentBase {
|
|||
this.state=state;
|
||||
}
|
||||
|
||||
protected void initGoto(VascEntryState state,Object stateEditId) {
|
||||
protected void initGoto(VascEntryState state,Serializable stateEditId) {
|
||||
logger.fine("init goto "+state);
|
||||
this.state=state;
|
||||
this.stateEditId=stateEditId;
|
||||
|
@ -218,7 +219,7 @@ public class JSFVascUIComponent extends UIComponentBase {
|
|||
}
|
||||
|
||||
if (stateEditId!=null) {
|
||||
Object rowObject = stateEditId;
|
||||
Serializable rowObject = stateEditId;
|
||||
|
||||
// setup for renderEdit() of frontend
|
||||
List<Object> list = new ArrayList<Object>(1);
|
||||
|
|
|
@ -29,11 +29,8 @@ import net.forwardfire.vasc.backend.VascBackendException;
|
|||
import net.forwardfire.vasc.backend.VascEntryFieldValue;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.frontend.VascFrontendDataSelector.EntryFieldSelectType;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
|
@ -44,11 +41,11 @@ public class VascDataBackendBean implements Serializable {
|
|||
|
||||
private static final long serialVersionUID = 3881688974089760074L;
|
||||
private VascEntry entry = null;
|
||||
private Object record = null;
|
||||
private Serializable record = null;
|
||||
private boolean realValue = false;
|
||||
private int recordId = 0;
|
||||
|
||||
public VascDataBackendBean(VascEntry entry,Object record,int recordId) {
|
||||
public VascDataBackendBean(VascEntry entry,Serializable record,int recordId) {
|
||||
this.entry=entry;
|
||||
this.record=record;
|
||||
this.recordId=recordId;
|
||||
|
@ -102,7 +99,7 @@ public class VascDataBackendBean implements Serializable {
|
|||
}
|
||||
}
|
||||
|
||||
public Object getRecord() {
|
||||
public Serializable getRecord() {
|
||||
return record;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package net.forwardfire.vasc.opt.editor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -27,14 +28,14 @@ import net.forwardfire.vasc.impl.DefaultVascEntryField;
|
|||
import net.forwardfire.vasc.impl.DefaultVascEntryFieldSet;
|
||||
import net.forwardfire.vasc.impl.DefaultVascEntryLink;
|
||||
|
||||
public class VirtualVascBackend extends AbstractVascBackend {
|
||||
public class VirtualVascBackend extends AbstractVascBackend<Serializable> {
|
||||
|
||||
private VascController vascController = null;
|
||||
private String vascType = "entry";
|
||||
private String entryId = null;
|
||||
|
||||
public List<Object> execute(VascBackendState state) throws VascBackendException {
|
||||
List<Object> result = new ArrayList<Object>(100);
|
||||
public List<Serializable> execute(VascBackendState state) throws VascBackendException {
|
||||
List<Serializable> result = new ArrayList<Serializable>(100);
|
||||
entryId = (String)state.getDataParameter("entry_id");
|
||||
if ("entry".equals(vascType)) {
|
||||
for (String id:vascController.getVascEntryController().getVascEntryIds()) {
|
||||
|
@ -65,19 +66,19 @@ public class VirtualVascBackend extends AbstractVascBackend {
|
|||
return result;
|
||||
}
|
||||
|
||||
public void persist(Object object) throws VascBackendException {
|
||||
public void persist(Serializable object) throws VascBackendException {
|
||||
edit(object,false,true);
|
||||
}
|
||||
|
||||
public Object merge(Object object) throws VascBackendException {
|
||||
public Serializable merge(Serializable object) throws VascBackendException {
|
||||
return edit(object,true,true);
|
||||
}
|
||||
|
||||
public void delete(Object object) throws VascBackendException {
|
||||
public void delete(Serializable object) throws VascBackendException {
|
||||
edit(object,true,false);
|
||||
}
|
||||
|
||||
public Object edit(Object object,boolean removeReal,boolean addEdit) throws VascBackendException {
|
||||
public Serializable edit(Serializable object,boolean removeReal,boolean addEdit) throws VascBackendException {
|
||||
|
||||
if (object instanceof VascEntry) {
|
||||
entryId = ((VascEntry)object).getId();
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
package net.forwardfire.vasc.test.frontend.data;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import net.forwardfire.vasc.annotations.VascDefaultValue;
|
||||
|
@ -41,8 +42,9 @@ import net.forwardfire.vasc.validators.VascStringLength;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 28, 2007
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
@VascEntry(headerName="En een tooltip op het model")
|
||||
public class TestModelOrder {
|
||||
public class TestModelOrder implements Serializable {
|
||||
|
||||
private Integer id = null;
|
||||
private String name = null;
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
package net.forwardfire.vasc.test.frontend.data;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import net.forwardfire.vasc.annotations.VascDefaultValue;
|
||||
|
@ -41,8 +42,9 @@ import net.forwardfire.vasc.validators.VascStringLength;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 Feb 7, 2012
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
@VascEntry(headerName="OrderLine")
|
||||
public class TestModelOrderLine {
|
||||
public class TestModelOrderLine implements Serializable {
|
||||
|
||||
private TestModelOrder order = null;
|
||||
private String name = null;
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
package net.forwardfire.vasc.test.frontend.data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
@ -45,8 +46,8 @@ import net.forwardfire.vasc.backend.data.BeanVascEntryRecordCreator;
|
|||
public class TestModelVascDataSource {
|
||||
|
||||
//private List<TestModelOrder> testModels = null;
|
||||
public ListObjectVascDataSource orderModel = null;
|
||||
public ListObjectVascDataSource orderLineModel = null;
|
||||
public ListObjectVascDataSource<TestModelOrder> orderModel = null;
|
||||
public ListObjectVascDataSource<TestModelOrderLine> orderLineModel = null;
|
||||
|
||||
public TestModelVascDataSource() {
|
||||
this(new ArrayList<TestModelOrder>(200),new ArrayList<TestModelOrderLine>(200));
|
||||
|
@ -86,26 +87,26 @@ public class TestModelVascDataSource {
|
|||
}
|
||||
}
|
||||
|
||||
class ListObjectVascDataSource extends AbstractVascBackend {
|
||||
class ListObjectVascDataSource<DATA_OBJECT extends Serializable> extends AbstractVascBackend<DATA_OBJECT> {
|
||||
private Class<?> modelClass = null;
|
||||
private List<Object> modelList = null;
|
||||
private List<DATA_OBJECT> modelList = null;
|
||||
private String nullLabel = null;
|
||||
private String nullKeyValue = null;
|
||||
|
||||
public ListObjectVascDataSource(Class<?> modelClass,List<Object> modelList) {
|
||||
public ListObjectVascDataSource(Class<?> modelClass,List<DATA_OBJECT> modelList) {
|
||||
this.modelClass=modelClass;
|
||||
this.modelList=modelList;
|
||||
}
|
||||
|
||||
public List<Object> getObjectList() {
|
||||
public List<DATA_OBJECT> getObjectList() {
|
||||
return modelList;
|
||||
}
|
||||
|
||||
public List<Object> execute(VascBackendState state) throws VascBackendException {
|
||||
public List<DATA_OBJECT> execute(VascBackendState state) throws VascBackendException {
|
||||
if (state.getDataParameterKeys().isEmpty()==false) {
|
||||
List<Object> result = new ArrayList<Object>(modelList.size()/2);
|
||||
List<DATA_OBJECT> result = new ArrayList<DATA_OBJECT>(modelList.size()/2);
|
||||
DefaultElementObjectPropertyValue helper = new DefaultElementObjectPropertyValue();
|
||||
for (Object row:modelList) {
|
||||
for (DATA_OBJECT row:modelList) {
|
||||
boolean addRow = true;
|
||||
for (String key:state.getDataParameterKeys()) {
|
||||
Object keyValue = state.getDataParameter(key);
|
||||
|
@ -129,26 +130,26 @@ public class TestModelVascDataSource {
|
|||
}
|
||||
return result;
|
||||
} else {
|
||||
List<Object> result = new ArrayList<Object>(modelList.size());
|
||||
for (Object row:modelList) {
|
||||
List<DATA_OBJECT> result = new ArrayList<DATA_OBJECT>(modelList.size());
|
||||
for (DATA_OBJECT row:modelList) {
|
||||
result.add(row);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public void persist(Object object) throws VascBackendException {
|
||||
public void persist(DATA_OBJECT object) throws VascBackendException {
|
||||
modelList.add(object);
|
||||
}
|
||||
|
||||
public Object merge(Object object) throws VascBackendException {
|
||||
public DATA_OBJECT merge(DATA_OBJECT object) throws VascBackendException {
|
||||
if(modelList.contains(object)==false) {
|
||||
modelList.add(object);
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
public void delete(Object object) throws VascBackendException {
|
||||
public void delete(DATA_OBJECT object) throws VascBackendException {
|
||||
modelList.remove(object);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue