Split backend to backend api.
This commit is contained in:
parent
4bd244f4e5
commit
a13719f008
116 changed files with 1029 additions and 815 deletions
|
|
@ -6,6 +6,7 @@
|
|||
<version>0.4.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>vasc-backend</artifactId>
|
||||
<groupId>net.forwardfire.vasc.backend</groupId>
|
||||
<packaging>pom</packaging>
|
||||
<name>vasc-backend</name>
|
||||
<description>vasc-backend</description>
|
||||
|
|
@ -15,5 +16,6 @@
|
|||
<module>vasc-backend-mongodb</module>
|
||||
<module>vasc-backend-jdbc</module>
|
||||
<module>vasc-backend-metamodel</module>
|
||||
<module>vasc-backend-api</module>
|
||||
</modules>
|
||||
</project>
|
||||
|
|
|
|||
23
vasc-backend/vasc-backend-api/.project
Normal file
23
vasc-backend/vasc-backend-api/.project
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>vasc-backend-api</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
18
vasc-backend/vasc-backend-api/pom.xml
Normal file
18
vasc-backend/vasc-backend-api/pom.xml
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>net.forwardfire.vasc.backend</groupId>
|
||||
<artifactId>vasc-backend</artifactId>
|
||||
<version>0.4.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>vasc-backend-api</artifactId>
|
||||
<name>vasc-backend-api</name>
|
||||
<description>vasc-backend-api</description>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.x4o</groupId>
|
||||
<artifactId>x4o-driver</artifactId>
|
||||
<version>${x4o.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,148 @@
|
|||
/*
|
||||
* 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.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @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()
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#setId(java.lang.String)
|
||||
*/
|
||||
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()
|
||||
*/
|
||||
public void startBackend() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#stopBackend()
|
||||
*/
|
||||
public void stopBackend() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#isReadOnly()
|
||||
*/
|
||||
public boolean isReadOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#isPageable()
|
||||
*/
|
||||
public boolean isPageable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#fetchTotalExecuteSize(VascBackendState state)
|
||||
*/
|
||||
public long fetchTotalExecuteSize(VascBackendState state) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#isSearchable()
|
||||
*/
|
||||
public boolean isSearchable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#isSortable()
|
||||
*/
|
||||
public boolean isSortable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#isRecordMoveable()
|
||||
*/
|
||||
public boolean isRecordMoveable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#doRecordMoveDownById(java.lang.Object)
|
||||
*/
|
||||
public long doRecordMoveDownById(VascBackendState state,Object primaryId) throws VascBackendException {
|
||||
return 0l;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#doRecordMoveUpById(java.lang.Object)
|
||||
*/
|
||||
public long doRecordMoveUpById(VascBackendState state,Object primaryId) throws VascBackendException {
|
||||
return 0l;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#executePageSummary()
|
||||
*/
|
||||
public Map<String, Object> executePageSummary() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#executeTotalSummary()
|
||||
*/
|
||||
public Map<String, Object> executeTotalSummary() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#isPageSummary()
|
||||
*/
|
||||
public boolean isPageSummary() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#isTotalSummary()
|
||||
*/
|
||||
public boolean isTotalSummary() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
/*
|
||||
* 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.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* AbstractVascBackendControllerLocal
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jun 5, 2012
|
||||
*/
|
||||
abstract public class AbstractVascBackendControllerLocal implements VascBackendControllerLocal {
|
||||
|
||||
private Map<String,VascBackend> backends = null;
|
||||
|
||||
public AbstractVascBackendControllerLocal() {
|
||||
backends = new HashMap<String,VascBackend>(1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackendController#getVascBackendById(java.lang.String)
|
||||
*/
|
||||
public VascBackend getVascBackendById(String id) {
|
||||
return backends.get(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackendController#getVascBackendIds()
|
||||
*/
|
||||
public List<String> getVascBackendIds() {
|
||||
List<String> result = new ArrayList<String>(50);
|
||||
for (String id:backends.keySet()) {
|
||||
result.add(id);
|
||||
}
|
||||
Collections.sort(result); // lets do abc for consistance behauvior.
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackendControllerLocal#addVascBackend(net.forwardfire.vasc.backend.VascBackend)
|
||||
*/
|
||||
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();
|
||||
backends.put(backend.getId(), backend);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackendControllerLocal#removeVascBackendById(java.lang.String)
|
||||
*/
|
||||
public void removeVascBackendById(String backendId) {
|
||||
VascBackend backend = getVascBackendById(backendId);
|
||||
if (backend==null) {
|
||||
throw new NullPointerException("Could not find backend to remove with id: "+backendId);
|
||||
}
|
||||
backend.stopBackend();
|
||||
backends.remove(backendId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackendControllerLocal#clearAndStopBackends()
|
||||
*/
|
||||
public void clearAndStopBackends() {
|
||||
for (String backendId:getVascBackendIds()) {
|
||||
removeVascBackendById(backendId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,168 @@
|
|||
/*
|
||||
* 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.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 26, 2009
|
||||
*/
|
||||
abstract public class AbstractVascBackendState implements VascBackendState {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
protected Map<String,Object> parameters = null;
|
||||
private int pageIndex = 0;
|
||||
private int pageSize = 0;
|
||||
private int pageSizeMax = 0;
|
||||
private String sortField = null;
|
||||
private String searchString = null;
|
||||
private boolean ascending = true;
|
||||
//private long pagesTotalRecords = 0;
|
||||
|
||||
public AbstractVascBackendState() {
|
||||
parameters = new HashMap<String,Object>(10);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackendState#setDataParameter(java.lang.String, java.lang.Object)
|
||||
*/
|
||||
public void setDataParameter(String key, Object data) {
|
||||
parameters.put(key,data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackendState#removeDataParameter(java.lang.String)
|
||||
*/
|
||||
public void removeDataParameter(String key) {
|
||||
parameters.remove(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackendState#removeDataParameterAll()
|
||||
*/
|
||||
public void removeDataParameterAll() {
|
||||
parameters.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackendState#getDataParameter(java.lang.String)
|
||||
*/
|
||||
public Object getDataParameter(String key) {
|
||||
return parameters.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackendState#getDataParameterKeys()
|
||||
*/
|
||||
public Set<String> getDataParameterKeys() {
|
||||
return parameters.keySet();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#getPageIndex()
|
||||
*/
|
||||
public int getPageIndex() {
|
||||
return pageIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#setPageIndex(int)
|
||||
*/
|
||||
public void setPageIndex(int pageIndex) {
|
||||
this.pageIndex=pageIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#getPageSize()
|
||||
*/
|
||||
public int getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#setPageSize(int)
|
||||
*/
|
||||
public void setPageSize(int pageSize) {
|
||||
this.pageSize=pageSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#getSearchString()
|
||||
*/
|
||||
public String getSearchString() {
|
||||
return searchString;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#setSearchString(java.lang.String)
|
||||
*/
|
||||
public void setSearchString(String searchString) {
|
||||
this.searchString=searchString;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#isSortAscending()
|
||||
*/
|
||||
public boolean isSortAscending() {
|
||||
return ascending;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#setSortAscending(boolean)
|
||||
*/
|
||||
public void setSortAscending(boolean ascending) {
|
||||
this.ascending=ascending;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#getSortField()
|
||||
*/
|
||||
public String getSortField() {
|
||||
return sortField;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#setSortField(java.lang.String)
|
||||
*/
|
||||
public void setSortField(String sortField) {
|
||||
this.sortField=sortField;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pageSizeMax
|
||||
*/
|
||||
public int getPageSizeMax() {
|
||||
return pageSizeMax;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pageSizeMax the pageSizeMax to set
|
||||
*/
|
||||
public void setPageSizeMax(int pageSizeMax) {
|
||||
this.pageSizeMax = pageSizeMax;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
|
||||
/**
|
||||
* DefaultVascBackendController stores the vasc backends.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Sep 18, 2008
|
||||
*/
|
||||
public class DefaultVascBackendController extends AbstractVascBackendControllerLocal {
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
|
||||
/**
|
||||
* Holds the state for the backend
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 26, 2009
|
||||
*/
|
||||
public class DefaultVascBackendState extends AbstractVascBackendState {
|
||||
|
||||
private static final long serialVersionUID = 8828343641448595993L;
|
||||
}
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
/*
|
||||
* 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.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 21, 2007
|
||||
*/
|
||||
public interface VascBackend {
|
||||
|
||||
public String getId();
|
||||
public void setId(String id);
|
||||
|
||||
public void startBackend();
|
||||
public void stopBackend();
|
||||
|
||||
public List<Object> execute(VascBackendState state) throws VascBackendException;
|
||||
|
||||
public boolean isReadOnly();
|
||||
|
||||
public void persist(Object object) throws VascBackendException;
|
||||
|
||||
public Object merge(Object object) throws VascBackendException;
|
||||
|
||||
public void delete(Object object) 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
|
||||
*/
|
||||
public 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
|
||||
*/
|
||||
public VascEntryRecordCreator provideVascEntryRecordCreator();
|
||||
|
||||
/**
|
||||
* Defines if the backend supports sorting
|
||||
* @return
|
||||
*/
|
||||
public boolean isSortable();
|
||||
|
||||
/**
|
||||
* Defines if the backend supports pageing
|
||||
* @return
|
||||
*/
|
||||
public boolean isPageable();
|
||||
|
||||
/**
|
||||
* Returns the total amount of records.
|
||||
* @return
|
||||
*/
|
||||
public long fetchTotalExecuteSize(VascBackendState state);
|
||||
|
||||
/**
|
||||
* Defines if the backend supports pageing
|
||||
* @return
|
||||
*/
|
||||
public boolean isSearchable();
|
||||
|
||||
/**
|
||||
* Defines if the backend supports moveing an record up or down.
|
||||
* @return
|
||||
*/
|
||||
public boolean isRecordMoveable();
|
||||
public long doRecordMoveUpById(VascBackendState state,Object primaryId) throws VascBackendException;
|
||||
public long doRecordMoveDownById(VascBackendState state,Object primaryId) throws VascBackendException;
|
||||
|
||||
|
||||
public boolean isPageSummary();
|
||||
public Map<String,Object> executePageSummary();
|
||||
|
||||
public boolean isTotalSummary();
|
||||
public Map<String,Object> executeTotalSummary();
|
||||
|
||||
/*
|
||||
public boolean hasSettings();
|
||||
public Map<String,String> getSettings();
|
||||
public void putSetting(String key,String value);
|
||||
*/
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* 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.util.List;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Sep 4, 2008
|
||||
*/
|
||||
public interface VascBackendController {
|
||||
|
||||
public VascBackend getVascBackendById(String id);
|
||||
|
||||
public List<String> getVascBackendIds();
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Nov 17, 2008
|
||||
*/
|
||||
public interface VascBackendControllerLocal extends VascBackendController {
|
||||
|
||||
public void addVascBackend(VascBackend backend);
|
||||
|
||||
public void removeVascBackendById(String backendId);
|
||||
|
||||
public void clearAndStopBackends();
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* VascBackendException wraps the backend exception.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Nov 22, 2013
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class VascBackendException extends Exception {
|
||||
|
||||
|
||||
public VascBackendException() {
|
||||
}
|
||||
|
||||
public VascBackendException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public VascBackendException(Exception e) {
|
||||
super(e);
|
||||
}
|
||||
|
||||
public VascBackendException(String message,Exception e) {
|
||||
super(message,e);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* 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;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Holds all the data the backend needs to know to execute its work.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 26, 2009
|
||||
*/
|
||||
public interface VascBackendState extends Serializable {
|
||||
|
||||
public void setDataParameter(String key,Object data);
|
||||
public void removeDataParameter(String key);
|
||||
public void removeDataParameterAll();
|
||||
public Object getDataParameter(String key);
|
||||
public Set<String> getDataParameterKeys();
|
||||
|
||||
public String getSortField();
|
||||
public void setSortField(String name);
|
||||
public boolean isSortAscending();
|
||||
public void setSortAscending(boolean ascending);
|
||||
|
||||
public void setPageSize(int size);
|
||||
public int getPageSize();
|
||||
|
||||
public void setPageSizeMax(int size);
|
||||
public int getPageSizeMax();
|
||||
|
||||
public void setPageIndex(int index);
|
||||
public int getPageIndex();
|
||||
|
||||
public void setSearchString(String searchString);
|
||||
public String getSearchString();
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
|
||||
/**
|
||||
* VascEntryFieldValue
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 21, 2007
|
||||
*/
|
||||
public interface VascEntryFieldValue extends Serializable {
|
||||
|
||||
public Object getValue(String backendName,Object record) throws VascBackendException;
|
||||
|
||||
public String getDisplayValue(String backendName,Object record) throws VascBackendException;
|
||||
|
||||
public void setValue(String backendName,Object record,Object value) throws VascBackendException;
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 21, 2007
|
||||
*/
|
||||
public interface VascEntryRecordCreator extends Serializable {
|
||||
|
||||
public Object newRecord() throws VascBackendException;
|
||||
|
||||
public Class<?> getObjectClass();
|
||||
}
|
||||
|
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
* 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 net.forwardfire.vasc.backend.VascBackendException;
|
||||
import net.forwardfire.vasc.backend.VascEntryFieldValue;
|
||||
|
||||
import org.x4o.xml.element.DefaultElementObjectPropertyValue;
|
||||
|
||||
/**
|
||||
* BeanVascEntryFieldValue provides get/set support for bean based backends.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Dec 05, 2009
|
||||
*/
|
||||
public class BeanVascEntryFieldValue implements VascEntryFieldValue {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private DefaultElementObjectPropertyValue bean = new DefaultElementObjectPropertyValue();
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.entry.VascEntryFieldValue#getValue(java.lang.String, java.lang.Object)
|
||||
*/
|
||||
public Object getValue(String backendName, Object record) throws VascBackendException {
|
||||
if (backendName==null) {
|
||||
throw new NullPointerException("Can't get value of null backendName.");
|
||||
}
|
||||
if (record==null) {
|
||||
throw new NullPointerException("Can't get value of null object.");
|
||||
}
|
||||
try {
|
||||
Object o = bean.getProperty(record,backendName);
|
||||
return o;
|
||||
} catch (Exception e) {
|
||||
throw new VascBackendException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.entry.VascEntryFieldValue#getDisplayValue(java.lang.String, java.lang.Object)
|
||||
*/
|
||||
public String getDisplayValue(String backendName, Object record) throws VascBackendException {
|
||||
Object 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)
|
||||
*/
|
||||
public void setValue(String backendName, Object record,Object value) throws VascBackendException {
|
||||
if (backendName==null) {
|
||||
throw new NullPointerException("Can't set value of null backendName.");
|
||||
}
|
||||
if (record==null) {
|
||||
throw new NullPointerException("Can't set value of null object.");
|
||||
}
|
||||
try {
|
||||
bean.setProperty(record, backendName, value);
|
||||
} catch (Exception e) {
|
||||
throw new VascBackendException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -20,38 +20,41 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.backend.metamodel.x4o;
|
||||
package net.forwardfire.vasc.backend.data;
|
||||
|
||||
import net.forwardfire.vasc.backend.metamodel.MetaModelSchemaAutoEntry;
|
||||
import net.forwardfire.vasc.core.VascController;
|
||||
import net.forwardfire.vasc.impl.x4o.VascDriver;
|
||||
import net.forwardfire.vasc.backend.VascBackendException;
|
||||
import net.forwardfire.vasc.backend.VascEntryRecordCreator;
|
||||
|
||||
import org.x4o.xml.element.AbstractElementConfigurator;
|
||||
import org.x4o.xml.element.Element;
|
||||
import org.x4o.xml.element.ElementConfiguratorException;
|
||||
|
||||
/**
|
||||
* SchemaAutoEntryElementConfigurator runs the autoCreateEntries method the MetaModelSchemaAutoEntry bean.
|
||||
* BeanVascEntryRecordCreator creates a new backend record based on class object.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 12, 2012
|
||||
* @version 1.0 Dec 05, 2009
|
||||
*/
|
||||
public class SchemaAutoEntryElementConfigurator extends AbstractElementConfigurator {
|
||||
public class BeanVascEntryRecordCreator implements VascEntryRecordCreator {
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.AbstractElementConfigurator#doConfigEndTag(org.x4o.xml.element.Element)
|
||||
*/
|
||||
public void doConfigElement(Element element) throws ElementConfiguratorException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Class<?> resultClass = null;
|
||||
|
||||
public BeanVascEntryRecordCreator(Class<?> resultClass) {
|
||||
if (resultClass==null) {
|
||||
throw new NullPointerException("Can't provide creator service with null class object.");
|
||||
}
|
||||
this.resultClass=resultClass;
|
||||
}
|
||||
|
||||
public Class<?> getObjectClass() {
|
||||
return resultClass;
|
||||
}
|
||||
|
||||
if (element.getElementObject()==null) {
|
||||
throw new ElementConfiguratorException(this,"ElementObject is null");
|
||||
public Object newRecord() throws VascBackendException {
|
||||
try {
|
||||
return resultClass.newInstance();
|
||||
} catch (InstantiationException e) {
|
||||
throw new VascBackendException(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new VascBackendException(e);
|
||||
}
|
||||
if ((element.getElementObject() instanceof MetaModelSchemaAutoEntry)==false) {
|
||||
throw new ElementConfiguratorException(this,"ElementObject is not MetaModelSchemaAutoEntry object.");
|
||||
}
|
||||
MetaModelSchemaAutoEntry autoEntry = (MetaModelSchemaAutoEntry)element.getElementObject();
|
||||
VascController vascController = VascDriver.getVascController(element.getLanguageSession());
|
||||
autoEntry.autoFillResult(vascController);
|
||||
autoEntry.autoAddResultToController();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* 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.util.Map;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackendException;
|
||||
import net.forwardfire.vasc.backend.VascEntryFieldValue;
|
||||
|
||||
|
||||
/**
|
||||
* MapVascEntryFieldValue provides get/set support on Map record object.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Dec 05, 2009
|
||||
*/
|
||||
public class MapVascEntryFieldValue implements VascEntryFieldValue {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.entry.VascEntryFieldValue#getValue(java.lang.String, java.lang.Object)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object getValue(String backendName, Object record) throws VascBackendException {
|
||||
if (backendName==null) {
|
||||
throw new NullPointerException("Can't get value of null backendName field.");
|
||||
}
|
||||
if (record==null) {
|
||||
throw new NullPointerException("Can't get value of null object.");
|
||||
}
|
||||
Map<String,Object> map = (Map<String,Object>)record;
|
||||
Object fieldValue = map.get(backendName);
|
||||
return fieldValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.entry.VascEntryFieldValue#getDisplayValue(net.forwardfire.vasc.core.VascEntryField, java.lang.Object)
|
||||
*/
|
||||
public String getDisplayValue(String field, Object record) throws VascBackendException {
|
||||
Object 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)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setValue(String backendName, Object record,Object value) throws VascBackendException {
|
||||
Map<String,Object> map = (Map<String,Object>)record;
|
||||
map.put(backendName, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* 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.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackendException;
|
||||
import net.forwardfire.vasc.backend.VascEntryRecordCreator;
|
||||
|
||||
|
||||
/**
|
||||
* MapVascEntryRecordCreator creates a new HashMap for Map based record backends.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Dec 05, 2009
|
||||
*/
|
||||
public class MapVascEntryRecordCreator implements VascEntryRecordCreator {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Class<?> getObjectClass() {
|
||||
return Map.class;
|
||||
}
|
||||
|
||||
public Object newRecord() throws VascBackendException {
|
||||
return new HashMap<String,Object>(10);
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>vasc-backend</artifactId>
|
||||
<groupId>net.forwardfire.vasc</groupId>
|
||||
<groupId>net.forwardfire.vasc.backend</groupId>
|
||||
<version>0.4.2-SNAPSHOT</version>
|
||||
<relativePath>..</relativePath>
|
||||
</parent>
|
||||
|
|
@ -11,8 +11,13 @@
|
|||
<description>vasc-backend-jdbc</description>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>net.forwardfire.vasc</groupId>
|
||||
<artifactId>vasc-core</artifactId>
|
||||
<groupId>net.forwardfire.vasc.backend</groupId>
|
||||
<artifactId>vasc-backend-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.forwardfire.vasc.lib</groupId>
|
||||
<artifactId>vasc-lib-xpql</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
|
|
|||
|
|
@ -31,15 +31,12 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import net.forwardfire.vasc.backend.AbstractVascBackend;
|
||||
import net.forwardfire.vasc.backend.VascBackendException;
|
||||
import net.forwardfire.vasc.backend.VascBackendState;
|
||||
import net.forwardfire.vasc.backend.VascEntryFieldValue;
|
||||
import net.forwardfire.vasc.backend.VascEntryRecordCreator;
|
||||
import net.forwardfire.vasc.backend.data.MapVascEntryFieldValue;
|
||||
import net.forwardfire.vasc.backend.data.MapVascEntryRecordCreator;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFieldValue;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryRecordCreator;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -83,7 +80,7 @@ public class JdbcVascBackend extends AbstractVascBackend {
|
|||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state)
|
||||
*/
|
||||
public List<Object> execute(VascBackendState state) throws VascException {
|
||||
public List<Object> execute(VascBackendState state) throws VascBackendException {
|
||||
JdbcConnectionProvider prov = getJdbcConnectionProvider();
|
||||
List<Object> result = new ArrayList<Object>(50);
|
||||
Connection connection = null;
|
||||
|
|
@ -103,7 +100,7 @@ public class JdbcVascBackend extends AbstractVascBackend {
|
|||
result.add(map);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new VascException(e);
|
||||
throw new VascBackendException(e);
|
||||
} finally {
|
||||
if (connection!=null) {
|
||||
try {
|
||||
|
|
@ -118,33 +115,33 @@ public class JdbcVascBackend extends AbstractVascBackend {
|
|||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#merge(java.lang.Object)
|
||||
*/
|
||||
public Object merge(Object object) throws VascException {
|
||||
public Object merge(Object object) throws VascBackendException {
|
||||
return object;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#persist(java.lang.Object)
|
||||
*/
|
||||
public void persist(Object object) throws VascException {
|
||||
public void persist(Object object) throws VascBackendException {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#delete(java.lang.Object)
|
||||
*/
|
||||
public void delete(Object object) throws VascException {
|
||||
public void delete(Object object) throws VascBackendException {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryFieldValue(net.forwardfire.vasc.core.VascEntryField)
|
||||
*/
|
||||
public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) {
|
||||
public VascEntryFieldValue provideVascEntryFieldValue() {
|
||||
return new MapVascEntryFieldValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryRecordCreator(net.forwardfire.vasc.core.VascEntry)
|
||||
*/
|
||||
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
|
||||
public VascEntryRecordCreator provideVascEntryRecordCreator() {
|
||||
return new MapVascEntryRecordCreator();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,14 +31,12 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import net.forwardfire.vasc.backend.AbstractVascBackend;
|
||||
import net.forwardfire.vasc.backend.VascBackendException;
|
||||
import net.forwardfire.vasc.backend.VascBackendState;
|
||||
import net.forwardfire.vasc.backend.VascEntryFieldValue;
|
||||
import net.forwardfire.vasc.backend.VascEntryRecordCreator;
|
||||
import net.forwardfire.vasc.backend.data.MapVascEntryFieldValue;
|
||||
import net.forwardfire.vasc.backend.data.MapVascEntryRecordCreator;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFieldValue;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryRecordCreator;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.xpql.query.QueryParameterValue;
|
||||
|
||||
|
||||
|
|
@ -94,7 +92,7 @@ public class JdbcVascBackendXpql extends AbstractVascBackend {
|
|||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state)
|
||||
*/
|
||||
public List<Object> execute(VascBackendState state) throws VascException {
|
||||
public List<Object> execute(VascBackendState state) throws VascBackendException {
|
||||
// Copy parameters
|
||||
for (String key:state.getDataParameterKeys()) {
|
||||
Object value = state.getDataParameter(key);
|
||||
|
|
@ -126,7 +124,7 @@ public class JdbcVascBackendXpql extends AbstractVascBackend {
|
|||
}
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
throw new VascException(e);
|
||||
throw new VascBackendException(e);
|
||||
} finally {
|
||||
if (c!=null) {
|
||||
try {
|
||||
|
|
@ -140,33 +138,33 @@ public class JdbcVascBackendXpql extends AbstractVascBackend {
|
|||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#merge(java.lang.Object)
|
||||
*/
|
||||
public Object merge(Object object) throws VascException {
|
||||
public Object merge(Object object) throws VascBackendException {
|
||||
return object;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#persist(java.lang.Object)
|
||||
*/
|
||||
public void persist(Object object) throws VascException {
|
||||
public void persist(Object object) throws VascBackendException {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#delete(java.lang.Object)
|
||||
*/
|
||||
public void delete(Object object) throws VascException {
|
||||
public void delete(Object object) throws VascBackendException {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryFieldValue(net.forwardfire.vasc.core.VascEntryField)
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryFieldValue()
|
||||
*/
|
||||
public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) {
|
||||
public VascEntryFieldValue provideVascEntryFieldValue() {
|
||||
return new MapVascEntryFieldValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryRecordCreator(net.forwardfire.vasc.core.VascEntry)
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryRecordCreator()
|
||||
*/
|
||||
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
|
||||
public VascEntryRecordCreator provideVascEntryRecordCreator() {
|
||||
return new MapVascEntryRecordCreator();
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>vasc-backend</artifactId>
|
||||
<groupId>net.forwardfire.vasc</groupId>
|
||||
<groupId>net.forwardfire.vasc.backend</groupId>
|
||||
<version>0.4.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>vasc-backend-jpa</artifactId>
|
||||
|
|
@ -10,8 +10,13 @@
|
|||
<description>vasc-backend-jpa</description>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>net.forwardfire.vasc</groupId>
|
||||
<artifactId>vasc-core</artifactId>
|
||||
<groupId>net.forwardfire.vasc.backend</groupId>
|
||||
<artifactId>vasc-backend-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.forwardfire.vasc.lib</groupId>
|
||||
<artifactId>vasc-lib-xpql</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
package net.forwardfire.vasc.backends.jpa;
|
||||
|
||||
import net.forwardfire.vasc.backend.AbstractVascBackend;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.backend.VascBackendException;
|
||||
|
||||
import org.hibernate.Session;
|
||||
|
||||
|
|
@ -41,7 +41,7 @@ abstract public class AbstractHibernateVascBackend extends AbstractVascBackend
|
|||
*/
|
||||
abstract Session getHibernateSession();
|
||||
|
||||
public void persist(Object object) throws VascException {
|
||||
public void persist(Object object) throws VascBackendException {
|
||||
Session s = getHibernateSession();
|
||||
try {
|
||||
s.getTransaction().begin();
|
||||
|
|
@ -57,7 +57,7 @@ abstract public class AbstractHibernateVascBackend extends AbstractVascBackend
|
|||
}
|
||||
}
|
||||
|
||||
public Object merge(Object object) throws VascException {
|
||||
public Object merge(Object object) throws VascBackendException {
|
||||
Session s = getHibernateSession();
|
||||
try {
|
||||
s.getTransaction().begin();
|
||||
|
|
@ -74,7 +74,7 @@ abstract public class AbstractHibernateVascBackend extends AbstractVascBackend
|
|||
}
|
||||
}
|
||||
|
||||
public void delete(Object object) throws VascException {
|
||||
public void delete(Object object) throws VascBackendException {
|
||||
Session s = getHibernateSession();
|
||||
try {
|
||||
s.getTransaction().begin();
|
||||
|
|
|
|||
|
|
@ -22,13 +22,10 @@
|
|||
|
||||
package net.forwardfire.vasc.backends.jpa;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
|
||||
import net.forwardfire.vasc.backend.AbstractVascBackend;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackendException;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -41,7 +38,7 @@ abstract public class AbstractPersistenceVascBackend extends AbstractVascBackend
|
|||
|
||||
abstract EntityManager getEntityManager();
|
||||
|
||||
public void persist(Object object) throws VascException {
|
||||
public void persist(Object object) throws VascBackendException {
|
||||
EntityManager s = getEntityManager();
|
||||
try {
|
||||
if (emTransaction) {
|
||||
|
|
@ -58,7 +55,7 @@ abstract public class AbstractPersistenceVascBackend extends AbstractVascBackend
|
|||
}
|
||||
}
|
||||
|
||||
public Object merge(Object object) throws VascException {
|
||||
public Object merge(Object object) throws VascBackendException {
|
||||
EntityManager s = getEntityManager();
|
||||
try {
|
||||
if (emTransaction) {
|
||||
|
|
@ -76,7 +73,7 @@ abstract public class AbstractPersistenceVascBackend extends AbstractVascBackend
|
|||
}
|
||||
}
|
||||
|
||||
public void delete(Object object) throws VascException {
|
||||
public void delete(Object object) throws VascBackendException {
|
||||
EntityManager s = getEntityManager();
|
||||
try {
|
||||
if (emTransaction) {
|
||||
|
|
|
|||
|
|
@ -24,14 +24,12 @@ package net.forwardfire.vasc.backends.jpa;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackendException;
|
||||
import net.forwardfire.vasc.backend.VascBackendState;
|
||||
import net.forwardfire.vasc.backend.VascEntryFieldValue;
|
||||
import net.forwardfire.vasc.backend.VascEntryRecordCreator;
|
||||
import net.forwardfire.vasc.backend.data.BeanVascEntryFieldValue;
|
||||
import net.forwardfire.vasc.backend.data.BeanVascEntryRecordCreator;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFieldValue;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryRecordCreator;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.xpql.query.QueryParameterValue;
|
||||
|
||||
import org.hibernate.Hibernate;
|
||||
|
|
@ -75,11 +73,11 @@ public class XpqlHibernateVascBackend extends AbstractHibernateVascBackend {
|
|||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Object> execute(VascBackendState state) throws VascException {
|
||||
public List<Object> execute(VascBackendState state) throws VascBackendException {
|
||||
|
||||
// Copy parameters
|
||||
for (String key:state.getDataParameterKeys()) {
|
||||
Object value = state.getDataParameter(key);
|
||||
Object value = state.getDataParameter(key);
|
||||
query.setQueryParameter(key, value);
|
||||
if (queryTotal!=null) {
|
||||
queryTotal.setQueryParameter(key, value);
|
||||
|
|
@ -116,17 +114,17 @@ public class XpqlHibernateVascBackend extends AbstractHibernateVascBackend {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryFieldValue(net.forwardfire.vasc.core.VascEntryField)
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryFieldValue()
|
||||
*/
|
||||
public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) {
|
||||
public VascEntryFieldValue provideVascEntryFieldValue() {
|
||||
BeanVascEntryFieldValue result = new BeanVascEntryFieldValue();
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryRecordCreator(net.forwardfire.vasc.core.VascEntry)
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryRecordCreator()
|
||||
*/
|
||||
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
|
||||
public VascEntryRecordCreator provideVascEntryRecordCreator() {
|
||||
return new BeanVascEntryRecordCreator(resultClass);
|
||||
}
|
||||
|
||||
|
|
@ -230,7 +228,7 @@ public class XpqlHibernateVascBackend extends AbstractHibernateVascBackend {
|
|||
* @see net.forwardfire.vasc.backend.AbstractVascBackend#doRecordMoveDownById(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public long doRecordMoveDownById(VascBackendState state,Object primaryId) throws VascException {
|
||||
public long doRecordMoveDownById(VascBackendState state,Object primaryId) throws VascBackendException {
|
||||
long result = 0l;
|
||||
if (queryMoveDown!=null) {
|
||||
Session s = getHibernateSession();
|
||||
|
|
@ -299,7 +297,7 @@ public class XpqlHibernateVascBackend extends AbstractHibernateVascBackend {
|
|||
* @see net.forwardfire.vasc.backend.AbstractVascBackend#doRecordMoveUpById(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public long doRecordMoveUpById(VascBackendState state,Object primaryId) throws VascException {
|
||||
public long doRecordMoveUpById(VascBackendState state,Object primaryId) throws VascBackendException {
|
||||
long result = 0l;
|
||||
if (queryMoveUp!=null) {
|
||||
Session s = getHibernateSession();
|
||||
|
|
|
|||
|
|
@ -27,14 +27,12 @@ import java.util.List;
|
|||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.Query;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackendException;
|
||||
import net.forwardfire.vasc.backend.VascBackendState;
|
||||
import net.forwardfire.vasc.backend.VascEntryFieldValue;
|
||||
import net.forwardfire.vasc.backend.VascEntryRecordCreator;
|
||||
import net.forwardfire.vasc.backend.data.BeanVascEntryFieldValue;
|
||||
import net.forwardfire.vasc.backend.data.BeanVascEntryRecordCreator;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFieldValue;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryRecordCreator;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.xpql.query.QueryParameterValue;
|
||||
|
||||
|
||||
|
|
@ -78,7 +76,7 @@ public class XpqlPersistanceVascBackend extends AbstractPersistenceVascBackend
|
|||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Object> execute(VascBackendState state) throws VascException {
|
||||
public List<Object> execute(VascBackendState state) throws VascBackendException {
|
||||
|
||||
// Copy parameters
|
||||
for (String key:state.getDataParameterKeys()) {
|
||||
|
|
@ -121,17 +119,17 @@ public class XpqlPersistanceVascBackend extends AbstractPersistenceVascBackend
|
|||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryFieldValue(net.forwardfire.vasc.core.VascEntryField)
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryFieldValue()
|
||||
*/
|
||||
public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) {
|
||||
public VascEntryFieldValue provideVascEntryFieldValue() {
|
||||
VascEntryFieldValue result = new BeanVascEntryFieldValue();
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryRecordCreator(net.forwardfire.vasc.core.VascEntry)
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryRecordCreator()
|
||||
*/
|
||||
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
|
||||
public VascEntryRecordCreator provideVascEntryRecordCreator() {
|
||||
VascEntryRecordCreator result = new BeanVascEntryRecordCreator(resultClass);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -236,7 +234,7 @@ public class XpqlPersistanceVascBackend extends AbstractPersistenceVascBackend
|
|||
* @see net.forwardfire.vasc.core.AbstractVascBackend#doRecordMoveDownById(VascBackendState state,java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public long doRecordMoveDownById(VascBackendState state,Object primaryId) throws VascException {
|
||||
public long doRecordMoveDownById(VascBackendState state,Object primaryId) throws VascBackendException {
|
||||
long result = 0l;
|
||||
if (queryMoveDown!=null) {
|
||||
EntityManager em = getEntityManager();
|
||||
|
|
@ -299,7 +297,7 @@ public class XpqlPersistanceVascBackend extends AbstractPersistenceVascBackend
|
|||
* @see net.forwardfire.vasc.core.AbstractVascBackend#doRecordMoveUpById(VascBackendState state,java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public long doRecordMoveUpById(VascBackendState state,Object primaryId) throws VascException {
|
||||
public long doRecordMoveUpById(VascBackendState state,Object primaryId) throws VascBackendException {
|
||||
long result = 0l;
|
||||
if (queryMoveUp!=null) {
|
||||
EntityManager em = getEntityManager();
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>vasc-backend</artifactId>
|
||||
<groupId>net.forwardfire.vasc</groupId>
|
||||
<groupId>net.forwardfire.vasc.backend</groupId>
|
||||
<version>0.4.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>vasc-backend-ldap</artifactId>
|
||||
|
|
@ -10,8 +10,8 @@
|
|||
<description>vasc-backend-ldap</description>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>net.forwardfire.vasc</groupId>
|
||||
<artifactId>vasc-core</artifactId>
|
||||
<groupId>net.forwardfire.vasc.backend</groupId>
|
||||
<artifactId>vasc-backend-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
|||
|
|
@ -29,15 +29,12 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import net.forwardfire.vasc.backend.AbstractVascBackend;
|
||||
import net.forwardfire.vasc.backend.VascBackendException;
|
||||
import net.forwardfire.vasc.backend.VascBackendState;
|
||||
import net.forwardfire.vasc.backend.VascEntryFieldValue;
|
||||
import net.forwardfire.vasc.backend.VascEntryRecordCreator;
|
||||
import net.forwardfire.vasc.backend.data.MapVascEntryFieldValue;
|
||||
import net.forwardfire.vasc.backend.data.MapVascEntryRecordCreator;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFieldValue;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryRecordCreator;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
|
||||
|
||||
import com.novell.ldap.LDAPAttribute;
|
||||
import com.novell.ldap.LDAPAttributeSet;
|
||||
|
|
@ -53,7 +50,7 @@ import com.novell.ldap.LDAPSearchResults;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 Sep 4, 2008
|
||||
*/
|
||||
public class LdapVascBackend extends AbstractVascBackend {
|
||||
public class LdapVascBackend extends AbstractVascBackend {
|
||||
|
||||
|
||||
private LdapConnectionProvider ldapConnectionProvider = null;
|
||||
|
|
@ -81,7 +78,7 @@ public class LdapVascBackend extends AbstractVascBackend {
|
|||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#execute()
|
||||
*/
|
||||
public List<Object> execute(VascBackendState state) throws VascException {
|
||||
public List<Object> execute(VascBackendState state) throws VascBackendException {
|
||||
LdapConnectionProvider prov = getLdapConnectionProvider();
|
||||
LDAPConnection connection = prov.getLdapConnection();
|
||||
List<Object> result = new ArrayList<Object>(50);
|
||||
|
|
@ -125,7 +122,7 @@ public class LdapVascBackend extends AbstractVascBackend {
|
|||
result.add(map);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new VascException(e);
|
||||
throw new VascBackendException(e);
|
||||
} finally {
|
||||
if (connection!=null) {
|
||||
connection.clone();
|
||||
|
|
@ -137,7 +134,7 @@ public class LdapVascBackend extends AbstractVascBackend {
|
|||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#merge(java.lang.Object)
|
||||
*/
|
||||
public Object merge(Object object) throws VascException {
|
||||
public Object merge(Object object) throws VascBackendException {
|
||||
LdapConnectionProvider prov = getLdapConnectionProvider();
|
||||
LDAPConnection connection = prov.getLdapConnection();
|
||||
try {
|
||||
|
|
@ -209,7 +206,7 @@ public class LdapVascBackend extends AbstractVascBackend {
|
|||
|
||||
return object;
|
||||
} catch (Exception e) {
|
||||
throw new VascException(e);
|
||||
throw new VascBackendException(e);
|
||||
} finally {
|
||||
if (connection!=null) {
|
||||
connection.clone();
|
||||
|
|
@ -220,7 +217,7 @@ public class LdapVascBackend extends AbstractVascBackend {
|
|||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#persist(java.lang.Object)
|
||||
*/
|
||||
public void persist(Object object) throws VascException {
|
||||
public void persist(Object object) throws VascBackendException {
|
||||
Map<String,Object> map = (Map)object;
|
||||
LdapConnectionProvider prov = getLdapConnectionProvider();
|
||||
LDAPConnection connection = prov.getLdapConnection();
|
||||
|
|
@ -246,7 +243,7 @@ public class LdapVascBackend extends AbstractVascBackend {
|
|||
}
|
||||
connection.add(entry);
|
||||
} catch (Exception e) {
|
||||
throw new VascException(e);
|
||||
throw new VascBackendException(e);
|
||||
} finally {
|
||||
if (connection!=null) {
|
||||
connection.clone();
|
||||
|
|
@ -257,7 +254,7 @@ public class LdapVascBackend extends AbstractVascBackend {
|
|||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#delete(java.lang.Object)
|
||||
*/
|
||||
public void delete(Object object) throws VascException {
|
||||
public void delete(Object object) throws VascBackendException {
|
||||
LdapConnectionProvider prov = getLdapConnectionProvider();
|
||||
LDAPConnection connection = prov.getLdapConnection();
|
||||
try {
|
||||
|
|
@ -280,7 +277,7 @@ public class LdapVascBackend extends AbstractVascBackend {
|
|||
LDAPEntry entry = searchResults.next();
|
||||
connection.delete(entry.getDN());
|
||||
} catch (Exception e) {
|
||||
throw new VascException(e);
|
||||
throw new VascBackendException(e);
|
||||
} finally {
|
||||
if (connection!=null) {
|
||||
connection.clone();
|
||||
|
|
@ -289,16 +286,16 @@ public class LdapVascBackend extends AbstractVascBackend {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryRecordCreator(net.forwardfire.vasc.core.VascEntry)
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryRecordCreator()
|
||||
*/
|
||||
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
|
||||
public VascEntryRecordCreator provideVascEntryRecordCreator() {
|
||||
return new MapVascEntryRecordCreator();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryFieldValue(net.forwardfire.vasc.core.VascEntryField)
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryFieldValue()
|
||||
*/
|
||||
public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) {
|
||||
public VascEntryFieldValue provideVascEntryFieldValue() {
|
||||
return new MapVascEntryFieldValue();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>vasc-backend</artifactId>
|
||||
<groupId>net.forwardfire.vasc</groupId>
|
||||
<groupId>net.forwardfire.vasc.backend</groupId>
|
||||
<version>0.4.2-SNAPSHOT</version>
|
||||
<relativePath>..</relativePath>
|
||||
</parent>
|
||||
|
|
@ -11,8 +11,8 @@
|
|||
<description>vasc-backend-metamodel</description>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>net.forwardfire.vasc</groupId>
|
||||
<artifactId>vasc-core</artifactId>
|
||||
<groupId>net.forwardfire.vasc.backend</groupId>
|
||||
<artifactId>vasc-backend-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
|||
|
|
@ -1,528 +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.metamodel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.eobjects.metamodel.DataContext;
|
||||
import org.eobjects.metamodel.schema.Column;
|
||||
import org.eobjects.metamodel.schema.Relationship;
|
||||
import org.eobjects.metamodel.schema.Table;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackend;
|
||||
import net.forwardfire.vasc.backend.VascBackendControllerLocal;
|
||||
import net.forwardfire.vasc.core.VascController;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryAccessType;
|
||||
import net.forwardfire.vasc.core.VascEntryControllerLocal;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascEntryFieldLocal;
|
||||
import net.forwardfire.vasc.core.VascEntryGroupLocal;
|
||||
import net.forwardfire.vasc.core.VascEntryLinkType;
|
||||
import net.forwardfire.vasc.core.VascEntryLocal;
|
||||
|
||||
import net.forwardfire.vasc.impl.DefaultVascEntry;
|
||||
import net.forwardfire.vasc.impl.DefaultVascEntryField;
|
||||
import net.forwardfire.vasc.impl.DefaultVascEntryLink;
|
||||
import net.forwardfire.vasc.impl.ui.VascSelectItemModelEntry;
|
||||
|
||||
/**
|
||||
* MetaModelSchemaAutoEntry
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 2, 2012
|
||||
*/
|
||||
public class MetaModelSchemaAutoEntry {
|
||||
|
||||
private Logger logger = null;
|
||||
private VascController vascController = null;
|
||||
private MetaModelDataContextProvider dataContextProvider = null;
|
||||
private List<String> tables = null;
|
||||
private String tableInclude = null;
|
||||
private String tableExclude = null;
|
||||
private String entryPrefix = null;
|
||||
private String vascGroupId = null;
|
||||
private String veLinkPostfix = "_velink";
|
||||
private String veListPostfix = "_velist";
|
||||
|
||||
private Map<String,VascEntryLocal> resultEntries = null;
|
||||
private Map<String,VascEntryGroupLocal> resultEntryGroups = null;
|
||||
private Map<String,MetaModelVascBackend> resultBackends = null;
|
||||
|
||||
public MetaModelSchemaAutoEntry() {
|
||||
logger = Logger.getLogger(MetaModelSchemaAutoEntry.class.getName());
|
||||
tables = new ArrayList<String>();
|
||||
resultEntries = new HashMap<String,VascEntryLocal>();
|
||||
resultEntryGroups = new HashMap<String,VascEntryGroupLocal>();
|
||||
resultBackends = new HashMap<String,MetaModelVascBackend>();
|
||||
}
|
||||
|
||||
public void autoFillResult(VascController vascController) {
|
||||
if (getDataContextProvider()==null) {
|
||||
throw new NullPointerException("Can't auto create entries with null dataContextProvider.");
|
||||
}
|
||||
if (getEntryPrefix()==null) {
|
||||
throw new NullPointerException("Can't auto create with null entryPrefix.");
|
||||
}
|
||||
this.vascController=vascController;
|
||||
|
||||
DataContext ds = getDataContextProvider().getDataContext();
|
||||
for (String table:ds.getDefaultSchema().getTableNames()) {
|
||||
if (tables.isEmpty()==false && tables.contains(table)==false) {
|
||||
logger.finer("Excluding table: "+table+" because not in table list.");
|
||||
continue;
|
||||
}
|
||||
if (getTableInclude()!=null && table.matches(getTableInclude())==false) {
|
||||
logger.finer("Excluding table: "+table+" from include rule.");
|
||||
continue;
|
||||
}
|
||||
if (getTableExclude()!=null && table.matches(getTableExclude())) {
|
||||
logger.finer("Excluding table: "+table+" from exclude rule.");
|
||||
continue;
|
||||
}
|
||||
createMetaEntry(ds,getEntryPrefix()+"_"+table,table);
|
||||
}
|
||||
}
|
||||
|
||||
public void autoAddResultToController() {
|
||||
for (VascBackend backend:resultBackends.values()) {
|
||||
((VascBackendControllerLocal)getVascController().getVascBackendController()).addVascBackend(backend);
|
||||
}
|
||||
for (VascEntryLocal ve:resultEntries.values()) {
|
||||
((VascEntryControllerLocal)getVascController().getVascEntryController()).addVascEntry(ve);
|
||||
}
|
||||
for (VascEntryGroupLocal veg:resultEntryGroups.values()) {
|
||||
((VascEntryControllerLocal)getVascController().getVascEntryController()).addVascEntryGroup(veg);
|
||||
}
|
||||
}
|
||||
|
||||
private VascController getVascController() {
|
||||
return vascController;
|
||||
}
|
||||
|
||||
private void createMetaEntry(DataContext ds,String id,String tableName) {
|
||||
logger.fine("Creating entry id: "+id+" of table: "+tableName);
|
||||
Table metaTable = null;
|
||||
if (tableName==null) {
|
||||
metaTable = ds.getDefaultSchema().getTable(0);
|
||||
} else {
|
||||
metaTable = ds.getDefaultSchema().getTableByName(tableName);
|
||||
}
|
||||
Column[] keys = metaTable.getPrimaryKeys();
|
||||
Column[] cols = metaTable.getColumns();
|
||||
if (cols.length==0) {
|
||||
return; // vasc needs at least one column
|
||||
}
|
||||
|
||||
MetaModelVascBackend backend = new MetaModelVascBackend();
|
||||
backend.setId(id+"_backend");
|
||||
backend.setDataContextProvider(getDataContextProvider());
|
||||
backend.setTable(metaTable.getName());
|
||||
if (keys.length>0) {
|
||||
backend.setTableId(keys[0].getName());
|
||||
} else {
|
||||
backend.setTableId(cols[0].getName());
|
||||
//TODO backend.setRequestReadOnly(true);
|
||||
}
|
||||
|
||||
DefaultVascEntry ve = new DefaultVascEntry();
|
||||
ve.setId(id);
|
||||
ve.setBackendId(id+"_backend");
|
||||
ve.setPrimaryKeyFieldId(backend.getTableId());
|
||||
ve.setVascGroupId(getVascGroupId());
|
||||
createFields(ve,cols);
|
||||
|
||||
for (Relationship rs:metaTable.getRelationships()) {
|
||||
logger.finer("Found relation FT: "+rs.getForeignTable().getName()+" PT: "+rs.getPrimaryTable().getName());
|
||||
if (tableName.equals(rs.getForeignTable().getName())==false) {
|
||||
logger.finer("Creating Link entry for: "+rs.getForeignColumns()[0].getName()+" of table: "+rs.getForeignTable().getName());
|
||||
createLinkEntry(rs,ve,metaTable);
|
||||
} else {
|
||||
logger.finer("Creating List entry for: "+rs.getPrimaryColumns()[0].getName()+" of table: "+rs.getPrimaryTable().getName());
|
||||
createListEntry(rs,ve,metaTable);
|
||||
}
|
||||
}
|
||||
|
||||
resultBackends.put(backend.getId(),backend);
|
||||
resultEntries.put(ve.getId(),ve);
|
||||
}
|
||||
|
||||
private void createLinkEntry(Relationship rs2,VascEntryLocal ve,Table metaTable) {
|
||||
String id = getEntryPrefix()+"_"+rs2.getForeignTable().getName()+getVeLinkPostfix();
|
||||
MetaModelVascBackend backendLink = new MetaModelVascBackend();
|
||||
backendLink.setId(id+"_backend");
|
||||
backendLink.setDataContextProvider(getDataContextProvider());
|
||||
backendLink.setTable(rs2.getForeignTable().getName());
|
||||
|
||||
Column[] keys = rs2.getForeignTable().getPrimaryKeys();
|
||||
Column[] cols = rs2.getForeignTable().getColumns();
|
||||
if (cols.length==0) {
|
||||
return;
|
||||
}
|
||||
if (keys.length>0) {
|
||||
backendLink.setTableId(keys[0].getName());
|
||||
} else {
|
||||
backendLink.setTableId(cols[0].getName());
|
||||
}
|
||||
|
||||
DefaultVascEntry veLink = new DefaultVascEntry();
|
||||
veLink.setId(id);
|
||||
veLink.setBackendId(id+"_backend");
|
||||
veLink.setPrimaryKeyFieldId(backendLink.getTableId());
|
||||
veLink.setVascGroupId(getVascGroupId());
|
||||
veLink.setAccessType(VascEntryAccessType.ENTRY_LINK);
|
||||
createFields(veLink,cols);
|
||||
|
||||
if (resultBackends.containsKey(backendLink.getId())==false) {
|
||||
resultBackends.put(backendLink.getId(),backendLink);
|
||||
resultEntries.put(veLink.getId(),veLink);
|
||||
}
|
||||
|
||||
for (Relationship rs:rs2.getForeignTable().getRelationships()) {
|
||||
logger.finer("Found relation FT: "+rs.getForeignTable().getName()+" PT: "+rs.getPrimaryTable().getName());
|
||||
if (rs2.getForeignTable().getName().equals(rs.getForeignTable().getName())==false) {
|
||||
//logger.info("Creating Link entry for: "+rs.getForeignColumns()[0].getName()+" of table: "+rs.getForeignTable().getName());
|
||||
//createLinkEntry(rs,veLink,rs2.getForeignTable());
|
||||
} else {
|
||||
logger.fine("Creating List entry for: "+rs.getPrimaryColumns()[0].getName()+" of table: "+rs.getPrimaryTable().getName());
|
||||
createListEntry(rs,veLink,rs2.getForeignTable());
|
||||
}
|
||||
}
|
||||
|
||||
DefaultVascEntryLink vle = new DefaultVascEntryLink();
|
||||
vle.setId(id+"Link");
|
||||
vle.setVascEntryLinkType(VascEntryLinkType.DEFAULT_TYPE);
|
||||
vle.setVascEntryId(id);
|
||||
vle.addEntryParameterFieldId(rs2.getForeignColumns()[0].getName(), rs2.getPrimaryColumns()[0].getName());
|
||||
|
||||
ve.addVascEntryLink(vle);
|
||||
}
|
||||
|
||||
private void createListEntry(Relationship rs,VascEntry ve,Table metaTable) {
|
||||
String id = getEntryPrefix()+"_"+rs.getPrimaryTable().getName()+getVeListPostfix();
|
||||
MetaModelVascBackend backendList = new MetaModelVascBackend();
|
||||
backendList.setId(id+"_backend");
|
||||
backendList.setDataContextProvider(getDataContextProvider());
|
||||
backendList.setTable(rs.getPrimaryTable().getName());
|
||||
|
||||
Column[] keys = rs.getPrimaryTable().getPrimaryKeys();
|
||||
Column[] cols = rs.getPrimaryTable().getColumns();
|
||||
if (cols.length==0) {
|
||||
return;
|
||||
}
|
||||
if (keys.length>0) {
|
||||
backendList.setTableId(keys[0].getName());
|
||||
} else {
|
||||
backendList.setTableId(cols[0].getName());
|
||||
}
|
||||
DefaultVascEntry veList = new DefaultVascEntry();
|
||||
veList.setId(id);
|
||||
veList.setBackendId(id+"_backend");
|
||||
veList.setPrimaryKeyFieldId(backendList.getTableId());
|
||||
veList.setVascGroupId(getVascGroupId());
|
||||
veList.setAccessType(VascEntryAccessType.ENTRY_LIST);
|
||||
createFields(veList,cols);
|
||||
|
||||
if (resultBackends.containsKey(backendList.getId())==false) {
|
||||
resultBackends.put(backendList.getId(),backendList);
|
||||
resultEntries.put(veList.getId(),veList);
|
||||
}
|
||||
|
||||
VascEntryFieldLocal vef = (VascEntryFieldLocal)ve.getVascEntryFieldById(rs.getForeignColumns()[0].getName());
|
||||
if (vef==null) {
|
||||
logger.warning("Could not find: "+rs.getForeignColumns()[0].getName()+" in ve: "+ve.getId());
|
||||
return;
|
||||
}
|
||||
vef.setVascEntryFieldType(getVascController().getVascEntryFieldTypeController().getVascEntryFieldTypeById("ListField"));
|
||||
|
||||
VascSelectItemModelEntry itemModel = new VascSelectItemModelEntry();
|
||||
itemModel.setEntryId(veList.getId());
|
||||
if (veList.getDisplayNameFieldId()==null) {
|
||||
itemModel.setDisplayFieldId(veList.getPrimaryKeyFieldId()); // display can be null see createFields(), in vasc display is not null but defaulted on primary id.
|
||||
} else {
|
||||
itemModel.setDisplayFieldId(veList.getDisplayNameFieldId());
|
||||
}
|
||||
|
||||
vef.getVascEntryFieldType().setDataObject(itemModel);
|
||||
|
||||
}
|
||||
|
||||
private void createFields(VascEntryLocal ve,Column[] cols) {
|
||||
for (Column c:cols) {
|
||||
String name = c.getName().toLowerCase();
|
||||
DefaultVascEntryField vef = new DefaultVascEntryField();
|
||||
vef.setId(c.getName());
|
||||
vef.setVascEntryFieldType(getVascController().getVascEntryFieldTypeController().getVascEntryFieldTypeByClass(c.getType().getJavaEquivalentClass()));
|
||||
|
||||
if (vef.getId().equals(ve.getPrimaryKeyFieldId())) {
|
||||
vef.setEditReadOnly(true);
|
||||
vef.setCreate(false);
|
||||
}
|
||||
|
||||
if (vef.getVascEntryFieldType()==null || "TextField".equals(vef.getVascEntryFieldType().getId())) {
|
||||
if (name.contains("desc") || name.contains("text") || name.contains("comment") || name.contains("memo") ) {
|
||||
vef.setVascEntryFieldType(getVascController().getVascEntryFieldTypeController().getVascEntryFieldTypeById("TextAreaField"));
|
||||
}
|
||||
if (name.contains("active")) {
|
||||
vef.setDefaultValue("true");
|
||||
vef.setVascEntryFieldType(getVascController().getVascEntryFieldTypeController().getVascEntryFieldTypeById("BooleanField"));
|
||||
} /* todo
|
||||
if (c.getName().toLowerCase().contains("email")) {
|
||||
vef.setVascEntryFieldType(getVascController().getVascEntryFieldTypeController().getVascEntryFieldTypeById("EmailField"));
|
||||
}
|
||||
if (c.getName().toLowerCase().contains("url")) {
|
||||
vef.setVascEntryFieldType(getVascController().getVascEntryFieldTypeController().getVascEntryFieldTypeById("URLField"));
|
||||
} */
|
||||
}
|
||||
|
||||
if (vef.getVascEntryFieldType()!=null && vef.getVascEntryFieldType().getAutoDetectClass()==Date.class) {
|
||||
vef.setDefaultValue("now()");
|
||||
if (name.contains("create") || name.contains("modified")) {
|
||||
vef.setEdit(false);
|
||||
vef.setCreate(false);
|
||||
}
|
||||
if (name.contains("update")) {
|
||||
vef.setCreate(false);
|
||||
}
|
||||
}
|
||||
|
||||
ve.addVascEntryField(vef);
|
||||
if (ve.getDisplayNameFieldId()==null && c.getName().equals(ve.getPrimaryKeyFieldId())==false && c.getType().getJavaEquivalentClass()==String.class) {
|
||||
ve.setDisplayNameFieldId(c.getName());
|
||||
}
|
||||
}
|
||||
|
||||
// Disable lists when id contains;
|
||||
for (VascEntryField vef:ve.getVascEntryFields()) {
|
||||
String id = vef.getId().toLowerCase();
|
||||
if (ve.getDisplayNameFieldId()!=null && ve.getDisplayNameFieldId().equals(vef.getId())) {
|
||||
continue;
|
||||
}
|
||||
if (ve.getPrimaryKeyFieldId()!=null && ve.getPrimaryKeyFieldId().equals(vef.getId())) {
|
||||
continue;
|
||||
}
|
||||
if (vef.getList()!=null && vef.getList()==false) {
|
||||
continue;
|
||||
}
|
||||
if ( id.contains("email") |
|
||||
id.contains("phone") |
|
||||
id.contains("data") |
|
||||
id.contains("value") |
|
||||
id.contains("create") |
|
||||
id.contains("update") |
|
||||
id.contains("delete") |
|
||||
id.contains("classname") |
|
||||
id.contains("description")
|
||||
) {
|
||||
vef.setList(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Some auto detection on fields so default imported list view looks oke on 8++ columns.
|
||||
if (ve.getVascEntryFields().size()>10) {
|
||||
List<String> vefListIds = new ArrayList<String>(20);
|
||||
int max = 0;
|
||||
for (VascEntryField vef:ve.getVascEntryFields()) {
|
||||
if (ve.getDisplayNameFieldId()!=null && ve.getDisplayNameFieldId().equals(vef.getId())) {
|
||||
continue;
|
||||
}
|
||||
if (ve.getPrimaryKeyFieldId()!=null && ve.getPrimaryKeyFieldId().equals(vef.getId())) {
|
||||
continue;
|
||||
}
|
||||
if (vef.getList()!=null && vef.getList()==false) {
|
||||
continue;
|
||||
}
|
||||
vefListIds.add(vef.getId());
|
||||
max++;
|
||||
if (max>8) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (String key:vefListIds) {
|
||||
VascEntryField vef = ve.getVascEntryFieldById(key);
|
||||
vef.setList(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the dataContextProvider
|
||||
*/
|
||||
public MetaModelDataContextProvider getDataContextProvider() {
|
||||
return dataContextProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dataContextProvider the dataContextProvider to set
|
||||
*/
|
||||
public void setDataContextProvider(MetaModelDataContextProvider dataContextProvider) {
|
||||
this.dataContextProvider = dataContextProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the tableInclude
|
||||
*/
|
||||
public String getTableInclude() {
|
||||
return tableInclude;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param tableInclude the tableInclude to set
|
||||
*/
|
||||
public void setTableInclude(String tableInclude) {
|
||||
this.tableInclude = tableInclude;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the tableExclude
|
||||
*/
|
||||
public String getTableExclude() {
|
||||
return tableExclude;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param tableExclude the tableExclude to set
|
||||
*/
|
||||
public void setTableExclude(String tableExclude) {
|
||||
this.tableExclude = tableExclude;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the entryPrefix
|
||||
*/
|
||||
public String getEntryPrefix() {
|
||||
return entryPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param entryPrefix the entryPrefix to set
|
||||
*/
|
||||
public void setEntryPrefix(String entryPrefix) {
|
||||
this.entryPrefix = entryPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the vascGroupId
|
||||
*/
|
||||
public String getVascGroupId() {
|
||||
return vascGroupId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param vascGroupId the vascGroupId to set
|
||||
*/
|
||||
public void setVascGroupId(String vascGroupId) {
|
||||
this.vascGroupId = vascGroupId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the resultEntries
|
||||
*/
|
||||
public List<VascEntryLocal> getResultEntries() {
|
||||
List<VascEntryLocal> result = new ArrayList<VascEntryLocal>(resultEntries.values());
|
||||
Collections.sort(result, new Comparator<VascEntryLocal>() {
|
||||
@Override
|
||||
public int compare(VascEntryLocal o1, VascEntryLocal o2) {
|
||||
return o1.getId().compareTo(o2.getId());
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the resultEntryGroups
|
||||
*/
|
||||
public List<VascEntryGroupLocal> getResultEntryGroups() {
|
||||
List<VascEntryGroupLocal> result = new ArrayList<VascEntryGroupLocal>(resultEntryGroups.values());
|
||||
Collections.sort(result, new Comparator<VascEntryGroupLocal>() {
|
||||
@Override
|
||||
public int compare(VascEntryGroupLocal o1, VascEntryGroupLocal o2) {
|
||||
return o1.getId().compareTo(o2.getId());
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the resultBackends
|
||||
*/
|
||||
public List<MetaModelVascBackend> getResultBackends() {
|
||||
List<MetaModelVascBackend> result = new ArrayList<MetaModelVascBackend>(resultBackends.values());
|
||||
Collections.sort(result, new Comparator<MetaModelVascBackend>() {
|
||||
@Override
|
||||
public int compare(MetaModelVascBackend o1, MetaModelVascBackend o2) {
|
||||
return o1.getId().compareTo(o2.getId());
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the tables
|
||||
*/
|
||||
public List<String> getTables() {
|
||||
return tables;
|
||||
}
|
||||
|
||||
public void addTable(String table) {
|
||||
tables.add(table);
|
||||
}
|
||||
public void removeTable(String table) {
|
||||
tables.remove(table);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the veLinkPostfix
|
||||
*/
|
||||
public String getVeLinkPostfix() {
|
||||
return veLinkPostfix;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param veLinkPostfix the veLinkPostfix to set
|
||||
*/
|
||||
public void setVeLinkPostfix(String veLinkPostfix) {
|
||||
this.veLinkPostfix = veLinkPostfix;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the veListPostfix
|
||||
*/
|
||||
public String getVeListPostfix() {
|
||||
return veListPostfix;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param veListPostfix the veListPostfix to set
|
||||
*/
|
||||
public void setVeListPostfix(String veListPostfix) {
|
||||
this.veListPostfix = veListPostfix;
|
||||
}
|
||||
}
|
||||
|
|
@ -43,16 +43,14 @@ import org.eobjects.metamodel.schema.Schema;
|
|||
import org.eobjects.metamodel.schema.Table;
|
||||
|
||||
import net.forwardfire.vasc.backend.AbstractVascBackend;
|
||||
import net.forwardfire.vasc.backend.VascBackendException;
|
||||
import net.forwardfire.vasc.backend.VascBackendState;
|
||||
import net.forwardfire.vasc.backend.VascEntryFieldValue;
|
||||
import net.forwardfire.vasc.backend.VascEntryRecordCreator;
|
||||
import net.forwardfire.vasc.backend.metamodel.crud.CrudDataContext;
|
||||
import net.forwardfire.vasc.backend.metamodel.crud.UpdateableRow;
|
||||
import net.forwardfire.vasc.backend.metamodel.crud.CrudDataContextImpl;
|
||||
import net.forwardfire.vasc.backend.metamodel.crud.UpdateableRowMapImpl;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFieldValue;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryRecordCreator;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
|
||||
/**
|
||||
* MetaModelVascBackend provides vasc backend for metamodel.
|
||||
|
|
@ -212,11 +210,11 @@ public class MetaModelVascBackend extends AbstractVascBackend {
|
|||
return q;
|
||||
}
|
||||
|
||||
public List<Object> execute(VascBackendState state) throws VascException {
|
||||
public List<Object> execute(VascBackendState state) throws VascBackendException {
|
||||
Schema schema = dataContext.getDefaultSchema();
|
||||
Table t = schema.getTableByName(table);
|
||||
if (t==null) {
|
||||
throw new VascException("Could not get meta table for: '"+table+"'.");
|
||||
throw new VascBackendException("Could not get meta table for: '"+table+"'.");
|
||||
}
|
||||
Query q = createFilterQuery(state,t,false);
|
||||
if (isSortable() && state.getSortField() != null) {
|
||||
|
|
@ -265,32 +263,32 @@ public class MetaModelVascBackend extends AbstractVascBackend {
|
|||
return result;
|
||||
}
|
||||
|
||||
public void persist(Object object) throws VascException {
|
||||
public void persist(Object object) throws VascBackendException {
|
||||
if (crudDataContext==null) {
|
||||
return;
|
||||
}
|
||||
crudDataContext.persist((UpdateableRow) object);
|
||||
}
|
||||
|
||||
public Object merge(Object object) throws VascException {
|
||||
public Object merge(Object object) throws VascBackendException {
|
||||
if (crudDataContext==null) {
|
||||
return object;
|
||||
}
|
||||
return crudDataContext.merge((UpdateableRow) object);
|
||||
}
|
||||
|
||||
public void delete(Object object) throws VascException {
|
||||
public void delete(Object object) throws VascBackendException {
|
||||
if (crudDataContext==null) {
|
||||
return;
|
||||
}
|
||||
crudDataContext.delete((UpdateableRow) object);
|
||||
}
|
||||
|
||||
public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) {
|
||||
public VascEntryFieldValue provideVascEntryFieldValue() {
|
||||
return new RowVascEntryFieldValue();
|
||||
}
|
||||
|
||||
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
|
||||
public VascEntryRecordCreator provideVascEntryRecordCreator() {
|
||||
return new RowVascEntryRecordCreator(crudDataContext,crudDataContext.getDefaultSchema().getTableByName(table));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,34 +3,30 @@ package net.forwardfire.vasc.backend.metamodel;
|
|||
import org.eobjects.metamodel.data.Row;
|
||||
import org.eobjects.metamodel.query.SelectItem;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackendException;
|
||||
import net.forwardfire.vasc.backend.VascEntryFieldValue;
|
||||
import net.forwardfire.vasc.backend.metamodel.crud.UpdateableRow;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFieldValue;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
|
||||
public class RowVascEntryFieldValue implements VascEntryFieldValue {
|
||||
|
||||
private static final long serialVersionUID = -806674640688182132L;
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.entry.VascEntryFieldValue#getValue(net.forwardfire.vasc.core.VascEntryField, java.lang.Object)
|
||||
* @see net.forwardfire.vasc.backend.VascEntryFieldValue#getValue(java.lang.String, java.lang.Object)
|
||||
*/
|
||||
public Object getValue(VascEntryField field, Object record) throws VascException {
|
||||
if (field==null) {
|
||||
throw new NullPointerException("Can't get value of null field.");
|
||||
}
|
||||
if (field.getBackendName()==null) {
|
||||
throw new NullPointerException("Can't get value of null backendName field.");
|
||||
public Object getValue(String backendName, Object record) throws VascBackendException {
|
||||
if (backendName==null) {
|
||||
throw new NullPointerException("Can't get value of null backendName.");
|
||||
}
|
||||
if (record==null) {
|
||||
throw new NullPointerException("Can't get value of null object.");
|
||||
}
|
||||
if (record instanceof UpdateableRow) {
|
||||
UpdateableRow row = (UpdateableRow)record;
|
||||
return row.getValue(field.getBackendName());
|
||||
return row.getValue(backendName);
|
||||
}
|
||||
Row row = (Row)record;
|
||||
Object fieldValue = row.getValue(indexOf(field.getBackendName(),row));
|
||||
Object fieldValue = row.getValue(indexOf(backendName,row));
|
||||
return fieldValue;
|
||||
}
|
||||
|
||||
|
|
@ -49,10 +45,10 @@ public class RowVascEntryFieldValue implements VascEntryFieldValue {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.entry.VascEntryFieldValue#getDisplayValue(net.forwardfire.vasc.core.VascEntryField, java.lang.Object)
|
||||
* @see net.forwardfire.vasc.backend.VascEntryFieldValue#getDisplayValue(java.lang.String, java.lang.Object)
|
||||
*/
|
||||
public String getDisplayValue(VascEntryField field, Object record) throws VascException {
|
||||
Object fieldValue = getValue(field,record);
|
||||
public String getDisplayValue(String backendName, Object record) throws VascBackendException {
|
||||
Object fieldValue = getValue(backendName,record);
|
||||
if (fieldValue==null) {
|
||||
fieldValue = "";
|
||||
}
|
||||
|
|
@ -60,12 +56,12 @@ public class RowVascEntryFieldValue implements VascEntryFieldValue {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.entry.VascEntryFieldValue#setValue(net.forwardfire.vasc.core.VascEntryField, java.lang.Object, java.lang.Object)
|
||||
* @see net.forwardfire.vasc.backend.VascEntryFieldValue#setValue(java.lang.String, java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
public void setValue(VascEntryField field, Object record,Object value) throws VascException {
|
||||
public void setValue(String backendName, Object record,Object value) throws VascBackendException {
|
||||
if (record instanceof UpdateableRow) {
|
||||
UpdateableRow row = (UpdateableRow)record;
|
||||
row.setValue(field.getBackendName(), value);
|
||||
row.setValue(backendName, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,11 +2,10 @@ package net.forwardfire.vasc.backend.metamodel;
|
|||
|
||||
import org.eobjects.metamodel.schema.Table;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackendException;
|
||||
import net.forwardfire.vasc.backend.VascEntryRecordCreator;
|
||||
import net.forwardfire.vasc.backend.metamodel.crud.CrudDataContext;
|
||||
import net.forwardfire.vasc.backend.metamodel.crud.UpdateableRow;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryRecordCreator;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
|
||||
public class RowVascEntryRecordCreator implements VascEntryRecordCreator {
|
||||
|
||||
|
|
@ -23,7 +22,7 @@ public class RowVascEntryRecordCreator implements VascEntryRecordCreator {
|
|||
return UpdateableRow.class;
|
||||
}
|
||||
|
||||
public Object newRecord(VascEntry entry) throws VascException {
|
||||
public Object newRecord() throws VascBackendException {
|
||||
return dataContext.createRow(table);
|
||||
}
|
||||
}
|
||||
|
|
@ -30,10 +30,5 @@
|
|||
<element tag="xmlDomDataContext" objectClass="net.forwardfire.vasc.backend.metamodel.MetaModelDataContextXmlDom"/>
|
||||
|
||||
<element tag="jndiDataContext" objectClass="net.forwardfire.vasc.backend.metamodel.MetaModelDataContextJndiDataContext"/>
|
||||
|
||||
<element tag="schemaAutoEntry" objectClass="net.forwardfire.vasc.backend.metamodel.MetaModelSchemaAutoEntry">
|
||||
<configurator id="schemaAutoEntry-SchemaAutoEntryElementConfigurator" bean.class="net.forwardfire.vasc.backend.metamodel.x4o.SchemaAutoEntryElementConfigurator" configAction="true"/>
|
||||
</element>
|
||||
|
||||
</namespace>
|
||||
</root:module>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>vasc-backend</artifactId>
|
||||
<groupId>net.forwardfire.vasc</groupId>
|
||||
<groupId>net.forwardfire.vasc.backend</groupId>
|
||||
<version>0.4.2-SNAPSHOT</version>
|
||||
<relativePath>..</relativePath>
|
||||
</parent>
|
||||
|
|
@ -11,8 +11,8 @@
|
|||
<description>vasc-backend-mongodb</description>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>net.forwardfire.vasc</groupId>
|
||||
<artifactId>vasc-core</artifactId>
|
||||
<groupId>net.forwardfire.vasc.backend</groupId>
|
||||
<artifactId>vasc-backend-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
|||
|
|
@ -27,13 +27,10 @@ import java.util.List;
|
|||
import java.util.logging.Logger;
|
||||
|
||||
import net.forwardfire.vasc.backend.AbstractVascBackend;
|
||||
import net.forwardfire.vasc.backend.VascBackendException;
|
||||
import net.forwardfire.vasc.backend.VascBackendState;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFieldValue;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryRecordCreator;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascEntryFieldValue;
|
||||
import net.forwardfire.vasc.backend.VascEntryRecordCreator;
|
||||
|
||||
import com.mongodb.DB;
|
||||
import com.mongodb.DBCollection;
|
||||
|
|
@ -108,7 +105,7 @@ public class MongodbVascBackend extends AbstractVascBackend {
|
|||
return query;
|
||||
}
|
||||
|
||||
public List<Object> execute(VascBackendState state) throws VascException {
|
||||
public List<Object> execute(VascBackendState state) throws VascBackendException {
|
||||
DBCollection coll = getDBCollection();
|
||||
DBObject query = createFilterQuery(state);
|
||||
DBCursor cur = coll.find(query);
|
||||
|
|
@ -124,12 +121,12 @@ public class MongodbVascBackend extends AbstractVascBackend {
|
|||
return result;
|
||||
}
|
||||
|
||||
public void persist(Object object) throws VascException {
|
||||
public void persist(Object object) throws VascBackendException {
|
||||
DBCollection coll = getDBCollection();
|
||||
coll.insert((DBObject)object);
|
||||
}
|
||||
|
||||
public Object merge(Object object) throws VascException {
|
||||
public Object merge(Object object) throws VascBackendException {
|
||||
DBCollection coll = getDBCollection();
|
||||
DBObject row = (DBObject)object;
|
||||
DBObject query = new BasicDBObject();
|
||||
|
|
@ -139,18 +136,18 @@ public class MongodbVascBackend extends AbstractVascBackend {
|
|||
return object;
|
||||
}
|
||||
|
||||
public void delete(Object object) throws VascException {
|
||||
public void delete(Object object) throws VascBackendException {
|
||||
DBCollection coll = getDBCollection();
|
||||
DBObject query = new BasicDBObject();
|
||||
query.put("_id",((DBObject)object).get("_id"));
|
||||
coll.remove(query); // remove by _id
|
||||
}
|
||||
|
||||
public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) {
|
||||
public VascEntryFieldValue provideVascEntryFieldValue() {
|
||||
return new MongodbVascEntryFieldValue();
|
||||
}
|
||||
|
||||
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
|
||||
public VascEntryRecordCreator provideVascEntryRecordCreator() {
|
||||
return new MongodbVascEntryRecordCreator();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,10 +22,8 @@
|
|||
|
||||
package net.forwardfire.vasc.backend.mongodb;
|
||||
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFieldValue;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackendException;
|
||||
import net.forwardfire.vasc.backend.VascEntryFieldValue;
|
||||
|
||||
import com.mongodb.BasicDBObject;
|
||||
|
||||
|
|
@ -39,18 +37,18 @@ public class MongodbVascEntryFieldValue implements VascEntryFieldValue {
|
|||
|
||||
private static final long serialVersionUID = -7371273796529818557L;
|
||||
|
||||
public Object getValue(VascEntryField field, Object record) throws VascException {
|
||||
public Object getValue(String backendName, Object record) throws VascBackendException {
|
||||
BasicDBObject row = (BasicDBObject)record;
|
||||
Object data = row.get(field.getBackendName());
|
||||
Object data = row.get(backendName);
|
||||
return data;
|
||||
}
|
||||
|
||||
public String getDisplayValue(VascEntryField field, Object record) throws VascException {
|
||||
public String getDisplayValue(String field, Object record) throws VascBackendException {
|
||||
return ""+getValue(field,record);
|
||||
}
|
||||
|
||||
public void setValue(VascEntryField field, Object record, Object value) throws VascException {
|
||||
public void setValue(String backendName, Object record, Object value) throws VascBackendException {
|
||||
BasicDBObject row = (BasicDBObject)record;
|
||||
row.put(field.getBackendName(), value);
|
||||
row.put(backendName, value);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,10 +23,8 @@
|
|||
|
||||
package net.forwardfire.vasc.backend.mongodb;
|
||||
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryRecordCreator;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackendException;
|
||||
import net.forwardfire.vasc.backend.VascEntryRecordCreator;
|
||||
|
||||
import com.mongodb.BasicDBObject;
|
||||
|
||||
|
|
@ -40,7 +38,7 @@ public class MongodbVascEntryRecordCreator implements VascEntryRecordCreator {
|
|||
|
||||
private static final long serialVersionUID = -9213830731796787384L;
|
||||
|
||||
public Object newRecord(VascEntry entry) throws VascException {
|
||||
public Object newRecord() throws VascBackendException {
|
||||
return new BasicDBObject();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue