Small refactor for comming converters
This commit is contained in:
parent
75b3d5e0a0
commit
1c308a684a
178 changed files with 5865 additions and 1531 deletions
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.backend.jdbc;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Sep 5, 2008
|
||||
*/
|
||||
public interface JdbcConnectionProvider {
|
||||
|
||||
public Connection getJdbcConnection() throws SQLException;
|
||||
}
|
||||
|
|
@ -0,0 +1,117 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.backend.jdbc;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 15, 2009
|
||||
*/
|
||||
public class JdbcConnectionProviderImpl implements JdbcConnectionProvider {
|
||||
|
||||
private String driverClassName = null;
|
||||
private String dbUrl = null;
|
||||
private String dbUser = null;
|
||||
private String dbPassword = null;
|
||||
private boolean loadedDriver = false;
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.jdbc.JdbcConnectionProvider#getJdbcConnection()
|
||||
*/
|
||||
public Connection getJdbcConnection() throws SQLException {
|
||||
if (loadedDriver==false) {
|
||||
try {
|
||||
Class.forName(driverClassName);
|
||||
loadedDriver = true;
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new SQLException("Could not load driver: "+driverClassName+" error: "+e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
Connection connection = DriverManager.getConnection(dbUrl, dbUser, dbPassword);
|
||||
return connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the driverClassName
|
||||
*/
|
||||
public String getDriverClassName() {
|
||||
return driverClassName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param driverClassName the driverClassName to set
|
||||
*/
|
||||
public void setDriverClassName(String driverClassName) {
|
||||
this.driverClassName = driverClassName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the dbUrl
|
||||
*/
|
||||
public String getDbUrl() {
|
||||
return dbUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dbUrl the dbUrl to set
|
||||
*/
|
||||
public void setDbUrl(String dbUrl) {
|
||||
this.dbUrl = dbUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the dbUser
|
||||
*/
|
||||
public String getDbUser() {
|
||||
return dbUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dbUser the dbUser to set
|
||||
*/
|
||||
public void setDbUser(String dbUser) {
|
||||
this.dbUser = dbUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the dbPassword
|
||||
*/
|
||||
public String getDbPassword() {
|
||||
return dbPassword;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dbPassword the dbPassword to set
|
||||
*/
|
||||
public void setDbPassword(String dbPassword) {
|
||||
this.dbPassword = dbPassword;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.backend.jdbc;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
import javax.naming.NamingException;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 15, 2009
|
||||
*/
|
||||
public class JdbcConnectionProviderJdniImpl implements JdbcConnectionProvider {
|
||||
|
||||
/** The context in which database data sources are found. */
|
||||
private String dataSourceContext = "java:/";
|
||||
|
||||
private String dataSourceName = null;
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.jdbc.JdbcConnectionProvider#getJdbcConnection()
|
||||
*/
|
||||
public Connection getJdbcConnection() throws SQLException {
|
||||
Connection connection = getDataSource(dataSourceName).getConnection();
|
||||
return connection;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets a DataSource out of the JNDI context.
|
||||
* <p>
|
||||
* @param name The name of the data source in the JDNI context.
|
||||
* @return The data source.
|
||||
*/
|
||||
private DataSource getDataSource(String name) throws SQLException {
|
||||
|
||||
try {
|
||||
Context initialContext = new InitialContext();
|
||||
if ( initialContext == null ) {
|
||||
throw new SQLException("Cannot get Initial Context");
|
||||
}
|
||||
DataSource datasource = (DataSource)initialContext.lookup(dataSourceContext+name);
|
||||
if ( datasource == null ) {
|
||||
throw new SQLException("Cannot lookup datasource: "+name);
|
||||
}
|
||||
return datasource;
|
||||
} catch ( NamingException e ) {
|
||||
throw new SQLException("Cannot get connection " + e,e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the dataSourceContext
|
||||
*/
|
||||
public String getDataSourceContext() {
|
||||
return dataSourceContext;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param dataSourceContext the dataSourceContext to set
|
||||
*/
|
||||
public void setDataSourceContext(String dataSourceContext) {
|
||||
this.dataSourceContext = dataSourceContext;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the dataSourceName
|
||||
*/
|
||||
public String getDataSourceName() {
|
||||
return dataSourceName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param dataSourceName the dataSourceName to set
|
||||
*/
|
||||
public void setDataSourceName(String dataSourceName) {
|
||||
this.dataSourceName = dataSourceName;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,157 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.backend.jdbc;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.forwardfire.vasc.backend.AbstractVascBackend;
|
||||
import net.forwardfire.vasc.backend.VascBackendState;
|
||||
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.VascException;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFieldValue;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryRecordCreator;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Sep 5, 2008
|
||||
*/
|
||||
public class JdbcVascBackend extends AbstractVascBackend {
|
||||
|
||||
private JdbcConnectionProvider jdbcConnectionProvider = null;
|
||||
private String sqlList = null;
|
||||
private String idColumn = null;
|
||||
private String sqlDelete = null;
|
||||
private String sqlUpdate = null;
|
||||
private String sqlInsert = null;
|
||||
|
||||
/**
|
||||
* @return the JdbcConnectionProvider
|
||||
*/
|
||||
public JdbcConnectionProvider getJdbcConnectionProvider() {
|
||||
return jdbcConnectionProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param JdbcConnectionProvider the JdbcConnectionProvider to set
|
||||
*/
|
||||
public void setJdbcConnectionProvider(JdbcConnectionProvider jdbcConnectionProvider) {
|
||||
this.jdbcConnectionProvider = jdbcConnectionProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state)
|
||||
*/
|
||||
public List<Object> execute(VascBackendState state) throws VascException {
|
||||
JdbcConnectionProvider prov = getJdbcConnectionProvider();
|
||||
List<Object> result = new ArrayList<Object>(50);
|
||||
Connection connection = null;
|
||||
try {
|
||||
connection = prov.getJdbcConnection();
|
||||
Statement s = connection.createStatement();
|
||||
s.execute(getSqlList());
|
||||
ResultSet rs = s.getResultSet();
|
||||
int cols = rs.getMetaData().getColumnCount();
|
||||
while (rs.next()) {
|
||||
Map<String,Object> map = new HashMap<String,Object>(cols);
|
||||
for (int i=1;i<=cols;i++) {
|
||||
String columnName = rs.getMetaData().getColumnName(i);
|
||||
Object columnObject = rs.getObject(i);
|
||||
map.put(columnName, columnObject);
|
||||
}
|
||||
result.add(map);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new VascException(e);
|
||||
} finally {
|
||||
if (connection!=null) {
|
||||
try {
|
||||
connection.close();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#merge(java.lang.Object)
|
||||
*/
|
||||
public Object merge(Object object) throws VascException {
|
||||
return object;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#persist(java.lang.Object)
|
||||
*/
|
||||
public void persist(Object object) throws VascException {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#delete(java.lang.Object)
|
||||
*/
|
||||
public void delete(Object object) throws VascException {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryFieldValue(net.forwardfire.vasc.core.VascEntryField)
|
||||
*/
|
||||
public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) {
|
||||
return new MapVascEntryFieldValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryRecordCreator(net.forwardfire.vasc.core.VascEntry)
|
||||
*/
|
||||
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
|
||||
return new MapVascEntryRecordCreator();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the sqlList
|
||||
*/
|
||||
public String getSqlList() {
|
||||
return sqlList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sqlList the sqlList to set
|
||||
*/
|
||||
public void setSqlList(String sqlList) {
|
||||
this.sqlList = sqlList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,163 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.backend.jdbc;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.forwardfire.vasc.backend.AbstractVascBackend;
|
||||
import net.forwardfire.vasc.backend.VascBackendState;
|
||||
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.VascException;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFieldValue;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryRecordCreator;
|
||||
import net.forwardfire.vasc.xpql.query.QueryParameterValue;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Sep 5, 2008
|
||||
*/
|
||||
public class JdbcVascBackendXpql extends AbstractVascBackend {
|
||||
|
||||
private JdbcConnectionProvider jdbcConnectionProvider = null;
|
||||
|
||||
private net.forwardfire.vasc.xpql.query.Query query = null;
|
||||
|
||||
/**
|
||||
* @return the JdbcConnectionProvider
|
||||
*/
|
||||
public JdbcConnectionProvider getJdbcConnectionProvider() {
|
||||
return jdbcConnectionProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param JdbcConnectionProvider the JdbcConnectionProvider to set
|
||||
*/
|
||||
public void setJdbcConnectionProvider(JdbcConnectionProvider jdbcConnectionProvider) {
|
||||
this.jdbcConnectionProvider = jdbcConnectionProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the query
|
||||
*/
|
||||
public net.forwardfire.vasc.xpql.query.Query getQuery() {
|
||||
return query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param query the query to set
|
||||
*/
|
||||
public void setQuery(net.forwardfire.vasc.xpql.query.Query query) {
|
||||
this.query = query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state)
|
||||
*/
|
||||
public List<Object> execute(VascBackendState state) throws VascException {
|
||||
// Copy parameters
|
||||
for (String key:state.getDataParameterKeys()) {
|
||||
Object value = state.getDataParameter(key);
|
||||
query.setQueryParameter(key, value);
|
||||
}
|
||||
Connection c = null;
|
||||
try {
|
||||
c = getJdbcConnectionProvider().getJdbcConnection();;
|
||||
PreparedStatement q = c.prepareStatement(query.toPreparedSQL(query));
|
||||
|
||||
List<QueryParameterValue> values = query.getOrderQueryParameterValues();
|
||||
int ii = 1;
|
||||
for (QueryParameterValue value:values) {
|
||||
q.setObject(ii,value.getValue());
|
||||
ii++;
|
||||
}
|
||||
q.execute();
|
||||
ResultSet rs = q.getResultSet();
|
||||
int cols = rs.getMetaData().getColumnCount();
|
||||
List<Object> result = new ArrayList<Object>(50);
|
||||
while (rs.next()) {
|
||||
Map<String,Object> map = new HashMap<String,Object>(cols);
|
||||
for (int i=1;i<=cols;i++) {
|
||||
String columnName = rs.getMetaData().getColumnName(i);
|
||||
Object columnObject = rs.getObject(i);
|
||||
map.put(columnName, columnObject);
|
||||
}
|
||||
result.add(map);
|
||||
}
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
throw new VascException(e);
|
||||
} finally {
|
||||
if (c!=null) {
|
||||
try {
|
||||
c.close();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#merge(java.lang.Object)
|
||||
*/
|
||||
public Object merge(Object object) throws VascException {
|
||||
return object;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#persist(java.lang.Object)
|
||||
*/
|
||||
public void persist(Object object) throws VascException {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#delete(java.lang.Object)
|
||||
*/
|
||||
public void delete(Object object) throws VascException {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryFieldValue(net.forwardfire.vasc.core.VascEntryField)
|
||||
*/
|
||||
public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) {
|
||||
return new MapVascEntryFieldValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryRecordCreator(net.forwardfire.vasc.core.VascEntry)
|
||||
*/
|
||||
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
|
||||
return new MapVascEntryRecordCreator();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<eld:root xmlns:eld="http://eld.x4o.org/eld/eld-lang.eld">
|
||||
|
||||
<eld:elementClass tag="jdbcBackend" objectClassName="net.forwardfire.vasc.backend.jdbc.JdbcVascBackend">
|
||||
<eld:elementConfigurator bean.class="net.forwardfire.vasc.impl.x4o.VascBackendElementConfigurator" configAction="true"/>
|
||||
</eld:elementClass>
|
||||
<eld:elementClass tag="jdbcConnectionProvider" objectClassName="net.forwardfire.vasc.backend.jdbc.JdbcConnectionProviderImpl"/>
|
||||
<eld:elementClass tag="jdbcConnectionProviderJndi" objectClassName="net.forwardfire.vasc.backend.jdbc.JdbcConnectionProviderJdniImpl"/>
|
||||
|
||||
<eld:elementClass tag="jdbcBackendXpql" objectClassName="net.forwardfire.vasc.backend.jdbc.JdbcVascBackendXpql">
|
||||
<eld:elementConfigurator bean.class="net.forwardfire.vasc.impl.x4o.VascBackendElementConfigurator" configAction="true"/>
|
||||
</eld:elementClass>
|
||||
|
||||
</eld:root>
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
|
||||
<properties>
|
||||
<comment>
|
||||
Vasc namespace for the jdbc backend
|
||||
</comment>
|
||||
<entry key="eld.http://vasc.forwardfire.net/eld/vasc-backend-jdbc.eld">vasc-backend-jdbc.eld</entry>
|
||||
</properties>
|
||||
Loading…
Add table
Add a link
Reference in a new issue