diff --git a/pom.xml b/pom.xml
index a35d8cc..463f9d6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -124,10 +124,6 @@
6.0
- 3.0
- 1.1
- 1.0.2
- 3.0-alpha-1
1.0-MR1
1.2
2.2.1-b03
diff --git a/todo.txt b/todo.txt
index c51961a..cc19459 100644
--- a/todo.txt
+++ b/todo.txt
@@ -35,3 +35,4 @@
- create XML-RPC frontend
- export interface + exports
- graphs of numeric value columns
+- Add JETT export templates support
diff --git a/vasc-backend/pom.xml b/vasc-backend/pom.xml
index e9168cc..658c2f4 100644
--- a/vasc-backend/pom.xml
+++ b/vasc-backend/pom.xml
@@ -18,5 +18,6 @@
vasc-backend-metamodel
vasc-backend-api
vasc-backend-test
+ vasc-backend-object
diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackend.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackend.java
deleted file mode 100644
index 40b4c1d..0000000
--- a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackend.java
+++ /dev/null
@@ -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 implements VascBackend {
-
- 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;
- }
-}
\ No newline at end of file
diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackendControllerLocal.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackendControllerLocal.java
index 2ebba7f..defe0b5 100644
--- a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackendControllerLocal.java
+++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackendControllerLocal.java
@@ -22,14 +22,12 @@
package net.forwardfire.vasc.backend;
-import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
/**
* AbstractVascBackendControllerLocal
*
@@ -38,18 +36,16 @@ import java.util.Map;
*/
abstract public class AbstractVascBackendControllerLocal implements VascBackendControllerLocal {
- private Map> backends = null;
+ private Map backends = null;
public AbstractVascBackendControllerLocal() {
- backends = new HashMap>(1000);
+ backends = new HashMap(1000);
}
- /**
- * @see net.forwardfire.vasc.backend.VascBackendController#getVascBackendById(java.lang.String)
- */
@Override
- public VascBackend getVascBackendById(String id) {
- return backends.get(id);
+ @SuppressWarnings("unchecked")
+ public BACKEND_TYPE getVascBackendById(Class clazz,String id) {
+ return (BACKEND_TYPE) backends.get(id);
}
/**
@@ -64,44 +60,49 @@ abstract public class AbstractVascBackendControllerLocal implements VascBackendC
Collections.sort(result); // lets do abc for consistance behauvior.
return result;
}
-
+
/**
- * @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
- public void addVascBackend(VascBackend extends Serializable> backend) {
+ public void addVascBackend(VascBackend backend) {
if (backend==null) {
throw new NullPointerException("backend must not be null.");
}
if (backend.getId()==null) {
throw new IllegalArgumentException("The backend must have an id.");
}
- backend.startBackend();
- VascBackend castedBackend = (VascBackend) backend;
- backends.put(backend.getId(), castedBackend);
+ backends.put(backend.getId(), backend);
}
- /**
- * @see net.forwardfire.vasc.backend.VascBackendControllerLocal#removeVascBackendById(java.lang.String)
- */
@Override
- public void removeVascBackendById(String backendId) {
- VascBackend extends Serializable> backend = getVascBackendById(backendId);
- if (backend==null) {
- throw new NullPointerException("Could not find backend to remove with id: "+backendId);
+ public VascBackend removeVascBackend(VascBackend backend) {
+ VascBackend result = getVascBackendById(VascBackend.class,backend.getId());
+ if (result==null) {
+ throw new NullPointerException("Could not find backend to remove with id: "+backend.getId());
}
- backend.stopBackend();
- backends.remove(backendId);
+ return backends.remove(backend.getId());
}
- /**
- * @see net.forwardfire.vasc.backend.VascBackendControllerLocal#clearAndStopBackends()
- */
@Override
- public void clearAndStopBackends() {
+ public void stopBackends() {
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();
+ }
}
}
}
diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackendLocal.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackendLocal.java
new file mode 100644
index 0000000..e7f0dd3
--- /dev/null
+++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackendLocal.java
@@ -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 implements VascBackendLocal {
+
+ 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));
+ }
+ }
+}
diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackendRecord.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackendRecord.java
new file mode 100644
index 0000000..0e0da4e
--- /dev/null
+++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackendRecord.java
@@ -0,0 +1,8 @@
+package net.forwardfire.vasc.backend;
+
+import java.io.Serializable;
+
+public abstract interface AbstractVascBackendRecord extends VascBackend {
+
+ VascBackendAccessDataRecord createVascBackendAccessDataRecord();
+}
diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackend.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackend.java
index c39f231..7c52f8a 100644
--- a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackend.java
+++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackend.java
@@ -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;
import java.io.Serializable;
-/**
- * VascBackend provides stateless data access to a data source.
- *
- * @author Willem Cazander
- * @version 1.0 Mar 21, 2007
- */
-public interface VascBackend {
+public interface VascBackend {
String getId();
- void setId(String id);
- void startBackend();
- void stopBackend();
-
- VascBackendResult execute(VascBackendState state) throws VascBackendException;
-
- boolean isReadOnly();
-
- //public DATA_OBJECT fetch(Map 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 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 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();
+ VascBackendAccessDataKey createVascBackendAccessDataKey();
}
diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/DefaultVascBackendResult.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendAccessDataKey.java
similarity index 69%
rename from vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/DefaultVascBackendResult.java
rename to vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendAccessDataKey.java
index 68d113c..981ece1 100644
--- a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/DefaultVascBackendResult.java
+++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendAccessDataKey.java
@@ -23,28 +23,21 @@
package net.forwardfire.vasc.backend;
import java.io.Serializable;
-import java.util.List;
import java.util.Map;
+
/**
- * DefaultVascBackendResult.
+ * VascEntryFieldValue
*
* @author Willem Cazander
- * @version 1.0 Aug 23, 2014
+ * @version 1.0 Oct 24, 2014
*/
-public final class DefaultVascBackendResult extends AbstractVascBackendResult {
+public interface VascBackendAccessDataKey extends Serializable {
- public DefaultVascBackendResult(List pageData) {
- this(pageData,-1);
- }
+ Map> getKeyMapType();
+ Map getKeyMapFromPrimaryKey(DATA_PK primaryKey) throws VascBackendException;
+ DATA_PK getPrimaryKeyFromKeyMap(Map keyMap) throws VascBackendException;
- public DefaultVascBackendResult(List pageData,long totalSize) {
- this(pageData,totalSize,null,null);
- }
-
- public DefaultVascBackendResult(List pageData, long totalSize,
- Map pageSummary,
- Map totalSummary) {
- super(pageData, totalSize, pageSummary, totalSummary);
- }
-}
+ Map getStringMapFromPrimaryKey(DATA_PK primaryKey) throws VascBackendException;
+ DATA_PK getPrimaryKeyFromStringMap(Map keyMap) throws VascBackendException;
+}
\ No newline at end of file
diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascEntryFieldValue.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendAccessDataRecord.java
similarity index 82%
rename from vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascEntryFieldValue.java
rename to vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendAccessDataRecord.java
index 8ce072f..2d4118a 100644
--- a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascEntryFieldValue.java
+++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendAccessDataRecord.java
@@ -31,11 +31,11 @@ import java.io.Serializable;
* @author Willem Cazander
* @version 1.0 Mar 21, 2007
*/
-public interface VascEntryFieldValue extends Serializable {
+public interface VascBackendAccessDataRecord 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;
}
\ No newline at end of file
diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendController.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendController.java
index 92ac6de..6aab34b 100644
--- a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendController.java
+++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendController.java
@@ -22,18 +22,17 @@
package net.forwardfire.vasc.backend;
-import java.io.Serializable;
import java.util.List;
-
/**
+ * VascBackendController.
*
* @author Willem Cazander
* @version 1.0 Sep 4, 2008
*/
public interface VascBackendController {
- VascBackend getVascBackendById(String id);
+ BACKEND_TYPE getVascBackendById(Class clazz,String id);
List getVascBackendIds();
-}
\ No newline at end of file
+}
diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendControllerLocal.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendControllerLocal.java
index 60b732b..cb21bfe 100644
--- a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendControllerLocal.java
+++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendControllerLocal.java
@@ -22,9 +22,6 @@
package net.forwardfire.vasc.backend;
-import java.io.Serializable;
-
-
/**
*
* @author Willem Cazander
@@ -32,9 +29,11 @@ import java.io.Serializable;
*/
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();
}
\ No newline at end of file
diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendLifeCycle.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendLifeCycle.java
new file mode 100644
index 0000000..f2b5d4a
--- /dev/null
+++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendLifeCycle.java
@@ -0,0 +1,10 @@
+package net.forwardfire.vasc.backend;
+
+import java.io.Serializable;
+
+public interface VascBackendLifeCycle extends VascBackend {
+
+ void startBackend();
+ void stopBackend();
+ boolean isRunning();
+}
diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendLocal.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendLocal.java
new file mode 100644
index 0000000..fbd76d3
--- /dev/null
+++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendLocal.java
@@ -0,0 +1,8 @@
+package net.forwardfire.vasc.backend;
+
+import java.io.Serializable;
+
+public interface VascBackendLocal extends VascBackendLifeCycle {
+
+ void setId(String id);
+}
diff --git a/vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascEntryRecordCreator.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/crud/VascBackendCrud.java
similarity index 67%
rename from vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascEntryRecordCreator.java
rename to vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/crud/VascBackendCrud.java
index 7f32411..dc57218 100644
--- a/vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascEntryRecordCreator.java
+++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/crud/VascBackendCrud.java
@@ -20,26 +20,28 @@
* 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.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
- * @version 1.0 Dec 30, 2011
+ * @version 1.0 Mar 21, 2007
*/
-public class MongodbVascEntryRecordCreator implements VascEntryRecordCreator {
-
- private static final long serialVersionUID = -9213830731796787384L;
+public interface VascBackendCrud extends AbstractVascBackendRecord {
- @Override
- public BasicDBObject newRecord() throws VascBackendException {
- return new BasicDBObject();
- }
+ public DATA_RECORD fetch(DATA_PK recordPK) throws VascBackendException;
+
+ DATA_RECORD persist(DATA_RECORD record) throws VascBackendException;
+
+ DATA_RECORD merge(DATA_RECORD record) throws VascBackendException;
+
+ void delete(DATA_PK recordPK) throws VascBackendException;
+
+ DATA_RECORD newRecord() throws VascBackendException;
}
diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/HashMapVascEntryRecordCreator.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/crud/VascBackendCrudRevision.java
similarity index 73%
rename from vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/HashMapVascEntryRecordCreator.java
rename to vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/crud/VascBackendCrudRevision.java
index b2fb32a..3321c30 100644
--- a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/HashMapVascEntryRecordCreator.java
+++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/crud/VascBackendCrudRevision.java
@@ -20,26 +20,24 @@
* 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.util.HashMap;
+import java.util.List;
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
- * @version 1.0 Dec 05, 2009
+ * @version 1.0 Mar 25, 2014
*/
-public class HashMapVascEntryRecordCreator implements VascEntryRecordCreator> {
+public interface VascBackendCrudRevision extends VascBackendCrud {
- private static final long serialVersionUID = 1L;
-
- @Override
- public HashMap newRecord() throws VascBackendException {
- return new HashMap(10);
- }
+ List> revisionList(DATA_PK recordPK) throws VascBackendException;
+
+ void revisionDelete(String version) throws VascBackendException;
+
+ DATA_RECORD revisionFetch(DATA_PK recordPK,String version) throws VascBackendException;
}
diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/crud/package-info.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/crud/package-info.java
new file mode 100644
index 0000000..973576d
--- /dev/null
+++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/crud/package-info.java
@@ -0,0 +1,8 @@
+/**
+ *
+ */
+/**
+ * @author willemc
+ *
+ */
+package net.forwardfire.vasc.backend.crud;
\ No newline at end of file
diff --git a/vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascEntryFieldValue.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/AbstractVascBackendAccessDataKey.java
similarity index 64%
rename from vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascEntryFieldValue.java
rename to vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/AbstractVascBackendAccessDataKey.java
index 2cdde42..45e7a4a 100644
--- a/vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascEntryFieldValue.java
+++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/AbstractVascBackendAccessDataKey.java
@@ -20,38 +20,35 @@
* 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.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.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
- * @version 1.0 Dec 30, 2011
+ * @version 1.0 Oct 27, 2014
*/
-public class MongodbVascEntryFieldValue implements VascEntryFieldValue {
+@SuppressWarnings("serial")
+abstract public class AbstractVascBackendAccessDataKey implements VascBackendAccessDataKey {
- private static final long serialVersionUID = -7371273796529818557L;
-
- @Override
- public Serializable getValue(String backendName, BasicDBObject row) throws VascBackendException {
- Serializable data = (Serializable) row.get(backendName);
- return data;
+ private final Map> keyMapType;
+
+ public AbstractVascBackendAccessDataKey(Map> keyMapType) {
+ this.keyMapType = keyMapType;
}
-
+
@Override
- public String getDisplayValue(String field, BasicDBObject row) throws VascBackendException {
- return ""+getValue(field,row);
- }
-
- @Override
- public void setValue(String backendName, BasicDBObject row, Serializable value) throws VascBackendException {
- row.put(backendName, value);
+ public final Map> getKeyMapType() {
+ return keyMapType;
}
}
diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/BeanVascBackendAccessDataKey.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/BeanVascBackendAccessDataKey.java
new file mode 100644
index 0000000..bb03b95
--- /dev/null
+++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/BeanVascBackendAccessDataKey.java
@@ -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 extends AbstractVascBackendAccessDataKey {
+
+ private final Class> primaryKeyType;
+ private final DefaultElementObjectPropertyValue bean = new DefaultElementObjectPropertyValue();
+
+ public BeanVascBackendAccessDataKey(Class> primaryKeyType,Map> keyMapType) {
+ super(keyMapType);
+ this.primaryKeyType=primaryKeyType;
+ }
+
+ @Override
+ public Map getKeyMapFromPrimaryKey(DATA_PK primaryKey) throws VascBackendException {
+ Map result = new HashMap();
+
+ return result;
+ }
+
+ @Override
+ public DATA_PK getPrimaryKeyFromKeyMap(Map keyMap) throws VascBackendException {
+ //DATA_PK result = primaryKeyType.newInstance();
+ return null;
+ }
+
+ @Override
+ public Map getStringMapFromPrimaryKey(DATA_PK primaryKey) throws VascBackendException {
+ return null;
+ }
+
+ @Override
+ public DATA_PK getPrimaryKeyFromStringMap(Map keyMap) throws VascBackendException {
+ return null;
+ }
+}
diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/BeanVascEntryFieldValue.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/BeanVascBackendAccessDataRecord.java
similarity index 65%
rename from vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/BeanVascEntryFieldValue.java
rename to vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/BeanVascBackendAccessDataRecord.java
index f6a6461..59ae248 100644
--- a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/BeanVascEntryFieldValue.java
+++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/BeanVascBackendAccessDataRecord.java
@@ -26,26 +26,40 @@ package net.forwardfire.vasc.backend.data;
import java.io.Serializable;
import net.forwardfire.vasc.backend.VascBackendException;
-import net.forwardfire.vasc.backend.VascEntryFieldValue;
+import net.forwardfire.vasc.backend.VascBackendAccessDataRecord;
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
* @version 1.0 Dec 05, 2009
*/
-public class BeanVascEntryFieldValue implements VascEntryFieldValue {
+@SuppressWarnings("serial")
+public class BeanVascBackendAccessDataRecord implements VascBackendAccessDataRecord {
- private static final long serialVersionUID = 1L;
+ private final String primaryKeyProperty;
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
- 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) {
throw new NullPointerException("Can't get value of null backendName.");
}
@@ -59,42 +73,12 @@ public class BeanVascEntryFieldValue implement
throw new VascBackendException(e);
}
}
-
+
/**
- * @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
- public String getDisplayValue(String backendName, DATA_OBJECT record) 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 {
+ public void setValue(String backendName, DATA_RECORD record,Serializable value) throws VascBackendException {
if (backendName==null) {
throw new NullPointerException("Can't set value of null backendName.");
}
diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/HashMapVascBackendAccessDataKey.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/HashMapVascBackendAccessDataKey.java
new file mode 100644
index 0000000..eb8e459
--- /dev/null
+++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/HashMapVascBackendAccessDataKey.java
@@ -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> {
+
+ public HashMapVascBackendAccessDataKey(Map> keyMapType) {
+ super(keyMapType);
+ }
+
+ @Override
+ public Map getKeyMapFromPrimaryKey(HashMap primaryKey) throws VascBackendException {
+ return new HashMap(primaryKey); // wrap only as key is already object map
+ }
+
+ @Override
+ public HashMap getPrimaryKeyFromKeyMap(Map keyMap) throws VascBackendException {
+ return new HashMap(keyMap); // wrap only as key is already object map
+ }
+
+ @Override
+ public Map getStringMapFromPrimaryKey(HashMap primaryKey) throws VascBackendException {
+ HashMap result = new HashMap(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 getPrimaryKeyFromStringMap(Map keyMap) throws VascBackendException {
+ try {
+ HashMap result = new HashMap(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);
+ }
+ }
+}
diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/HashMapVascEntryFieldValue.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/HashMapVascBackendAccessDataRecord.java
similarity index 65%
rename from vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/HashMapVascEntryFieldValue.java
rename to vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/HashMapVascBackendAccessDataRecord.java
index bfee46f..957e61a 100644
--- a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/HashMapVascEntryFieldValue.java
+++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/HashMapVascBackendAccessDataRecord.java
@@ -24,22 +24,40 @@ package net.forwardfire.vasc.backend.data;
import java.io.Serializable;
import java.util.HashMap;
+import java.util.Map;
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
* @version 1.0 Dec 05, 2009
*/
-public class HashMapVascEntryFieldValue implements VascEntryFieldValue> {
-
- private static final long serialVersionUID = 1L;
+@SuppressWarnings("serial")
+public class HashMapVascBackendAccessDataRecord implements VascBackendAccessDataRecord,HashMap> {
+ private final Map> keyMapType;
+
+ public HashMapVascBackendAccessDataRecord(Map> 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 getPrimaryKey(HashMap record) throws VascBackendException {
+ HashMap result = new HashMap(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
public Serializable getValue(String backendName,HashMap map) throws VascBackendException {
@@ -52,21 +70,9 @@ public class HashMapVascEntryFieldValue implements VascEntryFieldValue 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)
+ * @see net.forwardfire.vasc.core.entry.VascBackendAccessDataRecord#setValue(java.lang.String, java.lang.Object, java.lang.Object)
*/
@Override
public void setValue(String backendName, HashMap map,Serializable value) throws VascBackendException {
diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackendState.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/DefaultVascBackendListRequest.java
similarity index 66%
rename from vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackendState.java
rename to vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/DefaultVascBackendListRequest.java
index d26ee06..11e44fa 100644
--- a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackendState.java
+++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/DefaultVascBackendListRequest.java
@@ -20,20 +20,23 @@
* 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.Map;
import java.util.Set;
+
+
/**
+ * Holds the state for the backend
*
* @author Willem Cazander
* @version 1.0 May 26, 2009
*/
-abstract public class AbstractVascBackendState implements VascBackendState {
-
- private static final long serialVersionUID = 1L;
+@SuppressWarnings("serial")
+public class DefaultVascBackendListRequest implements VascBackendListRequest {
+
protected Map parameters = null;
private int pageIndex = 0;
private int pageSize = 0;
@@ -41,38 +44,25 @@ abstract public class AbstractVascBackendState implements VascBackendState {
private String sortField = null;
private String searchString = null;
private boolean ascending = true;
- //private long pagesTotalRecords = 0;
- public AbstractVascBackendState() {
+ public DefaultVascBackendListRequest() {
parameters = new HashMap(10);
}
- /**
- * @see net.forwardfire.vasc.backend.VascBackendState#setDataParameter(java.lang.String, java.lang.Object)
- */
- @Override
public void setDataParameter(String key, Object data) {
parameters.put(key,data);
}
-
- /**
- * @see net.forwardfire.vasc.backend.VascBackendState#removeDataParameter(java.lang.String)
- */
- @Override
+
public void removeDataParameter(String key) {
parameters.remove(key);
}
-
- /**
- * @see net.forwardfire.vasc.backend.VascBackendState#removeDataParameterAll()
- */
- @Override
+
public void removeDataParameterAll() {
parameters.clear();
}
/**
- * @see net.forwardfire.vasc.backend.VascBackendState#getDataParameter(java.lang.String)
+ * @see net.forwardfire.vasc.backend.list.VascBackendListRequest#getDataParameter(java.lang.String)
*/
@Override
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
public Set getDataParameterKeys() {
@@ -88,85 +78,65 @@ abstract public class AbstractVascBackendState implements VascBackendState {
}
/**
- * @see net.forwardfire.vasc.backend.VascBackend#getPageIndex()
+ * @see net.forwardfire.vasc.backend.crud.VascBackendCrud#getPageIndex()
*/
@Override
public int getPageIndex() {
return pageIndex;
}
-
- /**
- * @see net.forwardfire.vasc.backend.VascBackend#setPageIndex(int)
- */
- @Override
+
public void setPageIndex(int pageIndex) {
this.pageIndex=pageIndex;
}
-
+
/**
- * @see net.forwardfire.vasc.backend.VascBackend#getPageSize()
+ * @see net.forwardfire.vasc.backend.crud.VascBackendCrud#getPageSize()
*/
@Override
public int getPageSize() {
return pageSize;
}
- /**
- * @see net.forwardfire.vasc.backend.VascBackend#setPageSize(int)
- */
- @Override
public void setPageSize(int pageSize) {
this.pageSize=pageSize;
}
/**
- * @see net.forwardfire.vasc.backend.VascBackend#getSearchString()
+ * @see net.forwardfire.vasc.backend.crud.VascBackendCrud#getSearchString()
*/
@Override
public String getSearchString() {
return searchString;
}
-
- /**
- * @see net.forwardfire.vasc.backend.VascBackend#setSearchString(java.lang.String)
- */
- @Override
+
public void setSearchString(String searchString) {
this.searchString=searchString;
}
-
+
/**
- * @see net.forwardfire.vasc.backend.VascBackend#isSortAscending()
+ * @see net.forwardfire.vasc.backend.crud.VascBackendCrud#isSortAscending()
*/
@Override
public boolean isSortAscending() {
return ascending;
}
- /**
- * @see net.forwardfire.vasc.backend.VascBackend#setSortAscending(boolean)
- */
- @Override
public void setSortAscending(boolean ascending) {
this.ascending=ascending;
}
-
+
/**
- * @see net.forwardfire.vasc.backend.VascBackend#getSortField()
+ * @see net.forwardfire.vasc.backend.crud.VascBackendCrud#getSortField()
*/
@Override
public String getSortField() {
return sortField;
}
- /**
- * @see net.forwardfire.vasc.backend.VascBackend#setSortField(java.lang.String)
- */
- @Override
public void setSortField(String sortField) {
this.sortField=sortField;
}
-
+
/**
* @return the pageSizeMax
*/
@@ -174,11 +144,7 @@ abstract public class AbstractVascBackendState implements VascBackendState {
public int getPageSizeMax() {
return pageSizeMax;
}
-
- /**
- * @param pageSizeMax the pageSizeMax to set
- */
- @Override
+
public void setPageSizeMax(int pageSizeMax) {
this.pageSizeMax = pageSizeMax;
}
diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackendResult.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/DefaultVascBackendListResult.java
similarity index 55%
rename from vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackendResult.java
rename to vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/DefaultVascBackendListResult.java
index 36a6e20..c9be9a1 100644
--- a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackendResult.java
+++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/DefaultVascBackendListResult.java
@@ -20,61 +20,60 @@
* 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.util.List;
import java.util.Map;
/**
- * AbstractVascBackendResult.
+ * DefaultVascBackendResult.
*
* @author Willem Cazander
* @version 1.0 Aug 23, 2014
*/
-abstract public class AbstractVascBackendResult implements VascBackendResult {
-
- private final List pageData;
- private final long totalSize;
- private final Map pageSummary;
- private final Map totalSummary;
+@SuppressWarnings("serial")
+public final class DefaultVascBackendListResult implements VascBackendListResult {
- public AbstractVascBackendResult(List pageData,long totalSize,Map pageSummary,Map totalSummary) {
- this.pageData = pageData;
- this.totalSize = totalSize;
- this.pageSummary = pageSummary;
- this.totalSummary = totalSummary;
+ private final List data;
+ private final long totalRecordCount;
+ private final Map> dataExtra;
+
+ public DefaultVascBackendListResult(List data) {
+ this(data,data.size());
+ }
+
+ public DefaultVascBackendListResult(List data,long totalRecordCount) {
+ this(data,totalRecordCount,null);
+ }
+
+ public DefaultVascBackendListResult(List data,long totalRecordCount,Map> 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
- public List getPageData() {
- return pageData;
+ public List getData() {
+ return data;
}
/**
- * @see net.forwardfire.vasc.backend.VascBackendResult#getTotalSize()
+ * @see net.forwardfire.vasc.backend.list.VascBackendListResult#getTotalRecordCount()
*/
@Override
- public long getTotalSize() {
- return totalSize;
+ public long getTotalRecordCount() {
+ return totalRecordCount;
}
/**
- * @see net.forwardfire.vasc.backend.VascBackendResult#getPageSummary()
+ * @see net.forwardfire.vasc.backend.list.VascBackendListResult#getDataExtra()
*/
@Override
- public Map getPageSummary() {
- return pageSummary;
- }
-
- /**
- * @see net.forwardfire.vasc.backend.VascBackendResult#getTotalSummary()
- */
- @Override
- public Map getTotalSummary() {
- return totalSummary;
+ public Map> getDataExtra() {
+ return dataExtra;
}
}
diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/VascBackendList.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/VascBackendList.java
new file mode 100644
index 0000000..6a6097f
--- /dev/null
+++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/VascBackendList.java
@@ -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 extends AbstractVascBackendRecord {
+
+ 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 getSupportedFeatures();
+
+ /**
+ * Executes the list request with parameters to return a list result.
+ * @param request
+ * @return
+ * @throws VascBackendException
+ */
+ VascBackendListResult execute(VascBackendListRequest request) throws VascBackendException;
+
+ /**
+ * @return Returns the action names of the row actions we support.
+ */
+ List 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 recordPKs,String actionName) throws VascBackendException;
+}
diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/DefaultVascBackendState.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/VascBackendListFeature.java
similarity index 76%
rename from vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/DefaultVascBackendState.java
rename to vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/VascBackendListFeature.java
index 654ea8d..f39f02a 100644
--- a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/DefaultVascBackendState.java
+++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/VascBackendListFeature.java
@@ -20,16 +20,28 @@
* 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
- * @version 1.0 May 26, 2009
+ * @version 1.0 Aug 26, 2014
*/
-public class DefaultVascBackendState extends AbstractVascBackendState {
-
- private static final long serialVersionUID = 8828343641448595993L;
-}
\ No newline at end of file
+public enum VascBackendListFeature {
+
+ /** 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;
+}
diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendState.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/VascBackendListRequest.java
similarity index 80%
rename from vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendState.java
rename to vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/VascBackendListRequest.java
index 4f9cc52..ecb56be 100644
--- a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendState.java
+++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/VascBackendListRequest.java
@@ -20,7 +20,7 @@
* 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.util.Set;
@@ -31,28 +31,20 @@ import java.util.Set;
* @author Willem Cazander
* @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);
Set getDataParameterKeys();
-
+
String getSortField();
- void setSortField(String name);
+
boolean isSortAscending();
- void setSortAscending(boolean ascending);
-
- void setPageSize(int size);
+
int getPageSize();
- void setPageSizeMax(int size);
int getPageSizeMax();
- void setPageIndex(int index);
int getPageIndex();
- void setSearchString(String searchString);
String getSearchString();
}
diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendResult.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/VascBackendListResult.java
similarity index 85%
rename from vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendResult.java
rename to vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/VascBackendListResult.java
index 205fadc..5f65c6c 100644
--- a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendResult.java
+++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/VascBackendListResult.java
@@ -20,7 +20,7 @@
* 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.util.List;
@@ -32,10 +32,9 @@ import java.util.Map;
* @author Willem Cazander
* @version 1.0 Aug 23, 2014
*/
-public interface VascBackendResult {
+public interface VascBackendListResult extends Serializable {
- List getPageData();
- long getTotalSize();
- Map getPageSummary();
- Map getTotalSummary();
+ List getData();
+ long getTotalRecordCount();
+ Map> getDataExtra();
}
diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/package-info.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/package-info.java
new file mode 100644
index 0000000..a40f6c2
--- /dev/null
+++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/package-info.java
@@ -0,0 +1,8 @@
+/**
+ *
+ */
+/**
+ * @author willemc
+ *
+ */
+package net.forwardfire.vasc.backend.list;
\ No newline at end of file
diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/select/DefaultVascBackendSelectItem.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/select/DefaultVascBackendSelectItem.java
new file mode 100644
index 0000000..c957ab2
--- /dev/null
+++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/select/DefaultVascBackendSelectItem.java
@@ -0,0 +1,62 @@
+package net.forwardfire.vasc.backend.select;
+
+import java.io.Serializable;
+
+public class DefaultVascBackendSelectItem implements VascBackendSelectItem {
+
+ 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;
+ }
+}
diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/select/VascBackendSelect.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/select/VascBackendSelect.java
new file mode 100644
index 0000000..4b9c753
--- /dev/null
+++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/select/VascBackendSelect.java
@@ -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 extends VascBackend {
+
+ List> execute() throws VascBackendException;
+}
diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascEntryRecordCreator.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/select/VascBackendSelectItem.java
similarity index 81%
rename from vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascEntryRecordCreator.java
rename to vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/select/VascBackendSelectItem.java
index e5d197e..5480223 100644
--- a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascEntryRecordCreator.java
+++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/select/VascBackendSelectItem.java
@@ -20,17 +20,22 @@
* 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;
-
/**
*
* @author Willem Cazander
- * @version 1.0 Mar 21, 2007
+ * @version 1.0 Aug 12, 2007
*/
-public interface VascEntryRecordCreator extends Serializable {
-
- DATA_OBJECT newRecord() throws VascBackendException;
-}
\ No newline at end of file
+public interface VascBackendSelectItem {
+
+ boolean isHeader();
+ boolean isEnabled();
+ String getName();
+ boolean isNameI18nKey();
+ String getDescription();
+ boolean isDescriptionI18nKey();
+ DATA_PK getPrimaryKey();
+}
diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/select/package-info.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/select/package-info.java
new file mode 100644
index 0000000..d385214
--- /dev/null
+++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/select/package-info.java
@@ -0,0 +1,8 @@
+/**
+ *
+ */
+/**
+ * @author willemc
+ *
+ */
+package net.forwardfire.vasc.backend.select;
\ No newline at end of file
diff --git a/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/AbstractJdbcVascBackend.java b/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/AbstractJdbcVascBackend.java
new file mode 100644
index 0000000..c1fd70e
--- /dev/null
+++ b/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/AbstractJdbcVascBackend.java
@@ -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> {
+
+ private JdbcConnectionProvider jdbcConnectionProvider = null;
+ private final Map> keyMapType = new HashMap>(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> getKeyMapType() {
+ return keyMapType;
+ }
+
+ /**
+ * @see net.forwardfire.vasc.backend.VascBackend#createVascBackendAccessDataKey()
+ */
+ @Override
+ public final VascBackendAccessDataKey> 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;
+ }
+}
diff --git a/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcVascBackend.java b/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcVascBackend.java
deleted file mode 100644
index b805ee0..0000000
--- a/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcVascBackend.java
+++ /dev/null
@@ -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> {
-
- 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> execute(VascBackendState state) throws VascBackendException {
- JdbcConnectionProvider prov = getJdbcConnectionProvider();
- List> result = new ArrayList>(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 map = new HashMap(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>(result);
- }
-
- /**
- * @see net.forwardfire.vasc.backend.VascBackend#merge(java.lang.Object)
- */
- @Override
- public HashMap merge(HashMap object) throws VascBackendException {
- return object;
- }
-
- /**
- * @see net.forwardfire.vasc.backend.VascBackend#persist(java.lang.Object)
- */
- @Override
- public void persist(HashMap object) throws VascBackendException {
- }
-
- /**
- * @see net.forwardfire.vasc.backend.VascBackend#delete(java.lang.Object)
- */
- @Override
- public void delete(HashMap 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;
- }
-}
diff --git a/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcVascBackendList.java b/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcVascBackendList.java
new file mode 100644
index 0000000..fd53174
--- /dev/null
+++ b/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcVascBackendList.java
@@ -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> {
+
+ private final EnumSet features = EnumSet.noneOf(VascBackendListFeature.class);
+ private final List rowActions = new ArrayList();
+ 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> createVascBackendAccessDataRecord() {
+ return new HashMapVascBackendAccessDataRecord(getKeyMapType());
+ }
+
+ @Override
+ public EnumSet getSupportedFeatures() {
+ return features;
+ }
+
+ @Override
+ public List getSupportedRowActions() {
+ return rowActions;
+ }
+
+ @Override
+ public void executeRowAction(VascBackendListRequest request,List> recordPKs, String actionName) throws VascBackendException {
+ }
+
+ /**
+ * @see net.forwardfire.vasc.backend.crud.VascBackendList#execute(VascBackendListRequest state)
+ */
+ @Override
+ public VascBackendListResult> execute(VascBackendListRequest state) throws VascBackendException {
+ JdbcConnectionProvider prov = getJdbcConnectionProvider();
+ List> result = new ArrayList>(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 map = new HashMap(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>(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;
+ }
+}
diff --git a/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcVascBackendSelect.java b/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcVascBackendSelect.java
new file mode 100644
index 0000000..963026d
--- /dev/null
+++ b/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcVascBackendSelect.java
@@ -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> {
+
+ private String query = null;
+
+ @Override
+ protected void startBackendJdbc() {
+ requireNonEmpty(getQuery(), "query is empty.");
+ }
+
+ @Override
+ public List>> execute() throws VascBackendException {
+ return null;
+ }
+
+ public VascBackendListResult> execute(VascBackendListRequest state) throws VascBackendException {
+ JdbcConnectionProvider prov = getJdbcConnectionProvider();
+ List> result = new ArrayList>(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 map = new HashMap(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>(result);
+ }
+
+ /**
+ * @return the query
+ */
+ public String getQuery() {
+ return query;
+ }
+
+ /**
+ * @param query the query to set
+ */
+ public void setQuery(String query) {
+ this.query = query;
+ }
+}
diff --git a/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcVascBackendXpql.java b/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/xpql/JdbcVascBackendXpqlList.java
similarity index 55%
rename from vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcVascBackendXpql.java
rename to vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/xpql/JdbcVascBackendXpqlList.java
index 78164df..3647216 100644
--- a/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcVascBackendXpql.java
+++ b/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/xpql/JdbcVascBackendXpqlList.java
@@ -20,25 +20,26 @@
* 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.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
+import java.util.EnumSet;
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;
+import net.forwardfire.vasc.backend.VascBackendAccessDataRecord;
+import net.forwardfire.vasc.backend.jdbc.AbstractJdbcVascBackend;
+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.xpql.query.QueryParameterValue;
/**
@@ -47,53 +48,46 @@ import net.forwardfire.vasc.xpql.query.QueryParameterValue;
* @author Willem Cazander
* @version 1.0 Sep 5, 2008
*/
-public class JdbcVascBackendXpql extends AbstractVascBackend> {
+public class JdbcVascBackendXpqlList extends AbstractJdbcVascBackend implements VascBackendList,HashMap> {
- private JdbcConnectionProvider jdbcConnectionProvider = null;
-
+ private final EnumSet features = EnumSet.noneOf(VascBackendListFeature.class);
+ private final List rowActions = new ArrayList();
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> createVascBackendAccessDataRecord() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public EnumSet getSupportedFeatures() {
+ return features;
+ }
+
+ @Override
+ public List getSupportedRowActions() {
+ return rowActions;
+ }
+
+ @Override
+ public void executeRowAction(VascBackendListRequest request,List> recordPKs, String actionName) throws VascBackendException {
+ }
/**
- * @see net.forwardfire.vasc.backend.AbstractVascBackend#isReadOnly()
+ * @see net.forwardfire.vasc.backend.crud.VascBackendCrud#execute(VascBackendListRequest state)
*/
@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;
- }
-
- /**
- * @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> execute(VascBackendState state) throws VascBackendException {
+ public VascBackendListResult> execute(VascBackendListRequest state) throws VascBackendException {
// Copy parameters
for (String key:state.getDataParameterKeys()) {
Object value = state.getDataParameter(key);
@@ -113,17 +107,17 @@ public class JdbcVascBackendXpql extends AbstractVascBackend> result = new ArrayList>(50);
+ List> result = new ArrayList>(50);
while (rs.next()) {
- HashMap map = new HashMap(cols);
+ HashMap map = new HashMap(cols);
for (int i=1;i<=cols;i++) {
String columnName = rs.getMetaData().getColumnName(i);
- Object columnObject = rs.getObject(i);
+ Serializable columnObject = (Serializable) rs.getObject(i);
map.put(columnName, columnObject);
}
result.add(map);
}
- return new DefaultVascBackendResult>(result);
+ return new DefaultVascBackendListResult>(result);
} catch (SQLException e) {
throw new VascBackendException(e);
} finally {
@@ -135,42 +129,18 @@ public class JdbcVascBackendXpql extends AbstractVascBackend merge(HashMap object) throws VascBackendException {
- return object;
- }
-
- /**
- * @see net.forwardfire.vasc.backend.VascBackend#persist(java.lang.Object)
- */
- @Override
- public void persist(HashMap object) throws VascBackendException {
+ public net.forwardfire.vasc.xpql.query.Query getQuery() {
+ return query;
}
/**
- * @see net.forwardfire.vasc.backend.VascBackend#delete(java.lang.Object)
+ * @param query the query to set
*/
- @Override
- public void delete(HashMap object) throws VascBackendException {
+ public void setQuery(net.forwardfire.vasc.xpql.query.Query query) {
+ this.query = query;
}
-
- /**
- * @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();
- }
-}
\ No newline at end of file
+}
diff --git a/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/xpql/package-info.java b/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/xpql/package-info.java
new file mode 100644
index 0000000..6581635
--- /dev/null
+++ b/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/xpql/package-info.java
@@ -0,0 +1,8 @@
+/**
+ *
+ */
+/**
+ * @author willemc
+ *
+ */
+package net.forwardfire.vasc.backend.jdbc.xpql;
\ No newline at end of file
diff --git a/vasc-backend/vasc-backend-jpa/pom.xml b/vasc-backend/vasc-backend-jpa/pom.xml
index ec46ef9..9ab1890 100644
--- a/vasc-backend/vasc-backend-jpa/pom.xml
+++ b/vasc-backend/vasc-backend-jpa/pom.xml
@@ -1,29 +1,30 @@
-
- 4.0.0
-
- vasc-backend
- net.forwardfire.vasc.backend
- 0.4.2-SNAPSHOT
-
- vasc-backend-jpa
- vasc-backend-jpa
- vasc-backend-jpa
-
-
- net.forwardfire.vasc.backend
- vasc-backend-api
- ${project.version}
-
-
- net.forwardfire.vasc.lib
- vasc-lib-xpql
- ${project.version}
-
-
- javax.persistence
- persistence-api
- ${persistence-api.version}
- provided
-
-
+
+ 4.0.0
+
+ vasc-backend
+ net.forwardfire.vasc.backend
+ 0.4.2-SNAPSHOT
+
+ vasc-backend-jpa
+ vasc-backend-jpa
+ vasc-backend-jpa
+
+
+ net.forwardfire.vasc.backend
+ vasc-backend-api
+ ${project.version}
+
+
+ net.forwardfire.vasc.lib
+ vasc-lib-xpql
+ ${project.version}
+
+
+ javax
+ javaee-api
+ ${javaee-api.version}
+ provided
+
+
diff --git a/vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/AbstractPersistenceVascBackend.java b/vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/AbstractPersistenceVascBackend.java
index 5c8e055..d1e4512 100644
--- a/vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/AbstractPersistenceVascBackend.java
+++ b/vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/AbstractPersistenceVascBackend.java
@@ -26,73 +26,54 @@ import java.io.Serializable;
import javax.persistence.EntityManager;
-import net.forwardfire.vasc.backend.AbstractVascBackend;
-import net.forwardfire.vasc.backend.VascBackendException;
+import net.forwardfire.vasc.backend.AbstractVascBackendLocal;
/**
+ * AbstractPersistenceVascBackend.
*
* @author Willem Cazander
- * @version 1.0 Mar 21, 2007
+ * @version 1.0 Aug 25, 2014
*/
-abstract public class AbstractPersistenceVascBackend extends AbstractVascBackend {
+abstract public class AbstractPersistenceVascBackend extends AbstractVascBackendLocal {
- 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
- public void persist(DATA_OBJECT object) throws VascBackendException {
- EntityManager s = getEntityManager();
- try {
- if (emTransaction) {
- s.getTransaction().begin();
- }
- s.persist(object);
- if (emTransaction) {
- s.getTransaction().commit();
- }
- } finally {
- if (s!=null) {
- //s.close();
- }
- }
+ protected final void startBackendLocal() {
+ requireNonNull(getEntityManagerProvider(), "entityManagerProvider is null.");
+ //requireNonEmpty(keyMapType.keySet(), "No primary keys defined.");
+ startBackendPersistence();
}
- @Override
- public DATA_OBJECT merge(DATA_OBJECT object) throws VascBackendException {
- EntityManager s = getEntityManager();
- 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();
- }
+ protected final EntityManager getEntityManager() {
+ if (emTransaction == null) {
+ emTransaction=entityManagerProvider.hasEntityManagerTransaction();
}
+ return entityManagerProvider.getEntityManager();
}
- @Override
- public void delete(DATA_OBJECT object) throws VascBackendException {
- EntityManager s = getEntityManager();
- try {
- if (emTransaction) {
- s.getTransaction().begin();
- }
- Object newObject = s.merge(object);
- s.remove(newObject);
- if (emTransaction) {
- s.getTransaction().commit();
- }
- } finally {
- if (s!=null) {
- //s.close();
- }
- }
+ protected final boolean hasTransaction() {
+ return emTransaction;
+ }
+
+ /**
+ * @return the entityManagerProvider
+ */
+ public final EntityManagerProvider getEntityManagerProvider() {
+ return entityManagerProvider;
+ }
+
+ /**
+ * @param entityManagerProvider the entityManagerProvider to set
+ */
+ public final void setEntityManagerProvider(EntityManagerProvider entityManagerProvider) {
+ this.entityManagerProvider = entityManagerProvider;
}
}
\ No newline at end of file
diff --git a/vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/PersistanceVascBackendCrud.java b/vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/PersistanceVascBackendCrud.java
new file mode 100644
index 0000000..5cbe905
--- /dev/null
+++ b/vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/PersistanceVascBackendCrud.java
@@ -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 extends AbstractPersistenceVascBackend implements VascBackendCrud {
+
+ private Class recordClass = null;
+
+ public PersistanceVascBackendCrud() {
+ }
+
+ public PersistanceVascBackendCrud(Class recordClass) {
+ setRecordClass(recordClass);
+ }
+
+ @Override
+ protected void startBackendPersistence() {
+ requireNonNull(getRecordClass(), "recordClass is null");
+ }
+
+ @Override
+ public VascBackendAccessDataRecord createVascBackendAccessDataRecord() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public VascBackendAccessDataKey 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 getRecordClass() {
+ return recordClass;
+ }
+
+ public void setRecordClass(Class recordClass) {
+ this.recordClass = recordClass;
+ }
+}
diff --git a/vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/XpqlPersistanceVascBackend.java b/vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/PersistanceVascBackendXpqlList.java
similarity index 65%
rename from vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/XpqlPersistanceVascBackend.java
rename to vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/PersistanceVascBackendXpqlList.java
index 1114fe8..fa0cbeb 100644
--- a/vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/XpqlPersistanceVascBackend.java
+++ b/vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/PersistanceVascBackendXpqlList.java
@@ -23,32 +23,30 @@
package net.forwardfire.vasc.backends.jpa;
import java.io.Serializable;
+import java.util.EnumSet;
import java.util.List;
import javax.persistence.EntityManager;
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.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.BeanVascEntryFieldValue;
-import net.forwardfire.vasc.backend.data.BeanVascEntryRecordCreator;
+import net.forwardfire.vasc.backend.VascBackendAccessDataRecord;
+import net.forwardfire.vasc.backend.data.BeanVascBackendAccessDataRecord;
+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.xpql.query.QueryParameterValue;
-
-
/**
* Manages persistance with xpql queries
*
* @author Willem Cazander
* @version 1.0 Mar 17, 2009
*/
-public class XpqlPersistanceVascBackend extends AbstractPersistenceVascBackend {
-
- private EntityManagerProvider entityManagerProvider = null;
+public class PersistanceVascBackendXpqlList extends AbstractPersistenceVascBackend implements VascBackendList {
private net.forwardfire.vasc.xpql.query.Query query = null;
@@ -62,38 +60,62 @@ public class XpqlPersistanceVascBackend extend
private net.forwardfire.vasc.xpql.query.Query queryMoveDownUp = null;
- private Class> resultClass = null;
-
- public XpqlPersistanceVascBackend() {
- }
-
- /**
- * @see net.forwardfire.vasc.backends.jpa.AbstractPersistenceVascBackend#getEntityManager()
- */
- @Override
- EntityManager getEntityManager() {
- emTransaction=entityManagerProvider.hasEntityManagerTransaction();
- return entityManagerProvider.getEntityManager();
+ public PersistanceVascBackendXpqlList() {
}
@Override
- public VascBackendResult execute(VascBackendState state) throws VascBackendException {
- return new DefaultVascBackendResult(executeList(state),fetchTotalExecuteSize(state));
+ protected void startBackendPersistence() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public VascBackendAccessDataRecord createVascBackendAccessDataRecord() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public VascBackendAccessDataKey createVascBackendAccessDataKey() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public EnumSet getSupportedFeatures() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public List getSupportedRowActions() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void executeRowAction(VascBackendListRequest request,List recordPKs, String actionName) throws VascBackendException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public VascBackendListResult execute(VascBackendListRequest state) throws VascBackendException {
+ return new DefaultVascBackendListResult(executeList(state),fetchTotalExecuteSize(state));
}
@SuppressWarnings("unchecked")
- private List executeList(VascBackendState state) throws VascBackendException {
+ private List executeList(VascBackendListRequest state) throws VascBackendException {
+
+ // Copy parameters
+ for (String key:state.getDataParameterKeys()) {
+ Object value = state.getDataParameter(key);
+ query.setQueryParameter(key, value);
+ if (queryTotal!=null) {
+ queryTotal.setQueryParameter(key, value);
+ }
+ }
- // Copy parameters
- for (String key:state.getDataParameterKeys()) {
- Object value = state.getDataParameter(key);
- //System.out.println("Set para pame: "+key+" value: "+value);
- query.setQueryParameter(key, value);
- if (queryTotal!=null) {
- queryTotal.setQueryParameter(key, value);
- }
- }
-
EntityManager em = getEntityManager();
try {
Query q = em.createQuery(query.toPreparedSQL(query));
@@ -109,11 +131,11 @@ public class XpqlPersistanceVascBackend extend
q.setFirstResult(state.getPageIndex()*state.getPageSize());
q.setMaxResults(state.getPageSize());
}
- if (emTransaction) {
+ if (hasTransaction()) {
em.getTransaction().begin();
}
- List data = q.getResultList();
- if (emTransaction) {
+ List data = q.getResultList();
+ if (hasTransaction()) {
em.getTransaction().commit();
}
return data;
@@ -123,24 +145,6 @@ public class XpqlPersistanceVascBackend 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
@@ -155,53 +159,24 @@ public class XpqlPersistanceVascBackend extend
public void setQuery(net.forwardfire.vasc.xpql.query.Query query) {
this.query = query;
}
-
+
/**
* @return the queryTotal
*/
public net.forwardfire.vasc.xpql.query.Query getQueryTotal() {
return queryTotal;
}
-
+
/**
* @param queryTotal the queryTotal to set
*/
public void setQueryTotal(net.forwardfire.vasc.xpql.query.Query queryTotal) {
this.queryTotal = queryTotal;
}
-
+
/**
- * @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() {
if (queryTotal==null) {
return false;
@@ -209,21 +184,21 @@ public class XpqlPersistanceVascBackend extend
return true;
}
- private long fetchTotalExecuteSize(VascBackendState state) {
+ private long fetchTotalExecuteSize(VascBackendListRequest state) {
EntityManager em = getEntityManager();
try {
Query q = em.createQuery(queryTotal.toPreparedSQL(queryTotal));
List values = queryTotal.getOrderQueryParameterValues();
int i = 1;
for (QueryParameterValue value:values) {
- q.setParameter(i,value.getValue());
+ q.setParameter(i,value.getValue());
i++;
}
- if (emTransaction) {
+ if (hasTransaction()) {
em.getTransaction().begin();
}
Long resultTotal = (Long)q.getSingleResult();
- if (emTransaction) {
+ if (hasTransaction()) {
em.getTransaction().commit();
}
return resultTotal;
@@ -234,25 +209,23 @@ public class XpqlPersistanceVascBackend extend
}
}
-
/**
* @see net.forwardfire.vasc.core.AbstractVascBackend#doRecordMoveDownById(VascBackendState state,java.lang.Object)
*/
- @Override
- public long doRecordMoveDownById(VascBackendState state,Object primaryId) throws VascBackendException {
+ public long doRecordMoveDownById(Object primaryId) throws VascBackendException {
long result = 0l;
if (queryMoveDown!=null) {
EntityManager em = getEntityManager();
try {
- if (emTransaction) {
+ if (hasTransaction()) {
em.getTransaction().begin();
}
// Copy parameters
- for (String key:state.getDataParameterKeys()) {
- Object value = state.getDataParameter(key);
- queryMoveDown.setQueryParameter(key, value);
- }
+// for (String key:state.getDataParameterKeys()) {
+// Object value = state.getDataParameter(key);
+// queryMoveDown.setQueryParameter(key, value);
+// }
// set id
queryMoveDown.setQueryParameter("id", primaryId);
@@ -268,10 +241,10 @@ public class XpqlPersistanceVascBackend extend
result+=q.executeUpdate();
// Copy parameters
- for (String key:state.getDataParameterKeys()) {
- Object value = state.getDataParameter(key);
- queryMoveDownUp.setQueryParameter(key, value);
- }
+// for (String key:state.getDataParameterKeys()) {
+// Object value = state.getDataParameter(key);
+// queryMoveDownUp.setQueryParameter(key, value);
+// }
// set id
queryMoveDownUp.setQueryParameter("id", primaryId);
@@ -286,7 +259,7 @@ public class XpqlPersistanceVascBackend