Small refactor for comming converters
This commit is contained in:
parent
75b3d5e0a0
commit
1c308a684a
3
.settings/org.eclipse.core.resources.prefs
Normal file
3
.settings/org.eclipse.core.resources.prefs
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#Sat Jan 14 05:41:26 CET 2012
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
encoding/<project>=UTF-8
|
4
pom.xml
4
pom.xml
|
@ -28,10 +28,12 @@
|
||||||
<module>vasc-core</module>
|
<module>vasc-core</module>
|
||||||
<module>vasc-ejb3</module>
|
<module>vasc-ejb3</module>
|
||||||
<module>vasc-xpql</module>
|
<module>vasc-xpql</module>
|
||||||
<module>vasc-xpql-ejb3</module>
|
<module>vasc-xpql-ejb3-server</module>
|
||||||
|
<module>vasc-xpql-ejb3-client</module>
|
||||||
<module>vasc-backend</module>
|
<module>vasc-backend</module>
|
||||||
<module>vasc-frontend</module>
|
<module>vasc-frontend</module>
|
||||||
<module>vasc-demo</module>
|
<module>vasc-demo</module>
|
||||||
|
<module>vasc-test</module>
|
||||||
</modules>
|
</modules>
|
||||||
<properties>
|
<properties>
|
||||||
<hg.repo.url>https://...vasc/</hg.repo.url>
|
<hg.repo.url>https://...vasc/</hg.repo.url>
|
||||||
|
|
10
vasc-backend/vasc-backend-jdbc/.classpath
Normal file
10
vasc-backend/vasc-backend-jdbc/.classpath
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
|
||||||
|
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
|
||||||
|
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
|
||||||
|
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
|
||||||
|
<classpathentry kind="output" path="target/classes"/>
|
||||||
|
</classpath>
|
23
vasc-backend/vasc-backend-jdbc/.project
Normal file
23
vasc-backend/vasc-backend-jdbc/.project
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>vasc-backend-jdbc</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>
|
|
@ -0,0 +1,7 @@
|
||||||
|
#Sat Dec 31 04:21:23 CET 2011
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
encoding//src/main/java=UTF-8
|
||||||
|
encoding//src/main/resources=UTF-8
|
||||||
|
encoding//src/test/java=UTF-8
|
||||||
|
encoding//src/test/resources=UTF-8
|
||||||
|
encoding/<project>=UTF-8
|
|
@ -0,0 +1,6 @@
|
||||||
|
#Sat Dec 31 04:21:23 CET 2011
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
|
||||||
|
org.eclipse.jdt.core.compiler.compliance=1.5
|
||||||
|
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||||
|
org.eclipse.jdt.core.compiler.source=1.5
|
|
@ -0,0 +1,5 @@
|
||||||
|
#Sat Dec 31 04:21:23 CET 2011
|
||||||
|
activeProfiles=
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
resolveWorkspaceProjects=true
|
||||||
|
version=1
|
19
vasc-backend/vasc-backend-jdbc/pom.xml
Normal file
19
vasc-backend/vasc-backend-jdbc/pom.xml
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
<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>
|
||||||
|
<artifactId>vasc-backend</artifactId>
|
||||||
|
<groupId>net.forwardfire.vasc</groupId>
|
||||||
|
<version>0.3.5-SNAPSHOT</version>
|
||||||
|
<relativePath>..</relativePath>
|
||||||
|
</parent>
|
||||||
|
<artifactId>vasc-backend-jdbc</artifactId>
|
||||||
|
<name>vasc-backend-jdbc</name>
|
||||||
|
<description>vasc-backend-jdbc</description>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.forwardfire.vasc</groupId>
|
||||||
|
<artifactId>vasc-core</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
|
@ -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>
|
|
@ -16,12 +16,12 @@
|
||||||
</arguments>
|
</arguments>
|
||||||
</buildCommand>
|
</buildCommand>
|
||||||
<buildCommand>
|
<buildCommand>
|
||||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
<name>org.eclipse.wst.validation.validationbuilder</name>
|
||||||
<arguments>
|
<arguments>
|
||||||
</arguments>
|
</arguments>
|
||||||
</buildCommand>
|
</buildCommand>
|
||||||
<buildCommand>
|
<buildCommand>
|
||||||
<name>org.eclipse.wst.validation.validationbuilder</name>
|
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||||
<arguments>
|
<arguments>
|
||||||
</arguments>
|
</arguments>
|
||||||
</buildCommand>
|
</buildCommand>
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
package net.forwardfire.vasc.backends.jpa;
|
package net.forwardfire.vasc.backends.jpa;
|
||||||
|
|
||||||
import net.forwardfire.vasc.core.AbstractVascBackend;
|
import net.forwardfire.vasc.backend.AbstractVascBackend;
|
||||||
import net.forwardfire.vasc.core.VascException;
|
import net.forwardfire.vasc.core.VascException;
|
||||||
|
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
|
|
|
@ -26,7 +26,7 @@ import java.lang.reflect.Method;
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
|
|
||||||
import net.forwardfire.vasc.core.AbstractVascBackend;
|
import net.forwardfire.vasc.backend.AbstractVascBackend;
|
||||||
import net.forwardfire.vasc.core.VascException;
|
import net.forwardfire.vasc.core.VascException;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -24,9 +24,9 @@ package net.forwardfire.vasc.backends.jpa;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.forwardfire.vasc.backends.BeanVascEntryFieldValue;
|
import net.forwardfire.vasc.backend.VascBackendState;
|
||||||
import net.forwardfire.vasc.backends.BeanVascEntryRecordCreator;
|
import net.forwardfire.vasc.backend.data.BeanVascEntryFieldValue;
|
||||||
import net.forwardfire.vasc.core.VascBackendState;
|
import net.forwardfire.vasc.backend.data.BeanVascEntryRecordCreator;
|
||||||
import net.forwardfire.vasc.core.VascEntry;
|
import net.forwardfire.vasc.core.VascEntry;
|
||||||
import net.forwardfire.vasc.core.VascEntryField;
|
import net.forwardfire.vasc.core.VascEntryField;
|
||||||
import net.forwardfire.vasc.core.VascException;
|
import net.forwardfire.vasc.core.VascException;
|
||||||
|
@ -116,7 +116,7 @@ public class XpqlHibernateVascBackend extends AbstractHibernateVascBackend {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#provideVascEntryFieldValue(net.forwardfire.vasc.core.VascEntryField)
|
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryFieldValue(net.forwardfire.vasc.core.VascEntryField)
|
||||||
*/
|
*/
|
||||||
public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) {
|
public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) {
|
||||||
BeanVascEntryFieldValue result = new BeanVascEntryFieldValue();
|
BeanVascEntryFieldValue result = new BeanVascEntryFieldValue();
|
||||||
|
@ -124,7 +124,7 @@ public class XpqlHibernateVascBackend extends AbstractHibernateVascBackend {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#provideVascEntryRecordCreator(net.forwardfire.vasc.core.VascEntry)
|
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryRecordCreator(net.forwardfire.vasc.core.VascEntry)
|
||||||
*/
|
*/
|
||||||
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
|
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
|
||||||
return new BeanVascEntryRecordCreator(resultClass);
|
return new BeanVascEntryRecordCreator(resultClass);
|
||||||
|
@ -187,7 +187,7 @@ public class XpqlHibernateVascBackend extends AbstractHibernateVascBackend {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.AbstractVascBackend#isPageable()
|
* @see net.forwardfire.vasc.backend.AbstractVascBackend#isPageable()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isPageable() {
|
public boolean isPageable() {
|
||||||
|
@ -198,7 +198,7 @@ public class XpqlHibernateVascBackend extends AbstractHibernateVascBackend {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#fetchTotalExecuteSize(VascBackendState state)
|
* @see net.forwardfire.vasc.backend.VascBackend#fetchTotalExecuteSize(VascBackendState state)
|
||||||
*/
|
*/
|
||||||
public long fetchTotalExecuteSize(VascBackendState state) {
|
public long fetchTotalExecuteSize(VascBackendState state) {
|
||||||
Session s = getHibernateSession();
|
Session s = getHibernateSession();
|
||||||
|
@ -227,7 +227,7 @@ public class XpqlHibernateVascBackend extends AbstractHibernateVascBackend {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.AbstractVascBackend#doRecordMoveDownById(java.lang.Object)
|
* @see net.forwardfire.vasc.backend.AbstractVascBackend#doRecordMoveDownById(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public long doRecordMoveDownById(VascBackendState state,Object primaryId) throws VascException {
|
public long doRecordMoveDownById(VascBackendState state,Object primaryId) throws VascException {
|
||||||
|
@ -296,7 +296,7 @@ public class XpqlHibernateVascBackend extends AbstractHibernateVascBackend {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.AbstractVascBackend#doRecordMoveUpById(java.lang.Object)
|
* @see net.forwardfire.vasc.backend.AbstractVascBackend#doRecordMoveUpById(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public long doRecordMoveUpById(VascBackendState state,Object primaryId) throws VascException {
|
public long doRecordMoveUpById(VascBackendState state,Object primaryId) throws VascException {
|
||||||
|
@ -365,7 +365,7 @@ public class XpqlHibernateVascBackend extends AbstractHibernateVascBackend {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.AbstractVascBackend#isRecordMoveable()
|
* @see net.forwardfire.vasc.backend.AbstractVascBackend#isRecordMoveable()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isRecordMoveable() {
|
public boolean isRecordMoveable() {
|
||||||
|
|
|
@ -27,9 +27,9 @@ import java.util.List;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.Query;
|
import javax.persistence.Query;
|
||||||
|
|
||||||
import net.forwardfire.vasc.backends.BeanVascEntryFieldValue;
|
import net.forwardfire.vasc.backend.VascBackendState;
|
||||||
import net.forwardfire.vasc.backends.BeanVascEntryRecordCreator;
|
import net.forwardfire.vasc.backend.data.BeanVascEntryFieldValue;
|
||||||
import net.forwardfire.vasc.core.VascBackendState;
|
import net.forwardfire.vasc.backend.data.BeanVascEntryRecordCreator;
|
||||||
import net.forwardfire.vasc.core.VascEntry;
|
import net.forwardfire.vasc.core.VascEntry;
|
||||||
import net.forwardfire.vasc.core.VascEntryField;
|
import net.forwardfire.vasc.core.VascEntryField;
|
||||||
import net.forwardfire.vasc.core.VascException;
|
import net.forwardfire.vasc.core.VascException;
|
||||||
|
@ -121,7 +121,7 @@ public class XpqlPersistanceVascBackend extends AbstractPersistenceVascBackend
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#provideVascEntryFieldValue(net.forwardfire.vasc.core.VascEntryField)
|
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryFieldValue(net.forwardfire.vasc.core.VascEntryField)
|
||||||
*/
|
*/
|
||||||
public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) {
|
public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) {
|
||||||
VascEntryFieldValue result = new BeanVascEntryFieldValue();
|
VascEntryFieldValue result = new BeanVascEntryFieldValue();
|
||||||
|
@ -129,7 +129,7 @@ public class XpqlPersistanceVascBackend extends AbstractPersistenceVascBackend
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#provideVascEntryRecordCreator(net.forwardfire.vasc.core.VascEntry)
|
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryRecordCreator(net.forwardfire.vasc.core.VascEntry)
|
||||||
*/
|
*/
|
||||||
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
|
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
|
||||||
VascEntryRecordCreator result = new BeanVascEntryRecordCreator(resultClass);
|
VascEntryRecordCreator result = new BeanVascEntryRecordCreator(resultClass);
|
||||||
|
@ -193,7 +193,7 @@ public class XpqlPersistanceVascBackend extends AbstractPersistenceVascBackend
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.AbstractVascBackend#isPageable()
|
* @see net.forwardfire.vasc.backend.AbstractVascBackend#isPageable()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isPageable() {
|
public boolean isPageable() {
|
||||||
|
@ -204,7 +204,7 @@ public class XpqlPersistanceVascBackend extends AbstractPersistenceVascBackend
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#fetchTotalExecuteSize(VascBackendState state)
|
* @see net.forwardfire.vasc.backend.VascBackend#fetchTotalExecuteSize(VascBackendState state)
|
||||||
*/
|
*/
|
||||||
public long fetchTotalExecuteSize(VascBackendState state) {
|
public long fetchTotalExecuteSize(VascBackendState state) {
|
||||||
EntityManager em = getEntityManager();
|
EntityManager em = getEntityManager();
|
||||||
|
@ -359,7 +359,7 @@ public class XpqlPersistanceVascBackend extends AbstractPersistenceVascBackend
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.AbstractVascBackend#isRecordMoveable()
|
* @see net.forwardfire.vasc.backend.AbstractVascBackend#isRecordMoveable()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isRecordMoveable() {
|
public boolean isRecordMoveable() {
|
||||||
|
@ -423,7 +423,7 @@ public class XpqlPersistanceVascBackend extends AbstractPersistenceVascBackend
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#isSearchable()
|
* @see net.forwardfire.vasc.backend.VascBackend#isSearchable()
|
||||||
*/
|
*/
|
||||||
public boolean isSearchable() {
|
public boolean isSearchable() {
|
||||||
if (query.getQueryParameterValue("text_search")==null) {
|
if (query.getQueryParameterValue("text_search")==null) {
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<eld:root xmlns:eld="http://eld.x4o.org/eld/eld-lang.eld">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
<eld:elementClass tag="ldapBackend" objectClassName="net.forwardfire.vasc.backend.ldap.LdapVascBackend">
|
||||||
|
<eld:elementConfigurator bean.class="net.forwardfire.vasc.impl.x4o.VascBackendElementConfigurator" configAction="true"/>
|
||||||
|
</eld:elementClass>
|
||||||
|
<eld:elementClass tag="ldapConnectionProvider" objectClassName="net.forwardfire.vasc.backend.ldap.LdapConnectionProviderImpl"/>
|
||||||
|
-->
|
||||||
|
|
||||||
|
|
||||||
|
<eld:elementClass tag="xpqlPersistanceBackend" objectClassName="net.forwardfire.vasc.backends.jpa.XpqlPersistanceVascBackend">
|
||||||
|
<eld:elementConfigurator bean.class="net.forwardfire.vasc.impl.x4o.VascBackendElementConfigurator" configAction="true"/>
|
||||||
|
<eld:elementClassAttribute attributeName="resultClass">
|
||||||
|
<eld:attributeClassConverter/>
|
||||||
|
</eld:elementClassAttribute>
|
||||||
|
</eld:elementClass>
|
||||||
|
|
||||||
|
<eld:elementClass tag="xpqlHibernateBackend" objectClassName="net.forwardfire.vasc.backends.jpa.XpqlHibernateVascBackend">
|
||||||
|
<eld:elementConfigurator bean.class="net.forwardfire.vasc.impl.x4o.VascBackendElementConfigurator" configAction="true"/>
|
||||||
|
<eld:elementClassAttribute attributeName="resultClass">
|
||||||
|
<eld:attributeClassConverter/>
|
||||||
|
</eld:elementClassAttribute>
|
||||||
|
</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 jpa backend
|
||||||
|
</comment>
|
||||||
|
<entry key="eld.http://vasc.forwardfire.net/eld/vasc-backend-jpa.eld">vasc-backend-jpa.eld</entry>
|
||||||
|
</properties>
|
|
@ -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.ldap;
|
||||||
|
|
||||||
|
import com.novell.ldap.LDAPConnection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Sep 4, 2008
|
||||||
|
*/
|
||||||
|
public interface LdapConnectionProvider {
|
||||||
|
|
||||||
|
public LDAPConnection getLdapConnection();
|
||||||
|
}
|
|
@ -0,0 +1,133 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package net.forwardfire.vasc.backend.ldap;
|
||||||
|
|
||||||
|
import com.novell.ldap.LDAPConnection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Sep 4, 2008
|
||||||
|
*/
|
||||||
|
public class LdapConnectionProviderImpl implements LdapConnectionProvider {
|
||||||
|
|
||||||
|
private String ldapHost = "localhost";
|
||||||
|
private int ldapPort = LDAPConnection.DEFAULT_PORT;
|
||||||
|
private int ldapVersion = LDAPConnection.LDAP_V3;
|
||||||
|
private String bindUser = null;
|
||||||
|
private String bindPass = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see net.forwardfire.vasc.backend.ldap.LdapConnectionProvider#getLdapConnection()
|
||||||
|
*/
|
||||||
|
public LDAPConnection getLdapConnection() {
|
||||||
|
try {
|
||||||
|
|
||||||
|
// if ssl;
|
||||||
|
//Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
|
||||||
|
//System.setProperty("javax.net.ssl.trustStore", "/tmp/somewhere/ldap.root.crt");
|
||||||
|
//LDAPSocketFactory ssf = new LDAPJSSESecureSocketFactory();
|
||||||
|
// Set the socket factory as the default for all future connections
|
||||||
|
//LDAPConnection.setSocketFactory(ssf);
|
||||||
|
|
||||||
|
LDAPConnection lc = new LDAPConnection();
|
||||||
|
lc.connect( ldapHost, ldapPort );
|
||||||
|
if (bindUser!=null && bindPass!=null) {
|
||||||
|
lc.bind( ldapVersion, bindUser, bindPass.getBytes("UTF8") );
|
||||||
|
}
|
||||||
|
return lc;
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the ldapHost
|
||||||
|
*/
|
||||||
|
public String getLdapHost() {
|
||||||
|
return ldapHost;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ldapHost the ldapHost to set
|
||||||
|
*/
|
||||||
|
public void setLdapHost(String ldapHost) {
|
||||||
|
this.ldapHost = ldapHost;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the ldapPort
|
||||||
|
*/
|
||||||
|
public int getLdapPort() {
|
||||||
|
return ldapPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ldapPort the ldapPort to set
|
||||||
|
*/
|
||||||
|
public void setLdapPort(int ldapPort) {
|
||||||
|
this.ldapPort = ldapPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the ldapVersion
|
||||||
|
*/
|
||||||
|
public int getLdapVersion() {
|
||||||
|
return ldapVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ldapVersion the ldapVersion to set
|
||||||
|
*/
|
||||||
|
public void setLdapVersion(int ldapVersion) {
|
||||||
|
this.ldapVersion = ldapVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the bindUser
|
||||||
|
*/
|
||||||
|
public String getBindUser() {
|
||||||
|
return bindUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param bindUser the bindUser to set
|
||||||
|
*/
|
||||||
|
public void setBindUser(String bindUser) {
|
||||||
|
this.bindUser = bindUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the bindPass
|
||||||
|
*/
|
||||||
|
public String getBindPass() {
|
||||||
|
return bindPass;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param bindPass the bindPass to set
|
||||||
|
*/
|
||||||
|
public void setBindPass(String bindPass) {
|
||||||
|
this.bindPass = bindPass;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,334 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.forwardfire.vasc.backend.ldap;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
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 com.novell.ldap.LDAPAttribute;
|
||||||
|
import com.novell.ldap.LDAPAttributeSet;
|
||||||
|
import com.novell.ldap.LDAPConnection;
|
||||||
|
import com.novell.ldap.LDAPEntry;
|
||||||
|
import com.novell.ldap.LDAPModification;
|
||||||
|
import com.novell.ldap.LDAPSearchConstraints;
|
||||||
|
import com.novell.ldap.LDAPSearchResults;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides backend for ldap.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Sep 4, 2008
|
||||||
|
*/
|
||||||
|
public class LdapVascBackend extends AbstractVascBackend {
|
||||||
|
|
||||||
|
|
||||||
|
private LdapConnectionProvider ldapConnectionProvider = null;
|
||||||
|
private String baseDN = null;
|
||||||
|
private String keyAttribute = null;
|
||||||
|
private String ldapFilter = null;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the ldapConnectionProvider
|
||||||
|
*/
|
||||||
|
public LdapConnectionProvider getLdapConnectionProvider() {
|
||||||
|
return ldapConnectionProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ldapConnectionProvider the ldapConnectionProvider to set
|
||||||
|
*/
|
||||||
|
public void setLdapConnectionProvider(LdapConnectionProvider ldapConnectionProvider) {
|
||||||
|
this.ldapConnectionProvider = ldapConnectionProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see net.forwardfire.vasc.backend.VascBackend#execute()
|
||||||
|
*/
|
||||||
|
public List<Object> execute(VascBackendState state) throws VascException {
|
||||||
|
LdapConnectionProvider prov = getLdapConnectionProvider();
|
||||||
|
LDAPConnection connection = prov.getLdapConnection();
|
||||||
|
List<Object> result = new ArrayList<Object>(50);
|
||||||
|
try {
|
||||||
|
|
||||||
|
|
||||||
|
LDAPSearchConstraints cons = new LDAPSearchConstraints();
|
||||||
|
cons.setBatchSize( 0 );
|
||||||
|
cons.setTimeLimit( 10000 ) ;
|
||||||
|
cons.setReferralFollowing(true);
|
||||||
|
connection.setConstraints(cons);
|
||||||
|
|
||||||
|
int searchScope = LDAPConnection.SCOPE_ONE;
|
||||||
|
String searchBase = baseDN;
|
||||||
|
|
||||||
|
//System.out.println("Reading object :" + searchBase + " with filter: " + ldapFilter);
|
||||||
|
LDAPSearchResults searchResults = connection.search(
|
||||||
|
searchBase, // object to read
|
||||||
|
searchScope, // scope - read single object
|
||||||
|
ldapFilter, // search filter
|
||||||
|
null, // return all attributes
|
||||||
|
false); // return attrs and values
|
||||||
|
|
||||||
|
while (searchResults.hasMore()) {
|
||||||
|
LDAPEntry entry = searchResults.next();
|
||||||
|
Map<String,Object> map = new HashMap<String,Object>(10);
|
||||||
|
|
||||||
|
LDAPAttributeSet attributeSet = entry.getAttributeSet();
|
||||||
|
Iterator<LDAPAttribute> i = attributeSet.iterator();
|
||||||
|
while (i.hasNext()) {
|
||||||
|
LDAPAttribute attr = i.next();
|
||||||
|
//System.out.println("ATTR: "+attr.getName()+" value: "+attr.getStringValue());
|
||||||
|
String[] s = attr.getStringValueArray();
|
||||||
|
if (s.length==1) {
|
||||||
|
map.put(attr.getName(), attr.getStringValue());
|
||||||
|
} else {
|
||||||
|
List<String> multiValue = new ArrayList<String>(s.length);
|
||||||
|
for (String ss:s) {
|
||||||
|
multiValue.add(ss);
|
||||||
|
}
|
||||||
|
map.put(attr.getName(), multiValue );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result.add(map);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new VascException(e);
|
||||||
|
} finally {
|
||||||
|
if (connection!=null) {
|
||||||
|
connection.clone();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see net.forwardfire.vasc.backend.VascBackend#merge(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public Object merge(Object object) throws VascException {
|
||||||
|
LdapConnectionProvider prov = getLdapConnectionProvider();
|
||||||
|
LDAPConnection connection = prov.getLdapConnection();
|
||||||
|
try {
|
||||||
|
Map<String,Object> map = (Map)object;
|
||||||
|
String keyValue = (String)map.get(keyAttribute);
|
||||||
|
LDAPSearchConstraints cons = new LDAPSearchConstraints();
|
||||||
|
cons.setBatchSize( 0 );
|
||||||
|
cons.setTimeLimit( 10000 ) ;
|
||||||
|
cons.setReferralFollowing(true);
|
||||||
|
connection.setConstraints(cons);
|
||||||
|
|
||||||
|
int searchScope = LDAPConnection.SCOPE_ONE;
|
||||||
|
String searchBase = baseDN;
|
||||||
|
String filter = "(&("+keyAttribute+"="+keyValue+"))";
|
||||||
|
System.out.println("ldap filter: "+filter);
|
||||||
|
LDAPSearchResults searchResults = connection.search(
|
||||||
|
searchBase, // object to read
|
||||||
|
searchScope, // scope - read single object
|
||||||
|
filter, // search filter
|
||||||
|
null, // return all attributes
|
||||||
|
false); // return attrs and values
|
||||||
|
|
||||||
|
if (searchResults.hasMore()==false) {
|
||||||
|
// no result to mod
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
LDAPEntry entry = searchResults.next();
|
||||||
|
List<LDAPModification> mods = new ArrayList<LDAPModification>(20);
|
||||||
|
for (String key:map.keySet()) {
|
||||||
|
Object value = map.get(key);
|
||||||
|
LDAPAttribute attr = entry.getAttribute(key);
|
||||||
|
if (attr==null) {
|
||||||
|
LDAPModification mod = new LDAPModification(LDAPModification.ADD,new LDAPAttribute(key,(String)value));
|
||||||
|
mods.add(mod);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String[] s = attr.getStringValueArray();
|
||||||
|
if (s.length==1) {
|
||||||
|
String v = (String)value;
|
||||||
|
if (attr.getStringValue().equals(v)==false) {
|
||||||
|
LDAPModification mod = new LDAPModification(LDAPModification.REPLACE,new LDAPAttribute(key,v));
|
||||||
|
mods.add(mod);
|
||||||
|
}
|
||||||
|
map.put(attr.getName(), attr.getStringValue());
|
||||||
|
} else {
|
||||||
|
List<String> multiValue = new ArrayList<String>(s.length);
|
||||||
|
for (String ss:s) {
|
||||||
|
multiValue.add(ss);
|
||||||
|
}
|
||||||
|
List<String> v = null;
|
||||||
|
if (value instanceof String) {
|
||||||
|
v = new ArrayList<String>(1);
|
||||||
|
v.add((String)value);
|
||||||
|
} else {
|
||||||
|
v = (List<String>)value;
|
||||||
|
}
|
||||||
|
if (v.equals(multiValue)==false) {
|
||||||
|
LDAPAttribute a = new LDAPAttribute(key);
|
||||||
|
for (String vv:v) {
|
||||||
|
a.addValue(vv);
|
||||||
|
}
|
||||||
|
LDAPModification mod = new LDAPModification(LDAPModification.REPLACE,a);
|
||||||
|
mods.add(mod);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LDAPModification[] m = new LDAPModification[mods.size()];
|
||||||
|
mods.toArray(m);
|
||||||
|
connection.modify(entry.getDN(), m);
|
||||||
|
return object;
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new VascException(e);
|
||||||
|
} finally {
|
||||||
|
if (connection!=null) {
|
||||||
|
connection.clone();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see net.forwardfire.vasc.backend.VascBackend#persist(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void persist(Object object) throws VascException {
|
||||||
|
LdapConnectionProvider prov = getLdapConnectionProvider();
|
||||||
|
LDAPConnection connection = prov.getLdapConnection();
|
||||||
|
try {
|
||||||
|
LDAPEntry entry = new LDAPEntry();
|
||||||
|
// entry.getAttributeSet().
|
||||||
|
|
||||||
|
connection.add(entry);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new VascException(e);
|
||||||
|
} finally {
|
||||||
|
if (connection!=null) {
|
||||||
|
connection.clone();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see net.forwardfire.vasc.backend.VascBackend#delete(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void delete(Object object) throws VascException {
|
||||||
|
LdapConnectionProvider prov = getLdapConnectionProvider();
|
||||||
|
LDAPConnection connection = prov.getLdapConnection();
|
||||||
|
try {
|
||||||
|
Map<String,Object> map = (Map)object;
|
||||||
|
String keyValue = (String)map.get(keyAttribute);
|
||||||
|
int searchScope = LDAPConnection.SCOPE_ONE;
|
||||||
|
String searchBase = baseDN;
|
||||||
|
String filter = "(&("+ldapFilter+")("+keyAttribute+"="+keyValue+"))";
|
||||||
|
LDAPSearchResults searchResults = connection.search(
|
||||||
|
searchBase, // object to read
|
||||||
|
searchScope, // scope - read single object
|
||||||
|
filter, // search filter
|
||||||
|
null, // return all attributes
|
||||||
|
false); // return attrs and values
|
||||||
|
|
||||||
|
if (searchResults.hasMore()==false) {
|
||||||
|
// no result to mod
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
LDAPEntry entry = searchResults.next();
|
||||||
|
connection.delete(entry.getDN());
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new VascException(e);
|
||||||
|
} finally {
|
||||||
|
if (connection!=null) {
|
||||||
|
connection.clone();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryRecordCreator(net.forwardfire.vasc.core.VascEntry)
|
||||||
|
*/
|
||||||
|
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
|
||||||
|
return new MapVascEntryRecordCreator();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryFieldValue(net.forwardfire.vasc.core.VascEntryField)
|
||||||
|
*/
|
||||||
|
public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) {
|
||||||
|
return new MapVascEntryFieldValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the baseDN
|
||||||
|
*/
|
||||||
|
public String getBaseDN() {
|
||||||
|
return baseDN;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param baseDN the baseDN to set
|
||||||
|
*/
|
||||||
|
public void setBaseDN(String baseDN) {
|
||||||
|
this.baseDN = baseDN;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the keyAttribute
|
||||||
|
*/
|
||||||
|
public String getKeyAttribute() {
|
||||||
|
return keyAttribute;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param keyAttribute the keyAttribute to set
|
||||||
|
*/
|
||||||
|
public void setKeyAttribute(String keyAttribute) {
|
||||||
|
this.keyAttribute = keyAttribute;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the ldapFilter
|
||||||
|
*/
|
||||||
|
public String getLdapFilter() {
|
||||||
|
return ldapFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ldapFilter the ldapFilter to set
|
||||||
|
*/
|
||||||
|
public void setLdapFilter(String ldapFilter) {
|
||||||
|
this.ldapFilter = ldapFilter;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<eld:root xmlns:eld="http://eld.x4o.org/eld/eld-lang.eld">
|
||||||
|
|
||||||
|
<eld:elementClass tag="ldapBackend" objectClassName="net.forwardfire.vasc.backend.ldap.LdapVascBackend">
|
||||||
|
<eld:elementConfigurator bean.class="net.forwardfire.vasc.impl.x4o.VascBackendElementConfigurator" configAction="true"/>
|
||||||
|
</eld:elementClass>
|
||||||
|
<eld:elementClass tag="ldapConnectionProvider" objectClassName="net.forwardfire.vasc.backend.ldap.LdapConnectionProviderImpl"/>
|
||||||
|
|
||||||
|
</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 ldap backend
|
||||||
|
</comment>
|
||||||
|
<entry key="eld.http://vasc.forwardfire.net/eld/vasc-backend-ldap.eld">vasc-backend-ldap.eld</entry>
|
||||||
|
</properties>
|
10
vasc-backend/vasc-backend-metamodel/.classpath
Normal file
10
vasc-backend/vasc-backend-metamodel/.classpath
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
|
||||||
|
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
|
||||||
|
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
|
||||||
|
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
|
||||||
|
<classpathentry kind="output" path="target/classes"/>
|
||||||
|
</classpath>
|
23
vasc-backend/vasc-backend-metamodel/.project
Normal file
23
vasc-backend/vasc-backend-metamodel/.project
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>vasc-backend-metamodel</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>
|
|
@ -0,0 +1,7 @@
|
||||||
|
#Sat Dec 31 05:51:03 CET 2011
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
encoding//src/main/java=UTF-8
|
||||||
|
encoding//src/main/resources=UTF-8
|
||||||
|
encoding//src/test/java=UTF-8
|
||||||
|
encoding//src/test/resources=UTF-8
|
||||||
|
encoding/<project>=UTF-8
|
|
@ -0,0 +1,6 @@
|
||||||
|
#Sat Dec 31 05:51:03 CET 2011
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
|
||||||
|
org.eclipse.jdt.core.compiler.compliance=1.5
|
||||||
|
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||||
|
org.eclipse.jdt.core.compiler.source=1.5
|
|
@ -0,0 +1,5 @@
|
||||||
|
#Sat Dec 31 05:51:03 CET 2011
|
||||||
|
activeProfiles=
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
resolveWorkspaceProjects=true
|
||||||
|
version=1
|
24
vasc-backend/vasc-backend-metamodel/pom.xml
Normal file
24
vasc-backend/vasc-backend-metamodel/pom.xml
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
<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>
|
||||||
|
<artifactId>vasc-backend</artifactId>
|
||||||
|
<groupId>net.forwardfire.vasc</groupId>
|
||||||
|
<version>0.3.5-SNAPSHOT</version>
|
||||||
|
<relativePath>..</relativePath>
|
||||||
|
</parent>
|
||||||
|
<artifactId>vasc-backend-metamodel</artifactId>
|
||||||
|
<name>vasc-backend-metamodel</name>
|
||||||
|
<description>vasc-backend-metamodel</description>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.forwardfire.vasc</groupId>
|
||||||
|
<artifactId>vasc-core</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eobjects.metamodel</groupId>
|
||||||
|
<artifactId>MetaModel-core</artifactId>
|
||||||
|
<version>2.1</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
|
@ -0,0 +1,97 @@
|
||||||
|
/*
|
||||||
|
* 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.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eobjects.metamodel.DataContext;
|
||||||
|
import org.eobjects.metamodel.data.DataSet;
|
||||||
|
import org.eobjects.metamodel.data.Row;
|
||||||
|
import org.eobjects.metamodel.query.Query;
|
||||||
|
import org.eobjects.metamodel.query.SelectItem;
|
||||||
|
import org.eobjects.metamodel.schema.Schema;
|
||||||
|
import org.eobjects.metamodel.schema.Table;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides backend for metamodel.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Dec 31, 2011
|
||||||
|
*/
|
||||||
|
public class MetaModelVascBackend extends AbstractVascBackend {
|
||||||
|
|
||||||
|
private DataContext dataContext = null;
|
||||||
|
private String table = null;
|
||||||
|
|
||||||
|
public List<Object> execute(VascBackendState state) throws VascException {
|
||||||
|
Schema schema = dataContext.getDefaultSchema();
|
||||||
|
Table t = schema.getTableByName(table);
|
||||||
|
//dataContext.query().from("").select("").where("").
|
||||||
|
Query q = dataContext.query().from(t).select(t.getColumns()).toQuery();
|
||||||
|
DataSet ds = dataContext.executeQuery(q);
|
||||||
|
List<Object> result = new ArrayList<Object>(50);
|
||||||
|
while (ds.next()) {
|
||||||
|
Row row = ds.getRow();
|
||||||
|
SelectItem[] cols = row.getSelectItems();
|
||||||
|
Map<String,Object> map = new HashMap<String,Object>(cols.length);
|
||||||
|
for (SelectItem col:cols) {
|
||||||
|
Object value = row.getValue(col);
|
||||||
|
map.put(col.getColumn().getName(), value);
|
||||||
|
}
|
||||||
|
result.add(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void persist(Object object) throws VascException {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object merge(Object object) throws VascException {
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void delete(Object object) throws VascException {
|
||||||
|
}
|
||||||
|
|
||||||
|
public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) {
|
||||||
|
return new MapVascEntryFieldValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
|
||||||
|
return new MapVascEntryRecordCreator();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.forwardfire.vasc.backend.mongodb;
|
||||||
|
|
||||||
|
import com.mongodb.DB;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides an mongodb DB connection to the backend.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Dec 30, 2011
|
||||||
|
*/
|
||||||
|
public interface MongodbConnectionProvider {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a DB connection.
|
||||||
|
* @return An DB connection to mongodb
|
||||||
|
*/
|
||||||
|
public DB getMongodbConnection();
|
||||||
|
}
|
|
@ -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.mongodb;
|
||||||
|
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import com.mongodb.DB;
|
||||||
|
import com.mongodb.Mongo;
|
||||||
|
import com.mongodb.MongoOptions;
|
||||||
|
import com.mongodb.ServerAddress;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides an mongodb DB connection to the backend.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Dec 30, 2011
|
||||||
|
*/
|
||||||
|
public class MongodbConnectionProviderImpl implements MongodbConnectionProvider {
|
||||||
|
|
||||||
|
private Logger logger = Logger.getLogger(MongodbConnectionProviderImpl.class.getName());
|
||||||
|
private String hostname = "localhost";
|
||||||
|
private int port = 27017;
|
||||||
|
private String database = null;
|
||||||
|
private String username = null;
|
||||||
|
private String password = null;
|
||||||
|
private boolean readonly = false;
|
||||||
|
|
||||||
|
protected static Mongo mongo = null;
|
||||||
|
protected static DB db = null;
|
||||||
|
|
||||||
|
public DB getMongodbConnection() {
|
||||||
|
if (db!=null) {
|
||||||
|
return db;
|
||||||
|
}
|
||||||
|
synchronized (this) {
|
||||||
|
ServerAddress server;
|
||||||
|
try {
|
||||||
|
server = new ServerAddress(hostname,port);
|
||||||
|
} catch (UnknownHostException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
MongoOptions options = new MongoOptions();
|
||||||
|
mongo = new Mongo(server,options);
|
||||||
|
db = mongo.getDB(database);
|
||||||
|
if (username!=null && password!=null) {
|
||||||
|
boolean auth = db.authenticate(username, password.toCharArray());
|
||||||
|
if (auth==false) {
|
||||||
|
throw new RuntimeException("Could not auth to db: "+database+" with username: "+username);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (readonly) {
|
||||||
|
db.setReadOnly(true);
|
||||||
|
}
|
||||||
|
logger.info("Connection to: "+db.getName());
|
||||||
|
}
|
||||||
|
return db;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the hostname
|
||||||
|
*/
|
||||||
|
public String getHostname() {
|
||||||
|
return hostname;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param hostname the hostname to set
|
||||||
|
*/
|
||||||
|
public void setHostname(String hostname) {
|
||||||
|
this.hostname = hostname;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the port
|
||||||
|
*/
|
||||||
|
public int getPort() {
|
||||||
|
return port;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param port the port to set
|
||||||
|
*/
|
||||||
|
public void setPort(int port) {
|
||||||
|
this.port = port;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the database
|
||||||
|
*/
|
||||||
|
public String getDatabase() {
|
||||||
|
return database;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param database the database to set
|
||||||
|
*/
|
||||||
|
public void setDatabase(String database) {
|
||||||
|
this.database = database;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the username
|
||||||
|
*/
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param username the username to set
|
||||||
|
*/
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the password
|
||||||
|
*/
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param password the password to set
|
||||||
|
*/
|
||||||
|
public void setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the readonly
|
||||||
|
*/
|
||||||
|
public boolean isReadonly() {
|
||||||
|
return readonly;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param readonly the readonly to set
|
||||||
|
*/
|
||||||
|
public void setReadonly(boolean readonly) {
|
||||||
|
this.readonly = readonly;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,151 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.forwardfire.vasc.backend.mongodb;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import net.forwardfire.vasc.backend.AbstractVascBackend;
|
||||||
|
import net.forwardfire.vasc.backend.VascBackendState;
|
||||||
|
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 com.mongodb.DB;
|
||||||
|
import com.mongodb.DBCollection;
|
||||||
|
import com.mongodb.DBCursor;
|
||||||
|
import com.mongodb.DBObject;
|
||||||
|
import com.mongodb.BasicDBObject;
|
||||||
|
import com.mongodb.WriteConcern;
|
||||||
|
import com.mongodb.WriteResult;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides backend for mongodb.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Dec 30, 2011
|
||||||
|
*/
|
||||||
|
public class MongodbVascBackend extends AbstractVascBackend {
|
||||||
|
|
||||||
|
private Logger logger = null;
|
||||||
|
private MongodbConnectionProvider connectionProvider = null;
|
||||||
|
private String collection = null;
|
||||||
|
private DB database = null;
|
||||||
|
|
||||||
|
public MongodbVascBackend() {
|
||||||
|
logger = Logger.getLogger(MongodbVascBackend.class.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Object> execute(VascBackendState state) throws VascException {
|
||||||
|
DBCollection coll = getDBCollection();
|
||||||
|
DBObject query = new BasicDBObject();
|
||||||
|
for (String key:state.getDataParameterKeys()) {
|
||||||
|
Object value = state.getDataParameter(key);
|
||||||
|
query.put(key, value);
|
||||||
|
logger.finer("Setting query parameter key: '"+key+"' value: '"+value+"'");
|
||||||
|
}
|
||||||
|
DBCursor cur = coll.find(query);
|
||||||
|
//cur.count();
|
||||||
|
List<Object> result = new ArrayList<Object>(cur.count());
|
||||||
|
while (cur.hasNext()) {
|
||||||
|
DBObject row = cur.next();
|
||||||
|
result.add(row);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void persist(Object object) throws VascException {
|
||||||
|
DBCollection coll = getDBCollection();
|
||||||
|
coll.insert((DBObject)object);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object merge(Object object) throws VascException {
|
||||||
|
DBCollection coll = getDBCollection();
|
||||||
|
DBObject row = (DBObject)object;
|
||||||
|
DBObject query = new BasicDBObject();
|
||||||
|
query.put("_id",row.get("_id"));
|
||||||
|
WriteResult wr = coll.update(query,row,false,false,WriteConcern.SAFE);
|
||||||
|
logger.info("WriteResult: "+wr);
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void delete(Object object) throws VascException {
|
||||||
|
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) {
|
||||||
|
return new MongodbVascEntryFieldValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
|
||||||
|
return new MongodbVascEntryRecordCreator();
|
||||||
|
}
|
||||||
|
|
||||||
|
private DBCollection getDBCollection() {
|
||||||
|
if (database!=null) {
|
||||||
|
return database.getCollection(collection);
|
||||||
|
}
|
||||||
|
if (connectionProvider==null) {
|
||||||
|
throw new RuntimeException("Can't get DBCollection from null connectionProvider.");
|
||||||
|
}
|
||||||
|
synchronized (connectionProvider) {
|
||||||
|
database = connectionProvider.getMongodbConnection();
|
||||||
|
}
|
||||||
|
return database.getCollection(collection);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the connectionProvider
|
||||||
|
*/
|
||||||
|
public MongodbConnectionProvider getConnectionProvider() {
|
||||||
|
return connectionProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param connectionProvider the connectionProvider to set
|
||||||
|
*/
|
||||||
|
public void setConnectionProvider(MongodbConnectionProvider connectionProvider) {
|
||||||
|
this.connectionProvider = connectionProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the collection
|
||||||
|
*/
|
||||||
|
public String getCollection() {
|
||||||
|
return collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param collection the collection to set
|
||||||
|
*/
|
||||||
|
public void setCollection(String collection) {
|
||||||
|
this.collection = collection;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,59 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.forwardfire.vasc.backend.mongodb;
|
||||||
|
|
||||||
|
import net.forwardfire.vasc.core.VascEntryField;
|
||||||
|
import net.forwardfire.vasc.core.VascException;
|
||||||
|
import net.forwardfire.vasc.core.entry.VascEntryFieldValue;
|
||||||
|
|
||||||
|
|
||||||
|
import com.mongodb.BasicDBObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a mongodb field entry knowlege.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Dec 30, 2011
|
||||||
|
*/
|
||||||
|
public class MongodbVascEntryFieldValue implements VascEntryFieldValue {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -7371273796529818557L;
|
||||||
|
|
||||||
|
public Object getValue(VascEntryField field, Object record) throws VascException {
|
||||||
|
BasicDBObject row = (BasicDBObject)record;
|
||||||
|
Object r = row.get(field.getBackendName());
|
||||||
|
if (r==null) {
|
||||||
|
return ""; // create new value, TODO
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDisplayValue(VascEntryField field, Object record) throws VascException {
|
||||||
|
return ""+getValue(field,record); // not supported TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(VascEntryField field, Object record, Object value) throws VascException {
|
||||||
|
BasicDBObject row = (BasicDBObject)record;
|
||||||
|
row.put(field.getBackendName(), 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.mongodb;
|
||||||
|
|
||||||
|
import net.forwardfire.vasc.core.VascEntry;
|
||||||
|
import net.forwardfire.vasc.core.entry.VascEntryRecordCreator;
|
||||||
|
|
||||||
|
|
||||||
|
import com.mongodb.BasicDBObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a mongodb object to create a new row.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Dec 30, 2011
|
||||||
|
*/
|
||||||
|
public class MongodbVascEntryRecordCreator implements VascEntryRecordCreator {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -9213830731796787384L;
|
||||||
|
|
||||||
|
public Object newRecord(VascEntry entry) throws Exception {
|
||||||
|
return new BasicDBObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Class<?> getObjectClass() {
|
||||||
|
return BasicDBObject.class;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<eld:root xmlns:eld="http://eld.x4o.org/eld/eld-lang.eld">
|
||||||
|
<eld:elementClass tag="mongodbBackend" objectClassName="net.forwardfire.vasc.backend.mongodb.MongodbVascBackend">
|
||||||
|
<eld:elementConfigurator bean.class="net.forwardfire.vasc.impl.x4o.VascBackendElementConfigurator" configAction="true"/>
|
||||||
|
</eld:elementClass>
|
||||||
|
<eld:elementClass tag="mongodbConnectionProvider" objectClassName="net.forwardfire.vasc.backend.mongodb.MongodbConnectionProviderImpl"/>
|
||||||
|
</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 mongodb backend
|
||||||
|
</comment>
|
||||||
|
<entry key="eld.http://vasc.forwardfire.net/eld/vasc-backend-mongodb.eld">vasc-backend-mongodb.eld</entry>
|
||||||
|
</properties>
|
|
@ -16,12 +16,12 @@
|
||||||
</arguments>
|
</arguments>
|
||||||
</buildCommand>
|
</buildCommand>
|
||||||
<buildCommand>
|
<buildCommand>
|
||||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
<name>org.eclipse.wst.validation.validationbuilder</name>
|
||||||
<arguments>
|
<arguments>
|
||||||
</arguments>
|
</arguments>
|
||||||
</buildCommand>
|
</buildCommand>
|
||||||
<buildCommand>
|
<buildCommand>
|
||||||
<name>org.eclipse.wst.validation.validationbuilder</name>
|
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||||
<arguments>
|
<arguments>
|
||||||
</arguments>
|
</arguments>
|
||||||
</buildCommand>
|
</buildCommand>
|
||||||
|
|
|
@ -20,10 +20,12 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.forwardfire.vasc.core;
|
package net.forwardfire.vasc.backend;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import net.forwardfire.vasc.core.VascException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -35,14 +37,14 @@ abstract public class AbstractVascBackend implements VascBackend {
|
||||||
private String id = null;
|
private String id = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#getId()
|
* @see net.forwardfire.vasc.backend.VascBackend#getId()
|
||||||
*/
|
*/
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#setId(java.lang.String)
|
* @see net.forwardfire.vasc.backend.VascBackend#setId(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public void setId(String id) {
|
public void setId(String id) {
|
||||||
if (id==null) {
|
if (id==null) {
|
||||||
|
@ -52,77 +54,77 @@ abstract public class AbstractVascBackend implements VascBackend {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#isPageable()
|
* @see net.forwardfire.vasc.backend.VascBackend#isPageable()
|
||||||
*/
|
*/
|
||||||
public boolean isPageable() {
|
public boolean isPageable() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#fetchTotalExecuteSize(VascBackendState state)
|
* @see net.forwardfire.vasc.backend.VascBackend#fetchTotalExecuteSize(VascBackendState state)
|
||||||
*/
|
*/
|
||||||
public long fetchTotalExecuteSize(VascBackendState state) {
|
public long fetchTotalExecuteSize(VascBackendState state) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#isSearchable()
|
* @see net.forwardfire.vasc.backend.VascBackend#isSearchable()
|
||||||
*/
|
*/
|
||||||
public boolean isSearchable() {
|
public boolean isSearchable() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#isSortable()
|
* @see net.forwardfire.vasc.backend.VascBackend#isSortable()
|
||||||
*/
|
*/
|
||||||
public boolean isSortable() {
|
public boolean isSortable() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#isRecordMoveable()
|
* @see net.forwardfire.vasc.backend.VascBackend#isRecordMoveable()
|
||||||
*/
|
*/
|
||||||
public boolean isRecordMoveable() {
|
public boolean isRecordMoveable() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#doRecordMoveDownById(java.lang.Object)
|
* @see net.forwardfire.vasc.backend.VascBackend#doRecordMoveDownById(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public long doRecordMoveDownById(VascBackendState state,Object primaryId) throws VascException {
|
public long doRecordMoveDownById(VascBackendState state,Object primaryId) throws VascException {
|
||||||
return 0l;
|
return 0l;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#doRecordMoveUpById(java.lang.Object)
|
* @see net.forwardfire.vasc.backend.VascBackend#doRecordMoveUpById(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public long doRecordMoveUpById(VascBackendState state,Object primaryId) throws VascException {
|
public long doRecordMoveUpById(VascBackendState state,Object primaryId) throws VascException {
|
||||||
return 0l;
|
return 0l;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#executePageSummary()
|
* @see net.forwardfire.vasc.backend.VascBackend#executePageSummary()
|
||||||
*/
|
*/
|
||||||
public Map<String, Object> executePageSummary() {
|
public Map<String, Object> executePageSummary() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#executeTotalSummary()
|
* @see net.forwardfire.vasc.backend.VascBackend#executeTotalSummary()
|
||||||
*/
|
*/
|
||||||
public Map<String, Object> executeTotalSummary() {
|
public Map<String, Object> executeTotalSummary() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#isPageSummary()
|
* @see net.forwardfire.vasc.backend.VascBackend#isPageSummary()
|
||||||
*/
|
*/
|
||||||
public boolean isPageSummary() {
|
public boolean isPageSummary() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#isTotalSummary()
|
* @see net.forwardfire.vasc.backend.VascBackend#isTotalSummary()
|
||||||
*/
|
*/
|
||||||
public boolean isTotalSummary() {
|
public boolean isTotalSummary() {
|
||||||
return false;
|
return false;
|
|
@ -20,7 +20,7 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.forwardfire.vasc.core;
|
package net.forwardfire.vasc.backend;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -60,70 +60,70 @@ abstract public class AbstractVascBackendState implements VascBackendState {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#getPageIndex()
|
* @see net.forwardfire.vasc.backend.VascBackend#getPageIndex()
|
||||||
*/
|
*/
|
||||||
public int getPageIndex() {
|
public int getPageIndex() {
|
||||||
return pageIndex;
|
return pageIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#setPageIndex(int)
|
* @see net.forwardfire.vasc.backend.VascBackend#setPageIndex(int)
|
||||||
*/
|
*/
|
||||||
public void setPageIndex(int pageIndex) {
|
public void setPageIndex(int pageIndex) {
|
||||||
this.pageIndex=pageIndex;
|
this.pageIndex=pageIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#getPageSize()
|
* @see net.forwardfire.vasc.backend.VascBackend#getPageSize()
|
||||||
*/
|
*/
|
||||||
public int getPageSize() {
|
public int getPageSize() {
|
||||||
return pageSize;
|
return pageSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#setPageSize(int)
|
* @see net.forwardfire.vasc.backend.VascBackend#setPageSize(int)
|
||||||
*/
|
*/
|
||||||
public void setPageSize(int pageSize) {
|
public void setPageSize(int pageSize) {
|
||||||
this.pageSize=pageSize;
|
this.pageSize=pageSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#getSearchString()
|
* @see net.forwardfire.vasc.backend.VascBackend#getSearchString()
|
||||||
*/
|
*/
|
||||||
public String getSearchString() {
|
public String getSearchString() {
|
||||||
return searchString;
|
return searchString;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#setSearchString(java.lang.String)
|
* @see net.forwardfire.vasc.backend.VascBackend#setSearchString(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public void setSearchString(String searchString) {
|
public void setSearchString(String searchString) {
|
||||||
this.searchString=searchString;
|
this.searchString=searchString;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#isSortAscending()
|
* @see net.forwardfire.vasc.backend.VascBackend#isSortAscending()
|
||||||
*/
|
*/
|
||||||
public boolean isSortAscending() {
|
public boolean isSortAscending() {
|
||||||
return ascending;
|
return ascending;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#setSortAscending(boolean)
|
* @see net.forwardfire.vasc.backend.VascBackend#setSortAscending(boolean)
|
||||||
*/
|
*/
|
||||||
public void setSortAscending(boolean ascending) {
|
public void setSortAscending(boolean ascending) {
|
||||||
this.ascending=ascending;
|
this.ascending=ascending;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#getSortField()
|
* @see net.forwardfire.vasc.backend.VascBackend#getSortField()
|
||||||
*/
|
*/
|
||||||
public String getSortField() {
|
public String getSortField() {
|
||||||
return sortField;
|
return sortField;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#setSortField(java.lang.String)
|
* @see net.forwardfire.vasc.backend.VascBackend#setSortField(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public void setSortField(String sortField) {
|
public void setSortField(String sortField) {
|
||||||
this.sortField=sortField;
|
this.sortField=sortField;
|
|
@ -20,11 +20,14 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.forwardfire.vasc.core;
|
package net.forwardfire.vasc.backend;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
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.VascEntryFieldValue;
|
||||||
import net.forwardfire.vasc.core.entry.VascEntryRecordCreator;
|
import net.forwardfire.vasc.core.entry.VascEntryRecordCreator;
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.forwardfire.vasc.core;
|
package net.forwardfire.vasc.backend;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -20,7 +20,7 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.forwardfire.vasc.core;
|
package net.forwardfire.vasc.backend;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -20,7 +20,9 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.forwardfire.vasc.core;
|
package net.forwardfire.vasc.backend;
|
||||||
|
|
||||||
|
import net.forwardfire.vasc.core.VascEntry;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -20,7 +20,7 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.forwardfire.vasc.core;
|
package net.forwardfire.vasc.backend;
|
||||||
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
|
@ -20,7 +20,7 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.forwardfire.vasc.core;
|
package net.forwardfire.vasc.backend;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
|
@ -20,7 +20,7 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.forwardfire.vasc.backends;
|
package net.forwardfire.vasc.backend.data;
|
||||||
|
|
||||||
|
|
||||||
import net.forwardfire.vasc.core.VascEntryField;
|
import net.forwardfire.vasc.core.VascEntryField;
|
|
@ -20,7 +20,7 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.forwardfire.vasc.backends;
|
package net.forwardfire.vasc.backend.data;
|
||||||
|
|
||||||
import net.forwardfire.vasc.core.VascEntry;
|
import net.forwardfire.vasc.core.VascEntry;
|
||||||
import net.forwardfire.vasc.core.entry.VascEntryRecordCreator;
|
import net.forwardfire.vasc.core.entry.VascEntryRecordCreator;
|
|
@ -20,7 +20,7 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.forwardfire.vasc.backends;
|
package net.forwardfire.vasc.backend.data;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -43,19 +43,29 @@ public class MapVascEntryFieldValue implements VascEntryFieldValue {
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public Object getValue(VascEntryField field, Object record) throws VascException {
|
public Object getValue(VascEntryField field, Object record) throws VascException {
|
||||||
Map<String,Object> map = (Map<String,Object>)record;
|
if (field==null) {
|
||||||
Object r = map.get(field.getBackendName());
|
throw new NullPointerException("Can't get value of null field.");
|
||||||
if (r==null) {
|
|
||||||
return ""; // create new value, ldap does not return data for field that an user does not have, but other do,...
|
|
||||||
}
|
}
|
||||||
return r;
|
if (field.getBackendName()==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(field.getBackendName());
|
||||||
|
return fieldValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.entry.VascEntryFieldValue#getDisplayValue(net.forwardfire.vasc.core.VascEntryField, java.lang.Object)
|
* @see net.forwardfire.vasc.core.entry.VascEntryFieldValue#getDisplayValue(net.forwardfire.vasc.core.VascEntryField, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public String getDisplayValue(VascEntryField field, Object record) throws VascException {
|
public String getDisplayValue(VascEntryField field, Object record) throws VascException {
|
||||||
return ""+getValue(field,record); // not supported (this)ldap is already fully string based.
|
Object fieldValue = getValue(field,record);
|
||||||
|
if (fieldValue==null) {
|
||||||
|
fieldValue = "";
|
||||||
|
}
|
||||||
|
return fieldValue.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -20,7 +20,7 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.forwardfire.vasc.backends;
|
package net.forwardfire.vasc.backend.data;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
|
@ -20,16 +20,22 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.forwardfire.vasc.core;
|
package net.forwardfire.vasc.backend.proxy;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import net.forwardfire.vasc.backend.VascBackend;
|
||||||
|
import net.forwardfire.vasc.backend.VascBackendState;
|
||||||
|
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.VascEntryFieldValue;
|
||||||
import net.forwardfire.vasc.core.entry.VascEntryRecordCreator;
|
import net.forwardfire.vasc.core.entry.VascEntryRecordCreator;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* AbstractVascBackendProxy to implement missing features of the backend.
|
||||||
*
|
*
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Apr 1, 2009
|
* @version 1.0 Apr 1, 2009
|
||||||
|
@ -46,14 +52,14 @@ abstract public class AbstractVascBackendProxy implements VascBackend {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#fetchTotalExecuteSize(VascBackendState state)
|
* @see net.forwardfire.vasc.backend.VascBackend#fetchTotalExecuteSize(VascBackendState state)
|
||||||
*/
|
*/
|
||||||
public long fetchTotalExecuteSize(VascBackendState state) {
|
public long fetchTotalExecuteSize(VascBackendState state) {
|
||||||
return backend.fetchTotalExecuteSize(state);
|
return backend.fetchTotalExecuteSize(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#isSortable()
|
* @see net.forwardfire.vasc.backend.VascBackend#isSortable()
|
||||||
*/
|
*/
|
||||||
public boolean isSortable() {
|
public boolean isSortable() {
|
||||||
return backend.isSortable();
|
return backend.isSortable();
|
||||||
|
@ -61,70 +67,70 @@ abstract public class AbstractVascBackendProxy implements VascBackend {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#execute(VascBackendState state)
|
* @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state)
|
||||||
*/
|
*/
|
||||||
public List<Object> execute(VascBackendState state) throws VascException {
|
public List<Object> execute(VascBackendState state) throws VascException {
|
||||||
return backend.execute(state);
|
return backend.execute(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#delete(java.lang.Object)
|
* @see net.forwardfire.vasc.backend.VascBackend#delete(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void delete(Object object) throws VascException {
|
public void delete(Object object) throws VascException {
|
||||||
backend.delete(object);
|
backend.delete(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#isPageable()
|
* @see net.forwardfire.vasc.backend.VascBackend#isPageable()
|
||||||
*/
|
*/
|
||||||
public boolean isPageable() {
|
public boolean isPageable() {
|
||||||
return backend.isPageable();
|
return backend.isPageable();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#isSearchable()
|
* @see net.forwardfire.vasc.backend.VascBackend#isSearchable()
|
||||||
*/
|
*/
|
||||||
public boolean isSearchable() {
|
public boolean isSearchable() {
|
||||||
return backend.isSearchable();
|
return backend.isSearchable();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#merge(java.lang.Object)
|
* @see net.forwardfire.vasc.backend.VascBackend#merge(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public Object merge(Object object) throws VascException {
|
public Object merge(Object object) throws VascException {
|
||||||
return backend.merge(object);
|
return backend.merge(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#persist(java.lang.Object)
|
* @see net.forwardfire.vasc.backend.VascBackend#persist(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void persist(Object object) throws VascException {
|
public void persist(Object object) throws VascException {
|
||||||
backend.persist(object);
|
backend.persist(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#provideVascEntryFieldValue(net.forwardfire.vasc.core.VascEntryField)
|
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryFieldValue(net.forwardfire.vasc.core.VascEntryField)
|
||||||
*/
|
*/
|
||||||
public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) {
|
public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) {
|
||||||
return backend.provideVascEntryFieldValue(field);
|
return backend.provideVascEntryFieldValue(field);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#provideVascEntryRecordCreator(net.forwardfire.vasc.core.VascEntry)
|
* @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryRecordCreator(net.forwardfire.vasc.core.VascEntry)
|
||||||
*/
|
*/
|
||||||
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
|
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
|
||||||
return backend.provideVascEntryRecordCreator(vascEntry);
|
return backend.provideVascEntryRecordCreator(vascEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#getId()
|
* @see net.forwardfire.vasc.backend.VascBackend#getId()
|
||||||
*/
|
*/
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return backend.getId();
|
return backend.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#setId(java.lang.String)
|
* @see net.forwardfire.vasc.backend.VascBackend#setId(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public void setId(String id) {
|
public void setId(String id) {
|
||||||
backend.setId(id);
|
backend.setId(id);
|
||||||
|
@ -145,35 +151,35 @@ abstract public class AbstractVascBackendProxy implements VascBackend {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#isRecordMoveable()
|
* @see net.forwardfire.vasc.backend.VascBackend#isRecordMoveable()
|
||||||
*/
|
*/
|
||||||
public boolean isRecordMoveable() {
|
public boolean isRecordMoveable() {
|
||||||
return backend.isRecordMoveable();
|
return backend.isRecordMoveable();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#executePageSummary()
|
* @see net.forwardfire.vasc.backend.VascBackend#executePageSummary()
|
||||||
*/
|
*/
|
||||||
public Map<String, Object> executePageSummary() {
|
public Map<String, Object> executePageSummary() {
|
||||||
return backend.executePageSummary();
|
return backend.executePageSummary();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#executeTotalSummary()
|
* @see net.forwardfire.vasc.backend.VascBackend#executeTotalSummary()
|
||||||
*/
|
*/
|
||||||
public Map<String, Object> executeTotalSummary() {
|
public Map<String, Object> executeTotalSummary() {
|
||||||
return backend.executeTotalSummary();
|
return backend.executeTotalSummary();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#isPageSummary()
|
* @see net.forwardfire.vasc.backend.VascBackend#isPageSummary()
|
||||||
*/
|
*/
|
||||||
public boolean isPageSummary() {
|
public boolean isPageSummary() {
|
||||||
return backend.isPageSummary();
|
return backend.isPageSummary();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#isTotalSummary()
|
* @see net.forwardfire.vasc.backend.VascBackend#isTotalSummary()
|
||||||
*/
|
*/
|
||||||
public boolean isTotalSummary() {
|
public boolean isTotalSummary() {
|
||||||
return backend.isTotalSummary();
|
return backend.isTotalSummary();
|
|
@ -20,15 +20,14 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.forwardfire.vasc.impl;
|
package net.forwardfire.vasc.backend.proxy;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import net.forwardfire.vasc.core.AbstractVascBackendProxy;
|
import net.forwardfire.vasc.backend.VascBackend;
|
||||||
import net.forwardfire.vasc.core.VascBackend;
|
import net.forwardfire.vasc.backend.VascBackendState;
|
||||||
import net.forwardfire.vasc.core.VascBackendState;
|
|
||||||
import net.forwardfire.vasc.core.VascEntry;
|
import net.forwardfire.vasc.core.VascEntry;
|
||||||
import net.forwardfire.vasc.core.VascException;
|
import net.forwardfire.vasc.core.VascException;
|
||||||
|
|
||||||
|
@ -77,7 +76,7 @@ public class VascBackendProxyCache extends AbstractVascBackendProxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#execute(VascBackendState state)
|
* @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Object> execute(VascBackendState state) throws VascException {
|
public List<Object> execute(VascBackendState state) throws VascException {
|
|
@ -20,14 +20,13 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.forwardfire.vasc.impl;
|
package net.forwardfire.vasc.backend.proxy;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.forwardfire.vasc.core.AbstractVascBackendProxy;
|
import net.forwardfire.vasc.backend.VascBackend;
|
||||||
import net.forwardfire.vasc.core.VascBackend;
|
import net.forwardfire.vasc.backend.VascBackendState;
|
||||||
import net.forwardfire.vasc.core.VascBackendState;
|
|
||||||
import net.forwardfire.vasc.core.VascEntry;
|
import net.forwardfire.vasc.core.VascEntry;
|
||||||
import net.forwardfire.vasc.core.VascException;
|
import net.forwardfire.vasc.core.VascException;
|
||||||
import net.forwardfire.vasc.core.entry.VascEntryBackendEventListener;
|
import net.forwardfire.vasc.core.entry.VascEntryBackendEventListener;
|
||||||
|
@ -92,7 +91,7 @@ public class VascBackendProxyEventExecutor extends AbstractVascBackendProxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.AbstractVascBackendProxy#delete(java.lang.Object)
|
* @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#delete(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void delete(Object object) throws VascException {
|
public void delete(Object object) throws VascException {
|
||||||
|
@ -102,7 +101,7 @@ public class VascBackendProxyEventExecutor extends AbstractVascBackendProxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.AbstractVascBackendProxy#doRecordMoveDownById(net.forwardfire.vasc.core.VascBackendState, java.lang.Object)
|
* @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#doRecordMoveDownById(net.forwardfire.vasc.backend.VascBackendState, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public long doRecordMoveDownById(VascBackendState state, Object primaryId) throws VascException {
|
public long doRecordMoveDownById(VascBackendState state, Object primaryId) throws VascException {
|
||||||
|
@ -113,7 +112,7 @@ public class VascBackendProxyEventExecutor extends AbstractVascBackendProxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.AbstractVascBackendProxy#doRecordMoveUpById(net.forwardfire.vasc.core.VascBackendState, java.lang.Object)
|
* @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#doRecordMoveUpById(net.forwardfire.vasc.backend.VascBackendState, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public long doRecordMoveUpById(VascBackendState state, Object primaryId) throws VascException {
|
public long doRecordMoveUpById(VascBackendState state, Object primaryId) throws VascException {
|
||||||
|
@ -124,7 +123,7 @@ public class VascBackendProxyEventExecutor extends AbstractVascBackendProxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.AbstractVascBackendProxy#execute(net.forwardfire.vasc.core.VascBackendState)
|
* @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#execute(net.forwardfire.vasc.backend.VascBackendState)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Object> execute(VascBackendState state) throws VascException {
|
public List<Object> execute(VascBackendState state) throws VascException {
|
||||||
|
@ -135,7 +134,7 @@ public class VascBackendProxyEventExecutor extends AbstractVascBackendProxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.AbstractVascBackendProxy#fetchTotalExecuteSize(net.forwardfire.vasc.core.VascBackendState)
|
* @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#fetchTotalExecuteSize(net.forwardfire.vasc.backend.VascBackendState)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public long fetchTotalExecuteSize(VascBackendState state) {
|
public long fetchTotalExecuteSize(VascBackendState state) {
|
||||||
|
@ -146,7 +145,7 @@ public class VascBackendProxyEventExecutor extends AbstractVascBackendProxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.AbstractVascBackendProxy#merge(java.lang.Object)
|
* @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#merge(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Object merge(Object object) throws VascException {
|
public Object merge(Object object) throws VascException {
|
||||||
|
@ -157,7 +156,7 @@ public class VascBackendProxyEventExecutor extends AbstractVascBackendProxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.AbstractVascBackendProxy#persist(java.lang.Object)
|
* @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#persist(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void persist(Object object) throws VascException {
|
public void persist(Object object) throws VascException {
|
|
@ -20,15 +20,14 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.forwardfire.vasc.impl;
|
package net.forwardfire.vasc.backend.proxy;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.forwardfire.vasc.core.AbstractVascBackendProxy;
|
import net.forwardfire.vasc.backend.VascBackend;
|
||||||
import net.forwardfire.vasc.core.VascBackend;
|
import net.forwardfire.vasc.backend.VascBackendFilter;
|
||||||
import net.forwardfire.vasc.core.VascBackendFilter;
|
import net.forwardfire.vasc.backend.VascBackendState;
|
||||||
import net.forwardfire.vasc.core.VascBackendState;
|
|
||||||
import net.forwardfire.vasc.core.VascEntry;
|
import net.forwardfire.vasc.core.VascEntry;
|
||||||
import net.forwardfire.vasc.core.VascException;
|
import net.forwardfire.vasc.core.VascException;
|
||||||
|
|
||||||
|
@ -51,7 +50,7 @@ public class VascBackendProxyFilter extends AbstractVascBackendProxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#execute(VascBackendState state)
|
* @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Object> execute(VascBackendState state) throws VascException {
|
public List<Object> execute(VascBackendState state) throws VascException {
|
|
@ -20,14 +20,13 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.forwardfire.vasc.impl;
|
package net.forwardfire.vasc.backend.proxy;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.forwardfire.vasc.core.AbstractVascBackendProxy;
|
import net.forwardfire.vasc.backend.VascBackend;
|
||||||
import net.forwardfire.vasc.core.VascBackend;
|
import net.forwardfire.vasc.backend.VascBackendState;
|
||||||
import net.forwardfire.vasc.core.VascBackendState;
|
|
||||||
import net.forwardfire.vasc.core.VascEntry;
|
import net.forwardfire.vasc.core.VascEntry;
|
||||||
import net.forwardfire.vasc.core.VascException;
|
import net.forwardfire.vasc.core.VascException;
|
||||||
|
|
||||||
|
@ -48,7 +47,7 @@ public class VascBackendProxyPaged extends AbstractVascBackendProxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#isPageable()
|
* @see net.forwardfire.vasc.backend.VascBackend#isPageable()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isPageable() {
|
public boolean isPageable() {
|
||||||
|
@ -56,7 +55,7 @@ public class VascBackendProxyPaged extends AbstractVascBackendProxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#execute(VascBackendState state)
|
* @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Object> execute(VascBackendState state) throws VascException {
|
public List<Object> execute(VascBackendState state) throws VascException {
|
|
@ -20,7 +20,7 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.forwardfire.vasc.impl;
|
package net.forwardfire.vasc.backend.proxy;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -29,11 +29,12 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import net.forwardfire.vasc.core.AbstractVascBackendProxy;
|
import net.forwardfire.vasc.backend.VascBackend;
|
||||||
import net.forwardfire.vasc.core.VascBackend;
|
import net.forwardfire.vasc.backend.VascBackendState;
|
||||||
import net.forwardfire.vasc.core.VascBackendState;
|
|
||||||
import net.forwardfire.vasc.core.VascEntry;
|
import net.forwardfire.vasc.core.VascEntry;
|
||||||
|
import net.forwardfire.vasc.core.VascEntryField;
|
||||||
import net.forwardfire.vasc.core.VascException;
|
import net.forwardfire.vasc.core.VascException;
|
||||||
|
import net.forwardfire.vasc.core.entry.VascEntryFieldValue;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,13 +47,15 @@ import net.forwardfire.vasc.core.VascException;
|
||||||
public class VascBackendProxySearch extends AbstractVascBackendProxy {
|
public class VascBackendProxySearch extends AbstractVascBackendProxy {
|
||||||
|
|
||||||
private long records = 0;
|
private long records = 0;
|
||||||
|
private VascEntry entry = null;
|
||||||
|
|
||||||
public VascBackendProxySearch(VascBackend backend,VascEntry entry) {
|
public VascBackendProxySearch(VascBackend backend,VascEntry entry) {
|
||||||
super(backend);
|
super(backend);
|
||||||
|
this.entry=entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#isSearchable()
|
* @see net.forwardfire.vasc.backend.VascBackend#isSearchable()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isSearchable() {
|
public boolean isSearchable() {
|
||||||
|
@ -60,7 +63,7 @@ public class VascBackendProxySearch extends AbstractVascBackendProxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#execute(VascBackendState state)
|
* @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Object> execute(VascBackendState state) throws VascException {
|
public List<Object> execute(VascBackendState state) throws VascException {
|
||||||
|
@ -75,7 +78,18 @@ public class VascBackendProxySearch extends AbstractVascBackendProxy {
|
||||||
}
|
}
|
||||||
String searchString = state.getSearchString().toLowerCase();
|
String searchString = state.getSearchString().toLowerCase();
|
||||||
List<Object> search = new ArrayList<Object>(result.size()/4);
|
List<Object> search = new ArrayList<Object>(result.size()/4);
|
||||||
for (Object o:result) {
|
for (Object record:result) {
|
||||||
|
for (VascEntryField field:entry.getVascEntryFields()) {
|
||||||
|
VascEntryFieldValue fieldValue = backend.provideVascEntryFieldValue(field);
|
||||||
|
Object value = fieldValue.getValue(field, record);
|
||||||
|
String r = value.toString().toLowerCase();
|
||||||
|
if (r.contains(searchString)) {
|
||||||
|
search.add(record);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
for (Method method:o.getClass().getMethods()) {
|
for (Method method:o.getClass().getMethods()) {
|
||||||
if (method.getName().startsWith("get")==false) { //a bit durty
|
if (method.getName().startsWith("get")==false) { //a bit durty
|
||||||
continue;
|
continue;
|
||||||
|
@ -110,6 +124,7 @@ public class VascBackendProxySearch extends AbstractVascBackendProxy {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
records = search.size();
|
records = search.size();
|
||||||
return search;
|
return search;
|
|
@ -20,15 +20,14 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.forwardfire.vasc.impl;
|
package net.forwardfire.vasc.backend.proxy;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.forwardfire.vasc.core.AbstractVascBackendProxy;
|
import net.forwardfire.vasc.backend.VascBackend;
|
||||||
import net.forwardfire.vasc.core.VascBackend;
|
import net.forwardfire.vasc.backend.VascBackendState;
|
||||||
import net.forwardfire.vasc.core.VascBackendState;
|
|
||||||
import net.forwardfire.vasc.core.VascEntry;
|
import net.forwardfire.vasc.core.VascEntry;
|
||||||
import net.forwardfire.vasc.core.VascEntryField;
|
import net.forwardfire.vasc.core.VascEntryField;
|
||||||
import net.forwardfire.vasc.core.VascException;
|
import net.forwardfire.vasc.core.VascException;
|
||||||
|
@ -55,7 +54,7 @@ public class VascBackendProxySort extends AbstractVascBackendProxy {
|
||||||
// sort stuff
|
// sort stuff
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#execute(VascBackendState state)
|
* @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state)
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
|
@ -20,15 +20,14 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.forwardfire.vasc.impl;
|
package net.forwardfire.vasc.backend.proxy;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import net.forwardfire.vasc.core.AbstractVascBackendProxy;
|
import net.forwardfire.vasc.backend.VascBackend;
|
||||||
import net.forwardfire.vasc.core.VascBackend;
|
import net.forwardfire.vasc.backend.VascBackendState;
|
||||||
import net.forwardfire.vasc.core.VascBackendState;
|
|
||||||
import net.forwardfire.vasc.core.VascEntry;
|
import net.forwardfire.vasc.core.VascEntry;
|
||||||
import net.forwardfire.vasc.core.VascException;
|
import net.forwardfire.vasc.core.VascException;
|
||||||
|
|
||||||
|
@ -50,7 +49,7 @@ public class VascBackendProxyTimerLogger extends AbstractVascBackendProxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackend#execute(VascBackendState state)
|
* @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Object> execute(VascBackendState state) throws VascException {
|
public List<Object> execute(VascBackendState state) throws VascException {
|
||||||
|
@ -75,7 +74,7 @@ public class VascBackendProxyTimerLogger extends AbstractVascBackendProxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.AbstractVascBackendProxy#doRecordMoveDownById(net.forwardfire.vasc.core.VascBackendState, java.lang.Object)
|
* @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#doRecordMoveDownById(net.forwardfire.vasc.backend.VascBackendState, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public long doRecordMoveDownById(VascBackendState state, Object primaryId) throws VascException {
|
public long doRecordMoveDownById(VascBackendState state, Object primaryId) throws VascException {
|
||||||
|
@ -89,7 +88,7 @@ public class VascBackendProxyTimerLogger extends AbstractVascBackendProxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.AbstractVascBackendProxy#doRecordMoveUpById(net.forwardfire.vasc.core.VascBackendState, java.lang.Object)
|
* @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#doRecordMoveUpById(net.forwardfire.vasc.backend.VascBackendState, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public long doRecordMoveUpById(VascBackendState state, Object primaryId) throws VascException {
|
public long doRecordMoveUpById(VascBackendState state, Object primaryId) throws VascException {
|
||||||
|
@ -103,7 +102,7 @@ public class VascBackendProxyTimerLogger extends AbstractVascBackendProxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.AbstractVascBackendProxy#delete(java.lang.Object)
|
* @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#delete(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void delete(Object object) throws VascException {
|
public void delete(Object object) throws VascException {
|
||||||
|
@ -117,7 +116,7 @@ public class VascBackendProxyTimerLogger extends AbstractVascBackendProxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.AbstractVascBackendProxy#merge(java.lang.Object)
|
* @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#merge(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Object merge(Object object) throws VascException {
|
public Object merge(Object object) throws VascException {
|
||||||
|
@ -131,7 +130,7 @@ public class VascBackendProxyTimerLogger extends AbstractVascBackendProxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.AbstractVascBackendProxy#persist(java.lang.Object)
|
* @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#persist(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void persist(Object object) throws VascException {
|
public void persist(Object object) throws VascException {
|
|
@ -141,8 +141,11 @@ abstract public class AbstractVascEntryFieldType implements VascEntryFieldType {
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascEntryFieldType#setAutoDetectClass(java.lang.Class)
|
* @see net.forwardfire.vasc.core.VascEntryFieldType#setAutoDetectClass(java.lang.Class)
|
||||||
*/
|
*/
|
||||||
public void setAutoDetectClass(Class<?> autoDetectClass) {
|
public void setAutoDetectClass(Class<?> classObject) {
|
||||||
this.autoDetectClass=autoDetectClass;
|
if (classObject==null) {
|
||||||
|
throw new NullPointerException("Can't add null classObject to fieldtype.");
|
||||||
|
}
|
||||||
|
autoDetectClass=classObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -27,6 +27,9 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import net.forwardfire.vasc.backend.VascBackend;
|
||||||
|
import net.forwardfire.vasc.backend.VascBackendState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds all default state values
|
* Holds all default state values
|
||||||
*
|
*
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
|
|
||||||
package net.forwardfire.vasc.core;
|
package net.forwardfire.vasc.core;
|
||||||
|
|
||||||
|
import net.forwardfire.vasc.backend.VascBackendController;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolvs all the resolvers.
|
* Resolvs all the resolvers.
|
||||||
|
|
|
@ -25,10 +25,12 @@ package net.forwardfire.vasc.core;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.forwardfire.vasc.backend.VascBackendFilter;
|
||||||
import net.forwardfire.vasc.core.actions.ColumnVascAction;
|
import net.forwardfire.vasc.core.actions.ColumnVascAction;
|
||||||
import net.forwardfire.vasc.core.actions.GlobalVascAction;
|
import net.forwardfire.vasc.core.actions.GlobalVascAction;
|
||||||
import net.forwardfire.vasc.core.actions.RowVascAction;
|
import net.forwardfire.vasc.core.actions.RowVascAction;
|
||||||
import net.forwardfire.vasc.core.entry.VascEntryFieldEventChannel;
|
import net.forwardfire.vasc.core.entry.VascEntryFieldEventChannel;
|
||||||
|
import net.forwardfire.vasc.frontend.VascFrontendData;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -33,4 +33,6 @@ package net.forwardfire.vasc.core;
|
||||||
public interface VascEntryControllerLocal extends VascEntryController {
|
public interface VascEntryControllerLocal extends VascEntryController {
|
||||||
|
|
||||||
public void addVascEntry(VascEntry entry,VascController vascController) throws VascException;
|
public void addVascEntry(VascEntry entry,VascController vascController) throws VascException;
|
||||||
|
|
||||||
|
public VascEntry getMasterVascEntryById(String id);
|
||||||
}
|
}
|
|
@ -26,6 +26,9 @@ import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import net.forwardfire.vasc.backend.VascBackend;
|
||||||
|
import net.forwardfire.vasc.backend.VascBackendState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds all the data for state.
|
* Holds all the data for state.
|
||||||
* So we can jump forward or back to a state.
|
* So we can jump forward or back to a state.
|
||||||
|
|
|
@ -20,10 +20,12 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.forwardfire.vasc.core;
|
package net.forwardfire.vasc.frontend;
|
||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import net.forwardfire.vasc.core.VascEntry;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -51,7 +53,7 @@ abstract public class AbstractVascFrontend implements VascFrontend {
|
||||||
abstract protected void addUiComponents();
|
abstract protected void addUiComponents();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascFrontend#initEntry(net.forwardfire.vasc.core.VascEntry)
|
* @see net.forwardfire.vasc.frontend.VascFrontend#initEntry(net.forwardfire.vasc.core.VascEntry)
|
||||||
*/
|
*/
|
||||||
public void initEntry(VascEntry entry) throws Exception {
|
public void initEntry(VascEntry entry) throws Exception {
|
||||||
if (entry.getVascFrontendData().getVascFrontend()==null) {
|
if (entry.getVascFrontendData().getVascFrontend()==null) {
|
||||||
|
@ -67,14 +69,14 @@ abstract public class AbstractVascFrontend implements VascFrontend {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascFrontend#getId()
|
* @see net.forwardfire.vasc.frontend.VascFrontend#getId()
|
||||||
*/
|
*/
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascFrontend#setId(java.lang.String)
|
* @see net.forwardfire.vasc.frontend.VascFrontend#setId(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public void setId(String id) {
|
public void setId(String id) {
|
||||||
this.id=id;
|
this.id=id;
|
|
@ -20,8 +20,9 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.forwardfire.vasc.core;
|
package net.forwardfire.vasc.frontend;
|
||||||
|
|
||||||
|
import net.forwardfire.vasc.core.VascEntry;
|
||||||
import net.forwardfire.vasc.core.entry.VascEntryExporter;
|
import net.forwardfire.vasc.core.entry.VascEntryExporter;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
* 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.frontend;
|
||||||
|
|
||||||
|
import net.forwardfire.vasc.core.VascEntryField;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* VascFrontendActions are the most common used actions in frontend implemention.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Jan 22, 2012
|
||||||
|
*/
|
||||||
|
public interface VascFrontendActions {
|
||||||
|
|
||||||
|
public void refreshData();
|
||||||
|
|
||||||
|
public Object createObject();
|
||||||
|
|
||||||
|
public void deleteObject();
|
||||||
|
|
||||||
|
public Object mergeObject();
|
||||||
|
|
||||||
|
public void sortAction(VascEntryField field);
|
||||||
|
|
||||||
|
public void searchAction(String searchString);
|
||||||
|
|
||||||
|
public void pageAction(Integer page);
|
||||||
|
|
||||||
|
public void moveUpAction(Object object);
|
||||||
|
|
||||||
|
public void moveDownAction(Object object);
|
||||||
|
}
|
|
@ -20,14 +20,20 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.forwardfire.vasc.core;
|
package net.forwardfire.vasc.frontend;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.forwardfire.vasc.core.VascController;
|
||||||
|
import net.forwardfire.vasc.core.VascEntry;
|
||||||
|
import net.forwardfire.vasc.core.VascEntryField;
|
||||||
|
import net.forwardfire.vasc.core.VascEntryState;
|
||||||
|
import net.forwardfire.vasc.core.VascException;
|
||||||
import net.forwardfire.vasc.core.entry.VascEntryFieldValidatorService;
|
import net.forwardfire.vasc.core.entry.VascEntryFieldValidatorService;
|
||||||
import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener;
|
import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener;
|
||||||
import net.forwardfire.vasc.core.entry.VascEntryResourceImageResolver;
|
import net.forwardfire.vasc.core.entry.VascEntryResourceImageResolver;
|
||||||
import net.forwardfire.vasc.core.entry.VascEntryResourceResolver;
|
import net.forwardfire.vasc.core.entry.VascEntryResourceResolver;
|
||||||
|
import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener.VascFrontendEventType;
|
||||||
import net.forwardfire.vasc.core.ui.VascUIComponent;
|
import net.forwardfire.vasc.core.ui.VascUIComponent;
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,6 +56,26 @@ public interface VascFrontendData {
|
||||||
*/
|
*/
|
||||||
public void setVascFrontend(VascFrontend vascFrontend);
|
public void setVascFrontend(VascFrontend vascFrontend);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the VascFrontendActions to make frontend actions simple.
|
||||||
|
*/
|
||||||
|
public VascFrontendActions getVascFrontendActions();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param vascFrontendActions the vascFrontendActions to set
|
||||||
|
*/
|
||||||
|
public void setVascFrontendActions(VascFrontendActions vascFrontendActions);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the vascFrontendPager
|
||||||
|
*/
|
||||||
|
public VascFrontendPager getVascFrontendPager();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param vascFrontendPager the vascFrontendPager to set
|
||||||
|
*/
|
||||||
|
public void setVascFrontendPager(VascFrontendPager vascFrontendPager);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the VascFrontendHelper
|
* @return the VascFrontendHelper
|
||||||
*/
|
*/
|
||||||
|
@ -104,4 +130,5 @@ public interface VascFrontendData {
|
||||||
public void initFrontendListeners(VascEntry entry,String frontendType) throws InstantiationException, IllegalAccessException;
|
public void initFrontendListeners(VascEntry entry,String frontendType) throws InstantiationException, IllegalAccessException;
|
||||||
public void addVascEntryFrontendEventListener(VascEntryFrontendEventListener listener);
|
public void addVascEntryFrontendEventListener(VascEntryFrontendEventListener listener);
|
||||||
public List<VascEntryFrontendEventListener> getVascEntryFrontendEventListener(VascEntryFrontendEventListener.VascFrontendEventType type);
|
public List<VascEntryFrontendEventListener> getVascEntryFrontendEventListener(VascEntryFrontendEventListener.VascFrontendEventType type);
|
||||||
|
public void fireVascFrontendEvent(VascEntry entry,VascFrontendEventType type,Object data);
|
||||||
}
|
}
|
|
@ -20,10 +20,12 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.forwardfire.vasc.core;
|
package net.forwardfire.vasc.frontend;
|
||||||
|
|
||||||
import java.util.EventListener;
|
import java.util.EventListener;
|
||||||
|
|
||||||
|
import net.forwardfire.vasc.core.VascEntry;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
|
@ -20,13 +20,16 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.forwardfire.vasc.core;
|
package net.forwardfire.vasc.frontend;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.forwardfire.vasc.core.VascEntry;
|
||||||
|
import net.forwardfire.vasc.core.VascEntryField;
|
||||||
|
import net.forwardfire.vasc.core.VascLinkEntry;
|
||||||
|
import net.forwardfire.vasc.core.VascLinkEntryType;
|
||||||
import net.forwardfire.vasc.core.actions.GlobalVascAction;
|
import net.forwardfire.vasc.core.actions.GlobalVascAction;
|
||||||
import net.forwardfire.vasc.core.actions.RowVascAction;
|
import net.forwardfire.vasc.core.actions.RowVascAction;
|
||||||
import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener.VascFrontendEventType;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper for frontend rederer
|
* Helper for frontend rederer
|
||||||
|
@ -47,20 +50,6 @@ public interface VascFrontendHelper {
|
||||||
public Integer getTotalColumnsWidth(VascEntry entry);
|
public Integer getTotalColumnsWidth(VascEntry entry);
|
||||||
|
|
||||||
public List<VascLinkEntry> getVascLinkEntryByType(VascEntry entry,VascLinkEntryType type);
|
public List<VascLinkEntry> getVascLinkEntryByType(VascEntry entry,VascLinkEntryType type);
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the total amount of pages
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public List<VascBackendPageNumber> getVascBackendPageNumbers(VascEntry entry);
|
|
||||||
|
|
||||||
public void refreshData(VascEntry entry);
|
|
||||||
|
|
||||||
public Object createObject(VascEntry entry);
|
|
||||||
|
|
||||||
public void deleteObject(VascEntry entry);
|
|
||||||
|
|
||||||
public Object mergeObject(VascEntry entry);
|
|
||||||
|
|
||||||
public List<String> validateObjectField(VascEntryField field);
|
public List<String> validateObjectField(VascEntryField field);
|
||||||
|
|
||||||
|
@ -71,16 +60,11 @@ public interface VascFrontendHelper {
|
||||||
public void editReadOnlyUIComponents(VascEntry entry);
|
public void editReadOnlyUIComponents(VascEntry entry);
|
||||||
|
|
||||||
public void handleException(VascEntry entry,Exception exception);
|
public void handleException(VascEntry entry,Exception exception);
|
||||||
|
|
||||||
public void fireVascEvent(VascEntry entry,VascFrontendEventType type,Object data);
|
|
||||||
|
|
||||||
public void sortAction(VascEntry entry,VascEntryField field);
|
|
||||||
|
|
||||||
public void searchAction(VascEntry entry,String searchString);
|
|
||||||
|
|
||||||
public void pageAction(VascEntry entry,Integer page);
|
|
||||||
|
|
||||||
public void moveAction(VascEntry entry,Object object,boolean moveUp);
|
|
||||||
|
|
||||||
public List<RowVascAction> getMultiRowActions(VascEntry entry);
|
public List<RowVascAction> getMultiRowActions(VascEntry entry);
|
||||||
|
|
||||||
|
public String getSelectedDisplayName(VascEntry entry);
|
||||||
|
public String getParentSelectedDisplayName(VascEntry entry);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,55 @@
|
||||||
|
/*
|
||||||
|
* 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.frontend;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.forwardfire.vasc.backend.VascBackendPageNumber;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* VascFrontendPager has some info about the pageing data models
|
||||||
|
*
|
||||||
|
* note all the get properties for different el parsers.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Jan 22, 2012
|
||||||
|
*/
|
||||||
|
public interface VascFrontendPager {
|
||||||
|
|
||||||
|
public long getPageStartCount();
|
||||||
|
public long getPageStopCount();
|
||||||
|
public long getPageSize();
|
||||||
|
public long getPageTotalRecordCount();
|
||||||
|
|
||||||
|
public boolean getHasPageNextAction();
|
||||||
|
public boolean getHasPagePreviousAction();
|
||||||
|
public boolean getHasOnlySinglePage();
|
||||||
|
public boolean getHasExtendedPageMode();
|
||||||
|
public boolean getHasExtendedPageModeCenter();
|
||||||
|
|
||||||
|
public List<VascBackendPageNumber> getTablePagesFromBackend();
|
||||||
|
public List<VascBackendPageNumber> getTablePagesNormal();
|
||||||
|
public List<VascBackendPageNumber> getTablePagesExtendedBegin();
|
||||||
|
public List<VascBackendPageNumber> getTablePagesExtendedCenter();
|
||||||
|
public List<VascBackendPageNumber> getTablePagesExtendedEnd();
|
||||||
|
}
|
|
@ -25,7 +25,7 @@ package net.forwardfire.vasc.impl;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
import net.forwardfire.vasc.core.VascBackend;
|
import net.forwardfire.vasc.backend.VascBackend;
|
||||||
import net.forwardfire.vasc.core.VascController;
|
import net.forwardfire.vasc.core.VascController;
|
||||||
import net.forwardfire.vasc.core.VascEntry;
|
import net.forwardfire.vasc.core.VascEntry;
|
||||||
import net.forwardfire.vasc.core.VascEntryField;
|
import net.forwardfire.vasc.core.VascEntryField;
|
||||||
|
@ -244,12 +244,10 @@ public class DefaultVascBackedEntryFinalizer implements VascEntryFinalizer {
|
||||||
if (defValue != null) {
|
if (defValue != null) {
|
||||||
for (String typeId: vascController.getVascEntryFieldTypeController().getVascEntryFieldTypeIds()) {
|
for (String typeId: vascController.getVascEntryFieldTypeController().getVascEntryFieldTypeIds()) {
|
||||||
VascEntryFieldType type = vascController.getVascEntryFieldTypeController().getVascEntryFieldTypeById(typeId);
|
VascEntryFieldType type = vascController.getVascEntryFieldTypeController().getVascEntryFieldTypeById(typeId);
|
||||||
|
Class<?> autoClass = type.getAutoDetectClass();
|
||||||
if (type.getAutoDetectClass()!=null) {
|
if (autoClass!=null && autoClass.isAssignableFrom(defValue.getClass())) {
|
||||||
if (type.getAutoDetectClass().isAssignableFrom(defValue.getClass())) {
|
vef.setVascEntryFieldType(type);
|
||||||
vef.setVascEntryFieldType(type);
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,8 +25,8 @@ package net.forwardfire.vasc.impl;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import net.forwardfire.vasc.core.VascBackend;
|
import net.forwardfire.vasc.backend.VascBackend;
|
||||||
import net.forwardfire.vasc.core.VascBackendControllerLocal;
|
import net.forwardfire.vasc.backend.VascBackendControllerLocal;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,7 +44,7 @@ public class DefaultVascBackendController implements VascBackendControllerLocal
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackendController#getVascBackendById(java.lang.String)
|
* @see net.forwardfire.vasc.backend.VascBackendController#getVascBackendById(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public VascBackend getVascBackendById(String id) {
|
public VascBackend getVascBackendById(String id) {
|
||||||
return backends.get(id);
|
return backends.get(id);
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
package net.forwardfire.vasc.impl;
|
package net.forwardfire.vasc.impl;
|
||||||
|
|
||||||
import net.forwardfire.vasc.core.AbstractVascBackendState;
|
import net.forwardfire.vasc.backend.AbstractVascBackendState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the state for the backend
|
* Holds the state for the backend
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
package net.forwardfire.vasc.impl;
|
package net.forwardfire.vasc.impl;
|
||||||
|
|
||||||
import net.forwardfire.vasc.core.VascBackendController;
|
import net.forwardfire.vasc.backend.VascBackendController;
|
||||||
import net.forwardfire.vasc.core.VascController;
|
import net.forwardfire.vasc.core.VascController;
|
||||||
import net.forwardfire.vasc.core.VascEntryController;
|
import net.forwardfire.vasc.core.VascEntryController;
|
||||||
import net.forwardfire.vasc.core.VascEntryFieldTypeController;
|
import net.forwardfire.vasc.core.VascEntryFieldTypeController;
|
||||||
|
|
|
@ -27,17 +27,17 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import net.forwardfire.vasc.core.VascBackendFilter;
|
import net.forwardfire.vasc.backend.VascBackendFilter;
|
||||||
import net.forwardfire.vasc.core.VascEntry;
|
import net.forwardfire.vasc.core.VascEntry;
|
||||||
import net.forwardfire.vasc.core.VascEntryField;
|
import net.forwardfire.vasc.core.VascEntryField;
|
||||||
import net.forwardfire.vasc.core.VascEntryFieldSet;
|
import net.forwardfire.vasc.core.VascEntryFieldSet;
|
||||||
import net.forwardfire.vasc.core.VascFrontendData;
|
|
||||||
import net.forwardfire.vasc.core.VascLinkEntry;
|
import net.forwardfire.vasc.core.VascLinkEntry;
|
||||||
import net.forwardfire.vasc.core.actions.ColumnVascAction;
|
import net.forwardfire.vasc.core.actions.ColumnVascAction;
|
||||||
import net.forwardfire.vasc.core.actions.GlobalVascAction;
|
import net.forwardfire.vasc.core.actions.GlobalVascAction;
|
||||||
import net.forwardfire.vasc.core.actions.RowVascAction;
|
import net.forwardfire.vasc.core.actions.RowVascAction;
|
||||||
import net.forwardfire.vasc.core.actions.VascAction;
|
import net.forwardfire.vasc.core.actions.VascAction;
|
||||||
import net.forwardfire.vasc.core.entry.VascEntryFieldEventChannel;
|
import net.forwardfire.vasc.core.entry.VascEntryFieldEventChannel;
|
||||||
|
import net.forwardfire.vasc.frontend.VascFrontendData;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class DefaultVascEntryController implements VascEntryControllerLocal {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public VascEntry getRealVascEntryById(String id) {
|
public VascEntry getMasterVascEntryById(String id) {
|
||||||
VascEntry entry = entries.get(id);
|
VascEntry entry = entries.get(id);
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,18 +25,30 @@ package net.forwardfire.vasc.impl;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
import net.forwardfire.vasc.core.VascBackend;
|
import net.forwardfire.vasc.backend.VascBackend;
|
||||||
import net.forwardfire.vasc.core.VascBackendFilter;
|
import net.forwardfire.vasc.backend.VascBackendFilter;
|
||||||
|
import net.forwardfire.vasc.backend.proxy.VascBackendProxyCache;
|
||||||
|
import net.forwardfire.vasc.backend.proxy.VascBackendProxyEventExecutor;
|
||||||
|
import net.forwardfire.vasc.backend.proxy.VascBackendProxyFilter;
|
||||||
|
import net.forwardfire.vasc.backend.proxy.VascBackendProxyPaged;
|
||||||
|
import net.forwardfire.vasc.backend.proxy.VascBackendProxySearch;
|
||||||
|
import net.forwardfire.vasc.backend.proxy.VascBackendProxySort;
|
||||||
|
import net.forwardfire.vasc.backend.proxy.VascBackendProxyTimerLogger;
|
||||||
import net.forwardfire.vasc.core.VascController;
|
import net.forwardfire.vasc.core.VascController;
|
||||||
import net.forwardfire.vasc.core.VascEntry;
|
import net.forwardfire.vasc.core.VascEntry;
|
||||||
|
import net.forwardfire.vasc.core.VascEntryControllerLocal;
|
||||||
import net.forwardfire.vasc.core.VascException;
|
import net.forwardfire.vasc.core.VascException;
|
||||||
import net.forwardfire.vasc.core.VascFrontendData;
|
import net.forwardfire.vasc.frontend.VascFrontendData;
|
||||||
|
import net.forwardfire.vasc.impl.actions.AddRowAction;
|
||||||
|
import net.forwardfire.vasc.impl.actions.CSVExportGlobalAction;
|
||||||
|
import net.forwardfire.vasc.impl.actions.DeleteRowAction;
|
||||||
|
import net.forwardfire.vasc.impl.actions.EditRowAction;
|
||||||
|
import net.forwardfire.vasc.impl.actions.RefreshDataGlobalAction;
|
||||||
|
import net.forwardfire.vasc.impl.actions.XMLExportGlobalAction;
|
||||||
import net.forwardfire.vasc.impl.entry.DefaultVascEntryResourceResolver;
|
import net.forwardfire.vasc.impl.entry.DefaultVascEntryResourceResolver;
|
||||||
import net.forwardfire.vasc.impl.entry.VascValidatorsValidatorService;
|
import net.forwardfire.vasc.impl.entry.VascValidatorsValidatorService;
|
||||||
import net.forwardfire.vasc.impl.type.DefaultVascEntryFieldTypeController;
|
import net.forwardfire.vasc.impl.type.DefaultVascEntryFieldTypeController;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default Vasc Factory for creating some base object plumming for vasc useage.
|
* Default Vasc Factory for creating some base object plumming for vasc useage.
|
||||||
*
|
*
|
||||||
|
@ -72,15 +84,19 @@ public class DefaultVascFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
static public VascFrontendData getDefaultVascFrontendData(ResourceBundle resourceBundle) {
|
static public VascFrontendData getDefaultVascFrontendData(ResourceBundle resourceBundle) {
|
||||||
DefaultVascFrontendData vascFrontendData = new DefaultVascFrontendData(); // controller is set by vasc
|
// Create default frontend data obj where controller is set by vasc
|
||||||
vascFrontendData.setVascEntryResourceResolver(new DefaultVascEntryResourceResolver(resourceBundle));
|
DefaultVascFrontendData vascFrontendData = new DefaultVascFrontendData(); //
|
||||||
vascFrontendData.setVascFrontendHelper(new DefaultVascFrontendHelper());
|
|
||||||
//vascFrontendData.setVascEntryResourceImageResolver(new ImageResources());
|
|
||||||
vascFrontendData.setVascEntryState(new DefaultVascEntryState());
|
vascFrontendData.setVascEntryState(new DefaultVascEntryState());
|
||||||
vascFrontendData.getVascEntryState().setVascBackendState(new DefaultVascBackendState());
|
vascFrontendData.getVascEntryState().setVascBackendState(new DefaultVascBackendState());
|
||||||
vascFrontendData.getVascEntryState().getVascBackendState().setPageSize(100); // default page size is zero aka disabled
|
vascFrontendData.getVascEntryState().getVascBackendState().setPageSize(100); // default page size is zero aka disabled
|
||||||
vascFrontendData.getVascEntryState().getVascBackendState().setPageSizeMax(1000); // max 1k records on screen.
|
vascFrontendData.getVascEntryState().getVascBackendState().setPageSizeMax(1000); // max 1k records on screen.
|
||||||
vascFrontendData.addVascValidatorService(new VascValidatorsValidatorService()); // normal vasc validators
|
|
||||||
|
// init resource resultsers
|
||||||
|
vascFrontendData.setVascEntryResourceResolver(new DefaultVascEntryResourceResolver(resourceBundle));
|
||||||
|
vascFrontendData.setVascFrontendHelper(new DefaultVascFrontendHelper());
|
||||||
|
//vascFrontendData.setVascEntryResourceImageResolver(new ImageResources());
|
||||||
|
|
||||||
|
vascFrontendData.addVascValidatorService(new VascValidatorsValidatorService());
|
||||||
return vascFrontendData;
|
return vascFrontendData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,6 +112,9 @@ public class DefaultVascFactory {
|
||||||
// logs all actions log logger
|
// logs all actions log logger
|
||||||
backend = new VascBackendProxyTimerLogger(backend,entry);
|
backend = new VascBackendProxyTimerLogger(backend,entry);
|
||||||
|
|
||||||
|
// Fire event listeners before caching.
|
||||||
|
backend = new VascBackendProxyEventExecutor(backend,entry);
|
||||||
|
|
||||||
// only cached one result, checks for paramater differnce
|
// only cached one result, checks for paramater differnce
|
||||||
backend = new VascBackendProxyCache(backend,entry);
|
backend = new VascBackendProxyCache(backend,entry);
|
||||||
|
|
||||||
|
@ -116,4 +135,80 @@ public class DefaultVascFactory {
|
||||||
// return the configed backend.
|
// return the configed backend.
|
||||||
return backend;
|
return backend;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static public void fillVascControllerLocalEntries(VascEntryControllerLocal c,VascController con) throws VascException {
|
||||||
|
for (String id:c.getVascEntryIds()) {
|
||||||
|
VascEntry entry = c.getMasterVascEntryById(id);
|
||||||
|
if (entry.isVascDisplayOnly()==false) {
|
||||||
|
if (entry.isVascAdminCreate()) {
|
||||||
|
entry.addRowAction(new AddRowAction());
|
||||||
|
}
|
||||||
|
if (entry.isVascAdminEdit()) {
|
||||||
|
entry.addRowAction(new EditRowAction());
|
||||||
|
}
|
||||||
|
if (entry.isVascAdminDelete()) {
|
||||||
|
entry.addRowAction(new DeleteRowAction());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
entry.addGlobalAction(new XMLExportGlobalAction());
|
||||||
|
entry.addGlobalAction(new CSVExportGlobalAction());
|
||||||
|
entry.addGlobalAction(new RefreshDataGlobalAction());
|
||||||
|
|
||||||
|
/*
|
||||||
|
DefaultVascEntryResourceResolver t = new DefaultVascEntryResourceResolver(resourceBundle);
|
||||||
|
if (t.getTextValue(entry.getEditDescription()).equals(entry.getEditDescription())) {
|
||||||
|
entry.setEditDescription("generic.editDescription");
|
||||||
|
}
|
||||||
|
if (t.getTextValue(entry.getDeleteDescription()).equals(entry.getDeleteDescription())) {
|
||||||
|
entry.setDeleteDescription("generic.deleteDescription");
|
||||||
|
}
|
||||||
|
if (t.getTextValue(entry.getCreateDescription()).equals(entry.getCreateDescription())) {
|
||||||
|
entry.setCreateDescription("generic.createDescription");
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
for (String key:entry.getEntryParameterKeys()) {
|
||||||
|
Object value = entry.getEntryParameter(key);
|
||||||
|
if (value instanceof String==false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String paraValue = (String)value;
|
||||||
|
if (paraValue.startsWith("userPara")==false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String[] ps = paraValue.split(":");
|
||||||
|
String type = ps[1];
|
||||||
|
String paraTypeValue = ps[2];
|
||||||
|
|
||||||
|
SetParameterBackendListener listener = new SetParameterBackendListener(vui.userId,vui.username);
|
||||||
|
listener.setName(key);
|
||||||
|
listener.setType(type);
|
||||||
|
listener.setValue(paraTypeValue);
|
||||||
|
|
||||||
|
entry.getVa
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
// hackje om deze manuale actions van i18n keys te voorzien;
|
||||||
|
// this is temp untill x4o templaing
|
||||||
|
DefaultVascBackedEntryFinalizer f = new DefaultVascBackedEntryFinalizer();
|
||||||
|
f.finalizeVascEntry(entry, con);
|
||||||
|
|
||||||
|
// execute backend event listeners NOTE: moved to default factory fillings
|
||||||
|
// VascBackend vb = c.getVascBackendController().getVascBackendById(entry.getBackendId());
|
||||||
|
// vb = new VascBackendProxyEventExecutor(vb,entry);
|
||||||
|
// ((VascBackendControllerLocal)c.getVascBackendController()).addVascBackend(vb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static public void fillVascEntryFrontend(VascEntry entry,VascController vascController,VascFrontendData frontendData) {
|
||||||
|
frontendData.setVascController(vascController);
|
||||||
|
entry.setVascFrontendData(frontendData);
|
||||||
|
VascBackend backend = DefaultVascFactory.getProxyVascBackend(entry);
|
||||||
|
frontendData.getVascEntryState().setVascBackend(backend);
|
||||||
|
frontendData.getVascEntryState().setVascEntry(entry);
|
||||||
|
frontendData.setVascFrontendPager(new DefaultVascFrontendPager(entry));
|
||||||
|
frontendData.setVascFrontendActions(new DefaultVascFrontendActions(entry));
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,290 @@
|
||||||
|
/*
|
||||||
|
* 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.impl;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import net.forwardfire.vasc.backend.VascBackendFilter;
|
||||||
|
import net.forwardfire.vasc.core.VascEntry;
|
||||||
|
import net.forwardfire.vasc.core.VascEntryField;
|
||||||
|
import net.forwardfire.vasc.core.VascException;
|
||||||
|
import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener;
|
||||||
|
import net.forwardfire.vasc.frontend.VascFrontendActions;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default impl of default frontend actions
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Jan 22, 2012
|
||||||
|
*/
|
||||||
|
public class DefaultVascFrontendActions implements VascFrontendActions {
|
||||||
|
|
||||||
|
private Logger logger = Logger.getLogger(DefaultVascFrontendActions.class.getName());
|
||||||
|
private VascEntry entry = null;
|
||||||
|
|
||||||
|
public DefaultVascFrontendActions(VascEntry entry) {
|
||||||
|
this.entry=entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see net.forwardfire.vasc.frontend.VascFrontendHelper#initEditObject(net.forwardfire.vasc.core.VascEntry)
|
||||||
|
*/
|
||||||
|
public Object createObject() {
|
||||||
|
try {
|
||||||
|
entry.getVascFrontendData().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.PRE_CREATE, null);
|
||||||
|
Object object = entry.getVascFrontendData().getVascEntryState().getVascBackend().provideVascEntryRecordCreator(entry.clone()).newRecord(entry);
|
||||||
|
if (object==null) {
|
||||||
|
throw new IllegalStateException("Can't work with null object for backend storage.");
|
||||||
|
}
|
||||||
|
for (VascEntryField field:entry.getVascEntryFields()) {
|
||||||
|
if (field.getDefaultValue()==null) {
|
||||||
|
continue; // no default value to set.
|
||||||
|
}
|
||||||
|
Object value = field.getVascEntryFieldValue().getValue(field, object);
|
||||||
|
if (value!=null) {
|
||||||
|
continue; // value is already set by backend creator.
|
||||||
|
}
|
||||||
|
Object defaultValue = field.getDefaultValue();
|
||||||
|
if (defaultValue instanceof String) {
|
||||||
|
String def = (String)defaultValue;
|
||||||
|
if (def.equals("now()")) { // TODO: add default string parsers
|
||||||
|
defaultValue = new Date();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
logger.finer("Setting default value for: "+field.getName()+" def: "+defaultValue);
|
||||||
|
field.getVascEntryFieldValue().setValue(field, object, defaultValue);
|
||||||
|
}
|
||||||
|
entry.getVascFrontendData().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.POST_CREATE, object);
|
||||||
|
return object;
|
||||||
|
} catch (Exception e) {
|
||||||
|
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry,e);
|
||||||
|
return null; /// ?? ,,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int removeObjectFromDataList(Object object) {
|
||||||
|
int indexOld = entry.getVascFrontendData().getVascEntryState().getEntryDataList().indexOf(object);
|
||||||
|
if (entry.getVascFrontendData().getVascEntryState().getEntryDataList().remove(object)) {
|
||||||
|
return indexOld; // java worked well for use
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove only work on (jpa)beans with an overrided equals method.
|
||||||
|
// we lets do the search ourselfs here because we should know the primary key value
|
||||||
|
try {
|
||||||
|
VascEntryField field = entry.getVascEntryFieldById(entry.getPrimaryKeyFieldId());
|
||||||
|
Object idObject = field.getVascEntryFieldValue().getValue(field, object);
|
||||||
|
|
||||||
|
// is only null when creating objects
|
||||||
|
if (idObject!=null) {
|
||||||
|
int index = 0;
|
||||||
|
for (Object o:entry.getVascFrontendData().getVascEntryState().getEntryDataList()) {
|
||||||
|
field = entry.getVascEntryFieldById(entry.getPrimaryKeyFieldId());
|
||||||
|
Object id = field.getVascEntryFieldValue().getValue(field, o);
|
||||||
|
if (idObject.equals(id)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
if (index<entry.getVascFrontendData().getVascEntryState().getEntryDataList().size()) {
|
||||||
|
entry.getVascFrontendData().getVascEntryState().getEntryDataList().remove(index);
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (VascException e) {
|
||||||
|
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry,e);
|
||||||
|
}
|
||||||
|
return 0; // make better (0=top of list)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see net.forwardfire.vasc.frontend.VascFrontendHelper#mergeObject(net.forwardfire.vasc.core.VascEntry)
|
||||||
|
*/
|
||||||
|
public Object mergeObject() {
|
||||||
|
Object object = entry.getVascFrontendData().getVascEntryState().getEntryDataObject();
|
||||||
|
Object result = null;
|
||||||
|
try {
|
||||||
|
entry.getVascFrontendData().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.PRE_UPDATE,object);
|
||||||
|
int index = removeObjectFromDataList(object);
|
||||||
|
|
||||||
|
// merge object on backend
|
||||||
|
result = entry.getVascFrontendData().getVascEntryState().getVascBackend().merge(object);
|
||||||
|
|
||||||
|
// put object thrue the filters
|
||||||
|
for (VascBackendFilter filter:entry.getVascBackendFilters()) {
|
||||||
|
result = filter.filterObject(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
// put object back in list
|
||||||
|
entry.getVascFrontendData().getVascEntryState().getEntryDataList().add(index, result);
|
||||||
|
entry.getVascFrontendData().getVascEntryState().setEntryDataObject(null);
|
||||||
|
entry.getVascFrontendData().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.POST_UPDATE,result);
|
||||||
|
} catch (Exception e) {
|
||||||
|
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry,e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes the selected row object from the list and fires event.
|
||||||
|
* @param entry
|
||||||
|
* @param object
|
||||||
|
*/
|
||||||
|
public void deleteObject() {
|
||||||
|
Object object = entry.getVascFrontendData().getVascEntryState().getEntryDataObject();
|
||||||
|
entry.getVascFrontendData().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.PRE_DELETE, object);
|
||||||
|
try {
|
||||||
|
entry.getVascFrontendData().getVascEntryState().getVascBackend().delete(object);
|
||||||
|
} catch (Exception e) {
|
||||||
|
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry,e);
|
||||||
|
}
|
||||||
|
removeObjectFromDataList(object);
|
||||||
|
entry.getVascFrontendData().getVascEntryState().setEntryDataObject(null);
|
||||||
|
entry.getVascFrontendData().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.POST_DELETE, object);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see net.forwardfire.vasc.frontend.VascFrontendHelper#refreshData(net.forwardfire.vasc.core.VascEntry)
|
||||||
|
*/
|
||||||
|
public void refreshData() {
|
||||||
|
entry.getVascFrontendData().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.PRE_READ, null);
|
||||||
|
entry.getVascFrontendData().getVascEntryState().setEntryDataObject(null);
|
||||||
|
try {
|
||||||
|
// check and correct max page size
|
||||||
|
if (entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageSize()>entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageSizeMax()) {
|
||||||
|
entry.getVascFrontendData().getVascEntryState().getVascBackendState().setPageSize(entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageSizeMax());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String key:entry.getEntryParameterKeys()) {
|
||||||
|
Object value = entry.getEntryParameter(key);
|
||||||
|
entry.getVascFrontendData().getVascEntryState().getVascBackendState().setDataParameter(key, value);
|
||||||
|
}
|
||||||
|
entry.getVascFrontendData().getVascEntryState().setEntryDataList(entry.getVascFrontendData().getVascEntryState().getVascBackend().execute(entry.getVascFrontendData().getVascEntryState().getVascBackendState()));
|
||||||
|
|
||||||
|
// also update total every time
|
||||||
|
Long total = entry.getVascFrontendData().getVascEntryState().getVascBackend().fetchTotalExecuteSize(entry.getVascFrontendData().getVascEntryState().getVascBackendState());
|
||||||
|
entry.getVascFrontendData().getVascEntryState().setTotalBackendRecords(total);
|
||||||
|
} catch (Exception e) {
|
||||||
|
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
|
||||||
|
}
|
||||||
|
entry.getVascFrontendData().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.POST_READ, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void sortAction(VascEntryField field) {
|
||||||
|
String curSort = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getSortField();
|
||||||
|
if (field.getBackendName().equals(curSort)) {
|
||||||
|
entry.getVascFrontendData().getVascEntryState().getVascBackendState().setSortAscending(!entry.getVascFrontendData().getVascEntryState().getVascBackendState().isSortAscending());
|
||||||
|
}
|
||||||
|
String sortID = field.getBackendName();
|
||||||
|
entry.getVascFrontendData().getVascEntryState().getVascBackendState().setSortField(sortID);
|
||||||
|
entry.getVascFrontendData().getVascEntryState().getVascBackendState().setPageIndex(0);
|
||||||
|
entry.getVascFrontendData().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.SORT, field);
|
||||||
|
|
||||||
|
refreshData();
|
||||||
|
try {
|
||||||
|
entry.getVascFrontendData().getVascFrontend().renderView();
|
||||||
|
} catch (Exception e) {
|
||||||
|
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void searchAction(String searchString) {
|
||||||
|
entry.getVascFrontendData().getVascEntryState().getVascBackendState().setSearchString(searchString);
|
||||||
|
entry.getVascFrontendData().getVascEntryState().getVascBackendState().setSortField(null);
|
||||||
|
entry.getVascFrontendData().getVascEntryState().getVascBackendState().setPageIndex(0);
|
||||||
|
entry.getVascFrontendData().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.SEARCH, searchString);
|
||||||
|
|
||||||
|
refreshData();
|
||||||
|
|
||||||
|
try {
|
||||||
|
entry.getVascFrontendData().getVascFrontend().renderView();
|
||||||
|
} catch (Exception e) {
|
||||||
|
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void pageAction(Integer pageIndex) {
|
||||||
|
if (pageIndex<1) {
|
||||||
|
pageIndex = 0;
|
||||||
|
}
|
||||||
|
Long total = entry.getVascFrontendData().getVascEntryState().getTotalBackendRecords(); // note: total is only null when pageAction is done before first refresh, which should never happen anyway.
|
||||||
|
if (total!=null && pageIndex>(total/entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageSize())) {
|
||||||
|
pageIndex = new Long(total/entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageSize()).intValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
entry.getVascFrontendData().getVascEntryState().getVascBackendState().setPageIndex(pageIndex);
|
||||||
|
entry.getVascFrontendData().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.PAGE, pageIndex);
|
||||||
|
|
||||||
|
// lets load data;
|
||||||
|
refreshData();
|
||||||
|
|
||||||
|
try {
|
||||||
|
entry.getVascFrontendData().getVascFrontend().renderView();
|
||||||
|
} catch (Exception e) {
|
||||||
|
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void moveUpAction(Object record) {
|
||||||
|
if (entry.getVascFrontendData().getVascEntryState().getVascBackend().isRecordMoveable()) {
|
||||||
|
try {
|
||||||
|
VascEntryField p = entry.getVascEntryFieldById(entry.getPrimaryKeyFieldId());
|
||||||
|
Object primaryId = p.getVascEntryFieldValue().getValue(p, record);
|
||||||
|
entry.getVascFrontendData().getVascEntryState().getVascBackend().doRecordMoveUpById(entry.getVascFrontendData().getVascEntryState().getVascBackendState(),primaryId);
|
||||||
|
} catch (Exception e) {
|
||||||
|
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
// lets load data;
|
||||||
|
refreshData();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
entry.getVascFrontendData().getVascFrontend().renderView();
|
||||||
|
} catch (Exception e) {
|
||||||
|
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void moveDownAction(Object record) {
|
||||||
|
if (entry.getVascFrontendData().getVascEntryState().getVascBackend().isRecordMoveable()) {
|
||||||
|
try {
|
||||||
|
VascEntryField p = entry.getVascEntryFieldById(entry.getPrimaryKeyFieldId());
|
||||||
|
Object primaryId = p.getVascEntryFieldValue().getValue(p, record);
|
||||||
|
entry.getVascFrontendData().getVascEntryState().getVascBackend().doRecordMoveDownById(entry.getVascFrontendData().getVascEntryState().getVascBackendState(),primaryId);
|
||||||
|
} catch (Exception e) {
|
||||||
|
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
|
||||||
|
}
|
||||||
|
// lets load data;
|
||||||
|
refreshData();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
entry.getVascFrontendData().getVascFrontend().renderView();
|
||||||
|
} catch (Exception e) {
|
||||||
|
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -33,9 +33,6 @@ import net.forwardfire.vasc.core.VascEntryField;
|
||||||
import net.forwardfire.vasc.core.VascEntryFinalizer;
|
import net.forwardfire.vasc.core.VascEntryFinalizer;
|
||||||
import net.forwardfire.vasc.core.VascEntryState;
|
import net.forwardfire.vasc.core.VascEntryState;
|
||||||
import net.forwardfire.vasc.core.VascException;
|
import net.forwardfire.vasc.core.VascException;
|
||||||
import net.forwardfire.vasc.core.VascFrontend;
|
|
||||||
import net.forwardfire.vasc.core.VascFrontendData;
|
|
||||||
import net.forwardfire.vasc.core.VascFrontendHelper;
|
|
||||||
import net.forwardfire.vasc.core.actions.ColumnVascAction;
|
import net.forwardfire.vasc.core.actions.ColumnVascAction;
|
||||||
import net.forwardfire.vasc.core.actions.GlobalVascAction;
|
import net.forwardfire.vasc.core.actions.GlobalVascAction;
|
||||||
import net.forwardfire.vasc.core.actions.RowVascAction;
|
import net.forwardfire.vasc.core.actions.RowVascAction;
|
||||||
|
@ -44,7 +41,13 @@ import net.forwardfire.vasc.core.entry.VascEntryFieldValidatorService;
|
||||||
import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener;
|
import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener;
|
||||||
import net.forwardfire.vasc.core.entry.VascEntryResourceImageResolver;
|
import net.forwardfire.vasc.core.entry.VascEntryResourceImageResolver;
|
||||||
import net.forwardfire.vasc.core.entry.VascEntryResourceResolver;
|
import net.forwardfire.vasc.core.entry.VascEntryResourceResolver;
|
||||||
|
import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener.VascFrontendEventType;
|
||||||
import net.forwardfire.vasc.core.ui.VascUIComponent;
|
import net.forwardfire.vasc.core.ui.VascUIComponent;
|
||||||
|
import net.forwardfire.vasc.frontend.VascFrontend;
|
||||||
|
import net.forwardfire.vasc.frontend.VascFrontendActions;
|
||||||
|
import net.forwardfire.vasc.frontend.VascFrontendData;
|
||||||
|
import net.forwardfire.vasc.frontend.VascFrontendHelper;
|
||||||
|
import net.forwardfire.vasc.frontend.VascFrontendPager;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,6 +60,8 @@ import net.forwardfire.vasc.core.ui.VascUIComponent;
|
||||||
public class DefaultVascFrontendData implements VascFrontendData {
|
public class DefaultVascFrontendData implements VascFrontendData {
|
||||||
|
|
||||||
private VascFrontend vascFrontend = null;
|
private VascFrontend vascFrontend = null;
|
||||||
|
private VascFrontendActions vascFrontendActions = null;
|
||||||
|
private VascFrontendPager vascFrontendPager = null;
|
||||||
private VascEntryFinalizer vascEntryFinalizer = null;
|
private VascEntryFinalizer vascEntryFinalizer = null;
|
||||||
private VascFrontendHelper vascFrontendHelper = null;
|
private VascFrontendHelper vascFrontendHelper = null;
|
||||||
private VascEntryResourceResolver vascEntryResourceResolver = null;
|
private VascEntryResourceResolver vascEntryResourceResolver = null;
|
||||||
|
@ -92,7 +97,35 @@ public class DefaultVascFrontendData implements VascFrontendData {
|
||||||
public void setVascFrontend(VascFrontend vascFrontend) {
|
public void setVascFrontend(VascFrontend vascFrontend) {
|
||||||
this.vascFrontend = vascFrontend;
|
this.vascFrontend = vascFrontend;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the vascFrontendActions
|
||||||
|
*/
|
||||||
|
public VascFrontendActions getVascFrontendActions() {
|
||||||
|
return vascFrontendActions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param vascFrontendActions the vascFrontendActions to set
|
||||||
|
*/
|
||||||
|
public void setVascFrontendActions(VascFrontendActions vascFrontendActions) {
|
||||||
|
this.vascFrontendActions = vascFrontendActions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the vascFrontendPager
|
||||||
|
*/
|
||||||
|
public VascFrontendPager getVascFrontendPager() {
|
||||||
|
return vascFrontendPager;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param vascFrontendPager the vascFrontendPager to set
|
||||||
|
*/
|
||||||
|
public void setVascFrontendPager(VascFrontendPager vascFrontendPager) {
|
||||||
|
this.vascFrontendPager = vascFrontendPager;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascBackendData#getVascEntryFinalizer()
|
* @see net.forwardfire.vasc.core.VascBackendData#getVascEntryFinalizer()
|
||||||
*/
|
*/
|
||||||
|
@ -159,14 +192,14 @@ public class DefaultVascFrontendData implements VascFrontendData {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascFrontendData#getVascUIComponent(java.lang.String)
|
* @see net.forwardfire.vasc.frontend.VascFrontendData#getVascUIComponent(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public String getVascUIComponentClass(String rendererId) {
|
public String getVascUIComponentClass(String rendererId) {
|
||||||
return uiComponents.get(rendererId);
|
return uiComponents.get(rendererId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascFrontendData#putVascUIComponent(java.lang.String, java.lang.String)
|
* @see net.forwardfire.vasc.frontend.VascFrontendData#putVascUIComponent(java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
public void putVascUIComponent(String rendererId, String uiComponentClass) {
|
public void putVascUIComponent(String rendererId, String uiComponentClass) {
|
||||||
uiComponents.put(rendererId, uiComponentClass);
|
uiComponents.put(rendererId, uiComponentClass);
|
||||||
|
@ -187,7 +220,7 @@ public class DefaultVascFrontendData implements VascFrontendData {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascFrontendData#addFieldVascUIComponents(net.forwardfire.vasc.core.VascEntryField, net.forwardfire.vasc.core.ui.VascUIComponent, java.lang.Object)
|
* @see net.forwardfire.vasc.frontend.VascFrontendData#addFieldVascUIComponents(net.forwardfire.vasc.core.VascEntryField, net.forwardfire.vasc.core.ui.VascUIComponent, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void addFieldVascUIComponents(VascEntryField field,VascUIComponent uiComponent, Object editor) {
|
public void addFieldVascUIComponents(VascEntryField field,VascUIComponent uiComponent, Object editor) {
|
||||||
fieldComps.put(field, uiComponent);
|
fieldComps.put(field, uiComponent);
|
||||||
|
@ -200,14 +233,14 @@ public class DefaultVascFrontendData implements VascFrontendData {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascFrontendData#getFieldRealRenderer(net.forwardfire.vasc.core.VascEntryField)
|
* @see net.forwardfire.vasc.frontend.VascFrontendData#getFieldRealRenderer(net.forwardfire.vasc.core.VascEntryField)
|
||||||
*/
|
*/
|
||||||
public Object getFieldRealRenderer(VascEntryField field) {
|
public Object getFieldRealRenderer(VascEntryField field) {
|
||||||
return fieldEditors.get(field);
|
return fieldEditors.get(field);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascFrontendData#getFieldVascUIComponent(net.forwardfire.vasc.core.VascEntryField)
|
* @see net.forwardfire.vasc.frontend.VascFrontendData#getFieldVascUIComponent(net.forwardfire.vasc.core.VascEntryField)
|
||||||
*/
|
*/
|
||||||
public VascUIComponent getFieldVascUIComponent(VascEntryField field) {
|
public VascUIComponent getFieldVascUIComponent(VascEntryField field) {
|
||||||
return fieldComps.get(field);
|
return fieldComps.get(field);
|
||||||
|
@ -228,14 +261,14 @@ public class DefaultVascFrontendData implements VascFrontendData {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascFrontendData#addVascValidatorService(net.forwardfire.vasc.core.entry.VascEntryFieldValidatorService)
|
* @see net.forwardfire.vasc.frontend.VascFrontendData#addVascValidatorService(net.forwardfire.vasc.core.entry.VascEntryFieldValidatorService)
|
||||||
*/
|
*/
|
||||||
public void addVascValidatorService(VascEntryFieldValidatorService validatorService) {
|
public void addVascValidatorService(VascEntryFieldValidatorService validatorService) {
|
||||||
validatorServices.add(validatorService);
|
validatorServices.add(validatorService);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascFrontendData#getVascValidatorServices()
|
* @see net.forwardfire.vasc.frontend.VascFrontendData#getVascValidatorServices()
|
||||||
*/
|
*/
|
||||||
public List<VascEntryFieldValidatorService> getVascValidatorServices() {
|
public List<VascEntryFieldValidatorService> getVascValidatorServices() {
|
||||||
return validatorServices;
|
return validatorServices;
|
||||||
|
@ -322,4 +355,11 @@ public class DefaultVascFrontendData implements VascFrontendData {
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void fireVascFrontendEvent(VascEntry entry,VascFrontendEventType type, Object data) {
|
||||||
|
List<VascEntryFrontendEventListener> list = getVascEntryFrontendEventListener(type);
|
||||||
|
for (VascEntryFrontendEventListener l:list) {
|
||||||
|
l.vascEvent(entry, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -23,26 +23,24 @@
|
||||||
package net.forwardfire.vasc.impl;
|
package net.forwardfire.vasc.impl;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import net.forwardfire.vasc.core.VascBackendFilter;
|
import net.forwardfire.vasc.backend.VascBackendPageNumber;
|
||||||
import net.forwardfire.vasc.core.VascBackendPageNumber;
|
import net.forwardfire.vasc.backend.VascBackendState;
|
||||||
import net.forwardfire.vasc.core.VascBackendState;
|
|
||||||
import net.forwardfire.vasc.core.VascEntry;
|
import net.forwardfire.vasc.core.VascEntry;
|
||||||
import net.forwardfire.vasc.core.VascEntryField;
|
import net.forwardfire.vasc.core.VascEntryField;
|
||||||
import net.forwardfire.vasc.core.VascException;
|
import net.forwardfire.vasc.core.VascException;
|
||||||
import net.forwardfire.vasc.core.VascFrontendHelper;
|
|
||||||
import net.forwardfire.vasc.core.VascLinkEntry;
|
import net.forwardfire.vasc.core.VascLinkEntry;
|
||||||
import net.forwardfire.vasc.core.VascLinkEntryType;
|
import net.forwardfire.vasc.core.VascLinkEntryType;
|
||||||
import net.forwardfire.vasc.core.VascUserRoleController;
|
import net.forwardfire.vasc.core.VascUserRoleController;
|
||||||
import net.forwardfire.vasc.core.actions.GlobalVascAction;
|
import net.forwardfire.vasc.core.actions.GlobalVascAction;
|
||||||
import net.forwardfire.vasc.core.actions.RowVascAction;
|
import net.forwardfire.vasc.core.actions.RowVascAction;
|
||||||
import net.forwardfire.vasc.core.entry.VascEntryFieldValidatorService;
|
import net.forwardfire.vasc.core.entry.VascEntryFieldValidatorService;
|
||||||
import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener;
|
import net.forwardfire.vasc.core.entry.VascEntryFieldValue;
|
||||||
import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener.VascFrontendEventType;
|
import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener.VascFrontendEventType;
|
||||||
import net.forwardfire.vasc.core.ui.VascUIComponent;
|
import net.forwardfire.vasc.core.ui.VascUIComponent;
|
||||||
|
import net.forwardfire.vasc.frontend.VascFrontendHelper;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,7 +54,7 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
|
||||||
private Logger logger = Logger.getLogger(DefaultVascFrontendHelper.class.getName());
|
private Logger logger = Logger.getLogger(DefaultVascFrontendHelper.class.getName());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascFrontendHelper#renderView(net.forwardfire.vasc.core.VascEntryField)
|
* @see net.forwardfire.vasc.frontend.VascFrontendHelper#renderView(net.forwardfire.vasc.core.VascEntryField)
|
||||||
*/
|
*/
|
||||||
public boolean renderView(VascEntryField field) {
|
public boolean renderView(VascEntryField field) {
|
||||||
if (field.getView()==false) {
|
if (field.getView()==false) {
|
||||||
|
@ -66,7 +64,7 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascFrontendHelper#renderCreate(net.forwardfire.vasc.core.VascEntryField)
|
* @see net.forwardfire.vasc.frontend.VascFrontendHelper#renderCreate(net.forwardfire.vasc.core.VascEntryField)
|
||||||
*/
|
*/
|
||||||
public boolean renderCreate(VascEntryField field) {
|
public boolean renderCreate(VascEntryField field) {
|
||||||
if (renderView(field)==false) {
|
if (renderView(field)==false) {
|
||||||
|
@ -83,7 +81,7 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascFrontendHelper#renderEdit(net.forwardfire.vasc.core.VascEntryField)
|
* @see net.forwardfire.vasc.frontend.VascFrontendHelper#renderEdit(net.forwardfire.vasc.core.VascEntryField)
|
||||||
*/
|
*/
|
||||||
public boolean renderEdit(VascEntryField field) {
|
public boolean renderEdit(VascEntryField field) {
|
||||||
if (renderView(field)==false) {
|
if (renderView(field)==false) {
|
||||||
|
@ -105,7 +103,7 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascFrontendHelper#renderEditReadOnly(net.forwardfire.vasc.core.VascEntryField)
|
* @see net.forwardfire.vasc.frontend.VascFrontendHelper#renderEditReadOnly(net.forwardfire.vasc.core.VascEntryField)
|
||||||
*/
|
*/
|
||||||
public boolean renderEditReadOnly(VascEntryField field) {
|
public boolean renderEditReadOnly(VascEntryField field) {
|
||||||
if (renderView(field)==false) {
|
if (renderView(field)==false) {
|
||||||
|
@ -122,7 +120,7 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascFrontendHelper#renderList(net.forwardfire.vasc.core.VascEntryField)
|
* @see net.forwardfire.vasc.frontend.VascFrontendHelper#renderList(net.forwardfire.vasc.core.VascEntryField)
|
||||||
*/
|
*/
|
||||||
public boolean renderList(VascEntryField field) {
|
public boolean renderList(VascEntryField field) {
|
||||||
if (renderView(field)==false) {
|
if (renderView(field)==false) {
|
||||||
|
@ -139,31 +137,23 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascFrontendHelper#renderGlobalVascAction(net.forwardfire.vasc.core.actions.GlobalVascAction)
|
* @see net.forwardfire.vasc.frontend.VascFrontendHelper#renderGlobalVascAction(net.forwardfire.vasc.core.actions.GlobalVascAction)
|
||||||
*/
|
*/
|
||||||
public boolean renderGlobalVascAction(GlobalVascAction action) {
|
public boolean renderGlobalVascAction(GlobalVascAction action) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascFrontendHelper#renderRowVascAction(net.forwardfire.vasc.core.actions.RowVascAction)
|
* @see net.forwardfire.vasc.frontend.VascFrontendHelper#renderRowVascAction(net.forwardfire.vasc.core.actions.RowVascAction)
|
||||||
*/
|
*/
|
||||||
public boolean renderRowVascAction(RowVascAction action) {
|
public boolean renderRowVascAction(RowVascAction action) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see net.forwardfire.vasc.core.VascFrontendHelper#fireVascEvent(net.forwardfire.vasc.core.entry.VascEntryEventListener.VascEventType, java.lang.Object)
|
|
||||||
*/
|
|
||||||
public void fireVascEvent(VascEntry entry,VascFrontendEventType type, Object data) {
|
|
||||||
List<VascEntryFrontendEventListener> list = entry.getVascFrontendData().getVascEntryFrontendEventListener(type);
|
|
||||||
for (VascEntryFrontendEventListener l:list) {
|
|
||||||
l.vascEvent(entry, data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascFrontendHelper#getTotalColumnsWidth(net.forwardfire.vasc.core.VascEntry)
|
* @see net.forwardfire.vasc.frontend.VascFrontendHelper#getTotalColumnsWidth(net.forwardfire.vasc.core.VascEntry)
|
||||||
*/
|
*/
|
||||||
public Integer getTotalColumnsWidth(VascEntry entry) {
|
public Integer getTotalColumnsWidth(VascEntry entry) {
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
@ -192,186 +182,21 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the total amount of pages
|
* @see net.forwardfire.vasc.frontend.VascFrontendHelper#handleException(net.forwardfire.vasc.core.VascEntry,java.lang.Exception)
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public List<VascBackendPageNumber> getVascBackendPageNumbers(VascEntry entry) {
|
|
||||||
List<VascBackendPageNumber> result = new ArrayList<VascBackendPageNumber>(30);
|
|
||||||
VascBackendState state = entry.getVascFrontendData().getVascEntryState().getVascBackendState();
|
|
||||||
if (state.getPageSize()==0) {
|
|
||||||
return result; // paging disabled
|
|
||||||
}
|
|
||||||
Long total = entry.getVascFrontendData().getVascEntryState().getTotalBackendRecords();
|
|
||||||
if (total==null) {
|
|
||||||
return result; // no pages
|
|
||||||
}
|
|
||||||
int pages = new Long(total/state.getPageSize()).intValue();
|
|
||||||
for (int i=0;i<=pages;i++) {
|
|
||||||
VascBackendPageNumber pn = new VascBackendPageNumber(i);
|
|
||||||
if (state.getPageIndex()==i) {
|
|
||||||
pn.setSelected(true);
|
|
||||||
}
|
|
||||||
result.add(pn);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see net.forwardfire.vasc.core.VascFrontendHelper#handleException(net.forwardfire.vasc.core.VascEntry,java.lang.Exception)
|
|
||||||
*/
|
*/
|
||||||
public void handleException(VascEntry entry,Exception exception) {
|
public void handleException(VascEntry entry,Exception exception) {
|
||||||
fireVascEvent(entry,VascFrontendEventType.EXCEPTION , exception);
|
entry.getVascFrontendData().fireVascFrontendEvent(entry,VascFrontendEventType.EXCEPTION , exception);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see net.forwardfire.vasc.core.VascFrontendHelper#initEditObject(net.forwardfire.vasc.core.VascEntry)
|
|
||||||
*/
|
|
||||||
public Object createObject(VascEntry entry) {
|
|
||||||
try {
|
|
||||||
fireVascEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.PRE_CREATE, null);
|
|
||||||
Object object = entry.getVascFrontendData().getVascEntryState().getVascBackend().provideVascEntryRecordCreator(entry.clone()).newRecord(entry);
|
|
||||||
if (object==null) {
|
|
||||||
throw new IllegalStateException("Can't work with null object for backend storage.");
|
|
||||||
}
|
|
||||||
for (VascEntryField field:entry.getVascEntryFields()) {
|
|
||||||
if (field.getDefaultValue()==null) {
|
|
||||||
continue; // no default value to set.
|
|
||||||
}
|
|
||||||
Object value = field.getVascEntryFieldValue().getValue(field, object);
|
|
||||||
if (value!=null) {
|
|
||||||
continue; // value is already set by backend creator.
|
|
||||||
}
|
|
||||||
Object defaultValue = field.getDefaultValue();
|
|
||||||
if (defaultValue instanceof String) {
|
|
||||||
String def = (String)defaultValue;
|
|
||||||
if (def.equals("now()")) { // TODO: add default string parsers
|
|
||||||
defaultValue = new Date();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logger.finer("Setting default value for: "+field.getName()+" def: "+defaultValue);
|
|
||||||
field.getVascEntryFieldValue().setValue(field, object, defaultValue);
|
|
||||||
}
|
|
||||||
fireVascEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.POST_CREATE, object);
|
|
||||||
return object;
|
|
||||||
} catch (Exception e) {
|
|
||||||
handleException(entry,e);
|
|
||||||
return null; /// ?? ,,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected int removeObjectFromDataList(VascEntry entry,Object object) {
|
|
||||||
int indexOld = entry.getVascFrontendData().getVascEntryState().getEntryDataList().indexOf(object);
|
|
||||||
if (entry.getVascFrontendData().getVascEntryState().getEntryDataList().remove(object)) {
|
|
||||||
return indexOld; // java worked well for use
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove only work on (jpa)beans with an overrided equals method.
|
|
||||||
// we lets do the search ourselfs here because we should know the primary key value
|
|
||||||
try {
|
|
||||||
VascEntryField field = entry.getVascEntryFieldById(entry.getPrimaryKeyFieldId());
|
|
||||||
Object idObject = field.getVascEntryFieldValue().getValue(field, object);
|
|
||||||
|
|
||||||
// is only null when creating objects
|
|
||||||
if (idObject!=null) {
|
|
||||||
int index = 0;
|
|
||||||
for (Object o:entry.getVascFrontendData().getVascEntryState().getEntryDataList()) {
|
|
||||||
field = entry.getVascEntryFieldById(entry.getPrimaryKeyFieldId());
|
|
||||||
Object id = field.getVascEntryFieldValue().getValue(field, o);
|
|
||||||
if (idObject.equals(id)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
if (index<entry.getVascFrontendData().getVascEntryState().getEntryDataList().size()) {
|
|
||||||
entry.getVascFrontendData().getVascEntryState().getEntryDataList().remove(index);
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (VascException e) {
|
|
||||||
handleException(entry,e);
|
|
||||||
}
|
|
||||||
return 0; // make better (0=top of list)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see net.forwardfire.vasc.core.VascFrontendHelper#mergeObject(net.forwardfire.vasc.core.VascEntry)
|
|
||||||
*/
|
|
||||||
public Object mergeObject(VascEntry entry) {
|
|
||||||
Object object = entry.getVascFrontendData().getVascEntryState().getEntryDataObject();
|
|
||||||
Object result = null;
|
|
||||||
try {
|
|
||||||
fireVascEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.PRE_UPDATE,object);
|
|
||||||
int index = removeObjectFromDataList(entry,object);
|
|
||||||
|
|
||||||
// merge object on backend
|
|
||||||
result = entry.getVascFrontendData().getVascEntryState().getVascBackend().merge(object);
|
|
||||||
|
|
||||||
// put object thrue the filters
|
|
||||||
for (VascBackendFilter filter:entry.getVascBackendFilters()) {
|
|
||||||
result = filter.filterObject(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
// put object back in list
|
|
||||||
entry.getVascFrontendData().getVascEntryState().getEntryDataList().add(index, result);
|
|
||||||
entry.getVascFrontendData().getVascEntryState().setEntryDataObject(null);
|
|
||||||
fireVascEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.POST_UPDATE,result);
|
|
||||||
} catch (Exception e) {
|
|
||||||
handleException(entry,e);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deletes the selected row object from the list and fires event.
|
|
||||||
* @param entry
|
|
||||||
* @param object
|
|
||||||
*/
|
|
||||||
public void deleteObject(VascEntry entry) {
|
|
||||||
Object object = entry.getVascFrontendData().getVascEntryState().getEntryDataObject();
|
|
||||||
fireVascEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.PRE_DELETE, object);
|
|
||||||
try {
|
|
||||||
entry.getVascFrontendData().getVascEntryState().getVascBackend().delete(object);
|
|
||||||
} catch (Exception e) {
|
|
||||||
handleException(entry,e);
|
|
||||||
}
|
|
||||||
removeObjectFromDataList(entry,object);
|
|
||||||
entry.getVascFrontendData().getVascEntryState().setEntryDataObject(null);
|
|
||||||
fireVascEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.POST_DELETE, object);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see net.forwardfire.vasc.core.VascFrontendHelper#refreshData(net.forwardfire.vasc.core.VascEntry)
|
|
||||||
*/
|
|
||||||
public void refreshData(VascEntry entry) {
|
|
||||||
fireVascEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.PRE_READ, null);
|
|
||||||
entry.getVascFrontendData().getVascEntryState().setEntryDataObject(null);
|
|
||||||
try {
|
|
||||||
// check and correct max page size
|
|
||||||
if (entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageSize()>entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageSizeMax()) {
|
|
||||||
entry.getVascFrontendData().getVascEntryState().getVascBackendState().setPageSize(entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageSizeMax());
|
|
||||||
}
|
|
||||||
|
|
||||||
for (String key:entry.getEntryParameterKeys()) {
|
|
||||||
Object value = entry.getEntryParameter(key);
|
|
||||||
entry.getVascFrontendData().getVascEntryState().getVascBackendState().setDataParameter(key, value);
|
|
||||||
}
|
|
||||||
entry.getVascFrontendData().getVascEntryState().setEntryDataList(entry.getVascFrontendData().getVascEntryState().getVascBackend().execute(entry.getVascFrontendData().getVascEntryState().getVascBackendState()));
|
|
||||||
|
|
||||||
// also update total every time
|
|
||||||
Long total = entry.getVascFrontendData().getVascEntryState().getVascBackend().fetchTotalExecuteSize(entry.getVascFrontendData().getVascEntryState().getVascBackendState());
|
|
||||||
entry.getVascFrontendData().getVascEntryState().setTotalBackendRecords(total);
|
|
||||||
} catch (Exception e) {
|
|
||||||
handleException(entry, e);
|
|
||||||
}
|
|
||||||
fireVascEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.POST_READ, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void headerOptionsCreatedFillData(VascEntry entry) {
|
public void headerOptionsCreatedFillData(VascEntry entry) {
|
||||||
entry.getVascFrontendData().getVascFrontendHelper().refreshData(entry);
|
|
||||||
|
// fix conv defs of options to object. ?
|
||||||
|
|
||||||
|
entry.getVascFrontendData().getVascFrontendActions().refreshData();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.forwardfire.vasc.core.VascFrontendHelper#validateObjectField(net.forwardfire.vasc.core.VascEntryField, java.lang.Object)
|
* @see net.forwardfire.vasc.frontend.VascFrontendHelper#validateObjectField(net.forwardfire.vasc.core.VascEntryField, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public List<String> validateObjectField(VascEntryField field) {
|
public List<String> validateObjectField(VascEntryField field) {
|
||||||
if (field==null) {
|
if (field==null) {
|
||||||
|
@ -463,64 +288,7 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sortAction(VascEntry entry,VascEntryField field) {
|
|
||||||
String curSort = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getSortField();
|
|
||||||
if (field.getBackendName().equals(curSort)) {
|
|
||||||
entry.getVascFrontendData().getVascEntryState().getVascBackendState().setSortAscending(!entry.getVascFrontendData().getVascEntryState().getVascBackendState().isSortAscending());
|
|
||||||
}
|
|
||||||
String sortID = field.getBackendName();
|
|
||||||
entry.getVascFrontendData().getVascEntryState().getVascBackendState().setSortField(sortID);
|
|
||||||
entry.getVascFrontendData().getVascEntryState().getVascBackendState().setPageIndex(0);
|
|
||||||
fireVascEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.SORT, field);
|
|
||||||
|
|
||||||
refreshData(entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void searchAction(VascEntry entry,String searchString) {
|
|
||||||
entry.getVascFrontendData().getVascEntryState().getVascBackendState().setSearchString(searchString);
|
|
||||||
entry.getVascFrontendData().getVascEntryState().getVascBackendState().setSortField(null);
|
|
||||||
entry.getVascFrontendData().getVascEntryState().getVascBackendState().setPageIndex(0);
|
|
||||||
fireVascEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.SEARCH, searchString);
|
|
||||||
|
|
||||||
refreshData(entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void pageAction(VascEntry entry,Integer pageIndex) {
|
|
||||||
if (pageIndex<1) {
|
|
||||||
pageIndex = 0;
|
|
||||||
}
|
|
||||||
Long total = entry.getVascFrontendData().getVascEntryState().getTotalBackendRecords(); // note: total is only null when pageAction is done before first refresh, which should never happen anyway.
|
|
||||||
if (total!=null && pageIndex>(total/entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageSize())) {
|
|
||||||
pageIndex = new Long(total/entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageSize()).intValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
entry.getVascFrontendData().getVascEntryState().getVascBackendState().setPageIndex(pageIndex);
|
|
||||||
fireVascEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.PAGE, pageIndex);
|
|
||||||
|
|
||||||
// lets load data;
|
|
||||||
refreshData(entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void moveAction(VascEntry entry,Object record,boolean moveUp) {
|
|
||||||
if (entry.getVascFrontendData().getVascEntryState().getVascBackend().isRecordMoveable()) {
|
|
||||||
try {
|
|
||||||
VascEntryField p = entry.getVascEntryFieldById(entry.getPrimaryKeyFieldId());
|
|
||||||
Object primaryId = p.getVascEntryFieldValue().getValue(p, record);
|
|
||||||
if (moveUp) {
|
|
||||||
entry.getVascFrontendData().getVascEntryState().getVascBackend().doRecordMoveUpById(entry.getVascFrontendData().getVascEntryState().getVascBackendState(),primaryId);
|
|
||||||
} else {
|
|
||||||
entry.getVascFrontendData().getVascEntryState().getVascBackend().doRecordMoveDownById(entry.getVascFrontendData().getVascEntryState().getVascBackendState(),primaryId);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
handleException(entry, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
// lets load data;
|
|
||||||
refreshData(entry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<RowVascAction> getMultiRowActions(VascEntry entry) {
|
public List<RowVascAction> getMultiRowActions(VascEntry entry) {
|
||||||
List<RowVascAction> result = new ArrayList<RowVascAction>(5);
|
List<RowVascAction> result = new ArrayList<RowVascAction>(5);
|
||||||
for (RowVascAction a:entry.getRowActions()) {
|
for (RowVascAction a:entry.getRowActions()) {
|
||||||
|
@ -530,4 +298,44 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getSelectedDisplayName(VascEntry entry) {
|
||||||
|
Object row = entry.getVascFrontendData().getVascEntryState().getEntryDataObject();
|
||||||
|
if (row==null) {
|
||||||
|
return "no-selection";
|
||||||
|
}
|
||||||
|
VascEntryField v = entry.getVascEntryFieldById(entry.getDisplayNameFieldId());
|
||||||
|
VascEntryFieldValue ve = v.getVascEntryFieldValue();
|
||||||
|
String result = "no-data";
|
||||||
|
try {
|
||||||
|
result = ve.getDisplayValue(v, row);
|
||||||
|
} catch (VascException e) {
|
||||||
|
throw new RuntimeException("Could not get selected name DisplayValue: "+e.getMessage(),e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getParentSelectedDisplayName(VascEntry entry) {
|
||||||
|
if (entry.getVascFrontendData().getVascEntryState().getParent()==null) {
|
||||||
|
return ""; // no parent
|
||||||
|
}
|
||||||
|
|
||||||
|
VascEntry parent = entry.getVascFrontendData().getVascEntryState().getParent().getVascEntry();
|
||||||
|
Object row = entry.getVascFrontendData().getVascEntryState().getParent().getEntryDataObject();
|
||||||
|
if (row==null) {
|
||||||
|
return "no-selection";
|
||||||
|
}
|
||||||
|
VascEntryField v = parent.getVascEntryFieldById(parent.getDisplayNameFieldId());
|
||||||
|
VascEntryFieldValue ve = v.getVascEntryFieldValue();
|
||||||
|
String result = "no-data";
|
||||||
|
try {
|
||||||
|
result = ve.getDisplayValue(v, row);
|
||||||
|
} catch (VascException e) {
|
||||||
|
throw new RuntimeException("Could not get parent name DisplayValue: "+e.getMessage(),e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,223 @@
|
||||||
|
/*
|
||||||
|
* 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.impl;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.forwardfire.vasc.backend.VascBackendPageNumber;
|
||||||
|
import net.forwardfire.vasc.backend.VascBackendState;
|
||||||
|
import net.forwardfire.vasc.core.VascEntry;
|
||||||
|
import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener;
|
||||||
|
import net.forwardfire.vasc.frontend.VascFrontendPager;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default impl of default frontend actions
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Jan 22, 2012
|
||||||
|
*/
|
||||||
|
public class DefaultVascFrontendPager implements VascFrontendPager {
|
||||||
|
|
||||||
|
//private Logger logger = Logger.getLogger(DefaultVascFrontendPager.class.getName());
|
||||||
|
private VascEntry entry = null;
|
||||||
|
private List<VascBackendPageNumber> pagesAll = null;
|
||||||
|
|
||||||
|
public DefaultVascFrontendPager(VascEntry entry) {
|
||||||
|
this.entry=entry;
|
||||||
|
pagesAll = new ArrayList<VascBackendPageNumber>(0);
|
||||||
|
entry.getVascFrontendData().addVascEntryFrontendEventListener(new DefaultVascFrontendPagerEventListener());
|
||||||
|
}
|
||||||
|
|
||||||
|
class DefaultVascFrontendPagerEventListener implements VascEntryFrontendEventListener {
|
||||||
|
private static final long serialVersionUID = -6667099892801941650L;
|
||||||
|
public VascFrontendEventType[] getEventTypes() {
|
||||||
|
VascFrontendEventType[] result = {VascEntryFrontendEventListener.VascFrontendEventType.POST_READ};
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
public void vascEvent(VascEntry entry, Object data) {
|
||||||
|
pagesAll = getTablePagesFromBackend();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public long getPageTotalRecordCount() {
|
||||||
|
long result = entry.getVascFrontendData().getVascEntryState().getTotalBackendRecords();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
public long getPageSize() {
|
||||||
|
long result = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageSize();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
public long getPageStartCount() {
|
||||||
|
int index = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageIndex();
|
||||||
|
int pageSize = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageSize();
|
||||||
|
long result = index*pageSize;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
public long getPageStopCount() {
|
||||||
|
int index = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageIndex();
|
||||||
|
int pageSize = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageSize();
|
||||||
|
long result = (index*pageSize)+pageSize;
|
||||||
|
|
||||||
|
// limit for small result sets.
|
||||||
|
if (result>entry.getVascFrontendData().getVascEntryState().getTotalBackendRecords()) {
|
||||||
|
result = entry.getVascFrontendData().getVascEntryState().getTotalBackendRecords();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getHasPageNextAction() {
|
||||||
|
int pageIndex = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageIndex();
|
||||||
|
pageIndex++;
|
||||||
|
// copyed from helper
|
||||||
|
Long total = entry.getVascFrontendData().getVascEntryState().getTotalBackendRecords();
|
||||||
|
if (total!=null && pageIndex>(total/entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageSize())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getHasPagePreviousAction() {
|
||||||
|
int pageIndex = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageIndex();
|
||||||
|
if (pageIndex==0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getHasOnlySinglePage() {
|
||||||
|
int pages = pagesAll.size();
|
||||||
|
if (pages==1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getHasExtendedPageMode() {
|
||||||
|
int pages = pagesAll.size();
|
||||||
|
if (pages>13) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getHasExtendedPageModeCenter() {
|
||||||
|
if (getHasExtendedPageMode()==false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
int page = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageIndex();
|
||||||
|
if (page<5) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
int pages = pagesAll.size();
|
||||||
|
if (page>pages-6) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<VascBackendPageNumber> getTablePagesFromBackend() {
|
||||||
|
List<VascBackendPageNumber> result = new ArrayList<VascBackendPageNumber>(30);
|
||||||
|
VascBackendState state = entry.getVascFrontendData().getVascEntryState().getVascBackendState();
|
||||||
|
if (state.getPageSize()==0) {
|
||||||
|
return result; // paging disabled
|
||||||
|
}
|
||||||
|
Long total = entry.getVascFrontendData().getVascEntryState().getTotalBackendRecords();
|
||||||
|
if (total==null) {
|
||||||
|
return result; // no pages
|
||||||
|
}
|
||||||
|
int pages = new Long(total/state.getPageSize()).intValue();
|
||||||
|
for (int i=0;i<=pages;i++) {
|
||||||
|
VascBackendPageNumber pn = new VascBackendPageNumber(i);
|
||||||
|
if (state.getPageIndex()==i) {
|
||||||
|
pn.setSelected(true);
|
||||||
|
}
|
||||||
|
result.add(pn);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<VascBackendPageNumber> getTablePagesNormal() {
|
||||||
|
if (getHasExtendedPageMode()) {
|
||||||
|
return new ArrayList<VascBackendPageNumber>(0);
|
||||||
|
} else {
|
||||||
|
return pagesAll;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<VascBackendPageNumber> getTablePagesExtendedBegin() {
|
||||||
|
List<VascBackendPageNumber> result = new ArrayList<VascBackendPageNumber>(6);
|
||||||
|
result.add(pagesAll.get(0));
|
||||||
|
result.add(pagesAll.get(1));
|
||||||
|
result.add(pagesAll.get(2));
|
||||||
|
|
||||||
|
int page = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageIndex();
|
||||||
|
if (page==2 | page==3 | page==4) {
|
||||||
|
result.add(pagesAll.get(3));
|
||||||
|
}
|
||||||
|
if (page==3 | page==4) {
|
||||||
|
result.add(pagesAll.get(4));
|
||||||
|
}
|
||||||
|
if (page==4) {
|
||||||
|
result.add(pagesAll.get(5));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<VascBackendPageNumber> getTablePagesExtendedEnd() {
|
||||||
|
List<VascBackendPageNumber> result = new ArrayList<VascBackendPageNumber>(6);
|
||||||
|
int pages = pagesAll.size();
|
||||||
|
int page = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageIndex();
|
||||||
|
int off = pages-page;
|
||||||
|
|
||||||
|
if (off==5) {
|
||||||
|
result.add(pagesAll.get(pages-6));
|
||||||
|
}
|
||||||
|
if (off==4 | off==5) {
|
||||||
|
result.add(pagesAll.get(pages-5));
|
||||||
|
}
|
||||||
|
if (off==3 | off==4 | off==5) {
|
||||||
|
result.add(pagesAll.get(pages-4));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pages>4) {
|
||||||
|
result.add(pagesAll.get(pages-3));
|
||||||
|
result.add(pagesAll.get(pages-2));
|
||||||
|
result.add(pagesAll.get(pages-1));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<VascBackendPageNumber> getTablePagesExtendedCenter() {
|
||||||
|
List<VascBackendPageNumber> result = new ArrayList<VascBackendPageNumber>(3);
|
||||||
|
int page = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageIndex();
|
||||||
|
if (page>0) {
|
||||||
|
result.add(pagesAll.get(page-1));
|
||||||
|
}
|
||||||
|
result.add(pagesAll.get(page));
|
||||||
|
result.add(pagesAll.get(page+1));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
|
@ -45,7 +45,7 @@ public class AddRowAction extends AbstractVascAction implements RowVascAction {
|
||||||
|
|
||||||
public void doRowAction(VascEntry entry,Object rowObject) throws Exception {
|
public void doRowAction(VascEntry entry,Object rowObject) throws Exception {
|
||||||
entry.getVascFrontendData().getVascEntryState().setEditCreate(true);
|
entry.getVascFrontendData().getVascEntryState().setEditCreate(true);
|
||||||
Object object = entry.getVascFrontendData().getVascFrontendHelper().createObject(entry);
|
Object object = entry.getVascFrontendData().getVascFrontendActions().createObject();
|
||||||
entry.getVascFrontendData().getVascEntryState().setEntryDataObject(object);
|
entry.getVascFrontendData().getVascEntryState().setEntryDataObject(object);
|
||||||
entry.getVascFrontendData().getVascFrontend().renderEdit();
|
entry.getVascFrontendData().getVascFrontend().renderEdit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ public class CSVExportGlobalAction extends AbstractVascAction implements GlobalV
|
||||||
int pages = total.intValue()/entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageSize();
|
int pages = total.intValue()/entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageSize();
|
||||||
for (int page=0;page<=pages;page++) {
|
for (int page=0;page<=pages;page++) {
|
||||||
entry.getVascFrontendData().getVascEntryState().getVascBackendState().setPageIndex(page);
|
entry.getVascFrontendData().getVascEntryState().getVascBackendState().setPageIndex(page);
|
||||||
entry.getVascFrontendData().getVascFrontendHelper().refreshData(entry);
|
entry.getVascFrontendData().getVascFrontendActions().refreshData();
|
||||||
for (Object o:entry.getVascFrontendData().getVascEntryState().getEntryDataList()) {
|
for (Object o:entry.getVascFrontendData().getVascEntryState().getEntryDataList()) {
|
||||||
for (VascEntryField c:entry.getVascEntryFields()) {
|
for (VascEntryField c:entry.getVascEntryFields()) {
|
||||||
p.write(c.getVascEntryFieldValue().getDisplayValue(c, o)+"\t");
|
p.write(c.getVascEntryFieldValue().getDisplayValue(c, o)+"\t");
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class EditRowAction extends AbstractVascAction implements RowVascAction {
|
||||||
return; // nothing selected
|
return; // nothing selected
|
||||||
}
|
}
|
||||||
entry.getVascFrontendData().getVascEntryState().setEditCreate(false);
|
entry.getVascFrontendData().getVascEntryState().setEditCreate(false);
|
||||||
entry.getVascFrontendData().getVascFrontendHelper().fireVascEvent(entry, VascFrontendEventType.SELECT, rowObject);
|
entry.getVascFrontendData().fireVascFrontendEvent(entry, VascFrontendEventType.SELECT, rowObject);
|
||||||
entry.getVascFrontendData().getVascEntryState().setEntryDataObject(rowObject);
|
entry.getVascFrontendData().getVascEntryState().setEntryDataObject(rowObject);
|
||||||
entry.getVascFrontendData().getVascFrontend().renderEdit();
|
entry.getVascFrontendData().getVascFrontend().renderEdit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,6 @@ public class RefreshDataGlobalAction extends AbstractVascAction implements Globa
|
||||||
|
|
||||||
|
|
||||||
public void doGlobalAction(VascEntry entry) throws Exception {
|
public void doGlobalAction(VascEntry entry) throws Exception {
|
||||||
entry.getVascFrontendData().getVascFrontendHelper().refreshData(entry); // this wil also fire the event
|
entry.getVascFrontendData().getVascFrontendActions().refreshData(); // this wil also fire the event
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -62,7 +62,7 @@ public class XMLExportGlobalAction extends AbstractVascAction implements GlobalV
|
||||||
int pages = total.intValue()/entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageSize();
|
int pages = total.intValue()/entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageSize();
|
||||||
for (int page=0;page<=pages;page++) {
|
for (int page=0;page<=pages;page++) {
|
||||||
entry.getVascFrontendData().getVascEntryState().getVascBackendState().setPageIndex(page);
|
entry.getVascFrontendData().getVascEntryState().getVascBackendState().setPageIndex(page);
|
||||||
entry.getVascFrontendData().getVascFrontendHelper().refreshData(entry);
|
entry.getVascFrontendData().getVascFrontendActions().refreshData();
|
||||||
for (Object o:entry.getVascFrontendData().getVascEntryState().getEntryDataList()) {
|
for (Object o:entry.getVascFrontendData().getVascEntryState().getEntryDataList()) {
|
||||||
p.write("\t<row>\n");
|
p.write("\t<row>\n");
|
||||||
for (VascEntryField c:entry.getVascEntryFields()) {
|
for (VascEntryField c:entry.getVascEntryFields()) {
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
package net.forwardfire.vasc.impl.entry;
|
package net.forwardfire.vasc.impl.entry;
|
||||||
|
|
||||||
import net.forwardfire.vasc.core.VascBackendState;
|
import net.forwardfire.vasc.backend.VascBackendState;
|
||||||
import net.forwardfire.vasc.core.VascEntry;
|
import net.forwardfire.vasc.core.VascEntry;
|
||||||
import net.forwardfire.vasc.core.entry.VascEntryBackendEventListener;
|
import net.forwardfire.vasc.core.entry.VascEntryBackendEventListener;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,293 @@
|
||||||
|
/*
|
||||||
|
* 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.impl.ui;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import net.forwardfire.vasc.backend.VascBackend;
|
||||||
|
import net.forwardfire.vasc.backend.VascBackendState;
|
||||||
|
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.ui.VascSelectItem;
|
||||||
|
import net.forwardfire.vasc.core.ui.VascSelectItemModel;
|
||||||
|
import net.forwardfire.vasc.impl.DefaultVascBackendState;
|
||||||
|
import net.forwardfire.vasc.impl.DefaultVascFactory;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The DefaultVascSelectItemModel
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Oct 27, 2007
|
||||||
|
*/
|
||||||
|
public class VascSelectItemModelEntry implements VascSelectItemModel {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
private String entryId = null;
|
||||||
|
private String keyFieldId = null;
|
||||||
|
private String displayFieldId = null;
|
||||||
|
private String nullLabel = null;
|
||||||
|
private String nullKeyValue = null;
|
||||||
|
private Boolean returnKeyValue = null;
|
||||||
|
private Map<String,String> entryParameterFieldIds = new HashMap<String,String>(3);
|
||||||
|
private Boolean useParentFields = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see net.forwardfire.vasc.core.ui.VascSelectItemModel#getVascSelectItems(net.forwardfire.vasc.core.VascEntry)
|
||||||
|
*/
|
||||||
|
public List<VascSelectItem> getVascSelectItems(VascEntry currentEntry) throws VascException {
|
||||||
|
List<VascSelectItem> result = new ArrayList<VascSelectItem>(100);
|
||||||
|
VascEntry entry = currentEntry.getVascFrontendData().getVascController().getVascEntryController().getVascEntryById(entryId);
|
||||||
|
|
||||||
|
if (keyFieldId==null) {
|
||||||
|
keyFieldId = entry.getPrimaryKeyFieldId();
|
||||||
|
}
|
||||||
|
VascEntryField key = entry.getVascEntryFieldById(keyFieldId);
|
||||||
|
|
||||||
|
if (displayFieldId==null) {
|
||||||
|
displayFieldId = entry.getDisplayNameFieldId();
|
||||||
|
}
|
||||||
|
VascEntryField dis = entry.getVascEntryFieldById(displayFieldId);
|
||||||
|
if (key==null) {
|
||||||
|
throw new VascException("Could not find: "+keyFieldId+" from: "+entry.getId());
|
||||||
|
}
|
||||||
|
if (dis==null) {
|
||||||
|
throw new VascException("Could not find: "+displayFieldId+" from: "+entry.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
// set frontend data for new clone, we need te get better lifecycle management for stats/entry/etc
|
||||||
|
entry.setVascFrontendData(currentEntry.getVascFrontendData());
|
||||||
|
VascBackend back = DefaultVascFactory.getProxyVascBackend(entry);
|
||||||
|
try {
|
||||||
|
if (nullLabel!=null) {
|
||||||
|
if (nullKeyValue==null) {
|
||||||
|
nullKeyValue = "null";
|
||||||
|
}
|
||||||
|
nullLabel = currentEntry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(nullLabel);
|
||||||
|
VascSelectItem item = new VascSelectItem(nullLabel,null,nullKeyValue);
|
||||||
|
result.add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
// set def para
|
||||||
|
VascBackendState state = new DefaultVascBackendState();
|
||||||
|
for (String key2:entry.getEntryParameterKeys()) {
|
||||||
|
Object value = entry.getEntryParameter(key2);
|
||||||
|
//System.out.println("Copy paras name: "+key2+" value: "+value+" class: "+value.getClass().getName());
|
||||||
|
state.setDataParameter(key2, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// set list para
|
||||||
|
for (VascEntryField vef:entry.getListOptions()) {
|
||||||
|
Object def = vef.getDefaultValue();
|
||||||
|
if (def==null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String backendName = vef.getBackendName();
|
||||||
|
state.setDataParameter(backendName, def);
|
||||||
|
}
|
||||||
|
|
||||||
|
// set para from parent state entry
|
||||||
|
for (String paraName:entryParameterFieldIds.keySet()) {
|
||||||
|
|
||||||
|
VascEntry fieldEntry = currentEntry;
|
||||||
|
if (useParentFields!=null && useParentFields==true) {
|
||||||
|
if (currentEntry.getVascFrontendData().getVascEntryState().getParent()==null) {
|
||||||
|
throw new IllegalStateException("Requested to use parent state field values but no parent state found.");
|
||||||
|
}
|
||||||
|
fieldEntry = currentEntry.getVascFrontendData().getVascEntryState().getParent().getVascEntry();
|
||||||
|
}
|
||||||
|
|
||||||
|
String paraValueId = entryParameterFieldIds.get(paraName);
|
||||||
|
VascEntryField fieldOrg = fieldEntry.getVascEntryFieldById(paraValueId);
|
||||||
|
if (fieldOrg==null) {
|
||||||
|
//System.out.println("could not find field: "+paraValueId);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
VascEntryField field = fieldOrg.clone();
|
||||||
|
field.getVascValidators().clear();
|
||||||
|
VascEntryFieldValue v = fieldEntry.getVascFrontendData().getVascEntryState().getVascBackend().provideVascEntryFieldValue(field);
|
||||||
|
|
||||||
|
Object record = fieldEntry.getVascFrontendData().getVascEntryState().getEntryDataObject();
|
||||||
|
if (record==null) {
|
||||||
|
//System.out.println("could not get selected records from state.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Object value = v.getValue(fieldOrg, record);
|
||||||
|
|
||||||
|
//System.out.println("Set entry paras name: "+paraName+" value: "+value+" class: "+value.getClass().getName());
|
||||||
|
state.setDataParameter(paraName, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: FIX >>>>>>>>>>>>>>>>>>
|
||||||
|
if (key.getVascEntryFieldValue()==null) {
|
||||||
|
// TODO: fix this for better remote support
|
||||||
|
VascEntryField fieldClone = key.clone();
|
||||||
|
fieldClone.getVascValidators().clear();
|
||||||
|
|
||||||
|
VascEntryFieldValue v = currentEntry.getVascFrontendData().getVascEntryState().getVascBackend().provideVascEntryFieldValue(fieldClone);
|
||||||
|
key.setVascEntryFieldValue(v);
|
||||||
|
}
|
||||||
|
if (dis.getVascEntryFieldValue()==null) {
|
||||||
|
// TODO: fix this for better remote support
|
||||||
|
VascEntryField fieldClone = dis.clone();
|
||||||
|
fieldClone.getVascValidators().clear();
|
||||||
|
|
||||||
|
VascEntryFieldValue v = currentEntry.getVascFrontendData().getVascEntryState().getVascBackend().provideVascEntryFieldValue(fieldClone);
|
||||||
|
dis.setVascEntryFieldValue(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// execute
|
||||||
|
for (Object o:back.execute(state)) {
|
||||||
|
Object keyId = key.getVascEntryFieldValue().getValue(key, o);
|
||||||
|
String nameId = dis.getVascEntryFieldValue().getDisplayValue(dis, o);
|
||||||
|
if (returnKeyValue!=null && true==returnKeyValue) {
|
||||||
|
VascSelectItem item = new VascSelectItem(nameId,keyId,""+keyId);
|
||||||
|
result.add(item);
|
||||||
|
} else {
|
||||||
|
VascSelectItem item = new VascSelectItem(nameId,o,""+keyId);
|
||||||
|
result.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new VascException(e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the entryId
|
||||||
|
*/
|
||||||
|
public String getEntryId() {
|
||||||
|
return entryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param entryId the entryId to set
|
||||||
|
*/
|
||||||
|
public void setEntryId(String entryId) {
|
||||||
|
this.entryId = entryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the keyFieldId
|
||||||
|
*/
|
||||||
|
public String getKeyFieldId() {
|
||||||
|
return keyFieldId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param keyFieldId the keyFieldId to set
|
||||||
|
*/
|
||||||
|
public void setKeyFieldId(String keyFieldId) {
|
||||||
|
this.keyFieldId = keyFieldId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the displayFieldId
|
||||||
|
*/
|
||||||
|
public String getDisplayFieldId() {
|
||||||
|
return displayFieldId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param displayFieldId the displayFieldId to set
|
||||||
|
*/
|
||||||
|
public void setDisplayFieldId(String displayFieldId) {
|
||||||
|
this.displayFieldId = displayFieldId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the nullLabel
|
||||||
|
*/
|
||||||
|
public String getNullLabel() {
|
||||||
|
return nullLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param nullLabel the nullLabel to set
|
||||||
|
*/
|
||||||
|
public void setNullLabel(String nullLabel) {
|
||||||
|
this.nullLabel = nullLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the nullKeyValue
|
||||||
|
*/
|
||||||
|
public String getNullKeyValue() {
|
||||||
|
return nullKeyValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param nullKeyValue the nullKeyValue to set
|
||||||
|
*/
|
||||||
|
public void setNullKeyValue(String nullKeyValue) {
|
||||||
|
this.nullKeyValue = nullKeyValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the returnKeyValue
|
||||||
|
*/
|
||||||
|
public Boolean getReturnKeyValue() {
|
||||||
|
return returnKeyValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param returnKeyValue the returnKeyValue to set
|
||||||
|
*/
|
||||||
|
public void setReturnKeyValue(Boolean returnKeyValue) {
|
||||||
|
this.returnKeyValue = returnKeyValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEntryParameterFieldId(String parameterName) {
|
||||||
|
return entryParameterFieldIds.get(parameterName);
|
||||||
|
}
|
||||||
|
public void addEntryParameterFieldId(String parameterName,String valueFieldId) {
|
||||||
|
entryParameterFieldIds.put(parameterName, valueFieldId);
|
||||||
|
}
|
||||||
|
public List<String> getEntryParameterFieldIdKeys() {
|
||||||
|
return new ArrayList<String>(entryParameterFieldIds.keySet());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the useParentFields
|
||||||
|
*/
|
||||||
|
public Boolean getUseParentFields() {
|
||||||
|
return useParentFields;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param useParentFields the useParentFields to set
|
||||||
|
*/
|
||||||
|
public void setUseParentFields(Boolean useParentFields) {
|
||||||
|
this.useParentFields = useParentFields;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,146 @@
|
||||||
|
/*
|
||||||
|
* 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.impl.ui;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.forwardfire.vasc.core.VascEntry;
|
||||||
|
import net.forwardfire.vasc.core.VascException;
|
||||||
|
import net.forwardfire.vasc.core.ui.VascSelectItem;
|
||||||
|
import net.forwardfire.vasc.core.ui.VascSelectItemModel;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The DefaultVascSelectItemModel
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Oct 27, 2007
|
||||||
|
*/
|
||||||
|
public class VascSelectItemModelStringEnum implements VascSelectItemModel {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
private Object data = null;
|
||||||
|
private String nullLabel = null;
|
||||||
|
private String nullKeyValue = null;
|
||||||
|
private Boolean returnKeyValue = null;
|
||||||
|
private Boolean useParentFields = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see net.forwardfire.vasc.core.ui.VascSelectItemModel#getVascSelectItems(net.forwardfire.vasc.core.VascEntry)
|
||||||
|
*/
|
||||||
|
public List<VascSelectItem> getVascSelectItems(VascEntry currentEntry) throws VascException {
|
||||||
|
List<VascSelectItem> result = new ArrayList<VascSelectItem>(100);
|
||||||
|
|
||||||
|
if (data==null) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
if (data instanceof String) {
|
||||||
|
String[] values = ((String)data).split(",");
|
||||||
|
for (String value:values) {
|
||||||
|
result.add(new VascSelectItem(value,value,value));
|
||||||
|
}
|
||||||
|
} else if (data instanceof List) {
|
||||||
|
List<?> values = (List<?>)data;
|
||||||
|
for (Object o:values) {
|
||||||
|
String value = ""+o;
|
||||||
|
result.add(new VascSelectItem(value,value,value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the data
|
||||||
|
*/
|
||||||
|
public Object getData() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param data the data to set
|
||||||
|
*/
|
||||||
|
public void setData(Object data) {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the nullLabel
|
||||||
|
*/
|
||||||
|
public String getNullLabel() {
|
||||||
|
return nullLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param nullLabel the nullLabel to set
|
||||||
|
*/
|
||||||
|
public void setNullLabel(String nullLabel) {
|
||||||
|
this.nullLabel = nullLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the nullKeyValue
|
||||||
|
*/
|
||||||
|
public String getNullKeyValue() {
|
||||||
|
return nullKeyValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param nullKeyValue the nullKeyValue to set
|
||||||
|
*/
|
||||||
|
public void setNullKeyValue(String nullKeyValue) {
|
||||||
|
this.nullKeyValue = nullKeyValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the returnKeyValue
|
||||||
|
*/
|
||||||
|
public Boolean getReturnKeyValue() {
|
||||||
|
return returnKeyValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param returnKeyValue the returnKeyValue to set
|
||||||
|
*/
|
||||||
|
public void setReturnKeyValue(Boolean returnKeyValue) {
|
||||||
|
this.returnKeyValue = returnKeyValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the useParentFields
|
||||||
|
*/
|
||||||
|
public Boolean getUseParentFields() {
|
||||||
|
return useParentFields;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param useParentFields the useParentFields to set
|
||||||
|
*/
|
||||||
|
public void setUseParentFields(Boolean useParentFields) {
|
||||||
|
this.useParentFields = useParentFields;
|
||||||
|
}
|
||||||
|
}
|
|
@ -325,23 +325,13 @@ public class AnnotationParserElement extends AbstractElement {
|
||||||
|
|
||||||
// search for type
|
// search for type
|
||||||
if (methodCall!=null) {
|
if (methodCall!=null) {
|
||||||
Class<?> retType = methodCall.getReturnType();
|
Class<?> returnType = methodCall.getReturnType();
|
||||||
|
|
||||||
for (String typeId: vascController.getVascEntryFieldTypeController().getVascEntryFieldTypeIds()) {
|
for (String typeId: vascController.getVascEntryFieldTypeController().getVascEntryFieldTypeIds()) {
|
||||||
VascEntryFieldType type = vascController.getVascEntryFieldTypeController().getVascEntryFieldTypeById(typeId);
|
VascEntryFieldType type = vascController.getVascEntryFieldTypeController().getVascEntryFieldTypeById(typeId);
|
||||||
|
Class<?> autoClass = type.getAutoDetectClass();
|
||||||
//String auto = "";
|
if (autoClass!=null && autoClass.isAssignableFrom(returnType)) {
|
||||||
//if (type.getAutoDetectClass()!=null) {
|
field.setVascEntryFieldType(type);
|
||||||
// auto = type.getAutoDetectClass().getName();
|
break;
|
||||||
//}
|
|
||||||
//System.out.println("Check ret: "+retType.getName()+" type: "+type.getId()+" auto: "+auto);
|
|
||||||
|
|
||||||
|
|
||||||
if (type.getAutoDetectClass()!=null) {
|
|
||||||
if (type.getAutoDetectClass().isAssignableFrom(retType)) {
|
|
||||||
field.setVascEntryFieldType(type);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,9 +23,9 @@
|
||||||
package net.forwardfire.vasc.impl.x4o;
|
package net.forwardfire.vasc.impl.x4o;
|
||||||
|
|
||||||
|
|
||||||
import net.forwardfire.vasc.core.VascBackend;
|
import net.forwardfire.vasc.backend.VascBackend;
|
||||||
import net.forwardfire.vasc.core.VascBackendController;
|
import net.forwardfire.vasc.backend.VascBackendController;
|
||||||
import net.forwardfire.vasc.core.VascBackendControllerLocal;
|
import net.forwardfire.vasc.backend.VascBackendControllerLocal;
|
||||||
import net.forwardfire.vasc.core.VascController;
|
import net.forwardfire.vasc.core.VascController;
|
||||||
|
|
||||||
import org.x4o.xml.element.AbstractElementConfigurator;
|
import org.x4o.xml.element.AbstractElementConfigurator;
|
||||||
|
|
|
@ -22,36 +22,36 @@
|
||||||
|
|
||||||
package net.forwardfire.vasc.impl.x4o;
|
package net.forwardfire.vasc.impl.x4o;
|
||||||
|
|
||||||
|
|
||||||
import net.forwardfire.vasc.core.VascController;
|
import net.forwardfire.vasc.core.VascController;
|
||||||
|
import net.forwardfire.vasc.core.VascEntryField;
|
||||||
|
import net.forwardfire.vasc.core.VascEntryFieldType;
|
||||||
|
|
||||||
import org.x4o.xml.element.AbstractElementAttributeConverter;
|
import org.x4o.xml.element.AbstractElementConfigurator;
|
||||||
import org.x4o.xml.element.Element;
|
import org.x4o.xml.element.Element;
|
||||||
import org.x4o.xml.element.ElementAttributeConverterException;
|
import org.x4o.xml.element.ElementConfiguratorException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts the type to the type object
|
* Maps the vasc
|
||||||
*
|
*
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Nov 16, 2008
|
* @version 1.0 Jan 20, 2012
|
||||||
*/
|
*/
|
||||||
public class VascEntryFieldTypeAttributeConverter extends AbstractElementAttributeConverter {
|
public class VascEntryFieldConfigurator extends AbstractElementConfigurator {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.AbstractElementAttributeConverter#doConvertAttribute(org.x4o.xml.element.Element, java.lang.Object)
|
* @see org.x4o.xml.element.AbstractElementConfigurator#doConfigEndTag(org.x4o.xml.element.Element)
|
||||||
*/
|
*/
|
||||||
public Object doConvertAttribute(Element element, Object attributeValue) throws ElementAttributeConverterException {
|
public void doConfigElement(Element element) throws ElementConfiguratorException {
|
||||||
if (attributeValue==null) {
|
String fieldID = element.getAttributes().get("vascEntryFieldType");
|
||||||
throw new NullPointerException("can't convert null parameter");
|
if (fieldID==null) {
|
||||||
|
fieldID = "";
|
||||||
}
|
}
|
||||||
if ("".equals(attributeValue)) {
|
if ("".equals(fieldID)) {
|
||||||
attributeValue = "TextField"; // ??
|
fieldID = "TextField"; // ??
|
||||||
}
|
}
|
||||||
String fieldID = attributeValue.toString();
|
|
||||||
|
|
||||||
VascController controller = VascParser.getVascController(element.getElementContext());
|
VascController controller = VascParser.getVascController(element.getElementContext());
|
||||||
Object result = controller.getVascEntryFieldTypeController().getVascEntryFieldTypeById(fieldID);
|
VascEntryFieldType result = controller.getVascEntryFieldTypeController().getVascEntryFieldTypeById(fieldID);
|
||||||
return result;
|
((VascEntryField)element.getElementObject()).setVascEntryFieldType(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -24,7 +24,6 @@ package net.forwardfire.vasc.impl.x4o;
|
||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
|
||||||
import net.forwardfire.vasc.core.VascEntry;
|
import net.forwardfire.vasc.core.VascEntry;
|
||||||
import net.forwardfire.vasc.core.VascEntryField;
|
import net.forwardfire.vasc.core.VascEntryField;
|
||||||
|
|
||||||
|
@ -47,7 +46,7 @@ public class VascEntryFieldElement extends AbstractElement {
|
||||||
* @see org.x4o.xml.element.AbstractElement#doElementRun()
|
* @see org.x4o.xml.element.AbstractElement#doElementRun()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void doElementRun() throws ElementException {
|
public void doElementRun() throws ElementException {
|
||||||
String id = getAttributes().get("id");
|
String id = getAttributes().get("id");
|
||||||
VascEntry back = (VascEntry)getParent().getElementObject();
|
VascEntry back = (VascEntry)getParent().getElementObject();
|
||||||
VascEntryField field = back.getVascEntryFieldById(id);
|
VascEntryField field = back.getVascEntryFieldById(id);
|
||||||
|
|
|
@ -25,9 +25,8 @@ package net.forwardfire.vasc.impl.x4o;
|
||||||
|
|
||||||
import net.forwardfire.vasc.core.VascEntryFieldSet;
|
import net.forwardfire.vasc.core.VascEntryFieldSet;
|
||||||
|
|
||||||
import org.x4o.xml.element.AbstractElementAttributeConverter;
|
import org.x4o.xml.element.AbstractElement;
|
||||||
import org.x4o.xml.element.Element;
|
import org.x4o.xml.element.ElementException;
|
||||||
import org.x4o.xml.element.ElementAttributeConverterException;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,25 +35,25 @@ import org.x4o.xml.element.ElementAttributeConverterException;
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Nov 17, 2008
|
* @version 1.0 Nov 17, 2008
|
||||||
*/
|
*/
|
||||||
public class VascEntryFieldSetAttributeConverter extends AbstractElementAttributeConverter {
|
public class VascEntryFieldSetElement extends AbstractElement {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.AbstractElementAttributeConverter#doConvertAttribute(org.x4o.xml.element.Element, java.lang.Object)
|
* @see org.x4o.xml.element.AbstractElement#doElementRun()
|
||||||
*/
|
*/
|
||||||
public Object doConvertAttribute(Element element, Object parameterValue) throws ElementAttributeConverterException {
|
@Override
|
||||||
|
public void doElementRun() throws ElementException {
|
||||||
|
String parameterValue = getAttributes().get("vascEntryFieldIds");
|
||||||
if (parameterValue==null) {
|
if (parameterValue==null) {
|
||||||
throw new NullPointerException("can't convert null parameter");
|
throw new ElementException("Must have vascEntryFieldIds attribute");
|
||||||
}
|
}
|
||||||
if ("".equals(parameterValue)) {
|
if ("".equals(parameterValue)) {
|
||||||
return null;
|
throw new ElementException("Must have not empty vascEntryFieldIds attribute");
|
||||||
}
|
}
|
||||||
String[] ids = parameterValue.toString().split(",");
|
String[] ids = parameterValue.toString().split(",");
|
||||||
|
|
||||||
VascEntryFieldSet set = (VascEntryFieldSet)element.getElementObject();
|
VascEntryFieldSet set = (VascEntryFieldSet)getElementObject();
|
||||||
for (String id:ids) {
|
for (String id:ids) {
|
||||||
set.addVascEntryFieldId(id);
|
set.addVascEntryFieldId(id);
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,11 +2,15 @@
|
||||||
<eld:root xmlns:eld="http://eld.x4o.org/eld/eld-lang.eld">
|
<eld:root xmlns:eld="http://eld.x4o.org/eld/eld-lang.eld">
|
||||||
|
|
||||||
<eld:elementClass tag="fieldType" objectClassName="net.forwardfire.vasc.impl.type.DefaultVascEntryFieldType">
|
<eld:elementClass tag="fieldType" objectClassName="net.forwardfire.vasc.impl.type.DefaultVascEntryFieldType">
|
||||||
<eld:elementClassAttributeConverter attributeName="autoDetectClass" bean.class="org.x4o.xml.impl.lang.ClassConverter"/>
|
<eld:elementClassAttribute attributeName="autoDetectClass">
|
||||||
|
<eld:attributeClassConverter/>
|
||||||
|
</eld:elementClassAttribute>
|
||||||
</eld:elementClass>
|
</eld:elementClass>
|
||||||
|
|
||||||
<eld:elementClass tag="multiTextFieldType" objectClassName="net.forwardfire.vasc.impl.type.MultiTextVascEntryFieldType">
|
<eld:elementClass tag="multiTextFieldType" objectClassName="net.forwardfire.vasc.impl.type.MultiTextVascEntryFieldType">
|
||||||
<eld:elementClassAttributeConverter attributeName="autoDetectClass" bean.class="org.x4o.xml.impl.lang.ClassConverter"/>
|
<eld:elementClassAttribute attributeName="autoDetectClass">
|
||||||
|
<eld:attributeClassConverter/>
|
||||||
|
</eld:elementClassAttribute>
|
||||||
</eld:elementClass>
|
</eld:elementClass>
|
||||||
|
|
||||||
<eld:elementRefectionBindingHandler parentClass="net.forwardfire.vasc.core.VascEntryFieldType"
|
<eld:elementRefectionBindingHandler parentClass="net.forwardfire.vasc.core.VascEntryFieldType"
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue