2
0
Fork 0

WIP: left over open files for long...

This commit is contained in:
Willem 2017-06-10 02:22:01 +02:00
parent 0a2398c5c1
commit 76aa74990e
165 changed files with 4299 additions and 3373 deletions

View file

@ -124,10 +124,6 @@
<!-- Java EE --> <!-- Java EE -->
<javaee-api.version>6.0</javaee-api.version> <javaee-api.version>6.0</javaee-api.version>
<ejb-api.version>3.0</ejb-api.version>
<jta.version>1.1</jta.version>
<persistence-api.version>1.0.2</persistence-api.version>
<servlet-api.version>3.0-alpha-1</servlet-api.version>
<jsr181-api.version>1.0-MR1</jsr181-api.version> <!-- ws annotations --> <jsr181-api.version>1.0-MR1</jsr181-api.version> <!-- ws annotations -->
<jstl.version>1.2</jstl.version> <jstl.version>1.2</jstl.version>
<jsp-api.version>2.2.1-b03</jsp-api.version> <jsp-api.version>2.2.1-b03</jsp-api.version>

View file

@ -35,3 +35,4 @@
- create XML-RPC frontend - create XML-RPC frontend
- export interface + exports - export interface + exports
- graphs of numeric value columns - graphs of numeric value columns
- Add JETT export templates support

View file

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

View file

@ -1,142 +0,0 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.backend;
import java.io.Serializable;
/**
* AbstractVascBackend.
*
*
* @author Willem Cazander
* @version 1.0 Aug 2, 2007
*/
abstract public class AbstractVascBackend<DATA_OBJECT extends Serializable> implements VascBackend<DATA_OBJECT> {
private String id = null;
/**
* @see net.forwardfire.vasc.backend.VascBackend#getId()
*/
@Override
public String getId() {
return id;
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#setId(java.lang.String)
*/
@Override
public void setId(String id) {
if (id==null) {
throw new IllegalArgumentException("id may not be null");
}
this.id=id;
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#startBackend()
*/
@Override
public void startBackend() {
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#stopBackend()
*/
@Override
public void stopBackend() {
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#isReadOnly()
*/
@Override
public boolean isReadOnly() {
return false;
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#isPageable()
*/
@Override
public boolean isPageable() {
return false;
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#isSearchable()
*/
@Override
public boolean isSearchable() {
return false;
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#isSortable()
*/
@Override
public boolean isSortable() {
return false;
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#isRecordMoveable()
*/
@Override
public boolean isRecordMoveable() {
return false;
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#doRecordMoveDownById(java.lang.Object)
*/
@Override
public long doRecordMoveDownById(VascBackendState state,Object primaryId) throws VascBackendException {
return 0l;
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#doRecordMoveUpById(java.lang.Object)
*/
@Override
public long doRecordMoveUpById(VascBackendState state,Object primaryId) throws VascBackendException {
return 0l;
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#hasPageSummary()
*/
@Override
public boolean hasPageSummary() {
return false;
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#hasTotalSummary()
*/
@Override
public boolean hasTotalSummary() {
return false;
}
}

View file

@ -22,14 +22,12 @@
package net.forwardfire.vasc.backend; package net.forwardfire.vasc.backend;
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
* AbstractVascBackendControllerLocal * AbstractVascBackendControllerLocal
* *
@ -38,18 +36,16 @@ import java.util.Map;
*/ */
abstract public class AbstractVascBackendControllerLocal implements VascBackendControllerLocal { abstract public class AbstractVascBackendControllerLocal implements VascBackendControllerLocal {
private Map<String,VascBackend<Serializable>> backends = null; private Map<String,VascBackend> backends = null;
public AbstractVascBackendControllerLocal() { public AbstractVascBackendControllerLocal() {
backends = new HashMap<String,VascBackend<Serializable>>(1000); backends = new HashMap<String,VascBackend>(1000);
} }
/**
* @see net.forwardfire.vasc.backend.VascBackendController#getVascBackendById(java.lang.String)
*/
@Override @Override
public VascBackend<Serializable> getVascBackendById(String id) { @SuppressWarnings("unchecked")
return backends.get(id); public <BACKEND_TYPE extends VascBackend> BACKEND_TYPE getVascBackendById(Class<BACKEND_TYPE> clazz,String id) {
return (BACKEND_TYPE) backends.get(id);
} }
/** /**
@ -66,42 +62,47 @@ abstract public class AbstractVascBackendControllerLocal implements VascBackendC
} }
/** /**
* @see net.forwardfire.vasc.backend.VascBackendControllerLocal#addVascBackend(net.forwardfire.vasc.backend.VascBackend) * @see net.forwardfire.vasc.backend.VascBackendControllerLocal#addVascBackend(net.forwardfire.vasc.backend.crud.VascBackendCrud)
*/ */
@SuppressWarnings("unchecked")
@Override @Override
public void addVascBackend(VascBackend<? extends Serializable> backend) { public void addVascBackend(VascBackend backend) {
if (backend==null) { if (backend==null) {
throw new NullPointerException("backend must not be null."); throw new NullPointerException("backend must not be null.");
} }
if (backend.getId()==null) { if (backend.getId()==null) {
throw new IllegalArgumentException("The backend must have an id."); 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)
*/
@Override @Override
public void removeVascBackendById(String backendId) { public VascBackend removeVascBackend(VascBackend backend) {
VascBackend<? extends Serializable> backend = getVascBackendById(backendId); VascBackend result = getVascBackendById(VascBackend.class,backend.getId());
if (backend==null) { if (result==null) {
throw new NullPointerException("Could not find backend to remove with id: "+backendId); throw new NullPointerException("Could not find backend to remove with id: "+backend.getId());
} }
backend.stopBackend(); return backends.remove(backend.getId());
backends.remove(backendId);
} }
/**
* @see net.forwardfire.vasc.backend.VascBackendControllerLocal#clearAndStopBackends()
*/
@Override @Override
public void clearAndStopBackends() { public void stopBackends() {
for (String backendId:getVascBackendIds()) { for (String backendId:getVascBackendIds()) {
removeVascBackendById(backendId); VascBackend vb = getVascBackendById(VascBackend.class,backendId);
if (vb instanceof VascBackendLocal) {
VascBackendLocal vbl = (VascBackendLocal)vb;
vbl.stopBackend();
}
}
}
@Override
public void startBackends() {
for (String backendId:getVascBackendIds()) {
VascBackend vb = getVascBackendById(VascBackend.class,backendId);
if (vb instanceof VascBackendLocal) {
VascBackendLocal vbl = (VascBackendLocal)vb;
vbl.startBackend();
}
} }
} }
} }

View file

@ -0,0 +1,87 @@
package net.forwardfire.vasc.backend;
import java.io.Serializable;
import java.util.Collection;
import java.util.Objects;
abstract public class AbstractVascBackendLocal<DATA_PK extends Serializable> implements VascBackendLocal<DATA_PK> {
private static final String CHECK_MSG_ID = " in ";
private String id = null;
private volatile boolean running = false;
/**
* @see net.forwardfire.vasc.backend.crud.VascBackend#getId()
*/
@Override
final public String getId() {
return id;
}
/**
* @see net.forwardfire.vasc.backend.crud.VascBackendLocal#setId(java.lang.String)
*/
@Override
final public void setId(String id) {
if (id==null) {
throw new IllegalArgumentException("id may not be null");
}
if (this.id!=null) {
throw new IllegalStateException("Can't change id after setting.");
}
this.id=id;
}
abstract protected void startBackendLocal();
protected void stopBackendLocal() {
}
/**
* @see net.forwardfire.vasc.backend.crud.VascBackendLocal#startBackend()
*/
@Override
final public void startBackend() {
requireNonEmpty(getId(),"id is empty.");
startBackendLocal();
running = true;
}
/**
* @see net.forwardfire.vasc.backend.crud.VascBackendLocal#stopBackend()
*/
@Override
final public void stopBackend() {
stopBackendLocal();
running = false;
}
/**
* @see net.forwardfire.vasc.backend.VascBackendLifeCycle#isRunning()
*/
@Override
final public boolean isRunning() {
return running;
}
final private String createCheckMessage(String message) {
return message + CHECK_MSG_ID + getId();
}
final protected void requireNonNull(Object value, String message) {
Objects.requireNonNull(value, createCheckMessage(message));
}
final protected void requireNonEmpty(String value, String message) {
requireNonNull(value, message);
if (value.isEmpty()) {
throw new IllegalArgumentException(createCheckMessage(message));
}
}
final protected void requireNonEmpty(Collection<?> value, String message) {
requireNonNull(value, message);
if (value.isEmpty()) {
throw new IllegalArgumentException(createCheckMessage(message));
}
}
}

View file

@ -0,0 +1,8 @@
package net.forwardfire.vasc.backend;
import java.io.Serializable;
public abstract interface AbstractVascBackendRecord <K extends Serializable,T extends Serializable> extends VascBackend<K> {
VascBackendAccessDataRecord<K,T> createVascBackendAccessDataRecord();
}

View file

@ -1,96 +1,10 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.backend; package net.forwardfire.vasc.backend;
import java.io.Serializable; import java.io.Serializable;
/** public interface VascBackend <DATA_PK extends Serializable> {
* VascBackend provides stateless data access to a data source.
*
* @author Willem Cazander
* @version 1.0 Mar 21, 2007
*/
public interface VascBackend<DATA_OBJECT extends Serializable> {
String getId(); String getId();
void setId(String id);
void startBackend(); VascBackendAccessDataKey<DATA_PK> createVascBackendAccessDataKey();
void stopBackend();
VascBackendResult<DATA_OBJECT> execute(VascBackendState state) throws VascBackendException;
boolean isReadOnly();
//public DATA_OBJECT fetch(Map<String,Serializable> pks) throws VascBackendException;
void persist(DATA_OBJECT record) throws VascBackendException;
DATA_OBJECT merge(DATA_OBJECT record) throws VascBackendException;
void delete(DATA_OBJECT record) throws VascBackendException;
/**
* Creates a new Field acces obj the the given field entry.
* note: Do not use inline class here because it needs to be seriabable and the backend is not seriabbzle.
* @return
*/
VascEntryFieldValue<DATA_OBJECT> provideVascEntryFieldValue();
/**
* Creates a new RecordCreater obj the the given entry.
* note: Do not use inline class here because it needs to be seriabable and the backend is not seriabbzle.
* @return
*/
VascEntryRecordCreator<DATA_OBJECT> provideVascEntryRecordCreator();
/**
* Defines if the backend supports sorting
* @return
*/
boolean isSortable();
/**
* Defines if the backend supports pageing
* @return
*/
boolean isPageable();
/**
* Defines if the backend supports pageing
* @return
*/
boolean isSearchable();
/**
* Defines if the backend supports moveing an record up or down.
* @return
*/
boolean isRecordMoveable();
long doRecordMoveUpById(VascBackendState state,Object primaryId) throws VascBackendException;
long doRecordMoveDownById(VascBackendState state,Object primaryId) throws VascBackendException;
boolean hasPageSummary();
boolean hasTotalSummary();
} }

View file

@ -23,28 +23,21 @@
package net.forwardfire.vasc.backend; package net.forwardfire.vasc.backend;
import java.io.Serializable; import java.io.Serializable;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
* DefaultVascBackendResult. * VascEntryFieldValue
* *
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Aug 23, 2014 * @version 1.0 Oct 24, 2014
*/ */
public final class DefaultVascBackendResult<DATA_OBJECT extends Serializable> extends AbstractVascBackendResult<DATA_OBJECT> { public interface VascBackendAccessDataKey<DATA_PK extends Serializable> extends Serializable {
public DefaultVascBackendResult(List<DATA_OBJECT> pageData) { Map<String,Class<?>> getKeyMapType();
this(pageData,-1); Map<String,Serializable> getKeyMapFromPrimaryKey(DATA_PK primaryKey) throws VascBackendException;
} DATA_PK getPrimaryKeyFromKeyMap(Map<String,Serializable> keyMap) throws VascBackendException;
public DefaultVascBackendResult(List<DATA_OBJECT> pageData,long totalSize) { Map<String,String> getStringMapFromPrimaryKey(DATA_PK primaryKey) throws VascBackendException;
this(pageData,totalSize,null,null); DATA_PK getPrimaryKeyFromStringMap(Map<String,String> keyMap) throws VascBackendException;
}
public DefaultVascBackendResult(List<DATA_OBJECT> pageData, long totalSize,
Map<String, Serializable> pageSummary,
Map<String, Serializable> totalSummary) {
super(pageData, totalSize, pageSummary, totalSummary);
}
} }

View file

@ -31,11 +31,11 @@ import java.io.Serializable;
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Mar 21, 2007 * @version 1.0 Mar 21, 2007
*/ */
public interface VascEntryFieldValue<DATA_OBJECT extends Serializable> extends Serializable { public interface VascBackendAccessDataRecord<DATA_PK extends Serializable,DATA_RECORD extends Serializable> extends Serializable {
Serializable getValue(String backendName,DATA_OBJECT record) throws VascBackendException; DATA_PK getPrimaryKey(DATA_RECORD record) throws VascBackendException;
String getDisplayValue(String backendName,DATA_OBJECT record) throws VascBackendException; Serializable getValue(String backendName,DATA_RECORD record) throws VascBackendException;
void setValue(String backendName,DATA_OBJECT record,Serializable value) throws VascBackendException; void setValue(String backendName,DATA_RECORD record,Serializable value) throws VascBackendException;
} }

View file

@ -22,18 +22,17 @@
package net.forwardfire.vasc.backend; package net.forwardfire.vasc.backend;
import java.io.Serializable;
import java.util.List; import java.util.List;
/** /**
* VascBackendController.
* *
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Sep 4, 2008 * @version 1.0 Sep 4, 2008
*/ */
public interface VascBackendController { public interface VascBackendController {
VascBackend<Serializable> getVascBackendById(String id); <BACKEND_TYPE extends VascBackend> BACKEND_TYPE getVascBackendById(Class<BACKEND_TYPE> clazz,String id);
List<String> getVascBackendIds(); List<String> getVascBackendIds();
} }

View file

@ -22,9 +22,6 @@
package net.forwardfire.vasc.backend; package net.forwardfire.vasc.backend;
import java.io.Serializable;
/** /**
* *
* @author Willem Cazander * @author Willem Cazander
@ -32,9 +29,11 @@ import java.io.Serializable;
*/ */
public interface VascBackendControllerLocal extends VascBackendController { public interface VascBackendControllerLocal extends VascBackendController {
void addVascBackend(VascBackend<? extends Serializable> backend); void addVascBackend(VascBackend backend);
void removeVascBackendById(String backendId); VascBackend removeVascBackend(VascBackend backend);
void clearAndStopBackends(); void startBackends();
void stopBackends();
} }

View file

@ -0,0 +1,10 @@
package net.forwardfire.vasc.backend;
import java.io.Serializable;
public interface VascBackendLifeCycle<DATA_PK extends Serializable> extends VascBackend<DATA_PK> {
void startBackend();
void stopBackend();
boolean isRunning();
}

View file

@ -0,0 +1,8 @@
package net.forwardfire.vasc.backend;
import java.io.Serializable;
public interface VascBackendLocal<DATA_PK extends Serializable> extends VascBackendLifeCycle<DATA_PK> {
void setId(String id);
}

View file

@ -20,26 +20,28 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package net.forwardfire.vasc.backend.crud;
package net.forwardfire.vasc.backend.mongodb; import java.io.Serializable;
import net.forwardfire.vasc.backend.AbstractVascBackendRecord;
import net.forwardfire.vasc.backend.VascBackendException; import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascEntryRecordCreator;
import com.mongodb.BasicDBObject;
/** /**
* Provides a mongodb object to create a new row. * VascBackendCrud provides stateless data access to a data source.
* *
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Dec 30, 2011 * @version 1.0 Mar 21, 2007
*/ */
public class MongodbVascEntryRecordCreator implements VascEntryRecordCreator<BasicDBObject> { public interface VascBackendCrud<DATA_PK extends Serializable,DATA_RECORD extends Serializable> extends AbstractVascBackendRecord<DATA_PK,DATA_RECORD> {
private static final long serialVersionUID = -9213830731796787384L; public DATA_RECORD fetch(DATA_PK recordPK) throws VascBackendException;
@Override DATA_RECORD persist(DATA_RECORD record) throws VascBackendException;
public BasicDBObject newRecord() throws VascBackendException {
return new BasicDBObject(); DATA_RECORD merge(DATA_RECORD record) throws VascBackendException;
}
void delete(DATA_PK recordPK) throws VascBackendException;
DATA_RECORD newRecord() throws VascBackendException;
} }

View file

@ -20,26 +20,24 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package net.forwardfire.vasc.backend.data; package net.forwardfire.vasc.backend.crud;
import java.io.Serializable; import java.io.Serializable;
import java.util.HashMap; import java.util.List;
import net.forwardfire.vasc.backend.VascBackendException; import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascEntryRecordCreator;
/** /**
* MapVascEntryRecordCreator creates a new HashMap for Map based record backends. * VascBackendCrudRevision idea test.
* *
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Dec 05, 2009 * @version 1.0 Mar 25, 2014
*/ */
public class HashMapVascEntryRecordCreator implements VascEntryRecordCreator<HashMap<String,Serializable>> { public interface VascBackendCrudRevision<DATA_PK extends Serializable,DATA_RECORD extends Serializable> extends VascBackendCrud<DATA_PK,DATA_RECORD> {
private static final long serialVersionUID = 1L; List<?> revisionList(DATA_PK recordPK) throws VascBackendException;
@Override void revisionDelete(String version) throws VascBackendException;
public HashMap<String,Serializable> newRecord() throws VascBackendException {
return new HashMap<String,Serializable>(10); DATA_RECORD revisionFetch(DATA_PK recordPK,String version) throws VascBackendException;
}
} }

View file

@ -0,0 +1,8 @@
/**
*
*/
/**
* @author willemc
*
*/
package net.forwardfire.vasc.backend.crud;

View file

@ -20,38 +20,35 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package net.forwardfire.vasc.backend.mongodb; package net.forwardfire.vasc.backend.data;
import java.io.Serializable; import java.io.Serializable;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Map;
import net.forwardfire.vasc.backend.VascBackendAccessDataKey;
import net.forwardfire.vasc.backend.VascBackendException; import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascEntryFieldValue;
import com.mongodb.BasicDBObject;
/** /**
* Provides a mongodb field entry knowlege. * AbstractVascBackendAccessDataKey.
* note: all types need to have a String constructor ot
* *
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Dec 30, 2011 * @version 1.0 Oct 27, 2014
*/ */
public class MongodbVascEntryFieldValue implements VascEntryFieldValue<BasicDBObject> { @SuppressWarnings("serial")
abstract public class AbstractVascBackendAccessDataKey<DATA_PK extends Serializable> implements VascBackendAccessDataKey<DATA_PK> {
private static final long serialVersionUID = -7371273796529818557L; private final Map<String,Class<?>> keyMapType;
@Override public AbstractVascBackendAccessDataKey(Map<String,Class<?>> keyMapType) {
public Serializable getValue(String backendName, BasicDBObject row) throws VascBackendException { this.keyMapType = keyMapType;
Serializable data = (Serializable) row.get(backendName);
return data;
} }
@Override @Override
public String getDisplayValue(String field, BasicDBObject row) throws VascBackendException { public final Map<String, Class<?>> getKeyMapType() {
return ""+getValue(field,row); return keyMapType;
}
@Override
public void setValue(String backendName, BasicDBObject row, Serializable value) throws VascBackendException {
row.put(backendName, value);
} }
} }

View file

@ -0,0 +1,75 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.backend.data;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import net.forwardfire.vasc.backend.VascBackendAccessDataKey;
import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascBackendAccessDataRecord;
import org.x4o.xml.element.DefaultElementObjectPropertyValue;
/**
* BeanVascBackendAccessDataKey provides primary key support on beans.
*
* @author Willem Cazander
* @version 1.0 Oct 27, 2014
*/
@SuppressWarnings("serial")
public class BeanVascBackendAccessDataKey<DATA_PK extends Serializable> extends AbstractVascBackendAccessDataKey<DATA_PK> {
private final Class<?> primaryKeyType;
private final DefaultElementObjectPropertyValue bean = new DefaultElementObjectPropertyValue();
public BeanVascBackendAccessDataKey(Class<?> primaryKeyType,Map<String,Class<?>> keyMapType) {
super(keyMapType);
this.primaryKeyType=primaryKeyType;
}
@Override
public Map<String, Serializable> getKeyMapFromPrimaryKey(DATA_PK primaryKey) throws VascBackendException {
Map<String, Serializable> result = new HashMap<String, Serializable>();
return result;
}
@Override
public DATA_PK getPrimaryKeyFromKeyMap(Map<String, Serializable> keyMap) throws VascBackendException {
//DATA_PK result = primaryKeyType.newInstance();
return null;
}
@Override
public Map<String, String> getStringMapFromPrimaryKey(DATA_PK primaryKey) throws VascBackendException {
return null;
}
@Override
public DATA_PK getPrimaryKeyFromStringMap(Map<String, String> keyMap) throws VascBackendException {
return null;
}
}

View file

@ -26,26 +26,40 @@ package net.forwardfire.vasc.backend.data;
import java.io.Serializable; import java.io.Serializable;
import net.forwardfire.vasc.backend.VascBackendException; import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascEntryFieldValue; import net.forwardfire.vasc.backend.VascBackendAccessDataRecord;
import org.x4o.xml.element.DefaultElementObjectPropertyValue; import org.x4o.xml.element.DefaultElementObjectPropertyValue;
/** /**
* BeanVascEntryFieldValue provides get/set support for bean based backends. * BeanVascBackendAccessDataRecord provides get/set support for bean based backends.
* *
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Dec 05, 2009 * @version 1.0 Dec 05, 2009
*/ */
public class BeanVascEntryFieldValue<DATA_OBJECT extends Serializable> implements VascEntryFieldValue<DATA_OBJECT> { @SuppressWarnings("serial")
public class BeanVascBackendAccessDataRecord<DATA_PK extends Serializable,DATA_RECORD extends Serializable> implements VascBackendAccessDataRecord<DATA_PK,DATA_RECORD> {
private static final long serialVersionUID = 1L; private final String primaryKeyProperty;
private DefaultElementObjectPropertyValue bean = new DefaultElementObjectPropertyValue(); private DefaultElementObjectPropertyValue bean = new DefaultElementObjectPropertyValue();
public BeanVascBackendAccessDataRecord(String primaryKeyProperty) {
this.primaryKeyProperty = primaryKeyProperty;
}
/** /**
* @see net.forwardfire.vasc.core.entry.VascEntryFieldValue#getValue(java.lang.String, java.lang.Object) * @see net.forwardfire.vasc.backend.VascBackendAccessDataRecord#getPrimaryKey(java.io.Serializable)
*/ */
@Override @Override
public Serializable getValue(String backendName, DATA_OBJECT record) throws VascBackendException { @SuppressWarnings("unchecked")
public DATA_PK getPrimaryKey(DATA_RECORD record) throws VascBackendException {
return (DATA_PK) getValue(primaryKeyProperty, record);
}
/**
* @see net.forwardfire.vasc.core.entry.VascBackendAccessDataRecord#getValue(java.lang.String, java.lang.Object)
*/
@Override
public Serializable getValue(String backendName, DATA_RECORD record) throws VascBackendException {
if (backendName==null) { if (backendName==null) {
throw new NullPointerException("Can't get value of null backendName."); throw new NullPointerException("Can't get value of null backendName.");
} }
@ -61,40 +75,10 @@ public class BeanVascEntryFieldValue<DATA_OBJECT extends Serializable> implement
} }
/** /**
* @see net.forwardfire.vasc.core.entry.VascEntryFieldValue#getDisplayValue(java.lang.String, java.lang.Object) * @see net.forwardfire.vasc.core.entry.VascBackendAccessDataRecord#setValue(java.lang.String, java.lang.Object, java.lang.Object)
*/ */
@Override @Override
public String getDisplayValue(String backendName, DATA_OBJECT record) throws VascBackendException { public void setValue(String backendName, DATA_RECORD record,Serializable value) throws VascBackendException {
Serializable value = getValue(backendName,record);
if (value==null) {
return "";
}
return value.toString();
/* TODO: move
if (field.getDisplayName()==null) {
if (value instanceof String) {
return (String)value;
}
return ""+value;
}
try {
Object result = bean.getProperty(value, field.getDisplayName());
if (result instanceof String) {
return (String)result;
}
return ""+result;
} catch (Exception e) {
throw new VascBackendException(e);
}
*/
}
/**
* @see net.forwardfire.vasc.core.entry.VascEntryFieldValue#setValue(java.lang.String, java.lang.Object, java.lang.Object)
*/
@Override
public void setValue(String backendName, DATA_OBJECT record,Serializable value) throws VascBackendException {
if (backendName==null) { if (backendName==null) {
throw new NullPointerException("Can't set value of null backendName."); throw new NullPointerException("Can't set value of null backendName.");
} }

View file

@ -0,0 +1,104 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.backend.data;
import java.io.Serializable;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Map;
import net.forwardfire.vasc.backend.VascBackendException;
/**
* HashMapVascBackendAccessDataKey provides get/set support on Map key object.
* note: all types need to have a String constructor.
*
* @author Willem Cazander
* @version 1.0 Oct 26, 2014
*/
@SuppressWarnings("serial")
public class HashMapVascBackendAccessDataKey extends AbstractVascBackendAccessDataKey<HashMap<String,Serializable>> {
public HashMapVascBackendAccessDataKey(Map<String,Class<?>> keyMapType) {
super(keyMapType);
}
@Override
public Map<String, Serializable> getKeyMapFromPrimaryKey(HashMap<String, Serializable> primaryKey) throws VascBackendException {
return new HashMap<String, Serializable>(primaryKey); // wrap only as key is already object map
}
@Override
public HashMap<String, Serializable> getPrimaryKeyFromKeyMap(Map<String, Serializable> keyMap) throws VascBackendException {
return new HashMap<String, Serializable>(keyMap); // wrap only as key is already object map
}
@Override
public Map<String, String> getStringMapFromPrimaryKey(HashMap<String, Serializable> primaryKey) throws VascBackendException {
HashMap<String,String> result = new HashMap<String,String>(primaryKey.size());
for (String key:primaryKey.keySet()) {
Serializable value = primaryKey.get(key);
if (value == null) {
result.put(key, null);
} else {
result.put(key, value.toString());
}
}
return result;
}
@Override
public HashMap<String, Serializable> getPrimaryKeyFromStringMap(Map<String, String> keyMap) throws VascBackendException {
try {
HashMap<String,Serializable> result = new HashMap<String,Serializable>(keyMap.size());
for (String key:keyMap.keySet()) {
String valueStr = keyMap.get(key);
Class<?> valueType = getKeyMapType().get(key);
if (valueType == null) {
throw new IllegalArgumentException("unknown key: "+key);
}
if (valueStr == null) {
result.put(key, null);
continue;
}
Constructor<?> valueObj = valueType.getConstructor(new Class<?>[]{String.class});
Object value = valueObj.newInstance(new Object[]{valueStr});
result.put(key, (Serializable)value);
}
return result;
} catch (NoSuchMethodException e) {
throw new VascBackendException(e);
} catch (SecurityException e) {
throw new VascBackendException(e);
} catch (InstantiationException e) {
throw new VascBackendException(e);
} catch (IllegalAccessException e) {
throw new VascBackendException(e);
} catch (IllegalArgumentException e) {
throw new VascBackendException(e);
} catch (InvocationTargetException e) {
throw new VascBackendException(e);
}
}
}

View file

@ -24,22 +24,40 @@ package net.forwardfire.vasc.backend.data;
import java.io.Serializable; import java.io.Serializable;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map;
import net.forwardfire.vasc.backend.VascBackendException; import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascEntryFieldValue; import net.forwardfire.vasc.backend.VascBackendAccessDataRecord;
/** /**
* MapVascEntryFieldValue provides get/set support on Map record object. * HashMapVascBackendAccessDataRecord provides get/set support on Map record object.
* *
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Dec 05, 2009 * @version 1.0 Dec 05, 2009
*/ */
public class HashMapVascEntryFieldValue implements VascEntryFieldValue<HashMap<String,Serializable>> { @SuppressWarnings("serial")
public class HashMapVascBackendAccessDataRecord implements VascBackendAccessDataRecord<HashMap<String,Serializable>,HashMap<String,Serializable>> {
private static final long serialVersionUID = 1L; private final Map<String,Class<?>> keyMapType;
public HashMapVascBackendAccessDataRecord(Map<String,Class<?>> keyMapType) {
this.keyMapType = keyMapType;
}
/** /**
* @see net.forwardfire.vasc.core.entry.VascEntryFieldValue#getValue(java.lang.String, java.lang.Object) * @see net.forwardfire.vasc.backend.VascBackendAccessDataRecord#getPrimaryKey(java.io.Serializable)
*/
@Override
public HashMap<String, Serializable> getPrimaryKey(HashMap<String, Serializable> record) throws VascBackendException {
HashMap<String, Serializable> result = new HashMap<String, Serializable>(keyMapType.size());
for (String key:keyMapType.keySet()) {
result.put(key, record.get(key));
}
return result;
}
/**
* @see net.forwardfire.vasc.core.entry.VascBackendAccessDataRecord#getValue(java.lang.String, java.lang.Object)
*/ */
@Override @Override
public Serializable getValue(String backendName,HashMap<String,Serializable> map) throws VascBackendException { public Serializable getValue(String backendName,HashMap<String,Serializable> map) throws VascBackendException {
@ -54,19 +72,7 @@ public class HashMapVascEntryFieldValue implements VascEntryFieldValue<HashMap<S
} }
/** /**
* @see net.forwardfire.vasc.core.entry.VascEntryFieldValue#getDisplayValue(net.forwardfire.vasc.core.VascEntryField, java.lang.Object) * @see net.forwardfire.vasc.core.entry.VascBackendAccessDataRecord#setValue(java.lang.String, java.lang.Object, java.lang.Object)
*/
@Override
public String getDisplayValue(String field, HashMap<String,Serializable> record) throws VascBackendException {
Serializable fieldValue = getValue(field,record);
if (fieldValue==null) {
fieldValue = "";
}
return fieldValue.toString();
}
/**
* @see net.forwardfire.vasc.core.entry.VascEntryFieldValue#setValue(java.lang.String, java.lang.Object, java.lang.Object)
*/ */
@Override @Override
public void setValue(String backendName, HashMap<String,Serializable> map,Serializable value) throws VascBackendException { public void setValue(String backendName, HashMap<String,Serializable> map,Serializable value) throws VascBackendException {

View file

@ -20,20 +20,23 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package net.forwardfire.vasc.backend; package net.forwardfire.vasc.backend.list;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
/** /**
* Holds the state for the backend
* *
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 May 26, 2009 * @version 1.0 May 26, 2009
*/ */
abstract public class AbstractVascBackendState implements VascBackendState { @SuppressWarnings("serial")
public class DefaultVascBackendListRequest implements VascBackendListRequest {
private static final long serialVersionUID = 1L;
protected Map<String,Object> parameters = null; protected Map<String,Object> parameters = null;
private int pageIndex = 0; private int pageIndex = 0;
private int pageSize = 0; private int pageSize = 0;
@ -41,38 +44,25 @@ abstract public class AbstractVascBackendState implements VascBackendState {
private String sortField = null; private String sortField = null;
private String searchString = null; private String searchString = null;
private boolean ascending = true; private boolean ascending = true;
//private long pagesTotalRecords = 0;
public AbstractVascBackendState() { public DefaultVascBackendListRequest() {
parameters = new HashMap<String,Object>(10); parameters = new HashMap<String,Object>(10);
} }
/**
* @see net.forwardfire.vasc.backend.VascBackendState#setDataParameter(java.lang.String, java.lang.Object)
*/
@Override
public void setDataParameter(String key, Object data) { public void setDataParameter(String key, Object data) {
parameters.put(key,data); parameters.put(key,data);
} }
/**
* @see net.forwardfire.vasc.backend.VascBackendState#removeDataParameter(java.lang.String)
*/
@Override
public void removeDataParameter(String key) { public void removeDataParameter(String key) {
parameters.remove(key); parameters.remove(key);
} }
/**
* @see net.forwardfire.vasc.backend.VascBackendState#removeDataParameterAll()
*/
@Override
public void removeDataParameterAll() { public void removeDataParameterAll() {
parameters.clear(); parameters.clear();
} }
/** /**
* @see net.forwardfire.vasc.backend.VascBackendState#getDataParameter(java.lang.String) * @see net.forwardfire.vasc.backend.list.VascBackendListRequest#getDataParameter(java.lang.String)
*/ */
@Override @Override
public Object getDataParameter(String key) { public Object getDataParameter(String key) {
@ -80,7 +70,7 @@ abstract public class AbstractVascBackendState implements VascBackendState {
} }
/** /**
* @see net.forwardfire.vasc.backend.VascBackendState#getDataParameterKeys() * @see net.forwardfire.vasc.backend.list.VascBackendListRequest#getDataParameterKeys()
*/ */
@Override @Override
public Set<String> getDataParameterKeys() { public Set<String> getDataParameterKeys() {
@ -88,81 +78,61 @@ abstract public class AbstractVascBackendState implements VascBackendState {
} }
/** /**
* @see net.forwardfire.vasc.backend.VascBackend#getPageIndex() * @see net.forwardfire.vasc.backend.crud.VascBackendCrud#getPageIndex()
*/ */
@Override @Override
public int getPageIndex() { public int getPageIndex() {
return pageIndex; return pageIndex;
} }
/**
* @see net.forwardfire.vasc.backend.VascBackend#setPageIndex(int)
*/
@Override
public void setPageIndex(int pageIndex) { public void setPageIndex(int pageIndex) {
this.pageIndex=pageIndex; this.pageIndex=pageIndex;
} }
/** /**
* @see net.forwardfire.vasc.backend.VascBackend#getPageSize() * @see net.forwardfire.vasc.backend.crud.VascBackendCrud#getPageSize()
*/ */
@Override @Override
public int getPageSize() { public int getPageSize() {
return pageSize; return pageSize;
} }
/**
* @see net.forwardfire.vasc.backend.VascBackend#setPageSize(int)
*/
@Override
public void setPageSize(int pageSize) { public void setPageSize(int pageSize) {
this.pageSize=pageSize; this.pageSize=pageSize;
} }
/** /**
* @see net.forwardfire.vasc.backend.VascBackend#getSearchString() * @see net.forwardfire.vasc.backend.crud.VascBackendCrud#getSearchString()
*/ */
@Override @Override
public String getSearchString() { public String getSearchString() {
return searchString; return searchString;
} }
/**
* @see net.forwardfire.vasc.backend.VascBackend#setSearchString(java.lang.String)
*/
@Override
public void setSearchString(String searchString) { public void setSearchString(String searchString) {
this.searchString=searchString; this.searchString=searchString;
} }
/** /**
* @see net.forwardfire.vasc.backend.VascBackend#isSortAscending() * @see net.forwardfire.vasc.backend.crud.VascBackendCrud#isSortAscending()
*/ */
@Override @Override
public boolean isSortAscending() { public boolean isSortAscending() {
return ascending; return ascending;
} }
/**
* @see net.forwardfire.vasc.backend.VascBackend#setSortAscending(boolean)
*/
@Override
public void setSortAscending(boolean ascending) { public void setSortAscending(boolean ascending) {
this.ascending=ascending; this.ascending=ascending;
} }
/** /**
* @see net.forwardfire.vasc.backend.VascBackend#getSortField() * @see net.forwardfire.vasc.backend.crud.VascBackendCrud#getSortField()
*/ */
@Override @Override
public String getSortField() { public String getSortField() {
return sortField; return sortField;
} }
/**
* @see net.forwardfire.vasc.backend.VascBackend#setSortField(java.lang.String)
*/
@Override
public void setSortField(String sortField) { public void setSortField(String sortField) {
this.sortField=sortField; this.sortField=sortField;
} }
@ -175,10 +145,6 @@ abstract public class AbstractVascBackendState implements VascBackendState {
return pageSizeMax; return pageSizeMax;
} }
/**
* @param pageSizeMax the pageSizeMax to set
*/
@Override
public void setPageSizeMax(int pageSizeMax) { public void setPageSizeMax(int pageSizeMax) {
this.pageSizeMax = pageSizeMax; this.pageSizeMax = pageSizeMax;
} }

View file

@ -20,61 +20,60 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package net.forwardfire.vasc.backend; package net.forwardfire.vasc.backend.list;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
* AbstractVascBackendResult. * DefaultVascBackendResult.
* *
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Aug 23, 2014 * @version 1.0 Aug 23, 2014
*/ */
abstract public class AbstractVascBackendResult<DATA_OBJECT extends Serializable> implements VascBackendResult<DATA_OBJECT> { @SuppressWarnings("serial")
public final class DefaultVascBackendListResult<DATA_OBJECT extends Serializable> implements VascBackendListResult<DATA_OBJECT> {
private final List<DATA_OBJECT> pageData; private final List<DATA_OBJECT> data;
private final long totalSize; private final long totalRecordCount;
private final Map<String, Serializable> pageSummary; private final Map<String,Map<String,Serializable>> dataExtra;
private final Map<String, Serializable> totalSummary;
public AbstractVascBackendResult(List<DATA_OBJECT> pageData,long totalSize,Map<String, Serializable> pageSummary,Map<String, Serializable> totalSummary) { public DefaultVascBackendListResult(List<DATA_OBJECT> data) {
this.pageData = pageData; this(data,data.size());
this.totalSize = totalSize; }
this.pageSummary = pageSummary;
this.totalSummary = totalSummary; public DefaultVascBackendListResult(List<DATA_OBJECT> data,long totalRecordCount) {
this(data,totalRecordCount,null);
}
public DefaultVascBackendListResult(List<DATA_OBJECT> data,long totalRecordCount,Map<String,Map<String,Serializable>> dataExtra) {
this.data = data;
this.totalRecordCount = totalRecordCount;
this.dataExtra = dataExtra;
} }
/** /**
* @see net.forwardfire.vasc.backend.VascBackendResult#getPageData() * @see net.forwardfire.vasc.backend.list.VascBackendListResult#getData()
*/ */
@Override @Override
public List<DATA_OBJECT> getPageData() { public List<DATA_OBJECT> getData() {
return pageData; return data;
} }
/** /**
* @see net.forwardfire.vasc.backend.VascBackendResult#getTotalSize() * @see net.forwardfire.vasc.backend.list.VascBackendListResult#getTotalRecordCount()
*/ */
@Override @Override
public long getTotalSize() { public long getTotalRecordCount() {
return totalSize; return totalRecordCount;
} }
/** /**
* @see net.forwardfire.vasc.backend.VascBackendResult#getPageSummary() * @see net.forwardfire.vasc.backend.list.VascBackendListResult#getDataExtra()
*/ */
@Override @Override
public Map<String, Serializable> getPageSummary() { public Map<String,Map<String,Serializable>> getDataExtra() {
return pageSummary; return dataExtra;
}
/**
* @see net.forwardfire.vasc.backend.VascBackendResult#getTotalSummary()
*/
@Override
public Map<String, Serializable> getTotalSummary() {
return totalSummary;
} }
} }

View file

@ -0,0 +1,71 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.backend.list;
import java.io.Serializable;
import java.util.EnumSet;
import java.util.List;
import net.forwardfire.vasc.backend.AbstractVascBackendRecord;
import net.forwardfire.vasc.backend.VascBackendException;
/**
* VascBackendList provides stateless data access to a data source which result one or multiple results.
*
* @author Willem Cazander
* @version 1.0 Aug 25, 2014
*/
public interface VascBackendList<DATA_PK extends Serializable,DATA_RECORD extends Serializable> extends AbstractVascBackendRecord<DATA_PK,DATA_RECORD> {
final static String ROW_ACTION_MOVE_UP = "rowActionMoveUp";
final static String ROW_ACTION_MOVE_DOWN = "rowActionMoveDown";
final static String ROW_ACTION_DELETE = "rowActionDelete";
/**
* Defines the features this list backend supports.
* @return An enum set of feature flags.
*/
EnumSet<VascBackendListFeature> getSupportedFeatures();
/**
* Executes the list request with parameters to return a list result.
* @param request
* @return
* @throws VascBackendException
*/
VascBackendListResult<DATA_RECORD> execute(VascBackendListRequest request) throws VascBackendException;
/**
* @return Returns the action names of the row actions we support.
*/
List<String> getSupportedRowActions();
/**
* Executes a single row action on one or more rows of fresh data.
* @param request
* @param recordPKs
* @param actionName
* @throws VascBackendException
*/
void executeRowAction(VascBackendListRequest request,List<DATA_PK> recordPKs,String actionName) throws VascBackendException;
}

View file

@ -20,16 +20,28 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package net.forwardfire.vasc.backend; package net.forwardfire.vasc.backend.list;
/** /**
* Holds the state for the backend * VascBackendListFeatures.
* *
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 May 26, 2009 * @version 1.0 Aug 26, 2014
*/ */
public class DefaultVascBackendState extends AbstractVascBackendState { public enum VascBackendListFeature {
private static final long serialVersionUID = 8828343641448595993L; /** Defines if the backend supports sorting. */
SORT_DATA,
SORT_DATA_PROXY,
/** Defines if the backend supports paging. */
PAGE_DATA,
PAGE_DATA_PROXY,
/** Defines if the backend support full text search. */
TEXT_SEARCH,
TEXT_SEARCH_PROXY,
DATA_EXTRA,
DATA_EXTRA_PROXY;
} }

View file

@ -20,7 +20,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package net.forwardfire.vasc.backend; package net.forwardfire.vasc.backend.list;
import java.io.Serializable; import java.io.Serializable;
import java.util.Set; import java.util.Set;
@ -31,28 +31,20 @@ import java.util.Set;
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 May 26, 2009 * @version 1.0 May 26, 2009
*/ */
public interface VascBackendState extends Serializable { public interface VascBackendListRequest extends Serializable {
void setDataParameter(String key,Object data);
void removeDataParameter(String key);
void removeDataParameterAll();
Object getDataParameter(String key); Object getDataParameter(String key);
Set<String> getDataParameterKeys(); Set<String> getDataParameterKeys();
String getSortField(); String getSortField();
void setSortField(String name);
boolean isSortAscending();
void setSortAscending(boolean ascending);
void setPageSize(int size); boolean isSortAscending();
int getPageSize(); int getPageSize();
void setPageSizeMax(int size);
int getPageSizeMax(); int getPageSizeMax();
void setPageIndex(int index);
int getPageIndex(); int getPageIndex();
void setSearchString(String searchString);
String getSearchString(); String getSearchString();
} }

View file

@ -20,7 +20,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package net.forwardfire.vasc.backend; package net.forwardfire.vasc.backend.list;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
@ -32,10 +32,9 @@ import java.util.Map;
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Aug 23, 2014 * @version 1.0 Aug 23, 2014
*/ */
public interface VascBackendResult<DATA_OBJECT extends Serializable> { public interface VascBackendListResult<DATA_OBJECT extends Serializable> extends Serializable {
List<DATA_OBJECT> getPageData(); List<DATA_OBJECT> getData();
long getTotalSize(); long getTotalRecordCount();
Map<String,Serializable> getPageSummary(); Map<String,Map<String,Serializable>> getDataExtra();
Map<String,Serializable> getTotalSummary();
} }

View file

@ -0,0 +1,8 @@
/**
*
*/
/**
* @author willemc
*
*/
package net.forwardfire.vasc.backend.list;

View file

@ -0,0 +1,62 @@
package net.forwardfire.vasc.backend.select;
import java.io.Serializable;
public class DefaultVascBackendSelectItem<DATA_PK extends Serializable> implements VascBackendSelectItem<DATA_PK> {
private final boolean header;
private final boolean enabled;
private final String name;
private final boolean nameI18nKey;
private final String description;
private final boolean descriptionI18nKey;
private final DATA_PK primaryKey;
public DefaultVascBackendSelectItem(boolean header, boolean enabled,
String name, boolean nameI18nKey, String description,
boolean descriptionI18nKey, DATA_PK primaryKey) {
super();
this.header = header;
this.enabled = enabled;
this.name = name;
this.nameI18nKey = nameI18nKey;
this.description = description;
this.descriptionI18nKey = descriptionI18nKey;
this.primaryKey = primaryKey;
}
@Override
public boolean isHeader() {
return header;
}
@Override
public boolean isEnabled() {
return enabled;
}
@Override
public String getName() {
return name;
}
@Override
public boolean isNameI18nKey() {
return nameI18nKey;
}
@Override
public String getDescription() {
return description;
}
@Override
public boolean isDescriptionI18nKey() {
return descriptionI18nKey;
}
@Override
public DATA_PK getPrimaryKey() {
return primaryKey;
}
}

View file

@ -0,0 +1,12 @@
package net.forwardfire.vasc.backend.select;
import java.io.Serializable;
import java.util.List;
import net.forwardfire.vasc.backend.VascBackend;
import net.forwardfire.vasc.backend.VascBackendException;
public interface VascBackendSelect<DATA_PK extends Serializable> extends VascBackend<DATA_PK> {
List<VascBackendSelectItem<DATA_PK>> execute() throws VascBackendException;
}

View file

@ -20,17 +20,22 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package net.forwardfire.vasc.backend; package net.forwardfire.vasc.backend.select;
import java.io.Serializable; import java.io.Serializable;
/** /**
* *
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Mar 21, 2007 * @version 1.0 Aug 12, 2007
*/ */
public interface VascEntryRecordCreator<DATA_OBJECT extends Serializable> extends Serializable { public interface VascBackendSelectItem<DATA_PK extends Serializable> {
DATA_OBJECT newRecord() throws VascBackendException; boolean isHeader();
boolean isEnabled();
String getName();
boolean isNameI18nKey();
String getDescription();
boolean isDescriptionI18nKey();
DATA_PK getPrimaryKey();
} }

View file

@ -0,0 +1,8 @@
/**
*
*/
/**
* @author willemc
*
*/
package net.forwardfire.vasc.backend.select;

View file

@ -0,0 +1,87 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.backend.jdbc;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import net.forwardfire.vasc.backend.AbstractVascBackendLocal;
import net.forwardfire.vasc.backend.VascBackendAccessDataKey;
import net.forwardfire.vasc.backend.data.HashMapVascBackendAccessDataKey;
/**
* AbstractJdbcVascBackend.
*
* @author Willem Cazander
* @version 1.0 Sep 5, 2008
*/
abstract public class AbstractJdbcVascBackend extends AbstractVascBackendLocal<HashMap<String,Serializable>> {
private JdbcConnectionProvider jdbcConnectionProvider = null;
private final Map<String,Class<?>> keyMapType = new HashMap<String,Class<?>>(5);
abstract protected void startBackendJdbc();
/**
* @see net.forwardfire.vasc.backend.AbstractVascBackendLocal#startBackendLocal()
*/
@Override
protected final void startBackendLocal() {
requireNonNull(getJdbcConnectionProvider(), "jdbcConnectionProvider is null.");
requireNonEmpty(keyMapType.keySet(), "No primary keys defined.");
startBackendJdbc();
}
protected final void addKeyMapType(String field,Class<?> fieldType) {
requireNonEmpty(field,"field has to have value");
requireNonNull(fieldType,"field has to have value");
keyMapType.put(field, fieldType);
}
protected final Map<String,Class<?>> getKeyMapType() {
return keyMapType;
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#createVascBackendAccessDataKey()
*/
@Override
public final VascBackendAccessDataKey<HashMap<String, Serializable>> createVascBackendAccessDataKey() {
return new HashMapVascBackendAccessDataKey(keyMapType);
}
/**
* @return the JdbcConnectionProvider
*/
public final JdbcConnectionProvider getJdbcConnectionProvider() {
return jdbcConnectionProvider;
}
/**
* @param JdbcConnectionProvider the JdbcConnectionProvider to set
*/
public final void setJdbcConnectionProvider(JdbcConnectionProvider jdbcConnectionProvider) {
this.jdbcConnectionProvider = jdbcConnectionProvider;
}
}

View file

@ -1,169 +0,0 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
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 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;
import net.forwardfire.vasc.backend.data.HashMapVascEntryFieldValue;
import net.forwardfire.vasc.backend.data.HashMapVascEntryRecordCreator;
/**
* JdbcVascBackend Simple jdbc vasc backend.
*
* @author Willem Cazander
* @version 1.0 Sep 5, 2008
*/
public class JdbcVascBackend extends AbstractVascBackend<HashMap<String,Object>> {
private JdbcConnectionProvider jdbcConnectionProvider = null;
private String sqlList = null;
//private String idColumn = null;
//private String sqlDelete = null;
//private String sqlUpdate = null;
//private String sqlInsert = null;
/**
* @see net.forwardfire.vasc.backend.AbstractVascBackend#isReadOnly()
*/
@Override
public boolean isReadOnly() {
return true;
}
/**
* @return the JdbcConnectionProvider
*/
public JdbcConnectionProvider getJdbcConnectionProvider() {
return jdbcConnectionProvider;
}
/**
* @param JdbcConnectionProvider the JdbcConnectionProvider to set
*/
public void setJdbcConnectionProvider(JdbcConnectionProvider jdbcConnectionProvider) {
this.jdbcConnectionProvider = jdbcConnectionProvider;
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state)
*/
@Override
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;
try {
connection = prov.getJdbcConnection();
Statement s = connection.createStatement();
s.execute(getSqlList());
ResultSet rs = s.getResultSet();
int cols = rs.getMetaData().getColumnCount();
while (rs.next()) {
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);
map.put(columnName, columnObject);
}
result.add(map);
}
} catch (SQLException e) {
throw new VascBackendException(e);
} finally {
if (connection!=null) {
try {
connection.close();
} catch (Exception e) {
}
}
}
return new DefaultVascBackendResult<HashMap<String,Object>>(result);
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#merge(java.lang.Object)
*/
@Override
public HashMap<String,Object> merge(HashMap<String,Object> object) throws VascBackendException {
return object;
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#persist(java.lang.Object)
*/
@Override
public void persist(HashMap<String,Object> object) throws VascBackendException {
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#delete(java.lang.Object)
*/
@Override
public void delete(HashMap<String,Object> object) throws VascBackendException {
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryFieldValue(net.forwardfire.vasc.core.VascEntryField)
*/
@Override
public VascEntryFieldValue provideVascEntryFieldValue() {
return new HashMapVascEntryFieldValue();
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryRecordCreator(net.forwardfire.vasc.core.VascEntry)
*/
@Override
public VascEntryRecordCreator provideVascEntryRecordCreator() {
return new HashMapVascEntryRecordCreator();
}
/**
* @return the sqlList
*/
public String getSqlList() {
return sqlList;
}
/**
* @param sqlList the sqlList to set
*/
public void setSqlList(String sqlList) {
this.sqlList = sqlList;
}
}

View file

@ -0,0 +1,147 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.backend.jdbc;
import java.io.Serializable;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascBackendAccessDataRecord;
import net.forwardfire.vasc.backend.data.HashMapVascBackendAccessDataRecord;
import net.forwardfire.vasc.backend.list.DefaultVascBackendListResult;
import net.forwardfire.vasc.backend.list.VascBackendList;
import net.forwardfire.vasc.backend.list.VascBackendListFeature;
import net.forwardfire.vasc.backend.list.VascBackendListResult;
import net.forwardfire.vasc.backend.list.VascBackendListRequest;
/**
* JdbcVascBackend Simple jdbc vasc backend.
*
* @author Willem Cazander
* @version 1.0 Sep 5, 2008
*/
public class JdbcVascBackendList extends AbstractJdbcVascBackend implements VascBackendList<HashMap<String,Serializable>,HashMap<String,Serializable>> {
private final EnumSet<VascBackendListFeature> features = EnumSet.noneOf(VascBackendListFeature.class);
private final List<String> rowActions = new ArrayList<String>();
private String query = null;
private String queryExtra = null;
@Override
protected void startBackendJdbc() {
requireNonEmpty(getQuery(), "query is empty.");
if (queryExtra!=null && !queryExtra.isEmpty()) {
features.add(VascBackendListFeature.DATA_EXTRA);
}
}
@Override
public VascBackendAccessDataRecord<HashMap<String, Serializable>, HashMap<String, Serializable>> createVascBackendAccessDataRecord() {
return new HashMapVascBackendAccessDataRecord(getKeyMapType());
}
@Override
public EnumSet<VascBackendListFeature> getSupportedFeatures() {
return features;
}
@Override
public List<String> getSupportedRowActions() {
return rowActions;
}
@Override
public void executeRowAction(VascBackendListRequest request,List<HashMap<String, Serializable>> recordPKs, String actionName) throws VascBackendException {
}
/**
* @see net.forwardfire.vasc.backend.crud.VascBackendList#execute(VascBackendListRequest state)
*/
@Override
public VascBackendListResult<HashMap<String,Serializable>> execute(VascBackendListRequest state) throws VascBackendException {
JdbcConnectionProvider prov = getJdbcConnectionProvider();
List<HashMap<String,Serializable>> result = new ArrayList<HashMap<String,Serializable>>(50);
Connection connection = null;
try {
connection = prov.getJdbcConnection();
Statement s = connection.createStatement();
s.execute(getQuery());
ResultSet rs = s.getResultSet();
int cols = rs.getMetaData().getColumnCount();
while (rs.next()) {
HashMap<String,Serializable> map = new HashMap<String,Serializable>(cols);
for (int i=1;i<=cols;i++) {
String columnName = rs.getMetaData().getColumnName(i);
Serializable columnObject = (Serializable) rs.getObject(i);
map.put(columnName, columnObject);
}
result.add(map);
}
} catch (SQLException e) {
throw new VascBackendException(e);
} finally {
if (connection!=null) {
try {
connection.close();
} catch (Exception e) {
}
}
}
return new DefaultVascBackendListResult<HashMap<String,Serializable>>(result);
}
/**
* @return the query
*/
public String getQuery() {
return query;
}
/**
* @param query the query to set
*/
public void setQuery(String query) {
this.query = query;
}
/**
* @return the queryExtra
*/
public String getQueryExtra() {
return queryExtra;
}
/**
* @param queryExtra the queryExtra to set
*/
public void setQueryExtra(String queryExtra) {
this.queryExtra = queryExtra;
}
}

View file

@ -0,0 +1,111 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.backend.jdbc;
import java.io.Serializable;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascBackendAccessDataRecord;
import net.forwardfire.vasc.backend.data.HashMapVascBackendAccessDataRecord;
import net.forwardfire.vasc.backend.list.DefaultVascBackendListResult;
import net.forwardfire.vasc.backend.list.VascBackendList;
import net.forwardfire.vasc.backend.list.VascBackendListFeature;
import net.forwardfire.vasc.backend.list.VascBackendListResult;
import net.forwardfire.vasc.backend.list.VascBackendListRequest;
import net.forwardfire.vasc.backend.select.VascBackendSelect;
import net.forwardfire.vasc.backend.select.VascBackendSelectItem;
/**
* JdbcVascBackend Simple jdbc vasc backend.
*
* @author Willem Cazander
* @version 1.0 Sep 5, 2008
*/
public class JdbcVascBackendSelect extends AbstractJdbcVascBackend implements VascBackendSelect<HashMap<String,Serializable>> {
private String query = null;
@Override
protected void startBackendJdbc() {
requireNonEmpty(getQuery(), "query is empty.");
}
@Override
public List<VascBackendSelectItem<HashMap<String, Serializable>>> execute() throws VascBackendException {
return null;
}
public VascBackendListResult<HashMap<String,Serializable>> execute(VascBackendListRequest state) throws VascBackendException {
JdbcConnectionProvider prov = getJdbcConnectionProvider();
List<HashMap<String,Serializable>> result = new ArrayList<HashMap<String,Serializable>>(50);
Connection connection = null;
try {
connection = prov.getJdbcConnection();
Statement s = connection.createStatement();
s.execute(getQuery());
ResultSet rs = s.getResultSet();
int cols = rs.getMetaData().getColumnCount();
while (rs.next()) {
HashMap<String,Serializable> map = new HashMap<String,Serializable>(cols);
for (int i=1;i<=cols;i++) {
String columnName = rs.getMetaData().getColumnName(i);
Serializable columnObject = (Serializable) rs.getObject(i);
map.put(columnName, columnObject);
}
result.add(map);
}
} catch (SQLException e) {
throw new VascBackendException(e);
} finally {
if (connection!=null) {
try {
connection.close();
} catch (Exception e) {
}
}
}
return new DefaultVascBackendListResult<HashMap<String,Serializable>>(result);
}
/**
* @return the query
*/
public String getQuery() {
return query;
}
/**
* @param query the query to set
*/
public void setQuery(String query) {
this.query = query;
}
}

View file

@ -20,25 +20,26 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package net.forwardfire.vasc.backend.jdbc; package net.forwardfire.vasc.backend.jdbc.xpql;
import java.io.Serializable;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; 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.VascBackendException;
import net.forwardfire.vasc.backend.VascBackendResult; import net.forwardfire.vasc.backend.VascBackendAccessDataRecord;
import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.jdbc.AbstractJdbcVascBackend;
import net.forwardfire.vasc.backend.VascEntryFieldValue; import net.forwardfire.vasc.backend.list.DefaultVascBackendListResult;
import net.forwardfire.vasc.backend.VascEntryRecordCreator; import net.forwardfire.vasc.backend.list.VascBackendList;
import net.forwardfire.vasc.backend.data.HashMapVascEntryFieldValue; import net.forwardfire.vasc.backend.list.VascBackendListFeature;
import net.forwardfire.vasc.backend.data.HashMapVascEntryRecordCreator; import net.forwardfire.vasc.backend.list.VascBackendListResult;
import net.forwardfire.vasc.backend.list.VascBackendListRequest;
import net.forwardfire.vasc.xpql.query.QueryParameterValue; import net.forwardfire.vasc.xpql.query.QueryParameterValue;
/** /**
@ -47,53 +48,46 @@ import net.forwardfire.vasc.xpql.query.QueryParameterValue;
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Sep 5, 2008 * @version 1.0 Sep 5, 2008
*/ */
public class JdbcVascBackendXpql extends AbstractVascBackend<HashMap<String,Object>> { public class JdbcVascBackendXpqlList extends AbstractJdbcVascBackend implements VascBackendList<HashMap<String,Serializable>,HashMap<String,Serializable>> {
private JdbcConnectionProvider jdbcConnectionProvider = null;
private final EnumSet<VascBackendListFeature> features = EnumSet.noneOf(VascBackendListFeature.class);
private final List<String> rowActions = new ArrayList<String>();
private net.forwardfire.vasc.xpql.query.Query query = null; private net.forwardfire.vasc.xpql.query.Query query = null;
private net.forwardfire.vasc.xpql.query.Query queryExtra = null;
@Override
protected void startBackendJdbc() {
requireNonNull(getQuery(), "query is null.");
if (queryExtra!=null) {
features.add(VascBackendListFeature.DATA_EXTRA);
}
}
@Override
public VascBackendAccessDataRecord<HashMap<String, Serializable>, HashMap<String, Serializable>> createVascBackendAccessDataRecord() {
// TODO Auto-generated method stub
return null;
}
@Override
public EnumSet<VascBackendListFeature> getSupportedFeatures() {
return features;
}
@Override
public List<String> getSupportedRowActions() {
return rowActions;
}
@Override
public void executeRowAction(VascBackendListRequest request,List<HashMap<String, Serializable>> recordPKs, String actionName) throws VascBackendException {
}
/** /**
* @see net.forwardfire.vasc.backend.AbstractVascBackend#isReadOnly() * @see net.forwardfire.vasc.backend.crud.VascBackendCrud#execute(VascBackendListRequest state)
*/ */
@Override @Override
public boolean isReadOnly() { public VascBackendListResult<HashMap<String,Serializable>> execute(VascBackendListRequest state) throws VascBackendException {
return true;
}
/**
* @return the JdbcConnectionProvider
*/
public JdbcConnectionProvider getJdbcConnectionProvider() {
return jdbcConnectionProvider;
}
/**
* @param JdbcConnectionProvider the JdbcConnectionProvider to set
*/
public void setJdbcConnectionProvider(JdbcConnectionProvider jdbcConnectionProvider) {
this.jdbcConnectionProvider = jdbcConnectionProvider;
}
/**
* @return the query
*/
public net.forwardfire.vasc.xpql.query.Query getQuery() {
return query;
}
/**
* @param query the query to set
*/
public void setQuery(net.forwardfire.vasc.xpql.query.Query query) {
this.query = query;
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state)
*/
@Override
public VascBackendResult<HashMap<String,Object>> execute(VascBackendState state) throws VascBackendException {
// Copy parameters // Copy parameters
for (String key:state.getDataParameterKeys()) { for (String key:state.getDataParameterKeys()) {
Object value = state.getDataParameter(key); Object value = state.getDataParameter(key);
@ -113,17 +107,17 @@ public class JdbcVascBackendXpql extends AbstractVascBackend<HashMap<String,Obje
q.execute(); q.execute();
ResultSet rs = q.getResultSet(); ResultSet rs = q.getResultSet();
int cols = rs.getMetaData().getColumnCount(); int cols = rs.getMetaData().getColumnCount();
List<HashMap<String,Object>> result = new ArrayList<HashMap<String,Object>>(50); List<HashMap<String,Serializable>> result = new ArrayList<HashMap<String,Serializable>>(50);
while (rs.next()) { while (rs.next()) {
HashMap<String,Object> map = new HashMap<String,Object>(cols); HashMap<String,Serializable> map = new HashMap<String,Serializable>(cols);
for (int i=1;i<=cols;i++) { for (int i=1;i<=cols;i++) {
String columnName = rs.getMetaData().getColumnName(i); String columnName = rs.getMetaData().getColumnName(i);
Object columnObject = rs.getObject(i); Serializable columnObject = (Serializable) rs.getObject(i);
map.put(columnName, columnObject); map.put(columnName, columnObject);
} }
result.add(map); result.add(map);
} }
return new DefaultVascBackendResult<HashMap<String,Object>>(result); return new DefaultVascBackendListResult<HashMap<String,Serializable>>(result);
} catch (SQLException e) { } catch (SQLException e) {
throw new VascBackendException(e); throw new VascBackendException(e);
} finally { } finally {
@ -137,40 +131,16 @@ public class JdbcVascBackendXpql extends AbstractVascBackend<HashMap<String,Obje
} }
/** /**
* @see net.forwardfire.vasc.backend.VascBackend#merge(java.lang.Object) * @return the query
*/ */
@Override public net.forwardfire.vasc.xpql.query.Query getQuery() {
public HashMap<String,Object> merge(HashMap<String,Object> object) throws VascBackendException { return query;
return object;
} }
/** /**
* @see net.forwardfire.vasc.backend.VascBackend#persist(java.lang.Object) * @param query the query to set
*/ */
@Override public void setQuery(net.forwardfire.vasc.xpql.query.Query query) {
public void persist(HashMap<String,Object> object) throws VascBackendException { this.query = query;
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#delete(java.lang.Object)
*/
@Override
public void delete(HashMap<String,Object> object) throws VascBackendException {
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryFieldValue()
*/
@Override
public VascEntryFieldValue provideVascEntryFieldValue() {
return new HashMapVascEntryFieldValue();
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryRecordCreator()
*/
@Override
public VascEntryRecordCreator provideVascEntryRecordCreator() {
return new HashMapVascEntryRecordCreator();
} }
} }

View file

@ -0,0 +1,8 @@
/**
*
*/
/**
* @author willemc
*
*/
package net.forwardfire.vasc.backend.jdbc.xpql;

View file

@ -1,29 +1,30 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<modelVersion>4.0.0</modelVersion> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent> <modelVersion>4.0.0</modelVersion>
<artifactId>vasc-backend</artifactId> <parent>
<groupId>net.forwardfire.vasc.backend</groupId> <artifactId>vasc-backend</artifactId>
<version>0.4.2-SNAPSHOT</version> <groupId>net.forwardfire.vasc.backend</groupId>
</parent> <version>0.4.2-SNAPSHOT</version>
<artifactId>vasc-backend-jpa</artifactId> </parent>
<name>vasc-backend-jpa</name> <artifactId>vasc-backend-jpa</artifactId>
<description>vasc-backend-jpa</description> <name>vasc-backend-jpa</name>
<dependencies> <description>vasc-backend-jpa</description>
<dependency> <dependencies>
<groupId>net.forwardfire.vasc.backend</groupId> <dependency>
<artifactId>vasc-backend-api</artifactId> <groupId>net.forwardfire.vasc.backend</groupId>
<version>${project.version}</version> <artifactId>vasc-backend-api</artifactId>
</dependency> <version>${project.version}</version>
<dependency> </dependency>
<groupId>net.forwardfire.vasc.lib</groupId> <dependency>
<artifactId>vasc-lib-xpql</artifactId> <groupId>net.forwardfire.vasc.lib</groupId>
<version>${project.version}</version> <artifactId>vasc-lib-xpql</artifactId>
</dependency> <version>${project.version}</version>
<dependency> </dependency>
<groupId>javax.persistence</groupId> <dependency>
<artifactId>persistence-api</artifactId> <groupId>javax</groupId>
<version>${persistence-api.version}</version> <artifactId>javaee-api</artifactId>
<scope>provided</scope> <version>${javaee-api.version}</version>
</dependency> <scope>provided</scope>
</dependencies> </dependency>
</dependencies>
</project> </project>

View file

@ -26,73 +26,54 @@ import java.io.Serializable;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import net.forwardfire.vasc.backend.AbstractVascBackend; import net.forwardfire.vasc.backend.AbstractVascBackendLocal;
import net.forwardfire.vasc.backend.VascBackendException;
/** /**
* AbstractPersistenceVascBackend.
* *
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Mar 21, 2007 * @version 1.0 Aug 25, 2014
*/ */
abstract public class AbstractPersistenceVascBackend<DATA_OBJECT extends Serializable> extends AbstractVascBackend<DATA_OBJECT> { abstract public class AbstractPersistenceVascBackend<DATA_PK extends Serializable> extends AbstractVascBackendLocal<DATA_PK> {
protected boolean emTransaction = true; private Boolean emTransaction;
abstract EntityManager getEntityManager(); private EntityManagerProvider entityManagerProvider = null;
abstract protected void startBackendPersistence();
/**
* @see net.forwardfire.vasc.backend.AbstractVascBackendLocal#startBackendLocal()
*/
@Override @Override
public void persist(DATA_OBJECT object) throws VascBackendException { protected final void startBackendLocal() {
EntityManager s = getEntityManager(); requireNonNull(getEntityManagerProvider(), "entityManagerProvider is null.");
try { //requireNonEmpty(keyMapType.keySet(), "No primary keys defined.");
if (emTransaction) { startBackendPersistence();
s.getTransaction().begin();
}
s.persist(object);
if (emTransaction) {
s.getTransaction().commit();
}
} finally {
if (s!=null) {
//s.close();
}
}
} }
@Override protected final EntityManager getEntityManager() {
public DATA_OBJECT merge(DATA_OBJECT object) throws VascBackendException { if (emTransaction == null) {
EntityManager s = getEntityManager(); emTransaction=entityManagerProvider.hasEntityManagerTransaction();
try {
if (emTransaction) {
s.getTransaction().begin();
}
DATA_OBJECT result = (DATA_OBJECT)s.merge(object);
if (emTransaction) {
s.getTransaction().commit();
}
return result;
} finally {
if (s!=null) {
//s.close();
}
} }
return entityManagerProvider.getEntityManager();
} }
@Override protected final boolean hasTransaction() {
public void delete(DATA_OBJECT object) throws VascBackendException { return emTransaction;
EntityManager s = getEntityManager(); }
try {
if (emTransaction) { /**
s.getTransaction().begin(); * @return the entityManagerProvider
} */
Object newObject = s.merge(object); public final EntityManagerProvider getEntityManagerProvider() {
s.remove(newObject); return entityManagerProvider;
if (emTransaction) { }
s.getTransaction().commit();
} /**
} finally { * @param entityManagerProvider the entityManagerProvider to set
if (s!=null) { */
//s.close(); public final void setEntityManagerProvider(EntityManagerProvider entityManagerProvider) {
} this.entityManagerProvider = entityManagerProvider;
}
} }
} }

View file

@ -0,0 +1,161 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.backends.jpa;
import java.io.Serializable;
import javax.persistence.EntityManager;
import net.forwardfire.vasc.backend.VascBackendAccessDataKey;
import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascBackendAccessDataRecord;
import net.forwardfire.vasc.backend.crud.VascBackendCrud;
/**
* Manages persistance with xpql queries
*
* @author Willem Cazander
* @version 1.0 Mar 17, 2009
*/
public class PersistanceVascBackendCrud<DATA_PK extends Serializable,DATA_RECORD extends Serializable> extends AbstractPersistenceVascBackend<DATA_PK> implements VascBackendCrud<DATA_PK,DATA_RECORD> {
private Class<DATA_RECORD> recordClass = null;
public PersistanceVascBackendCrud() {
}
public PersistanceVascBackendCrud(Class<DATA_RECORD> recordClass) {
setRecordClass(recordClass);
}
@Override
protected void startBackendPersistence() {
requireNonNull(getRecordClass(), "recordClass is null");
}
@Override
public VascBackendAccessDataRecord<DATA_PK, DATA_RECORD> createVascBackendAccessDataRecord() {
// TODO Auto-generated method stub
return null;
}
@Override
public VascBackendAccessDataKey<DATA_PK> createVascBackendAccessDataKey() {
// TODO Auto-generated method stub
return null;
}
@Override
public DATA_RECORD newRecord() throws VascBackendException {
try {
return getRecordClass().newInstance();
} catch (InstantiationException | IllegalAccessException e) {
throw new VascBackendException(e);
}
}
@Override
public DATA_RECORD fetch(DATA_PK recordPK) throws VascBackendException {
EntityManager s = getEntityManager();
try {
if (hasTransaction()) {
s.getTransaction().begin();
}
DATA_RECORD record = s.find(getRecordClass(), recordPK);
if (hasTransaction()) {
s.getTransaction().commit();
}
return record;
} finally {
if (s!=null) {
//s.close();
}
}
}
@Override
public DATA_RECORD persist(DATA_RECORD record) throws VascBackendException {
EntityManager s = getEntityManager();
try {
if (hasTransaction()) {
s.getTransaction().begin();
}
s.persist(record);
if (hasTransaction()) {
s.getTransaction().commit();
}
return record;
} finally {
if (s!=null) {
//s.close();
}
}
}
@Override
public DATA_RECORD merge(DATA_RECORD record) throws VascBackendException {
EntityManager s = getEntityManager();
try {
if (hasTransaction()) {
s.getTransaction().begin();
}
DATA_RECORD result = (DATA_RECORD)s.merge(record);
if (hasTransaction()) {
s.getTransaction().commit();
}
return result;
} finally {
if (s!=null) {
//s.close();
}
}
}
@Override
public void delete(DATA_PK recordPK) throws VascBackendException {
EntityManager s = getEntityManager();
try {
if (hasTransaction()) {
s.getTransaction().begin();
}
Object newObject = s.find(Object.class,recordPK);
s.remove(newObject);
if (hasTransaction()) {
s.getTransaction().commit();
}
} finally {
if (s!=null) {
//s.close();
}
}
}
public Class<DATA_RECORD> getRecordClass() {
return recordClass;
}
public void setRecordClass(Class<DATA_RECORD> recordClass) {
this.recordClass = recordClass;
}
}

View file

@ -23,32 +23,30 @@
package net.forwardfire.vasc.backends.jpa; package net.forwardfire.vasc.backends.jpa;
import java.io.Serializable; import java.io.Serializable;
import java.util.EnumSet;
import java.util.List; import java.util.List;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.persistence.Query; import javax.persistence.Query;
import net.forwardfire.vasc.backend.DefaultVascBackendResult; import net.forwardfire.vasc.backend.VascBackendAccessDataKey;
import net.forwardfire.vasc.backend.VascBackendException; import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascBackendResult; import net.forwardfire.vasc.backend.VascBackendAccessDataRecord;
import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.data.BeanVascBackendAccessDataRecord;
import net.forwardfire.vasc.backend.VascEntryFieldValue; import net.forwardfire.vasc.backend.list.DefaultVascBackendListResult;
import net.forwardfire.vasc.backend.VascEntryRecordCreator; import net.forwardfire.vasc.backend.list.VascBackendList;
import net.forwardfire.vasc.backend.data.BeanVascEntryFieldValue; import net.forwardfire.vasc.backend.list.VascBackendListFeature;
import net.forwardfire.vasc.backend.data.BeanVascEntryRecordCreator; import net.forwardfire.vasc.backend.list.VascBackendListResult;
import net.forwardfire.vasc.backend.list.VascBackendListRequest;
import net.forwardfire.vasc.xpql.query.QueryParameterValue; import net.forwardfire.vasc.xpql.query.QueryParameterValue;
/** /**
* Manages persistance with xpql queries * Manages persistance with xpql queries
* *
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Mar 17, 2009 * @version 1.0 Mar 17, 2009
*/ */
public class XpqlPersistanceVascBackend<DATA_OBJECT extends Serializable> extends AbstractPersistenceVascBackend<DATA_OBJECT> { public class PersistanceVascBackendXpqlList<DATA_PK extends Serializable,DATA_RECORD extends Serializable> extends AbstractPersistenceVascBackend<DATA_PK> implements VascBackendList<DATA_PK,DATA_RECORD> {
private EntityManagerProvider entityManagerProvider = null;
private net.forwardfire.vasc.xpql.query.Query query = null; private net.forwardfire.vasc.xpql.query.Query query = null;
@ -62,37 +60,61 @@ public class XpqlPersistanceVascBackend<DATA_OBJECT extends Serializable> extend
private net.forwardfire.vasc.xpql.query.Query queryMoveDownUp = null; private net.forwardfire.vasc.xpql.query.Query queryMoveDownUp = null;
private Class<?> resultClass = null; public PersistanceVascBackendXpqlList() {
public XpqlPersistanceVascBackend() {
}
/**
* @see net.forwardfire.vasc.backends.jpa.AbstractPersistenceVascBackend#getEntityManager()
*/
@Override
EntityManager getEntityManager() {
emTransaction=entityManagerProvider.hasEntityManagerTransaction();
return entityManagerProvider.getEntityManager();
} }
@Override @Override
public VascBackendResult<DATA_OBJECT> execute(VascBackendState state) throws VascBackendException { protected void startBackendPersistence() {
return new DefaultVascBackendResult<DATA_OBJECT>(executeList(state),fetchTotalExecuteSize(state)); // TODO Auto-generated method stub
}
@Override
public VascBackendAccessDataRecord<DATA_PK, DATA_RECORD> createVascBackendAccessDataRecord() {
// TODO Auto-generated method stub
return null;
}
@Override
public VascBackendAccessDataKey<DATA_PK> createVascBackendAccessDataKey() {
// TODO Auto-generated method stub
return null;
}
@Override
public EnumSet<VascBackendListFeature> getSupportedFeatures() {
// TODO Auto-generated method stub
return null;
}
@Override
public List<String> getSupportedRowActions() {
// TODO Auto-generated method stub
return null;
}
@Override
public void executeRowAction(VascBackendListRequest request,List<DATA_PK> recordPKs, String actionName) throws VascBackendException {
// TODO Auto-generated method stub
}
@Override
public VascBackendListResult<DATA_RECORD> execute(VascBackendListRequest state) throws VascBackendException {
return new DefaultVascBackendListResult<DATA_RECORD>(executeList(state),fetchTotalExecuteSize(state));
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private List<DATA_OBJECT> executeList(VascBackendState state) throws VascBackendException { private List<DATA_RECORD> executeList(VascBackendListRequest state) throws VascBackendException {
// Copy parameters // Copy parameters
for (String key:state.getDataParameterKeys()) { for (String key:state.getDataParameterKeys()) {
Object value = state.getDataParameter(key); Object value = state.getDataParameter(key);
//System.out.println("Set para pame: "+key+" value: "+value); query.setQueryParameter(key, value);
query.setQueryParameter(key, value); if (queryTotal!=null) {
if (queryTotal!=null) { queryTotal.setQueryParameter(key, value);
queryTotal.setQueryParameter(key, value); }
} }
}
EntityManager em = getEntityManager(); EntityManager em = getEntityManager();
try { try {
@ -109,11 +131,11 @@ public class XpqlPersistanceVascBackend<DATA_OBJECT extends Serializable> extend
q.setFirstResult(state.getPageIndex()*state.getPageSize()); q.setFirstResult(state.getPageIndex()*state.getPageSize());
q.setMaxResults(state.getPageSize()); q.setMaxResults(state.getPageSize());
} }
if (emTransaction) { if (hasTransaction()) {
em.getTransaction().begin(); em.getTransaction().begin();
} }
List<DATA_OBJECT> data = q.getResultList(); List<DATA_RECORD> data = q.getResultList();
if (emTransaction) { if (hasTransaction()) {
em.getTransaction().commit(); em.getTransaction().commit();
} }
return data; return data;
@ -124,24 +146,6 @@ public class XpqlPersistanceVascBackend<DATA_OBJECT extends Serializable> extend
} }
} }
/**
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryFieldValue()
*/
@Override
public VascEntryFieldValue provideVascEntryFieldValue() {
VascEntryFieldValue result = new BeanVascEntryFieldValue();
return result;
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryRecordCreator()
*/
@Override
public VascEntryRecordCreator provideVascEntryRecordCreator() {
VascEntryRecordCreator result = new BeanVascEntryRecordCreator(resultClass);
return result;
}
/** /**
* @return the query * @return the query
*/ */
@ -171,37 +175,8 @@ public class XpqlPersistanceVascBackend<DATA_OBJECT extends Serializable> extend
} }
/** /**
* @return the resultClass * @see net.forwardfire.vasc.backend.crud.VascBackendList#isPageable()
*/ */
public Class<?> getResultClass() {
return resultClass;
}
/**
* @param resultClass the resultClass to set
*/
public void setResultClass(Class<?> resultClass) {
this.resultClass = resultClass;
}
/**
* @return the entityManagerProvider
*/
public EntityManagerProvider getEntityManagerProvider() {
return entityManagerProvider;
}
/**
* @param entityManagerProvider the entityManagerProvider to set
*/
public void setEntityManagerProvider(EntityManagerProvider entityManagerProvider) {
this.entityManagerProvider = entityManagerProvider;
}
/**
* @see net.forwardfire.vasc.backend.AbstractVascBackend#isPageable()
*/
@Override
public boolean isPageable() { public boolean isPageable() {
if (queryTotal==null) { if (queryTotal==null) {
return false; return false;
@ -209,7 +184,7 @@ public class XpqlPersistanceVascBackend<DATA_OBJECT extends Serializable> extend
return true; return true;
} }
private long fetchTotalExecuteSize(VascBackendState state) { private long fetchTotalExecuteSize(VascBackendListRequest state) {
EntityManager em = getEntityManager(); EntityManager em = getEntityManager();
try { try {
Query q = em.createQuery(queryTotal.toPreparedSQL(queryTotal)); Query q = em.createQuery(queryTotal.toPreparedSQL(queryTotal));
@ -219,11 +194,11 @@ public class XpqlPersistanceVascBackend<DATA_OBJECT extends Serializable> extend
q.setParameter(i,value.getValue()); q.setParameter(i,value.getValue());
i++; i++;
} }
if (emTransaction) { if (hasTransaction()) {
em.getTransaction().begin(); em.getTransaction().begin();
} }
Long resultTotal = (Long)q.getSingleResult(); Long resultTotal = (Long)q.getSingleResult();
if (emTransaction) { if (hasTransaction()) {
em.getTransaction().commit(); em.getTransaction().commit();
} }
return resultTotal; return resultTotal;
@ -234,25 +209,23 @@ public class XpqlPersistanceVascBackend<DATA_OBJECT extends Serializable> extend
} }
} }
/** /**
* @see net.forwardfire.vasc.core.AbstractVascBackend#doRecordMoveDownById(VascBackendState state,java.lang.Object) * @see net.forwardfire.vasc.core.AbstractVascBackend#doRecordMoveDownById(VascBackendState state,java.lang.Object)
*/ */
@Override public long doRecordMoveDownById(Object primaryId) throws VascBackendException {
public long doRecordMoveDownById(VascBackendState state,Object primaryId) throws VascBackendException {
long result = 0l; long result = 0l;
if (queryMoveDown!=null) { if (queryMoveDown!=null) {
EntityManager em = getEntityManager(); EntityManager em = getEntityManager();
try { try {
if (emTransaction) { if (hasTransaction()) {
em.getTransaction().begin(); em.getTransaction().begin();
} }
// Copy parameters // Copy parameters
for (String key:state.getDataParameterKeys()) { // for (String key:state.getDataParameterKeys()) {
Object value = state.getDataParameter(key); // Object value = state.getDataParameter(key);
queryMoveDown.setQueryParameter(key, value); // queryMoveDown.setQueryParameter(key, value);
} // }
// set id // set id
queryMoveDown.setQueryParameter("id", primaryId); queryMoveDown.setQueryParameter("id", primaryId);
@ -268,10 +241,10 @@ public class XpqlPersistanceVascBackend<DATA_OBJECT extends Serializable> extend
result+=q.executeUpdate(); result+=q.executeUpdate();
// Copy parameters // Copy parameters
for (String key:state.getDataParameterKeys()) { // for (String key:state.getDataParameterKeys()) {
Object value = state.getDataParameter(key); // Object value = state.getDataParameter(key);
queryMoveDownUp.setQueryParameter(key, value); // queryMoveDownUp.setQueryParameter(key, value);
} // }
// set id // set id
queryMoveDownUp.setQueryParameter("id", primaryId); queryMoveDownUp.setQueryParameter("id", primaryId);
@ -286,7 +259,7 @@ public class XpqlPersistanceVascBackend<DATA_OBJECT extends Serializable> extend
} }
result+=q.executeUpdate(); result+=q.executeUpdate();
if (emTransaction) { if (hasTransaction()) {
em.getTransaction().commit(); em.getTransaction().commit();
} }
} finally { } finally {
@ -301,21 +274,20 @@ public class XpqlPersistanceVascBackend<DATA_OBJECT extends Serializable> extend
/** /**
* @see net.forwardfire.vasc.core.AbstractVascBackend#doRecordMoveUpById(VascBackendState state,java.lang.Object) * @see net.forwardfire.vasc.core.AbstractVascBackend#doRecordMoveUpById(VascBackendState state,java.lang.Object)
*/ */
@Override public long doRecordMoveUpById(Object primaryId) throws VascBackendException {
public long doRecordMoveUpById(VascBackendState state,Object primaryId) throws VascBackendException {
long result = 0l; long result = 0l;
if (queryMoveUp!=null) { if (queryMoveUp!=null) {
EntityManager em = getEntityManager(); EntityManager em = getEntityManager();
try { try {
if (emTransaction) { // if (emTransaction) {
em.getTransaction().begin(); // em.getTransaction().begin();
} // }
// Copy parameters // Copy parameters
for (String key:state.getDataParameterKeys()) { // for (String key:state.getDataParameterKeys()) {
Object value = state.getDataParameter(key); // Object value = state.getDataParameter(key);
queryMoveUp.setQueryParameter(key, value); // queryMoveUp.setQueryParameter(key, value);
} // }
// set id // set id
queryMoveUp.setQueryParameter("id", primaryId); queryMoveUp.setQueryParameter("id", primaryId);
@ -331,10 +303,10 @@ public class XpqlPersistanceVascBackend<DATA_OBJECT extends Serializable> extend
result+=q.executeUpdate(); result+=q.executeUpdate();
// Copy parameters // Copy parameters
for (String key:state.getDataParameterKeys()) { // for (String key:state.getDataParameterKeys()) {
Object value = state.getDataParameter(key); // Object value = state.getDataParameter(key);
queryMoveUpDown.setQueryParameter(key, value); // queryMoveUpDown.setQueryParameter(key, value);
} // }
// set id // set id
queryMoveUpDown.setQueryParameter("id", primaryId); queryMoveUpDown.setQueryParameter("id", primaryId);
@ -349,9 +321,9 @@ public class XpqlPersistanceVascBackend<DATA_OBJECT extends Serializable> extend
} }
result+=q.executeUpdate(); result+=q.executeUpdate();
if (emTransaction) { // if (emTransaction) {
em.getTransaction().commit(); // em.getTransaction().commit();
} // }
} finally { } finally {
if (em!=null) { if (em!=null) {
//em.close(); //em.close();
@ -361,10 +333,20 @@ public class XpqlPersistanceVascBackend<DATA_OBJECT extends Serializable> extend
return result; return result;
} }
/** /**
* @see net.forwardfire.vasc.backend.AbstractVascBackend#isRecordMoveable() * @see net.forwardfire.vasc.backend.crud.VascBackendList#isSearchable()
*/
public boolean isSearchable() {
if (query.getQueryParameterValue("text_search")!=null) {
return true;
}
return false;
}
/**
* @see net.forwardfire.vasc.backend.crud.AbstractVascBackendCrud#isRecordMoveable()
*/ */
@Override
public boolean isRecordMoveable() { public boolean isRecordMoveable() {
return queryMoveUp!=null & queryMoveDown!=null; return queryMoveUp!=null & queryMoveDown!=null;
} }
@ -424,16 +406,4 @@ public class XpqlPersistanceVascBackend<DATA_OBJECT extends Serializable> extend
public void setQueryMoveDownUp(net.forwardfire.vasc.xpql.query.Query queryMoveDownUp) { public void setQueryMoveDownUp(net.forwardfire.vasc.xpql.query.Query queryMoveDownUp) {
this.queryMoveDownUp = queryMoveDownUp; this.queryMoveDownUp = queryMoveDownUp;
} }
/**
* @see net.forwardfire.vasc.backend.VascBackend#isSearchable()
*/
@Override
public boolean isSearchable() {
if (query.getQueryParameterValue("text_search")==null) {
return false;
}
//return true;
return false;
}
} }

View file

@ -0,0 +1,119 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.backend.ldap;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;
import com.novell.ldap.LDAPConnection;
import com.novell.ldap.LDAPException;
import net.forwardfire.vasc.backend.AbstractVascBackendLocal;
import net.forwardfire.vasc.backend.VascBackendAccessDataKey;
import net.forwardfire.vasc.backend.data.HashMapVascBackendAccessDataKey;
/**
* LdapVascBackend provides abstract data access for ldap.
*
* @author Willem Cazander
* @version 1.0 Sep 4, 2008
*/
abstract public class AbstractLdapVascBackend extends AbstractVascBackendLocal<HashMap<String,Serializable>> {
private Logger logger = Logger.getLogger(AbstractLdapVascBackend.class.getName());
private LdapConnectionProvider ldapConnectionProvider = null;
private String baseDN = null;
private final Map<String,Class<?>> keyMapType = new HashMap<String,Class<?>>(5);
abstract protected void startBackendLdap();
/**
* @see net.forwardfire.vasc.backend.AbstractVascBackendLocal#startBackendLocal()
*/
@Override
protected final void startBackendLocal() {
requireNonEmpty(getBaseDN(), "baseDN requires value.");
requireNonEmpty(keyMapType.keySet(), "No primary keys defined.");
startBackendLdap();
}
protected void safeDisconnect(LDAPConnection connection) {
if (connection==null) {
return;
}
try {
connection.disconnect();
} catch (LDAPException e) {
logger.warning("Error while disconnecting: "+e.getMessage());
}
}
protected final void addKeyMapType(String field,Class<?> fieldType) {
requireNonEmpty(field,"field has to have value");
requireNonNull(fieldType,"field has to have value");
keyMapType.put(field, fieldType);
}
protected final Map<String,Class<?>> getKeyMapType() {
return keyMapType;
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#createVascBackendAccessDataKey()
*/
@Override
public final VascBackendAccessDataKey<HashMap<String, Serializable>> createVascBackendAccessDataKey() {
return new HashMapVascBackendAccessDataKey(keyMapType);
}
/**
* @return the ldapConnectionProvider.
*/
public final LdapConnectionProvider getLdapConnectionProvider() {
return ldapConnectionProvider;
}
/**
* @param ldapConnectionProvider the ldapConnectionProvider to set.
*/
public final void setLdapConnectionProvider(LdapConnectionProvider ldapConnectionProvider) {
this.ldapConnectionProvider = ldapConnectionProvider;
}
/**
* @return the baseDN.
*/
public final String getBaseDN() {
return baseDN;
}
/**
* @param baseDN the baseDN to set.
*/
public final void setBaseDN(String baseDN) {
this.baseDN = baseDN;
}
}

View file

@ -22,25 +22,18 @@
package net.forwardfire.vasc.backend.ldap; package net.forwardfire.vasc.backend.ldap;
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.logging.Logger; import java.util.logging.Logger;
import net.forwardfire.vasc.backend.AbstractVascBackend;
import net.forwardfire.vasc.backend.DefaultVascBackendResult;
import net.forwardfire.vasc.backend.VascBackendException; import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascBackendResult; import net.forwardfire.vasc.backend.VascBackendAccessDataRecord;
import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.crud.VascBackendCrud;
import net.forwardfire.vasc.backend.VascEntryFieldValue; import net.forwardfire.vasc.backend.data.HashMapVascBackendAccessDataRecord;
import net.forwardfire.vasc.backend.VascEntryRecordCreator;
import net.forwardfire.vasc.backend.data.HashMapVascEntryFieldValue;
import net.forwardfire.vasc.backend.data.HashMapVascEntryRecordCreator;
import com.novell.ldap.LDAPAttribute; import com.novell.ldap.LDAPAttribute;
import com.novell.ldap.LDAPAttributeSet;
import com.novell.ldap.LDAPConnection; import com.novell.ldap.LDAPConnection;
import com.novell.ldap.LDAPEntry; import com.novell.ldap.LDAPEntry;
import com.novell.ldap.LDAPException; import com.novell.ldap.LDAPException;
@ -54,91 +47,39 @@ import com.novell.ldap.LDAPSearchResults;
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Sep 4, 2008 * @version 1.0 Sep 4, 2008
*/ */
public class LdapVascBackend extends AbstractVascBackend<HashMap<String,Object>> { public class LdapVascBackendCrud extends AbstractLdapVascBackend implements VascBackendCrud<HashMap<String,Serializable>,HashMap<String,Serializable>> {
private Logger logger = Logger.getLogger(LdapVascBackend.class.getName()); private Logger logger = Logger.getLogger(LdapVascBackendCrud.class.getName());
private LdapConnectionProvider ldapConnectionProvider = null;
private String baseDN = null;
private String keyAttribute = null; private String keyAttribute = null;
private String ldapFilter = null; private String ldapFilter = null;
private String createObjectClass = null; private String createObjectClass = null;
private int timeLimit = 10000; private int timeLimit = 10000;
private boolean referralFollowing = true; private boolean referralFollowing = true;
/** @Override
* @return the ldapConnectionProvider. protected void startBackendLdap() {
*/ }
public LdapConnectionProvider getLdapConnectionProvider() {
return ldapConnectionProvider; @Override
public VascBackendAccessDataRecord<HashMap<String, Serializable>, HashMap<String, Serializable>> createVascBackendAccessDataRecord() {
return new HashMapVascBackendAccessDataRecord(getKeyMapType());
}
@Override
public HashMap<String, Serializable> fetch(HashMap<String, Serializable> recordPK) throws VascBackendException {
return null;
}
@Override
public HashMap<String, Serializable> newRecord() throws VascBackendException {
return new HashMap<String,Serializable>();
} }
/** /**
* @param ldapConnectionProvider the ldapConnectionProvider to set. * @see net.forwardfire.vasc.backend.crud.VascBackendCrud#merge(java.lang.Object)
*/
public void setLdapConnectionProvider(LdapConnectionProvider ldapConnectionProvider) {
this.ldapConnectionProvider = ldapConnectionProvider;
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#execute()
*/ */
@Override @Override
public VascBackendResult<HashMap<String,Object>> execute(VascBackendState state) throws VascBackendException { public HashMap<String,Serializable> merge(HashMap<String,Serializable> map) throws VascBackendException {
LdapConnectionProvider prov = getLdapConnectionProvider();
LDAPConnection connection = prov.getLdapConnection();
List<HashMap<String,Object>> result = new ArrayList<HashMap<String,Object>>(50);
try {
LDAPSearchConstraints cons = new LDAPSearchConstraints();
cons.setBatchSize( 0 );
cons.setTimeLimit(getTimeLimit() ) ;
cons.setReferralFollowing(isReferralFollowing());
connection.setConstraints(cons);
int searchScope = LDAPConnection.SCOPE_ONE;
String searchBase = baseDN;
LDAPSearchResults searchResults = connection.search(
searchBase, // object to read
searchScope, // scope - read single object
getLdapFilter(), // search filter
null, // return all attributes
false); // return attrs and values
while (searchResults.hasMore()) {
LDAPEntry entry = searchResults.next();
HashMap<String,Object> map = new HashMap<String,Object>(10);
LDAPAttributeSet attributeSet = entry.getAttributeSet();
Iterator<LDAPAttribute> i = attributeSet.iterator();
while (i.hasNext()) {
LDAPAttribute attr = i.next();
String[] s = attr.getStringValueArray();
if (s.length==1) {
map.put(attr.getName(), attr.getStringValue());
} else {
List<String> multiValue = new ArrayList<String>(s.length);
for (String ss:s) {
multiValue.add(ss);
}
map.put(attr.getName(), multiValue );
}
}
result.add(map);
}
} catch (LDAPException e) {
throw new VascBackendException(e);
} finally {
safeDisconnect(connection);
}
return new DefaultVascBackendResult<HashMap<String,Object>>(result);
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#merge(java.lang.Object)
*/
@Override
public HashMap<String,Object> merge(HashMap<String,Object> map) throws VascBackendException {
LdapConnectionProvider prov = getLdapConnectionProvider(); LdapConnectionProvider prov = getLdapConnectionProvider();
LDAPConnection connection = prov.getLdapConnection(); LDAPConnection connection = prov.getLdapConnection();
try { try {
@ -149,7 +90,7 @@ public class LdapVascBackend extends AbstractVascBackend<HashMap<String,Object>>
cons.setReferralFollowing(isReferralFollowing()); cons.setReferralFollowing(isReferralFollowing());
connection.setConstraints(cons); connection.setConstraints(cons);
int searchScope = LDAPConnection.SCOPE_ONE; int searchScope = LDAPConnection.SCOPE_ONE;
String searchBase = baseDN; String searchBase = getBaseDN();
String filter = "(&"+ldapFilter+"("+keyAttribute+"="+keyValue+"))"; String filter = "(&"+ldapFilter+"("+keyAttribute+"="+keyValue+"))";
LDAPSearchResults searchResults = connection.search( LDAPSearchResults searchResults = connection.search(
searchBase, // object to read searchBase, // object to read
@ -216,15 +157,15 @@ public class LdapVascBackend extends AbstractVascBackend<HashMap<String,Object>>
} }
/** /**
* @see net.forwardfire.vasc.backend.VascBackend#persist(java.lang.Object) * @see net.forwardfire.vasc.backend.crud.VascBackendCrud#persist(java.lang.Object)
*/ */
@Override @Override
public void persist(HashMap<String,Object> map) throws VascBackendException { public HashMap<String,Serializable> persist(HashMap<String,Serializable> map) throws VascBackendException {
LdapConnectionProvider prov = getLdapConnectionProvider(); LdapConnectionProvider prov = getLdapConnectionProvider();
LDAPConnection connection = prov.getLdapConnection(); LDAPConnection connection = prov.getLdapConnection();
try { try {
String keyValue = (String)map.get(keyAttribute); String keyValue = (String)map.get(keyAttribute);
LDAPEntry entry = new LDAPEntry(keyAttribute+"="+keyValue+","+baseDN); LDAPEntry entry = new LDAPEntry(keyAttribute+"="+keyValue+","+getBaseDN());
LDAPAttribute ob = new LDAPAttribute("objectClass"); LDAPAttribute ob = new LDAPAttribute("objectClass");
String[] obs = createObjectClass.split(","); String[] obs = createObjectClass.split(",");
@ -248,19 +189,20 @@ public class LdapVascBackend extends AbstractVascBackend<HashMap<String,Object>>
} finally { } finally {
safeDisconnect(connection); safeDisconnect(connection);
} }
return fetch(map);
} }
/** /**
* @see net.forwardfire.vasc.backend.VascBackend#delete(java.lang.Object) * @see net.forwardfire.vasc.backend.crud.VascBackendCrud#delete(java.lang.Object)
*/ */
@Override @Override
public void delete(HashMap<String,Object> map) throws VascBackendException { public void delete(HashMap<String,Serializable> map) throws VascBackendException {
LdapConnectionProvider prov = getLdapConnectionProvider(); LdapConnectionProvider prov = getLdapConnectionProvider();
LDAPConnection connection = prov.getLdapConnection(); LDAPConnection connection = prov.getLdapConnection();
try { try {
String keyValue = (String)map.get(keyAttribute); String keyValue = (String)map.get(keyAttribute);
int searchScope = LDAPConnection.SCOPE_ONE; int searchScope = LDAPConnection.SCOPE_ONE;
String searchBase = baseDN; String searchBase = getBaseDN();
String filter = "(&"+ldapFilter+"("+keyAttribute+"="+keyValue+"))"; String filter = "(&"+ldapFilter+"("+keyAttribute+"="+keyValue+"))";
LDAPSearchResults searchResults = connection.search( LDAPSearchResults searchResults = connection.search(
searchBase, // object to read searchBase, // object to read
@ -282,47 +224,6 @@ public class LdapVascBackend extends AbstractVascBackend<HashMap<String,Object>>
} }
} }
private void safeDisconnect(LDAPConnection connection) {
if (connection==null) {
return;
}
try {
connection.disconnect();
} catch (LDAPException e) {
logger.warning("Error while disconnecting: "+e.getMessage());
}
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryRecordCreator()
*/
@Override
public VascEntryRecordCreator provideVascEntryRecordCreator() {
return new HashMapVascEntryRecordCreator();
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryFieldValue()
*/
@Override
public VascEntryFieldValue provideVascEntryFieldValue() {
return new HashMapVascEntryFieldValue();
}
/**
* @return the baseDN.
*/
public String getBaseDN() {
return baseDN;
}
/**
* @param baseDN the baseDN to set.
*/
public void setBaseDN(String baseDN) {
this.baseDN = baseDN;
}
/** /**
* @return the keyAttribute. * @return the keyAttribute.
*/ */

View file

@ -0,0 +1,220 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.backend.ldap;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascBackendAccessDataRecord;
import net.forwardfire.vasc.backend.crud.VascBackendCrud;
import net.forwardfire.vasc.backend.data.HashMapVascBackendAccessDataRecord;
import net.forwardfire.vasc.backend.list.DefaultVascBackendListResult;
import net.forwardfire.vasc.backend.list.VascBackendList;
import net.forwardfire.vasc.backend.list.VascBackendListFeature;
import net.forwardfire.vasc.backend.list.VascBackendListResult;
import net.forwardfire.vasc.backend.list.VascBackendListRequest;
import com.novell.ldap.LDAPAttribute;
import com.novell.ldap.LDAPAttributeSet;
import com.novell.ldap.LDAPConnection;
import com.novell.ldap.LDAPEntry;
import com.novell.ldap.LDAPException;
import com.novell.ldap.LDAPModification;
import com.novell.ldap.LDAPSearchConstraints;
import com.novell.ldap.LDAPSearchResults;
/**
* LdapVascBackend provides abstract data access for ldap.
*
* @author Willem Cazander
* @version 1.0 Sep 4, 2008
*/
public class LdapVascBackendList extends AbstractLdapVascBackend implements VascBackendList<HashMap<String,Serializable>,HashMap<String,Serializable>> {
private Logger logger = Logger.getLogger(LdapVascBackendList.class.getName());
private final EnumSet<VascBackendListFeature> features = EnumSet.noneOf(VascBackendListFeature.class);
private final List<String> rowActions = new ArrayList<String>();
private String keyAttribute = null;
private String ldapFilter = null;
private String createObjectClass = null;
private int timeLimit = 10000;
private boolean referralFollowing = true;
@Override
protected void startBackendLdap() {
// TODO Auto-generated method stub
}
@Override
public VascBackendAccessDataRecord<HashMap<String, Serializable>, HashMap<String, Serializable>> createVascBackendAccessDataRecord() {
return new HashMapVascBackendAccessDataRecord(getKeyMapType());
}
@Override
public EnumSet<VascBackendListFeature> getSupportedFeatures() {
return features;
}
@Override
public List<String> getSupportedRowActions() {
return rowActions;
}
@Override
public void executeRowAction(VascBackendListRequest request,List<HashMap<String, Serializable>> recordPKs, String actionName) throws VascBackendException {
}
/**
* @see net.forwardfire.vasc.backend.crud.VascBackendCrud#execute()
*/
@Override
public VascBackendListResult<HashMap<String,Serializable>> execute(VascBackendListRequest state) throws VascBackendException {
LdapConnectionProvider prov = getLdapConnectionProvider();
LDAPConnection connection = prov.getLdapConnection();
List<HashMap<String,Serializable>> result = new ArrayList<HashMap<String,Serializable>>(50);
try {
LDAPSearchConstraints cons = new LDAPSearchConstraints();
cons.setBatchSize( 0 );
cons.setTimeLimit(getTimeLimit() ) ;
cons.setReferralFollowing(isReferralFollowing());
connection.setConstraints(cons);
int searchScope = LDAPConnection.SCOPE_ONE;
String searchBase = getBaseDN();
LDAPSearchResults searchResults = connection.search(
searchBase, // object to read
searchScope, // scope - read single object
getLdapFilter(), // search filter
null, // return all attributes
false); // return attrs and values
while (searchResults.hasMore()) {
LDAPEntry entry = searchResults.next();
HashMap<String,Serializable> map = new HashMap<String,Serializable>(10);
LDAPAttributeSet attributeSet = entry.getAttributeSet();
Iterator<LDAPAttribute> i = attributeSet.iterator();
while (i.hasNext()) {
LDAPAttribute attr = i.next();
String[] s = attr.getStringValueArray();
if (s.length==1) {
map.put(attr.getName(), attr.getStringValue());
} else {
List<String> multiValue = new ArrayList<String>(s.length);
for (String ss:s) {
multiValue.add(ss);
}
map.put(attr.getName(), (Serializable)multiValue );
}
}
result.add(map);
}
} catch (LDAPException e) {
throw new VascBackendException(e);
} finally {
safeDisconnect(connection);
}
return new DefaultVascBackendListResult<HashMap<String,Serializable>>(result);
}
/**
* @return the keyAttribute.
*/
public String getKeyAttribute() {
return keyAttribute;
}
/**
* @param keyAttribute the keyAttribute to set.
*/
public void setKeyAttribute(String keyAttribute) {
this.keyAttribute = keyAttribute;
}
/**
* @return the ldapFilter.
*/
public String getLdapFilter() {
return ldapFilter;
}
/**
* @param ldapFilter the ldapFilter to set.
*/
public void setLdapFilter(String ldapFilter) {
this.ldapFilter = ldapFilter;
}
/**
* @return the createObjectClass.
*/
public String getCreateObjectClass() {
return createObjectClass;
}
/**
* @param createObjectClass the createObjectClass to set.
*/
public void setCreateObjectClass(String createObjectClass) {
this.createObjectClass = createObjectClass;
}
/**
* @return the timeLimit.
*/
public int getTimeLimit() {
return timeLimit;
}
/**
* @param timeLimit the timeLimit to set.
*/
public void setTimeLimit(int timeLimit) {
this.timeLimit = timeLimit;
}
/**
* @return the referralFollowing.
*/
public boolean isReferralFollowing() {
return referralFollowing;
}
/**
* @param referralFollowing the referralFollowing to set.
*/
public void setReferralFollowing(boolean referralFollowing) {
this.referralFollowing = referralFollowing;
}
}

View file

@ -0,0 +1,142 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.backend.metamodel;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;
import org.eobjects.metamodel.DataContext;
import net.forwardfire.vasc.backend.AbstractVascBackendLocal;
import net.forwardfire.vasc.backend.VascBackendAccessDataKey;
import net.forwardfire.vasc.backend.data.HashMapVascBackendAccessDataKey;
/**
* AbstractMetaModelVascBackend provides shared metamodel options.
*
* @author Willem Cazander
* @version 1.0 Oct 27, 2014
*/
abstract public class AbstractMetaModelVascBackend extends AbstractVascBackendLocal<HashMap<String,Serializable>> {
private Logger logger = Logger.getLogger(MetaModelVascBackendCrud.class.getName());
private MetaModelDataContextProvider dataContextProvider = null;
private DataContext dataContext = null;
private String table = null;
private String tableId = null;
private final Map<String,Class<?>> keyMapType = new HashMap<String,Class<?>>(5);
abstract protected void startBackendMetaModel();
@Override
protected void stopBackendLocal() {
dataContext = null;
}
/**
* @see net.forwardfire.vasc.backend.AbstractVascBackendLocal#startBackendLocal()
*/
@Override
protected final void startBackendLocal() {
requireNonNull(getDataContextProvider(), "dataContextProvider is null.");
requireNonEmpty(keyMapType.keySet(), "No primary keys defined.");
requireNonNull(table,"table needs value");
//requireNonNull(tableId,"table needs value");
long startTime = System.currentTimeMillis();
dataContext = dataContextProvider.getDataContext();
requireNonNull(dataContext,"dataContextProvider created null dataContext.");
long stopTime = System.currentTimeMillis();
logger.fine(dataContext.getClass().getSimpleName()+" created for: "+table+" in: "+(stopTime-startTime)+" ms.");
startBackendMetaModel();
}
protected final void addKeyMapType(String field,Class<?> fieldType) {
requireNonEmpty(field,"field has to have value");
requireNonNull(fieldType,"field has to have value");
keyMapType.put(field, fieldType);
}
protected final Map<String,Class<?>> getKeyMapType() {
return keyMapType;
}
protected DataContext getDataContext() {
return dataContext;
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#createVascBackendAccessDataKey()
*/
@Override
public final VascBackendAccessDataKey<HashMap<String, Serializable>> createVascBackendAccessDataKey() {
return new HashMapVascBackendAccessDataKey(keyMapType);
}
/**
* @return the dataContextProvider
*/
public final MetaModelDataContextProvider getDataContextProvider() {
return dataContextProvider;
}
/**
* @param dataContextProvider the dataContextProvider to set
*/
public final void setDataContextProvider(MetaModelDataContextProvider dataContextProvider) {
this.dataContextProvider = dataContextProvider;
}
/**
* @return the table
*/
public final String getTable() {
return table;
}
/**
* @param table the table to set
*/
public final void setTable(String table) {
this.table = table;
}
/**
* @return the tableId
*/
public final String getTableId() {
return tableId;
}
/**
* @param tableId the tableId to set
*/
public final void setTableId(String tableId) {
this.tableId = tableId;
}
}

View file

@ -1,20 +1,36 @@
package net.forwardfire.vasc.backend.metamodel; package net.forwardfire.vasc.backend.metamodel;
import java.io.Serializable; import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import org.eobjects.metamodel.data.Row; import org.eobjects.metamodel.data.Row;
import org.eobjects.metamodel.query.SelectItem; import org.eobjects.metamodel.query.SelectItem;
import net.forwardfire.vasc.backend.VascBackendException; import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascEntryFieldValue; import net.forwardfire.vasc.backend.VascBackendAccessDataRecord;
import net.forwardfire.vasc.backend.metamodel.crud.UpdateableRow; import net.forwardfire.vasc.backend.metamodel.crud.UpdateableRow;
public class RowVascEntryFieldValue implements VascEntryFieldValue<Row> { @SuppressWarnings("serial")
public class MetaModelVascBackendAccessDataRecord implements VascBackendAccessDataRecord<HashMap<String,Serializable>,Row> {
private static final long serialVersionUID = -806674640688182132L; private final Map<String,Class<?>> keyMapType;
public MetaModelVascBackendAccessDataRecord(Map<String,Class<?>> keyMapType) {
this.keyMapType = keyMapType;
}
@Override
public HashMap<String, Serializable> getPrimaryKey(Row record) throws VascBackendException {
HashMap<String, Serializable> result = new HashMap<String, Serializable>();
for (String key:keyMapType.keySet()) {
result.put(key, getValue(key,record));
}
return result;
}
/** /**
* @see net.forwardfire.vasc.backend.VascEntryFieldValue#getValue(java.lang.String, java.lang.Object) * @see net.forwardfire.vasc.backend.VascBackendAccessDataRecord#getValue(java.lang.String, java.lang.Object)
*/ */
@Override @Override
public Serializable getValue(String backendName, Row record) throws VascBackendException { public Serializable getValue(String backendName, Row record) throws VascBackendException {
@ -47,19 +63,7 @@ public class RowVascEntryFieldValue implements VascEntryFieldValue<Row> {
} }
/** /**
* @see net.forwardfire.vasc.backend.VascEntryFieldValue#getDisplayValue(java.lang.String, java.lang.Object) * @see net.forwardfire.vasc.backend.VascBackendAccessDataRecord#setValue(java.lang.String, java.lang.Object, java.lang.Object)
*/
@Override
public String getDisplayValue(String backendName, Row record) throws VascBackendException {
Object fieldValue = getValue(backendName,record);
if (fieldValue==null) {
fieldValue = "";
}
return fieldValue.toString();
}
/**
* @see net.forwardfire.vasc.backend.VascEntryFieldValue#setValue(java.lang.String, java.lang.Object, java.lang.Object)
*/ */
@Override @Override
public void setValue(String backendName, Row record,Serializable value) throws VascBackendException { public void setValue(String backendName, Row record,Serializable value) throws VascBackendException {

View file

@ -0,0 +1,143 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.backend.metamodel;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Logger;
import org.eobjects.metamodel.DataContext;
import org.eobjects.metamodel.UpdateableDataContext;
import org.eobjects.metamodel.data.DataSet;
import org.eobjects.metamodel.data.Row;
import org.eobjects.metamodel.jdbc.JdbcDataContext;
import org.eobjects.metamodel.query.OrderByItem.Direction;
import org.eobjects.metamodel.query.Query;
import org.eobjects.metamodel.query.SelectItem;
import org.eobjects.metamodel.query.builder.SatisfiedQueryBuilder;
import org.eobjects.metamodel.query.builder.SatisfiedWhereBuilder;
import org.eobjects.metamodel.schema.Column;
import org.eobjects.metamodel.schema.Schema;
import org.eobjects.metamodel.schema.Table;
import net.forwardfire.vasc.backend.VascBackendAccessDataRecord;
import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.crud.VascBackendCrud;
import net.forwardfire.vasc.backend.list.DefaultVascBackendListResult;
import net.forwardfire.vasc.backend.list.VascBackendListResult;
import net.forwardfire.vasc.backend.list.VascBackendListRequest;
import net.forwardfire.vasc.backend.metamodel.crud.CrudDataContext;
import net.forwardfire.vasc.backend.metamodel.crud.UpdateableRow;
import net.forwardfire.vasc.backend.metamodel.crud.CrudDataContextImpl;
import net.forwardfire.vasc.backend.metamodel.crud.UpdateableRowMapImpl;
/**
* MetaModelVascBackend provides vasc backend for metamodel.
*
* @author Willem Cazander
* @version 1.0 Dec 31, 2011
*/
public class MetaModelVascBackendCrud extends AbstractMetaModelVascBackend implements VascBackendCrud<HashMap<String,Serializable>,Row> {
private Logger logger = Logger.getLogger(MetaModelVascBackendCrud.class.getName());
private CrudDataContext crudDataContext = null;
@Override
protected void startBackendMetaModel() {
// if (isUpdateableDataContext()) {
// CrudDataContextImpl crudDataContextImpl = new CrudDataContextImpl(getUpdateableDataContext());
// if (tableId!=null && tableId.isEmpty()==false) {
// List<String> ids = new ArrayList<String>(1);
// ids.add(tableId);
// crudDataContextImpl.overridePrimaryKeysForTable(table,ids);
// }
// crudDataContext = crudDataContextImpl;
// }
}
@Override
public VascBackendAccessDataRecord<HashMap<String, Serializable>, Row> createVascBackendAccessDataRecord() {
// TODO Auto-generated method stub
return null;
}
@Override
public Row newRecord() throws VascBackendException {
return crudDataContext.createRow(crudDataContext.getTableByQualifiedLabel(getTable()));
}
@Override
public Row fetch(HashMap<String, Serializable> recordPK) throws VascBackendException {
// TODO Auto-generated method stub
return null;
}
/**
* Returns casted version of data context.
*/
private UpdateableDataContext getUpdateableDataContext() {
return (UpdateableDataContext)getDataContext();
}
/**
* Returns true when data context in updateable.
*/
private boolean isUpdateableDataContext() {
return getDataContext() instanceof UpdateableDataContext;
}
public boolean isReadOnly() {
return isUpdateableDataContext()==false;
}
@Override
public Row persist(Row object) throws VascBackendException {
if (crudDataContext==null) {
return object;
}
crudDataContext.persist((UpdateableRow) object);
return object;
}
@Override
public Row merge(Row object) throws VascBackendException {
if (crudDataContext==null) {
return object;
}
return crudDataContext.merge((UpdateableRow) object);
}
@Override
public void delete(HashMap<String, Serializable> recordPK) throws VascBackendException {
if (crudDataContext==null) {
return;
}
//crudDataContext.delete((UpdateableRow) object);
}
}

View file

@ -22,8 +22,11 @@
package net.forwardfire.vasc.backend.metamodel; package net.forwardfire.vasc.backend.metamodel;
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -42,12 +45,15 @@ import org.eobjects.metamodel.schema.Column;
import org.eobjects.metamodel.schema.Schema; import org.eobjects.metamodel.schema.Schema;
import org.eobjects.metamodel.schema.Table; import org.eobjects.metamodel.schema.Table;
import net.forwardfire.vasc.backend.AbstractVascBackend; import net.forwardfire.vasc.backend.VascBackendAccessDataRecord;
import net.forwardfire.vasc.backend.DefaultVascBackendResult;
import net.forwardfire.vasc.backend.VascBackendException; import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascBackendResult; import net.forwardfire.vasc.backend.crud.VascBackendCrud;
import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.data.HashMapVascBackendAccessDataRecord;
import net.forwardfire.vasc.backend.VascEntryRecordCreator; import net.forwardfire.vasc.backend.list.DefaultVascBackendListResult;
import net.forwardfire.vasc.backend.list.VascBackendList;
import net.forwardfire.vasc.backend.list.VascBackendListFeature;
import net.forwardfire.vasc.backend.list.VascBackendListResult;
import net.forwardfire.vasc.backend.list.VascBackendListRequest;
import net.forwardfire.vasc.backend.metamodel.crud.CrudDataContext; import net.forwardfire.vasc.backend.metamodel.crud.CrudDataContext;
import net.forwardfire.vasc.backend.metamodel.crud.UpdateableRow; import net.forwardfire.vasc.backend.metamodel.crud.UpdateableRow;
import net.forwardfire.vasc.backend.metamodel.crud.CrudDataContextImpl; import net.forwardfire.vasc.backend.metamodel.crud.CrudDataContextImpl;
@ -59,91 +65,39 @@ import net.forwardfire.vasc.backend.metamodel.crud.UpdateableRowMapImpl;
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Dec 31, 2011 * @version 1.0 Dec 31, 2011
*/ */
public class MetaModelVascBackend extends AbstractVascBackend<Row> { public class MetaModelVascBackendList extends AbstractMetaModelVascBackend implements VascBackendList<HashMap<String,Serializable>,Row> {
private Logger logger = Logger.getLogger(MetaModelVascBackend.class.getName()); private Logger logger = Logger.getLogger(MetaModelVascBackendList.class.getName());
private MetaModelDataContextProvider dataContextProvider = null; private final EnumSet<VascBackendListFeature> features = EnumSet.noneOf(VascBackendListFeature.class);
private DataContext dataContext = null; private final List<String> rowActions = new ArrayList<String>();
private CrudDataContext crudDataContext = null;
private String table = null;
private String tableId = null;
/**
* Returns casted version of data context.
*/
private UpdateableDataContext getUpdateableDataContext() {
return (UpdateableDataContext)dataContext;
}
/**
* Returns true when data context in updateable.
*/
private boolean isUpdateableDataContext() {
return dataContext instanceof UpdateableDataContext;
}
/**
* @see net.forwardfire.vasc.backend.AbstractVascBackend#isReadOnly()
*/
@Override @Override
public boolean isReadOnly() { protected void startBackendMetaModel() {
return isUpdateableDataContext()==false;
} }
/**
* @see net.forwardfire.vasc.backend.AbstractVascBackend#startBackend()
*/
@Override @Override
public void startBackend() { public VascBackendAccessDataRecord<HashMap<String,Serializable>,Row> createVascBackendAccessDataRecord() {
if (table==null) { return new MetaModelVascBackendAccessDataRecord(getKeyMapType());
throw new NullPointerException("Can't start with null table.");
}
if (table.isEmpty()) {
throw new NullPointerException("Can't start with empty table.");
}
long startTime = System.currentTimeMillis();
dataContext = dataContextProvider.getDataContext();
if (isUpdateableDataContext()) {
CrudDataContextImpl crudDataContextImpl = new CrudDataContextImpl(getUpdateableDataContext());
if (tableId!=null && tableId.isEmpty()==false) {
List<String> ids = new ArrayList<String>(1);
ids.add(tableId);
crudDataContextImpl.overridePrimaryKeysForTable(table,ids);
}
crudDataContext = crudDataContextImpl;
}
long stopTime = System.currentTimeMillis();
logger.fine(dataContext.getClass().getSimpleName()+" created for: "+table+" in: "+(stopTime-startTime)+" ms.");
} }
/**
* @see net.forwardfire.vasc.backend.AbstractVascBackend#stopBackend()
*/
@Override @Override
public void stopBackend() { public EnumSet<VascBackendListFeature> getSupportedFeatures() {
dataContext = null; return features;
} }
/**
* @see net.forwardfire.vasc.backend.AbstractVascBackend#isPageable()
*/
@Override @Override
public boolean isPageable() { public List<String> getSupportedRowActions() {
return true; return rowActions;
} }
/**
* @see net.forwardfire.vasc.backend.AbstractVascBackend#isSortable()
*/
@Override @Override
public boolean isSortable() { public void executeRowAction(VascBackendListRequest request,List<HashMap<String, Serializable>> recordPKs, String actionName) throws VascBackendException {
return true;
} }
private long fetchTotalExecuteSize(VascBackendState state) { private long fetchTotalExecuteSize(VascBackendListRequest state) {
DataContext dataContext = getDataContext();
Schema schema = dataContext.getDefaultSchema(); Schema schema = dataContext.getDefaultSchema();
Table t = schema.getTableByName(table); Table t = schema.getTableByName(getTable());
Query q = createFilterQuery(state,t,true); Query q = createFilterQuery(state,t,true);
DataSet ds = dataContext.executeQuery(q); DataSet ds = dataContext.executeQuery(q);
if (ds.next()==false) { if (ds.next()==false) {
@ -156,7 +110,9 @@ public class MetaModelVascBackend extends AbstractVascBackend<Row> {
return result.longValue(); return result.longValue();
} }
private Query createFilterQuery(VascBackendState state,Table t,boolean count) { private Query createFilterQuery(VascBackendListRequest state,Table t,boolean count) {
DataContext dataContext = getDataContext();
Object qWhere = null; Object qWhere = null;
if (count==false) { if (count==false) {
qWhere = dataContext.query().from(t).select(t.getColumns()); qWhere = dataContext.query().from(t).select(t.getColumns());
@ -208,18 +164,19 @@ public class MetaModelVascBackend extends AbstractVascBackend<Row> {
} }
@Override @Override
public VascBackendResult<Row> execute(VascBackendState state) throws VascBackendException { public VascBackendListResult<Row> execute(VascBackendListRequest state) throws VascBackendException {
return new DefaultVascBackendResult<Row>(executeList(state),fetchTotalExecuteSize(state)); return new DefaultVascBackendListResult<Row>(executeList(state),fetchTotalExecuteSize(state));
} }
private List<Row> executeList(VascBackendState state) throws VascBackendException { private List<Row> executeList(VascBackendListRequest state) throws VascBackendException {
DataContext dataContext = getDataContext();
Schema schema = dataContext.getDefaultSchema(); Schema schema = dataContext.getDefaultSchema();
Table t = schema.getTableByName(table); Table t = schema.getTableByName(getTable());
if (t==null) { if (t==null) {
throw new VascBackendException("Could not get meta table for: '"+table+"'."); throw new VascBackendException("Could not get meta table for: '"+getTable()+"'.");
} }
Query q = createFilterQuery(state,t,false); Query q = createFilterQuery(state,t,false);
if (isSortable() && state.getSortField() != null) { if (state.getSortField() != null) {
Column orderColumn = t.getColumnByName(state.getSortField()); Column orderColumn = t.getColumnByName(state.getSortField());
if (state.isSortAscending()) { if (state.isSortAscending()) {
q.orderBy(orderColumn,Direction.ASC); q.orderBy(orderColumn,Direction.ASC);
@ -227,7 +184,7 @@ public class MetaModelVascBackend extends AbstractVascBackend<Row> {
q.orderBy(orderColumn,Direction.DESC); q.orderBy(orderColumn,Direction.DESC);
} }
} }
if (isPageable() && state.getPageSize()>0) { if (state.getPageSize()>0) {
if (state.getPageIndex()>0) { if (state.getPageIndex()>0) {
q.setFirstRow((state.getPageIndex()*state.getPageSize())+1); // MM is 1 based ?? q.setFirstRow((state.getPageIndex()*state.getPageSize())+1); // MM is 1 based ??
@ -239,12 +196,12 @@ public class MetaModelVascBackend extends AbstractVascBackend<Row> {
q.setMaxRows(state.getPageSize()); q.setMaxRows(state.getPageSize());
} }
List<Row> result = new ArrayList<Row>(50); List<Row> result = new ArrayList<Row>(50);
if (crudDataContext!=null) { // if (crudDataContext!=null) {
DataSet ds = crudDataContext.executeQuery(q); // DataSet ds = crudDataContext.executeQuery(q);
result.addAll(ds.toRows()); // result.addAll(ds.toRows());
ds.close(); // ds.close();
return result; // return result;
} // }
DataSet ds = dataContext.executeQuery(q); DataSet ds = dataContext.executeQuery(q);
while (ds.next()) { while (ds.next()) {
@ -252,7 +209,7 @@ public class MetaModelVascBackend extends AbstractVascBackend<Row> {
SelectItem[] cols = row.getSelectItems(); SelectItem[] cols = row.getSelectItems();
List<String> keys = new ArrayList<String>(1); List<String> keys = new ArrayList<String>(1);
keys.add(cols[0].getColumn().getName()); keys.add(cols[0].getColumn().getName());
UpdateableRowMapImpl rowMM = new UpdateableRowMapImpl(dataContext.getDefaultSchema().getTableByName(table),keys,cols); UpdateableRowMapImpl rowMM = new UpdateableRowMapImpl(dataContext.getDefaultSchema().getTableByName(getTable()),keys,cols);
for (SelectItem col:cols) { for (SelectItem col:cols) {
Object value = row.getValue(col); Object value = row.getValue(col);
rowMM.setValue(col, value); rowMM.setValue(col, value);
@ -263,80 +220,4 @@ public class MetaModelVascBackend extends AbstractVascBackend<Row> {
return result; return result;
} }
@Override
public void persist(Row object) throws VascBackendException {
if (crudDataContext==null) {
return;
}
crudDataContext.persist((UpdateableRow) object);
}
@Override
public Row merge(Row object) throws VascBackendException {
if (crudDataContext==null) {
return object;
}
return crudDataContext.merge((UpdateableRow) object);
}
@Override
public void delete(Row object) throws VascBackendException {
if (crudDataContext==null) {
return;
}
crudDataContext.delete((UpdateableRow) object);
}
@Override
public RowVascEntryFieldValue provideVascEntryFieldValue() {
return new RowVascEntryFieldValue();
}
@Override
public VascEntryRecordCreator<Row> provideVascEntryRecordCreator() {
return new RowVascEntryRecordCreator(crudDataContext,crudDataContext.getDefaultSchema().getTableByName(table));
}
/**
* @return the dataContextProvider
*/
public MetaModelDataContextProvider getDataContextProvider() {
return dataContextProvider;
}
/**
* @param dataContextProvider the dataContextProvider to set
*/
public void setDataContextProvider(MetaModelDataContextProvider dataContextProvider) {
this.dataContextProvider = dataContextProvider;
}
/**
* @return the table
*/
public String getTable() {
return table;
}
/**
* @param table the table to set
*/
public void setTable(String table) {
this.table = table;
}
/**
* @return the tableId
*/
public String getTableId() {
return tableId;
}
/**
* @param tableId the tableId to set
*/
public void setTableId(String tableId) {
this.tableId = tableId;
}
} }

View file

@ -1,25 +0,0 @@
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;
public class RowVascEntryRecordCreator implements VascEntryRecordCreator<Row> {
private static final long serialVersionUID = -1182678362367989090L;
private CrudDataContext dataContext = null;
private Table table = null;
public RowVascEntryRecordCreator(CrudDataContext dataContext,Table table) {
this.dataContext=dataContext;
this.table=table;
}
@Override
public Row newRecord() throws VascBackendException {
return dataContext.createRow(table);
}
}

View file

@ -0,0 +1,104 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.backend.mongodb;
import org.bson.types.ObjectId;
import net.forwardfire.vasc.backend.AbstractVascBackendLocal;
import net.forwardfire.vasc.backend.VascBackendAccessDataKey;
import net.forwardfire.vasc.backend.VascBackendException;
import com.mongodb.BasicDBObject;
import com.mongodb.DB;
import com.mongodb.DBCollection;
/**
* AbstractMongodbVascBackend
*
* @author Willem Cazander
* @version 1.0 Oct 26, 2014
*/
abstract public class AbstractMongodbVascBackend extends AbstractVascBackendLocal<ObjectId> {
public static final String PK_FIELD_NAME = "_id";
private MongodbConnectionProvider connectionProvider = null;
private String collection = null;
private DB database = null;
@Override
public final void startBackendLocal() {
requireNonNull(connectionProvider, "Can't start with null connectionProvider.");
requireNonEmpty(collection, "Can't start without collection.");
database = connectionProvider.getMongodbConnection();
requireNonNull(database, "connectionProvider provided us a null database.");
}
@Override
public final void stopBackendLocal() {
database = null;
}
protected final DBCollection getDBCollection() {
return database.getCollection(collection);
}
protected final void deleteById(ObjectId objectId) throws VascBackendException {
getDBCollection().remove(new BasicDBObject(PK_FIELD_NAME,objectId)); // remove by _id
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#createVascBackendAccessDataKey()
*/
@Override
public final VascBackendAccessDataKey<ObjectId> createVascBackendAccessDataKey() {
return new MongodbVascBackendAccessDataKey();
}
/**
* @return the connectionProvider
*/
public final MongodbConnectionProvider getConnectionProvider() {
return connectionProvider;
}
/**
* @param connectionProvider the connectionProvider to set
*/
public final void setConnectionProvider(MongodbConnectionProvider connectionProvider) {
this.connectionProvider = connectionProvider;
}
/**
* @return the collection
*/
public final String getCollection() {
return collection;
}
/**
* @param collection the collection to set
*/
public final void setCollection(String collection) {
this.collection = collection;
}
}

View file

@ -1,191 +0,0 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.backend.mongodb;
import java.util.ArrayList;
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;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.DBCursor;
import com.mongodb.DBObject;
import com.mongodb.BasicDBObject;
import com.mongodb.WriteConcern;
import com.mongodb.WriteResult;
/**
* MongodbVascBackend Provides backend for mongodb.
*
* @author Willem Cazander
* @version 1.0 Dec 30, 2011
*/
public class MongodbVascBackend extends AbstractVascBackend<BasicDBObject> {
private Logger logger = null;
private MongodbConnectionProvider connectionProvider = null;
private String collection = null;
private DB database = null;
public MongodbVascBackend() {
logger = Logger.getLogger(MongodbVascBackend.class.getName());
}
/**
* @see net.forwardfire.vasc.backend.AbstractVascBackend#startBackend()
*/
@Override
public void startBackend() {
if (connectionProvider==null) {
throw new NullPointerException("Can't start backend with null connectionProvider.");
}
database = connectionProvider.getMongodbConnection();
}
/**
* @see net.forwardfire.vasc.backend.AbstractVascBackend#stopBackend()
*/
@Override
public void stopBackend() {
database = null;
}
/**
* @see net.forwardfire.vasc.backend.AbstractVascBackend#isPageable()
*/
@Override
public boolean isPageable() {
return true;
}
private long fetchTotalExecuteSize(VascBackendState state) {
DBCollection coll = getDBCollection();
DBObject query = createFilterQuery(state);
long result = coll.count(query);
return result;
}
private DBObject createFilterQuery(VascBackendState state) {
DBObject query = new BasicDBObject();
for (String key:state.getDataParameterKeys()) {
Object value = state.getDataParameter(key);
query.put(key, value);
logger.finer("Setting query parameter key: '"+key+"' value: '"+value+"'");
}
return query;
}
@Override
public VascBackendResult<BasicDBObject> execute(VascBackendState state) throws VascBackendException {
return new DefaultVascBackendResult<BasicDBObject>(executeList(state),fetchTotalExecuteSize(state));
}
private List<BasicDBObject> executeList(VascBackendState state) throws VascBackendException {
DBCollection coll = getDBCollection();
DBObject query = createFilterQuery(state);
DBCursor cur = coll.find(query);
if (isPageable() && state.getPageSize()>0) {
cur.limit(state.getPageSize());
cur.skip(state.getPageIndex());
}
List<BasicDBObject> result = new ArrayList<BasicDBObject>(cur.count());
while (cur.hasNext()) {
DBObject row = cur.next();
result.add((BasicDBObject)row);
}
return result;
}
@Override
public void persist(BasicDBObject object) throws VascBackendException {
DBCollection coll = getDBCollection();
coll.insert(object);
}
@Override
public BasicDBObject merge(BasicDBObject row) throws VascBackendException {
DBCollection coll = getDBCollection();
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 row;
}
@Override
public void delete(BasicDBObject object) throws VascBackendException {
DBCollection coll = getDBCollection();
DBObject query = new BasicDBObject();
query.put("_id",object.get("_id"));
coll.remove(query); // remove by _id
}
@Override
public MongodbVascEntryFieldValue provideVascEntryFieldValue() {
return new MongodbVascEntryFieldValue();
}
@Override
public VascEntryRecordCreator<BasicDBObject> provideVascEntryRecordCreator() {
return new MongodbVascEntryRecordCreator();
}
private DBCollection getDBCollection() {
return database.getCollection(collection);
}
/**
* @return the connectionProvider
*/
public MongodbConnectionProvider getConnectionProvider() {
return connectionProvider;
}
/**
* @param connectionProvider the connectionProvider to set
*/
public void setConnectionProvider(MongodbConnectionProvider connectionProvider) {
this.connectionProvider = connectionProvider;
}
/**
* @return the collection
*/
public String getCollection() {
return collection;
}
/**
* @param collection the collection to set
*/
public void setCollection(String collection) {
this.collection = collection;
}
}

View file

@ -0,0 +1,78 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.backend.mongodb;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import org.bson.types.ObjectId;
import net.forwardfire.vasc.backend.VascBackendAccessDataKey;
import net.forwardfire.vasc.backend.VascBackendException;
/**
* MongodbVascBackendAccessDataKey convert key type to string and back.
*
* @author Willem Cazander
* @version 1.0 Oct 26, 2014
*/
@SuppressWarnings("serial")
public class MongodbVascBackendAccessDataKey implements VascBackendAccessDataKey<ObjectId> {
private final Map<String,Class<?>> keyMapType;
public MongodbVascBackendAccessDataKey() {
keyMapType = new HashMap<String,Class<?>>(1);
keyMapType.put(AbstractMongodbVascBackend.PK_FIELD_NAME, ObjectId.class);
}
@Override
public Map<String, Class<?>> getKeyMapType() {
return keyMapType;
}
@Override
public Map<String, Serializable> getKeyMapFromPrimaryKey(ObjectId primaryKey) throws VascBackendException {
Map<String, Serializable> result = new HashMap<String,Serializable>(1);
result.put(MongodbVascBackendCrud.PK_FIELD_NAME, primaryKey);
return result;
}
@Override
public ObjectId getPrimaryKeyFromKeyMap(Map<String, Serializable> keyMap) throws VascBackendException {
return (ObjectId)keyMap.get(MongodbVascBackendCrud.PK_FIELD_NAME);
}
@Override
public Map<String, String> getStringMapFromPrimaryKey(ObjectId primaryKey) throws VascBackendException {
Map<String, String> result = new HashMap<String,String>(1);
result.put(MongodbVascBackendCrud.PK_FIELD_NAME, primaryKey.toString());
return result;
}
@Override
public ObjectId getPrimaryKeyFromStringMap(Map<String, String> keyMap) throws VascBackendException {
return new ObjectId(keyMap.get(MongodbVascBackendCrud.PK_FIELD_NAME));
}
}

View file

@ -20,41 +20,47 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package net.forwardfire.vasc.backend.data; package net.forwardfire.vasc.backend.mongodb;
import java.io.Serializable; import java.io.Serializable;
import net.forwardfire.vasc.backend.VascBackendException; import org.bson.types.ObjectId;
import net.forwardfire.vasc.backend.VascEntryRecordCreator;
import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascBackendAccessDataRecord;
import com.mongodb.BasicDBObject;
/** /**
* BeanVascEntryRecordCreator creates a new backend record based on class object. * Provides a mongodb field entry knowlege.
* *
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Dec 05, 2009 * @version 1.0 Dec 30, 2011
*/ */
public class BeanVascEntryRecordCreator<DATA_OBJECT extends Serializable> implements VascEntryRecordCreator<DATA_OBJECT> { @SuppressWarnings("serial")
public class MongodbVascBackendAccessDataRecord implements VascBackendAccessDataRecord<ObjectId,BasicDBObject> {
private static final long serialVersionUID = 1L; /**
private Class<?> resultClass = null; * @see net.forwardfire.vasc.backend.VascBackendAccessDataRecord#getPrimaryKey(java.io.Serializable)
*/
public BeanVascEntryRecordCreator(Class<?> resultClass) { @Override
if (resultClass==null) { public ObjectId getPrimaryKey(BasicDBObject record) throws VascBackendException {
throw new NullPointerException("Can't provide creator service with null class object."); return record.getObjectId(AbstractMongodbVascBackend.PK_FIELD_NAME);
}
this.resultClass=resultClass;
} }
@SuppressWarnings("unchecked") /**
* @see net.forwardfire.vasc.backend.VascBackendAccessDataRecord#getValue(java.lang.String, java.io.Serializable)
*/
@Override @Override
public DATA_OBJECT newRecord() throws VascBackendException { public Serializable getValue(String backendName, BasicDBObject record) throws VascBackendException {
try { return (Serializable) record.get(backendName);
return (DATA_OBJECT)resultClass.newInstance(); }
} catch (InstantiationException e) {
throw new VascBackendException(e); /**
} catch (IllegalAccessException e) { * @see net.forwardfire.vasc.backend.VascBackendAccessDataRecord#setValue(java.lang.String, java.io.Serializable, java.io.Serializable)
throw new VascBackendException(e); */
} @Override
public void setValue(String backendName, BasicDBObject record,Serializable value) throws VascBackendException {
record.put(backendName, value);
} }
} }

View file

@ -0,0 +1,91 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.backend.mongodb;
import java.util.logging.Logger;
import org.bson.types.ObjectId;
import net.forwardfire.vasc.backend.VascBackendAccessDataRecord;
import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.crud.VascBackendCrud;
import com.mongodb.DBCollection;
import com.mongodb.DBObject;
import com.mongodb.BasicDBObject;
import com.mongodb.WriteConcern;
import com.mongodb.WriteResult;
/**
* MongodbVascBackend Provides backend for mongodb.
*
* @author Willem Cazander
* @version 1.0 Dec 30, 2011
*/
public class MongodbVascBackendCrud extends AbstractMongodbVascBackend implements VascBackendCrud<ObjectId,BasicDBObject> {
private Logger logger = null;
public MongodbVascBackendCrud() {
logger = Logger.getLogger(MongodbVascBackendCrud.class.getName());
}
@Override
public BasicDBObject newRecord() throws VascBackendException {
return new BasicDBObject();
}
@Override
public BasicDBObject fetch(ObjectId recordPK) throws VascBackendException {
return (BasicDBObject)getDBCollection().findOne(new BasicDBObject(PK_FIELD_NAME,recordPK));
}
@Override
public BasicDBObject persist(BasicDBObject object) throws VascBackendException {
getDBCollection().insert(object);
return fetch(object.getObjectId(AbstractMongodbVascBackend.PK_FIELD_NAME));
}
@Override
public BasicDBObject merge(BasicDBObject row) throws VascBackendException {
DBCollection coll = getDBCollection();
DBObject query = new BasicDBObject();
query.put(AbstractMongodbVascBackend.PK_FIELD_NAME,row.getObjectId(AbstractMongodbVascBackend.PK_FIELD_NAME));
WriteResult wr = coll.update(query,row,false,false,WriteConcern.SAFE);
logger.finer("WriteResult: "+wr);
return fetch(row.getObjectId(AbstractMongodbVascBackend.PK_FIELD_NAME));
}
@Override
public void delete(ObjectId objectId) throws VascBackendException {
deleteById(objectId);
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#createVascBackendAccessDataRecord()
*/
@Override
public VascBackendAccessDataRecord<ObjectId, BasicDBObject> createVascBackendAccessDataRecord() {
return new MongodbVascBackendAccessDataRecord();
}
}

View file

@ -0,0 +1,127 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.backend.mongodb;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.logging.Logger;
import org.bson.types.ObjectId;
import net.forwardfire.vasc.backend.VascBackendAccessDataRecord;
import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.list.DefaultVascBackendListResult;
import net.forwardfire.vasc.backend.list.VascBackendList;
import net.forwardfire.vasc.backend.list.VascBackendListFeature;
import net.forwardfire.vasc.backend.list.VascBackendListResult;
import net.forwardfire.vasc.backend.list.VascBackendListRequest;
import com.mongodb.DBCollection;
import com.mongodb.DBCursor;
import com.mongodb.DBObject;
import com.mongodb.BasicDBObject;
/**
* MongodbVascBackendList Provides backend for mongodb.
*
* @author Willem Cazander
* @version 1.0 Dec 30, 2011
*/
public class MongodbVascBackendList extends AbstractMongodbVascBackend implements VascBackendList<ObjectId,BasicDBObject> {
private Logger logger = null;
private final EnumSet<VascBackendListFeature> features = EnumSet.noneOf(VascBackendListFeature.class);
private final List<String> rowActions = new ArrayList<String>();
public MongodbVascBackendList() {
logger = Logger.getLogger(MongodbVascBackendList.class.getName());
features.add(VascBackendListFeature.PAGE_DATA);
rowActions.add(ROW_ACTION_DELETE);
}
@Override
public EnumSet<VascBackendListFeature> getSupportedFeatures() {
return features;
}
private long fetchTotalExecuteSize(VascBackendListRequest state) {
DBCollection coll = getDBCollection();
DBObject query = createFilterQuery(state);
long result = coll.count(query);
return result;
}
private DBObject createFilterQuery(VascBackendListRequest state) {
DBObject query = new BasicDBObject();
for (String key:state.getDataParameterKeys()) {
Object value = state.getDataParameter(key);
query.put(key, value);
logger.finer("Setting query parameter key: '"+key+"' value: '"+value+"'");
}
return query;
}
@Override
public VascBackendListResult<BasicDBObject> execute(VascBackendListRequest state) throws VascBackendException {
return new DefaultVascBackendListResult<BasicDBObject>(executeList(state),fetchTotalExecuteSize(state));
}
private List<BasicDBObject> executeList(VascBackendListRequest state) throws VascBackendException {
DBCollection coll = getDBCollection();
DBObject query = createFilterQuery(state);
DBCursor cur = coll.find(query);
if (state.getPageSize()>0) {
cur.limit(state.getPageSize());
cur.skip(state.getPageIndex());
}
List<BasicDBObject> result = new ArrayList<BasicDBObject>(cur.count());
while (cur.hasNext()) {
DBObject row = cur.next();
result.add((BasicDBObject)row);
}
return result;
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#createVascBackendAccessDataRecord()
*/
@Override
public VascBackendAccessDataRecord<ObjectId, BasicDBObject> createVascBackendAccessDataRecord() {
return new MongodbVascBackendAccessDataRecord();
}
@Override
public List<String> getSupportedRowActions() {
return rowActions;
}
@Override
public void executeRowAction(VascBackendListRequest request,List<ObjectId> recordPKs, String actionName) throws VascBackendException {
if (ROW_ACTION_DELETE.equals(actionName)) {
for (ObjectId objectId:recordPKs) {
deleteById(objectId);
}
}
}
}

View file

@ -0,0 +1,70 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.backend.mongodb;
import java.util.ArrayList;
import java.util.List;
import org.bson.types.ObjectId;
import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.select.DefaultVascBackendSelectItem;
import net.forwardfire.vasc.backend.select.VascBackendSelect;
import net.forwardfire.vasc.backend.select.VascBackendSelectItem;
import com.mongodb.DBCollection;
import com.mongodb.DBCursor;
import com.mongodb.DBObject;
import com.mongodb.BasicDBObject;
/**
* MongodbVascBackendSelect Provides backend for mongodb.
*
* @author Willem Cazander
* @version 1.0 Dec 30, 2011
*/
public class MongodbVascBackendSelect extends AbstractMongodbVascBackend implements VascBackendSelect<ObjectId> {
@Override
public List<VascBackendSelectItem<ObjectId>> execute() throws VascBackendException {
DBCollection coll = getDBCollection();
DBObject query = new BasicDBObject();
DBCursor cur = coll.find(query);
List<VascBackendSelectItem<ObjectId>> result = new ArrayList<VascBackendSelectItem<ObjectId>>(cur.count());
while (cur.hasNext()) {
BasicDBObject row = (BasicDBObject)cur.next();
boolean header = false;
boolean enabled = true;
String name = row.getString("toto");
boolean nameI18nKey = false;
String description = row.getString("sdf");
boolean descriptionI18nKey = false;
ObjectId primaryKey = row.getObjectId(PK_FIELD_NAME);
result.add(new DefaultVascBackendSelectItem<ObjectId>(header,enabled,name,nameI18nKey,description,descriptionI18nKey,primaryKey));
}
return result;
}
}

View file

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>vasc-backend-object</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,18 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.forwardfire.vasc.backend</groupId>
<artifactId>vasc-backend</artifactId>
<version>0.4.2-SNAPSHOT</version>
</parent>
<artifactId>vasc-backend-object</artifactId>
<name>vasc-backend-object</name>
<description>vasc-backend-object</description>
<dependencies>
<dependency>
<groupId>net.forwardfire.vasc.backend</groupId>
<artifactId>vasc-backend-api</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

View file

@ -0,0 +1,141 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.backend.object;
import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import net.forwardfire.vasc.backend.AbstractVascBackendLocal;
import net.forwardfire.vasc.backend.VascBackendAccessDataKey;
import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.list.VascBackendListFeature;
import net.forwardfire.vasc.backend.select.DefaultVascBackendSelectItem;
import net.forwardfire.vasc.backend.select.VascBackendSelect;
import net.forwardfire.vasc.backend.select.VascBackendSelectItem;
/**
* ObjectEnumVascBackendSelect uses an Enum as select backend.
*
* @author Willem Cazander
* @version 1.0 Oct 27, 2007
*/
public class ObjectEnumVascBackendSelect<ENUM_RETURN_TYPE extends Serializable> extends AbstractVascBackendLocal<ENUM_RETURN_TYPE> implements VascBackendSelect<ENUM_RETURN_TYPE> {
private Class<? extends Enum<?>> enumClass = null;
private ObjectEnumVascBackendSelectType enumReturnType = null;
private String enumReturnMethod = null;
@Override
protected void startBackendLocal() {
requireNonNull(enumClass, "enumClass is null");
requireNonNull(enumReturnType, "enumClass is null");
}
@Override
public VascBackendAccessDataKey<ENUM_RETURN_TYPE> createVascBackendAccessDataKey() {
return null;
}
@Override
public List<VascBackendSelectItem<ENUM_RETURN_TYPE>> execute() throws VascBackendException {
List<VascBackendSelectItem<ENUM_RETURN_TYPE>> result = new ArrayList<VascBackendSelectItem<ENUM_RETURN_TYPE>>();
for (Enum<?> enumObject:enumClass.getEnumConstants()) {
boolean header = false;
boolean enabled = true;
String name = enumObject.name();
boolean nameI18nKey = false;
String description = enumObject.name();
boolean descriptionI18nKey = false;
ENUM_RETURN_TYPE primaryKey = (ENUM_RETURN_TYPE)getEnumValue(enumObject);
result.add(new DefaultVascBackendSelectItem<ENUM_RETURN_TYPE>(header,enabled,name,nameI18nKey,description,descriptionI18nKey,primaryKey));
}
return result;
}
private Object getEnumValue(Enum<?> enumObject) {
switch (enumReturnType) {
case VALUE:
return enumObject;
case METHOD:
try {
return enumObject.getClass().getMethod(enumReturnMethod, new Class<?>[]{}).invoke(null, new Object[]{});
} catch (Exception e) {
throw new IllegalStateException("Could not get static return method value: "+e.getMessage(),e);
}
case NAME:
return enumObject.name();
case ORDINAL:
return enumObject.ordinal();
default:
throw new IllegalStateException("Unknown enum return type: "+enumReturnType.name());
}
}
/*
public List<VascBackendSelectItem> getVascSelectItems(VascEntry currentEntry) throws VascException {
List<VascBackendSelectItem> result = new ArrayList<VascBackendSelectItem>(100);
if (nullLabel!=null) {
if (nullKeyValue==null) {
nullKeyValue = "null";
}
nullLabel = currentEntry.getVascFrontendController().getVascEntryResourceResolver().getTextValue(nullLabel);
VascBackendSelectItem item = new VascBackendSelectItem(nullLabel,null,nullKeyValue);
result.add(item);
}
if (enumClass!=null) {
for (Object o:enumClass.getEnumConstants()) {
String value = o.toString();
result.add(new VascBackendSelectItem(value,value,value));
}
}
if (data==null) {
return result;
}
if (data instanceof String) {
String[] values = ((String)data).split(",");
for (String value:values) {
result.add(new VascBackendSelectItem(value,value,value));
}
} else if (data instanceof List) {
List<?> values = (List<?>)data;
for (Object o:values) {
String value = ""+o;
result.add(new VascBackendSelectItem(value,value,value));
}
}
return result;
}
*/
}

View file

@ -0,0 +1,9 @@
package net.forwardfire.vasc.backend.object;
public enum ObjectEnumVascBackendSelectType {
VALUE,
NAME,
ORDINAL,
METHOD,
}

View file

@ -20,7 +20,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package net.forwardfire.vasc.impl.ui; package net.forwardfire.vasc.backend.object;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
@ -28,17 +28,11 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import net.forwardfire.vasc.backend.DefaultVascBackendState; import net.forwardfire.vasc.backend.VascBackendAccessDataRecord;
import net.forwardfire.vasc.backend.VascBackend; import net.forwardfire.vasc.backend.crud.VascBackendCrud;
import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.list.DefaultVascBackendListRequest;
import net.forwardfire.vasc.backend.VascEntryFieldValue; import net.forwardfire.vasc.backend.list.VascBackendListRequest;
import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.backend.select.VascBackendSelectItem;
import net.forwardfire.vasc.core.VascEntryField;
import net.forwardfire.vasc.core.VascEntryFieldLocal;
import net.forwardfire.vasc.core.VascEntryLocal;
import net.forwardfire.vasc.core.ui.VascSelectItem;
import net.forwardfire.vasc.core.ui.VascSelectItemModel;
import net.forwardfire.vasc.core.VascException;
/** /**
* The DefaultVascSelectItemModel * The DefaultVascSelectItemModel
@ -46,8 +40,9 @@ import net.forwardfire.vasc.core.VascException;
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Oct 27, 2007 * @version 1.0 Oct 27, 2007
*/ */
public class VascSelectItemModelEntry implements VascSelectItemModel { public class VascSelectItemModelEntry /*implements VascSelectItemModel*/ {
/*
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private String entryId = null; private String entryId = null;
private String keyFieldId = null; private String keyFieldId = null;
@ -59,12 +54,9 @@ public class VascSelectItemModelEntry implements VascSelectItemModel {
private Map<String,String> entryParameterFieldIds = new HashMap<String,String>(3); private Map<String,String> entryParameterFieldIds = new HashMap<String,String>(3);
private Boolean useParentFields = null; private Boolean useParentFields = null;
/**
* @see net.forwardfire.vasc.core.ui.VascSelectItemModel#getVascSelectItems(net.forwardfire.vasc.core.VascEntry)
*/
@Override @Override
public List<VascSelectItem> getVascSelectItems(VascEntry currentEntry) throws VascException { public List<VascBackendSelectItem> getVascSelectItems(VascEntry currentEntry) throws VascException {
List<VascSelectItem> result = new ArrayList<VascSelectItem>(100); List<VascBackendSelectItem> result = new ArrayList<VascBackendSelectItem>(100);
VascEntryLocal entry = (VascEntryLocal)currentEntry.getVascFrontendController().getVascController().getVascEntryController().getVascEntryById(entryId); VascEntryLocal entry = (VascEntryLocal)currentEntry.getVascFrontendController().getVascController().getVascEntryController().getVascEntryById(entryId);
if (keyFieldId==null) { if (keyFieldId==null) {
@ -85,7 +77,7 @@ public class VascSelectItemModelEntry implements VascSelectItemModel {
// set frontend data for new clone, we need te get better lifecycle management for stats/entry/etc // set frontend data for new clone, we need te get better lifecycle management for stats/entry/etc
entry.setVascFrontendController(currentEntry.getVascFrontendController()); entry.setVascFrontendController(currentEntry.getVascFrontendController());
VascBackend<Serializable> back = currentEntry.getVascFrontendController().getVascController().getVascEntryConfigController().configVascBackendProxied(currentEntry.getVascFrontendController().getVascController(), entry); VascBackendCrud<Serializable,Serializable> back = currentEntry.getVascFrontendController().getVascController().getVascEntryConfigController().configVascBackendProxied(currentEntry.getVascFrontendController().getVascController(), entry);
try { try {
if (nullLabel!=null) { if (nullLabel!=null) {
if (nullKeyValue==null) { if (nullKeyValue==null) {
@ -93,14 +85,14 @@ public class VascSelectItemModelEntry implements VascSelectItemModel {
} }
nullLabel = currentEntry.getVascFrontendController().getVascEntryResourceResolver().getTextValue(nullLabel); nullLabel = currentEntry.getVascFrontendController().getVascEntryResourceResolver().getTextValue(nullLabel);
if (nullObjectValue==null) { if (nullObjectValue==null) {
result.add(new VascSelectItem(nullLabel,null,nullKeyValue)); result.add(new VascBackendSelectItem(nullLabel,null,nullKeyValue));
} else { } else {
result.add(new VascSelectItem(nullLabel,nullObjectValue,nullKeyValue)); result.add(new VascBackendSelectItem(nullLabel,nullObjectValue,nullKeyValue));
} }
} }
// set def para // set def para
VascBackendState state = new DefaultVascBackendState(); DefaultVascBackendListRequest state = new DefaultVascBackendListRequest();
for (String key2:entry.getEntryParameterKeys()) { for (String key2:entry.getEntryParameterKeys()) {
Object value = entry.getEntryParameter(key2); Object value = entry.getEntryParameter(key2);
@ -137,7 +129,7 @@ public class VascSelectItemModelEntry implements VascSelectItemModel {
} }
VascEntryField field = fieldOrg.clone(); VascEntryField field = fieldOrg.clone();
field.getVascValidators().clear(); field.getVascValidators().clear();
VascEntryFieldValue<Serializable> v = fieldEntry.getVascFrontendController().getVascEntryState().getVascBackend().provideVascEntryFieldValue(); VascBackendAccessDataRecord<Serializable,Serializable> v = fieldEntry.getVascFrontendController().getVascEntryState().getVascBackend().provideVascEntryFieldValue();
Serializable record = fieldEntry.getVascFrontendController().getVascEntryState().getEntryDataObject(); Serializable record = fieldEntry.getVascFrontendController().getVascEntryState().getEntryDataObject();
if (record==null) { if (record==null) {
@ -157,7 +149,7 @@ public class VascSelectItemModelEntry implements VascSelectItemModel {
VascEntryField fieldClone = key.clone(); VascEntryField fieldClone = key.clone();
fieldClone.getVascValidators().clear(); fieldClone.getVascValidators().clear();
VascEntryFieldValue<Serializable> v = currentEntry.getVascFrontendController().getVascEntryState().getVascBackend().provideVascEntryFieldValue(); VascBackendAccessDataRecord<Serializable,Serializable> v = currentEntry.getVascFrontendController().getVascEntryState().getVascBackend().provideVascEntryFieldValue();
key.setVascEntryFieldValue(v); key.setVascEntryFieldValue(v);
} }
if (dis.getVascEntryFieldValue()==null) { if (dis.getVascEntryFieldValue()==null) {
@ -165,7 +157,7 @@ public class VascSelectItemModelEntry implements VascSelectItemModel {
VascEntryField fieldClone = dis.clone(); VascEntryField fieldClone = dis.clone();
fieldClone.getVascValidators().clear(); fieldClone.getVascValidators().clear();
VascEntryFieldValue<Serializable> v = currentEntry.getVascFrontendController().getVascEntryState().getVascBackend().provideVascEntryFieldValue(); VascBackendAccessDataRecord<Serializable,Serializable> v = currentEntry.getVascFrontendController().getVascEntryState().getVascBackend().provideVascEntryFieldValue();
dis.setVascEntryFieldValue(v); dis.setVascEntryFieldValue(v);
} }
@ -173,12 +165,12 @@ public class VascSelectItemModelEntry implements VascSelectItemModel {
// execute // execute
for (Serializable o:back.execute(state).getPageData()) { for (Serializable o:back.execute(state).getPageData()) {
Serializable keyId = key.getVascEntryFieldValue().getValue(key.getBackendName(), o); Serializable keyId = key.getVascEntryFieldValue().getValue(key.getBackendName(), o);
String nameId = dis.getVascEntryFieldValue().getDisplayValue(dis.getBackendName(), o); String nameId = ""+dis.getVascEntryFieldValue().getValue(dis.getBackendName(), o);
if (returnKeyValue!=null && false==returnKeyValue) { if (returnKeyValue!=null && false==returnKeyValue) {
VascSelectItem item = new VascSelectItem(nameId,o,""+keyId); VascBackendSelectItem item = new VascBackendSelectItem(nameId,o,""+keyId);
result.add(item); result.add(item);
} else { } else {
VascSelectItem item = new VascSelectItem(nameId,keyId,""+keyId); // per default return keyID object. VascBackendSelectItem item = new VascBackendSelectItem(nameId,keyId,""+keyId); // per default return keyID object.
result.add(item); result.add(item);
} }
} }
@ -187,132 +179,133 @@ public class VascSelectItemModelEntry implements VascSelectItemModel {
} }
return result; return result;
} }
/*
/** //
* @return the entryId // /**
*/ // * @return the entryId
public String getEntryId() { // */
return entryId; // public String getEntryId() {
} // return entryId;
// }
/** //
* @param entryId the entryId to set // /**
*/ // * @param entryId the entryId to set
public void setEntryId(String entryId) { // */
this.entryId = entryId; // public void setEntryId(String entryId) {
} // this.entryId = entryId;
// }
/** //
* @return the keyFieldId // /**
*/ // * @return the keyFieldId
public String getKeyFieldId() { // */
return keyFieldId; // public String getKeyFieldId() {
} // return keyFieldId;
// }
/** //
* @param keyFieldId the keyFieldId to set // /**
*/ // * @param keyFieldId the keyFieldId to set
public void setKeyFieldId(String keyFieldId) { // */
this.keyFieldId = keyFieldId; // public void setKeyFieldId(String keyFieldId) {
} // this.keyFieldId = keyFieldId;
// }
/** //
* @return the displayFieldId // /**
*/ // * @return the displayFieldId
public String getDisplayFieldId() { // */
return displayFieldId; // public String getDisplayFieldId() {
} // return displayFieldId;
// }
/** //
* @param displayFieldId the displayFieldId to set // /**
*/ // * @param displayFieldId the displayFieldId to set
public void setDisplayFieldId(String displayFieldId) { // */
this.displayFieldId = displayFieldId; // public void setDisplayFieldId(String displayFieldId) {
} // this.displayFieldId = displayFieldId;
// }
/** //
* @return the nullLabel // /**
*/ // * @return the nullLabel
@Override // */
public String getNullLabel() { // @Override
return nullLabel; // public String getNullLabel() {
} // return nullLabel;
// }
/** //
* @param nullLabel the nullLabel to set // /**
*/ // * @param nullLabel the nullLabel to set
@Override // */
public void setNullLabel(String nullLabel) { // @Override
this.nullLabel = nullLabel; // public void setNullLabel(String nullLabel) {
} // this.nullLabel = nullLabel;
// }
/** //
* @return the nullKeyValue // /**
*/ // * @return the nullKeyValue
@Override // */
public String getNullKeyValue() { // @Override
return nullKeyValue; // public String getNullKeyValue() {
} // return nullKeyValue;
// }
/** //
* @param nullKeyValue the nullKeyValue to set // /**
*/ // * @param nullKeyValue the nullKeyValue to set
@Override // */
public void setNullKeyValue(String nullKeyValue) { // @Override
this.nullKeyValue = nullKeyValue; // public void setNullKeyValue(String nullKeyValue) {
} // this.nullKeyValue = nullKeyValue;
// }
/** //
* @return the returnKeyValue // /**
*/ // * @return the returnKeyValue
public Boolean getReturnKeyValue() { // */
return returnKeyValue; // public Boolean getReturnKeyValue() {
} // return returnKeyValue;
// }
/** //
* @param returnKeyValue the returnKeyValue to set // /**
*/ // * @param returnKeyValue the returnKeyValue to set
public void setReturnKeyValue(Boolean returnKeyValue) { // */
this.returnKeyValue = returnKeyValue; // public void setReturnKeyValue(Boolean returnKeyValue) {
} // this.returnKeyValue = returnKeyValue;
// }
public String getEntryParameterFieldId(String parameterName) { //
return entryParameterFieldIds.get(parameterName); // public String getEntryParameterFieldId(String parameterName) {
} // return entryParameterFieldIds.get(parameterName);
public void addEntryParameterFieldId(String parameterName,String valueFieldId) { // }
entryParameterFieldIds.put(parameterName, valueFieldId); // public void addEntryParameterFieldId(String parameterName,String valueFieldId) {
} // entryParameterFieldIds.put(parameterName, valueFieldId);
public List<String> getEntryParameterFieldIdKeys() { // }
return new ArrayList<String>(entryParameterFieldIds.keySet()); // public List<String> getEntryParameterFieldIdKeys() {
} // return new ArrayList<String>(entryParameterFieldIds.keySet());
// }
/** //
* @return the useParentFields // /**
*/ // * @return the useParentFields
public Boolean getUseParentFields() { // */
return useParentFields; // public Boolean getUseParentFields() {
} // return useParentFields;
// }
/** //
* @param useParentFields the useParentFields to set // /**
*/ // * @param useParentFields the useParentFields to set
public void setUseParentFields(Boolean useParentFields) { // */
this.useParentFields = useParentFields; // public void setUseParentFields(Boolean useParentFields) {
} // this.useParentFields = useParentFields;
// }
/** //
* @return the nullObjectValue // /**
*/ // * @return the nullObjectValue
public String getNullObjectValue() { // */
return nullObjectValue; // public String getNullObjectValue() {
} // return nullObjectValue;
// }
/** //
* @param nullObjectValue the nullObjectValue to set // /**
*/ // * @param nullObjectValue the nullObjectValue to set
public void setNullObjectValue(String nullObjectValue) { // */
this.nullObjectValue = nullObjectValue; // public void setNullObjectValue(String nullObjectValue) {
} // this.nullObjectValue = nullObjectValue;
// }
//
} }

View file

@ -0,0 +1,8 @@
/**
*
*/
/**
* @author willemc
*
*/
package net.forwardfire.vasc.backend.object;

View file

@ -4,12 +4,12 @@ import java.io.Serializable;
import junit.framework.TestCase; import junit.framework.TestCase;
import net.forwardfire.vasc.backend.DefaultVascBackendController; import net.forwardfire.vasc.backend.DefaultVascBackendController;
import net.forwardfire.vasc.backend.DefaultVascBackendState; import net.forwardfire.vasc.backend.VascBackendAccessDataRecord;
import net.forwardfire.vasc.backend.VascBackend; import net.forwardfire.vasc.backend.crud.VascBackendCrud;
import net.forwardfire.vasc.backend.VascBackendResult; import net.forwardfire.vasc.backend.list.DefaultVascBackendListRequest;
import net.forwardfire.vasc.backend.VascEntryFieldValue; import net.forwardfire.vasc.backend.list.VascBackendListResult;
import net.forwardfire.vasc.backend.metamodel.MetaModelDataContextJdbc; import net.forwardfire.vasc.backend.metamodel.MetaModelDataContextJdbc;
import net.forwardfire.vasc.backend.metamodel.MetaModelVascBackend; import net.forwardfire.vasc.backend.metamodel.MetaModelVascBackendCrud;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -27,7 +27,7 @@ public class CrudTest extends TestCase {
mmDB.setUsername("postgres"); mmDB.setUsername("postgres");
mmDB.setPassword("postgresql"); mmDB.setPassword("postgresql");
MetaModelVascBackend mm = new MetaModelVascBackend(); MetaModelVascBackendCrud mm = new MetaModelVascBackendCrud();
mm.setId("mm"); mm.setId("mm");
mm.setTable("country"); mm.setTable("country");
mm.setTableId("country_id"); mm.setTableId("country_id");
@ -42,21 +42,23 @@ public class CrudTest extends TestCase {
setup(); setup();
VascBackend<Serializable> backend = (VascBackend<Serializable>) backends.getVascBackendById("mm"); VascBackendCrud<Serializable,Serializable> backend = (VascBackendCrud<Serializable,Serializable>) backends.getVascBackendById(VascBackendCrud.class,"mm");
assertNotNull(backend); assertNotNull(backend);
DefaultVascBackendState state = new DefaultVascBackendState();
VascBackendResult<Serializable> result = backend.execute(state);
assertNotNull(result);
assertFalse(result.getPageData().isEmpty());
VascEntryFieldValue<Serializable> values = backend.provideVascEntryFieldValue(); //
// DefaultVascBackendListRequest state = new DefaultVascBackendListRequest();
for (Serializable record:result.getPageData()) { // VascBackendListResult<Serializable> result = backend.execute(state);
Object id = values.getValue("country_id", record); // assertNotNull(result);
Object name = values.getValue("name", record); // assertFalse(result.getData().isEmpty());
Object code = values.getValue("code", record); //
System.out.println("line: "+id+" name: "+name+" code: "+code); // VascBackendAccessDataRecord<Serializable,Serializable> values = backend.provideVascEntryFieldValue();
} //
// for (Serializable record:result.getData()) {
// Object id = values.getValue("country_id", record);
// Object name = values.getValue("name", record);
// Object code = values.getValue("code", record);
// System.out.println("line: "+id+" name: "+name+" code: "+code);
// }
} }
} }

View file

@ -1,24 +1,25 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<modelVersion>4.0.0</modelVersion> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <modelVersion>4.0.0</modelVersion>
<groupId>net.forwardfire.vasc</groupId> <parent>
<artifactId>vasc</artifactId> <groupId>net.forwardfire.vasc</groupId>
<version>0.4.2-SNAPSHOT</version> <artifactId>vasc</artifactId>
</parent> <version>0.4.2-SNAPSHOT</version>
<artifactId>vasc-core-ejb3-client</artifactId> </parent>
<name>vasc-core-ejb3-client</name> <artifactId>vasc-core-ejb3-client</artifactId>
<description>vasc-core-ejb3-client</description> <name>vasc-core-ejb3-client</name>
<dependencies> <description>vasc-core-ejb3-client</description>
<dependency> <dependencies>
<groupId>net.forwardfire.vasc</groupId> <dependency>
<artifactId>vasc-core</artifactId> <groupId>net.forwardfire.vasc</groupId>
<version>${project.version}</version> <artifactId>vasc-core</artifactId>
</dependency> <version>${project.version}</version>
<dependency> </dependency>
<groupId>javax.ejb</groupId> <dependency>
<artifactId>ejb-api</artifactId> <groupId>javax</groupId>
<version>${ejb-api.version}</version> <artifactId>javaee-api</artifactId>
<scope>provided</scope> <version>${javaee-api.version}</version>
</dependency> <scope>provided</scope>
</dependencies> </dependency>
</dependencies>
</project> </project>

View file

@ -26,12 +26,12 @@ import java.io.Serializable;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import net.forwardfire.vasc.backend.VascBackend;
import net.forwardfire.vasc.backend.VascBackendException; import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascBackendResult; import net.forwardfire.vasc.backend.VascBackendAccessDataRecord;
import net.forwardfire.vasc.backend.VascBackendState;
import net.forwardfire.vasc.backend.VascEntryFieldValue;
import net.forwardfire.vasc.backend.VascEntryRecordCreator; import net.forwardfire.vasc.backend.VascEntryRecordCreator;
import net.forwardfire.vasc.backend.crud.VascBackendCrud;
import net.forwardfire.vasc.backend.list.VascBackendListResult;
import net.forwardfire.vasc.backend.list.VascBackendListRequest;
/** /**
* VascServiceRemoteBackend wraps VascBasckend to the ejb3 context. * VascServiceRemoteBackend wraps VascBasckend to the ejb3 context.
@ -39,7 +39,7 @@ import net.forwardfire.vasc.backend.VascEntryRecordCreator;
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 18 Nov 2012 * @version 1.0 18 Nov 2012
*/ */
public class VascServiceRemoteBackend<DATA_OBJECT extends Serializable> implements VascBackend<DATA_OBJECT> { public class VascServiceRemoteBackend<DATA_OBJECT extends Serializable,DATA_PK extends Serializable> implements VascBackendCrud<DATA_OBJECT,DATA_PK> {
private String backendId = null; private String backendId = null;
private VascServiceManager vascManager = null; private VascServiceManager vascManager = null;
@ -68,13 +68,13 @@ public class VascServiceRemoteBackend<DATA_OBJECT extends Serializable> implemen
// we cant change id // we cant change id
} }
public void delete(DATA_OBJECT object) throws VascBackendException { public void delete(DATA_PK object) throws VascBackendException {
Object[] args = new Object[1]; Object[] args = new Object[1];
args[0]=object; args[0]=object;
vascManager.invokeBackendMethod(backendId, "delete", args); vascManager.invokeBackendMethod(backendId, "delete", args);
} }
public long doRecordMoveDownById(VascBackendState state,Object primaryId) throws VascBackendException { public long doRecordMoveDownById(VascBackendListRequest state,Object primaryId) throws VascBackendException {
Object[] args = new Object[2]; Object[] args = new Object[2];
args[0]=state; args[0]=state;
args[1]=primaryId; args[1]=primaryId;
@ -82,7 +82,7 @@ public class VascServiceRemoteBackend<DATA_OBJECT extends Serializable> implemen
return (Long)result; return (Long)result;
} }
public long doRecordMoveUpById(VascBackendState state, Object primaryId) throws VascBackendException { public long doRecordMoveUpById(VascBackendListRequest state, Object primaryId) throws VascBackendException {
Object[] args = new Object[2]; Object[] args = new Object[2];
args[0]=state; args[0]=state;
args[1]=primaryId; args[1]=primaryId;
@ -91,14 +91,14 @@ public class VascServiceRemoteBackend<DATA_OBJECT extends Serializable> implemen
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public VascBackendResult<DATA_OBJECT> execute(VascBackendState state) throws VascBackendException { public VascBackendListResult<DATA_OBJECT> execute(VascBackendListRequest state) throws VascBackendException {
Object[] args = new Object[1]; Object[] args = new Object[1];
args[0]=state; args[0]=state;
Object result = vascManager.invokeBackendMethod(backendId, "execute", args); Object result = vascManager.invokeBackendMethod(backendId, "execute", args);
return (VascBackendResult<DATA_OBJECT>)result; return (VascBackendListResult<DATA_OBJECT>)result;
} }
public long fetchTotalExecuteSize(VascBackendState state) { public long fetchTotalExecuteSize(VascBackendListRequest state) {
Object[] args = new Object[1]; Object[] args = new Object[1];
args[0]=state; args[0]=state;
Object result = vascManager.invokeBackendMethod(backendId, "fetchTotalExecuteSize", args); Object result = vascManager.invokeBackendMethod(backendId, "fetchTotalExecuteSize", args);
@ -144,10 +144,10 @@ public class VascServiceRemoteBackend<DATA_OBJECT extends Serializable> implemen
} }
@Override @Override
public VascEntryFieldValue provideVascEntryFieldValue() { public VascBackendAccessDataRecord provideVascEntryFieldValue() {
Object[] args = new Object[0]; Object[] args = new Object[0];
Object result = vascManager.invokeBackendMethod(backendId, "provideVascEntryFieldValue", args); Object result = vascManager.invokeBackendMethod(backendId, "provideVascEntryFieldValue", args);
return (VascEntryFieldValue)result; return (VascBackendAccessDataRecord)result;
} }
@Override @Override

View file

@ -1,35 +1,30 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<modelVersion>4.0.0</modelVersion> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <modelVersion>4.0.0</modelVersion>
<groupId>net.forwardfire.vasc</groupId> <parent>
<artifactId>vasc</artifactId>
<version>0.4.2-SNAPSHOT</version>
</parent>
<artifactId>vasc-core-ejb3-server</artifactId>
<name>vasc-core-ejb3-server</name>
<description>vasc-core-ejb3-server</description>
<dependencies>
<dependency>
<groupId>net.forwardfire.vasc</groupId> <groupId>net.forwardfire.vasc</groupId>
<artifactId>vasc-core-ejb3-client</artifactId> <artifactId>vasc</artifactId>
<version>${project.version}</version> <version>0.4.2-SNAPSHOT</version>
</dependency> </parent>
<dependency> <artifactId>vasc-core-ejb3-server</artifactId>
<groupId>net.forwardfire.vasc.backend</groupId> <name>vasc-core-ejb3-server</name>
<artifactId>vasc-backend-jpa</artifactId> <description>vasc-core-ejb3-server</description>
<version>${project.version}</version> <dependencies>
</dependency> <dependency>
<dependency> <groupId>net.forwardfire.vasc</groupId>
<groupId>javax.ejb</groupId> <artifactId>vasc-core-ejb3-client</artifactId>
<artifactId>ejb-api</artifactId> <version>${project.version}</version>
<version>${ejb-api.version}</version> </dependency>
<scope>provided</scope> <dependency>
</dependency> <groupId>net.forwardfire.vasc.backend</groupId>
<dependency> <artifactId>vasc-backend-jpa</artifactId>
<groupId>javax.persistence</groupId> <version>${project.version}</version>
<artifactId>persistence-api</artifactId> </dependency>
<version>${persistence-api.version}</version> <dependency>
<scope>provided</scope> <groupId>javax</groupId>
</dependency> <artifactId>javaee-api</artifactId>
</dependencies> <version>${javaee-api.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project> </project>

View file

@ -45,7 +45,7 @@ import javax.persistence.EntityManager;
import org.x4o.xml.io.X4OReader; import org.x4o.xml.io.X4OReader;
import net.forwardfire.vasc.backend.VascBackend; import net.forwardfire.vasc.backend.crud.VascBackendCrud;
import net.forwardfire.vasc.backends.jpa.EntityManagerProvider; import net.forwardfire.vasc.backends.jpa.EntityManagerProvider;
import net.forwardfire.vasc.core.VascController; import net.forwardfire.vasc.core.VascController;
import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntry;
@ -224,7 +224,7 @@ public class VascServiceManagerImpl implements VascServiceManagerRemote,VascServ
public Object invokeBackendMethod(String backendId,String method,Object[] args) { public Object invokeBackendMethod(String backendId,String method,Object[] args) {
VascController v = getVascController(); VascController v = getVascController();
VascBackend vb = v.getVascBackendController().getVascBackendById(backendId); VascBackendCrud vb = v.getVascBackendController().getVascBackendById(backendId);
Method vbm = null; Method vbm = null;
for (Method m:vb.getClass().getMethods()) { for (Method m:vb.getClass().getMethods()) {
if (m.getName().equals(method)) { if (m.getName().equals(method)) {

View file

@ -1,46 +1,47 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<modelVersion>4.0.0</modelVersion> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent> <modelVersion>4.0.0</modelVersion>
<artifactId>vasc</artifactId> <parent>
<groupId>net.forwardfire.vasc</groupId> <artifactId>vasc</artifactId>
<version>0.4.2-SNAPSHOT</version> <groupId>net.forwardfire.vasc</groupId>
</parent> <version>0.4.2-SNAPSHOT</version>
<artifactId>vasc-core</artifactId> </parent>
<name>vasc-core</name> <artifactId>vasc-core</artifactId>
<description>vasc-core</description> <name>vasc-core</name>
<dependencies> <description>vasc-core</description>
<dependency> <dependencies>
<groupId>org.x4o</groupId> <dependency>
<artifactId>x4o-driver</artifactId> <groupId>org.x4o</groupId>
<version>${x4o.version}</version> <artifactId>x4o-driver</artifactId>
</dependency> <version>${x4o.version}</version>
<dependency> </dependency>
<groupId>org.x4o</groupId> <dependency>
<artifactId>x4o-meta</artifactId> <groupId>org.x4o</groupId>
<version>${x4o.version}</version> <artifactId>x4o-meta</artifactId>
</dependency> <version>${x4o.version}</version>
<dependency> </dependency>
<groupId>net.forwardfire.vasc.backend</groupId> <dependency>
<artifactId>vasc-backend-api</artifactId> <groupId>net.forwardfire.vasc.backend</groupId>
<version>${project.version}</version> <artifactId>vasc-backend-api</artifactId>
</dependency> <version>${project.version}</version>
<dependency> </dependency>
<groupId>javax.persistence</groupId> <dependency>
<artifactId>persistence-api</artifactId> <groupId>javax</groupId>
<version>${persistence-api.version}</version> <artifactId>javaee-api</artifactId>
<scope>provided</scope> <version>${javaee-api.version}</version>
</dependency> <scope>provided</scope>
<dependency> </dependency>
<groupId>org.hibernate</groupId> <dependency>
<artifactId>hibernate-validator</artifactId> <groupId>org.hibernate</groupId>
<version>${hibernate-validator.version}</version> <artifactId>hibernate-validator</artifactId>
<scope>provided</scope> <version>${hibernate-validator.version}</version>
</dependency> <scope>provided</scope>
<dependency> </dependency>
<groupId>de.odysseus.juel</groupId> <dependency>
<artifactId>juel</artifactId> <groupId>de.odysseus.juel</groupId>
<version>2.1.0</version> <artifactId>juel</artifactId>
<scope>test</scope> <version>2.1.0</version>
</dependency> <scope>test</scope>
</dependencies> </dependency>
</dependencies>
</project> </project>

View file

@ -26,7 +26,7 @@ import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.forwardfire.vasc.core.ui.VascSelectItem; import net.forwardfire.vasc.backend.select.VascBackendSelectItem;
import net.forwardfire.vasc.core.ui.VascSelectItemModel; import net.forwardfire.vasc.core.ui.VascSelectItemModel;
import net.forwardfire.vasc.core.VascException; import net.forwardfire.vasc.core.VascException;
@ -54,8 +54,8 @@ public class VascChoicesSelectItemModel implements VascSelectItemModel,Serializa
* @see net.forwardfire.vasc.core.ui.VascSelectItemModel#getVascSelectItems(net.forwardfire.vasc.core.VascEntry) * @see net.forwardfire.vasc.core.ui.VascSelectItemModel#getVascSelectItems(net.forwardfire.vasc.core.VascEntry)
*/ */
@Override @Override
public List<VascSelectItem> getVascSelectItems(net.forwardfire.vasc.core.VascEntry entry) throws VascException { public List<VascBackendSelectItem> getVascSelectItems(net.forwardfire.vasc.core.VascEntry entry) throws VascException {
List<VascSelectItem> result = new ArrayList<VascSelectItem>(10); List<VascBackendSelectItem> result = new ArrayList<VascBackendSelectItem>(10);
if ("null".equals(vascChoices.nullLabel())==false) { if ("null".equals(vascChoices.nullLabel())==false) {
nullLabel = vascChoices.nullLabel(); nullLabel = vascChoices.nullLabel();
nullKeyValue = vascChoices.nullKeyValue(); nullKeyValue = vascChoices.nullKeyValue();
@ -65,7 +65,7 @@ public class VascChoicesSelectItemModel implements VascSelectItemModel,Serializa
nullKeyValue = "null"; nullKeyValue = "null";
} }
String nullLabelText = entry.getVascFrontendController().getVascEntryResourceResolver().getTextValue(nullLabel); String nullLabelText = entry.getVascFrontendController().getVascEntryResourceResolver().getTextValue(nullLabel);
VascSelectItem item = new VascSelectItem(nullLabelText,null,nullKeyValue); VascBackendSelectItem item = new VascBackendSelectItem(nullLabelText,null,nullKeyValue);
result.add(item); result.add(item);
} }
int index = 0; int index = 0;
@ -78,7 +78,7 @@ public class VascChoicesSelectItemModel implements VascSelectItemModel,Serializa
throw new IllegalStateException("Can't have unequal sizes of array of keys and values of vascChoices annotation."); throw new IllegalStateException("Can't have unequal sizes of array of keys and values of vascChoices annotation.");
} }
for (String key:a) { for (String key:a) {
VascSelectItem item = new VascSelectItem(); VascBackendSelectItem item = new VascBackendSelectItem();
String name = null; String name = null;
if (val) { if (val) {
name = key; name = key;

View file

@ -23,13 +23,14 @@
package net.forwardfire.vasc.backend.proxy; package net.forwardfire.vasc.backend.proxy;
import java.io.Serializable; import java.io.Serializable;
import java.util.EnumSet;
import java.util.List;
import net.forwardfire.vasc.backend.VascBackend;
import net.forwardfire.vasc.backend.VascBackendException; import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascBackendResult; import net.forwardfire.vasc.backend.list.VascBackendList;
import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.list.VascBackendListFeature;
import net.forwardfire.vasc.backend.VascEntryFieldValue; import net.forwardfire.vasc.backend.list.VascBackendListResult;
import net.forwardfire.vasc.backend.VascEntryRecordCreator; import net.forwardfire.vasc.backend.list.VascBackendListRequest;
import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntry;
/** /**
@ -38,19 +39,25 @@ import net.forwardfire.vasc.core.VascEntry;
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Apr 1, 2009 * @version 1.0 Apr 1, 2009
*/ */
abstract public class AbstractVascBackendProxy implements VascBackendProxy { abstract public class AbstractVascBackendProxy<DATA_PK extends Serializable,DATA_RECORD extends Serializable> implements VascBackendProxy<DATA_PK,DATA_RECORD> {
protected VascBackend<Serializable> backend = null; protected VascBackendList<DATA_PK,DATA_RECORD> backend = null;
protected VascEntry entry = null; protected VascEntry entry = null;
private volatile boolean running = false;
@Override @Override
abstract public VascBackendProxy clone() throws CloneNotSupportedException; abstract public VascBackendProxy<DATA_PK,DATA_RECORD> clone() throws CloneNotSupportedException;
protected void startBackendProxy() {
}
protected void stopBackendProxy() {
}
/** /**
* @see net.forwardfire.vasc.backend.proxy.VascBackendProxy#initProxy(net.forwardfire.vasc.backend.VascBackend, net.forwardfire.vasc.core.VascEntry) * @see net.forwardfire.vasc.backend.proxy.VascBackendProxy#initProxy(net.forwardfire.vasc.backend.crud.VascBackendList, net.forwardfire.vasc.core.VascEntry)
*/ */
@Override @Override
public void initProxy(VascBackend<Serializable> backend, VascEntry entry) { final public void initProxy(VascBackendList<DATA_PK,DATA_RECORD> backend, VascEntry entry) {
if (backend==null) { if (backend==null) {
throw new NullPointerException("backend object may not be null."); throw new NullPointerException("backend object may not be null.");
} }
@ -59,6 +66,33 @@ abstract public class AbstractVascBackendProxy implements VascBackendProxy {
} }
this.backend=backend; this.backend=backend;
this.entry=entry; this.entry=entry;
startBackend();
}
/**
* @see net.forwardfire.vasc.backend.VascBackendLifeCycle#startBackend()
*/
@Override
final public void startBackend() {
startBackendProxy();
running = true;
}
/**
* @see net.forwardfire.vasc.backend.VascBackendLifeCycle#stopBackend()
*/
@Override
final public void stopBackend() {
running = false;
stopBackendProxy();
}
/**
* @see net.forwardfire.vasc.backend.VascBackendLifeCycle#isRunning()
*/
@Override
public boolean isRunning() {
return running;
} }
/** /**
@ -70,104 +104,7 @@ abstract public class AbstractVascBackendProxy implements VascBackendProxy {
} }
/** /**
* @see net.forwardfire.vasc.backend.VascBackend#startBackend() * @see net.forwardfire.vasc.backend.crud.VascBackendCrud#getId()
*/
@Override
public void startBackend() {
backend.startBackend();
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#stopBackend()
*/
@Override
public void stopBackend() {
backend.stopBackend();
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#isReadOnly()
*/
@Override
public boolean isReadOnly() {
return backend.isReadOnly();
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#isSortable()
*/
@Override
public boolean isSortable() {
return backend.isSortable();
}
/**
* @throws Exception
* @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state)
*/
@Override
public VascBackendResult<Serializable> execute(VascBackendState state) throws VascBackendException {
return backend.execute(state);
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#delete(java.lang.Object)
*/
@Override
public void delete(Serializable object) throws VascBackendException {
backend.delete(object);
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#isPageable()
*/
@Override
public boolean isPageable() {
return backend.isPageable();
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#isSearchable()
*/
@Override
public boolean isSearchable() {
return backend.isSearchable();
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#merge(java.lang.Object)
*/
@Override
public Serializable merge(Serializable object) throws VascBackendException {
return backend.merge(object);
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#persist(java.lang.Object)
*/
@Override
public void persist(Serializable object) throws VascBackendException {
backend.persist(object);
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryFieldValue()
*/
@Override
public VascEntryFieldValue<Serializable> provideVascEntryFieldValue() {
return backend.provideVascEntryFieldValue();
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryRecordCreator()
*/
@Override
public VascEntryRecordCreator<Serializable> provideVascEntryRecordCreator() {
return backend.provideVascEntryRecordCreator();
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#getId()
*/ */
@Override @Override
public String getId() { public String getId() {
@ -175,50 +112,25 @@ abstract public class AbstractVascBackendProxy implements VascBackendProxy {
} }
/** /**
* @see net.forwardfire.vasc.backend.VascBackend#setId(java.lang.String) * @see net.forwardfire.vasc.backend.list.VascBackendList#getSupportedFeatures()
*/ */
@Override @Override
public void setId(String id) { public EnumSet<VascBackendListFeature> getSupportedFeatures() {
backend.setId(id); return backend.getSupportedFeatures(); // backend will always provide cloned copy
} }
/**
* @see net.forwardfire.vasc.core.VascBackend#doRecordMoveDownById(VascBackendState state,java.lang.Object)
*/
@Override @Override
public long doRecordMoveDownById(VascBackendState state,Object primaryId) throws VascBackendException { public VascBackendListResult<DATA_RECORD> execute(VascBackendListRequest request) throws VascBackendException {
return backend.doRecordMoveDownById(state,primaryId); return backend.execute(request);
} }
/**
* @see net.forwardfire.vasc.core.VascBackend#doRecordMoveUpById(VascBackendState state,java.lang.Object)
*/
@Override @Override
public long doRecordMoveUpById(VascBackendState state,Object primaryId) throws VascBackendException { public List<String> getSupportedRowActions() {
return backend.doRecordMoveUpById(state,primaryId); return backend.getSupportedRowActions();
} }
/**
* @see net.forwardfire.vasc.backend.VascBackend#isRecordMoveable()
*/
@Override @Override
public boolean isRecordMoveable() { public void executeRowAction(VascBackendListRequest request,List<DATA_PK> recordPKs,String actionName) throws VascBackendException {
return backend.isRecordMoveable(); executeRowAction(request, recordPKs, actionName);
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#hasPageSummary()
*/
@Override
public boolean hasPageSummary() {
return backend.hasPageSummary();
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#hasTotalSummary()
*/
@Override
public boolean hasTotalSummary() {
return backend.hasTotalSummary();
} }
} }

View file

@ -20,88 +20,45 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package net.forwardfire.vasc.core.ui; package net.forwardfire.vasc.backend.proxy;
import java.io.Serializable; import java.io.Serializable;
import java.util.EnumSet;
import net.forwardfire.vasc.backend.list.VascBackendListFeature;
/** /**
* AbstractVascBackendProxyFeature to implement single features of the backend.
* *
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Aug 12, 2007 * @version 1.0 Aug 27, 2014
*/ */
public class VascSelectItem { abstract public class AbstractVascBackendProxyFeature<DATA_PK extends Serializable,DATA_RECORD extends Serializable> extends AbstractVascBackendProxy<DATA_PK,DATA_RECORD> {
private String label = null; private final VascBackendListFeature proxyFeature;
private Serializable value = null; private final VascBackendListFeature proxyFeatureExtraFlag;
private String keyValue = null;
private boolean disabled = false;
public VascSelectItem() { protected AbstractVascBackendProxyFeature(VascBackendListFeature proxyFeature,VascBackendListFeature proxyFeatureExtraFlag) {
this.proxyFeature=proxyFeature;
} this.proxyFeatureExtraFlag=proxyFeatureExtraFlag;
public VascSelectItem(String label,Serializable value) {
setLabel(label);
setValue(value);
}
public VascSelectItem(String label,Serializable value,String keyValue) {
setLabel(label);
setValue(value);
setKeyValue(keyValue);
} }
/** /**
* @return the label * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#isProxyNeeded()
*/ */
public String getLabel() { @Override
return label; final public boolean isProxyNeeded() {
return !backend.getSupportedFeatures().contains(proxyFeature);
} }
/** /**
* @param label the label to set * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#getSupportedFeatures()
*/ */
public void setLabel(String label) { @Override
this.label = label; final public EnumSet<VascBackendListFeature> getSupportedFeatures() {
} EnumSet<VascBackendListFeature> result = super.getSupportedFeatures();
result.add(proxyFeature);
/** result.add(proxyFeatureExtraFlag);
* @return the value return result;
*/
public Serializable getValue() {
return value;
}
/**
* @param value the value to set
*/
public void setValue(Serializable value) {
this.value = value;
}
/**
* @return the keyValue
*/
public String getKeyValue() {
return keyValue;
}
/**
* @param keyValue the keyValue to set
*/
public void setKeyValue(String keyValue) {
this.keyValue = keyValue;
}
/**
* @return the disabled
*/
public boolean isDisabled() {
return disabled;
}
/**
* @param disabled the disabled to set
*/
public void setDisabled(boolean disabled) {
this.disabled = disabled;
} }
} }

View file

@ -24,7 +24,8 @@ package net.forwardfire.vasc.backend.proxy;
import java.io.Serializable; import java.io.Serializable;
import net.forwardfire.vasc.backend.VascBackend; import net.forwardfire.vasc.backend.VascBackendLifeCycle;
import net.forwardfire.vasc.backend.list.VascBackendList;
import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntry;
/** /**
@ -33,11 +34,11 @@ import net.forwardfire.vasc.core.VascEntry;
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 May 9, 2012 * @version 1.0 May 9, 2012
*/ */
public interface VascBackendProxy extends VascBackend<Serializable>,Cloneable { public interface VascBackendProxy<DATA_PK extends Serializable,DATA_RECORD extends Serializable> extends VascBackendList<DATA_PK,DATA_RECORD>,VascBackendLifeCycle<DATA_PK>,Cloneable {
void initProxy(VascBackend<Serializable> backend,VascEntry entry); void initProxy(VascBackendList<DATA_PK,DATA_RECORD> backend,VascEntry entry);
boolean isProxyNeeded(); boolean isProxyNeeded();
VascBackendProxy clone() throws CloneNotSupportedException; VascBackendProxy<DATA_PK,DATA_RECORD> clone() throws CloneNotSupportedException;
} }

View file

@ -1,167 +0,0 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.backend.proxy;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascBackendResult;
import net.forwardfire.vasc.backend.VascBackendState;
/**
* Does simple caching for the data.
*
* @author Willem Cazander
* @version 1.0 Nov 19, 2009
*/
public class VascBackendProxyCache extends AbstractVascBackendProxy {
private VascBackendResult<Serializable> data = null;
private String searchString = null;
private Map<String,Object> dataState = null;
private int pageIndex = 0;
private int pageSize = 0;
private int pageSizeMax = 0;
private String sortField = null;
private boolean sortDir = true;
private boolean requestFlush = false;
public VascBackendProxyCache() {
dataState = new HashMap<String,Object>(10);
}
/**
* @see java.lang.Object#clone()
*/
@Override
public VascBackendProxy clone() throws CloneNotSupportedException {
VascBackendProxyCache result = new VascBackendProxyCache();
return result;
}
private boolean isStateChanged(VascBackendState state) {
boolean changed = false;
for (String key:state.getDataParameterKeys()) {
Object value = state.getDataParameter(key);
Object valueLast = dataState.get(key);
dataState.put(key, value);
if (value==null & valueLast==null) {
continue;
}
if (value==null & valueLast!=null) {
changed = true;
break;
}
if (value.equals(valueLast)==false) {
changed = true;
break;
}
}
if (state.getSortField()!=null && state.getSortField().equals(sortField)==false) {
changed = true;
}
sortField = state.getSortField();
if (state.isSortAscending()==sortDir) {
changed = true;
}
sortDir = state.isSortAscending();
if (state.getPageSizeMax()==pageSizeMax) {
changed = true;
}
pageSizeMax = state.getPageSizeMax();
if (state.getPageSize()==pageSize) {
changed = true;
}
pageSize = state.getPageSize();
if (state.getPageIndex()==pageIndex) {
changed = true;
}
pageIndex = state.getPageIndex();
if (state.getSearchString()!=null && state.getSearchString().equals(searchString)==false) {
changed = true;
}
searchString = state.getSearchString();
if (requestFlush) {
requestFlush = false;
changed = true;
}
return changed;
}
/**
* @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#stopBackend()
*/
@Override
public void stopBackend() {
super.stopBackend();
data = null;
dataState.clear();
requestFlush = true;
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state)
*/
@Override
public VascBackendResult<Serializable> execute(VascBackendState state) throws VascBackendException {
boolean changed = isStateChanged(state);
if (data==null | changed) {
data = backend.execute(state);
}
return data;
}
/**
* @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#delete(java.lang.Object)
*/
@Override
public void delete(Serializable object) throws VascBackendException {
requestFlush = true;
super.delete(object);
}
/**
* @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#merge(java.lang.Object)
*/
@Override
public Serializable merge(Serializable object) throws VascBackendException {
requestFlush = true;
return super.merge(object);
}
/**
* @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#persist(java.lang.Object)
*/
@Override
public void persist(Serializable object) throws VascBackendException {
requestFlush = true;
super.persist(object);
}
}

View file

@ -26,10 +26,10 @@ import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.forwardfire.vasc.backend.VascBackend;
import net.forwardfire.vasc.backend.VascBackendException; import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascBackendResult; import net.forwardfire.vasc.backend.crud.VascBackendCrud;
import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.list.VascBackendListResult;
import net.forwardfire.vasc.backend.list.VascBackendListRequest;
import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntry;
import net.forwardfire.vasc.core.entry.VascEntryBackendEventListener; import net.forwardfire.vasc.core.entry.VascEntryBackendEventListener;
import net.forwardfire.vasc.core.entry.VascEntryBackendEventListener.VascBackendEventType; import net.forwardfire.vasc.core.entry.VascEntryBackendEventListener.VascBackendEventType;
@ -40,7 +40,7 @@ import net.forwardfire.vasc.core.entry.VascEntryBackendEventListener.VascBackend
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Sep 21, 2010 * @version 1.0 Sep 21, 2010
*/ */
public class VascBackendProxyEventExecutor extends AbstractVascBackendProxy { public class VascBackendProxyEventExecutor<DATA_PK extends Serializable,DATA_RECORD extends Serializable> extends AbstractVascBackendProxy<DATA_PK,DATA_RECORD> {
private List<VascEntryBackendEventListener> listeners = null; private List<VascEntryBackendEventListener> listeners = null;
@ -48,13 +48,13 @@ public class VascBackendProxyEventExecutor extends AbstractVascBackendProxy {
* @see java.lang.Object#clone() * @see java.lang.Object#clone()
*/ */
@Override @Override
public VascBackendProxy clone() throws CloneNotSupportedException { public VascBackendProxy<DATA_PK,DATA_RECORD> clone() throws CloneNotSupportedException {
VascBackendProxyEventExecutor result = new VascBackendProxyEventExecutor(); VascBackendProxyEventExecutor<DATA_PK,DATA_RECORD> result = new VascBackendProxyEventExecutor<>();
return result; return result;
} }
@Override @Override
public void initProxy(VascBackend<Serializable> backend,VascEntry entry) { public void initProxy(VascBackendCrud<Serializable> backend,VascEntry entry) {
super.initProxy(backend, entry); super.initProxy(backend, entry);
this.entry=entry; this.entry=entry;
this.listeners=new ArrayList<VascEntryBackendEventListener>(10); this.listeners=new ArrayList<VascEntryBackendEventListener>(10);
@ -115,10 +115,10 @@ public class VascBackendProxyEventExecutor extends AbstractVascBackendProxy {
} }
/** /**
* @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#doRecordMoveDownById(net.forwardfire.vasc.backend.VascBackendState, java.lang.Object) * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#doRecordMoveDownById(net.forwardfire.vasc.backend.list.VascBackendListRequest, java.lang.Object)
*/ */
@Override @Override
public long doRecordMoveDownById(VascBackendState state, Object primaryId) throws VascBackendException { public long doRecordMoveDownById(VascBackendListRequest state, Object primaryId) throws VascBackendException {
fireVascEvent(VascBackendEventType.PRE_MOVE_DOWN,primaryId); fireVascEvent(VascBackendEventType.PRE_MOVE_DOWN,primaryId);
Long result = super.doRecordMoveDownById(state, primaryId); Long result = super.doRecordMoveDownById(state, primaryId);
fireVascEvent(VascBackendEventType.POST_MOVE_DOWN,result); fireVascEvent(VascBackendEventType.POST_MOVE_DOWN,result);
@ -126,10 +126,10 @@ public class VascBackendProxyEventExecutor extends AbstractVascBackendProxy {
} }
/** /**
* @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#doRecordMoveUpById(net.forwardfire.vasc.backend.VascBackendState, java.lang.Object) * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#doRecordMoveUpById(net.forwardfire.vasc.backend.list.VascBackendListRequest, java.lang.Object)
*/ */
@Override @Override
public long doRecordMoveUpById(VascBackendState state, Object primaryId) throws VascBackendException { public long doRecordMoveUpById(VascBackendListRequest state, Object primaryId) throws VascBackendException {
fireVascEvent(VascBackendEventType.PRE_MOVE_UP,primaryId); fireVascEvent(VascBackendEventType.PRE_MOVE_UP,primaryId);
Long result = super.doRecordMoveUpById(state, primaryId); Long result = super.doRecordMoveUpById(state, primaryId);
fireVascEvent(VascBackendEventType.POST_MOVE_UP,result); fireVascEvent(VascBackendEventType.POST_MOVE_UP,result);
@ -137,12 +137,12 @@ public class VascBackendProxyEventExecutor extends AbstractVascBackendProxy {
} }
/** /**
* @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#execute(net.forwardfire.vasc.backend.VascBackendState) * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#execute(net.forwardfire.vasc.backend.list.VascBackendListRequest)
*/ */
@Override @Override
public VascBackendResult<Serializable> execute(VascBackendState state) throws VascBackendException { public VascBackendListResult<Serializable> execute(VascBackendListRequest state) throws VascBackendException {
fireVascEvent(VascBackendEventType.PRE_EXECUTE,state); fireVascEvent(VascBackendEventType.PRE_EXECUTE,state);
VascBackendResult<Serializable> result = super.execute(state); VascBackendListResult<Serializable> result = super.execute(state);
fireVascEvent(VascBackendEventType.POST_EXECUTE,result); fireVascEvent(VascBackendEventType.POST_EXECUTE,result);
return result; return result;
} }

View file

@ -26,12 +26,10 @@ import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.forwardfire.vasc.backend.DefaultVascBackendResult;
import net.forwardfire.vasc.backend.VascBackend;
import net.forwardfire.vasc.backend.VascBackendException; import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascBackendResult; import net.forwardfire.vasc.backend.list.DefaultVascBackendListResult;
import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.list.VascBackendListResult;
import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.backend.list.VascBackendListRequest;
/** /**
* Simple filter support * Simple filter support
@ -39,7 +37,7 @@ import net.forwardfire.vasc.core.VascEntry;
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Oct 27, 2007 * @version 1.0 Oct 27, 2007
*/ */
public class VascBackendProxyFilter extends AbstractVascBackendProxy { public class VascBackendProxyFilter<DATA_PK extends Serializable,DATA_RECORD extends Serializable> extends AbstractVascBackendProxy<DATA_PK,DATA_RECORD> {
private List<VascProxyFilter> filters = null; private List<VascProxyFilter> filters = null;
@ -47,17 +45,16 @@ public class VascBackendProxyFilter extends AbstractVascBackendProxy {
* @see java.lang.Object#clone() * @see java.lang.Object#clone()
*/ */
@Override @Override
public VascBackendProxy clone() throws CloneNotSupportedException { public VascBackendProxy<DATA_PK,DATA_RECORD> clone() throws CloneNotSupportedException {
VascBackendProxyFilter result = new VascBackendProxyFilter(); VascBackendProxyFilter<DATA_PK,DATA_RECORD> result = new VascBackendProxyFilter<>();
return result; return result;
} }
/** /**
* @see net.forwardfire.vasc.backend.proxy.VascBackendProxy#initProxy(net.forwardfire.vasc.backend.VascBackend, net.forwardfire.vasc.core.VascEntry) * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#startBackendProxy()
*/ */
@Override @Override
public void initProxy(VascBackend<Serializable> backend, VascEntry entry) { protected void startBackendProxy() {
super.initProxy(backend,entry);
filters = entry.getVascBackendFilters(); filters = entry.getVascBackendFilters();
for (VascProxyFilter filter:filters) { for (VascProxyFilter filter:filters) {
filter.initFilter(entry); filter.initFilter(entry);
@ -76,19 +73,19 @@ public class VascBackendProxyFilter extends AbstractVascBackendProxy {
} }
/** /**
* @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state) * @see net.forwardfire.vasc.backend.crud.VascBackendCrud#execute(VascBackendListRequest state)
*/ */
@Override @Override
public VascBackendResult<Serializable> execute(VascBackendState state) throws VascBackendException { public VascBackendListResult<Serializable> execute(VascBackendListRequest state) throws VascBackendException {
VascBackendResult<Serializable> result = backend.execute(state); VascBackendListResult<Serializable> result = backend.execute(state);
if (filters==null) { if (filters==null) {
return result; return result;
} }
if (filters.isEmpty()) { if (filters.isEmpty()) {
return result; return result;
} }
List<Serializable> search = new ArrayList<Serializable>(result.getPageData().size()/2); List<Serializable> search = new ArrayList<Serializable>(result.getData().size()/2);
for (Serializable o:result.getPageData()) { for (Serializable o:result.getData()) {
for (VascProxyFilter filter:filters) { for (VascProxyFilter filter:filters) {
Serializable r = filter.filterObject(o); Serializable r = filter.filterObject(o);
if (r!=null) { if (r!=null) {
@ -96,6 +93,6 @@ public class VascBackendProxyFilter extends AbstractVascBackendProxy {
} }
} }
} }
return new DefaultVascBackendResult<Serializable>(search,search.size()); return new DefaultVascBackendListResult<Serializable>(search,search.size());
} }
} }

View file

@ -26,10 +26,11 @@ import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.forwardfire.vasc.backend.DefaultVascBackendResult;
import net.forwardfire.vasc.backend.VascBackendException; import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascBackendResult; import net.forwardfire.vasc.backend.list.DefaultVascBackendListResult;
import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.list.VascBackendListFeature;
import net.forwardfire.vasc.backend.list.VascBackendListResult;
import net.forwardfire.vasc.backend.list.VascBackendListRequest;
/** /**
* Simulates a real pages backend. * Simulates a real pages backend.
@ -37,42 +38,26 @@ import net.forwardfire.vasc.backend.VascBackendState;
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Oct 27, 2007 * @version 1.0 Oct 27, 2007
*/ */
public class VascBackendProxyPaged extends AbstractVascBackendProxy { public class VascBackendProxyPaged<DATA_PK extends Serializable,DATA_RECORD extends Serializable> extends AbstractVascBackendProxyFeature<DATA_PK,DATA_RECORD> {
public VascBackendProxyPaged() {
super(VascBackendListFeature.PAGE_DATA,VascBackendListFeature.PAGE_DATA_PROXY);
}
/** /**
* @see java.lang.Object#clone() * @see java.lang.Object#clone()
*/ */
@Override @Override
public VascBackendProxy clone() throws CloneNotSupportedException { public VascBackendProxy<DATA_PK,DATA_RECORD> clone() throws CloneNotSupportedException {
VascBackendProxyPaged result = new VascBackendProxyPaged(); return new VascBackendProxyPaged<DATA_PK,DATA_RECORD>();
return result;
} }
/** /**
* @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#isProxyNeeded() * @see net.forwardfire.vasc.backend.crud.VascBackendCrud#execute(VascBackendListRequest state)
*/ */
@Override @Override
public boolean isProxyNeeded() { public VascBackendListResult<DATA_RECORD> execute(VascBackendListRequest state) throws VascBackendException {
if (backend.isPageable()) { VascBackendListResult<Serializable> allData = backend.execute(state);
return false;
}
return true;
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#isPageable()
*/
@Override
public boolean isPageable() {
return true;
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state)
*/
@Override
public VascBackendResult<Serializable> execute(VascBackendState state) throws VascBackendException {
VascBackendResult<Serializable> allData = backend.execute(state);
int pageSize = state.getPageSize(); int pageSize = state.getPageSize();
if (pageSize==0) { if (pageSize==0) {
return allData; return allData;
@ -81,12 +66,12 @@ public class VascBackendProxyPaged extends AbstractVascBackendProxy {
int off = state.getPageIndex()*pageSize; int off = state.getPageIndex()*pageSize;
int offMax = off+state.getPageSize(); int offMax = off+state.getPageSize();
for (int i=off;i<offMax;i++) { for (int i=off;i<offMax;i++) {
if (i>=allData.getPageData().size()) { if (i>=allData.getData().size()) {
break; break;
} }
Serializable o = allData.getPageData().get(i); Serializable o = allData.getData().get(i);
paged.add(o); paged.add(o);
} }
return new DefaultVascBackendResult<Serializable>(paged,allData.getPageData().size()); return new DefaultVascBackendListResult<DATA_RECORD>(paged,allData.getData().size());
} }
} }

View file

@ -26,11 +26,12 @@ import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.forwardfire.vasc.backend.DefaultVascBackendResult;
import net.forwardfire.vasc.backend.VascBackendException; import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascBackendResult; import net.forwardfire.vasc.backend.VascBackendAccessDataRecord;
import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.list.DefaultVascBackendListResult;
import net.forwardfire.vasc.backend.VascEntryFieldValue; import net.forwardfire.vasc.backend.list.VascBackendListFeature;
import net.forwardfire.vasc.backend.list.VascBackendListResult;
import net.forwardfire.vasc.backend.list.VascBackendListRequest;
import net.forwardfire.vasc.core.VascEntryField; import net.forwardfire.vasc.core.VascEntryField;
/** /**
@ -39,42 +40,27 @@ import net.forwardfire.vasc.core.VascEntryField;
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Oct 27, 2007 * @version 1.0 Oct 27, 2007
*/ */
public class VascBackendProxySearch extends AbstractVascBackendProxy { public class VascBackendProxySearch<DATA_PK extends Serializable,DATA_RECORD extends Serializable> extends AbstractVascBackendProxyFeature<DATA_PK,DATA_RECORD> {
public VascBackendProxySearch() {
super(VascBackendListFeature.TEXT_SEARCH,VascBackendListFeature.TEXT_SEARCH_PROXY);
}
/** /**
* @see java.lang.Object#clone() * @see java.lang.Object#clone()
*/ */
@Override @Override
public VascBackendProxy clone() throws CloneNotSupportedException { public VascBackendProxy<DATA_PK,DATA_RECORD> clone() throws CloneNotSupportedException {
VascBackendProxySearch result = new VascBackendProxySearch(); VascBackendProxySearch<DATA_PK,DATA_RECORD> result = new VascBackendProxySearch<>();
return result; return result;
} }
/** /**
* @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#isProxyNeeded() * @see net.forwardfire.vasc.backend.crud.VascBackendCrud#execute(VascBackendListRequest state)
*/ */
@Override @Override
public boolean isProxyNeeded() { public VascBackendListResult<Serializable> execute(VascBackendListRequest state) throws VascBackendException {
if (backend.isSearchable()) { VascBackendListResult<Serializable> result = backend.execute(state);
return false;
}
return true;
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#isSearchable()
*/
@Override
public boolean isSearchable() {
return true;
}
/**
* @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state)
*/
@Override
public VascBackendResult<Serializable> execute(VascBackendState state) throws VascBackendException {
VascBackendResult<Serializable> result = backend.execute(state);
if (state.getSearchString()==null) { if (state.getSearchString()==null) {
return result; return result;
} }
@ -82,59 +68,21 @@ public class VascBackendProxySearch extends AbstractVascBackendProxy {
return result; return result;
} }
String searchString = state.getSearchString().toLowerCase(); String searchString = state.getSearchString().toLowerCase();
List<Serializable> search = new ArrayList<Serializable>(result.getPageData().size()/4); List<Serializable> search = new ArrayList<Serializable>(result.getData().size()/4);
for (Serializable record:result.getPageData()) { for (Serializable record:result.getData()) {
for (VascEntryField field:entry.getVascEntryFields()) { for (VascEntryField field:entry.getVascEntryFields()) {
VascEntryFieldValue<Serializable> fieldValue = backend.provideVascEntryFieldValue(); VascBackendAccessDataRecord<Serializable,Serializable> fieldValue = backend.provideVascEntryFieldValue();
Serializable value = fieldValue.getValue(field.getBackendName(), record); Serializable value = fieldValue.getValue(field.getBackendName(), record);
if (value==null) { if (value==null) {
continue; // can't search null values. continue; // can't search null values.
} }
String r = value.toString().toLowerCase(); String r = value.toString().toLowerCase();
if (r.contains(searchString)) { if (r.contains(searchString)) {
search.add(record); search.add(record);
break; break;
}
}
/*
for (Method method:o.getClass().getMethods()) {
if (method.getName().startsWith("get")==false) { //a bit durty
continue;
}
if (method.getName().equals("getClass")) {
continue;
}
if (method.getReturnType().isAssignableFrom(Collection.class)) {
continue;
}
if (method.getReturnType().isAssignableFrom(List.class)) {
continue;
}
if (method.getReturnType().isAssignableFrom(Set.class)) {
continue;
}
if (method.getReturnType().isAssignableFrom(Map.class)) {
continue;
}
Object res;
try {
res = method.invoke(o,new Object[]{});
} catch (Exception e) {
throw new VascException(e);
} }
if (res==null) { }
continue;
}
String r = res.toString().toLowerCase();
if (r.contains(searchString)) {
search.add(o);
break;
}
}
*/
} }
//records = search.size(); return new DefaultVascBackendListResult<Serializable>(search);
return new DefaultVascBackendResult<Serializable>(search);
} }
} }

View file

@ -27,9 +27,10 @@ import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import net.forwardfire.vasc.backend.VascBackendException; import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascBackendResult; import net.forwardfire.vasc.backend.VascBackendAccessDataRecord;
import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.list.VascBackendListFeature;
import net.forwardfire.vasc.backend.VascEntryFieldValue; import net.forwardfire.vasc.backend.list.VascBackendListResult;
import net.forwardfire.vasc.backend.list.VascBackendListRequest;
import net.forwardfire.vasc.core.VascEntryField; import net.forwardfire.vasc.core.VascEntryField;
/** /**
@ -38,28 +39,21 @@ import net.forwardfire.vasc.core.VascEntryField;
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Oct 27, 2007 * @version 1.0 Oct 27, 2007
*/ */
public class VascBackendProxySort extends AbstractVascBackendProxy { public class VascBackendProxySort<DATA_PK extends Serializable,DATA_RECORD extends Serializable> extends AbstractVascBackendProxyFeature<DATA_PK,DATA_RECORD> {
public VascBackendProxySort() {
super(VascBackendListFeature.SORT_DATA,VascBackendListFeature.SORT_DATA_PROXY);
}
/** /**
* @see java.lang.Object#clone() * @see java.lang.Object#clone()
*/ */
@Override @Override
public VascBackendProxy clone() throws CloneNotSupportedException { public VascBackendProxy<DATA_PK,DATA_RECORD> clone() throws CloneNotSupportedException {
VascBackendProxySort result = new VascBackendProxySort(); VascBackendProxySort<DATA_PK,DATA_RECORD> result = new VascBackendProxySort<>();
return result; return result;
} }
/**
* @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#isProxyNeeded()
*/
@Override
public boolean isProxyNeeded() {
if (backend.isSortable()) {
return false;
}
return true;
}
public VascEntryField getVascEntryFieldByBackendName(String linkId) { public VascEntryField getVascEntryFieldByBackendName(String linkId) {
for (VascEntryField a:entry.getVascEntryFields()) { for (VascEntryField a:entry.getVascEntryFields()) {
if (a.getBackendName().equals(linkId)) { if (a.getBackendName().equals(linkId)) {
@ -70,31 +64,32 @@ public class VascBackendProxySort extends AbstractVascBackendProxy {
} }
/** /**
* @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state) * @see net.forwardfire.vasc.backend.crud.VascBackendCrud#execute(VascBackendListRequest state)
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public VascBackendResult<Serializable> execute(final VascBackendState state) throws VascBackendException { public VascBackendListResult<DATA_RECORD> execute(final VascBackendListRequest state) throws VascBackendException {
VascBackendResult<Serializable> result = backend.execute(state); VascBackendListResult<DATA_RECORD> result = backend.execute(state);
if (state.getSortField()==null) { if (state.getSortField()==null) {
return result; return result;
} }
final VascEntryField field = getVascEntryFieldByBackendName(state.getSortField()); final VascEntryField field = getVascEntryFieldByBackendName(state.getSortField());
final VascEntryFieldValue<Serializable> fieldValue = backend.provideVascEntryFieldValue(); final VascBackendAccessDataRecord<Serializable,Serializable> fieldValue = backend.provideVascEntryFieldValue();
Collections.sort(result.getPageData(), new Comparator<Serializable>() { Collections.sort(result.getData(), new Comparator<Serializable>() {
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
@Override @Override
public int compare(Serializable o1, Serializable o2) { public int compare(Serializable o1, Serializable o2) {
try { try {
Comparable c1 = null; Comparable c1 = null;
Comparable c2 = null; Comparable c2 = null;
if (field.getDisplayName()!=null) { // if (field.getDisplayName()!=null) {
c1 = fieldValue.getDisplayValue(field.getBackendName(), o1); // c1 = fieldValue.getValue(field.getBackendName(), o1);
c2 = fieldValue.getDisplayValue(field.getBackendName(), o2); // c2 = fieldValue.getValue(field.getBackendName(), o2);
} else { // } else {
// TODO: fix none Comparable goes toString
c1 = (Comparable)fieldValue.getValue(field.getBackendName(), o1); c1 = (Comparable)fieldValue.getValue(field.getBackendName(), o1);
c2 = (Comparable)fieldValue.getValue(field.getBackendName(), o2); c2 = (Comparable)fieldValue.getValue(field.getBackendName(), o2);
} // }
if (c1==null & c2==null) { if (c1==null & c2==null) {
return 0; return 0;
} }

View file

@ -27,8 +27,8 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import net.forwardfire.vasc.backend.VascBackendException; import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascBackendResult; import net.forwardfire.vasc.backend.list.VascBackendListResult;
import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.list.VascBackendListRequest;
/** /**
* Does simple timer logging for the backend actions. * Does simple timer logging for the backend actions.
@ -36,7 +36,7 @@ import net.forwardfire.vasc.backend.VascBackendState;
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Nov 19, 2009 * @version 1.0 Nov 19, 2009
*/ */
public class VascBackendProxyTimerLogger extends AbstractVascBackendProxy { public class VascBackendProxyTimerLogger<DATA_PK extends Serializable,DATA_RECORD extends Serializable> extends AbstractVascBackendProxy<DATA_PK,DATA_RECORD> {
protected Logger logger = null; protected Logger logger = null;
protected Level logLevel = Level.INFO; protected Level logLevel = Level.INFO;
@ -49,17 +49,17 @@ public class VascBackendProxyTimerLogger extends AbstractVascBackendProxy {
* @see java.lang.Object#clone() * @see java.lang.Object#clone()
*/ */
@Override @Override
public VascBackendProxy clone() throws CloneNotSupportedException { public VascBackendProxy<DATA_PK,DATA_RECORD> clone() throws CloneNotSupportedException {
VascBackendProxyTimerLogger result = new VascBackendProxyTimerLogger(); VascBackendProxyTimerLogger<DATA_PK,DATA_RECORD> result = new VascBackendProxyTimerLogger<>();
result.logLevel=logLevel; result.logLevel=logLevel;
return result; return result;
} }
/** /**
* @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state) * @see net.forwardfire.vasc.backend.crud.VascBackendCrud#execute(VascBackendListRequest state)
*/ */
@Override @Override
public VascBackendResult<Serializable> execute(VascBackendState state) throws VascBackendException { public VascBackendListResult<Serializable> execute(VascBackendListRequest state) throws VascBackendException {
long t1 = System.currentTimeMillis(); long t1 = System.currentTimeMillis();
try { try {
return backend.execute(state); return backend.execute(state);
@ -70,13 +70,13 @@ public class VascBackendProxyTimerLogger extends AbstractVascBackendProxy {
} }
/** /**
* @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#doRecordMoveDownById(net.forwardfire.vasc.backend.VascBackendState, java.lang.Object) * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#doRecordMoveDownById(net.forwardfire.vasc.backend.list.VascBackendListRequest, java.lang.Object)
*/ */
@Override @Override
public long doRecordMoveDownById(VascBackendState state, Object primaryId) throws VascBackendException { public long doRecordMoveDownById(VascBackendListRequest request,Serializable recordPK) throws VascBackendException {
long t1 = System.currentTimeMillis(); long t1 = System.currentTimeMillis();
try { try {
return backend.doRecordMoveDownById(state, primaryId); return backend.doRecordMoveDownById(request, recordPK);
} finally { } finally {
long t2 = System.currentTimeMillis(); long t2 = System.currentTimeMillis();
logger.log(logLevel,"vasc-doRecordMoveDownById backend: "+getId()+" in "+(t2-t1)+" ms"); logger.log(logLevel,"vasc-doRecordMoveDownById backend: "+getId()+" in "+(t2-t1)+" ms");
@ -84,61 +84,19 @@ public class VascBackendProxyTimerLogger extends AbstractVascBackendProxy {
} }
/** /**
* @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#doRecordMoveUpById(net.forwardfire.vasc.backend.VascBackendState, java.lang.Object) * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#doRecordMoveUpById(net.forwardfire.vasc.backend.list.VascBackendListRequest, java.lang.Object)
*/ */
@Override @Override
public long doRecordMoveUpById(VascBackendState state, Object primaryId) throws VascBackendException { public long doRecordMoveUpById(VascBackendListRequest request,Serializable recordPK) throws VascBackendException {
long t1 = System.currentTimeMillis(); long t1 = System.currentTimeMillis();
try { try {
return backend.doRecordMoveUpById(state, primaryId); return backend.doRecordMoveUpById(request, recordPK);
} finally { } finally {
long t2 = System.currentTimeMillis(); long t2 = System.currentTimeMillis();
logger.log(logLevel,"vasc-doRecordMoveUpById backend: "+getId()+" in "+(t2-t1)+" ms"); logger.log(logLevel,"vasc-doRecordMoveUpById backend: "+getId()+" in "+(t2-t1)+" ms");
} }
} }
/**
* @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#delete(java.lang.Object)
*/
@Override
public void delete(Serializable object) throws VascBackendException {
long t1 = System.currentTimeMillis();
try {
backend.delete(object);
} finally {
long t2 = System.currentTimeMillis();
logger.log(logLevel,"vasc-delete backend: "+getId()+" in "+(t2-t1)+" ms");
}
}
/**
* @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#merge(java.lang.Object)
*/
@Override
public Serializable merge(Serializable object) throws VascBackendException {
long t1 = System.currentTimeMillis();
try {
return backend.merge(object);
} finally {
long t2 = System.currentTimeMillis();
logger.log(logLevel,"vasc-merge backend: "+getId()+" in "+(t2-t1)+" ms");
}
}
/**
* @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#persist(java.lang.Object)
*/
@Override
public void persist(Serializable object) throws VascBackendException {
long t1 = System.currentTimeMillis();
try {
backend.persist(object);
} finally {
long t2 = System.currentTimeMillis();
logger.log(logLevel,"vasc-persist backend: "+getId()+" in "+(t2-t1)+" ms");
}
}
/** /**
* @return the logLevel * @return the logLevel
*/ */

View file

@ -26,7 +26,7 @@ import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.forwardfire.vasc.backend.VascEntryFieldValue; import net.forwardfire.vasc.backend.VascBackendAccessDataRecord;
import net.forwardfire.vasc.core.base.AbstractVascBaseIdRoleCrudOrderMetaLocal; import net.forwardfire.vasc.core.base.AbstractVascBaseIdRoleCrudOrderMetaLocal;
import net.forwardfire.vasc.validators.VascValidator; import net.forwardfire.vasc.validators.VascValidator;
@ -43,7 +43,7 @@ abstract public class AbstractVascEntryFieldLocal extends AbstractVascBaseIdRole
private String backendName = null; private String backendName = null;
private String displayName = null; private String displayName = null;
private VascEntryFieldType vascEntryFieldType = null; private VascEntryFieldType vascEntryFieldType = null;
private VascEntryFieldValue<Serializable> vascEntryFieldValue = null; private VascBackendAccessDataRecord<Serializable,Serializable> vascEntryFieldValue = null;
private List<VascValidator> vascValidators = null; private List<VascValidator> vascValidators = null;
private Serializable defaultValue = null; private Serializable defaultValue = null;
private Integer sizeList = null; private Integer sizeList = null;
@ -147,7 +147,7 @@ abstract public class AbstractVascEntryFieldLocal extends AbstractVascBaseIdRole
* @return the vascEntryFieldValue * @return the vascEntryFieldValue
*/ */
@Override @Override
public VascEntryFieldValue<Serializable> getVascEntryFieldValue() { public VascBackendAccessDataRecord<Serializable,Serializable> getVascEntryFieldValue() {
return vascEntryFieldValue; return vascEntryFieldValue;
} }
@ -155,7 +155,7 @@ abstract public class AbstractVascEntryFieldLocal extends AbstractVascBaseIdRole
* @param vascEntryFieldValue the vascEntryFieldValue to set * @param vascEntryFieldValue the vascEntryFieldValue to set
*/ */
@Override @Override
public void setVascEntryFieldValue(VascEntryFieldValue<Serializable> vascEntryFieldValue) { public void setVascEntryFieldValue(VascBackendAccessDataRecord<Serializable,Serializable> vascEntryFieldValue) {
this.vascEntryFieldValue = vascEntryFieldValue; this.vascEntryFieldValue = vascEntryFieldValue;
} }

View file

@ -28,8 +28,8 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import net.forwardfire.vasc.backend.VascBackend; import net.forwardfire.vasc.backend.crud.VascBackendCrud;
import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.list.VascBackendListRequest;
/** /**
* Holds all default state values * Holds all default state values
@ -43,11 +43,11 @@ abstract public class AbstractVascEntryState implements VascEntryState {
private List<Serializable> entryDataList = null; private List<Serializable> entryDataList = null;
private Serializable entryDataObject = null; private Serializable entryDataObject = null;
private Long totalBackendRecords = null; private Long totalBackendRecords = null;
private VascBackendState vascBackendState = null; private VascBackendListRequest vascBackendState = null;
private VascEntryState state = null; private VascEntryState state = null;
private Map<Integer,Boolean> multiActionSelection = null; private Map<Integer,Boolean> multiActionSelection = null;
private boolean isEditCreate = false; private boolean isEditCreate = false;
private VascBackend<Serializable> vascBackend = null; private VascBackendCrud<Serializable,Serializable> vascBackend = null;
private VascEntry vascEntry = null; private VascEntry vascEntry = null;
public AbstractVascEntryState() { public AbstractVascEntryState() {
@ -91,7 +91,7 @@ abstract public class AbstractVascEntryState implements VascEntryState {
* @return the vascBackendState * @return the vascBackendState
*/ */
@Override @Override
public VascBackendState getVascBackendState() { public VascBackendListRequest getVascBackendState() {
return vascBackendState; return vascBackendState;
} }
@ -99,7 +99,7 @@ abstract public class AbstractVascEntryState implements VascEntryState {
* @param vascBackendState the vascBackendState to set * @param vascBackendState the vascBackendState to set
*/ */
@Override @Override
public void setVascBackendState(VascBackendState vascBackendState) { public void setVascBackendState(VascBackendListRequest vascBackendState) {
this.vascBackendState = vascBackendState; this.vascBackendState = vascBackendState;
} }
@ -143,7 +143,7 @@ abstract public class AbstractVascEntryState implements VascEntryState {
* @return the vascBackend * @return the vascBackend
*/ */
@Override @Override
public VascBackend<Serializable> getVascBackend() { public VascBackendCrud<Serializable,Serializable> getVascBackend() {
return vascBackend; return vascBackend;
} }
@ -151,7 +151,7 @@ abstract public class AbstractVascEntryState implements VascEntryState {
* @param vascBackend the vascBackend to set * @param vascBackend the vascBackend to set
*/ */
@Override @Override
public void setVascBackend(VascBackend<Serializable> vascBackend) { public void setVascBackend(VascBackendCrud<Serializable,Serializable> vascBackend) {
this.vascBackend = vascBackend; this.vascBackend = vascBackend;
} }

View file

@ -25,7 +25,7 @@ package net.forwardfire.vasc.core;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
import net.forwardfire.vasc.backend.VascBackend; import net.forwardfire.vasc.backend.crud.VascBackendCrud;
import net.forwardfire.vasc.core.entry.VascEntryExport; import net.forwardfire.vasc.core.entry.VascEntryExport;
import net.forwardfire.vasc.core.VascException; import net.forwardfire.vasc.core.VascException;
@ -46,9 +46,9 @@ public interface VascEntryConfigController {
void configVascEntry(VascController vascController,VascEntryLocal vascEntry) throws VascException; void configVascEntry(VascController vascController,VascEntryLocal vascEntry) throws VascException;
VascBackend<Serializable> configVascBackendProxied(VascController vascController,VascEntry vascEntry) throws VascException; VascBackendCrud<Serializable,Serializable> configVascBackendProxied(VascController vascController,VascEntry vascEntry) throws VascException;
VascBackend<Serializable> configVascBackendProxied(VascController vascController,VascEntry vascEntry,VascBackend<Serializable> realBackend) throws VascException; VascBackendCrud<Serializable,Serializable> configVascBackendProxied(VascController vascController,VascEntry vascEntry,VascBackendCrud<Serializable,Serializable> realBackend) throws VascException;
List<String> getVascEntryExporterIds(); List<String> getVascEntryExporterIds();

View file

@ -24,7 +24,7 @@ package net.forwardfire.vasc.core;
import java.util.List; import java.util.List;
import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.list.VascBackendListRequest;
import net.forwardfire.vasc.backend.proxy.VascBackendProxy; import net.forwardfire.vasc.backend.proxy.VascBackendProxy;
import net.forwardfire.vasc.core.entry.VascEntryExport; import net.forwardfire.vasc.core.entry.VascEntryExport;
import net.forwardfire.vasc.core.entry.VascEntryFieldValidatorService; import net.forwardfire.vasc.core.entry.VascEntryFieldValidatorService;
@ -60,7 +60,7 @@ public interface VascEntryConfigControllerLocal extends VascEntryConfigControlle
void removeVascEntryExporter(VascEntryExport exporter); void removeVascEntryExporter(VascEntryExport exporter);
VascBackendState getMasterVascBackendState(); VascBackendListRequest getMasterVascBackendState();
void setResourceBundle(String resourceBundle); void setResourceBundle(String resourceBundle);

View file

@ -25,7 +25,7 @@ package net.forwardfire.vasc.core;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
import net.forwardfire.vasc.backend.VascEntryFieldValue; import net.forwardfire.vasc.backend.VascBackendAccessDataRecord;
import net.forwardfire.vasc.core.base.VascBaseIdRoleCrudOrderMeta; import net.forwardfire.vasc.core.base.VascBaseIdRoleCrudOrderMeta;
import net.forwardfire.vasc.validators.VascValidator; import net.forwardfire.vasc.validators.VascValidator;
@ -56,7 +56,7 @@ public interface VascEntryField extends VascBaseIdRoleCrudOrderMeta {
/** /**
* @return the vascEntryFieldValue * @return the vascEntryFieldValue
*/ */
VascEntryFieldValue<Serializable> getVascEntryFieldValue(); VascBackendAccessDataRecord<Serializable,Serializable> getVascEntryFieldValue();
/** /**
* @return the vascValidators * @return the vascValidators

View file

@ -24,7 +24,7 @@ package net.forwardfire.vasc.core;
import java.io.Serializable; import java.io.Serializable;
import net.forwardfire.vasc.backend.VascEntryFieldValue; import net.forwardfire.vasc.backend.VascBackendAccessDataRecord;
import net.forwardfire.vasc.core.base.VascBaseIdRoleCrudOrderMetaLocal; import net.forwardfire.vasc.core.base.VascBaseIdRoleCrudOrderMetaLocal;
import net.forwardfire.vasc.validators.VascValidator; import net.forwardfire.vasc.validators.VascValidator;
@ -55,7 +55,7 @@ public interface VascEntryFieldLocal extends VascEntryField,VascBaseIdRoleCrudOr
/** /**
* @param vascEntryFieldValue the vascEntryFieldValue to set * @param vascEntryFieldValue the vascEntryFieldValue to set
*/ */
void setVascEntryFieldValue(VascEntryFieldValue<Serializable> vascEntryFieldValue); void setVascEntryFieldValue(VascBackendAccessDataRecord<Serializable,Serializable> vascEntryFieldValue);
/** /**
* @param vascValidator the vascValidator to add * @param vascValidator the vascValidator to add

View file

@ -26,8 +26,8 @@ import java.io.Serializable;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import net.forwardfire.vasc.backend.VascBackend; import net.forwardfire.vasc.backend.crud.VascBackendCrud;
import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.list.VascBackendListRequest;
/** /**
* Holds all the data for state. * Holds all the data for state.
@ -61,12 +61,12 @@ public interface VascEntryState extends Serializable {
/** /**
* @return the vascBackendState * @return the vascBackendState
*/ */
VascBackendState getVascBackendState(); VascBackendListRequest getVascBackendState();
/** /**
* @param vascBackendState the vascBackendState to set * @param vascBackendState the vascBackendState to set
*/ */
void setVascBackendState(VascBackendState vascBackendState); void setVascBackendState(VascBackendListRequest vascBackendState);
/** /**
* @return the totalBackendRecords * @return the totalBackendRecords
@ -97,12 +97,12 @@ public interface VascEntryState extends Serializable {
/** /**
* @return the vascBackend * @return the vascBackend
*/ */
public VascBackend<Serializable> getVascBackend(); public VascBackendCrud<Serializable,Serializable> getVascBackend();
/** /**
* @param vascBackend the vascBackend to set * @param vascBackend the vascBackend to set
*/ */
void setVascBackend(VascBackend<Serializable> vascBackend); void setVascBackend(VascBackendCrud<Serializable,Serializable> vascBackend);
/** /**
* @return the isEditCreate * @return the isEditCreate

View file

@ -1,6 +1,6 @@
package net.forwardfire.vasc.core; package net.forwardfire.vasc.core;
import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.list.VascBackendListRequest;
import net.forwardfire.vasc.frontend.VascFrontendActions; import net.forwardfire.vasc.frontend.VascFrontendActions;
import net.forwardfire.vasc.frontend.VascFrontendControllerLocal; import net.forwardfire.vasc.frontend.VascFrontendControllerLocal;
import net.forwardfire.vasc.frontend.VascFrontendDataSelector; import net.forwardfire.vasc.frontend.VascFrontendDataSelector;
@ -19,7 +19,7 @@ public interface VascInterfaceLoader {
VascEntryState createVascEntryStateImpl(); VascEntryState createVascEntryStateImpl();
VascBackendState createVascBackendStateImpl(); VascBackendListRequest createVascBackendStateImpl();
VascFrontendControllerLocal createVascFrontendControllerLocalImpl(); VascFrontendControllerLocal createVascFrontendControllerLocalImpl();

View file

@ -25,6 +25,7 @@ package net.forwardfire.vasc.core.ui;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
import net.forwardfire.vasc.backend.select.VascBackendSelectItem;
import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntry;
import net.forwardfire.vasc.core.VascException; import net.forwardfire.vasc.core.VascException;
@ -42,7 +43,7 @@ public interface VascSelectItemModel extends Serializable {
* @return * @return
* @throws VascException * @throws VascException
*/ */
List<VascSelectItem> getVascSelectItems(VascEntry entry) throws VascException; List<VascBackendSelectItem> getVascSelectItems(VascEntry entry) throws VascException;
/** /**
* @return the nullLabel * @return the nullLabel

View file

@ -30,10 +30,10 @@ import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.ResourceBundle; import java.util.ResourceBundle;
import net.forwardfire.vasc.backend.DefaultVascBackendState; import net.forwardfire.vasc.backend.VascBackendAccessDataRecord;
import net.forwardfire.vasc.backend.VascBackend; import net.forwardfire.vasc.backend.crud.VascBackendCrud;
import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.list.DefaultVascBackendListRequest;
import net.forwardfire.vasc.backend.VascEntryFieldValue; import net.forwardfire.vasc.backend.list.VascBackendListRequest;
import net.forwardfire.vasc.backend.proxy.VascBackendProxy; import net.forwardfire.vasc.backend.proxy.VascBackendProxy;
import net.forwardfire.vasc.core.VascController; import net.forwardfire.vasc.core.VascController;
import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntry;
@ -69,7 +69,7 @@ public class DefaultVascEntryConfigController implements VascEntryConfigControll
private Map<VascInterfaceKey,Class<?>> vascInterfaceImpls = null; private Map<VascInterfaceKey,Class<?>> vascInterfaceImpls = null;
private Map<VascInterfaceKeyFrontend,Class<?>> vascInterfaceImplFrontends = null; private Map<VascInterfaceKeyFrontend,Class<?>> vascInterfaceImplFrontends = null;
private VascInterfaceLoader vascInterfaceLoader = null; private VascInterfaceLoader vascInterfaceLoader = null;
private VascBackendState masterVascBackendState = null; private VascBackendListRequest masterVascBackendState = null;
private String resourceBundle = null; private String resourceBundle = null;
public DefaultVascEntryConfigController() { public DefaultVascEntryConfigController() {
@ -80,7 +80,7 @@ public class DefaultVascEntryConfigController implements VascEntryConfigControll
vascInterfaceImpls = new HashMap<VascInterfaceKey,Class<?>>(VascInterfaceKey.values().length); vascInterfaceImpls = new HashMap<VascInterfaceKey,Class<?>>(VascInterfaceKey.values().length);
vascInterfaceImplFrontends = new HashMap<VascInterfaceKeyFrontend,Class<?>>(VascInterfaceKeyFrontend.values().length); vascInterfaceImplFrontends = new HashMap<VascInterfaceKeyFrontend,Class<?>>(VascInterfaceKeyFrontend.values().length);
vascInterfaceLoader = new DefaultVascInterfaceLoader(this); vascInterfaceLoader = new DefaultVascInterfaceLoader(this);
masterVascBackendState = new DefaultVascBackendState(); masterVascBackendState = new DefaultVascBackendListRequest();
masterVascBackendState.setPageSize(100); masterVascBackendState.setPageSize(100);
masterVascBackendState.setPageSizeMax(1500); masterVascBackendState.setPageSizeMax(1500);
} }
@ -177,8 +177,8 @@ public class DefaultVascEntryConfigController implements VascEntryConfigControll
* @see net.forwardfire.vasc.core.VascEntryConfigController#configVascBackendProxied(net.forwardfire.vasc.core.VascController, net.forwardfire.vasc.core.VascEntry) * @see net.forwardfire.vasc.core.VascEntryConfigController#configVascBackendProxied(net.forwardfire.vasc.core.VascController, net.forwardfire.vasc.core.VascEntry)
*/ */
@Override @Override
public VascBackend<Serializable> configVascBackendProxied(VascController vascController,VascEntry vascEntry) throws VascException { public VascBackendCrud<Serializable,Serializable> configVascBackendProxied(VascController vascController,VascEntry vascEntry) throws VascException {
VascBackend<Serializable> realBackend = vascController.getVascBackendController().getVascBackendById(vascEntry.getBackendId()); VascBackendCrud<Serializable,Serializable> realBackend = vascController.getVascBackendController().getVascBackendById(VascBackendCrud.class,vascEntry.getBackendId());
if (realBackend==null) { if (realBackend==null) {
throw new VascException("Could not find backend: "+vascEntry.getBackendId()); throw new VascException("Could not find backend: "+vascEntry.getBackendId());
} }
@ -186,11 +186,11 @@ public class DefaultVascEntryConfigController implements VascEntryConfigControll
} }
/** /**
* @see net.forwardfire.vasc.core.VascEntryConfigController#configVascBackendProxied(net.forwardfire.vasc.core.VascController, net.forwardfire.vasc.core.VascEntry, net.forwardfire.vasc.backend.VascBackend) * @see net.forwardfire.vasc.core.VascEntryConfigController#configVascBackendProxied(net.forwardfire.vasc.core.VascController, net.forwardfire.vasc.core.VascEntry, net.forwardfire.vasc.backend.crud.VascBackendCrud)
*/ */
@Override @Override
public VascBackend<Serializable> configVascBackendProxied(VascController vascController,VascEntry vascEntry, VascBackend<Serializable> realBackend) throws VascException { public VascBackendCrud<Serializable,Serializable> configVascBackendProxied(VascController vascController,VascEntry vascEntry, VascBackendCrud<Serializable,Serializable> realBackend) throws VascException {
VascBackend<Serializable> backend = realBackend; VascBackendCrud<Serializable,Serializable> backend = realBackend;
for (VascBackendProxy proxy:backendProxies) { for (VascBackendProxy proxy:backendProxies) {
VascBackendProxy proxyClone; VascBackendProxy proxyClone;
try { try {
@ -217,7 +217,7 @@ public class DefaultVascEntryConfigController implements VascEntryConfigControll
// get the interface loader and create some impl objects // get the interface loader and create some impl objects
VascInterfaceLoader loader = getVascInterfaceLoader(); VascInterfaceLoader loader = getVascInterfaceLoader();
VascFrontendControllerLocal controller = loader.createVascFrontendControllerLocalImpl(); VascFrontendControllerLocal controller = loader.createVascFrontendControllerLocalImpl();
VascBackendState backendState = loader.createVascBackendStateImpl(); VascBackendListRequest backendState = loader.createVascBackendStateImpl();
VascEntryState state = loader.createVascEntryStateImpl(); VascEntryState state = loader.createVascEntryStateImpl();
// Add impl to tree // Add impl to tree
@ -234,7 +234,7 @@ public class DefaultVascEntryConfigController implements VascEntryConfigControll
controller.setVascFrontendUserSettingController( loader.createVascFrontendUserSettingControllerImpl(entry)); controller.setVascFrontendUserSettingController( loader.createVascFrontendUserSettingControllerImpl(entry));
// Config backend state from master template // Config backend state from master template
VascBackendState master = getMasterVascBackendState(); VascBackendListRequest master = getMasterVascBackendState();
for (String key:master.getDataParameterKeys()) { for (String key:master.getDataParameterKeys()) {
backendState.setDataParameter(key, master.getDataParameter(key)); backendState.setDataParameter(key, master.getDataParameter(key));
} }
@ -257,14 +257,14 @@ public class DefaultVascEntryConfigController implements VascEntryConfigControll
} }
// Add backend to entry // Add backend to entry
VascBackend<Serializable> backend = vascController.getVascEntryConfigController().configVascBackendProxied(vascController, entry); VascBackendCrud<Serializable,Serializable> backend = vascController.getVascEntryConfigController().configVascBackendProxied(vascController, entry);
controller.getVascEntryState().setVascBackend(backend); controller.getVascEntryState().setVascBackend(backend);
controller.getVascEntryState().setVascEntry(entry); controller.getVascEntryState().setVascEntry(entry);
// Fetch all data field value impl for this backend. // Fetch all data field value impl for this backend.
for (VascEntryField field:entry.getVascEntryFields()) { for (VascEntryField field:entry.getVascEntryFields()) {
if (field.getVascEntryFieldValue()==null) { if (field.getVascEntryFieldValue()==null) {
VascEntryFieldValue<Serializable> v = backend.provideVascEntryFieldValue(); VascBackendAccessDataRecord<Serializable,Serializable> v = backend.provideVascEntryFieldValue();
((VascEntryFieldLocal)field).setVascEntryFieldValue(v); ((VascEntryFieldLocal)field).setVascEntryFieldValue(v);
} }
} }
@ -422,7 +422,7 @@ public class DefaultVascEntryConfigController implements VascEntryConfigControll
* @see net.forwardfire.vasc.core.VascEntryConfigControllerLocal#getMasterVascBackendState() * @see net.forwardfire.vasc.core.VascEntryConfigControllerLocal#getMasterVascBackendState()
*/ */
@Override @Override
public VascBackendState getMasterVascBackendState() { public VascBackendListRequest getMasterVascBackendState() {
return masterVascBackendState; return masterVascBackendState;
} }
} }

View file

@ -23,7 +23,7 @@
package net.forwardfire.vasc.impl; package net.forwardfire.vasc.impl;
import net.forwardfire.vasc.backend.DefaultVascBackendController; import net.forwardfire.vasc.backend.DefaultVascBackendController;
import net.forwardfire.vasc.backend.DefaultVascBackendState; import net.forwardfire.vasc.backend.list.DefaultVascBackendListRequest;
import net.forwardfire.vasc.backend.proxy.VascBackendProxyCache; import net.forwardfire.vasc.backend.proxy.VascBackendProxyCache;
import net.forwardfire.vasc.backend.proxy.VascBackendProxyEventExecutor; import net.forwardfire.vasc.backend.proxy.VascBackendProxyEventExecutor;
import net.forwardfire.vasc.backend.proxy.VascBackendProxyFilter; import net.forwardfire.vasc.backend.proxy.VascBackendProxyFilter;
@ -73,7 +73,7 @@ public class DefaultVascFactory {
vascConfig.putVascInterfaceImplemention(VascInterfaceKey.VASC_ENTRY_LINK, DefaultVascEntryLink.class); vascConfig.putVascInterfaceImplemention(VascInterfaceKey.VASC_ENTRY_LINK, DefaultVascEntryLink.class);
vascConfig.putVascInterfaceImplemention(VascInterfaceKey.VASC_ENTRY_LIST_OPTION, DefaultVascEntryListOption.class); vascConfig.putVascInterfaceImplemention(VascInterfaceKey.VASC_ENTRY_LIST_OPTION, DefaultVascEntryListOption.class);
vascConfig.putVascInterfaceImplemention(VascInterfaceKey.VASC_BACKEND_STATE, DefaultVascBackendState.class); vascConfig.putVascInterfaceImplemention(VascInterfaceKey.VASC_BACKEND_STATE, DefaultVascBackendListRequest.class);
vascConfig.putVascInterfaceImplemention(VascInterfaceKey.VASC_FRONTEND_CONTROLLER_LOCAL, DefaultVascFrontendController.class); vascConfig.putVascInterfaceImplemention(VascInterfaceKey.VASC_FRONTEND_CONTROLLER_LOCAL, DefaultVascFrontendController.class);
vascConfig.putVascInterfaceImplementionFrontend(VascInterfaceKeyFrontend.VASC_FRONTEND_ACTIONS, DefaultVascFrontendActions.class); vascConfig.putVascInterfaceImplementionFrontend(VascInterfaceKeyFrontend.VASC_FRONTEND_ACTIONS, DefaultVascFrontendActions.class);

View file

@ -22,7 +22,7 @@
package net.forwardfire.vasc.impl; package net.forwardfire.vasc.impl;
import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.list.VascBackendListRequest;
import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntry;
import net.forwardfire.vasc.core.VascEntryConfigControllerLocal; import net.forwardfire.vasc.core.VascEntryConfigControllerLocal;
import net.forwardfire.vasc.core.VascEntryField; import net.forwardfire.vasc.core.VascEntryField;
@ -114,8 +114,8 @@ public class DefaultVascInterfaceLoader implements VascInterfaceLoader {
* @see net.forwardfire.vasc.core.VascInterfaceLoader#createVascBackendStateImpl() * @see net.forwardfire.vasc.core.VascInterfaceLoader#createVascBackendStateImpl()
*/ */
@Override @Override
public VascBackendState createVascBackendStateImpl() { public VascBackendListRequest createVascBackendStateImpl() {
return (VascBackendState)createImpl(VascInterfaceKey.VASC_BACKEND_STATE); return (VascBackendListRequest)createImpl(VascInterfaceKey.VASC_BACKEND_STATE);
} }
/** /**

View file

@ -22,7 +22,7 @@
package net.forwardfire.vasc.impl.entry; package net.forwardfire.vasc.impl.entry;
import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.list.VascBackendListRequest;
import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntry;
import net.forwardfire.vasc.core.entry.VascEntryBackendEventListener; import net.forwardfire.vasc.core.entry.VascEntryBackendEventListener;
@ -74,8 +74,8 @@ public class SetParameterBackendListener implements VascEntryBackendEventListene
*/ */
@Override @Override
public void vascEvent(VascEntry entry, Object data) { public void vascEvent(VascEntry entry, Object data) {
if (data instanceof VascBackendState) { if (data instanceof VascBackendListRequest) {
VascBackendState state = (VascBackendState)data; VascBackendListRequest state = (VascBackendListRequest)data;
if (isUserValue) { if (isUserValue) {
if (value==null) { if (value==null) {
value="id"; value="id";

View file

@ -27,7 +27,7 @@ import java.util.Locale;
import org.x4o.xml.conv.ObjectConverterException; import org.x4o.xml.conv.ObjectConverterException;
import net.forwardfire.vasc.backend.VascBackend; import net.forwardfire.vasc.backend.crud.VascBackendCrud;
import net.forwardfire.vasc.core.VascController; import net.forwardfire.vasc.core.VascController;
import net.forwardfire.vasc.core.VascEntryField; import net.forwardfire.vasc.core.VascEntryField;
import net.forwardfire.vasc.core.VascEntryConfigFinalizer; import net.forwardfire.vasc.core.VascEntryConfigFinalizer;
@ -59,7 +59,7 @@ public class VascDefaultsFinalizer implements VascEntryConfigFinalizer {
} }
// Check if backendId is valid // Check if backendId is valid
VascBackend<Serializable> back = vascController.getVascBackendController().getVascBackendById( entry.getBackendId() ); VascBackendCrud<Serializable,Serializable> back = vascController.getVascBackendController().getVascBackendById( VascBackendCrud.class, entry.getBackendId() );
if (back==null) { if (back==null) {
throw new IllegalArgumentException("The VascEntry backend is not found in backends: '"+entry.getBackendId()+"' in entryId: "+id); throw new IllegalArgumentException("The VascEntry backend is not found in backends: '"+entry.getBackendId()+"' in entryId: "+id);
} }

View file

@ -24,7 +24,7 @@ package net.forwardfire.vasc.impl.entry.config;
import java.io.Serializable; import java.io.Serializable;
import net.forwardfire.vasc.backend.VascBackend; import net.forwardfire.vasc.backend.crud.VascBackendCrud;
import net.forwardfire.vasc.core.VascController; import net.forwardfire.vasc.core.VascController;
import net.forwardfire.vasc.core.VascEntryField; import net.forwardfire.vasc.core.VascEntryField;
import net.forwardfire.vasc.core.VascEntryFieldSet; import net.forwardfire.vasc.core.VascEntryFieldSet;
@ -68,7 +68,7 @@ public class VascIdCheckFinalizer implements VascEntryConfigFinalizer {
} }
// Check if backendId is valid // Check if backendId is valid
VascBackend<Serializable> back = vascController.getVascBackendController().getVascBackendById( entry.getBackendId() ); VascBackendCrud<Serializable> back = vascController.getVascBackendController().getVascBackendById( entry.getBackendId() );
if (back==null) { if (back==null) {
throw new IllegalArgumentException("The VascEntry backend is not found in backends: '"+entry.getBackendId()+"' in entryId: "+id); throw new IllegalArgumentException("The VascEntry backend is not found in backends: '"+entry.getBackendId()+"' in entryId: "+id);
} }

View file

@ -27,8 +27,8 @@ import java.util.Date;
import java.util.logging.Logger; import java.util.logging.Logger;
import net.forwardfire.vasc.backend.VascBackendException; import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascBackendResult; import net.forwardfire.vasc.backend.list.VascBackendListResult;
import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.list.VascBackendListRequest;
import net.forwardfire.vasc.backend.proxy.VascProxyFilter; import net.forwardfire.vasc.backend.proxy.VascProxyFilter;
import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntry;
import net.forwardfire.vasc.core.VascEntryField; import net.forwardfire.vasc.core.VascEntryField;
@ -210,7 +210,7 @@ public class DefaultVascFrontendActions implements VascFrontendActions {
// Fire pre read event // Fire pre read event
entry.getVascFrontendController().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.PRE_READ, null); entry.getVascFrontendController().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.PRE_READ, null);
entry.getVascFrontendController().getVascEntryState().setEntryDataObject(null); entry.getVascFrontendController().getVascEntryState().setEntryDataObject(null);
VascBackendState backendState = entry.getVascFrontendController().getVascEntryState().getVascBackendState(); VascBackendListRequest backendState = entry.getVascFrontendController().getVascEntryState().getVascBackendState();
// check and correct max page size // check and correct max page size
if (backendState.getPageSize() > backendState.getPageSizeMax()) { if (backendState.getPageSize() > backendState.getPageSizeMax()) {
@ -226,7 +226,7 @@ public class DefaultVascFrontendActions implements VascFrontendActions {
} }
} }
VascBackendResult<Serializable> result; VascBackendListResult<Serializable> result;
try { try {
result = entry.getVascFrontendController().getVascEntryState().getVascBackend().execute(backendState); result = entry.getVascFrontendController().getVascEntryState().getVascBackend().execute(backendState);
} catch (VascBackendException ve) { } catch (VascBackendException ve) {
@ -234,11 +234,11 @@ public class DefaultVascFrontendActions implements VascFrontendActions {
} }
// Set data in frontend // Set data in frontend
entry.getVascFrontendController().getVascEntryState().setEntryDataList(result.getPageData()); entry.getVascFrontendController().getVascEntryState().setEntryDataList(result.getData());
entry.getVascFrontendController().getVascEntryState().setTotalBackendRecords(result.getTotalSize()); entry.getVascFrontendController().getVascEntryState().setTotalBackendRecords(result.getTotalRecordCount());
// check if we need to change the current page if table size if changed in between // check if we need to change the current page if table size if changed in between
int pages = new Long(result.getTotalSize()/backendState.getPageSize()).intValue(); int pages = new Long(result.getTotalRecordCount()/backendState.getPageSize()).intValue();
if (backendState.getPageIndex() > pages) { if (backendState.getPageIndex() > pages) {
backendState.setPageIndex(pages); backendState.setPageIndex(pages);
} }

View file

@ -28,7 +28,7 @@ import java.util.List;
import java.util.logging.Logger; import java.util.logging.Logger;
import net.forwardfire.vasc.backend.VascBackendException; import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascEntryFieldValue; import net.forwardfire.vasc.backend.VascBackendAccessDataRecord;
import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntry;
import net.forwardfire.vasc.core.VascEntryField; import net.forwardfire.vasc.core.VascEntryField;
import net.forwardfire.vasc.core.VascEntryLink; import net.forwardfire.vasc.core.VascEntryLink;
@ -202,10 +202,10 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
return "no-selection"; return "no-selection";
} }
VascEntryField v = entry.getVascEntryFieldById(entry.getDisplayNameFieldId()); VascEntryField v = entry.getVascEntryFieldById(entry.getDisplayNameFieldId());
VascEntryFieldValue<Serializable> ve = v.getVascEntryFieldValue(); VascBackendAccessDataRecord<Serializable,Serializable> ve = v.getVascEntryFieldValue();
String result = "no-data"; String result = "no-data";
try { try {
result = ve.getDisplayValue(v.getBackendName(), row); result = ""+ve.getValue(v.getBackendName(), row);
} catch (VascBackendException e) { } catch (VascBackendException e) {
throw new RuntimeException("Could not get selected name DisplayValue: "+e.getMessage(),e); throw new RuntimeException("Could not get selected name DisplayValue: "+e.getMessage(),e);
} }
@ -224,10 +224,10 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
return "no-selection"; return "no-selection";
} }
VascEntryField v = parent.getVascEntryFieldById(parent.getDisplayNameFieldId()); VascEntryField v = parent.getVascEntryFieldById(parent.getDisplayNameFieldId());
VascEntryFieldValue<Serializable> ve = v.getVascEntryFieldValue(); VascBackendAccessDataRecord<Serializable,Serializable> ve = v.getVascEntryFieldValue();
String result = "no-data"; String result = "no-data";
try { try {
result = ve.getDisplayValue(v.getBackendName(), row); result = ""+ve.getValue(v.getBackendName(), row);
} catch (VascBackendException e) { } catch (VascBackendException e) {
throw new RuntimeException("Could not get parent name DisplayValue: "+e.getMessage(),e); throw new RuntimeException("Could not get parent name DisplayValue: "+e.getMessage(),e);
} }

View file

@ -26,7 +26,7 @@ import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.list.VascBackendListRequest;
import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntry;
import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener; import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener;
import net.forwardfire.vasc.frontend.VascFrontendPageInfoNumber; import net.forwardfire.vasc.frontend.VascFrontendPageInfoNumber;
@ -156,7 +156,7 @@ public class DefaultVascFrontendPager implements VascFrontendPageInfo {
@Override @Override
public List<VascFrontendPageInfoNumber> getTablePagesFromBackend() { public List<VascFrontendPageInfoNumber> getTablePagesFromBackend() {
List<VascFrontendPageInfoNumber> result = new ArrayList<VascFrontendPageInfoNumber>(30); List<VascFrontendPageInfoNumber> result = new ArrayList<VascFrontendPageInfoNumber>(30);
VascBackendState state = entry.getVascFrontendController().getVascEntryState().getVascBackendState(); VascBackendListRequest state = entry.getVascFrontendController().getVascEntryState().getVascBackendState();
if (state.getPageSize()==0) { if (state.getPageSize()==0) {
return result; // paging disabled return result; // paging disabled
} }

View file

@ -33,9 +33,9 @@ import javax.naming.RefAddr;
import javax.naming.Reference; import javax.naming.Reference;
import javax.naming.spi.ObjectFactory; import javax.naming.spi.ObjectFactory;
import net.forwardfire.vasc.backend.VascBackend;
import net.forwardfire.vasc.backend.VascBackendController; import net.forwardfire.vasc.backend.VascBackendController;
import net.forwardfire.vasc.backend.VascBackendControllerLocal; import net.forwardfire.vasc.backend.VascBackendControllerLocal;
import net.forwardfire.vasc.backend.crud.VascBackendCrud;
import net.forwardfire.vasc.core.VascController; import net.forwardfire.vasc.core.VascController;
import net.forwardfire.vasc.core.VascControllerLocal; import net.forwardfire.vasc.core.VascControllerLocal;
import net.forwardfire.vasc.core.VascControllerProvider; import net.forwardfire.vasc.core.VascControllerProvider;
@ -130,7 +130,7 @@ public class JndiVascControllerFactory implements ObjectFactory {
return backendController.getVascBackendIds(); return backendController.getVascBackendIds();
} }
@Override @Override
public VascBackend<Serializable> getVascBackendById(String id) { public VascBackendCrud<Serializable> getVascBackendById(String id) {
return backendController.getVascBackendById(id); return backendController.getVascBackendById(id);
} }
}); });

Some files were not shown because too many files have changed in this diff Show more