diff --git a/.gitignore b/.gitignore index 26d57f9..0298f94 100644 --- a/.gitignore +++ b/.gitignore @@ -10,8 +10,12 @@ */*/*/*/target # Inore some artifact dirs; -vasc-demo/vasc-demo-tech/vasc-demo-tech-ui/deploy -vasc-demo/vasc-demo-tech/vasc-demo-tech-ui/workdir +vasc-demo/vasc-demo-tech/vasc-demo-tech-core/conf +vasc-demo/vasc-demo-tech/vasc-demo-tech-core/data +vasc-demo/vasc-demo-tech/vasc-demo-tech-core/demo +vasc-demo/vasc-demo-tech/vasc-demo-tech-core/deploy +vasc-demo/vasc-demo-tech/vasc-demo-tech-core/logs +vasc-demo/vasc-demo-tech/vasc-demo-tech-core/workdir # Ignore leftovers of really failed release build release.properties diff --git a/pom.xml b/pom.xml index 5d0b207..437faf8 100644 --- a/pom.xml +++ b/pom.xml @@ -37,15 +37,10 @@ vasc-lib - https://...vasc/ - file://${project.build.directory}/target-maven-repo UTF-8 - 2.1.0 - 5.8 - 0.8.2-SNAPSHOT - 4.3 + 1.5 - + 1.2 2.3.1 2.4 @@ -53,59 +48,121 @@ 1.0-beta-3 3.2 1.0-beta-3 + 2.3 + 2.0-beta-2 + 2.2.1 + 2.3.1 2.1 2.3 2.4.2 - 2.0.2 + 2.3.2 + 2.4.1 + 2.7.1 + 2.3.1 2.1.2 - 2.7 - 2.1 - 2.5 - 3.0-beta-3 + 2.5 + 2.8.1 + 2.2.2 + 2.6 + 3.0 2.0 2.5 1.0 - 2.4 - 2.5 + 2.12 + 2.6 2.5 1.0-beta-1 - 2.2 + 2.4 + 5.8 + 2.1.0 - - 2.4 + + 0.8.2-SNAPSHOT + + + 4.3 + + + 3.0-beta7-SNAPSHOT + + + 2.7.3 + + + 2.6.0 + + + 0.4.4.1 + + + 3.3.0-I20070606-0010 + + + 4.5.1 + + + 1.0.3 + 1.0.3 + 1.6.4 + 1.6.4 + 2.3 + 1.9.2 + + + 9.1-901.jdbc4 + 5.1.20 + 1.3.167 + 10.8.2.2 + + + 3.1.0.CR1 + 3.5.6-Final + + + 6.0 + 3.0 + 1.1 + 1.0.2 + 3.0-alpha-1 + 1.0-MR1 1.2 - 2.1 + 2.2.1-b03 + 2.1 + 2.1.6 + + + 4.1.0.Final + 3.3.3 + 1.0.6-SNAPSHOT + 3.3.3 + + 1.1.2 - 1.2_12 - 1.2_12 - 1.1.15.B1 - 3.3.3.Final - 3.3.3.Final - 3.3.3.Final 1.2 - 1.2 - - - 3.0 - 1.0 - 3.4.0.GA + 2.2.1-b04 1.6.3 + 3.0.0.CR2 + 6.0.0.Final 9.1.0.8 2.8.1 1.0.b2 - - - 3.0.0.CR2 - 6.0.0.Final - - - 1.9.2 + + + + org.richfaces + richfaces-bom + ${richfaces.version} + import + pom + + + + - org.testng testng @@ -113,26 +170,25 @@ jdk15 test - - - maven-compiler-plugin + ${maven-compiler-plugin.version} - UTF-8 - 1.5 - 1.5 + ${project.build.sourceEncoding} + ${project.build.sourceVersion} + ${project.build.sourceVersion} maven-source-plugin + ${maven-source-plugin.version} attach-sources @@ -144,9 +200,9 @@ maven-site-plugin - 2.0-beta-7 + ${maven-site-plugin.version} - UTF-8 + ${project.build.sourceEncoding} @@ -154,97 +210,55 @@ org.apache.maven.plugins maven-surefire-plugin - 2.4 + ${maven-surefire-plugin.version} - - - - com.agilejava.docbkx - docbkx-maven-plugin - - - - src/main/docbook/ - target/site/docbook/ - - - *.xml - - - - true - - - version - ${version} - - - - - true - - - - - - - - create-pdf-docs - site - generate-pdf - - - file:///${basedir}/src/main/docbook/ - - - - - create-html-docs - site - generate-html - - - - - - - - - - - - - - - org.docbook - docbook-xml - 4.4 - runtime - - - org.apache.maven.plugins maven-release-plugin - 2.1 clean install verify - - clean install javadoc:javadoc deploy - -Prelease -DaltDeploymentRepository="${altDeploymentRepository}" + + clean install -P notest + + maven-clean-plugin + ${maven-clean-plugin.version} + + + maven-changes-plugin + ${maven-changes-plugin.version} + + + maven-install-plugin + ${maven-install-plugin.version} + + + maven-resources-plugin + ${maven-resources-plugin.version} + + + maven-jar-plugin + ${maven-jar-plugin.version} + + + maven-javadoc-plugin + ${maven-javadoc-plugin.version} + + + maven-deploy-plugin + ${maven-deploy-plugin.version} + - org.apache.maven.plugins maven-release-plugin - 2.1 + ${maven-release-plugin.version} @@ -255,19 +269,23 @@ org.codehaus.mojo - cobertura-maven-plugin + cobertura-maven-plugin + ${cobertura-maven-plugin} org.apache.maven.plugins - maven-surefire-report-plugin + maven-surefire-report-plugin + ${maven-surefire-report-plugin.version} org.apache.maven.plugins - maven-javadoc-plugin + maven-javadoc-plugin + ${maven-javadoc-plugin} org.apache.maven.plugins maven-project-info-reports-plugin + ${maven-project-info-reports-plugin.version} @@ -280,21 +298,23 @@ org.codehaus.mojo - jxr-maven-plugin + jxr-maven-plugin + ${jxr-maven-plugin.version} org.apache.maven.plugins maven-surefire-report-plugin - 2.4.2 + ${maven-surefire-report-plugin.version} org.codehaus.mojo - jdepend-maven-plugin + jdepend-maven-plugin + ${jdepend-maven-plugin.version} org.apache.maven.plugins maven-changes-plugin - 2.0 + ${maven-changes-plugin.version} ${basedir}/src/site/changes.xml @@ -313,7 +333,7 @@ jboss JBoss Repository Switchboard default - http://repository.jboss.com/maven2/ + http://repository.jboss.com/ true false @@ -324,6 +344,11 @@ http://repository.ops4j.org/maven2/ false + + sonatype-snapshots + https://oss.sonatype.org/content/repositories/snapshots/ + + @@ -363,146 +389,13 @@ - - release + + notest - file://${project.build.directory}/dummy-hg-repo - release-repo-hudson::default::${staging.mvn.repo.url} + true - - - - org.codehaus.mojo - exec-maven-plugin - - - clean-release-dirs - initialize - - exec - - false - - rm - - -rf - ${project.build.directory}/dummy-hg-repo - ${project.build.directory}/target-maven-repo - - - - - create-release-dirs - initialize - - exec - - false - - mkdir - - -p - ${project.build.directory}/dummy-hg-repo - ${project.build.directory}/target-maven-repo - - - - - init-dummy-hg-repo - initialize - - exec - - false - - hg - ${project.build.directory}/dummy-hg-repo - - init - - - - - - - - - - release-commit - - - - org.codehaus.mojo - exec-maven-plugin - - - push-hg - initialize - - exec - - false - - hg - - push - - - - - - - org.codehaus.mojo - wagon-maven-plugin - - ${staging.mvn.repo.url} - ${project.distributionManagement.repository.url} - ${project.distributionManagement.repository.id} - - - - merge-repo - initialize - - merge-maven-repos - - false - - - - - - - - release-cancel - - - - org.codehaus.mojo - exec-maven-plugin - - - strip-hg - initialize - - exec - - false - - - rm - - -rf - .hg - - - - - - - - + - \ No newline at end of file + diff --git a/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcConnectionProviderJdniImpl.java b/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcConnectionProviderJdniImpl.java index 65a4570..5d705b0 100644 --- a/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcConnectionProviderJdniImpl.java +++ b/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcConnectionProviderJdniImpl.java @@ -61,9 +61,6 @@ public class JdbcConnectionProviderJdniImpl implements JdbcConnectionProvider { 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); diff --git a/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcVascBackend.java b/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcVascBackend.java index 073a823..f7c4834 100644 --- a/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcVascBackend.java +++ b/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcVascBackend.java @@ -51,10 +51,19 @@ 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; + //private String idColumn = null; + //private String sqlDelete = null; + //private String sqlUpdate = null; + //private String sqlInsert = null; + + + /** + * @see net.forwardfire.vasc.backend.AbstractVascBackend#isReadOnly() + */ + @Override + public boolean isReadOnly() { + return true; + } /** * @return the JdbcConnectionProvider diff --git a/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcVascBackendXpql.java b/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcVascBackendXpql.java index c821710..0d3c12e 100644 --- a/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcVascBackendXpql.java +++ b/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcVascBackendXpql.java @@ -54,6 +54,14 @@ public class JdbcVascBackendXpql extends AbstractVascBackend { private net.forwardfire.vasc.xpql.query.Query query = null; + /** + * @see net.forwardfire.vasc.backend.AbstractVascBackend#isReadOnly() + */ + @Override + public boolean isReadOnly() { + return true; + } + /** * @return the JdbcConnectionProvider */ diff --git a/vasc-backend/vasc-backend-jpa/pom.xml b/vasc-backend/vasc-backend-jpa/pom.xml index 44d781a..057923e 100644 --- a/vasc-backend/vasc-backend-jpa/pom.xml +++ b/vasc-backend/vasc-backend-jpa/pom.xml @@ -19,13 +19,13 @@ javax.persistence persistence-api - 1.0 + ${persistence-api.version} provided org.hibernate hibernate-annotations - 3.4.0.GA + ${hibernate-annotations.version} provided diff --git a/vasc-backend/vasc-backend-metamodel/pom.xml b/vasc-backend/vasc-backend-metamodel/pom.xml index ed0e903..a614963 100644 --- a/vasc-backend/vasc-backend-metamodel/pom.xml +++ b/vasc-backend/vasc-backend-metamodel/pom.xml @@ -18,7 +18,19 @@ org.eobjects.metamodel MetaModel-full - 3.0-SNAPSHOT + ${metamodel.version} + + com.h2database + h2 + ${h2.version} + test + + + postgresql + postgresql + ${postgresql.version} + test + \ No newline at end of file diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelDataContextJndiDataContext.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelDataContextJndiDataContext.java new file mode 100644 index 0000000..335785a --- /dev/null +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelDataContextJndiDataContext.java @@ -0,0 +1,70 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.backend.metamodel; + +import javax.naming.InitialContext; +import javax.naming.NamingException; + +import org.eobjects.metamodel.DataContext; + +/** + * MetaModelDataContextJndiDataContext provides a data context from jndi. + * + * @author Willem Cazander + * @version 1.0 May 22, 2012 + */ +public class MetaModelDataContextJndiDataContext implements MetaModelDataContextProvider { + + private String jndiName = null; + + public DataContext getDataContext() { + return getDataContextJndi(); + } + + private DataContext getDataContextJndi() { + try { + InitialContext context = new InitialContext(); + DataContext dataContext = (DataContext)context.lookup(jndiName); + if (dataContext == null) { + throw new NullPointerException("Cannot lookup dataContext: "+jndiName); + } + return dataContext; + } catch (NamingException e) { + throw new IllegalStateException("Naming error:"+e.getMessage(),e); + } + } + + /** + * @return the jndiName + */ + public String getJndiName() { + return jndiName; + } + + /** + * @param jndiName the jndiName to set + */ + public void setJndiName(String jndiName) { + this.jndiName = jndiName; + } +} diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelDataContextJndiDataSource.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelDataContextJndiDataSource.java new file mode 100644 index 0000000..b225659 --- /dev/null +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelDataContextJndiDataSource.java @@ -0,0 +1,73 @@ +/* + * 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 javax.naming.InitialContext; +import javax.naming.NamingException; +import javax.sql.DataSource; + +import org.eobjects.metamodel.DataContext; +import org.eobjects.metamodel.jdbc.JdbcDataContext; + +/** + * MetaModelDataContextJndiDataSource provides a connection from datasource for meta model data context. + * + * @author Willem Cazander + * @version 1.0 May 15, 2012 + */ +public class MetaModelDataContextJndiDataSource implements MetaModelDataContextProvider { + + private String jndiName = null; + + public DataContext getDataContext() { + JdbcDataContext dataContext = new JdbcDataContext(getDataSource()); + return dataContext; + } + + private DataSource getDataSource() { + try { + InitialContext context = new InitialContext(); + DataSource datasource = (DataSource)context.lookup(jndiName); + if (datasource == null) { + throw new NullPointerException("Cannot lookup datasource: "+jndiName); + } + return datasource; + } catch (NamingException e) { + throw new IllegalStateException("Naming error:"+e.getMessage(),e); + } + } + + /** + * @return the jndiName + */ + public String getJndiName() { + return jndiName; + } + + /** + * @param jndiName the jndiName to set + */ + public void setJndiName(String jndiName) { + this.jndiName = jndiName; + } +} diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelDataContextMongodb.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelDataContextMongodb.java index fc24a07..ee27275 100644 --- a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelDataContextMongodb.java +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelDataContextMongodb.java @@ -26,6 +26,7 @@ import java.net.UnknownHostException; import org.eobjects.metamodel.DataContext; import org.eobjects.metamodel.mongodb.MongoDbDataContext; +import org.eobjects.metamodel.mongodb.MongoDbDataContextBean; import com.mongodb.DB; import com.mongodb.Mongo; @@ -48,10 +49,15 @@ public class MetaModelDataContextMongodb implements MetaModelDataContextProvider private boolean readonly = false; protected Mongo mongo = null; - //protected DB db = null; public DataContext getDataContext() { - MongoDbDataContext dataContext = new MongoDbDataContext(getMongodbConnection()); + MongoDbDataContextBean dataContext = new MongoDbDataContextBean(getMongodbConnection()); + dataContext.setRegisterMBean(true); + dataContext.start(); + //MongoDbDataContextSchemaDetector detector = new MongoDbDataContextSchemaDetector(); + //detector.setDataCheckSize(10); + //detector.setSearchReference(true); + //DataContext dataContext = detector.new MongoDbDataContextExtended(getMongodbConnection(),detector); return dataContext; } diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelDataContextXmlDom.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelDataContextXmlDom.java new file mode 100644 index 0000000..0a45e57 --- /dev/null +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelDataContextXmlDom.java @@ -0,0 +1,78 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.backend.metamodel; + +import java.io.File; + +import org.eobjects.metamodel.DataContext; +import org.eobjects.metamodel.xml.XmlDomDataContext; + +/** + * MetaModelDataContextXmlDom provides basic auto xml editing support. + * + * @author Willem Cazander + * @version 1.0 May 20, 2012 + */ +public class MetaModelDataContextXmlDom implements MetaModelDataContextProvider { + + private String file = null; + private boolean autoFlattenTables = true; + + + public DataContext getDataContext() { + if (file==null) { + throw new NullPointerException("Can's provided data context with null file."); + } + XmlDomDataContext dataContext = new XmlDomDataContext(new File(file),autoFlattenTables); + return dataContext; + } + + + /** + * @return the file + */ + public String getFile() { + return file; + } + + /** + * @param file the file to set + */ + public void setFile(String file) { + this.file = file; + } + + /** + * @return the autoFlattenTables + */ + public boolean isAutoFlattenTables() { + return autoFlattenTables; + } + + /** + * @param autoFlattenTables the autoFlattenTables to set + */ + public void setAutoFlattenTables(boolean autoFlattenTables) { + this.autoFlattenTables = autoFlattenTables; + } +} diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelDataContextXmlSax.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelDataContextXmlSax.java new file mode 100644 index 0000000..3d3734d --- /dev/null +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelDataContextXmlSax.java @@ -0,0 +1,79 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.backend.metamodel; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import org.eobjects.metamodel.DataContext; +import org.eobjects.metamodel.xml.XmlSaxDataContext; +import org.eobjects.metamodel.xml.XmlSaxTableDef; + +/** + * MetaModelDataContextXml provides basic xml editing support. + * + * @author Willem Cazander + * @version 1.0 May 3, 2012 + */ +public class MetaModelDataContextXmlSax implements MetaModelDataContextProvider { + + private String file = null; + private List tableSchemas = null; + + public MetaModelDataContextXmlSax() { + tableSchemas = new ArrayList(5); + } + + public DataContext getDataContext() { + if (file==null) { + throw new NullPointerException("Can's provided data context with null file."); + } + if (tableSchemas.isEmpty()) { + throw new IllegalStateException("Can't provided data context with zero table schemas."); + } + XmlSaxTableDef[] args = new XmlSaxTableDef[tableSchemas.size()]; + XmlSaxDataContext dataContext = new XmlSaxDataContext(new File(file),tableSchemas.toArray(args)); + return dataContext; + } + + public void addTableSchema(XmlSaxTableDef tableSchema) { + tableSchemas.add(tableSchema); + } + + public void removeTableSchema(XmlSaxTableDef tableSchema) { + tableSchemas.remove(tableSchema); + } + + public List getTableSchemas() { + return tableSchemas; + } + + public void setFile(String file) { + this.file=file; + } + + public String getFile() { + return file; + } +} diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelSchemaAutoEntry.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelSchemaAutoEntry.java index e0af677..83e18f4 100644 --- a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelSchemaAutoEntry.java +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelSchemaAutoEntry.java @@ -33,14 +33,13 @@ import net.forwardfire.vasc.backend.VascBackendControllerLocal; import net.forwardfire.vasc.core.VascController; import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntryControllerLocal; -import net.forwardfire.vasc.core.VascEntryField; -import net.forwardfire.vasc.core.VascLinkEntry; -import net.forwardfire.vasc.core.VascLinkEntryType; +import net.forwardfire.vasc.core.VascEntryFieldLocal; +import net.forwardfire.vasc.core.VascEntryLinkType; +import net.forwardfire.vasc.core.VascEntryLocal; import net.forwardfire.vasc.impl.DefaultVascEntry; import net.forwardfire.vasc.impl.DefaultVascEntryField; -import net.forwardfire.vasc.impl.DefaultVascFactory; -import net.forwardfire.vasc.impl.DefaultVascLinkEntry; +import net.forwardfire.vasc.impl.DefaultVascEntryLink; import net.forwardfire.vasc.impl.ui.VascSelectItemModelEntry; /** @@ -74,11 +73,11 @@ public class MetaModelSchemaAutoEntry { DataContext ds = getDataContextProvider().getDataContext(); for (String table:ds.getDefaultSchema().getTableNames()) { if (getTableInclude()!=null && table.matches(getTableInclude())==false) { - logger.fine("Excluding table: "+table+" from include rule."); + logger.finer("Excluding table: "+table+" from include rule."); continue; } if (getTableExclude()!=null && table.matches(getTableExclude())) { - logger.fine("Excluding table: "+table+" from exclude rule."); + logger.finer("Excluding table: "+table+" from exclude rule."); continue; } createMetaEntry(ds,getEntryPrefix()+"_"+table,table); @@ -90,7 +89,7 @@ public class MetaModelSchemaAutoEntry { } private void createMetaEntry(DataContext ds,String id,String tableName) { - logger.info("Creating entry id: "+id+" of table: "+tableName); + logger.fine("Creating entry id: "+id+" of table: "+tableName); Table metaTable = null; if (tableName==null) { metaTable = ds.getDefaultSchema().getTable(0); @@ -114,7 +113,7 @@ public class MetaModelSchemaAutoEntry { //TODO backend.setRequestReadOnly(true); } - VascEntry ve = new DefaultVascEntry(); + DefaultVascEntry ve = new DefaultVascEntry(); ve.setId(id); ve.setBackendId(id+"_backend"); ve.setPrimaryKeyFieldId(backend.getTableId()); @@ -123,10 +122,10 @@ public class MetaModelSchemaAutoEntry { for (Relationship rs:metaTable.getRelationships()) { logger.finer("Found relation FT: "+rs.getForeignTable().getName()+" PT: "+rs.getPrimaryTable().getName()); if (tableName.equals(rs.getForeignTable().getName())==false) { - logger.info("Creating Link entry for: "+rs.getForeignColumns()[0].getName()+" of table: "+rs.getForeignTable().getName()); + logger.finer("Creating Link entry for: "+rs.getForeignColumns()[0].getName()+" of table: "+rs.getForeignTable().getName()); createLinkEntry(rs,ve,metaTable,id+"_"+rs.getForeignTable().getName()+"_"+rs.getForeignColumns()[0].getName()+"_link"); } else { - logger.info("Creating List entry for: "+rs.getPrimaryColumns()[0].getName()+" of table: "+rs.getPrimaryTable().getName()); + logger.finer("Creating List entry for: "+rs.getPrimaryColumns()[0].getName()+" of table: "+rs.getPrimaryTable().getName()); createListEntry(rs,ve,metaTable,id+"_"+rs.getPrimaryTable().getName()+"_"+rs.getPrimaryColumns()[0].getName()+"_list"); } } @@ -134,15 +133,12 @@ public class MetaModelSchemaAutoEntry { try { ((VascBackendControllerLocal)getVascController().getVascBackendController()).addVascBackend(backend); ((VascEntryControllerLocal)getVascController().getVascEntryController()).addVascEntry(ve); - - // mm TODO rm this fill which adds the global actions ... and show updated tree in editor - DefaultVascFactory.fillVascControllerLocalEntries((VascEntryControllerLocal) getVascController().getVascEntryController(), getVascController()); } catch (Exception ee) { ee.printStackTrace(); } } - private void createLinkEntry(Relationship rs2,VascEntry ve,Table metaTable,String id) { + private void createLinkEntry(Relationship rs2,VascEntryLocal ve,Table metaTable,String id) { MetaModelVascBackend backendLink = new MetaModelVascBackend(); backendLink.setId(id+"_backend"); backendLink.setDataContextProvider(getDataContextProvider()); @@ -159,7 +155,7 @@ public class MetaModelSchemaAutoEntry { backendLink.setTableId(cols[0].getName()); } - VascEntry veLink = new DefaultVascEntry(); + DefaultVascEntry veLink = new DefaultVascEntry(); veLink.setId(id); veLink.setBackendId(id+"_backend"); veLink.setPrimaryKeyFieldId(backendLink.getTableId()); @@ -171,7 +167,7 @@ public class MetaModelSchemaAutoEntry { //logger.info("Creating Link entry for: "+rs.getForeignColumns()[0].getName()+" of table: "+rs.getForeignTable().getName()); //createLinkEntry(rs,ve,rs2.getForeignTable(),id+"_"+rs.getForeignTable().getName()+"_"+rs.getForeignColumns()[0].getName()+"_link"); } else { - logger.info("Creating List entry for: "+rs.getPrimaryColumns()[0].getName()+" of table: "+rs.getPrimaryTable().getName()); + logger.fine("Creating List entry for: "+rs.getPrimaryColumns()[0].getName()+" of table: "+rs.getPrimaryTable().getName()); createListEntry(rs,veLink,rs2.getForeignTable(),id+"_"+rs.getPrimaryTable().getName()+"_"+rs.getPrimaryColumns()[0].getName()+"_list"); } } @@ -180,13 +176,13 @@ public class MetaModelSchemaAutoEntry { ((VascBackendControllerLocal)getVascController().getVascBackendController()).addVascBackend(backendLink); ((VascEntryControllerLocal)getVascController().getVascEntryController()).addVascEntry(veLink); - VascLinkEntry vle = new DefaultVascLinkEntry(); + DefaultVascEntryLink vle = new DefaultVascEntryLink(); vle.setId(id+"Link"); - vle.setVascLinkEntryType(VascLinkEntryType.DEFAULT_TYPE); + vle.setVascLinkEntryType(VascEntryLinkType.DEFAULT_TYPE); vle.setVascEntryId(id); vle.addEntryParameterFieldId(rs2.getForeignColumns()[0].getName(), rs2.getPrimaryColumns()[0].getName()); - ve.addVascLinkEntry(vle); + ve.addVascEntryLink(vle); } catch (Exception e) { e.printStackTrace(); @@ -209,13 +205,13 @@ public class MetaModelSchemaAutoEntry { } else { backendLink.setTableId(cols[0].getName()); } - VascEntry veLink = new DefaultVascEntry(); + DefaultVascEntry veLink = new DefaultVascEntry(); veLink.setId(id); veLink.setBackendId(id+"_backend"); veLink.setPrimaryKeyFieldId(backendLink.getTableId()); createFields(veLink,cols); try { - VascEntryField vef = ve.getVascEntryFieldById(rs.getForeignColumns()[0].getName()); + VascEntryFieldLocal vef = (VascEntryFieldLocal)ve.getVascEntryFieldById(rs.getForeignColumns()[0].getName()); if (vef==null) { logger.warning("Could not find: "+rs.getForeignColumns()[0].getName()+" in ve: "+ve.getId()); return; @@ -234,9 +230,10 @@ public class MetaModelSchemaAutoEntry { } } - private void createFields(VascEntry ve,Column[] cols) { + private void createFields(VascEntryLocal ve,Column[] cols) { for (Column c:cols) { - VascEntryField vef = new DefaultVascEntryField(c.getName()); + DefaultVascEntryField vef = new DefaultVascEntryField(); + vef.setId(c.getName()); vef.setVascEntryFieldType(getVascController().getVascEntryFieldTypeController().getVascEntryFieldTypeByClass(c.getType().getJavaEquivalentClass())); if (vef.getId().equals(ve.getPrimaryKeyFieldId())) { diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelVascBackend.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelVascBackend.java index 7a3c0fc..e2571be 100644 --- a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelVascBackend.java +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelVascBackend.java @@ -24,29 +24,27 @@ package net.forwardfire.vasc.backend.metamodel; import java.util.ArrayList; import java.util.Date; -import java.util.HashMap; import java.util.Iterator; import java.util.List; -import java.util.Map; +import java.util.logging.Logger; -import org.eobjects.metamodel.UpdateCallback; -import org.eobjects.metamodel.UpdateScript; +import org.eobjects.metamodel.DataContext; import org.eobjects.metamodel.UpdateableDataContext; import org.eobjects.metamodel.data.DataSet; import org.eobjects.metamodel.data.Row; -import org.eobjects.metamodel.insert.RowInsertionBuilder; import org.eobjects.metamodel.query.Query; import org.eobjects.metamodel.query.SelectItem; import org.eobjects.metamodel.query.builder.SatisfiedQueryBuilder; import org.eobjects.metamodel.query.builder.SatisfiedWhereBuilder; import org.eobjects.metamodel.schema.Schema; import org.eobjects.metamodel.schema.Table; -import org.eobjects.metamodel.update.RowUpdationBuilder; 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.backend.metamodel.crud.CrudDataContext; +import net.forwardfire.vasc.backend.metamodel.crud.UpdateableRow; +import net.forwardfire.vasc.backend.metamodel.crud.CrudDataContextImpl; +import net.forwardfire.vasc.backend.metamodel.crud.UpdateableRowMapImpl; import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntryField; import net.forwardfire.vasc.core.VascException; @@ -61,19 +59,55 @@ import net.forwardfire.vasc.core.entry.VascEntryRecordCreator; */ public class MetaModelVascBackend extends AbstractVascBackend { + private Logger logger = Logger.getLogger(MetaModelVascBackend.class.getName()); private MetaModelDataContextProvider dataContextProvider = null; - private UpdateableDataContext dataContext = null; + private DataContext dataContext = null; + private CrudDataContext crudDataContext = null; private String table = null; private String tableId = null; + /** + * Returns casted version of data context. + */ + private UpdateableDataContext getUpdateableDataContext() { + return (UpdateableDataContext)dataContext; + } + + /** + * Returns true when data context in updateable. + */ + private boolean isUpdateableDataContext() { + return dataContext instanceof UpdateableDataContext; + } + + /** + * @see net.forwardfire.vasc.backend.AbstractVascBackend#isReadOnly() + */ + @Override + public boolean isReadOnly() { + return isUpdateableDataContext()==false; + } + /** * @see net.forwardfire.vasc.backend.AbstractVascBackend#startBackend() */ @Override public void startBackend() { - dataContext = (UpdateableDataContext)dataContextProvider.getDataContext(); + if (table==null) { + throw new NullPointerException("Can't start with null table."); + } + if (table.isEmpty()) { + throw new NullPointerException("Can't start with empty table."); + } + long startTime = System.currentTimeMillis(); + dataContext = dataContextProvider.getDataContext(); + if (isUpdateableDataContext()) { + crudDataContext = new CrudDataContextImpl(getUpdateableDataContext()); + } + long stopTime = System.currentTimeMillis(); + logger.info(dataContext.getClass().getSimpleName()+" created for: "+table+" in: "+(stopTime-startTime)+" ms."); } - + /** * @see net.forwardfire.vasc.backend.AbstractVascBackend#stopBackend() */ @@ -163,89 +197,68 @@ public class MetaModelVascBackend extends AbstractVascBackend { public List execute(VascBackendState state) throws VascException { Schema schema = dataContext.getDefaultSchema(); Table t = schema.getTableByName(table); + if (t==null) { + throw new VascException("Could not get meta table for: '"+table+"'."); + } Query q = createFilterQuery(state,t,false); if (isPageable() && state.getPageSize()>0) { q.setFirstRow(state.getPageIndex()); q.setMaxRows(state.getPageSize()); } + if (crudDataContext!=null) { + DataSet ds = crudDataContext.executeQuery(q); + List result = new ArrayList(50); + result.addAll(ds.toRows()); + ds.close(); + return result; + } + DataSet ds = dataContext.executeQuery(q); List result = new ArrayList(50); while (ds.next()) { Row row = ds.getRow(); SelectItem[] cols = row.getSelectItems(); - Map map = new HashMap(cols.length); + List keys = new ArrayList(1); + keys.add(cols[0].getColumn().getName()); + UpdateableRowMapImpl rowMM = new UpdateableRowMapImpl(dataContext.getDefaultSchema().getTableByName(table),keys); for (SelectItem col:cols) { Object value = row.getValue(col); - map.put(col.getColumn().getName(), value); + rowMM.setValue(col, value); } - result.add(map); + result.add(rowMM); } ds.close(); return result; } - @SuppressWarnings("unchecked") public void persist(Object object) throws VascException { - final Map map = (Map)object; - dataContext.executeUpdate(new UpdateScript() { - public void run(UpdateCallback backendImpl) { - RowInsertionBuilder query = backendImpl.insertInto(table); - for (String key:map.keySet()) { - Object value = map.get(key); - query.value(key, value); - } - query.execute(); - } - }); - + if (crudDataContext==null) { + return; + } + crudDataContext.persist((UpdateableRow) object); } - @SuppressWarnings("unchecked") public Object merge(Object object) throws VascException { - final Map map = (Map)object; - dataContext.executeUpdate(new UpdateScript() { - public void run(UpdateCallback backendImpl) { - - RowUpdationBuilder query = null; - if (map.get(tableId) instanceof Number) { - query = backendImpl.update(table).where(tableId).equals((Number)map.get(tableId)); - } else { - query = backendImpl.update(table).where(tableId).equals(map.get(tableId).toString()); - } - for (String key:map.keySet()) { - if (key.equals(tableId)) { - continue; // skip id; - } - Object value = map.get(key); - query.value(key, value); - } - query.execute(); - } - }); - return object; + if (crudDataContext==null) { + return object; + } + return crudDataContext.merge((UpdateableRow) object); } - @SuppressWarnings("unchecked") public void delete(Object object) throws VascException { - final Map map = (Map)object; - dataContext.executeUpdate(new UpdateScript() { - public void run(UpdateCallback backendImpl) { - if (map.get(tableId) instanceof Number) { - backendImpl.deleteFrom(table).where(tableId).equals((Number)map.get(tableId)).execute(); - } else { - backendImpl.deleteFrom(table).where(tableId).equals(map.get(tableId).toString()).execute(); - } - } - }); + if (crudDataContext==null) { + return; + } + crudDataContext.delete((UpdateableRow) object); } public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) { - return new MapVascEntryFieldValue(); + return new RowVascEntryFieldValue(); } public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) { - return new MapVascEntryRecordCreator(); + return new RowVascEntryRecordCreator(crudDataContext,crudDataContext.getDefaultSchema().getTableByName(table)); } /** diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MongoDbDataContextSchemaDetector.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MongoDbDataContextSchemaDetector.java new file mode 100644 index 0000000..dff0b31 --- /dev/null +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MongoDbDataContextSchemaDetector.java @@ -0,0 +1,479 @@ +package net.forwardfire.vasc.backend.metamodel; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.SortedMap; +import java.util.TreeMap; +import java.util.Map.Entry; + +import org.bson.types.ObjectId; +import org.eobjects.metamodel.MetaModelException; +import org.eobjects.metamodel.QueryPostprocessDataContext; +import org.eobjects.metamodel.data.AbstractDataSet; +import org.eobjects.metamodel.data.DataSet; +import org.eobjects.metamodel.data.DefaultRow; +import org.eobjects.metamodel.data.FirstRowDataSet; +import org.eobjects.metamodel.data.MaxRowsDataSet; +import org.eobjects.metamodel.data.Row; +import org.eobjects.metamodel.query.FilterItem; +import org.eobjects.metamodel.query.FromItem; +import org.eobjects.metamodel.query.Query; +import org.eobjects.metamodel.query.SelectItem; +import org.eobjects.metamodel.schema.Column; +import org.eobjects.metamodel.schema.ColumnType; +import org.eobjects.metamodel.schema.MutableColumn; +import org.eobjects.metamodel.schema.MutableRelationship; +import org.eobjects.metamodel.schema.MutableSchema; +import org.eobjects.metamodel.schema.MutableTable; +import org.eobjects.metamodel.schema.Relationship; +import org.eobjects.metamodel.schema.Schema; +import org.eobjects.metamodel.schema.Table; +import org.eobjects.metamodel.schema.TableType; + +import com.mongodb.BasicDBList; +import com.mongodb.BasicDBObject; +import com.mongodb.DB; +import com.mongodb.DBCollection; +import com.mongodb.DBCursor; +import com.mongodb.DBObject; + +public class MongoDbDataContextSchemaDetector /* implements MetaModelSchemaDetector */ { + + private int dataCheckSize = 100; + private boolean searchReference = true; + + public MongoDbDataContextSchemaDetector() { + } + + public class MongoDbDataContextExtended extends QueryPostprocessDataContext /* MongoDbDataContext */ { + protected DB mongoDb; + protected Schema schema; + protected MongoDbDataContextSchemaDetector walker; + public MongoDbDataContextExtended(DB mongoDb,MongoDbDataContextSchemaDetector walker) { + this.mongoDb=mongoDb; + this.walker=walker; + } + @Override + protected Schema getMainSchema() throws MetaModelException { + if (schema!=null) { + return schema; + } + schema = walker.detectSchema(mongoDb, getMainSchemaName()); + return schema; + } + protected String getMainSchemaName() throws MetaModelException { + return mongoDb.getName(); + } + protected DataSet materializeMainSchemaTable(Table table, Column[] columns, int maxRows) { + return materializeMainSchemaTableInternal(table, columns, null, maxRows, true); + } + + // Overidded these method because they do not use the getMainSchema() method + public DataSet executeQuery(Query query) { + // Check for queries containing only simple selects and where clauses, + // or if it is a COUNT(*) query. + + // if from clause only contains a main schema table + List fromItems = query.getFromClause().getItems(); + if (fromItems.size() == 1 && fromItems.get(0).getTable() != null + && fromItems.get(0).getTable().getSchema() == getMainSchema()) { + final Table table = fromItems.get(0).getTable(); + + // if GROUP BY, HAVING and ORDER BY clauses are not specified + if (query.getGroupByClause().isEmpty() && query.getHavingClause().isEmpty() + && query.getOrderByClause().isEmpty()) { + + final List whereItems = query.getWhereClause().getItems(); + + // if all of the select items are "pure" column selection + boolean allSelectItemsAreColumns = true; + List selectItems = query.getSelectClause().getItems(); + + // if it is a + // "SELECT [columns] FROM [table] WHERE [conditions]" + // query. + for (SelectItem selectItem : selectItems) { + if (selectItem.getFunction() != null || selectItem.getColumn() == null) { + allSelectItemsAreColumns = false; + break; + } + } + + if (allSelectItemsAreColumns) { + //logger.debug("Query can be expressed in full MongoDB, no post processing needed."); + + // prepare for a non-post-processed query + Column[] columns = new Column[selectItems.size()]; + for (int i = 0; i < columns.length; i++) { + columns[i] = selectItems.get(i).getColumn(); + } + + DataSet dataSet = materializeMainSchemaTableInternal(table, columns, whereItems, -1, false); + if (query.getFirstRow() != null) { + dataSet = new FirstRowDataSet(dataSet, query.getFirstRow()); + } + if (query.getMaxRows() != null) { + dataSet = new MaxRowsDataSet(dataSet, query.getMaxRows()); + } + return dataSet; + } + } + } + //logger.debug("Query will be simplified for MongoDB and post processed."); + return super.executeQuery(query); + } + private DataSet materializeMainSchemaTableInternal(Table table, Column[] columns, List whereItems, + int maxRows, boolean queryPostProcessed) { + final DBCollection collection = mongoDb.getCollection(table.getName()); + + final DBObject query = createMongoDbQuery(table, whereItems); + + //logger.info("Executing MongoDB 'find' query: {}", query); + DBCursor cursor = collection.find(query); + + if (maxRows > 0) { + cursor = cursor.limit(maxRows); + } + + return new MongoDbDataSet(cursor, columns, queryPostProcessed); + } + final class MongoDbDataSet extends AbstractDataSet { + + //private static final Logger logger = LoggerFactory + // .getLogger(MongoDbDataSet.class); + + private final DBCursor _cursor; + private final SelectItem[] _selectItems; + private final boolean _queryPostProcessed; + + private boolean _closed; + private volatile DBObject _dbObject; + + public MongoDbDataSet(DBCursor cursor, Column[] columns, + boolean queryPostProcessed) { + _cursor = cursor; + _selectItems = new SelectItem[columns.length]; + for (int i = 0; i < columns.length; i++) { + _selectItems[i] = new SelectItem(columns[i]); + } + _queryPostProcessed = queryPostProcessed; + _closed = false; + } + + public boolean isQueryPostProcessed() { + return _queryPostProcessed; + } + + public SelectItem[] getSelectItems() { + return _selectItems; + } + + @Override + public void close() { + super.close(); + _cursor.close(); + _closed = true; + } + + @Override + protected void finalize() throws Throwable { + super.finalize(); + if (!_closed) { + // logger.warn( + // "finalize() invoked, but DataSet is not closed. Invoking close() on {}", + // this); + close(); + } + } + + public boolean next() { + if (_cursor.hasNext()) { + _dbObject = _cursor.next(); + return true; + } else { + _dbObject = null; + return false; + } + } + + public Row getRow() { + if (_dbObject == null) { + return null; + } + + final Object[] values = new Object[_selectItems.length]; + for (int i = 0; i < values.length; i++) { + String key = _selectItems[i].getColumn().getName(); + Object value = _dbObject.get(key); + values[i] = toValue(_selectItems[i].getColumn(), value); + } + return new DefaultRow(_selectItems, values); + } + + private Object toValue(Column column, Object value) { + if (value instanceof List) { + return value; + } + if (value instanceof DBObject) { + DBObject basicDBObject = (DBObject) value; + return basicDBObject.toMap(); + } + return value; + } + + } + + protected BasicDBObject createMongoDbQuery(Table table, List whereItems) { + assert getMainSchema() == table.getSchema(); + + final BasicDBObject query = new BasicDBObject(); + if (whereItems != null && !whereItems.isEmpty()) { + for (FilterItem item : whereItems) { + convertToCursorObject(query, item); + } + } + + return query; + } + private void convertToCursorObject(BasicDBObject query, FilterItem item) { + if (item.isCompoundFilter()) { + + BasicDBList orList = new BasicDBList(); + + final FilterItem[] childItems = item.getChildItems(); + for (FilterItem childItem : childItems) { + BasicDBObject childObject = new BasicDBObject(); + convertToCursorObject(childObject, childItem); + orList.add(childObject); + } + + query.put("$or", orList); + + } else { + + final Column column = item.getSelectItem().getColumn(); + final String columnName = column.getName(); + final Object operand = item.getOperand(); + final String operatorName = getOperatorName(item); + + final BasicDBObject existingFilterObject = (BasicDBObject) query.get(columnName); + if (existingFilterObject == null) { + if (operatorName == null) { + query.put(columnName, operand); + } else { + query.put(columnName, new BasicDBObject(operatorName, operand)); + } + } else { + if (operatorName == null) { + throw new IllegalStateException("Cannot retrieve records for a column with two EQUALS_TO operators"); + } else { + existingFilterObject.append(operatorName, operand); + } + } + } + } + @SuppressWarnings("deprecation") + private String getOperatorName(FilterItem item) { + final String operatorName; + switch (item.getOperator()) { + case EQUALS_TO: + operatorName = null; + break; + case LESS_THAN: + case LOWER_THAN: + operatorName = "$lt"; + break; + case GREATER_THAN: + case HIGHER_THAN: + operatorName = "$gt"; + break; + case DIFFERENT_FROM: + operatorName = "$ne"; + break; + case IN: + operatorName = "$in"; + break; + default: + throw new IllegalStateException("Unsupported operator type: " + item.getOperator()); + } + return operatorName; + } + + protected void addTable(MutableTable table) { + if (getMainSchema() instanceof MutableSchema) { + MutableSchema mutableSchema = (MutableSchema) getMainSchema(); + mutableSchema.addTable(table); + } else { + throw new UnsupportedOperationException("Schema is not mutable"); + } + } + } + + public Schema detectSchema(Object nativeBackendConnection,String schemaName) { + if ((nativeBackendConnection instanceof DB)==false) { + throw new RuntimeException("Can only work with DB instance not with: "+nativeBackendConnection); + } + DB db = (DB)nativeBackendConnection; + MutableSchema schema = new MutableSchema(schemaName); + for (MutableTable tableDef : detectSchemaTables(db)) { + tableDef.setSchema(schema); + schema.addTable(tableDef); + } + return schema; + } + + protected MutableTable[] detectSchemaTables(DB db) { + Set collectionNames = db.getCollectionNames(); + Map tables = new HashMap(collectionNames.size()); + for (String collectionName : collectionNames) { + PublicTable table = detectTable(db, collectionName); + tables.put(collectionName, table); + } + + // Check for object id + for (String collectionName:objectIdRef.keySet()) { + Map refMap = objectIdRef.get(collectionName); + if (refMap==null) { + continue; + } + for (String columnName:refMap.keySet()) { + ObjectId objectId = refMap.get(columnName); + + for (String colName : collectionNames) { + Column primaryColumn = findColumnRef(db,colName,tables,objectId,columnName); + if (primaryColumn==null) { + continue; + } + PublicTable t = tables.get(collectionName); + Column foreignColumn = t.getColumnByName(columnName); + t.addRelationship(MutableRelationship.createRelationship(primaryColumn, foreignColumn)); + } + } + } + + MutableTable[] result = new MutableTable[collectionNames.size()]; + return new ArrayList(tables.values()).toArray(result); + } + + Map> objectIdRef = new HashMap>(20); + + protected Column findColumnRef(DB db, String collectionName,Map tables,ObjectId objectId,String colName) { + DBCollection collection = db.getCollection(collectionName); + DBObject query = new BasicDBObject(); + query.put("_id", objectId); + DBCursor cursor = collection.find(query).limit(dataCheckSize); + try { + if (cursor.hasNext()) { + PublicTable t = tables.get(collectionName); + return t.getColumnByName("_id"); + } + } finally { + if (cursor!=null) { + cursor.close(); + } + } + return null; + } + + protected PublicTable detectTable(DB db, String collectionName) { + final DBCollection collection = db.getCollection(collectionName); + final DBCursor cursor = collection.find().limit(dataCheckSize); + final SortedMap>> columnsAndTypes = new TreeMap>>(); + while (cursor.hasNext()) { + DBObject row = cursor.next(); + Set keysInObject = row.keySet(); + for (String key : keysInObject) { + Set> types = columnsAndTypes.get(key); + if (types == null) { + types = new HashSet>(); + columnsAndTypes.put(key, types); + } + Object value = row.get(key); + if (value != null) { + types.add(value.getClass()); + } + if ("_id".equals(key)==false && value instanceof ObjectId) { + Map map = objectIdRef.get(collectionName); + if (map==null) { + map = new HashMap(10); + objectIdRef.put(collectionName,map); + } + map.put(key, (ObjectId)value); + } + } + } + cursor.close(); + + final String[] columnNames = new String[columnsAndTypes.size()]; + final ColumnType[] columnTypes = new ColumnType[columnsAndTypes.size()]; + + int i = 0; + for (Entry>> columnAndTypes : columnsAndTypes.entrySet()) { + final String columnName = columnAndTypes.getKey(); + final Set> columnTypeSet = columnAndTypes.getValue(); + final Class columnType; + if (columnTypeSet.size() == 1) { + columnType = columnTypeSet.iterator().next(); + } else { + columnType = Object.class; + } + columnNames[i] = columnName; + if (columnType == ObjectId.class) { + columnTypes[i] = ColumnType.ROWID; + } else { + columnTypes[i] = ColumnType.convertColumnType(columnType); + } + i++; + } + + PublicTable tableSchema = new PublicTable(collectionName,TableType.TABLE); + for (int y = 0; y < columnNames.length; y++) { + MutableColumn col = new MutableColumn(columnNames[y], columnTypes[y], tableSchema, i, true); + tableSchema.addColumn(col); + } + return tableSchema; // new SimpleTableDef(collectionName, columnNames, columnTypes); + } + + // Override to make public + class PublicTable extends MutableTable { + public PublicTable(String name,TableType type) { + super(name,type); + } + @Override + public void addRelationship(Relationship relation) { + super.addRelationship(relation); + } + } + + /** + * @return the dataCheckSize + */ + public int getDataCheckSize() { + return dataCheckSize; + } + + /** + * @param dataCheckSize the dataCheckSize to set + */ + public void setDataCheckSize(int dataCheckSize) { + this.dataCheckSize = dataCheckSize; + } + + /** + * @return the searchReference + */ + public boolean isSearchReference() { + return searchReference; + } + + /** + * @param searchReference the searchReference to set + */ + public void setSearchReference(boolean searchReference) { + this.searchReference = searchReference; + } +} diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/RowVascEntryFieldValue.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/RowVascEntryFieldValue.java new file mode 100644 index 0000000..2072e6e --- /dev/null +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/RowVascEntryFieldValue.java @@ -0,0 +1,71 @@ +package net.forwardfire.vasc.backend.metamodel; + +import org.eobjects.metamodel.data.Row; +import org.eobjects.metamodel.query.SelectItem; + +import net.forwardfire.vasc.backend.metamodel.crud.UpdateableRow; +import net.forwardfire.vasc.core.VascEntryField; +import net.forwardfire.vasc.core.VascException; +import net.forwardfire.vasc.core.entry.VascEntryFieldValue; + +public class RowVascEntryFieldValue implements VascEntryFieldValue { + + private static final long serialVersionUID = -806674640688182132L; + + /** + * @see net.forwardfire.vasc.core.entry.VascEntryFieldValue#getValue(net.forwardfire.vasc.core.VascEntryField, java.lang.Object) + */ + public Object getValue(VascEntryField field, Object record) throws VascException { + if (field==null) { + throw new NullPointerException("Can't get value of null field."); + } + if (field.getBackendName()==null) { + throw new NullPointerException("Can't get value of null backendName field."); + } + if (record==null) { + throw new NullPointerException("Can't get value of null object."); + } + if (record instanceof UpdateableRow) { + UpdateableRow row = (UpdateableRow)record; + return row.getValue(field.getBackendName()); + } + Row row = (Row)record; + Object fieldValue = row.getValue(indexOf(field.getBackendName(),row)); + return fieldValue; + } + + private int indexOf(String columnName,Row row) { // RM after MM Row update + if (columnName==null) { + return UpdateableRow.INDEX_NOT_FOUND; + } + int index = 0; + for (SelectItem si:row.getSelectItems()) { + if (si.getColumn().getName().equals(columnName)) { + return index; + } + index++; + } + return UpdateableRow.INDEX_NOT_FOUND; + } + + /** + * @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 { + Object fieldValue = getValue(field,record); + if (fieldValue==null) { + fieldValue = ""; + } + return fieldValue.toString(); + } + + /** + * @see net.forwardfire.vasc.core.entry.VascEntryFieldValue#setValue(net.forwardfire.vasc.core.VascEntryField, java.lang.Object, java.lang.Object) + */ + public void setValue(VascEntryField field, Object record,Object value) throws VascException { + if (record instanceof UpdateableRow) { + UpdateableRow row = (UpdateableRow)record; + row.setValue(field.getBackendName(), value); + } + } +} \ No newline at end of file diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/RowVascEntryRecordCreator.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/RowVascEntryRecordCreator.java new file mode 100644 index 0000000..cd23fbf --- /dev/null +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/RowVascEntryRecordCreator.java @@ -0,0 +1,28 @@ +package net.forwardfire.vasc.backend.metamodel; + +import org.eobjects.metamodel.schema.Table; + +import net.forwardfire.vasc.backend.metamodel.crud.CrudDataContext; +import net.forwardfire.vasc.backend.metamodel.crud.UpdateableRow; +import net.forwardfire.vasc.core.VascEntry; +import net.forwardfire.vasc.core.entry.VascEntryRecordCreator; + +public class RowVascEntryRecordCreator implements VascEntryRecordCreator { + + private static final long serialVersionUID = -1182678362367989090L; + private CrudDataContext dataContext = null; + private Table table = null; + + public RowVascEntryRecordCreator(CrudDataContext dataContext,Table table) { + this.dataContext=dataContext; + this.table=table; + } + + public Class getObjectClass() { + return UpdateableRow.class; + } + + public Object newRecord(VascEntry entry) throws Exception { + return dataContext.createRow(table); + } +} \ No newline at end of file diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/bundle/ResourceBundleDataContext.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/bundle/ResourceBundleDataContext.java new file mode 100644 index 0000000..779a1f6 --- /dev/null +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/bundle/ResourceBundleDataContext.java @@ -0,0 +1,240 @@ +package net.forwardfire.vasc.backend.metamodel.bundle; + +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Properties; +import java.util.ResourceBundle; + +import org.eobjects.metamodel.MetaModelException; +import org.eobjects.metamodel.QueryPostprocessDataContext; +import org.eobjects.metamodel.UpdateScript; +import org.eobjects.metamodel.UpdateableDataContext; +import org.eobjects.metamodel.data.AbstractDataSet; +import org.eobjects.metamodel.data.DataSet; +import org.eobjects.metamodel.data.DefaultRow; +import org.eobjects.metamodel.data.Row; +import org.eobjects.metamodel.query.FilterItem; +import org.eobjects.metamodel.query.SelectItem; +import org.eobjects.metamodel.schema.Column; +import org.eobjects.metamodel.schema.MutableColumn; +import org.eobjects.metamodel.schema.MutableSchema; +import org.eobjects.metamodel.schema.MutableTable; +import org.eobjects.metamodel.schema.Schema; +import org.eobjects.metamodel.schema.Table; +import org.eobjects.metamodel.schema.TableType; + +/** + * ResourceBundleDataContext is updatable context for file based data source. + * Will try to load all supported locals by jvm as tables. (except for URL) + * + * @author Willem Cazander + * @version 1.0 May 26, 2012 + */ +public class ResourceBundleDataContext extends QueryPostprocessDataContext implements UpdateableDataContext { + + protected static final String DEFAULT_CHAR_SET = "UTF-8"; + protected ResourceBundleUpdateExecutor resourceBundleUpdateExecutor = null; + protected ResourceBundleDataControl bundleDataControl = null; + protected String mainSchemaName = null; + protected Charset charSet = null; + + private ResourceBundleDataContext(Charset charSet) { + if (charSet==null) { + throw new NullPointerException("Can't start with null charSet"); + } + this.charSet = charSet; + } + + public ResourceBundleDataContext(String resourceBundle) { + this(resourceBundle,Charset.forName(DEFAULT_CHAR_SET)); + } + + public ResourceBundleDataContext(String resourceBundle,Charset charSet) { + this(charSet); + if (resourceBundle==null) { + throw new NullPointerException("Can't start with null resourceBundle"); + } + init(resourceBundle); + } + + public ResourceBundleDataContext(File resourceBundle) { + this(resourceBundle,Charset.forName(DEFAULT_CHAR_SET)); + } + + public ResourceBundleDataContext(File resourceBundle,Charset charSet) { + this(charSet); + if (resourceBundle==null) { + throw new NullPointerException("Can't start with null resourceBundle"); + } + init(resourceBundle); + } + + public ResourceBundleDataContext(URL resourceBundle) { + this(resourceBundle,Charset.forName(DEFAULT_CHAR_SET)); + } + + public ResourceBundleDataContext(URL resourceBundle,Charset charSet) { + this(charSet); + if (resourceBundle==null) { + throw new NullPointerException("Can't start with null resourceBundle"); + } + init(resourceBundle); + } + + /** + * Init ResourceBundleDataContext to use diffect source backends. + */ + protected void init(Object source) { + if (source==null) { + throw new NullPointerException("Can't init with null source"); + } + if (bundleDataControl!=null) { + throw new NullPointerException("Only one init allowed."); // can't override refreshSchema to reinit again. + } + + // Setup data source + String bundleBaseName = null; + if (source instanceof File) { + File baseFile = (File)source; + bundleBaseName = baseFile.getName(); + bundleDataControl = new ResourceBundleDataControl(charSet,baseFile); + } else if (source instanceof URL) { + URL baseUrl = (URL)source; + bundleBaseName = baseUrl.getFile(); + bundleDataControl = new ResourceBundleDataControl(charSet,baseUrl); + } else { + bundleBaseName = source.toString(); + bundleDataControl = new ResourceBundleDataControl(charSet); + } + mainSchemaName = cleanMainSchemaName(bundleBaseName); + + // Load all data + //ResourceBundle.getBundle(bundleBaseName,bundleDataControl); + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + if (cl==null) { cl=getClass().getClassLoader(); } + try { + bundleDataControl.newBundle(bundleBaseName, Locale.getDefault(), null, cl, false); + } catch (Exception e) { + e.printStackTrace(); + } + + // Start Query executor + resourceBundleUpdateExecutor = new ResourceBundleUpdateExecutor(this,bundleDataControl); + } + + // TODO check where static verion is. + protected String cleanMainSchemaName(String name) { + if (name.endsWith(ResourceBundleDataControl.BUNDLE_EXTENSION)) { + name = name.substring(0,name.indexOf(ResourceBundleDataControl.BUNDLE_EXTENSION)-1); + } + StringBuffer buffer = new StringBuffer(name.length()); + for (char c:name.toCharArray()) { + if (Character.isDigit(c)) { + buffer.append(c); + } else if (Character.isLetter(c)) { + buffer.append(c); + } else { + buffer.append('_'); + } + } + return buffer.toString(); + } + + public boolean isDataContextWritable() { + return bundleDataControl.isWritable(); + } + + protected MutableTable createTable(Schema schema,String name) { + MutableTable table = new MutableTable(name, TableType.TABLE, schema); + + MutableColumn idColumn = new MutableColumn("id"); + //idColumn.setColumnNumber(0); + idColumn.setIndexed(true); + idColumn.setNullable(false); + //idColumn.setPrimaryKey(true); + + MutableColumn keyColumn = new MutableColumn("key"); + keyColumn.setColumnNumber(1); + keyColumn.setNullable(false); + + MutableColumn valueColumn = new MutableColumn("value"); + valueColumn.setColumnNumber(2); + valueColumn.setNullable(false); + + table.addColumn(idColumn); + table.addColumn(keyColumn); + table.addColumn(valueColumn); + + return table; + } + + // ======== Interface + + + @Override + protected Number executeCountQuery(Table table, List whereItems, boolean functionApproximationAllowed) { + return null; + } + + @Override + protected Schema getMainSchema() throws MetaModelException { + String schemaName = getDefaultSchemaName(); + MutableSchema schema = new MutableSchema(schemaName); + for (String bundleName:bundleDataControl.getBundleNames()) { + schema.addTable(createTable(schema,bundleName)); + } + return schema; + } + + // TODO: move to SelectItem + static public SelectItem[] convertColumns(Column[] cols) { + SelectItem[] selectItems = new SelectItem[cols.length]; + for (int i=0;i result = new ArrayList(200); + for (Object keyO:data.keySet()) { + String keyId = Integer.toString(keyO.hashCode()); + String key = (String)keyO; + String value = data.getProperty(key); + result.add(new DefaultRow(selectItems, new Object[] {keyId,key,value})); + } + final Iterator resultData = result.iterator(); + return new AbstractDataSet() { + int resultCount = 0; + public SelectItem[] getSelectItems() { return selectItems; } + public Row getRow() { return resultData.next(); } + public boolean next() { + if (maxRows > 0 && resultCount++ > maxRows) { + return false; + } + return resultData.hasNext(); + } + }; + } + + public void executeUpdate(UpdateScript update) { + update.run(resourceBundleUpdateExecutor); + } + + @Override + protected String getMainSchemaName() throws MetaModelException { + return mainSchemaName; + } +} diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/bundle/ResourceBundleDataControl.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/bundle/ResourceBundleDataControl.java new file mode 100644 index 0000000..32bceff --- /dev/null +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/bundle/ResourceBundleDataControl.java @@ -0,0 +1,254 @@ +package net.forwardfire.vasc.backend.metamodel.bundle; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.net.URL; +import java.net.URLConnection; +import java.nio.charset.Charset; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; +import java.util.Properties; +import java.util.PropertyResourceBundle; +import java.util.ResourceBundle; +import java.util.ResourceBundle.Control; +import java.util.Set; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * ResourceBundleControl load ResourceBundles with correct CharSet from file and class path. + * + * @author Willem Cazander + * @version 1.0 Mar 26, 2012 + */ +public class ResourceBundleDataControl extends Control { + + /** The default extension for bundles. */ + protected static final String BUNDLE_EXTENSION = "properties"; + protected static final String BUNDLE_COMMENT = "Saved by MetaModel; "; + + protected Logger logger = null; + protected Charset charSet = null; + + /** The charSet to load with **/ + protected File baseBundleFile = null; + protected URL baseBundleUrl = null; + + protected Map bundleData = null; + protected Map bundleFiles = null; + + private ResourceBundleDataControl() { + logger = LoggerFactory.getLogger(ResourceBundleDataControl.class); + bundleFiles = new HashMap(10); + bundleData = Collections.synchronizedMap(new HashMap(10)); + } + + /** + * Creates ResourceBundleControl to read ResourceBundle with charSet. + */ + public ResourceBundleDataControl(Charset charSet) { + this(); + if (charSet==null) { + throw new NullPointerException("Can't load bundle with null Charset."); + } + this.charSet=charSet; + } + + public ResourceBundleDataControl(Charset charSet,File baseBundleFile) { + this(charSet); + if (baseBundleFile==null) { + throw new NullPointerException("Can't load bundle with null baseBundleFile."); + } + this.baseBundleFile=baseBundleFile; + } + + public ResourceBundleDataControl(Charset charSet,URL baseBundleUrl) { + this(charSet); + if (baseBundleUrl==null) { + throw new NullPointerException("Can't load bundle with null baseBundleUrl."); + } + this.baseBundleUrl=baseBundleUrl; + } + + public boolean isWritable() { + return baseBundleFile!=null; + } + + public Set getBundleNames() { + return bundleData.keySet(); + } + + public Properties getBundleData(String bundleName) { + if (bundleName==null) { + throw new NullPointerException("Can't get data for null bundleName."); + } + return bundleData.get(bundleName); + } + + public void removeBundle(String bundleName) { + Properties data = getBundleData(bundleName); + if (data==null) { + throw new IllegalStateException("Can't remove bundle data of unknown bundle: "+bundleName); + } + bundleData.remove(bundleName); + bundleFiles.remove(bundleName); + } + + public void saveBundle(String bundleName) throws IOException { + Properties data = getBundleData(bundleName); + if (data==null) { + throw new IllegalStateException("Can't save bundle data of unknown bundle: "+bundleName); + } + File bundleFile = bundleFiles.get(bundleName); + if (bundleFile==null) { + throw new IllegalStateException("Could not find loaded bundle file: "+bundleName); + } + long startTime = System.currentTimeMillis(); + saveBundleFile(data,bundleFile); + long stopTime = System.currentTimeMillis(); + logger.info("Saved bundle "+bundleName+" with "+data.size()+" keys in "+(stopTime-startTime)+" ms."); + } + + public int putBundleData(ResourceBundle bundle,String bundleName,File file) { + Properties p = new Properties(); + for (String key:bundle.keySet()) { + p.put(key, bundle.getString(key)); + } + bundleData.put(bundleName, p); + if (file!=null) { + bundleFiles.put(bundleName, file); + } + return p.size(); + } + + /** + * Does the loading of the ResourceBundle + */ + public ResourceBundle newBundle(String baseName, Locale localeRequested, String format, ClassLoader loader, boolean reload) throws IllegalAccessException, InstantiationException, IOException { + long startTime = System.currentTimeMillis(); + + // On urls only load the requested one. + if (baseBundleUrl!=null) { + ResourceBundle bundle = loadBundleUrl(baseBundleUrl); + putBundleData(bundle, baseBundleUrl.getFile(), null); + return bundle; + } + + if (baseName.endsWith(BUNDLE_EXTENSION)) { + baseName = baseName.substring(0,baseName.indexOf(BUNDLE_EXTENSION)-1); + } + + // Try to load all bundles. + ResourceBundle bundleLast = null; + int totalBundleDataSize = 0; + for (Locale locale:Locale.getAvailableLocales()) { + String bundleName = toBundleName(baseName, locale); + ResourceBundle bundle = null; + File bundleFile = null; + try { + if (baseBundleFile==null) { + String resourceName = toResourceName(bundleName, BUNDLE_EXTENSION); + logger.info("Loading: "+resourceName); + bundle = loadBundleClassPath(resourceName,loader,reload); + } else { + String resourceName = baseBundleFile.getParent()+File.separatorChar+bundleName+"."+BUNDLE_EXTENSION; + logger.info("Loading: "+resourceName); + bundleFile = new File(resourceName); + bundle = loadBundleFile(bundleFile); + } + } catch (FileNotFoundException fnfe) { + } catch (IOException e) { + e.printStackTrace(); + continue; // next + } + if (bundle==null) { + continue; + } + bundleLast = bundle; + String tableName = toBundleName("", locale).substring(1); + totalBundleDataSize += putBundleData(bundle,tableName,bundleFile); + } + + long stopTime = System.currentTimeMillis(); + logger.info("Loaded total "+bundleData.size()+" bundles with "+totalBundleDataSize+" keys in "+(stopTime-startTime)+" ms."); + + return bundleLast; // just return last one, not requested one. + } + + protected ResourceBundle loadBundleClassPath(String resourceName,ClassLoader loader,boolean reload) throws IOException { + ResourceBundle bundle = null; + InputStream stream = null; + if (reload) { + URL url = loader.getResource(resourceName); + if (url != null) { + URLConnection connection = url.openConnection(); + if (connection != null) { + connection.setUseCaches(false); + stream = connection.getInputStream(); + } + } + } else { + stream = loader.getResourceAsStream(resourceName); + } + if (stream != null) { + bundle = loadBundleStream(stream); + } + return bundle; + } + + protected ResourceBundle loadBundleUrl(URL url) throws IOException { + ResourceBundle bundle = null; + InputStream stream = null; + URLConnection connection = url.openConnection(); + if (connection != null) { + connection.setUseCaches(false); + stream = connection.getInputStream(); + } + if (stream != null) { + bundle = loadBundleStream(stream); + } + return bundle; + } + + protected ResourceBundle loadBundleFile(File file) throws IOException { + ResourceBundle bundle = null; + InputStream stream = new FileInputStream(file); + if (stream != null) { + bundle = loadBundleStream(stream); + } + return bundle; + } + + protected ResourceBundle loadBundleStream(InputStream stream) throws IOException { + if (stream==null) { + return null; + } + try { + return new PropertyResourceBundle(new InputStreamReader(stream, charSet)); + } finally { + stream.close(); + } + } + + protected void saveBundleFile(Properties properties,File file) throws IOException { + OutputStream out = new FileOutputStream(file); + try { + properties.store(new OutputStreamWriter(out,charSet), BUNDLE_COMMENT+new Date()); + } finally { + if (out!=null) { + out.close(); + } + } + } +} diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/bundle/ResourceBundleUpdateExecutor.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/bundle/ResourceBundleUpdateExecutor.java new file mode 100644 index 0000000..ec56ce5 --- /dev/null +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/bundle/ResourceBundleUpdateExecutor.java @@ -0,0 +1,137 @@ +package net.forwardfire.vasc.backend.metamodel.bundle; + +import java.io.File; +import java.util.Properties; +import java.util.ResourceBundle; + +import org.eobjects.metamodel.AbstractUpdateCallback; +import org.eobjects.metamodel.MetaModelException; +import org.eobjects.metamodel.UpdateCallback; +import org.eobjects.metamodel.create.ColumnCreationBuilder; +import org.eobjects.metamodel.create.TableCreationBuilder; +import org.eobjects.metamodel.data.DataSet; +import org.eobjects.metamodel.data.Row; +import org.eobjects.metamodel.delete.AbstractRowDeletionBuilder; +import org.eobjects.metamodel.delete.RowDeletionBuilder; +import org.eobjects.metamodel.drop.AbstractTableDropBuilder; +import org.eobjects.metamodel.drop.TableDropBuilder; +import org.eobjects.metamodel.insert.AbstractRowInsertionBuilder; +import org.eobjects.metamodel.insert.RowInsertionBuilder; +import org.eobjects.metamodel.schema.Column; +import org.eobjects.metamodel.schema.ColumnType; +import org.eobjects.metamodel.schema.Schema; +import org.eobjects.metamodel.schema.Table; + +/** + * ResourceBundleUpdateExecutor handles update to ResourceBundleDataContext + * + * @author Willem Cazander + * @version 1.0 May 26, 2012 + */ +public class ResourceBundleUpdateExecutor extends AbstractUpdateCallback { + + protected ResourceBundleDataContext resourceBundleDataContext = null; + protected ResourceBundleDataControl resourceBundleDataControl = null; + + public ResourceBundleUpdateExecutor(ResourceBundleDataContext resourceBundleDataContext,ResourceBundleDataControl resourceBundleDataControl) { + super(resourceBundleDataContext); + this.resourceBundleDataControl=resourceBundleDataControl; + } + + public boolean isDataContextWritable() { + return resourceBundleDataControl.isWritable(); + } + + @Override + public boolean isCreateTableSupported() { + return isDataContextWritable(); + } + + @Override + public boolean isInsertSupported() { + return isDataContextWritable(); + } + + public boolean isDeleteSupported() { + return isDataContextWritable(); + } + + public boolean isDropTableSupported() { + return isDataContextWritable(); + } + + public TableCreationBuilder createTable(final Schema schema, final String name) throws IllegalArgumentException, IllegalStateException { + TableCreationBuilder result = new TableCreationBuilder() { + public Table toTable() { return execute(); } + public String toSql() { return "nosql"; } + public TableCreationBuilder like(Table table) { return this; } + public ColumnCreationBuilder withColumn(String name) { + //return new ColumnCreationBuilderImpl(this,new MutableColumn(name)); + final TableCreationBuilder parent = this; + return new ColumnCreationBuilder() { + public ColumnCreationBuilder withColumn(String name) { return this; } + public ColumnCreationBuilder ofType(ColumnType type) { return this; } + public ColumnCreationBuilder ofSize(int size) { return this; } + public ColumnCreationBuilder ofNativeType(String nativeType) { return this; } + public ColumnCreationBuilder nullable(boolean nullable) { return this; } + public ColumnCreationBuilder asPrimaryKey() { return this; } + public ColumnCreationBuilder like(Column column) { return this; } + public TableCreationBuilder like(Table table) { return this; } + public String toSql() { return "nosql"; } + public Table toTable() { return execute(); } + public Table execute() throws MetaModelException { return parent.execute();} + + }; + } + public Table execute() throws MetaModelException { + File file = new File(name); + Properties p = new Properties(); + try { + resourceBundleDataControl.saveBundleFile(p, file); + ResourceBundle bundle = resourceBundleDataControl.loadBundleFile(file); + resourceBundleDataControl.putBundleData(bundle, name, file); + } catch (Exception e) { + throw new MetaModelException(e); + } + return resourceBundleDataContext.createTable(schema, name); + } + }; + return result; + } + + public TableDropBuilder dropTable(Table table) throws IllegalArgumentException, IllegalStateException,UnsupportedOperationException { + TableDropBuilder result = new AbstractTableDropBuilder(table) { + public void execute() throws MetaModelException { + resourceBundleDataControl.removeBundle(getTable().getName()); + } + }; + return result; + } + + public RowInsertionBuilder insertInto(final Table table) throws IllegalArgumentException, IllegalStateException,UnsupportedOperationException { + RowInsertionBuilder result = new AbstractRowInsertionBuilder(this, table) { + public void execute() throws MetaModelException { + Properties data = resourceBundleDataControl.getBundleData(table.getName()); + Object[] values = getValues(); + data.put(values[1], values[2]); + } + }; + return result; + } + + public RowDeletionBuilder deleteFrom(final Table table) throws IllegalArgumentException, IllegalStateException,UnsupportedOperationException { + RowDeletionBuilder result = new AbstractRowDeletionBuilder(table) { + public void execute() throws MetaModelException { + DataSet ds = resourceBundleDataContext.materializeMainSchemaTable(getTable(),getTable().getColumns(),0); + Properties data = resourceBundleDataControl.getBundleData(table.getName()); + while (ds.next()) { + Row row = ds.getRow(); + if (deleteRow(row)) { + data.remove(row.getValue(1)); // delete by key + } + } + } + }; + return result; + } +} diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/crud/AbstractCrudDataContext.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/crud/AbstractCrudDataContext.java new file mode 100644 index 0000000..b23f7e4 --- /dev/null +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/crud/AbstractCrudDataContext.java @@ -0,0 +1,294 @@ +package net.forwardfire.vasc.backend.metamodel.crud; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.List; + +import org.eobjects.metamodel.DataContext; +import org.eobjects.metamodel.MetaModelException; +import org.eobjects.metamodel.UpdateCallback; +import org.eobjects.metamodel.UpdateScript; +import org.eobjects.metamodel.UpdateableDataContext; +import org.eobjects.metamodel.data.DataSet; +import org.eobjects.metamodel.data.EmptyDataSet; +import org.eobjects.metamodel.data.InMemoryDataSet; +import org.eobjects.metamodel.data.Row; +import org.eobjects.metamodel.delete.RowDeletionBuilder; +import org.eobjects.metamodel.insert.RowInsertionBuilder; +import org.eobjects.metamodel.query.FromItem; +import org.eobjects.metamodel.query.Query; +import org.eobjects.metamodel.query.SelectItem; +import org.eobjects.metamodel.query.builder.SatisfiedQueryBuilder; +import org.eobjects.metamodel.query.builder.SatisfiedWhereBuilder; +import org.eobjects.metamodel.schema.Table; +import org.eobjects.metamodel.update.RowUpdationBuilder; + +/** + * AbstractCrudDataContext implements the generic abstract crud actions. + * + * @author Willem Cazander + * @version 1.0 May 23, 2012 + */ +abstract public class AbstractCrudDataContext implements CrudDataContext { + + abstract public UpdateableRow wrapOrCreateToUpdateableRow(Row row,Table table); + + protected UpdateableDataContext abstractProviderUpdateableDataContext() { + return this; + } + + public UpdateableRow createRow(Table table) { + return wrapOrCreateToUpdateableRow(null,table); + } + + public void persist(final UpdateableRow row) { + UpdateableDataContext dataContext = abstractProviderUpdateableDataContext(); + dataContext.executeUpdate(new UpdateScript() { + public void run(UpdateCallback backendImpl) { + RowInsertionBuilder query = backendImpl.insertInto(row.getTable()); + for (int i=0;i primaryKeyColumns = new ArrayList(30); + Collections.addAll(primaryKeyColumns, row.getPrimaryKeys()); + for (String column:primaryKeyColumns) { + Object value = row.getValue(column); + queryWhereBuilderUpdate(qWhere,column,value,first); + first = false; + } + List columns = new ArrayList(30); + Collections.addAll(columns, row.getTable().getColumnNames()); + columns.removeAll(primaryKeyColumns); + for (String column:columns) { + Object value = row.getValue(column); + ((RowUpdationBuilder)qWhere).value(column, value); + } + if (first==false) { + ((RowUpdationBuilder)qWhere).execute(); + } else { + // loggger.warning no where clause + } + } + }); + + Object qWhere = dataContext.query().from(row.getTable()).select(row.getTable().getColumns()); + boolean first = true; + for (String column:row.getPrimaryKeys()) { + Object value = row.getValue(column); + queryWhereBuilder(qWhere,column,value,first); + first = false; + } + Query mergeSelectQuery = ((SatisfiedQueryBuilder)qWhere).toQuery(); + DataSet ds = dataContext.executeQuery(mergeSelectQuery); + if (ds.next()==false) { + ds.close(); + throw new IllegalStateException("Could not fetch row after merging."); + } + UpdateableRow rowResult = wrapOrCreateToUpdateableRow(ds.getRow(),row.getTable()); + ds.close(); + return rowResult; + } + + public void delete(final UpdateableRow row) { + UpdateableDataContext dataContext = abstractProviderUpdateableDataContext(); + dataContext.executeUpdate(new UpdateScript() { + public void run(UpdateCallback backendImpl) { + Object qWhere = backendImpl.deleteFrom(row.getTable()); + boolean first = true; + for (String column:row.getPrimaryKeys()) { + Object value = row.getValue(column); + queryWhereBuilderDelete(qWhere,column,value,first); + first = false; + } + if (first==false) { + ((RowDeletionBuilder)qWhere).execute(); + } else { + ///logger.warning no where clause + } + } + }); + } + + // TODO: redo these queryWhereBuilder methods to cleaner code + + protected Object queryWhereBuilder(Object qWhere,String key,Object value,boolean first) { + if (value instanceof Number) { + if (first) { + qWhere = ((SatisfiedQueryBuilder)qWhere).where(key).equals((Number)value); + } else { + qWhere = ((SatisfiedWhereBuilder)qWhere).and(key).equals((Number)value); + } + } else if (value instanceof Date) { + if (first) { + qWhere = ((SatisfiedQueryBuilder)qWhere).where(key).equals((Date)value); + } else { + qWhere = ((SatisfiedWhereBuilder)qWhere).and(key).equals((Date)value); + } + } else if (value instanceof Boolean) { + if (first) { + qWhere = ((SatisfiedQueryBuilder)qWhere).where(key).equals((Boolean)value); + } else { + qWhere = ((SatisfiedWhereBuilder)qWhere).and(key).equals((Boolean)value); + } + } else { + if (value==null) { + if (first) { + qWhere = ((SatisfiedQueryBuilder)qWhere).where(key).isNull(); + } else { + qWhere = ((SatisfiedWhereBuilder)qWhere).and(key).isNull(); + } + } else { + if (first) { + qWhere = ((SatisfiedQueryBuilder)qWhere).where(key).equals(value.toString()); + } else { + qWhere = ((SatisfiedWhereBuilder)qWhere).and(key).equals(value.toString()); + } + } + } + return qWhere; + } + + protected Object queryWhereBuilderUpdate(Object qWhere,String key,Object value,boolean first) { + if (value instanceof Number) { + if (first) { + qWhere = ((RowUpdationBuilder)qWhere).where(key).equals((Number)value); + } else { + qWhere = ((RowUpdationBuilder)qWhere).where(key).equals((Number)value); + } + } else if (value instanceof Date) { + if (first) { + qWhere = ((RowUpdationBuilder)qWhere).where(key).equals((Date)value); + } else { + qWhere = ((RowUpdationBuilder)qWhere).where(key).equals((Date)value); + } + } else if (value instanceof Boolean) { + if (first) { + qWhere = ((RowUpdationBuilder)qWhere).where(key).equals((Boolean)value); + } else { + qWhere = ((RowUpdationBuilder)qWhere).where(key).equals((Boolean)value); + } + } else { + if (value==null) { + if (first) { + qWhere = ((RowUpdationBuilder)qWhere).where(key).isNull(); + } else { + qWhere = ((RowUpdationBuilder)qWhere).where(key).isNull(); + } + } else { + if (first) { + qWhere = ((RowUpdationBuilder)qWhere).where(key).equals(value.toString()); + } else { + qWhere = ((RowUpdationBuilder)qWhere).where(key).equals(value.toString()); + } + } + } + return qWhere; + } + + protected Object queryWhereBuilderDelete(Object qWhere,String key,Object value,boolean first) { + if (value instanceof Number) { + if (first) { + qWhere = ((RowDeletionBuilder)qWhere).where(key).equals((Number)value); + } else { + qWhere = ((RowDeletionBuilder)qWhere).where(key).equals((Number)value); + } + } else if (value instanceof Date) { + if (first) { + qWhere = ((RowDeletionBuilder)qWhere).where(key).equals((Date)value); + } else { + qWhere = ((RowDeletionBuilder)qWhere).where(key).equals((Date)value); + } + } else if (value instanceof Boolean) { + if (first) { + qWhere = ((RowDeletionBuilder)qWhere).where(key).equals((Boolean)value); + } else { + qWhere = ((RowDeletionBuilder)qWhere).where(key).equals((Boolean)value); + } + } else { + if (value==null) { + if (first) { + qWhere = ((RowDeletionBuilder)qWhere).where(key).isNull(); + } else { + qWhere = ((RowDeletionBuilder)qWhere).where(key).isNull(); + } + } else { + if (first) { + qWhere = ((RowDeletionBuilder)qWhere).where(key).equals(value.toString()); + } else { + qWhere = ((RowDeletionBuilder)qWhere).where(key).equals(value.toString()); + } + } + } + return qWhere; + } + + /** + * executeQueryWrapDataSet interface so when implemented on backend then executeQueryWrapDataSet is not used. + * There for no need to expose this primary key handler method in this abstract class. + */ + protected interface QueryWrapDataSetPrimaryKeyHandler { + public List getPrimaryKeysForTable(Table table); + } + + protected DataSet executeQueryWrapDataSet(DataContext dataContext,Query query,boolean checkPrimaryKeysAllRows,QueryWrapDataSetPrimaryKeyHandler keyHandler) throws MetaModelException { + DataSet data = dataContext.executeQuery(query); + if (query.getFromClause().getItems().size() > 1) { + return data; // Only supports crud on single table data. + } + FromItem fromItem = query.getFromClause().getItems().get(0); + Table table = fromItem.getTable(); + List keys = keyHandler.getPrimaryKeysForTable(table); + if (keys.isEmpty()) { + return data; + } + if (query.getSelectClause().getItemCount()==1 && query.getSelectClause().getItem(0).getColumn()==null) { + return data; // TODO: use correct api to detect selectCount query + } + List dataWrap = new ArrayList(2000); + boolean keysOke = false; // NOTE: could add option checkPrimaryKeys to override if user/impl is really sure keys are there. + boolean keysCheck = true; // always check first row + List keysCheckList = new ArrayList(keys); // copy keys + while (data.next()) { + Row row = data.getRow(); + if (keysCheck) { + for (SelectItem si:row.getSelectItems()) { + keysCheckList.remove(si.getColumn().getName()); + } + keysCheck = checkPrimaryKeysAllRows; // default is check first row only. + keysOke = keysCheckList.isEmpty(); // Found all primary keys in result so we can wrap data. + if (keysCheck) { + keysCheckList.addAll(keys); // Reload keys to check all data. + } + } + if (keysOke) { + dataWrap.add(wrapOrCreateToUpdateableRow(data.getRow(),table)); + } else { + dataWrap.add(row); + } + } + data.close(); + if (dataWrap.isEmpty()) { + return new EmptyDataSet(table.getColumns()); + } + return new InMemoryDataSet(dataWrap); + } +} diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/crud/AbstractRow.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/crud/AbstractRow.java new file mode 100644 index 0000000..7b4ab6d --- /dev/null +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/crud/AbstractRow.java @@ -0,0 +1,163 @@ +package net.forwardfire.vasc.backend.metamodel.crud; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.eobjects.metamodel.data.Row; +import org.eobjects.metamodel.data.Style; +import org.eobjects.metamodel.query.SelectItem; +import org.eobjects.metamodel.schema.Column; + +/** + * AbstractRow implements most Row features onto of itself. + * + * @author Willem Cazander + * @version 1.0 May 23, 2012 + */ +@SuppressWarnings("serial") +abstract public class AbstractRow implements Row,RowLocal { + + protected Map metaData = null; + + public AbstractRow() { + metaData = new HashMap(30); + } + + public SelectItem getSelectItem(int index) { + MetaRowData metaRow = getMetaRowData(index); + return metaRow.selectItem; + } + + public void addSelectItems(Column[] columns) { + for (Column column:columns) { + addSelectItem(new SelectItem(column)); + } + } + + public void addSelectItems(SelectItem[] selectItems) { + for (SelectItem selectItem:selectItems) { + addSelectItem(selectItem); + } + } + + public void addSelectItems(List selectItems) { + for (SelectItem selectItem:selectItems) { + addSelectItem(selectItem); + } + } + + public void addSelectItem(SelectItem selectItem) { + MetaRowData metaRow = new MetaRowData(); + metaRow.selectItem=selectItem; + metaData.put(metaData.size(), metaRow); + } + + public MetaRowData getMetaRowData(int index) { + MetaRowData metaRow = metaData.get(index); + return metaRow; + } + + public List getIndexedMetaRowDataList() { + List result = new ArrayList(size()); + for (int i=0;i getIndexedSelectItemList() { + List result = new ArrayList(size()); + for (MetaRowData metaRow:getIndexedMetaRowDataList()) { + result.add(metaRow.selectItem); + } + return result; + } + + public void setStyle(int index,Style style) { + MetaRowData metaRow = metaData.get(index); + metaRow.style=style; + } + + class MetaRowData /* implements DataSetRowMetaData */ { + SelectItem selectItem; + Style style; + // name and backendIndex,etc so DataSetApi does not need SchemaApi, when using schema aware code like an DataContext + // the DC api does not change because it fill/config/wires the DS api with meta data from schema. + // When using DataSet api in non-schema aware code then caller has to provided meta data for api to work. + // ObjectConverter objectConverter + // List + // etc/etc + } + + // ==== Start interface + + public Object[] getValues() { + Object[] result = new Object[size()]; + for (int i=0;i list = getIndexedSelectItemList(); + SelectItem[] result = new SelectItem[list.size()]; + return list.toArray(result); + } + + public Style getStyle(SelectItem item) { + return getStyle(indexOf(item)); + } + + public Style getStyle(Column column) { + return getStyle(indexOf(column)); + } + + public Style getStyle(int index) throws IndexOutOfBoundsException { + MetaRowData metaRow = getMetaRowData(index); + if (metaRow==null) { + return Style.NO_STYLE; + } + if (metaRow.style==null) { + return Style.NO_STYLE; + } + return metaRow.style; + } + + public int size() { + return metaData.size(); + } +} diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/crud/AbstractUpdateableRow.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/crud/AbstractUpdateableRow.java new file mode 100644 index 0000000..131deeb --- /dev/null +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/crud/AbstractUpdateableRow.java @@ -0,0 +1,80 @@ +package net.forwardfire.vasc.backend.metamodel.crud; + +import java.util.List; + +import org.eobjects.metamodel.data.Row; +import org.eobjects.metamodel.data.Style; +import org.eobjects.metamodel.query.SelectItem; +import org.eobjects.metamodel.schema.Column; + +/** + * AbstractUpdateableRow implements some setters of UpdateableRow interface. + * + * @author Willem Cazander + * @version 1.0 May 23, 2012 + */ +@SuppressWarnings("serial") +abstract public class AbstractUpdateableRow extends AbstractRow implements UpdateableRow { + + // TODO: rm / move getValue and indexOf to AbstractRow after UpdateableRow interface change + public Object getValue(String columnName) { + return getValue(indexOf(columnName)); + } + public int indexOf(String columnName) { + if (columnName==null) { + return UpdateableRow.INDEX_NOT_FOUND; + } + int index = 0; + for (SelectItem si:getIndexedSelectItemList()) { + if (si.getColumn().getName().equals(columnName)) { + return index; + } + index++; + } + return UpdateableRow.INDEX_NOT_FOUND; + } + + public void setValue(Row row) { + for (SelectItem selectItem:row.getSelectItems()) { + Object value = row.getValue(selectItem); + setValue(indexOf(selectItem),value); + } + } + + public void setValue(String columnName,Object object) { + setValue(indexOf(columnName), object); + } + + public void setValue(SelectItem selectItem,Object object) { + setValue(indexOf(selectItem),object); + } + + public void setValue(Column column,Object object) { + setValue(indexOf(column),object); + } + + public String[] getPrimaryKeys() { + List primaryKeys = getPrimaryKeysList(); + return primaryKeys.toArray(new String[primaryKeys.size()]); + } + + public Row getSubSelectionFromImpl(AbstractUpdateableRow rowImpl,SelectItem[] selectItems) { + for (SelectItem selectItem:selectItems) { + int index = rowImpl.indexOf(selectItem); + Object value = null; + Style style = null; + + if (selectItem.getSubQuerySelectItem() != null) { + value = getValue(selectItem.getSubQuerySelectItem()); + style = getStyle(selectItem.getSubQuerySelectItem()); + } + if (value == null) { + value = getValue(selectItem); + style = getStyle(selectItem); + } + rowImpl.setValue(index, value); + rowImpl.setStyle(index, style); + } + return rowImpl; + } +} diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/crud/CrudDataContext.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/crud/CrudDataContext.java new file mode 100644 index 0000000..c7ed02b --- /dev/null +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/crud/CrudDataContext.java @@ -0,0 +1,35 @@ +package net.forwardfire.vasc.backend.metamodel.crud; + +import org.eobjects.metamodel.UpdateableDataContext; +import org.eobjects.metamodel.schema.Table; + +/** + * CrudDataContext provides Create/Update/Delete operations on row level of table. + * + * note: UpdateableDataContext can implement UpdateableRowDataContext interface to provide native support for UpdateableRow in DataSet. + * + * @author Willem Cazander + * @version 1.0 May 23, 2012 + */ +public interface CrudDataContext extends UpdateableDataContext { + + /** + * Creates empty row to fill and persist. + */ + public UpdateableRow createRow(Table table); + + /** + * Inserts row into table. + */ + public void persist(UpdateableRow row); + + /** + * Merges row with table. + */ + public Object merge(UpdateableRow row); + + /** + * Deletes row from table. + */ + public void delete(UpdateableRow row); +} diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/crud/CrudDataContextImpl.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/crud/CrudDataContextImpl.java new file mode 100644 index 0000000..17583fb --- /dev/null +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/crud/CrudDataContextImpl.java @@ -0,0 +1,194 @@ +package net.forwardfire.vasc.backend.metamodel.crud; + +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.MetaModelException; +import org.eobjects.metamodel.UpdateScript; +import org.eobjects.metamodel.UpdateableDataContext; +import org.eobjects.metamodel.data.DataSet; +import org.eobjects.metamodel.data.Row; +import org.eobjects.metamodel.query.Query; +import org.eobjects.metamodel.query.builder.InitFromBuilder; +import org.eobjects.metamodel.query.builder.InitFromBuilderImpl; +import org.eobjects.metamodel.schema.Column; +import org.eobjects.metamodel.schema.ColumnType; +import org.eobjects.metamodel.schema.Schema; +import org.eobjects.metamodel.schema.Table; + +/** + * CrudDataContextImpl is implementation of CrudDataContext interface which provides crud operations on UpdateableDataContext + * + * @author Willem Cazander + * @version 1.0 May 23, 2012 + */ +public class CrudDataContextImpl extends AbstractCrudDataContext implements AbstractCrudDataContext.QueryWrapDataSetPrimaryKeyHandler { + + protected UpdateableDataContext dataContextDelegate = null; + protected Map> tableKeys = null; + private boolean checkPrimaryKeysAllRows = false; + + public CrudDataContextImpl(UpdateableDataContext dataContext) { + dataContextDelegate = dataContext; + tableKeys = new HashMap>(100); + } + + public void overridePrimaryKeysForTable(String table,List keys) { + tableKeys.put(table, keys); + } + + public List getPrimaryKeysForTable(Table table) { + List keys = tableKeys.get(table.getName()); + if (keys!=null) { + return keys; + } + keys = new ArrayList(5); + for (Column k:table.getPrimaryKeys()) { + keys.add(k.getName()); // strange getPrimaryKeys is mostly empty, check SimpleTableDef.toTable or MutableColumn.setType to fix + } + // start test hack code + if (keys.isEmpty()) { + for (Column k:table.getColumnsOfType(ColumnType.ROWID)) { // mmm still empty + keys.add(k.getName()); + } + if (keys.isEmpty()) { + for (Column k:table.getColumns()) { + String colName = k.getName(); + if (colName.equals("_id")) { + keys.add(colName); + } else if (colName.equalsIgnoreCase("id")) { // TODO: rm this quick hard code ID search + keys.add(colName); + } + } + } + } + // stop test hack code + if (keys.isEmpty()) { + throw new IllegalStateException("Can't work with table: "+table+" without primary key."); + } + return keys; + } + + /** + * Does the actual automatic Row to UpdateableRow wrapping. + */ + @Override + public UpdateableRow wrapOrCreateToUpdateableRow(Row row,Table table) { + UpdateableRowMapImpl result = new UpdateableRowMapImpl(table,getPrimaryKeysForTable(table)); + if (row==null) { + result.addSelectItems(table.getColumns()); // create new when row is null + } else { + result.addSelectItems(row.getSelectItems()); + result.setValue(row); // copy all values to impl + } + return result; + } + + /** + * Checks if backend dataContextDelegate has native support for UpdateableRowDataContext. + * If not then automatic wrap full DataSet data to UpdateableRow + */ + public DataSet executeQuery(Query query) throws MetaModelException { + if (dataContextDelegate instanceof UpdateableRowDataContext) { + return ((UpdateableRowDataContext) dataContextDelegate).crudExecuteQuery(this,query); + } else { + return executeQueryWrapDataSet(dataContextDelegate,query,isCheckPrimaryKeysAllRows(),this); + } + } + + /** + * Checks if backend dataContextDelegate has native support for UpdateableRowDataContext. + * If so then use api to start query builder with this datacontext. + * Else use default InitFromBuilderImpl query builder. + */ + public InitFromBuilder query() { + if (dataContextDelegate instanceof UpdateableRowDataContext) { + return ((UpdateableRowDataContext) dataContextDelegate).crudCreateQuery(this); + } else { + return new InitFromBuilderImpl(this); + } + } + + // === Bean properties + + + + /** + * @return the checkPrimaryKeysAllRows + */ + public boolean isCheckPrimaryKeysAllRows() { + return checkPrimaryKeysAllRows; + } + + /** + * @param checkPrimaryKeysAllRows the checkPrimaryKeysAllRows to set + */ + public void setCheckPrimaryKeysAllRows(boolean checkPrimaryKeysAllRows) { + this.checkPrimaryKeysAllRows = checkPrimaryKeysAllRows; + } + + + + // === Start wrapper to dataContextDelegate + + + + /** + * @see org.eobjects.metamodel.UpdateableDataContext#executeUpdate(org.eobjects.metamodel.UpdateScript) + */ + public void executeUpdate(UpdateScript arg0) { + dataContextDelegate.executeUpdate(arg0); + } + + /** + * @see org.eobjects.metamodel.DataContext#getColumnByQualifiedLabel(java.lang.String) + */ + public Column getColumnByQualifiedLabel(String arg0) { + return dataContextDelegate.getColumnByQualifiedLabel(arg0); + } + + /** + * @see org.eobjects.metamodel.DataContext#getDefaultSchema() + */ + public Schema getDefaultSchema() throws MetaModelException { + return dataContextDelegate.getDefaultSchema(); + } + + /** + * @see org.eobjects.metamodel.DataContext#getSchemaByName(java.lang.String) + */ + public Schema getSchemaByName(String arg0) throws MetaModelException { + return dataContextDelegate.getSchemaByName(arg0); + } + + /** + * @see org.eobjects.metamodel.DataContext#getSchemaNames() + */ + public String[] getSchemaNames() throws MetaModelException { + return dataContextDelegate.getSchemaNames(); + } + + /** + * @see org.eobjects.metamodel.DataContext#getSchemas() + */ + public Schema[] getSchemas() throws MetaModelException { + return dataContextDelegate.getSchemas(); + } + + /** + * @see org.eobjects.metamodel.DataContext#getTableByQualifiedLabel(java.lang.String) + */ + public Table getTableByQualifiedLabel(String arg0) { + return dataContextDelegate.getTableByQualifiedLabel(arg0); + } + + /** + * @see org.eobjects.metamodel.DataContext#refreshSchemas() + */ + public DataContext refreshSchemas() { + return dataContextDelegate.refreshSchemas(); + } +} diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/crud/RowLocal.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/crud/RowLocal.java new file mode 100644 index 0000000..69043ff --- /dev/null +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/crud/RowLocal.java @@ -0,0 +1,19 @@ +package net.forwardfire.vasc.backend.metamodel.crud; + +import org.eobjects.metamodel.data.Row; +import org.eobjects.metamodel.data.Style; + +/** + * RowLocal is the set version of Row interface. + * + * Currently only needed setStyle to make duplicate code in Row.getSubSelection(SelectItem[] selectItems) abstract so impl can do one liner. + * other option is move all get/setStyle to one RowStyle interface as that data is almost always locally implemented. + * + * @author Willem Cazander + * @version 1.0 May 23, 2012 + */ +public interface RowLocal extends Row { + + public void setStyle(int index,Style style); + +} diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/crud/UpdateableRow.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/crud/UpdateableRow.java new file mode 100644 index 0000000..4f2a55a --- /dev/null +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/crud/UpdateableRow.java @@ -0,0 +1,75 @@ +package net.forwardfire.vasc.backend.metamodel.crud; + +import java.util.List; + +import org.eobjects.metamodel.data.Row; +import org.eobjects.metamodel.query.SelectItem; +import org.eobjects.metamodel.schema.Column; +import org.eobjects.metamodel.schema.Table; + +/** + * UpdateableRow is the setValue(...) version of Row interface. + * + * @author Willem Cazander + * @version 1.0 May 23, 2012 + */ +public interface UpdateableRow extends Row { + + // TODO: move these 3 to Row interface + public SelectItem getSelectItem(int index); + public Object getValue(String columnName); + public static final int INDEX_NOT_FOUND = -1; + + /** + * Returns the table + */ + public Table getTable(); + + /** + * Returns primary keys of table. + */ + public List getPrimaryKeysList(); + + /** + * Returns primary keys of table. + */ + public String[] getPrimaryKeys(); + + /** + * Sets the value by the column name. + * + * @param columnName + * @param object + */ + public void setValue(String columnName,Object object); + + /** + * Sets the value of the provided SelectItem. + * + * @param item + * @return the value that corresponds to the provided SelectItem. Can be + * null if either the value is null or if no value exists + * that matches the SelectItem. + */ + public void setValue(SelectItem item,Object object); + + /** + * Shorthand method for setting the value of a SelectItem based on the + * provided column. Invoking this method is equivalent to invoking + * setValue(new SelectItem(column)). + * + * @param column + * @return the value of the specified column + */ + public void setValue(Column column,Object object); + + /** + * Sets the value of the row at a given index + * + * @param index + * @return the value at the specified index + * @throws IndexOutOfBoundsException + * if the provided index is out of range + */ + public void setValue(int index,Object object) throws IndexOutOfBoundsException; +} diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/crud/UpdateableRowDataContext.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/crud/UpdateableRowDataContext.java new file mode 100644 index 0000000..f6e9f19 --- /dev/null +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/crud/UpdateableRowDataContext.java @@ -0,0 +1,24 @@ +package net.forwardfire.vasc.backend.metamodel.crud; + +import org.eobjects.metamodel.data.DataSet; +import org.eobjects.metamodel.query.Query; +import org.eobjects.metamodel.query.builder.InitFromBuilder; + +/** + * UpdateableRowDataContext to let DataContexts integrate CrudDataContext without wrapping data. + * + * @author Willem Cazander + * @version 1.0 May 24, 2012 + */ +public interface UpdateableRowDataContext { + + /** + * Gets called by executeQuery from crud to this impl which knows how to return UpdateableRow DataSet. + */ + public DataSet crudExecuteQuery(CrudDataContext crudDataContext,Query query); + + /** + * Start the query builder with correct data context for execute call back. + */ + public InitFromBuilder crudCreateQuery(CrudDataContext crudDataContext); +} diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/crud/UpdateableRowMapImpl.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/crud/UpdateableRowMapImpl.java new file mode 100644 index 0000000..569e4a0 --- /dev/null +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/crud/UpdateableRowMapImpl.java @@ -0,0 +1,60 @@ +package net.forwardfire.vasc.backend.metamodel.crud; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.eobjects.metamodel.data.Row; +import org.eobjects.metamodel.query.SelectItem; +import org.eobjects.metamodel.schema.Table; + +/** + * UpdateableRowMapImpl is basic implementation of UpdateableRow interface. + * + * @author Willem Cazander + * @version 1.0 May 23, 2012 + */ +public class UpdateableRowMapImpl extends AbstractUpdateableRow { + + private static final long serialVersionUID = 7660759661023194759L; + private Map dataMap = null; + private Table table = null; + private List primaryKeys = null; + + public UpdateableRowMapImpl(Table table,List primaryKeys) { + this(table,primaryKeys,null); + } + + public UpdateableRowMapImpl(Table table,List primaryKeys,SelectItem[] selectItems) { + if (table==null) { throw new NullPointerException("Can't work with null table."); } + if (primaryKeys==null) { throw new NullPointerException("Can't work with null primaryKeys."); } + this.dataMap = new HashMap(30); + this.table=table; + this.primaryKeys = primaryKeys; + if (selectItems!=null) { + addSelectItems(selectItems); + } + } + + // interface + + public Table getTable() { + return table; + } + + public List getPrimaryKeysList() { + return primaryKeys; + } + + public void setValue(int index, Object value) throws IndexOutOfBoundsException { + dataMap.put(index, value); + } + + public Object getValue(int index) throws IndexOutOfBoundsException { + return dataMap.get(index); + } + + public Row getSubSelection(SelectItem[] selectItems) { + return getSubSelectionFromImpl(new UpdateableRowMapImpl(table,primaryKeys,selectItems),selectItems); + } +} diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/jndi/DataContextProvider.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/jndi/DataContextProvider.java new file mode 100644 index 0000000..882497f --- /dev/null +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/jndi/DataContextProvider.java @@ -0,0 +1,14 @@ +package net.forwardfire.vasc.backend.metamodel.jndi; + +import org.eobjects.metamodel.DataContext; + +/** + * DataContextProvider will create of fetch an DataContext for use. + * + * @author Willem Cazander + * @version 1.0 May 22, 2012 + */ +public interface DataContextProvider { + + public DataContext getDataContext(); +} diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/jndi/JndiDataContextObjectFactory.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/jndi/JndiDataContextObjectFactory.java new file mode 100644 index 0000000..33fb5fd --- /dev/null +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/jndi/JndiDataContextObjectFactory.java @@ -0,0 +1,118 @@ +package net.forwardfire.vasc.backend.metamodel.jndi; + +import java.util.Hashtable; + +import javax.naming.Context; +import javax.naming.Name; +import javax.naming.spi.ObjectFactory; + +import net.forwardfire.vasc.backend.metamodel.jndi.loader.JndiCsvDataContextLoader; +import net.forwardfire.vasc.backend.metamodel.jndi.loader.JndiDataContextLoader; +import net.forwardfire.vasc.backend.metamodel.jndi.loader.JndiDataContextLoaderConfig; +import net.forwardfire.vasc.backend.metamodel.jndi.loader.JndiJdbcDataContextLoader; +import net.forwardfire.vasc.backend.metamodel.jndi.loader.JndiMongodbDataContextLoader; +import net.forwardfire.vasc.backend.metamodel.jndi.loader.JndiXmlDomDataContextLoader; +import net.forwardfire.vasc.backend.metamodel.jndi.loader.JndiXmlSaxDataContextLoader; + +import org.eobjects.metamodel.DataContext; +import org.eobjects.metamodel.UpdateableDataContext; + +/** + * JndiDataContextObjectFactory provides data contexts on application scope level for + * all (EE) servers which provides java naming support. + * + * Tomcat context.xml config example; + *
+ * 
+ * 
+ * + * @author Willem Cazander + * @version 1.0 May 22, 2012 + */ +public class JndiDataContextObjectFactory implements ObjectFactory { + + protected DataContext dataContext = null; + public enum BackendType { + jdbcJndi,jdbc,mongodb,mongodbJndi,csvFile,csvUrl,xmlDomFile,xmlDomUrl,xmlSaxFile,xmlSaxUrl,providerClass + } + + /** + * @see javax.naming.spi.ObjectFactory#getObjectInstance(java.lang.Object, javax.naming.Name, javax.naming.Context, java.util.Hashtable) + */ + synchronized public Object getObjectInstance(Object obj, Name namePath, Context nameCtx,Hashtable env) throws Exception { + + // Create only once. + if (dataContext!=null) { + return dataContext; + } + + // Create objectName to print with errors + StringBuffer buf = new StringBuffer(40); + for (int i=0;i providerClass = cl.loadClass(className); + DataContextProvider dataContextProvider = (DataContextProvider)providerClass.newInstance(); + return dataContextProvider; + } catch (Exception e) { + throw new IllegalStateException("Could not create provider of: "+className,e); + } + } +} diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/jndi/JndiDataContextProvider.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/jndi/JndiDataContextProvider.java new file mode 100644 index 0000000..4f292e2 --- /dev/null +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/jndi/JndiDataContextProvider.java @@ -0,0 +1,45 @@ +package net.forwardfire.vasc.backend.metamodel.jndi; + +import javax.naming.InitialContext; +import javax.naming.NamingException; + +import org.eobjects.metamodel.DataContext; + +/** + * JndiDataContextProvider retreives a DataContext from the jndi tree by the jndiName. + * + * + * @author Willem Cazander + * @version 1.0 May 22, 2012 + */ +public class JndiDataContextProvider implements DataContextProvider { + + private String jndiName = null; + + /** + * Returns an DataContext object from the jndi tree. + */ + public DataContext getDataContext() { + try { + InitialContext context = new InitialContext(); + DataContext dataContext = (DataContext)context.lookup(jndiName); + return dataContext; + } catch (NamingException e) { + throw new IllegalStateException("Jndi naming error on: "+jndiName,e); + } + } + + /** + * @return the jndiName + */ + public String getJndiName() { + return jndiName; + } + + /** + * @param jndiName the jndiName to set + */ + public void setJndiName(String jndiName) { + this.jndiName = jndiName; + } +} diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/jndi/JndiReadOnlyDataContext.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/jndi/JndiReadOnlyDataContext.java new file mode 100644 index 0000000..cb621e5 --- /dev/null +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/jndi/JndiReadOnlyDataContext.java @@ -0,0 +1,50 @@ +package net.forwardfire.vasc.backend.metamodel.jndi; + +import org.eobjects.metamodel.DataContext; +import org.eobjects.metamodel.MetaModelException; +import org.eobjects.metamodel.data.DataSet; +import org.eobjects.metamodel.query.Query; +import org.eobjects.metamodel.query.builder.InitFromBuilder; +import org.eobjects.metamodel.schema.Column; +import org.eobjects.metamodel.schema.Schema; +import org.eobjects.metamodel.schema.Table; + +/** + * JndiReadOnlyDataContext makes DataContext read only by removing the UpdateableDataContext interface. + * + * @author Willem Cazanders + * @version 1.0 May 22, 2012 + */ +public class JndiReadOnlyDataContext /* extends DataContextProxy */ implements DataContext { + private DataContext proxyDataContext = null; + public JndiReadOnlyDataContext(DataContext proxyDataContext) { + this.proxyDataContext=proxyDataContext; + } + public DataSet executeQuery(Query arg0) throws MetaModelException { + return proxyDataContext.executeQuery(arg0); + } + public Column getColumnByQualifiedLabel(String arg0) { + return proxyDataContext.getColumnByQualifiedLabel(arg0); + } + public Schema getDefaultSchema() throws MetaModelException { + return proxyDataContext.getDefaultSchema(); + } + public Schema getSchemaByName(String arg0) throws MetaModelException { + return proxyDataContext.getSchemaByName(arg0); + } + public String[] getSchemaNames() throws MetaModelException { + return proxyDataContext.getSchemaNames(); + } + public Schema[] getSchemas() throws MetaModelException { + return proxyDataContext.getSchemas(); + } + public Table getTableByQualifiedLabel(String arg0) { + return proxyDataContext.getTableByQualifiedLabel(arg0); + } + public InitFromBuilder query() { + return proxyDataContext.query(); + } + public DataContext refreshSchemas() { + return proxyDataContext.refreshSchemas(); + } +} diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/jndi/loader/JndiCsvDataContextLoader.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/jndi/loader/JndiCsvDataContextLoader.java new file mode 100644 index 0000000..ee02028 --- /dev/null +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/jndi/loader/JndiCsvDataContextLoader.java @@ -0,0 +1,71 @@ +package net.forwardfire.vasc.backend.metamodel.jndi.loader; + +import java.util.Map; + +import org.eobjects.metamodel.DataContext; +import org.eobjects.metamodel.csv.CsvConfiguration; +import org.eobjects.metamodel.csv.CsvDataContext; + +/** + * JndiCsvDataContextLoader Loads and confis csv DataContext from jndi loader config. + * + * @author Willem Cazander + * @version 1.0 May 22, 2012 + */ +public class JndiCsvDataContextLoader implements JndiDataContextLoader { + + private boolean useUrlSource = false; + + public JndiCsvDataContextLoader() { + } + public JndiCsvDataContextLoader(boolean useUrlSource) { + setUseUrlSource(useUrlSource); + } + + public DataContext loadDataContext(JndiDataContextLoaderConfig config) { + if (useUrlSource) { + return new CsvDataContext(config.checkBackendUrl(),createCsvConfig(config.getBackendParameters())); + } else { + return new CsvDataContext(config.checkFile(),createCsvConfig(config.getBackendParameters())); + } + } + + protected CsvConfiguration createCsvConfig(Map param) { + int columnNameLineNumber = 0; + String encoding = "UTF-8"; + char separatorChar = CsvConfiguration.DEFAULT_SEPARATOR_CHAR; + char quoteChar = CsvConfiguration.DEFAULT_QUOTE_CHAR; + char escapeChar = CsvConfiguration.DEFAULT_ESCAPE_CHAR; + boolean failOnInconsistentRowLength = false; + if (param.containsKey("fileEnconding")) { + encoding = param.get("fileEnconding"); + } + if (param.containsKey("separatorChar")) { + separatorChar = param.get("separatorChar").charAt(0); + } + if (param.containsKey("quoteChar")) { + quoteChar = param.get("quoteChar").charAt(0); + } + if (param.containsKey("escapeChar")) { + escapeChar = param.get("escapeChar").charAt(0); + } + if (param.containsKey("failOnInconsistentRowLength")) { + failOnInconsistentRowLength = true; + } + return new CsvConfiguration(columnNameLineNumber,encoding,separatorChar,quoteChar,escapeChar,failOnInconsistentRowLength); + } + + /** + * @return the useUrlSource + */ + public boolean isUseUrlSource() { + return useUrlSource; + } + + /** + * @param useUrlSource the useUrlSource to set + */ + public void setUseUrlSource(boolean useUrlSource) { + this.useUrlSource = useUrlSource; + } +} diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/jndi/loader/JndiDataContextLoader.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/jndi/loader/JndiDataContextLoader.java new file mode 100644 index 0000000..0f36711 --- /dev/null +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/jndi/loader/JndiDataContextLoader.java @@ -0,0 +1,17 @@ +package net.forwardfire.vasc.backend.metamodel.jndi.loader; + +import org.eobjects.metamodel.DataContext; + +/** + * JndiDataContextLoader loads and config the DataContext(DC) from the loader config. + * This makes the jndi factory class independent from all MetaModel DC classes. + * So we can have one factory for all DC without needing all DC libs in classpath when + * most are not needed if using only one or two different DC's. + * + * @author Willem Cazander + * @version 1.0 May 22, 2012 + */ +public interface JndiDataContextLoader { + + public DataContext loadDataContext(JndiDataContextLoaderConfig config); +} diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/jndi/loader/JndiDataContextLoaderConfig.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/jndi/loader/JndiDataContextLoaderConfig.java new file mode 100644 index 0000000..88500ae --- /dev/null +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/jndi/loader/JndiDataContextLoaderConfig.java @@ -0,0 +1,238 @@ +package net.forwardfire.vasc.backend.metamodel.jndi.loader; + +import java.io.File; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.Map; + +import javax.naming.Context; +import javax.naming.Name; +import javax.naming.RefAddr; +import javax.naming.Reference; + +/** + * JndiDataContextLoaderConfig hold generic parameters to config the loader and DataContext. + * + * @author Willem Cazander + * @version 1.0 May 22, 2012 + */ +public class JndiDataContextLoaderConfig { + + public final static String BACKEND_TYPE = "backendType"; + public final static String BACKEND_FILE = "backendFile"; + public final static String BACKEND_URL = "backendUrl"; + public final static String BACKEND_HOST = "backendHost"; + public final static String BACKEND_PORT = "backendPort"; + public final static String BACKEND_DB = "backendDatabase"; + public final static String BACKEND_USER = "backendUsername"; + public final static String BACKEND_PASS = "backendPassword"; + public final static String BACKEND_CLASS= "backendClass"; + public final static String BACKEND_READ_ONLY = "backendReadOnly"; + + private Object jndiObject = null; + private Name jndiNamePath = null; + private Context jndiContext = null; + private Hashtable jndiEnv = null; + private String jndiObjectName = null; + private String backendType = null; + private String backendFile = null; + private String backendUrl = null; + private String backendHost = null; + private String backendPort = null; + private String backendDatabase = null; + private String backendUsername = null; + private String backendPassword = null; + private String backendClass = null; + private String backendReadOnly = null; + private Map backendParameters = null; + + public JndiDataContextLoaderConfig(Object jndiObject,Name jndiNamePath,Context jndiContext,Hashtable jndiEnv,String jndiObjectName) { + this.jndiObject=jndiObject; + this.jndiNamePath=jndiNamePath; + this.jndiContext=jndiContext; + this.jndiEnv=jndiEnv; + this.jndiObjectName=jndiObjectName; + + initBackendParameters(); + initBeanParameters(); + } + + protected void initBackendParameters() { + // Copy config parameters of this factory instance to map + backendParameters = new HashMap(30); + Reference ref = (Reference) getJndiObject(); + Enumeration addrs = ref.getAll(); + while (addrs.hasMoreElements()) { + RefAddr addr = (RefAddr) addrs.nextElement(); + String name = addr.getType(); + String value = (String) addr.getContent(); + backendParameters.put(name,value); + } + } + + protected void initBeanParameters() { + // Check out most generic parameters + backendType = backendParameters.get(BACKEND_TYPE); + backendFile = backendParameters.get(BACKEND_FILE); + backendUrl = backendParameters.get(BACKEND_URL); + backendHost = backendParameters.get(BACKEND_HOST); + backendPort = backendParameters.get(BACKEND_PORT); + backendDatabase = backendParameters.get(BACKEND_DB); + backendUsername = backendParameters.get(BACKEND_USER); + backendPassword = backendParameters.get(BACKEND_PASS); + backendClass = backendParameters.get(BACKEND_CLASS); + backendReadOnly = backendParameters.get(BACKEND_READ_ONLY); + if (backendHost==null) { + backendHost = "localhost"; + } + if (backendHost.isEmpty()) { + throw new IllegalArgumentException("Can't work with empty "+BACKEND_HOST+" attribute."); + } + } + + public URL checkBackendUrl() { + if (backendUrl==null) { + throw new IllegalArgumentException("Can't work with null "+BACKEND_URL+" attribute for: "+jndiObjectName); + } + if (backendUrl.isEmpty()) { + throw new IllegalArgumentException("Can't work with empty "+BACKEND_URL+" attribute for: "+jndiObjectName); + } + try { + return new URL(backendUrl); + } catch (MalformedURLException e) { + throw new IllegalArgumentException("Could not convert "+backendUrl+" to url.",e); + } + } + + public File checkFile() { + if (backendFile==null) { + throw new IllegalArgumentException("Can't work with null "+BACKEND_FILE+" attribute for: "+jndiObjectName); + } + if (backendFile.isEmpty()) { + throw new IllegalArgumentException("Can't work with empty "+BACKEND_FILE+" attribute for: "+jndiObjectName); + } + File file = new File(backendFile); + if (file.exists()==false) { + throw new IllegalStateException("File not found: "+file.getName()+" for: "+jndiObjectName); + } + if (file.canRead()==false) { + throw new IllegalStateException("Can't read file: "+file+" for: "+jndiObjectName); + } + return file; + } + + /** + * @return the jndiObject + */ + public Object getJndiObject() { + return jndiObject; + } + + /** + * @return the jndiNamePath + */ + public Name getJndiNamePath() { + return jndiNamePath; + } + + /** + * @return the jndiContext + */ + public Context getJndiContext() { + return jndiContext; + } + + /** + * @return the jndiEnv + */ + public Hashtable getJndiEnv() { + return jndiEnv; + } + + /** + * @return the jndiObjectName + */ + public String getJndiObjectName() { + return jndiObjectName; + } + + /** + * @return the backendType + */ + public String getBackendType() { + return backendType; + } + + /** + * @return the backendFile + */ + public String getBackendFile() { + return backendFile; + } + + /** + * @return the backendUrl + */ + public String getBackendUrl() { + return backendUrl; + } + + /** + * @return the backendHost + */ + public String getBackendHost() { + return backendHost; + } + + /** + * @return the backendPort + */ + public String getBackendPort() { + return backendPort; + } + + /** + * @return the backendDatabase + */ + public String getBackendDatabase() { + return backendDatabase; + } + + /** + * @return the backendUsername + */ + public String getBackendUsername() { + return backendUsername; + } + + /** + * @return the backendPassword + */ + public String getBackendPassword() { + return backendPassword; + } + + /** + * @return the backendClass + */ + public String getBackendClass() { + return backendClass; + } + + /** + * @return the backendReadOnly + */ + public String getBackendReadOnly() { + return backendReadOnly; + } + + /** + * @return the backendParameters + */ + public Map getBackendParameters() { + return backendParameters; + } +} diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/jndi/loader/JndiJdbcDataContextLoader.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/jndi/loader/JndiJdbcDataContextLoader.java new file mode 100644 index 0000000..434a4eb --- /dev/null +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/jndi/loader/JndiJdbcDataContextLoader.java @@ -0,0 +1,90 @@ +package net.forwardfire.vasc.backend.metamodel.jndi.loader; + +import java.sql.Connection; +import java.sql.DriverManager; + +import javax.naming.InitialContext; +import javax.naming.NamingException; +import javax.sql.DataSource; + +import org.eobjects.metamodel.DataContext; +import org.eobjects.metamodel.jdbc.JdbcDataContext; + +/** + * JndiCsvDataContextLoader Loads and config jdbc DataContext from jndi loader config. + * + * @author Willem Cazander + * @version 1.0 May 22, 2012 + */ +public class JndiJdbcDataContextLoader implements JndiDataContextLoader { + + private boolean useDataSource = true; + + public JndiJdbcDataContextLoader() { + } + public JndiJdbcDataContextLoader(boolean useDataSource) { + setUseDataSource(useDataSource); + } + + public DataContext loadDataContext(JndiDataContextLoaderConfig config) { + if (useDataSource) { + if (config.getBackendUrl()==null) { + throw new IllegalArgumentException("Can't work with null "+JndiDataContextLoaderConfig.BACKEND_URL+" attribute for: "+config.getJndiObjectName()); + } + if (config.getBackendUrl().isEmpty()) { + throw new IllegalArgumentException("Can't work with empty "+JndiDataContextLoaderConfig.BACKEND_URL+" attribute for: "+config.getJndiObjectName()); + } + + return new JdbcDataContext(getDataSource(config.getJndiObjectName(),config.getBackendUrl())); + } else { + config.checkBackendUrl(); + return new JdbcDataContext(getConnection( + config.getJndiObjectName(), + config.getBackendClass(), + config.getBackendUrl(), + config.getBackendUsername(), + config.getBackendPassword() + )); + } + } + + protected Connection getConnection(String objectName,String driverClass,String url,String user,String pass) { + try { + if (driverClass!=null && driverClass.isEmpty()==false) { + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + if (cl==null) { + cl = this.getClass().getClassLoader(); + } + cl.loadClass(driverClass); + } + Connection connection = DriverManager.getConnection(url,user,pass); + return connection; + } catch (Exception e) { + throw new RuntimeException("Could not get jdbc connection to: "+url+" for: "+objectName,e); + } + } + + protected DataSource getDataSource(String objectName,String jndiName) { + try { + InitialContext context = new InitialContext(); + DataSource datasource = (DataSource)context.lookup(jndiName); + return datasource; + } catch (NamingException e) { + throw new IllegalStateException("Jndi naming error on: "+jndiName+" for: "+objectName,e); + } + } + + /** + * @return the useDataSource + */ + public boolean isUseDataSource() { + return useDataSource; + } + + /** + * @param useDataSource the useDataSource to set + */ + public void setUseDataSource(boolean useDataSource) { + this.useDataSource = useDataSource; + } +} diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/jndi/loader/JndiMongodbDataContextLoader.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/jndi/loader/JndiMongodbDataContextLoader.java new file mode 100644 index 0000000..6279def --- /dev/null +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/jndi/loader/JndiMongodbDataContextLoader.java @@ -0,0 +1,106 @@ +package net.forwardfire.vasc.backend.metamodel.jndi.loader; + +import java.net.UnknownHostException; + +import javax.naming.InitialContext; +import javax.naming.NamingException; + +import org.eobjects.metamodel.DataContext; +import org.eobjects.metamodel.mongodb.MongoDbDataContext; +import org.eobjects.metamodel.mongodb.MongoDbDataContextBean; + +import com.mongodb.DB; +import com.mongodb.Mongo; +import com.mongodb.MongoOptions; +import com.mongodb.ServerAddress; + +/** + * JndiCsvDataContextLoader Loads and config mongodb DataContext from jndi loader config. + * + * @author Willem Cazander + * @version 1.0 May 22, 2012 + */ +public class JndiMongodbDataContextLoader implements JndiDataContextLoader { + + private boolean useJndiResource = false; + + public JndiMongodbDataContextLoader() { + } + public JndiMongodbDataContextLoader(boolean useJndiResource) { + setUseJndiResource(useJndiResource); + } + + public DataContext loadDataContext(JndiDataContextLoaderConfig config) { + MongoDbDataContextBean result = null; + if (useJndiResource) { + config.checkBackendUrl(); + result = new MongoDbDataContextBean(getMongodbJdni(config.getJndiObjectName(),config.getBackendUrl())); + } else { + int mongoPort = 27017; + if (config.getBackendPort()!=null && config.getBackendPort().isEmpty()==false) { + mongoPort = new Integer(config.getBackendPort()); + } + result = new MongoDbDataContextBean(getMongodbConnection( + config.getJndiObjectName(), + config.getBackendHost(), + mongoPort, + config.getBackendDatabase(), + config.getBackendUsername(), + config.getBackendPassword() + )); + } + result.setRegisterMBean(true); // TODO: make flag + result.start(); + return result; + } + + protected DB getMongodbJdni(String objectName,String jndiName) { + try { + InitialContext context = new InitialContext(); + DB db = (DB)context.lookup(jndiName); + return db; + } catch (NamingException e) { + throw new IllegalStateException("Jndi naming error on: "+jndiName+" for: "+objectName,e); + } + } + + protected DB getMongodbConnection(String objectName,String hostname,int port,String database,String username,String password) { + if (database==null) { + throw new IllegalArgumentException("Can't work with null "+JndiDataContextLoaderConfig.BACKEND_DB+" attribute for: "+objectName); + } + if (database.isEmpty()) { + throw new IllegalArgumentException("Can't work with empty "+JndiDataContextLoaderConfig.BACKEND_DB+" attribute for: "+objectName); + } + ServerAddress server; + try { + server = new ServerAddress(hostname,port); + } catch (UnknownHostException e) { + throw new IllegalStateException("Could not create hostname from: "+hostname+" for: "+objectName,e); + } + MongoOptions options = new MongoOptions(); + Mongo mongo = new Mongo(server,options); + DB db = mongo.getDB(database); + if (username!=null && password!=null) { + boolean auth = db.authenticate(username, password.toCharArray()); + if (auth==false) { + throw new IllegalStateException("Could not auth to db: "+database+" with username: "+username+" for: "+objectName); + } + } + return db; + } + + /** + * @return the useJndiResource + */ + public boolean isUseJndiResource() { + return useJndiResource; + } + + + /** + * @param useJndiResource the useJndiResource to set + */ + public void setUseJndiResource(boolean useJndiResource) { + this.useJndiResource = useJndiResource; + } +} diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/jndi/loader/JndiXmlDomDataContextLoader.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/jndi/loader/JndiXmlDomDataContextLoader.java new file mode 100644 index 0000000..6386496 --- /dev/null +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/jndi/loader/JndiXmlDomDataContextLoader.java @@ -0,0 +1,47 @@ +package net.forwardfire.vasc.backend.metamodel.jndi.loader; + +import org.eobjects.metamodel.DataContext; +import org.eobjects.metamodel.xml.XmlDomDataContext; + +/** + * JndiCsvDataContextLoader Loads and config xml dom DataContext from jndi loader config. + * + * @author Willem Cazander + * @version 1.0 May 22, 2012 + */ +public class JndiXmlDomDataContextLoader implements JndiDataContextLoader { + + private boolean useUrlSource = false; + + public JndiXmlDomDataContextLoader() { + } + public JndiXmlDomDataContextLoader(boolean useUrlSource) { + setUseUrlSource(useUrlSource); + } + + public DataContext loadDataContext(JndiDataContextLoaderConfig config) { + boolean autoFlattenTables = true; + if ("false".equalsIgnoreCase(config.getBackendParameters().get("autoFlattenTables"))) { + autoFlattenTables = false; + } + if (useUrlSource) { + return new XmlDomDataContext(config.checkBackendUrl(),autoFlattenTables); + } else { + return new XmlDomDataContext(config.checkFile(),autoFlattenTables); + } + } + + /** + * @return the useUrlSource + */ + public boolean isUseUrlSource() { + return useUrlSource; + } + + /** + * @param useUrlSource the useUrlSource to set + */ + public void setUseUrlSource(boolean useUrlSource) { + this.useUrlSource = useUrlSource; + } +} diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/jndi/loader/JndiXmlSaxDataContextLoader.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/jndi/loader/JndiXmlSaxDataContextLoader.java new file mode 100644 index 0000000..ad289ad --- /dev/null +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/jndi/loader/JndiXmlSaxDataContextLoader.java @@ -0,0 +1,96 @@ +package net.forwardfire.vasc.backend.metamodel.jndi.loader; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.eobjects.metamodel.DataContext; +import org.eobjects.metamodel.util.Ref; +import org.eobjects.metamodel.xml.XmlSaxDataContext; +import org.eobjects.metamodel.xml.XmlSaxTableDef; +import org.xml.sax.InputSource; + +/** + * JndiXmlSaxDataContextLoader Loads and config xml sax DataContext from jndi loader config. + * + * @author Willem Cazander + * @version 1.0 May 22, 2012 + */ +public class JndiXmlSaxDataContextLoader implements JndiDataContextLoader { + + private boolean useUrlSource = false; + + public JndiXmlSaxDataContextLoader() { + } + public JndiXmlSaxDataContextLoader(boolean useUrlSource) { + setUseUrlSource(useUrlSource); + } + + public DataContext loadDataContext(JndiDataContextLoaderConfig config) { + List tableSchemas = createXmlSaxConfig(config.getJndiObjectName(),config.getBackendParameters()); + XmlSaxTableDef[] args = new XmlSaxTableDef[tableSchemas.size()]; + if (useUrlSource) { + final URL url = config.checkBackendUrl(); + return new XmlSaxDataContext(new Ref() { // TODO: missing constructor in XmlSaxDataContext + public InputSource get() { + InputStream in = null; + try { + in = url.openStream(); + return new InputSource(in); + } catch (IOException e) { + throw new IllegalStateException("Could not read url; "+url,e); + } finally { + if (in!=null) { + try { + in.close(); + } catch (IOException e) { + } + } + } + } + },tableSchemas.toArray(args)); + } else { + return new XmlSaxDataContext(config.checkFile(),tableSchemas.toArray(args)); // copy List to array + } + } + + protected List createXmlSaxConfig(String objectName,Map param) { + String rowXPath = param.get("rowXPath"); + String dataXPaths = param.get("dataXPaths"); + if (rowXPath==null) { + throw new IllegalArgumentException("Can't work with null rowXPath attribute for: "+objectName); + } + if (rowXPath.isEmpty()) { + throw new IllegalArgumentException("Can't work with empty rowXPath attribute for: "+objectName); + } + if (dataXPaths==null) { + throw new IllegalArgumentException("Can't work with null dataXPaths attribute for: "+objectName); + } + if (dataXPaths.isEmpty()) { + throw new IllegalArgumentException("Can't work with empty dataXPaths attribute for: "+objectName); + } + String[] args = dataXPaths.split(","); + + List tableSchemas = new ArrayList(5); + XmlSaxTableDef tableSchema = new XmlSaxTableDef(rowXPath,args); + tableSchemas.add(tableSchema); + return tableSchemas; + } + + /** + * @return the useUrlSource + */ + public boolean isUseUrlSource() { + return useUrlSource; + } + + /** + * @param useUrlSource the useUrlSource to set + */ + public void setUseUrlSource(boolean useUrlSource) { + this.useUrlSource = useUrlSource; + } +} diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/x4o/XmlSaxSchemaElement.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/x4o/XmlSaxSchemaElement.java new file mode 100644 index 0000000..ec6f83a --- /dev/null +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/x4o/XmlSaxSchemaElement.java @@ -0,0 +1,55 @@ +package net.forwardfire.vasc.backend.metamodel.x4o; + +import java.util.ArrayList; +import java.util.List; + +import net.forwardfire.vasc.backend.metamodel.MetaModelDataContextXmlSax; + +import org.eobjects.metamodel.xml.XmlSaxTableDef; +import org.x4o.xml.element.AbstractElement; +import org.x4o.xml.element.Element; +import org.x4o.xml.element.ElementException; + +public class XmlSaxSchemaElement extends AbstractElement { + + /** + * @see org.x4o.xml.element.AbstractElement#doElementRun() + */ + @Override + public void doElementRun() throws ElementException { + if (getElementClass().getTag().endsWith("Column")) { + return; // save one object to code. + } + if (getParent()==null) { + throw new ElementException("Parent element is null."); + } + if (getParent().getElementObject()==null) { + throw new ElementException("Parent object is null."); + } + if ((getParent().getElementObject() instanceof MetaModelDataContextXmlSax)==false) { + throw new ElementException("Parent object is not MetaModelDataContextXmlSax class."); + } + String rowXPath = getAttributes().get("rowXPath"); + if (rowXPath==null) { + throw new ElementException("Attribute rowXPath is null."); + } + if (rowXPath.isEmpty()) { + throw new ElementException("Attribute rowXPath is empty."); + } + List columns = new ArrayList(15); + for (Element e:getChilderen()) { + String col = e.getAttributes().get("dataXPath"); + if (col==null) { + throw new ElementException("Attribute dataXPath is null."); + } + if (col.isEmpty()) { + throw new ElementException("Attribute dataXPath is empty."); + } + columns.add(col); + } + MetaModelDataContextXmlSax saxDataContext = (MetaModelDataContextXmlSax)getParent().getElementObject(); + String[] args = new String[columns.size()]; + XmlSaxTableDef tableSchema = new XmlSaxTableDef(rowXPath,columns.toArray(args)); + saxDataContext.addTableSchema(tableSchema); + } +} diff --git a/vasc-backend/vasc-backend-metamodel/src/main/resources/META-INF/vasc/vasc-backend-metamodel.eld b/vasc-backend/vasc-backend-metamodel/src/main/resources/META-INF/vasc/vasc-backend-metamodel.eld index b4ae26e..8959e50 100644 --- a/vasc-backend/vasc-backend-metamodel/src/main/resources/META-INF/vasc/vasc-backend-metamodel.eld +++ b/vasc-backend/vasc-backend-metamodel/src/main/resources/META-INF/vasc/vasc-backend-metamodel.eld @@ -1,11 +1,21 @@ - - - - - + + + + + + + + + + + + + + + diff --git a/vasc-backend/vasc-backend-metamodel/src/test/java/BravoTest.java b/vasc-backend/vasc-backend-metamodel/src/test/java/BravoTest.java new file mode 100644 index 0000000..818e14e --- /dev/null +++ b/vasc-backend/vasc-backend-metamodel/src/test/java/BravoTest.java @@ -0,0 +1,67 @@ +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.Statement; + +import junit.framework.TestCase; + +import org.eobjects.metamodel.data.DataSet; +import org.eobjects.metamodel.jdbc.JdbcDataContext; +import org.eobjects.metamodel.schema.Table; + + +public class BravoTest extends TestCase { + + private Connection conn; + + @Override + protected void setUp() throws Exception { + super.setUp(); + Class.forName("org.postgresql.Driver"); + conn = DriverManager.getConnection("jdbc:postgresql://localhost/openbravo","postgres","postgresql"); + } + + @Override + protected void tearDown() throws Exception { + super.tearDown(); + conn.close(); + } + + public void testDataTypeBoolean() throws Exception { + +/* + Statement s = conn.createStatement(); + s.executeUpdate("DROP TABLE test_type_bool IF EXISTS;"); + s.executeUpdate("CREATE TABLE test_type_bool (id IDENTITY not null primary key,name varchar not null,active boolean not null);"); + s.executeUpdate("INSERT INTO test_type_bool VALUES(1,\'name\',true);"); + + // Test working data first + JdbcDataContext dc = new JdbcDataContext(conn); + Table table = dc.getDefaultSchema().getTableByName("TEST_TYPE_BOOL"); + assertNotNull(table); + DataSet ds = dc.query().from(table).select(table.getColumns()).execute(); + assertTrue(ds.next()); + ds = dc.query().from(table).selectCount().execute(); + assertTrue(ds.next()); + + // Now let it fail + s.executeUpdate("DROP TABLE test_type_bool IF EXISTS;"); + s.executeUpdate("CREATE TABLE test_type_bool (id IDENTITY not null primary key,name varchar not null,active boolean not null);"); + s.executeUpdate("INSERT INTO test_type_bool VALUES(1,\'\',true);"); + + // Make sure it works from jdbc driver + Boolean active = null; + s.execute("SELECT * FROM TEST_TYPE_BOOL"); + ResultSet rs = s.getResultSet(); + while (rs.next()) { + active = rs.getBoolean(3); // this should be same method as exception + } + assertTrue(active); + */ + // Fails on execute. + long startTime = System.currentTimeMillis(); + JdbcDataContext dc = new JdbcDataContext(conn); + long stopTime = System.currentTimeMillis(); + System.out.println("DC init took: "+(stopTime-startTime)+" ms. for total tables: "+dc.getDefaultSchema().getTableCount()); + } +} diff --git a/vasc-backend/vasc-backend-metamodel/src/test/java/H2Test.java b/vasc-backend/vasc-backend-metamodel/src/test/java/H2Test.java new file mode 100644 index 0000000..99b57e0 --- /dev/null +++ b/vasc-backend/vasc-backend-metamodel/src/test/java/H2Test.java @@ -0,0 +1,70 @@ +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.Statement; + +import junit.framework.TestCase; + +import org.eobjects.metamodel.data.DataSet; +import org.eobjects.metamodel.jdbc.JdbcDataContext; +import org.eobjects.metamodel.schema.Table; + + +public class H2Test extends TestCase { + + private Connection conn; + + @Override + protected void setUp() throws Exception { + super.setUp(); + Class.forName("org.h2.Driver"); + conn = DriverManager.getConnection("jdbc:h2:mem:"); + } + + @Override + protected void tearDown() throws Exception { + super.tearDown(); + conn.close(); + } + + public void testDataTypeBoolean() throws Exception { + + // This works see diff is empty value in column before boolean column ... + Statement s = conn.createStatement(); + s.executeUpdate("DROP TABLE test_type_bool IF EXISTS;"); + s.executeUpdate("CREATE TABLE test_type_bool (id IDENTITY not null primary key,name varchar not null,active boolean not null);"); + s.executeUpdate("INSERT INTO test_type_bool VALUES(1,\'name\',true);"); + + // Test working data first + JdbcDataContext dc = new JdbcDataContext(conn); + Table table = dc.getDefaultSchema().getTableByName("TEST_TYPE_BOOL"); + assertNotNull(table); + DataSet ds = dc.query().from(table).select(table.getColumns()).execute(); + assertTrue(ds.next()); + ds = dc.query().from(table).selectCount().execute(); + assertTrue(ds.next()); + + // Now let it fail + s.executeUpdate("DROP TABLE test_type_bool IF EXISTS;"); + s.executeUpdate("CREATE TABLE test_type_bool (id IDENTITY not null primary key,name varchar not null,active boolean not null);"); + s.executeUpdate("INSERT INTO test_type_bool VALUES(1,\'\',true);"); + + // Make sure it works from jdbc driver + Boolean active = null; + s.execute("SELECT * FROM TEST_TYPE_BOOL"); + ResultSet rs = s.getResultSet(); + while (rs.next()) { + active = rs.getBoolean(3); // this should be same method as exception + } + assertTrue(active); + + // Fails on execute. + dc = new JdbcDataContext(conn); + table = dc.getDefaultSchema().getTableByName("TEST_TYPE_BOOL"); + assertNotNull(table); + ds = dc.query().from(table).select(table.getColumns()).execute(); + assertTrue(ds.next()); + ds = dc.query().from(table).selectCount().execute(); + assertTrue(ds.next()); + } +} diff --git a/vasc-backend/vasc-backend-metamodel/src/test/java/SwingLoadTest.java b/vasc-backend/vasc-backend-metamodel/src/test/java/SwingLoadTest.java new file mode 100644 index 0000000..9bd826c --- /dev/null +++ b/vasc-backend/vasc-backend-metamodel/src/test/java/SwingLoadTest.java @@ -0,0 +1,38 @@ + +import java.io.File; + +import org.eobjects.metamodel.UpdateCallback; +import org.eobjects.metamodel.UpdateScript; +import org.eobjects.metamodel.csv.CsvDataContext; +import org.eobjects.metamodel.data.DataSet; +import org.eobjects.metamodel.data.Row; +import org.eobjects.metamodel.schema.Schema; +import org.eobjects.metamodel.schema.Table; +import org.eobjects.metamodel.util.MutableRef; + +public class SwingLoadTest { + private Table table = null; + public static void main(String[] argu) { + try {SwingLoadTest test = new SwingLoadTest();test.run(argu);} catch (Exception e) {e.printStackTrace();} + } + public void run(String[] argu) throws Exception { + File tmpFile = File.createTempFile("test-class-loading", "csv"); + tmpFile.deleteOnExit(); + CsvDataContext dataContext = new CsvDataContext(tmpFile); + final Schema schema = dataContext.getDefaultSchema(); + dataContext.executeUpdate(new UpdateScript() { + public void run(UpdateCallback cb) { + MutableRef tableRef = new MutableRef
(); + table = cb.createTable(schema, "table").withColumn("column").execute(); + tableRef.set(table); + cb.insertInto(table).value(0,"data").execute(); + } + }); + DataSet ds = dataContext.query().from(table).select(table.getColumns()).execute(); + while (ds.next()) { + Row row = ds.getRow(); + System.out.println("Row value contains "+row.getValue(0)); + } + ds.close(); + } +} diff --git a/vasc-backend/vasc-backend-metamodel/src/test/java/net/forwardfire/vasc/backend/metamodel/bundle/ResouceBundleTest.java b/vasc-backend/vasc-backend-metamodel/src/test/java/net/forwardfire/vasc/backend/metamodel/bundle/ResouceBundleTest.java new file mode 100644 index 0000000..71ff57d --- /dev/null +++ b/vasc-backend/vasc-backend-metamodel/src/test/java/net/forwardfire/vasc/backend/metamodel/bundle/ResouceBundleTest.java @@ -0,0 +1,36 @@ +package net.forwardfire.vasc.backend.metamodel.bundle; + +import java.io.File; + +import org.eobjects.metamodel.DataContext; +import org.eobjects.metamodel.UpdateableDataContext; +import org.eobjects.metamodel.csv.CsvDataContext; +import org.eobjects.metamodel.data.DataSet; +import org.eobjects.metamodel.data.Row; +import org.eobjects.metamodel.schema.Table; + +import junit.framework.TestCase; + +public class ResouceBundleTest extends TestCase { + + public void testBundle() { + final String tableName = "mm-bundle-test"; // Setup some small test data in tmp + File testFile = new File(System.getProperty("java.io.tmpdir")+File.separatorChar+tableName+".properties"); + final boolean createTable = testFile.exists()==false; + DataContext dataContext = new ResourceBundleDataContext(testFile); + assertTrue(dataContext instanceof UpdateableDataContext); + + for (String t:dataContext.getDefaultSchema().getTableNames()) { + System.out.println("table: '"+t+"'"); + } + + Table table = dataContext.getDefaultSchema().getTableByName("en"); + assertNotNull(table); + + DataSet ds = dataContext.query().from(table).select(table.getColumns()).execute(); + while (ds.next()) { + Row row = ds.getRow(); + System.out.println("row: "+row.getValue(0)+" "+row.getValue(1)+" "+row.getValue(2)); + } + } +} diff --git a/vasc-backend/vasc-backend-metamodel/src/test/java/net/forwardfire/vasc/backend/metamodel/crud/CrudContextTest.java b/vasc-backend/vasc-backend-metamodel/src/test/java/net/forwardfire/vasc/backend/metamodel/crud/CrudContextTest.java new file mode 100644 index 0000000..4129c69 --- /dev/null +++ b/vasc-backend/vasc-backend-metamodel/src/test/java/net/forwardfire/vasc/backend/metamodel/crud/CrudContextTest.java @@ -0,0 +1,97 @@ +package net.forwardfire.vasc.backend.metamodel.crud; + +import java.io.File; +import org.eobjects.metamodel.DataContext; +import org.eobjects.metamodel.UpdateCallback; +import org.eobjects.metamodel.UpdateScript; +import org.eobjects.metamodel.UpdateableDataContext; +import org.eobjects.metamodel.csv.CsvDataContext; +import org.eobjects.metamodel.data.DataSet; +import org.eobjects.metamodel.data.Row; +import org.eobjects.metamodel.schema.Schema; +import org.eobjects.metamodel.schema.Table; +import org.eobjects.metamodel.util.MutableRef; +import junit.framework.TestCase; + +public class CrudContextTest extends TestCase { + + public void testCrud() { + final String tableName = "test-crud"; // Setup some small test data in tmp + File testFile = new File(System.getProperty("java.io.tmpdir")+File.separatorChar+tableName+".csv"); + final boolean createTable = testFile.exists()==false; + CsvDataContext dataContext = new CsvDataContext(testFile); + assertTrue(dataContext instanceof UpdateableDataContext); + final Schema schema = dataContext.getDefaultSchema(); + final MutableRef
tableRef = new MutableRef
(); + dataContext.executeUpdate(new UpdateScript() { + public void run(UpdateCallback cb) { + Table table = null; + int idx = 0; + if (createTable) { + table = cb.createTable(schema, tableName).withColumn("id").withColumn("name").withColumn("active").execute(); + tableRef.set(table); + } else { + table = cb.getDataContext().getDefaultSchema().getTableByName(tableName); + idx = generateNextId(cb.getDataContext(),table); + } + cb.insertInto(table).value(0,idx+1).value(1, "foo").value(2, true).execute(); + cb.insertInto(table).value(0,idx+2).value(1, "foo").value(2, false).execute(); + cb.insertInto(table).value(0,idx+3).value(1, "bar").value(2, false).execute(); + cb.insertInto(table).value(0,idx+4).value(1, "bar").value(2, true).execute(); + cb.insertInto(table).value(0,idx+5).value(1, "object").value(2, true).execute(); + } + }); + + // Wrap to CrudDataContext and get table to test with. + CrudDataContext crudDataContext = new CrudDataContextImpl((UpdateableDataContext)dataContext); + Table table = crudDataContext.getDefaultSchema().getTableByName(tableName); + assertNotNull(table); + + // Fetch and update data + DataSet ds = crudDataContext.query().from(table).select(table.getColumns()).execute(); + while (ds.next()) { + Row row = ds.getRow(); + if (row instanceof UpdateableRow) { + UpdateableRow rowCrud = (UpdateableRow)row; + if (rowCrud.getValue("name")!=null && rowCrud.getValue("name").toString().startsWith("test")==false) { + rowCrud.setValue("active", false); + crudDataContext.merge(rowCrud); + } + } + } + ds.close(); + + // Lets add an record. + UpdateableRow newRow = crudDataContext.createRow(table); + newRow.setValue("id", generateNextId(crudDataContext,table)); // Leave key out on jdbc/mongo backends for sequence/auto id. + newRow.setValue("name", "test date "+System.currentTimeMillis()); + newRow.setValue("active", true); + crudDataContext.persist(newRow); + + // Delete some data. + DataSet dsDel = crudDataContext.query().from(table).select(table.getColumns()).where("name").equals("foo").or("name").equals("bar").execute(); + while (dsDel.next()) { + crudDataContext.delete((UpdateableRow)dsDel.getRow()); + } + dsDel.close(); + //testFile.deleteOnExit(); + } + + private int generateNextId(DataContext dataContext,Table table) { + //DataSet dsMax = dataContext.query().from(table).select(FunctionType.MAX, table.getColumn(0)).execute(); + //assertTrue(dsMax.next()); + //Row rowMax = dsMax.getRow(); + //int recordId = new Integer(rowMax.getValue(0).toString()); // MAX stops on first row ? + //dsMax.close(); + int recordId = 0; + DataSet ds = dataContext.query().from(table).select(table.getColumns()).execute(); + while (ds.next()) { + Row row = ds.getRow(); + int id = new Integer(row.getValue(0).toString()); + if (id > recordId) { + recordId = id; + } + } + return recordId + 1; // Fetch new ID because CSV has no auto ID + } +} diff --git a/vasc-backend/vasc-backend-mongodb/pom.xml b/vasc-backend/vasc-backend-mongodb/pom.xml index 171f7cd..4164784 100644 --- a/vasc-backend/vasc-backend-mongodb/pom.xml +++ b/vasc-backend/vasc-backend-mongodb/pom.xml @@ -18,7 +18,7 @@ org.mongodb mongo-java-driver - 2.7.2 + ${mongo-java-driver.version} \ No newline at end of file diff --git a/vasc-core-ejb3/pom.xml b/vasc-core-ejb3/pom.xml index 25356b3..7d07998 100644 --- a/vasc-core-ejb3/pom.xml +++ b/vasc-core-ejb3/pom.xml @@ -24,13 +24,13 @@ javax.ejb ejb-api - 3.0 + ${ejb-api.version} provided javax.persistence persistence-api - 1.0 + ${persistence-api.version} provided diff --git a/vasc-core-ejb3/src/main/java/net/forwardfire/vasc/ejb3/VascServiceManagerImpl.java b/vasc-core-ejb3/src/main/java/net/forwardfire/vasc/ejb3/VascServiceManagerImpl.java index 75a3d2e..24b5e98 100644 --- a/vasc-core-ejb3/src/main/java/net/forwardfire/vasc/ejb3/VascServiceManagerImpl.java +++ b/vasc-core-ejb3/src/main/java/net/forwardfire/vasc/ejb3/VascServiceManagerImpl.java @@ -50,6 +50,7 @@ import net.forwardfire.vasc.backends.jpa.EntityManagerProvider; import net.forwardfire.vasc.core.VascController; import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntryControllerLocal; +import net.forwardfire.vasc.core.VascEntryLocal; import net.forwardfire.vasc.impl.DefaultVascFactory; import net.forwardfire.vasc.impl.x4o.VascParser; import net.forwardfire.vasc.xpql.ejb3.XpqlQueryManager; @@ -106,7 +107,7 @@ public class VascServiceManagerImpl implements VascServiceManager.IRemote,VascSe long s = System.currentTimeMillis(); // get local jvm plugging controller - VascController c = DefaultVascFactory.getDefaultVascController(0l, "nobody", "NO_ROLE"); + VascController c = DefaultVascFactory.getDefaultVascController(); for (String key:keys.keySet()) { String value = keys.get(key); @@ -198,7 +199,7 @@ public class VascServiceManagerImpl implements VascServiceManager.IRemote,VascSe public VascEntry getVascEntry(String entryId) { VascController v = getVascController(); - VascEntry ve = v.getVascEntryController().getVascEntryById(entryId); + VascEntryLocal ve = (VascEntryLocal)v.getVascEntryController().getVascEntryById(entryId); try { VascEntry result = ve.clone(); diff --git a/vasc-core/pom.xml b/vasc-core/pom.xml index 05e4dc9..629e298 100644 --- a/vasc-core/pom.xml +++ b/vasc-core/pom.xml @@ -29,13 +29,13 @@ javax.persistence persistence-api - 1.0 + ${persistence-api.version} provided org.hibernate hibernate-validator - 3.1.0.CR1 + ${hibernate-validator.version} provided diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/annotations/VascAnnotationParser.java b/vasc-core/src/main/java/net/forwardfire/vasc/annotations/VascAnnotationParser.java index 0e2df7a..d040c18 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/annotations/VascAnnotationParser.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/annotations/VascAnnotationParser.java @@ -71,8 +71,17 @@ public class VascAnnotationParser { return (String)getValue(beanClass,VascI18n.class,null,"image"); } - public Integer getVascOrderIndex(Class beanClass,String property) { - return (Integer)getValue(beanClass,VascFieldOrder.class,property,"orderIndex"); + public Integer getVascOrder(Class beanClass,String property) { + return (Integer)getValue(beanClass,VascFieldOrder.class,property,"order"); + } + public Integer getVascOrderCreate(Class beanClass,String property) { + return (Integer)getValue(beanClass,VascFieldOrder.class,property,"orderCreate"); + } + public Integer getVascOrderEdit(Class beanClass,String property) { + return (Integer)getValue(beanClass,VascFieldOrder.class,property,"orderEdit"); + } + public Integer getVascOrderList(Class beanClass,String property) { + return (Integer)getValue(beanClass,VascFieldOrder.class,property,"orderList"); } @@ -499,7 +508,16 @@ public class VascAnnotationParser { } if (a.equals(VascFieldOrder.class)) { VascFieldOrder v = (VascFieldOrder)b; - return v.orderIndex(); + if ("orderCreate".equals(field)) { + return v.orderCreate(); + } + if ("orderEdit".equals(field)) { + return v.orderEdit(); + } + if ("orderList".equals(field)) { + return v.orderList(); + } + return v.order(); } if (a.equals(VascChoices.class)) { VascChoices v = (VascChoices)b; diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/annotations/VascChoicesSelectItemModel.java b/vasc-core/src/main/java/net/forwardfire/vasc/annotations/VascChoicesSelectItemModel.java index f2c7c0f..437527d 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/annotations/VascChoicesSelectItemModel.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/annotations/VascChoicesSelectItemModel.java @@ -63,7 +63,7 @@ public class VascChoicesSelectItemModel implements VascSelectItemModel,Serializa if (nullKeyValue==null) { nullKeyValue = "null"; } - String nullLabelText = entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(nullLabel); + String nullLabelText = entry.getVascFrontendController().getVascEntryResourceResolver().getTextValue(nullLabel); VascSelectItem item = new VascSelectItem(nullLabelText,null,nullKeyValue); result.add(item); } @@ -82,7 +82,7 @@ public class VascChoicesSelectItemModel implements VascSelectItemModel,Serializa if (val) { name = key; } else { - name = entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(key); + name = entry.getVascFrontendController().getVascEntryResourceResolver().getTextValue(key); } item.setLabel(name); Object value = vascChoices.choisesValues()[index]; diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/annotations/VascFieldOrder.java b/vasc-core/src/main/java/net/forwardfire/vasc/annotations/VascFieldOrder.java index 4908094..319e6bd 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/annotations/VascFieldOrder.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/annotations/VascFieldOrder.java @@ -41,6 +41,10 @@ public @interface VascFieldOrder { /** * The editor of the method/field */ - int orderIndex() default 0; + int order() default 0; + + int orderCreate() default 0; + int orderEdit() default 0; + int orderList() default 0; } \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackendState.java b/vasc-core/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackendState.java index 451b207..d978605 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackendState.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackendState.java @@ -47,18 +47,41 @@ abstract public class AbstractVascBackendState implements VascBackendState { parameters = new HashMap(10); } - public void setDataParameter(String key,Object data) { + /** + * @see net.forwardfire.vasc.backend.VascBackendState#setDataParameter(java.lang.String, java.lang.Object) + */ + public void setDataParameter(String key, Object data) { parameters.put(key,data); } - + + /** + * @see net.forwardfire.vasc.backend.VascBackendState#removeDataParameter(java.lang.String) + */ + public void removeDataParameter(String key) { + parameters.remove(key); + } + + /** + * @see net.forwardfire.vasc.backend.VascBackendState#removeDataParameterAll() + */ + public void removeDataParameterAll() { + parameters.clear(); + } + + /** + * @see net.forwardfire.vasc.backend.VascBackendState#getDataParameter(java.lang.String) + */ public Object getDataParameter(String key) { return parameters.get(key); } - + + /** + * @see net.forwardfire.vasc.backend.VascBackendState#getDataParameterKeys() + */ public Set getDataParameterKeys() { return parameters.keySet(); } - + /** * @see net.forwardfire.vasc.backend.VascBackend#getPageIndex() */ diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/backend/VascBackendState.java b/vasc-core/src/main/java/net/forwardfire/vasc/backend/VascBackendState.java index 325a6be..c3b7764 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/backend/VascBackendState.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/backend/VascBackendState.java @@ -34,6 +34,8 @@ import java.util.Set; public interface VascBackendState extends Serializable { public void setDataParameter(String key,Object data); + public void removeDataParameter(String key); + public void removeDataParameterAll(); public Object getDataParameter(String key); public Set getDataParameterKeys(); diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/backend/VirtualVascBackend.java b/vasc-core/src/main/java/net/forwardfire/vasc/backend/VirtualVascBackend.java index 0734f5f..581fd05 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/backend/VirtualVascBackend.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/backend/VirtualVascBackend.java @@ -9,15 +9,21 @@ import net.forwardfire.vasc.core.VascController; import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntryControllerLocal; import net.forwardfire.vasc.core.VascEntryField; +import net.forwardfire.vasc.core.VascEntryFieldLocal; import net.forwardfire.vasc.core.VascEntryFieldSet; +import net.forwardfire.vasc.core.VascEntryFieldSetLocal; +import net.forwardfire.vasc.core.VascEntryLinkLocal; +import net.forwardfire.vasc.core.VascEntryListOption; +import net.forwardfire.vasc.core.VascEntryListOptionLocal; +import net.forwardfire.vasc.core.VascEntryLocal; import net.forwardfire.vasc.core.VascException; -import net.forwardfire.vasc.core.VascLinkEntry; +import net.forwardfire.vasc.core.VascEntryLink; import net.forwardfire.vasc.core.entry.VascEntryFieldValue; import net.forwardfire.vasc.core.entry.VascEntryRecordCreator; import net.forwardfire.vasc.impl.DefaultVascEntry; import net.forwardfire.vasc.impl.DefaultVascEntryField; import net.forwardfire.vasc.impl.DefaultVascEntryFieldSet; -import net.forwardfire.vasc.impl.DefaultVascLinkEntry; +import net.forwardfire.vasc.impl.DefaultVascEntryLink; public class VirtualVascBackend extends AbstractVascBackend { @@ -45,12 +51,12 @@ public class VirtualVascBackend extends AbstractVascBackend { } else if ("linkentries".equals(vascType)) { if (entryId!=null) { VascEntry ve = vascController.getVascEntryController().getVascEntryById(entryId); - result.addAll(ve.getVascLinkEntries()); + result.addAll(ve.getVascEntryLinks()); } } else if ("listoptions".equals(vascType)) { if (entryId!=null) { VascEntry ve = vascController.getVascEntryController().getVascEntryById(entryId); - result.addAll(ve.getListOptions()); + result.addAll(ve.getVascEntryListOptions()); } } @@ -74,45 +80,45 @@ public class VirtualVascBackend extends AbstractVascBackend { if (object instanceof VascEntry) { entryId = ((VascEntry)object).getId(); } - VascEntry veReal = ((VascEntryControllerLocal)vascController.getVascEntryController()).getMasterVascEntryById(entryId); + VascEntryLocal veReal = (VascEntryLocal)((VascEntryControllerLocal)vascController.getVascEntryController()).getMasterVascEntryById(entryId); if ("entry".equals(vascType)) { } else if ("field".equals(vascType)) { - VascEntryField vef = (VascEntryField)object; + VascEntryFieldLocal vef = (VascEntryFieldLocal)object; if (removeReal) { VascEntryField vefReal = veReal.getVascEntryFieldById(vef.getId()); - veReal.removeVascEntryField(vefReal); + veReal.removeVascEntryField((VascEntryFieldLocal)vefReal); } if (addEdit) { veReal.addVascEntryField(vef); } } else if ("fieldset".equals(vascType)) { - VascEntryFieldSet vefs = (VascEntryFieldSet)object; + VascEntryFieldSetLocal vefs = (VascEntryFieldSetLocal)object; if (removeReal) { VascEntryFieldSet vefsReal = veReal.getVascEntryFieldSetById(vefs.getId()); - veReal.removeVascEntryFieldSet(vefsReal); + veReal.removeVascEntryFieldSet((VascEntryFieldSetLocal)vefsReal); } if (addEdit) { veReal.addVascEntryFieldSet(vefs); } } else if ("linkentries".equals(vascType)) { - VascLinkEntry vefs = (VascLinkEntry)object; + VascEntryLinkLocal vefs = (VascEntryLinkLocal)object; if (removeReal) { - VascLinkEntry vefsReal = veReal.getVascLinkEntryById(vefs.getId()); - veReal.removeVascLinkEntry(vefsReal); + VascEntryLink vefsReal = veReal.getVascEntryLinkById(vefs.getId()); + veReal.removeVascEntryLink((VascEntryLinkLocal)vefsReal); } if (addEdit) { - veReal.addVascLinkEntry(vefs); + veReal.addVascEntryLink(vefs); } } else if ("listoptions".equals(vascType)) { - VascEntryField vef = (VascEntryField)object; + VascEntryListOptionLocal vef = (VascEntryListOptionLocal)object; if (removeReal) { - VascEntryField vefReal = veReal.getListOptionById(vef.getId()); - veReal.removeListOption(vefReal); + VascEntryListOption vefReal = veReal.getVascEntryListOptionById(vef.getId()); + veReal.removeVascEntryListOption((VascEntryListOptionLocal)vefReal); } if (addEdit) { - veReal.addListOption(vef); + veReal.addVascEntryListOption(vef); } } return object; @@ -131,7 +137,7 @@ public class VirtualVascBackend extends AbstractVascBackend { } else if ("fieldset".equals(vascType)) { return new BeanVascEntryRecordCreator(DefaultVascEntryFieldSet.class); } else if ("linkentries".equals(vascType)) { - return new BeanVascEntryRecordCreator(DefaultVascLinkEntry.class); + return new BeanVascEntryRecordCreator(DefaultVascEntryLink.class); } else if ("listoptions".equals(vascType)) { return new BeanVascEntryRecordCreator(DefaultVascEntryField.class); } diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxySearch.java b/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxySearch.java index 7cb3b99..0fde42c 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxySearch.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxySearch.java @@ -37,9 +37,7 @@ import net.forwardfire.vasc.core.entry.VascEntryFieldValue; * @version 1.0 Oct 27, 2007 */ public class VascBackendProxySearch extends AbstractVascBackendProxy { - - private long records = 0; - + /** * @see java.lang.Object#clone() */ @@ -75,11 +73,9 @@ public class VascBackendProxySearch extends AbstractVascBackendProxy { public List execute(VascBackendState state) throws VascException { List result = backend.execute(state); if (state.getSearchString()==null) { - if (backend.isPageable()) { - records = backend.fetchTotalExecuteSize(state); - } else { - records = result.size(); - } + return result; + } + if (state.getSearchString().isEmpty()) { return result; } String searchString = state.getSearchString().toLowerCase(); @@ -135,12 +131,12 @@ public class VascBackendProxySearch extends AbstractVascBackendProxy { } */ } - records = search.size(); + //records = search.size(); return search; } @Override public long fetchTotalExecuteSize(VascBackendState state) { - return records; + return backend.fetchTotalExecuteSize(state); } } \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxySort.java b/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxySort.java index f4ecf82..2b861fd 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxySort.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxySort.java @@ -28,6 +28,7 @@ import java.util.List; import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.core.VascEntryField; +import net.forwardfire.vasc.core.VascEntryFieldLocal; import net.forwardfire.vasc.core.VascException; import net.forwardfire.vasc.core.entry.VascEntryFieldValue; @@ -71,7 +72,7 @@ public class VascBackendProxySort extends AbstractVascBackendProxy { } try { final VascEntryField field = entry.getVascEntryFieldById(state.getSortField()); - final VascEntryFieldValue fieldValue = backend.provideVascEntryFieldValue(field.clone()); + final VascEntryFieldValue fieldValue = backend.provideVascEntryFieldValue(((VascEntryFieldLocal)field).clone()); // TODO fixme Collections.sort(result, new Comparator() { @SuppressWarnings("rawtypes") public int compare(Object o1, Object o2) { diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascControllerLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascControllerLocal.java new file mode 100644 index 0000000..2fe0151 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascControllerLocal.java @@ -0,0 +1,110 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.core; + +import net.forwardfire.vasc.backend.VascBackendController; + +/** + * AbstractVascEntryFieldLocal + * + * @author Willem Cazander + * @version 1.0 Jun 2, 2012 + */ +abstract public class AbstractVascControllerLocal implements VascControllerLocal { + + private VascEntryConfigController vascEntryConfigController = null; + private VascBackendController vascBackendController = null; + private VascEntryController vascEntryController = null; + private VascEntryFieldTypeController vascEntryFieldTypeController = null; + private VascEventChannelController vascEventChannelController = null; + + /** + * @return the vascEntryConfigController + */ + public VascEntryConfigController getVascEntryConfigController() { + return vascEntryConfigController; + } + + /** + * @param vascEntryConfigController the vascEntryConfigController to set + */ + public void setVascEntryConfigController(VascEntryConfigController vascEntryConfigController) { + this.vascEntryConfigController = vascEntryConfigController; + } + + /** + * @return the vascEventChannelController + */ + public VascEventChannelController getVascEventChannelController() { + return vascEventChannelController; + } + + /** + * @param vascEventChannelController the vascEventChannelController to set + */ + public void setVascEventChannelController(VascEventChannelController vascEventChannelController) { + this.vascEventChannelController = vascEventChannelController; + } + + /** + * @return the vascBackendController + */ + public VascBackendController getVascBackendController() { + return vascBackendController; + } + + /** + * @param vascBackendController the vascBackendController to set + */ + public void setVascBackendController(VascBackendController vascBackendController) { + this.vascBackendController = vascBackendController; + } + + /** + * @return the vascEntryController + */ + public VascEntryController getVascEntryController() { + return vascEntryController; + } + + /** + * @param vascEntryController the vascEntryController to set + */ + public void setVascEntryController(VascEntryController vascEntryController) { + this.vascEntryController = vascEntryController; + } + + /** + * @return the vascEntryFieldController + */ + public VascEntryFieldTypeController getVascEntryFieldTypeController() { + return vascEntryFieldTypeController; + } + + /** + * @param vascEntryFieldController the vascEntryFieldController to set + */ + public void setVascEntryFieldTypeController(VascEntryFieldTypeController vascEntryFieldTypeController) { + this.vascEntryFieldTypeController = vascEntryFieldTypeController; + } +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryFieldLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryFieldLocal.java new file mode 100644 index 0000000..3c5840f --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryFieldLocal.java @@ -0,0 +1,362 @@ +/* + * 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.core; + +import java.util.ArrayList; +import java.util.List; + +import net.forwardfire.vasc.core.base.AbstractVascBaseIdRoleCrudOrderMetaLocal; +import net.forwardfire.vasc.core.entry.VascEntryFieldValue; +import net.forwardfire.vasc.validators.VascValidator; + +/** + * AbstractVascEntryFieldLocal + * + * @author Willem Cazander + * @version 1.0 Jun 2, 2012 + */ +@SuppressWarnings("serial") +abstract public class AbstractVascEntryFieldLocal extends AbstractVascBaseIdRoleCrudOrderMetaLocal implements VascEntryFieldLocal { + + private VascEntry vascEntry = null; + private String backendName = null; + private String displayName = null; + private VascEntryFieldType vascEntryFieldType = null; + private VascEntryFieldValue vascEntryFieldValue = null; + private List vascValidators = null; + private Object defaultValue = null; + private Integer sizeList = null; + private Integer sizeEdit = null; + private String styleList = null; + private String styleEdit = null; + private String choices = null; + private Boolean choicesAsRadio = null; + private Boolean optional = null; + private Boolean editBlank = null; + private Boolean sortable = null; + private Boolean sumable = null; + private Boolean graphable = null; + + public AbstractVascEntryFieldLocal() { + vascValidators = new ArrayList(5); + } + + @Override + public VascEntryFieldLocal clone() throws CloneNotSupportedException { + Object clone = cloneCreate(); + cloneFields(clone); + return (VascEntryFieldLocal)clone; + } + + + @Override + public void cloneFields(Object cloneObject) throws CloneNotSupportedException { + super.cloneFields(cloneObject); + VascEntryFieldLocal clone = (VascEntryFieldLocal)cloneObject; + + // TODO: rm + // vascEntry and + // this polls full backend.. + //result.vascEntryFieldValue=vascEntryFieldValue; + + + clone.setBackendName(getBackendName()); + clone.setDisplayName(getDisplayName()); + clone.setVascEntryFieldType(getVascEntryFieldType()); + for (VascValidator v:getVascValidators()) { + clone.addVascValidator(v.clone()); + } + clone.setDefaultValue(getDefaultValue()); + clone.setSizeList(getSizeList()); + clone.setSizeEdit(getSizeEdit()); + clone.setStyleList(getStyleList()); + clone.setStyleEdit(getStyleEdit()); + clone.setChoices(getChoices()); + clone.setChoicesAsRadio(getChoicesAsRadio()); + clone.setOptional(getOptional()); + clone.setEditBlank(getEditBlank()); + clone.setSortable(getSortable()); + clone.setSumable(getSumable()); + clone.setGraphable(getGraphable()); + } + + + public VascEntry getVascEntry() { + return vascEntry; + } + + public void setVascEntry(VascEntry vascEntry) { + this.vascEntry=vascEntry; + } + + + + /** + * @return the vascEntryFieldType + */ + public VascEntryFieldType getVascEntryFieldType() { + return vascEntryFieldType; + } + + /** + * @param vascEntryFieldType the vascEntryFieldType to set + */ + public void setVascEntryFieldType(VascEntryFieldType vascEntryFieldType) { + this.vascEntryFieldType = vascEntryFieldType; + } + + /** + * @return the backendName + */ + public String getBackendName() { + return backendName; + } + + /** + * @param backendName the backendName to set + */ + public void setBackendName(String backendName) { + this.backendName = backendName; + } + + /** + * @return the vascEntryFieldValue + */ + public VascEntryFieldValue getVascEntryFieldValue() { + return vascEntryFieldValue; + } + + /** + * @param vascEntryFieldValue the vascEntryFieldValue to set + */ + public void setVascEntryFieldValue(VascEntryFieldValue vascEntryFieldValue) { + this.vascEntryFieldValue = vascEntryFieldValue; + } + + /** + * @return the vascValidators + */ + public List getVascValidators() { + return vascValidators; + } + + /** + * @param vascValidators the vascValidators to add + */ + public void addVascValidator(VascValidator vascValidator) { + this.vascValidators.add(vascValidator); + } + + /** + * @param vascValidators the vascValidators to remove + */ + public void removeVascValidator(VascValidator vascValidator) { + this.vascValidators.remove(vascValidator); + } + + + /** + * @return the defaultValue + */ + public Object getDefaultValue() { + return defaultValue; + } + + /** + * @param defaultValue the defaultValue to set + */ + public void setDefaultValue(Object defaultValue) { + this.defaultValue = defaultValue; + } + + /** + * @return the sizeList + */ + public Integer getSizeList() { + return sizeList; + } + + /** + * @param sizeList the sizeList to set + */ + public void setSizeList(Integer sizeList) { + this.sizeList = sizeList; + } + + /** + * @return the sizeEdit + */ + public Integer getSizeEdit() { + return sizeEdit; + } + + /** + * @param sizeEdit the sizeEdit to set + */ + public void setSizeEdit(Integer sizeEdit) { + this.sizeEdit = sizeEdit; + } + + /** + * @return the styleList + */ + public String getStyleList() { + return styleList; + } + + /** + * @param styleList the styleList to set + */ + public void setStyleList(String styleList) { + this.styleList = styleList; + } + + /** + * @return the styleEdit + */ + public String getStyleEdit() { + return styleEdit; + } + + /** + * @param styleEdit the styleEdit to set + */ + public void setStyleEdit(String styleEdit) { + this.styleEdit = styleEdit; + } + + /** + * @return the choices + */ + public String getChoices() { + return choices; + } + + /** + * @param choices the choices to set + */ + public void setChoices(String choices) { + this.choices = choices; + } + + + /** + * @return the optional + */ + public Boolean getOptional() { + return optional; + } + + /** + * @param optional the optional to set + */ + public void setOptional(Boolean optional) { + this.optional = optional; + } + + + + /** + * @return the choicesAsRadio + */ + public Boolean getChoicesAsRadio() { + return choicesAsRadio; + } + + /** + * @param choicesAsRadio the choicesAsRadio to set + */ + public void setChoicesAsRadio(Boolean choicesAsRadio) { + this.choicesAsRadio = choicesAsRadio; + } + + /** + * @return the editBlank + */ + public Boolean getEditBlank() { + return editBlank; + } + + /** + * @param editBlank the editBlank to set + */ + public void setEditBlank(Boolean editBlank) { + this.editBlank = editBlank; + } + + /** + * @return the displayName + */ + public String getDisplayName() { + return displayName; + } + + /** + * @param displayName the displayName to set + */ + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + /** + * @return the sortable + */ + public Boolean getSortable() { + return sortable; + } + + /** + * @param sortable the sortable to set + */ + public void setSortable(Boolean sortable) { + this.sortable = sortable; + } + + /** + * @return the sumable + */ + public Boolean getSumable() { + return sumable; + } + + /** + * @param sumable the sumable to set + */ + public void setSumable(Boolean sumable) { + this.sumable = sumable; + } + + /** + * @return the graphable + */ + public Boolean getGraphable() { + return graphable; + } + + /** + * @param graphable the graphable to set + */ + public void setGraphable(Boolean graphable) { + this.graphable = graphable; + } +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryFieldSetLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryFieldSetLocal.java new file mode 100644 index 0000000..5d4d5cb --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryFieldSetLocal.java @@ -0,0 +1,129 @@ +/* + * 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.core; + +import java.util.ArrayList; +import java.util.List; + +import net.forwardfire.vasc.core.base.AbstractVascBaseIdRoleCrudOrderMetaLocal; + +/** + * AbstractVascEntryFieldSetLocal + * + * @author Willem Cazander + * @version 1.0 Jun 2, 2012 + */ +@SuppressWarnings("serial") +abstract public class AbstractVascEntryFieldSetLocal extends AbstractVascBaseIdRoleCrudOrderMetaLocal implements VascEntryFieldSetLocal { + + private String styleList = null; + private String styleEdit = null; + private Boolean collapsed = false; + private List vascEntryFieldIds = null; + + public AbstractVascEntryFieldSetLocal() { + vascEntryFieldIds = new ArrayList(10); + } + + @Override + public VascEntryFieldSetLocal clone() throws CloneNotSupportedException { + Object clone = cloneCreate(); + cloneFields(clone); + return (VascEntryFieldSetLocal)clone; + } + + @Override + public void cloneFields(Object cloneObject) throws CloneNotSupportedException { + super.cloneFields(cloneObject); + VascEntryFieldSetLocal clone = (VascEntryFieldSetLocal)cloneObject; + clone.setStyleList(getStyleList()); + clone.setStyleEdit(getStyleEdit()); + clone.setCollapsed(getCollapsed()); + for (String id:getVascEntryFieldIds()) { + clone.addVascEntryFieldId(id); + } + } + + /** + * @return the styleList + */ + public String getStyleList() { + return styleList; + } + + /** + * @param styleList the styleList to set + */ + public void setStyleList(String styleList) { + this.styleList = styleList; + } + + /** + * @return the styleEdit + */ + public String getStyleEdit() { + return styleEdit; + } + + /** + * @param styleEdit the styleEdit to set + */ + public void setStyleEdit(String styleEdit) { + this.styleEdit = styleEdit; + } + + /** + * @return the collapsed + */ + public Boolean getCollapsed() { + return collapsed; + } + + /** + * @param collapsed the collapsed to set + */ + public void setCollapsed(Boolean collapsed) { + this.collapsed = collapsed; + } + + /** + * @return the vascEntryFieldIds + */ + public List getVascEntryFieldIds() { + return vascEntryFieldIds; + } + + /** + * @param vascEntryFieldIds the vascEntryFieldIds to set + */ + public void addVascEntryFieldId(String vascEntryFieldId) { + vascEntryFieldIds.add(vascEntryFieldId); + } + + /** + * @param vascEntryFieldIds the vascEntryFieldIds to set + */ + public void removeVascEntryFieldId(String vascEntryFieldId) { + vascEntryFieldIds.remove(vascEntryFieldId); + } +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryFieldTypeLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryFieldTypeLocal.java new file mode 100644 index 0000000..a0ba335 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryFieldTypeLocal.java @@ -0,0 +1,237 @@ +/* + * 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.core; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.x4o.xml.conv.ObjectConverter; + +import net.forwardfire.vasc.core.base.AbstractVascBaseIdLocal; +import net.forwardfire.vasc.core.ui.VascUIComponent; +import net.forwardfire.vasc.core.ui.VascValueModel; +import net.forwardfire.vasc.validators.VascValidator; + +/** + * AbstractVascEntryFieldTypeLocal + * + * @author Willem Cazander + * @version 1.0 Aug 2, 2007 + */ +@SuppressWarnings("serial") +abstract public class AbstractVascEntryFieldTypeLocal extends AbstractVascBaseIdLocal implements VascEntryFieldTypeLocal { + + private Class autoDetectClass = null; + private List vascValidators = null; + private Map properties = null; + private ObjectConverter objectConverter = null; + + private Object dataObject = null; + private String uiComponentId = null; + private String inputMask = null; + + public AbstractVascEntryFieldTypeLocal() { + vascValidators = new ArrayList(4); + properties = new HashMap(); + } + + @Override + public VascEntryFieldTypeLocal clone() throws CloneNotSupportedException { + Object clone = cloneCreate(); + cloneFields(clone); + return (VascEntryFieldTypeLocal)clone; + } + + @Override + public void cloneFields(Object cloneObject) throws CloneNotSupportedException { + super.cloneFields(cloneObject); + VascEntryFieldTypeLocal clone = (VascEntryFieldTypeLocal)cloneObject; + clone.setAutoDetectClass(getAutoDetectClass()); + for (VascValidator v:getVascValidators()) { + clone.addVascValidator(v.clone()); + } + for (String key:getPropertyNames()) { + clone.setProperty(key, getProperty(key)); + } + if (getObjectConverter()!=null) { + clone.setObjectConverter(getObjectConverter().clone()); // use clone + } + clone.setDataObject(getDataObject()); + clone.setUIComponentId(getUIComponentId()); + clone.setInputMask(getInputMask()); + } + + /** + * @see net.forwardfire.vasc.core.VascEntryFieldType#getProperty(java.lang.String) + */ + public String getProperty(String name) { + return properties.get(name); + } + + /** + * @see net.forwardfire.vasc.core.VascEntryFieldType#setProperty(java.lang.String, java.lang.String) + */ + public void setProperty(String name, String value) { + properties.put(name, value); + } + + /** + * @see net.forwardfire.vasc.core.VascEntryFieldType#getPropertyNames() + */ + public List getPropertyNames() { + return new ArrayList(properties.keySet()); + } + + /** + * @return the dataObject + */ + public Object getDataObject() { + return dataObject; + } + + /** + * @param dataObject the dataObject to set + */ + public void setDataObject(Object dataObject) { + this.dataObject = dataObject; + } + + /** + * @see net.forwardfire.vasc.core.VascEntryFieldType#getVascValidators() + */ + public List getVascValidators() { + return vascValidators; + } + + /** + * @see net.forwardfire.vasc.core.VascEntryFieldType#addVascValidator(net.forwardfire.vasc.validators.VascValidator) + */ + public void addVascValidator(VascValidator vascValidator) { + vascValidators.add(vascValidator); + } + + /** + * @see net.forwardfire.vasc.core.VascEntryFieldType#removeVascValidator(net.forwardfire.vasc.validators.VascValidator) + */ + public void removeVascValidator(VascValidator vascValidator) { + vascValidators.remove(vascValidator); + } + + /** + * @see net.forwardfire.vasc.core.VascEntryFieldType#getAutoDetectClass() + */ + public Class getAutoDetectClass() { + return autoDetectClass; + } + + /** + * @see net.forwardfire.vasc.core.VascEntryFieldType#setAutoDetectClass(java.lang.Class) + */ + public void setAutoDetectClass(Class classObject) { + autoDetectClass=classObject; + } + + /** + * @see net.forwardfire.vasc.core.VascEntryFieldType#getInputMask() + */ + public String getInputMask() { + return inputMask; + } + + /** + * @see net.forwardfire.vasc.core.VascEntryFieldType#setInputMask(java.lang.String) + */ + public void setInputMask(String inputMask) { + this.inputMask=inputMask; + } + + /** + * @see net.forwardfire.vasc.core.VascEntryFieldType#getUIComponentId() + */ + public String getUIComponentId() { + return uiComponentId; + } + + /** + * @see net.forwardfire.vasc.core.VascEntryFieldType#setUIComponentId(java.lang.String) + */ + public void setUIComponentId(String uiComponentId) { + this.uiComponentId=uiComponentId; + } + + /** + * @see net.forwardfire.vasc.core.VascEntryFieldType#getUIComponentCount() + */ + public int getUIComponentCount(VascEntryField entryField) throws VascException { + return 1; + } + + /** + * @see net.forwardfire.vasc.core.VascEntryFieldType#provideEditorUIComponent(int) + */ + public VascUIComponent provideEditorUIComponent(int index,VascEntryField entryField) throws VascException { + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + if (cl == null) { + cl = entryField.getClass().getClassLoader(); // fallback + } + String compId = getUIComponentId(); + if (compId==null) { + compId = VascUIComponent.VASC_TEXT; + } + return entryField.getVascEntry().getVascFrontendController().getVascUIComponent(compId); + } + + /** + * @see net.forwardfire.vasc.core.VascEntryFieldType#provideLabelUIComponent(int) + */ + public VascUIComponent provideLabelUIComponent(int index,VascEntryField entryField) throws VascException { + return entryField.getVascEntry().getVascFrontendController().getVascUIComponent(VascUIComponent.VASC_LABEL); + } + + /** + * @see net.forwardfire.vasc.core.VascEntryFieldType#provideEditorVascValueModel() + */ + public VascValueModel provideEditorVascValueModel(int index,VascEntryField entryField) throws VascException { + if (index>0) { + throw new IllegalArgumentException("You have to override provideEditorVascValueModel if multi editor support is needed"); + } + VascValueModel model = new VascValueModel(); + return model; + } + + /** + * @return the objectConverter + */ + public ObjectConverter getObjectConverter() { + return objectConverter; + } + + /** + * @param objectConverter the objectConverter to set + */ + public void setObjectConverter(ObjectConverter objectConverter) { + this.objectConverter = objectConverter; + } +} \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryLinkLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryLinkLocal.java new file mode 100644 index 0000000..251e752 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryLinkLocal.java @@ -0,0 +1,131 @@ +/* + * 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.core; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import net.forwardfire.vasc.core.base.AbstractVascBaseIdRoleViewOrderMetaLocal; + +/** + * AbstractVascEntryLinkLocal + * + * @author Willem Cazander + * @version 1.0 Jun 2, 2012 + */ +@SuppressWarnings("serial") +abstract public class AbstractVascEntryLinkLocal extends AbstractVascBaseIdRoleViewOrderMetaLocal implements VascEntryLinkLocal { + + private String vascEntryId = null; + private Map entryParameterFieldIds = new HashMap(3); + private Map entryCreateFieldValues = new HashMap(3); + private VascEntryLinkType vascLinkEntryType = null; + private String doActionId = null; + + + @Override + public VascEntryLinkLocal clone() throws CloneNotSupportedException { + Object clone = cloneCreate(); + cloneFields(clone); + return (VascEntryLinkLocal)clone; + } + + @Override + public void cloneFields(Object cloneObject) throws CloneNotSupportedException { + super.cloneFields(cloneObject); + VascEntryLinkLocal clone = (VascEntryLinkLocal)cloneObject; + clone.setVascEntryId(getVascEntryId()); + clone.setDoActionId(getDoActionId()); + clone.setVascLinkEntryType(getVascLinkEntryType()); + for (String key:getEntryParameterFieldIdKeys()) { + clone.addEntryParameterFieldId(key, getEntryParameterFieldId(key)); + } + for (String key:getEntryCreateFieldValueKeys()) { + clone.addEntryCreateFieldValue(key, getEntryCreateFieldValue(key)); + } + } + + public String getEntryParameterFieldId(String parameterName) { + return entryParameterFieldIds.get(parameterName); + } + public void addEntryParameterFieldId(String parameterName,String valueFieldId) { + entryParameterFieldIds.put(parameterName, valueFieldId); + } + public List getEntryParameterFieldIdKeys() { + return new ArrayList(entryParameterFieldIds.keySet()); + } + + public String getEntryCreateFieldValue(String valueFieldId) { + return entryCreateFieldValues.get(valueFieldId); + } + public void addEntryCreateFieldValue(String valueFieldId,String selectedFieldId) { + entryCreateFieldValues.put(valueFieldId, selectedFieldId); + } + public List getEntryCreateFieldValueKeys() { + return new ArrayList(entryCreateFieldValues.keySet()); + } + + /** + * @return the vascEntryId + */ + public String getVascEntryId() { + return vascEntryId; + } + + /** + * @param vascEntryId the vascEntryId to set + */ + public void setVascEntryId(String vascEntryId) { + this.vascEntryId = vascEntryId; + } + + /** + * @return the vascLinkEntryType + */ + public VascEntryLinkType getVascLinkEntryType() { + return vascLinkEntryType; + } + + /** + * @param vascLinkEntryType the vascLinkEntryType to set + */ + public void setVascLinkEntryType(VascEntryLinkType vascLinkEntryType) { + this.vascLinkEntryType = vascLinkEntryType; + } + + /** + * @return the doActionId + */ + public String getDoActionId() { + return doActionId; + } + + /** + * @param doActionId the doActionId to set + */ + public void setDoActionId(String doActionId) { + this.doActionId = doActionId; + } +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryListOptionLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryListOptionLocal.java new file mode 100644 index 0000000..f011dd3 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryListOptionLocal.java @@ -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.core; + +/** + * AbstractVascEntryListOptionLocal + * + * @author Willem Cazander + * @version 1.0 Jun 2, 2012 + */ +@SuppressWarnings("serial") +abstract public class AbstractVascEntryListOptionLocal extends AbstractVascEntryFieldLocal implements VascEntryListOptionLocal { + + @Override + public VascEntryListOptionLocal clone() throws CloneNotSupportedException { + Object clone = cloneCreate(); + cloneFields(clone); + return (VascEntryListOptionLocal)clone; + } +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryLocal.java new file mode 100644 index 0000000..34108a1 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryLocal.java @@ -0,0 +1,903 @@ +/* + * 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.core; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import net.forwardfire.vasc.backend.VascBackendFilter; +import net.forwardfire.vasc.core.actions.ColumnVascAction; +import net.forwardfire.vasc.core.actions.ColumnVascActionLocal; +import net.forwardfire.vasc.core.actions.GlobalVascAction; +import net.forwardfire.vasc.core.actions.GlobalVascActionLocal; +import net.forwardfire.vasc.core.actions.RowVascAction; +import net.forwardfire.vasc.core.actions.RowVascActionLocal; +import net.forwardfire.vasc.core.base.AbstractVascBaseIdRoleCrudLocal; +import net.forwardfire.vasc.core.entry.VascEntryFieldEventChannel; +import net.forwardfire.vasc.frontend.VascFrontendController; + +/** + * AbstractVascEntryLocal + * + * @author Willem Cazander + * @version 1.0 Jun 2, 2012 + */ +@SuppressWarnings("serial") +abstract public class AbstractVascEntryLocal extends AbstractVascBaseIdRoleCrudLocal implements VascEntryLocal { + + private String name = null; + private String helpId = null; + private String image = null; + + private String listDescription = null; + private String listImage = null; + private String editDescription = null; + private String editImage = null; + private String deleteDescription = null; + private String deleteImage = null; + private String createDescription = null; + private String createImage = null; + + private String primaryKeyFieldId = null; + private String displayNameFieldId = null; + + private Boolean vascDisplayOnly = null; // todo rename + private Boolean delete = null; + private String rolesDelete = null; + + private List vascFields = null; + private List rowActions = null; + private List columnActions = null; + private List globalActions = null; + private List exportActions = null; + private List vascEntryFieldSets = null; + private List vascEntryLinks = null; + + private Map entryParameters = null; + private VascEntryFieldEventChannel vascEntryFieldEventChannel = null; + private Map> eventEntryFrontendEventListeners = null; + private List eventEntryBackendEventListeners = null; + private List vascEntryListOptions = null; + private List backendFilters = null; + private Map> eventEntryFrontendActions = null; + + private String backendId = null; + private VascFrontendController vascFrontendData = null; + + public AbstractVascEntryLocal() { + vascFields = new ArrayList(20); + + rowActions = new ArrayList(10); + columnActions = new ArrayList(5); + globalActions = new ArrayList(5); + exportActions = new ArrayList(10); + + vascEntryFieldSets = new ArrayList(10); + vascEntryLinks = new ArrayList(10); + entryParameters = new HashMap(10); + + eventEntryFrontendActions = new HashMap>(10); + eventEntryFrontendEventListeners = new HashMap>(10); + eventEntryBackendEventListeners = new ArrayList(10); + vascEntryListOptions = new ArrayList(10); + backendFilters = new ArrayList(3); + } + + @Override + public VascEntryLocal clone() throws CloneNotSupportedException { + Object clone = cloneCreate(); + cloneFields(clone); + return (VascEntryLocal)clone; + } + + @Override + public void cloneFields(Object cloneObject) throws CloneNotSupportedException { + super.cloneFields(cloneObject); + VascEntryLocal clone = (VascEntryLocal)cloneObject; + clone.setName(getName()); + clone.setHelpId(getHelpId()); + clone.setImage(getImage()); + clone.setListDescription(getListDescription()); + clone.setListImage(getListImage()); + clone.setEditDescription(getEditDescription()); + clone.setEditImage(getEditImage()); + clone.setCreateDescription(getCreateDescription()); + clone.setCreateImage(getCreateImage()); + clone.setDeleteDescription(getDeleteDescription()); + clone.setDeleteImage(getDeleteImage()); + + clone.setPrimaryKeyFieldId(getPrimaryKeyFieldId()); + clone.setDisplayNameFieldId(getDisplayNameFieldId()); + + clone.setDelete(getDelete()); + clone.setRolesDelete(getRolesDelete()); + + for (VascEntryFieldLocal field:getVascEntryFieldsLocal()) { + VascEntryFieldLocal fieldClone = field.clone(); + fieldClone.setVascEntry(clone); // TODO rm me + clone.addVascEntryField(fieldClone); + } + for (RowVascActionLocal a:getRowActionsLocal()) { clone.addRowAction(a.clone()); } + for (ColumnVascActionLocal a:getColumnActionsLocal()) { clone.addColumnAction(a.clone()); } + for (GlobalVascActionLocal a:getGlobalActionsLocal()) { clone.addGlobalAction(a.clone()); } + for (GlobalVascActionLocal a:getExportActionsLocal()) { clone.addExportAction(a.clone()); } + for (VascEntryFieldSetLocal set:getVascEntryFieldSetsLocal()) { + clone.addVascEntryFieldSet(set.clone()); + } + for (VascEntryLinkLocal link:getVascEntryLinksLocal()) { + clone.addVascEntryLink(link.clone()); + } + for (String key:getEntryParameterKeys()) { + clone.setEntryParameter(key, getEntryParameter(key)); + } + // TODO: vascEntryFieldEventChannel + + for (String key:eventEntryFrontendEventListeners.keySet()) { + List list = eventEntryFrontendEventListeners.get(key); + if (list==null) { + continue; + } + for (String listener:list) { + clone.addVascEntryFrontendEventListener(listener, key); + } + } + for (String key:eventEntryBackendEventListeners) { + clone.addVascEntryBackendEventListener(key); + } + for (VascEntryListOptionLocal option:vascEntryListOptions) { + VascEntryListOptionLocal optionClone = option.clone(); + optionClone.setVascEntry(clone); + clone.addVascEntryListOption(optionClone); + } + for (VascBackendFilter filter:backendFilters) { + clone.addVascBackendFilter(filter.clone()); + } + for (String key:eventEntryFrontendActions.keySet()) { + List list = eventEntryFrontendActions.get(key); + if (list==null) { + continue; + } + for (String listener:list) { + clone.addVascEntryFrontendAction(listener, key); + } + } + clone.setBackendId(getBackendId()); + } + + + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return the helpId + */ + public String getHelpId() { + return helpId; + } + + /** + * @param helpId the helpId to set + */ + public void setHelpId(String helpId) { + this.helpId = helpId; + } + + /** + * @return the image + */ + public String getImage() { + return image; + } + + /** + * @param image the image to set + */ + public void setImage(String image) { + this.image = image; + } + + /** + * @return the listDescription + */ + public String getListDescription() { + return listDescription; + } + + /** + * @param listDescription the listDescription to set + */ + public void setListDescription(String listDescription) { + this.listDescription = listDescription; + } + + /** + * @return the listImage + */ + public String getListImage() { + return listImage; + } + + /** + * @param listImage the listImage to set + */ + public void setListImage(String listImage) { + this.listImage = listImage; + } + + /** + * @return the editDescription + */ + public String getEditDescription() { + return editDescription; + } + + /** + * @param editDescription the editDescription to set + */ + public void setEditDescription(String editDescription) { + this.editDescription = editDescription; + } + + /** + * @return the editImage + */ + public String getEditImage() { + return editImage; + } + + /** + * @param editImage the editImage to set + */ + public void setEditImage(String editImage) { + this.editImage = editImage; + } + + /** + * @return the deleteDescription + */ + public String getDeleteDescription() { + return deleteDescription; + } + + /** + * @param deleteDescription the deleteDescription to set + */ + public void setDeleteDescription(String deleteDescription) { + this.deleteDescription = deleteDescription; + } + + /** + * @return the deleteImage + */ + public String getDeleteImage() { + return deleteImage; + } + + /** + * @param deleteImage the deleteImage to set + */ + public void setDeleteImage(String deleteImage) { + this.deleteImage = deleteImage; + } + + /** + * @return the createDescription + */ + public String getCreateDescription() { + return createDescription; + } + + /** + * @param createDescription the createDescription to set + */ + public void setCreateDescription(String createDescription) { + this.createDescription = createDescription; + } + + /** + * @return the createImage + */ + public String getCreateImage() { + return createImage; + } + + /** + * @param createImage the createImage to set + */ + public void setCreateImage(String createImage) { + this.createImage = createImage; + } + + /** + * @return the primaryKeyFieldId + */ + public String getPrimaryKeyFieldId() { + return primaryKeyFieldId; + } + + /** + * @param primaryKeyFieldId the primaryKeyFieldId to set + */ + public void setPrimaryKeyFieldId(String primaryKeyFieldId) { + this.primaryKeyFieldId = primaryKeyFieldId; + } + + /** + * @return the displayNameFieldId + */ + public String getDisplayNameFieldId() { + return displayNameFieldId; + } + + /** + * @param displayNameFieldId the displayNameFieldId to set + */ + public void setDisplayNameFieldId(String displayNameFieldId) { + this.displayNameFieldId = displayNameFieldId; + } + + /** + * @return the delete + */ + public Boolean getDelete() { + return delete; + } + + /** + * @param delete the delete to set + */ + public void setDelete(Boolean delete) { + this.delete = delete; + } + + /** + * @return the rolesDelete + */ + public String getRolesDelete() { + return rolesDelete; + } + + /** + * @param rolesDelete the rolesDelete to set + */ + public void setRolesDelete(String rolesDelete) { + this.rolesDelete = rolesDelete; + } + + /** + * @return the vascFields + */ + public Collection getVascEntryFields() { + return new ArrayList(vascFields); + } + + /** + * @return the vascFields + */ + public Collection getVascEntryFieldsLocal() { + return vascFields; + } + + /** + * @param vascField the vascFields to add + */ + public void addVascEntryField(VascEntryFieldLocal vascField) { + vascFields.add(vascField); + } + + /** + * @param vascField the vascFields to remove + */ + public void removeVascEntryField(VascEntryFieldLocal vascField) { + vascFields.remove(vascField); + } + + /** + * @see net.forwardfire.vasc.core.VascEntry#getVascEntryFieldById(java.lang.String) + */ + public VascEntryField getVascEntryFieldById(String id) { + for (VascEntryField field:vascFields) { + if (id.equals(field.getId())) { + return field; + } + } + return null; + } + + /** + * @return the rowActions + */ + public Collection getRowActions() { + return new ArrayList(rowActions); + } + + /** + * @return the RowVascAction + */ + public RowVascAction getRowActionById(String actionId) { + for (RowVascAction a:rowActions) { + if (a.getId().equals(actionId)) { + return a; + } + } + return null; + } + + /** + * @param rowAction the rowAction to add + */ + public void addRowAction(RowVascActionLocal rowAction) { + rowActions.add(rowAction); + } + + /** + * @param rowAction the rowAction to remove + */ + public void removeRowAction(RowVascActionLocal rowAction) { + rowActions.remove(rowAction); + } + + /** + * @return the rowActions + */ + public Collection getRowActionsLocal() { + return rowActions; + } + + /** + * @return the columnActions + */ + public Collection getColumnActions() { + return new ArrayList(columnActions); + } + + /** + * @return the ColumnVascAction + */ + public ColumnVascAction getColumnActionById(String actionId) { + for (ColumnVascAction a:columnActions) { + if (a.getId().equals(actionId)) { + return a; + } + } + return null; + } + + /** + * @param columnAction the columnActions to add + */ + public void addColumnAction(ColumnVascActionLocal columnAction) { + columnActions.add(columnAction); + } + + /** + * @param columnAction the columnActions to remove + */ + public void removeColumnAction(ColumnVascActionLocal columnAction) { + columnActions.remove(columnAction); + } + + /** + * @return the columnActions + */ + public Collection getColumnActionsLocal() { + return columnActions; + } + + /** + * @return the globalActions + */ + public Collection getGlobalActions() { + return new ArrayList(globalActions); + } + + /** + * @return the GlobalVascAction + */ + public GlobalVascAction getGlobalActionById(String actionId) { + for (GlobalVascAction a:globalActions) { + if (a.getId().equals(actionId)) { + return a; + } + } + return null; + } + + /** + * @param globalAction the globalAction to add + */ + public void addGlobalAction(GlobalVascActionLocal globalAction) { + globalActions.add(globalAction); + } + + /** + * @param globalAction the globalAction to remove + */ + public void removeGlobalAction(GlobalVascActionLocal globalAction) { + globalActions.remove(globalAction); + } + + /** + * @return the globalActions + */ + public Collection getGlobalActionsLocal() { + return globalActions; + } + + /** + * @return the exportActions + */ + public Collection getExportActions() { + return new ArrayList(exportActions); + } + + /** + * @return the GlobalVascAction exportAction + */ + public GlobalVascAction getExportActionById(String actionId) { + for (GlobalVascAction a:exportActions) { + if (a.getId().equals(actionId)) { + return a; + } + } + return null; + } + + /** + * @param exportAction the exportAction to add + */ + public void addExportAction(GlobalVascActionLocal exportAction) { + exportActions.add(exportAction); + } + + /** + * @param exportAction the exportAction to remove + */ + public void removeExportAction(GlobalVascActionLocal exportAction) { + exportActions.remove(exportAction); + } + + /** + * @return the exportActions + */ + public Collection getExportActionsLocal() { + return exportActions; + } + + /** + * @return the vascEntryFieldSets + */ + public Collection getVascEntryFieldSets() { + return new ArrayList(vascEntryFieldSets); + } + + /** + * @return the vascEntryFieldSets + */ + public Collection getVascEntryFieldSetsLocal() { + return vascEntryFieldSets; + } + + /** + * @return the VascEntryFieldSet + */ + public VascEntryFieldSet getVascEntryFieldSetById(String fieldSetId) { + for (VascEntryFieldSet a:vascEntryFieldSets) { + if (a.getId().equals(fieldSetId)) { + return a; + } + } + return null; + } + + /** + * @param vascEntryFieldSet the vascEntryFieldSet to add + */ + public void addVascEntryFieldSet(VascEntryFieldSetLocal vascEntryFieldSet) { + vascEntryFieldSets.add(vascEntryFieldSet); + } + + /** + * @param vascEntryFieldSet the vascEntryFieldSet to add + */ + public void removeVascEntryFieldSet(VascEntryFieldSetLocal vascEntryFieldSet) { + vascEntryFieldSets.remove(vascEntryFieldSet); + } + + /** + * @return the vascEntryLinks + */ + public Collection getVascEntryLinks() { + return new ArrayList(vascEntryLinks); + } + + /** + * @return the vascEntryLinks + */ + public Collection getVascEntryLinksLocal() { + return vascEntryLinks; + } + + /** + * @return the vascEntryLinks + */ + public VascEntryLink getVascEntryLinkById(String linkId) { + for (VascEntryLink a:vascEntryLinks) { + if (a.getId().equals(linkId)) { + return a; + } + } + return null; + } + + /** + * @param vascEntryLink the vascEntryLink to set + */ + public void addVascEntryLink(VascEntryLinkLocal vascEntryLink) { + vascEntryLinks.add(vascEntryLink); + } + + /** + * @param vascEntryLink the vascEntryLink to remove + */ + public void removeVascEntryLink(VascEntryLinkLocal vascEntryLink) { + vascEntryLinks.remove(vascEntryLink); + } + + /** + * @see net.forwardfire.vasc.core.VascEntry#getEntryParameter(java.lang.String) + */ + public Object getEntryParameter(String key) { + return entryParameters.get(key); + } + + /** + * @see net.forwardfire.vasc.core.VascEntry#getEntryParameterKeys() + */ + public List getEntryParameterKeys() { + return new ArrayList(entryParameters.keySet()); + } + + /** + * @see net.forwardfire.vasc.core.VascEntry#setEntryParameter(java.lang.String, java.lang.Object) + */ + public void setEntryParameter(String key, Object value) { + entryParameters.put(key, value); + } + + /** + * @see net.forwardfire.vasc.core.VascEntry#removeEntryParameter(java.lang.String) + */ + public void removeEntryParameter(String key) { + entryParameters.remove(key); + } + + /** + * @return the vascFrontendData + */ + public VascFrontendController getVascFrontendController() { + return vascFrontendData; + } + + /** + * @param vascFrontendData the vascFrontendData to set + */ + public void setVascFrontendController(VascFrontendController vascFrontendData) { + this.vascFrontendData = vascFrontendData; + } + + /** + * @return the backendId + */ + public String getBackendId() { + return backendId; + } + + /** + * @param backendId the backendId to set + */ + public void setBackendId(String backendId) { + this.backendId = backendId; + } + + /** + * @return the vascEntryFieldEventChannel + */ + public VascEntryFieldEventChannel getVascEntryFieldEventChannel() { + return vascEntryFieldEventChannel; + } + + /** + * @param vascEntryFieldEventChannel the vascEntryFieldEventChannel to set + */ + public void setVascEntryFieldEventChannel(VascEntryFieldEventChannel vascEntryFieldEventChannel) { + this.vascEntryFieldEventChannel = vascEntryFieldEventChannel; + } + + /** + * Added an VascEntryBackendEventListener + * @param listener The class of the event listener. + */ + public void addVascEntryBackendEventListener(String listener) { + eventEntryBackendEventListeners.add(listener); + } + + /** + * Returns the list of VascEntryBackendEventListener + * @return + */ + public List getVascEntryBackendEventListeners() { + return eventEntryBackendEventListeners; + } + + /** + * Added an VascEntryFrontendEventListener + * @param listener The class of the event listener. + */ + public void addVascEntryFrontendEventListener(String listener,String frontendType) { + if (frontendType==null) { + frontendType = "__ALL__"; + } + if (frontendType.isEmpty() | "all".equalsIgnoreCase(frontendType)) { + frontendType = "__ALL__"; + } + List typeList = eventEntryFrontendEventListeners.get(frontendType); + if (typeList==null) { + typeList = new ArrayList(10); + eventEntryFrontendEventListeners.put(frontendType,typeList); + } + typeList.add(listener); + } + + /** + * Returns the list of VascEntryFrontendEventListener + * @return + */ + public List getVascEntryFrontendEventListenersByType(String frontendType) { + if (frontendType==null) { + frontendType = "__ALL__"; + } + if (frontendType.isEmpty() | "all".equalsIgnoreCase(frontendType)) { + frontendType = "__ALL__"; + } + List typeList = eventEntryFrontendEventListeners.get(frontendType); + if (typeList==null) { + typeList = new ArrayList(0); + } + if (frontendType.equals("__ALL__")==false) { + // also add all + List typeListAll = eventEntryFrontendEventListeners.get("__ALL__"); + if (typeListAll!=null) { + typeList.addAll(typeListAll); + } + } + return typeList; + } + + public void addVascEntryFrontendAction(String actionClass,String frontendType) { + if (frontendType==null) { + frontendType = "__ALL__"; + } + if (frontendType.isEmpty() | "all".equalsIgnoreCase(frontendType)) { + frontendType = "__ALL__"; + } + List typeList = eventEntryFrontendActions.get(frontendType); + if (typeList==null) { + typeList = new ArrayList(10); + eventEntryFrontendActions.put(frontendType,typeList); + } + typeList.add(actionClass); + } + + + public List getVascEntryFrontendActionsByType(String frontendType) { + if (frontendType==null) { + frontendType = "__ALL__"; + } + if (frontendType.isEmpty() | "all".equalsIgnoreCase(frontendType)) { + frontendType = "__ALL__"; + } + List typeList = eventEntryFrontendActions.get(frontendType); + if (typeList==null) { + typeList = new ArrayList(0); + } + if (frontendType.equals("__ALL__")==false) { + // also add all + List typeListAll = eventEntryFrontendActions.get("__ALL__"); + if (typeListAll!=null) { + typeList.addAll(typeListAll); + } + } + return typeList; + } + + + + + public List getVascEntryListOptions() { + return new ArrayList(vascEntryListOptions); + } + + public Collection getVascEntryListOptionsLocal() { + return vascEntryListOptions; + } + + + public VascEntryListOption getVascEntryListOptionById(String listOptionId) { + for (VascEntryListOption vef:vascEntryListOptions) { + if (vef.getId().equals(listOptionId)) { + return vef; + } + } + return null; + } + + public void addVascEntryListOption(VascEntryListOptionLocal listOption) { + if (listOption==null) { + throw new NullPointerException("can not add null listOption."); + } + vascEntryListOptions.add(listOption); + } + + public void removeVascEntryListOption(VascEntryListOptionLocal listOption) { + vascEntryListOptions.remove(listOption); + } + + + public void addVascBackendFilter(VascBackendFilter filter) { + backendFilters.add(filter); + } + + public List getVascBackendFilters() { + return backendFilters; + } + + /** + * @return the vascDisplayOnly + */ + public Boolean getVascDisplayOnly() { + return vascDisplayOnly; + } + + /** + * @param vascDisplayOnly the vascDisplayOnly to set + */ + public void setVascDisplayOnly(Boolean vascDisplayOnly) { + this.vascDisplayOnly = vascDisplayOnly; + } +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryState.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryState.java index 0b364da..4c668cb 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryState.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryState.java @@ -36,9 +36,9 @@ import net.forwardfire.vasc.backend.VascBackendState; * @author Willem Cazander * @version 1.0 Dec 15, 2009 */ +@SuppressWarnings("serial") abstract public class AbstractVascEntryState implements VascEntryState { - private static final long serialVersionUID = 1L; private List entryDataList = null; private Object entryDataObject = null; private Long totalBackendRecords = null; diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascController.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascController.java index 20e9e22..d5182e9 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascController.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascController.java @@ -26,8 +26,9 @@ import net.forwardfire.vasc.backend.VascBackendController; /** - * Resolvs all the resolvers. - * These resolved often point to an external locations. + * VascController hold all core controllers which resolve all the vasc data. + * + * These resolves can be proxyed to external networked locations. * * @author Willem Cazander * @version 1.0 Sep 11, 2008 @@ -61,10 +62,4 @@ public interface VascController { * @return Returns the VascEventChannelController */ public VascEventChannelController getVascEventChannelController(); - - /** - * - * @return Returns the VascUserRoleController - */ - public VascUserRoleController getVascUserRoleController(); } \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascControllerLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascControllerLocal.java new file mode 100644 index 0000000..35024fa --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascControllerLocal.java @@ -0,0 +1,60 @@ +/* + * 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.core; + +import net.forwardfire.vasc.backend.VascBackendController; + + +/** + * VascControllerLocal are the set methods to config the controller. + * + * @author Willem Cazander + * @version 1.0 May 18, 2012 + */ +public interface VascControllerLocal extends VascController { + + /** + * @param vascEntryConfigController the vascEntryConfigController to set + */ + public void setVascEntryConfigController(VascEntryConfigController vascEntryConfigController); + + /** + * @param vascEventChannelController the vascEventChannelController to set + */ + public void setVascEventChannelController(VascEventChannelController vascEventChannelController); + + /** + * @param vascBackendController the vascBackendController to set + */ + public void setVascBackendController(VascBackendController vascBackendController); + + /** + * @param vascEntryController the vascEntryController to set + */ + public void setVascEntryController(VascEntryController vascEntryController); + + /** + * @param vascEntryFieldController the vascEntryFieldController to set + */ + public void setVascEntryFieldTypeController(VascEntryFieldTypeController vascEntryFieldTypeController); +} \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntry.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntry.java index f903712..eb4516d 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntry.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntry.java @@ -22,222 +22,105 @@ package net.forwardfire.vasc.core; -import java.io.Serializable; +import java.util.Collection; import java.util.List; import net.forwardfire.vasc.backend.VascBackendFilter; import net.forwardfire.vasc.core.actions.ColumnVascAction; import net.forwardfire.vasc.core.actions.GlobalVascAction; import net.forwardfire.vasc.core.actions.RowVascAction; +import net.forwardfire.vasc.core.base.VascBaseIdRoleCrud; import net.forwardfire.vasc.core.entry.VascEntryFieldEventChannel; -import net.forwardfire.vasc.frontend.VascFrontendData; - - +import net.forwardfire.vasc.frontend.VascFrontendController; /** - * The main vasc entry + * VascEntry is the main vasc entry interface which defines an editable crud entry. * * * @author Willem Cazander * @version 1.0 Mar 21, 2007 */ -public interface VascEntry extends Cloneable,Serializable { - - /** - * @return the id - */ - public String getId(); - - /** - * @param id the id to set - */ - public void setId(String id); +public interface VascEntry extends VascBaseIdRoleCrud { /** * @return the name */ public String getName(); - /** - * @param name the name to set - */ - public void setName(String name); - /** * @return the helpId */ public String getHelpId(); - - /** - * @param helpId the helpId to set - */ - public void setHelpId(String helpId); - + /** * @return the image */ public String getImage(); - /** - * @param image the image to set - */ - public void setImage(String image); - - /** * @return the listDescription */ public String getListDescription(); - /** - * @param listDescription the listDescription to set - */ - public void setListDescription(String listDescription); - /** * @return the listImage */ public String getListImage(); - /** - * @param listImage the listImage to set - */ - public void setListImage(String listImage); - /** * @return the editDescription */ public String getEditDescription(); - /** - * @param editDescription the editDescription to set - */ - public void setEditDescription(String editDescription); - /** * @return the editImage */ public String getEditImage(); - /** - * @param editImage the editImage to set - */ - public void setEditImage(String editImage); - /** * @return the deleteDescription */ public String getDeleteDescription(); - /** - * @param deleteDescription the deleteDescription to set - */ - public void setDeleteDescription(String deleteDescription); - /** * @return the deleteImage */ public String getDeleteImage(); - - /** - * @param deleteImage the deleteImage to set - */ - public void setDeleteImage(String deleteImage); /** * @return the createDescription */ public String getCreateDescription(); - /** - * @param createDescription the createDescription to set - */ - public void setCreateDescription(String createDescription); - /** * @return the createImage */ public String getCreateImage(); - - /** - * @param createImage the createImage to set - */ - public void setCreateImage(String createImage); /** * @return the primaryKeyField */ public String getPrimaryKeyFieldId(); - /** - * @param primaryKeyField the primaryKeyField to set - */ - public void setPrimaryKeyFieldId(String primaryKeyField); - /** * @return the displayNameField */ public String getDisplayNameFieldId(); /** - * @param displayNameField the displayNameField to set + * @return the delete */ - public void setDisplayNameFieldId(String displayNameField); + public Boolean getDelete(); /** - * @return the vascAdminList + * @return the rolesDelete */ - public boolean isVascAdminList(); - - /** - * @param vascAdminList the vascAdminList to set - */ - public void setVascAdminList(boolean vascAdminList); - - /** - * @return the vascAdminEdit - */ - public boolean isVascAdminEdit(); - - /** - * @param vascAdminEdit the vascAdminEdit to set - */ - public void setVascAdminEdit(boolean vascAdminEdit); - - /** - * @return the vascAdminCreate - */ - public boolean isVascAdminCreate(); - - /** - * @param vascAdminCreate the vascAdminCreate to set - */ - public void setVascAdminCreate(boolean vascAdminCreate); - - /** - * @return the vascAdminDelete - */ - public boolean isVascAdminDelete(); - - /** - * @param vascAdminDelete the vascAdminDelete to set - */ - public void setVascAdminDelete(boolean vascAdminDelete); + public String getRolesDelete(); /** * @return the vascFields */ - public List getVascEntryFields(); - - /** - * @param vascField the vascField to add - */ - public void addVascEntryField(VascEntryField vascField); - - /** - * @param vascField the vascField to remove - */ - public void removeVascEntryField(VascEntryField vascField); + public Collection getVascEntryFields(); /** * @return the vascField @@ -247,197 +130,98 @@ public interface VascEntry extends Cloneable,Serializable { /** * @return the rowActions */ - public List getRowActions(); + public Collection getRowActions(); /** * @return the RowVascAction */ public RowVascAction getRowActionById(String actionId); - /** - * @param rowAction the rowAction to add - */ - public void addRowAction(RowVascAction rowAction); - - /** - * @param rowAction the rowAction to remove - */ - public void removeRowAction(RowVascAction rowAction); - /** * @return the columnActions */ - public List getColumnActions(); + public Collection getColumnActions(); /** * @return the ColumnVascAction */ public ColumnVascAction getColumnActionById(String actionId); - - /** - * @param columnAction the columnAction to add - */ - public void addColumnAction(ColumnVascAction columnAction); - - /** - * @param columnAction the columnAction to remove - */ - public void removeColumnAction(ColumnVascAction columnAction); - + /** * @return the globalActions */ - public List getGlobalActions(); + public Collection getGlobalActions(); /** * @return the GlobalVascAction */ public GlobalVascAction getGlobalActionById(String actionId); - - /** - * @param globalAction the globalAction to add - */ - public void addGlobalAction(GlobalVascAction globalAction); - /** - * @param globalAction the globalAction to remove - */ - public void removeGlobalAction(GlobalVascAction globalAction); - /** * @return the exportActions */ - public List getExportActions(); + public Collection getExportActions(); /** * @return the GlobalVascAction exportAction */ public GlobalVascAction getExportActionById(String actionId); - - /** - * @param exportAction the exportAction to add - */ - public void addExportAction(GlobalVascAction exportAction); - - /** - * @param exportAction the exportAction to remove - */ - public void removeExportAction(GlobalVascAction exportAction); - + /** * @return the vascEntryFieldSets */ - public List getVascEntryFieldSets(); + public Collection getVascEntryFieldSets(); /** * @return the VascEntryFieldSet */ public VascEntryFieldSet getVascEntryFieldSetById(String actionId); - - /** - * @param vascEntryFieldSet the vascEntryFieldSet to add - */ - public void addVascEntryFieldSet(VascEntryFieldSet vascEntryFieldSet); - - /** - * @param vascEntryFieldSet the vascEntryFieldSet to remove - */ - public void removeVascEntryFieldSet(VascEntryFieldSet vascEntryFieldSet); - + /** * @return the vascLinkEntries */ - public List getVascLinkEntries(); + public Collection getVascEntryLinks(); /** * @return the VascLinkEntry */ - public VascLinkEntry getVascLinkEntryById(String actionId); - - /** - * @param vascLinkEntry the vascLinkEntry to add - */ - public void addVascLinkEntry(VascLinkEntry vascLinkEntry); - - /** - * @param vascLinkEntry the vascLinkEntry to remover - */ - public void removeVascLinkEntry(VascLinkEntry vascLinkEntry); + public VascEntryLink getVascEntryLinkById(String linkId); public Object getEntryParameter(String key); - public void setEntryParameter(String key,Object value); + public List getEntryParameterKeys(); - public VascFrontendData getVascFrontendData(); - public void setVascFrontendData(VascFrontendData vascFrontendData); - + public VascFrontendController getVascFrontendController(); + public String getBackendId(); - public void setBackendId(String backendId); - - /** * @return the vascDisplayOnly */ - public boolean isVascDisplayOnly(); - - /** - * @param vascDisplayOnly the vascDisplayOnly to set - */ - public void setVascDisplayOnly(boolean vascDisplayOnly); - + public Boolean getVascDisplayOnly(); /** * @return the vascEntryFieldEventChannel */ public VascEntryFieldEventChannel getVascEntryFieldEventChannel(); - /** - * @param vascEntryFieldEventChannel the vascEntryFieldEventChannel to set - */ - public void setVascEntryFieldEventChannel(VascEntryFieldEventChannel vascEntryFieldEventChannel); - - /** - * Added an VascEntryBackendEventListener - * @param listener The class of the event listener. - */ - public void addVascEntryBackendEventListener(String listener); - /** * Returns the list of VascEntryBackendEventListener * @return */ public List getVascEntryBackendEventListeners(); - /** - * Added an VascEntryFrontendEventListener - * @param listener The class of the event listener. - */ - public void addVascEntryFrontendEventListener(String listener,String frontendType); - /** * Returns the list of VascEntryFrontendEventListener * @return */ public List getVascEntryFrontendEventListenersByType(String frontendType); + + public Collection getVascEntryListOptions(); + public VascEntryListOption getVascEntryListOptionById(String listOptionId); - public void addListOption(VascEntryField listOption); - public void removeListOption(VascEntryField listOption); - public List getListOptions(); - public VascEntryField getListOptionById(String listOptionId); - - - public void addVascBackendFilter(VascBackendFilter filter); public List getVascBackendFilters(); - public void addVascEntryFrontendAction(String actionClass,String frontendType); public List getVascEntryFrontendActionsByType(String frontendType); - - /** - * Force impl to have public clone methode - * @return - * @throws CloneNotSupportedException - */ - public VascEntry clone() throws CloneNotSupportedException; } diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryConfigController.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryConfigController.java index 3999e2e..ad948d3 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryConfigController.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryConfigController.java @@ -23,12 +23,9 @@ package net.forwardfire.vasc.core; import java.util.List; -import java.util.Locale; import net.forwardfire.vasc.backend.VascBackend; -import net.forwardfire.vasc.backend.proxy.VascBackendProxy; import net.forwardfire.vasc.core.entry.VascEntryExporter; -import net.forwardfire.vasc.core.entry.VascEntryFieldValidatorService; /** * Interface to make default fill/etc config plugable. @@ -38,56 +35,24 @@ import net.forwardfire.vasc.core.entry.VascEntryFieldValidatorService; */ public interface VascEntryConfigController { + public VascInterfaceLoader getVascInterfaceLoader(); + + public Object createVascInterfaceImplemention(VascInterfaceKey key); + public Object createVascInterfaceImplementionFrontend(VascInterfaceKeyFrontend key,VascEntry entry); + public VascEntry configVascEntry(VascController vascController,String entryId) throws VascException; - public void configVascEntry(VascController vascController,VascEntry vascEntry) throws VascException; - - - public void addVascEntryConfigFinalizer(VascEntryConfigFinalizer vascEntryConfigFinalizer); - - public void removeVascEntryConfigFinalizer(VascEntryConfigFinalizer vascEntryConfigFinalizer); - - public List getVascEntryConfigFinalizers(); - - + public void configVascEntry(VascController vascController,VascEntryLocal vascEntry) throws VascException; + public VascBackend configVascBackendProxied(VascController vascController,VascEntry vascEntry) throws VascException; public VascBackend configVascBackendProxied(VascController vascController,VascEntry vascEntry,VascBackend realBackend) throws VascException; - public void addVascBackendProxy(VascBackendProxy proxy); - - public void removeVascBackendProxy(VascBackendProxy proxy); - - public List getVascBackendProxies(); - + public List getVascEntryExporterIds(); public VascEntryExporter getVascEntryExporterById(String exporterId); - public void addVascEntryExporter(VascEntryExporter exporter); - - public void removeVascEntryExporter(VascEntryExporter exporter); - - public List getVascEntryExporters(); - - - public void configVascFrontendData(VascController vascController,VascEntry entry,Locale locale) throws VascException; + public void configVascFrontendController(VascController vascController,VascEntryLocal entry) throws VascException; public String getResourceBundle(); - - public void setResourceBundle(String resourceBundle); - - public int getDefaultPageSizeMax(); - - public void setDefaultPageSizeMax(int max); - - public int getDefaultPageSize(); - - public void setDefaultPageSize(int size); - - public void addVascEntryFieldValidatorService(VascEntryFieldValidatorService validator); - - public void removeVascEntryFieldValidatorService(VascEntryFieldValidatorService validator); - - public List getVascEntryFieldValidatorServices(); - } \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryConfigControllerLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryConfigControllerLocal.java new file mode 100644 index 0000000..ed3ae40 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryConfigControllerLocal.java @@ -0,0 +1,76 @@ +/* + * 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.core; + +import java.util.List; + +import net.forwardfire.vasc.backend.VascBackendState; +import net.forwardfire.vasc.backend.proxy.VascBackendProxy; +import net.forwardfire.vasc.core.entry.VascEntryExporter; +import net.forwardfire.vasc.core.entry.VascEntryFieldValidatorService; + +/** + * Interface to make default fill/etc config plugable. + * + * @author Willem Cazander + * @version 1.0 May 9, 2012 + */ +public interface VascEntryConfigControllerLocal extends VascEntryConfigController { + + public void putVascInterfaceImplemention(VascInterfaceKey key,Class interfaceImpl); + public void putVascInterfaceImplementionFrontend(VascInterfaceKeyFrontend key,Class interfaceImpl); + + + + public void addVascEntryConfigFinalizer(VascEntryConfigFinalizer vascEntryConfigFinalizer); + + public void removeVascEntryConfigFinalizer(VascEntryConfigFinalizer vascEntryConfigFinalizer); + + public List getVascEntryConfigFinalizers(); + + + + public void addVascBackendProxy(VascBackendProxy proxy); + + public void removeVascBackendProxy(VascBackendProxy proxy); + + public List getVascBackendProxies(); + + + + public void addVascEntryExporter(VascEntryExporter exporter); + + public void removeVascEntryExporter(VascEntryExporter exporter); + + + public VascBackendState getMasterVascBackendState(); + + public void setResourceBundle(String resourceBundle); + + public void addVascEntryFieldValidatorService(VascEntryFieldValidatorService validator); + + public void removeVascEntryFieldValidatorService(VascEntryFieldValidatorService validator); + + public List getVascEntryFieldValidatorServices(); + +} \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryConfigFinalizer.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryConfigFinalizer.java index b91af16..b40ff8e 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryConfigFinalizer.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryConfigFinalizer.java @@ -30,5 +30,5 @@ package net.forwardfire.vasc.core; */ public interface VascEntryConfigFinalizer { - public void configVascEntry(VascController vascController,VascEntry entry) throws VascException; + public void configVascEntry(VascController vascController,VascEntryLocal entry) throws VascException; } \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryControllerLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryControllerLocal.java index 4772a3a..7a88738 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryControllerLocal.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryControllerLocal.java @@ -32,9 +32,9 @@ package net.forwardfire.vasc.core; */ public interface VascEntryControllerLocal extends VascEntryController { - public void addVascEntry(VascEntry entry); + public void addVascEntry(VascEntryLocal entry); public void removeVascEntry(String entryId); - public VascEntry getMasterVascEntryById(String entryId); + public VascEntryLocal getMasterVascEntryById(String entryId); } \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryField.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryField.java index 860a76d..21fe5af 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryField.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryField.java @@ -22,364 +22,108 @@ package net.forwardfire.vasc.core; -import java.io.Serializable; import java.util.List; +import net.forwardfire.vasc.core.base.VascBaseIdRoleCrudOrderMeta; import net.forwardfire.vasc.core.entry.VascEntryFieldValue; import net.forwardfire.vasc.validators.VascValidator; - - /** - * Defines an VascEntryField + * VascEntryField defines values per field. * * - * * @author Willem Cazander * @version 1.0 Mar 21, 2007 */ -public interface VascEntryField extends Cloneable,Serializable { +public interface VascEntryField extends VascBaseIdRoleCrudOrderMeta { /** * @return the VascEntry */ public VascEntry getVascEntry(); - /** - * @param entry the VascEntry to set - */ - public void setVascEntry(VascEntry entry); - - /** - * @return the id - */ - public String getId(); - - /** - * @param id the id to set - */ - public void setId(String id); - /** * @return the vascEntryFieldType */ public VascEntryFieldType getVascEntryFieldType(); - /** - * @param vascEntryFieldType the vascEntryFieldType to set - */ - public void setVascEntryFieldType(VascEntryFieldType vascEntryFieldType); - /** * @return the backendName */ public String getBackendName(); - /** - * @param backendName the backendName to set - */ - public void setBackendName(String backendName); - /** * @return the vascEntryFieldValue */ public VascEntryFieldValue getVascEntryFieldValue(); - - /** - * @param vascEntryFieldValue the vascEntryFieldValue to set - */ - public void setVascEntryFieldValue(VascEntryFieldValue vascEntryFieldValue); /** * @return the vascValidators */ public List getVascValidators(); - /** - * @param vascValidator the vascValidator to add - */ - public void addVascValidator(VascValidator vascValidator); - - /** - * @param vascValidator the vascValidator to remove - */ - public void removeVascValidator(VascValidator vascValidator); - - /** - * @return the name - */ - public String getName(); - - /** - * @param name the name to set - */ - public void setName(String name); - - /** - * @return the description - */ - public String getDescription(); - - /** - * @param description the description to set - */ - public void setDescription(String description); - - /** - * @return the helpId - */ - public String getHelpId(); - - /** - * @param helpId the helpId to set - */ - public void setHelpId(String helpId); - - /** - * @return the image - */ - public String getImage(); - - /** - * @param image the image to set - */ - public void setImage(String image); - /** * @return the defaultValue */ public Object getDefaultValue(); - /** - * @param defaultValue the defaultValue to set - */ - public void setDefaultValue(Object defaultValue); - /** * @return the sizeList */ public Integer getSizeList(); - /** - * @param sizeList the sizeList to set - */ - public void setSizeList(Integer sizeList); - /** * @return the sizeEdit */ public Integer getSizeEdit(); - /** - * @param sizeEdit the sizeEdit to set - */ - public void setSizeEdit(Integer sizeEdit); - /** * @return the styleList */ public String getStyleList(); - /** - * @param styleList the styleList to set - */ - public void setStyleList(String styleList); - /** * @return the styleEdit */ public String getStyleEdit(); - /** - * @param styleEdit the styleEdit to set - */ - public void setStyleEdit(String styleEdit); - /** * @return the choices */ public String getChoices(); - /** - * @param choices the choices to set - */ - public void setChoices(String choices); - - /** - * @return the view - */ - public Boolean getView(); - - /** - * @param view the view to set - */ - public void setView(Boolean view); - /** * @return the optional */ public Boolean getOptional(); - - /** - * @param optional the optional to set - */ - public void setOptional(Boolean optional); - - /** - * @return the create - */ - public Boolean getCreate(); - - /** - * @param create the create to set - */ - public void setCreate(Boolean create); - - /** - * @return the edit - */ - public Boolean getEdit(); - - /** - * @param edit the edit to set - */ - public void setEdit(Boolean edit); - - /** - * @return the editReadOnly - */ - public Boolean getEditReadOnly(); - - /** - * @param editReadOnly the editReadOnly to set - */ - public void setEditReadOnly(Boolean editReadOnly); - - /** - * @return the list - */ - public Boolean getList(); - - /** - * @param list the list to set - */ - public void setList(Boolean list); - - /** - * @return the rolesCreate - */ - public String getRolesCreate(); - - /** - * @param rolesCreate the rolesCreate to set - */ - public void setRolesCreate(String rolesCreate); - - /** - * @return the rolesEdit - */ - public String getRolesEdit(); - - /** - * @param rolesEdit the rolesEdit to set - */ - public void setRolesEdit(String rolesEdit); - - /** - * @return the rolesEditReadOnly - */ - public String getRolesEditReadOnly(); - - /** - * @param rolesEditReadOnly the rolesEditReadOnly to set - */ - public void setRolesEditReadOnly(String rolesEditReadOnly); - - /** - * @return the rolesList - */ - public String getRolesList(); - - /** - * @param rolesList the rolesList to set - */ - public void setRolesList(String rolesList); - - + /** * @return the choicesAsRadio */ public Boolean getChoicesAsRadio(); - /** - * @param choicesAsRadio the choicesAsRadio to set - */ - public void setChoicesAsRadio(Boolean choicesAsRadio); - /** * @return the editBlank */ public Boolean getEditBlank(); - - /** - * @param editBlank the editBlank to set - */ - public void setEditBlank(Boolean editBlank); /** * @return the displayName */ public String getDisplayName(); - - /** - * @param displayName the displayName to set - */ - public void setDisplayName(String displayName); - - /** - * @return the orderIndex - */ - public Integer getOrderIndex(); - - /** - * @param orderIndex the orderIndex to set - */ - public void setOrderIndex(Integer orderIndex); /** * @return the sortable */ public Boolean getSortable(); - /** - * @param sortable the sortable to set - */ - public void setSortable(Boolean sortable); - /** * @return the sumable */ public Boolean getSumable(); - /** - * @param sumable the sumable to set - */ - public void setSumable(Boolean sumable); - /** * @return the graphable */ public Boolean getGraphable(); - - /** - * @param graphable the graphable to set - */ - public void setGraphable(Boolean graphable); - - /** - * Force impl to have public clone method - * @return - * @throws CloneNotSupportedException - */ - public VascEntryField clone() throws CloneNotSupportedException; } \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryFieldLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryFieldLocal.java new file mode 100644 index 0000000..1bc8eb0 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryFieldLocal.java @@ -0,0 +1,139 @@ +/* + * 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.core; + +import net.forwardfire.vasc.core.base.VascBaseIdRoleCrudOrderMetaLocal; +import net.forwardfire.vasc.core.entry.VascEntryFieldValue; +import net.forwardfire.vasc.validators.VascValidator; + +/** + * VascEntryFieldLocal + * + * + * @author Willem Cazander + * @version 1.0 Jun 2, 2012 + */ +public interface VascEntryFieldLocal extends VascEntryField,VascBaseIdRoleCrudOrderMetaLocal { + + /** + * @param entry the VascEntry to set + */ + public void setVascEntry(VascEntry entry); + + /** + * @param vascEntryFieldType the vascEntryFieldType to set + */ + public void setVascEntryFieldType(VascEntryFieldType vascEntryFieldType); + + /** + * @param backendName the backendName to set + */ + public void setBackendName(String backendName); + + /** + * @param vascEntryFieldValue the vascEntryFieldValue to set + */ + public void setVascEntryFieldValue(VascEntryFieldValue vascEntryFieldValue); + + /** + * @param vascValidator the vascValidator to add + */ + public void addVascValidator(VascValidator vascValidator); + + /** + * @param vascValidator the vascValidator to remove + */ + public void removeVascValidator(VascValidator vascValidator); + + /** + * @param defaultValue the defaultValue to set + */ + public void setDefaultValue(Object defaultValue); + + /** + * @param sizeList the sizeList to set + */ + public void setSizeList(Integer sizeList); + + /** + * @param sizeEdit the sizeEdit to set + */ + public void setSizeEdit(Integer sizeEdit); + + /** + * @param styleList the styleList to set + */ + public void setStyleList(String styleList); + + /** + * @param styleEdit the styleEdit to set + */ + public void setStyleEdit(String styleEdit); + + /** + * @param choices the choices to set + */ + public void setChoices(String choices); + + /** + * @param optional the optional to set + */ + public void setOptional(Boolean optional); + + /** + * @param choicesAsRadio the choicesAsRadio to set + */ + public void setChoicesAsRadio(Boolean choicesAsRadio); + + /** + * @param editBlank the editBlank to set + */ + public void setEditBlank(Boolean editBlank); + + /** + * @param displayName the displayName to set + */ + public void setDisplayName(String displayName); + + /** + * @param sortable the sortable to set + */ + public void setSortable(Boolean sortable); + + /** + * @param sumable the sumable to set + */ + public void setSumable(Boolean sumable); + + /** + * @param graphable the graphable to set + */ + public void setGraphable(Boolean graphable); + + /** + * Force impl to have public clone method + * @return + * @throws CloneNotSupportedException + */ + public VascEntryFieldLocal clone() throws CloneNotSupportedException; +} \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryFieldSet.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryFieldSet.java index 3f317f8..2227cd8 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryFieldSet.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryFieldSet.java @@ -24,6 +24,8 @@ package net.forwardfire.vasc.core; import java.util.List; +import net.forwardfire.vasc.core.base.VascBaseIdRoleCrudOrderMeta; + /** * Orgenisess Fields * @@ -32,119 +34,25 @@ import java.util.List; * @author Willem Cazander * @version 1.0 Sep 56, 2008 */ -public interface VascEntryFieldSet extends Cloneable { - - /** - * @return the id - */ - public String getId(); - - /** - * @param id the id to set - */ - public void setId(String id); - - /** - * @return the name - */ - public String getName(); - - /** - * @param name the name to set - */ - public void setName(String name); - - /** - * @return the description - */ - public String getDescription(); - - /** - * @param description the description to set - */ - public void setDescription(String description); - - /** - * @return the helpId - */ - public String getHelpId(); - - /** - * @param helpId the helpId to set - */ - public void setHelpId(String helpId); - - /** - * @return the image - */ - public String getImage(); - - /** - * @param image the image to set - */ - public void setImage(String image); +public interface VascEntryFieldSet extends VascBaseIdRoleCrudOrderMeta { /** * @return the styleList */ public String getStyleList(); - /** - * @param styleList the styleList to set - */ - public void setStyleList(String styleList); - /** * @return the styleEdit */ public String getStyleEdit(); - /** - * @param styleEdit the styleEdit to set - */ - public void setStyleEdit(String styleEdit); - /** * @return the collapsed */ - public boolean isCollapsed(); - - /** - * @param collapsed the collapsed to set - */ - public void setCollapsed(boolean collapsed); - - /** - * @return the optional - */ - public boolean isOptional(); - - /** - * @param optional the optional to set - */ - public void setOptional(boolean optional); + public Boolean getCollapsed(); /** * @return the vascEntryFieldIds */ public List getVascEntryFieldIds(); - - /** - * Add and VascEntryFieldId - * @param vascEntryFieldIds the vascEntryFieldIds to add - */ - public void addVascEntryFieldId(String vascEntryFieldId); - - /** - * Removes and VascEntryFieldId - * @param vascEntryFieldIds the vascEntryFieldIds to remove - */ - public void removeVascEntryFieldId(String vascEntryFieldId); - - /** - * Force impl to have public clone methode - * @return - * @throws CloneNotSupportedException - */ - public VascEntryFieldSet clone() throws CloneNotSupportedException; } \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryFieldSetLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryFieldSetLocal.java new file mode 100644 index 0000000..a4e59f6 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryFieldSetLocal.java @@ -0,0 +1,70 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.core; + +import net.forwardfire.vasc.core.base.VascBaseIdRoleCrudOrderMetaLocal; + + +/** + * VascEntryFieldSetLocal + * + * @author Willem Cazander + * @version 1.0 Jun 2, 2012 + */ +public interface VascEntryFieldSetLocal extends VascEntryFieldSet,VascBaseIdRoleCrudOrderMetaLocal { + + /** + * @param styleList the styleList to set + */ + public void setStyleList(String styleList); + + /** + * @param styleEdit the styleEdit to set + */ + public void setStyleEdit(String styleEdit); + + /** + * @param collapsed the collapsed to set + */ + public void setCollapsed(Boolean collapsed); + + /** + * Add and VascEntryFieldId + * @param vascEntryFieldIds the vascEntryFieldIds to add + */ + public void addVascEntryFieldId(String vascEntryFieldId); + + /** + * Removes and VascEntryFieldId + * @param vascEntryFieldIds the vascEntryFieldIds to remove + */ + public void removeVascEntryFieldId(String vascEntryFieldId); + + + /** + * Force impl to have public clone methode + * @return + * @throws CloneNotSupportedException + */ + public VascEntryFieldSetLocal clone() throws CloneNotSupportedException; +} \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryFieldType.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryFieldType.java index 7319d03..88cc049 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryFieldType.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryFieldType.java @@ -22,46 +22,36 @@ package net.forwardfire.vasc.core; -import java.io.Serializable; import java.util.List; import org.x4o.xml.conv.ObjectConverter; +import net.forwardfire.vasc.core.base.VascBaseId; import net.forwardfire.vasc.core.ui.VascUIComponent; import net.forwardfire.vasc.core.ui.VascValueModel; import net.forwardfire.vasc.validators.VascValidator; - - - /** + * VascEntryFieldType * * @author Willem Cazander * @version 1.0 Mar 21, 2007 */ -public interface VascEntryFieldType extends Serializable { +public interface VascEntryFieldType extends VascBaseId { - public String getId(); - public void setId(String id); public String getUIComponentId(); - public void setUIComponentId(String uiComponentId); public String getInputMask(); - public void setInputMask(String inputMask); public Class getAutoDetectClass(); - public void setAutoDetectClass(Class classObject); - - public void addVascValidator(VascValidator vascValidator); - public void removeVascValidator(VascValidator vascValidator); + public List getVascValidators(); - public void setProperty(String name,String value); public String getProperty(String name); public List getPropertyNames(); - public void setDataObject(Object data); + public void setDataObject(Object data); // TODO move to fronend controller public Object getDataObject(); public int getUIComponentCount(VascEntryField entryField) throws VascException; @@ -74,16 +64,4 @@ public interface VascEntryFieldType extends Serializable { * @return the objectConverter */ public ObjectConverter getObjectConverter(); - - /** - * @param objectConverter the objectConverter to set - */ - public void setObjectConverter(ObjectConverter objectConverter); - - /** - * Force impl to have public clone methode - * @return - * @throws CloneNotSupportedException - */ - public VascEntryFieldType clone() throws CloneNotSupportedException; } diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryFieldTypeControllerLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryFieldTypeControllerLocal.java index 0d516d4..b9b9e45 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryFieldTypeControllerLocal.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryFieldTypeControllerLocal.java @@ -30,5 +30,5 @@ package net.forwardfire.vasc.core; */ public interface VascEntryFieldTypeControllerLocal extends VascEntryFieldTypeController { - public void addVascEntryFieldType(VascEntryFieldType vascEntryFieldType); + public void addVascEntryFieldType(VascEntryFieldTypeLocal vascEntryFieldType); } \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryFieldTypeLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryFieldTypeLocal.java new file mode 100644 index 0000000..ba743f4 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryFieldTypeLocal.java @@ -0,0 +1,60 @@ +/* + * 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.core; + +import org.x4o.xml.conv.ObjectConverter; + +import net.forwardfire.vasc.core.base.VascBaseIdLocal; +import net.forwardfire.vasc.validators.VascValidator; + +/** + * + * @author Willem Cazander + * @version 1.0 Jun 2, 2012 + */ +public interface VascEntryFieldTypeLocal extends VascEntryFieldType,VascBaseIdLocal { + + + public void setUIComponentId(String uiComponentId); + + public void setInputMask(String inputMask); + + public void setAutoDetectClass(Class classObject); + + public void addVascValidator(VascValidator vascValidator); + public void removeVascValidator(VascValidator vascValidator); + + public void setProperty(String name,String value); + + /** + * @param objectConverter the objectConverter to set + */ + public void setObjectConverter(ObjectConverter objectConverter); + + /** + * Force impl to have public clone methode + * @return + * @throws CloneNotSupportedException + */ + public VascEntryFieldTypeLocal clone() throws CloneNotSupportedException; +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryLink.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryLink.java new file mode 100644 index 0000000..07c5f57 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryLink.java @@ -0,0 +1,60 @@ +/* + * 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.core; + +import java.util.List; + +import net.forwardfire.vasc.core.base.VascBaseIdRoleViewOrderMeta; + + +/** + * VascLinkEntry + * + * @author Willem Cazander + * @version 1.0 Sep 7, 2008 + */ +public interface VascEntryLink extends VascBaseIdRoleViewOrderMeta { + + + public String getEntryParameterFieldId(String parameterName); + public List getEntryParameterFieldIdKeys(); + + public String getEntryCreateFieldValue(String valueFieldId); + public List getEntryCreateFieldValueKeys(); + + + /** + * @return the vascEntryId + */ + public String getVascEntryId(); + + /** + * @return the vascLinkEntryType + */ + public VascEntryLinkType getVascLinkEntryType(); + + /** + * @return the doActionId + */ + public String getDoActionId(); +} \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryLinkLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryLinkLocal.java new file mode 100644 index 0000000..5fad744 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryLinkLocal.java @@ -0,0 +1,62 @@ +/* + * 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.core; + +import net.forwardfire.vasc.core.base.VascBaseIdRoleViewOrderMetaLocal; + + +/** + * VascEntryLinkLocal + * + * @author Willem Cazander + * @version 1.0 Jun 2, 2012 + */ +public interface VascEntryLinkLocal extends VascEntryLink,VascBaseIdRoleViewOrderMetaLocal { + + + public void addEntryParameterFieldId(String parameterName,String valueFieldId); + + public void addEntryCreateFieldValue(String valueFieldId,String selectedFieldId); + + /** + * @param vascEntryId the vascEntryId to set + */ + public void setVascEntryId(String vascEntryId); + + /** + * @param vascLinkEntryType the vascLinkEntryType to set + */ + public void setVascLinkEntryType(VascEntryLinkType vascLinkEntryType); + + /** + * @param doActionId the doActionId to set + */ + public void setDoActionId(String doActionId); + + /** + * Force impl to have public clone methode + * @return + * @throws CloneNotSupportedException + */ + public VascEntryLinkLocal clone() throws CloneNotSupportedException; +} \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryLinkType.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryLinkType.java new file mode 100644 index 0000000..fc43733 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryLinkType.java @@ -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.core; + +import java.io.Serializable; + +/** + * The type of a VascLinkEntry + * + * @author Willem Cazander + * @version 1.0 Mrt 16, 2010 + */ +public enum VascEntryLinkType implements Serializable { + + EDIT_INLINE, + EDIT_TAB, + LIST; + + public static VascEntryLinkType DEFAULT_TYPE = VascEntryLinkType.EDIT_TAB; +} \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryListOption.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryListOption.java new file mode 100644 index 0000000..eef0b13 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryListOption.java @@ -0,0 +1,41 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.core; + +/** + * VascEntryListOption defines list options. + * + * + * @author Willem Cazander + * @version 1.0 Jun 3, 2012 + */ +public interface VascEntryListOption extends VascEntryField { + + /* + public VascEntryFieldType getVascEntryFieldType(); + public String getBackendName(); + public List getVascValidators(); + public Object getDefaultValue(); + public Boolean getOptional(); + */ +} \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryListOptionLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryListOptionLocal.java new file mode 100644 index 0000000..3b7b179 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryListOptionLocal.java @@ -0,0 +1,41 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.core; + + +/** + * VascEntryListOptionLocal + * + * + * @author Willem Cazander + * @version 1.0 Jun 2, 2012 + */ +public interface VascEntryListOptionLocal extends VascEntryListOption,VascEntryFieldLocal { + + /** + * Force impl to have public clone method + * @return + * @throws CloneNotSupportedException + */ + public VascEntryListOptionLocal clone() throws CloneNotSupportedException; +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryLocal.java new file mode 100644 index 0000000..45676c7 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryLocal.java @@ -0,0 +1,271 @@ +/* + * 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.core; + +import java.util.Collection; + +import net.forwardfire.vasc.backend.VascBackendFilter; +import net.forwardfire.vasc.core.actions.ColumnVascActionLocal; +import net.forwardfire.vasc.core.actions.GlobalVascActionLocal; +import net.forwardfire.vasc.core.actions.RowVascActionLocal; +import net.forwardfire.vasc.core.base.VascBaseIdRoleCrudLocal; +import net.forwardfire.vasc.core.entry.VascEntryFieldEventChannel; +import net.forwardfire.vasc.frontend.VascFrontendController; + +/** + * VascEntryLocal + * + * + * @author Willem Cazander + * @version 1.0 Jun 2, 2012 + */ +public interface VascEntryLocal extends VascEntry,VascBaseIdRoleCrudLocal { + + /** + * @param name the name to set + */ + public void setName(String name); + + /** + * @param helpId the helpId to set + */ + public void setHelpId(String helpId); + + /** + * @param image the image to set + */ + public void setImage(String image); + + /** + * @param listDescription the listDescription to set + */ + public void setListDescription(String listDescription); + + /** + * @param listImage the listImage to set + */ + public void setListImage(String listImage); + + /** + * @param editDescription the editDescription to set + */ + public void setEditDescription(String editDescription); + + /** + * @param editImage the editImage to set + */ + public void setEditImage(String editImage); + + /** + * @param deleteDescription the deleteDescription to set + */ + public void setDeleteDescription(String deleteDescription); + + /** + * @param deleteImage the deleteImage to set + */ + public void setDeleteImage(String deleteImage); + + /** + * @param createDescription the createDescription to set + */ + public void setCreateDescription(String createDescription); + + /** + * @param createImage the createImage to set + */ + public void setCreateImage(String createImage); + + /** + * @param primaryKeyField the primaryKeyField to set + */ + public void setPrimaryKeyFieldId(String primaryKeyField); + + /** + * @param displayNameField the displayNameField to set + */ + public void setDisplayNameFieldId(String displayNameField); + + /** + * @param delete the delete to set + */ + public void setDelete(Boolean delete); + + /** + * @param rolesDelete the rolesDelete to set + */ + public void setRolesDelete(String rolesDelete); + + /** + * @param vascField the vascField to add + */ + public void addVascEntryField(VascEntryFieldLocal vascField); + + /** + * @param vascField the vascField to remove + */ + public void removeVascEntryField(VascEntryFieldLocal vascField); + + /** + * @return the vascFields + */ + public Collection getVascEntryFieldsLocal(); + + /** + * @param rowAction the rowAction to add + */ + public void addRowAction(RowVascActionLocal rowAction); + + /** + * @param rowAction the rowAction to remove + */ + public void removeRowAction(RowVascActionLocal rowAction); + + /** + * @return the rowActions + */ + public Collection getRowActionsLocal(); + + /** + * @param columnAction the columnAction to add + */ + public void addColumnAction(ColumnVascActionLocal columnAction); + + /** + * @param columnAction the columnAction to remove + */ + public void removeColumnAction(ColumnVascActionLocal columnAction); + + /** + * @return the columnActions + */ + public Collection getColumnActionsLocal(); + + /** + * @param globalAction the globalAction to add + */ + public void addGlobalAction(GlobalVascActionLocal globalAction); + + /** + * @param globalAction the globalAction to remove + */ + public void removeGlobalAction(GlobalVascActionLocal globalAction); + + /** + * @return the globalActions + */ + public Collection getGlobalActionsLocal(); + + /** + * @param exportAction the exportAction to add + */ + public void addExportAction(GlobalVascActionLocal exportAction); + + /** + * @param exportAction the exportAction to remove + */ + public void removeExportAction(GlobalVascActionLocal exportAction); + + /** + * @return the exportActions + */ + public Collection getExportActionsLocal(); + + /** + * @param vascEntryFieldSet the vascEntryFieldSet to add + */ + public void addVascEntryFieldSet(VascEntryFieldSetLocal vascEntryFieldSet); + + /** + * @param vascEntryFieldSet the vascEntryFieldSet to remove + */ + public void removeVascEntryFieldSet(VascEntryFieldSetLocal vascEntryFieldSet); + + /** + * @return the vascEntryFieldSets + */ + public Collection getVascEntryFieldSetsLocal(); + + /** + * @param vascLinkEntry the vascLinkEntry to add + */ + public void addVascEntryLink(VascEntryLinkLocal vascEntryLink); + + /** + * @param vascLinkEntry the vascLinkEntry to remover + */ + public void removeVascEntryLink(VascEntryLinkLocal vascEntryLink); + + /** + * @return the vascLinkEntries + */ + public Collection getVascEntryLinksLocal(); + + public void setEntryParameter(String key,Object value); + public void removeEntryParameter(String key); + + + public void setVascFrontendController(VascFrontendController vascFrontendData); + + + public void setBackendId(String backendId); + + /** + * @param vascDisplayOnly the vascDisplayOnly to set + */ + public void setVascDisplayOnly(Boolean vascDisplayOnly); + + /** + * @param vascEntryFieldEventChannel the vascEntryFieldEventChannel to set + */ + public void setVascEntryFieldEventChannel(VascEntryFieldEventChannel vascEntryFieldEventChannel); + + /** + * Added an VascEntryBackendEventListener + * @param listener The class of the event listener. + */ + public void addVascEntryBackendEventListener(String listener); + + /** + * Added an VascEntryFrontendEventListener + * @param listener The class of the event listener. + */ + public void addVascEntryFrontendEventListener(String listener,String frontendType); + + public void addVascEntryListOption(VascEntryListOptionLocal listOption); + + public void removeVascEntryListOption(VascEntryListOptionLocal listOption); + + public Collection getVascEntryListOptionsLocal(); + + public void addVascBackendFilter(VascBackendFilter filter); + + public void addVascEntryFrontendAction(String actionClass,String frontendType); + + /** + * Force impl to have public clone methode + * @return + * @throws CloneNotSupportedException + */ + public VascEntryLocal clone() throws CloneNotSupportedException; +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascInterfaceKey.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascInterfaceKey.java new file mode 100644 index 0000000..48b0eb8 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascInterfaceKey.java @@ -0,0 +1,47 @@ +/* + * 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.core; + +/** + * VascInterfaceKey defines which interfaces are easy extentable. + * + * @author Willem Cazander + * @version 1.0 May 9, 2012 + */ +public enum VascInterfaceKey { + + VASC_ENTRY, + VASC_ENTRY_FIELD, + VASC_ENTRY_FIELD_SET, + VASC_ENTRY_LINK, + VASC_ENTRY_LIST_OPTION, + + + VASC_ENTRY_STATE, + VASC_BACKEND_STATE, + VASC_FRONTEND_CONTROLLER_LOCAL, + + + + END_RM_ME; +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascInterfaceKeyFrontend.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascInterfaceKeyFrontend.java new file mode 100644 index 0000000..dee5eb2 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascInterfaceKeyFrontend.java @@ -0,0 +1,41 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.core; + +/** + * VascInterfaceKeyFrontend defines which interfaces are easy extentable. + * + * @author Willem Cazander + * @version 1.0 May 9, 2012 + */ +public enum VascInterfaceKeyFrontend { + + + VASC_FRONTEND_PAGER, + VASC_FRONTEND_ACTIONS, + VASC_FRONTEND_DATA_SELECTOR, + VASC_FRONTEND_USER_CONTROLLER, + VASC_FRONTEND_USER_SETTING_CONTROLLER + + ; +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascInterfaceLoader.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascInterfaceLoader.java new file mode 100644 index 0000000..9c7b2f9 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascInterfaceLoader.java @@ -0,0 +1,34 @@ +package net.forwardfire.vasc.core; + +import net.forwardfire.vasc.backend.VascBackendState; +import net.forwardfire.vasc.frontend.VascFrontendActions; +import net.forwardfire.vasc.frontend.VascFrontendControllerLocal; +import net.forwardfire.vasc.frontend.VascFrontendDataSelector; +import net.forwardfire.vasc.frontend.VascFrontendPager; +import net.forwardfire.vasc.frontend.VascFrontendUserController; +import net.forwardfire.vasc.frontend.VascFrontendUserSettingController; + + +public interface VascInterfaceLoader { + + public VascEntry createVascEntryImpl(); + public VascEntryField createVascEntryFieldImpl(); + public VascEntryFieldSet createVascEntryFieldSetImpl(); + public VascEntryLink createVascEntryLinkImpl(); + public VascEntryListOption createVascEntryListOptionImpl(); + + + public VascEntryState createVascEntryStateImpl(); + public VascBackendState createVascBackendStateImpl(); + public VascFrontendControllerLocal createVascFrontendControllerLocalImpl(); + + + + public VascFrontendPager createVascFrontendPagerImpl(VascEntry entry); + public VascFrontendActions createVascFrontendActionsImpl(VascEntry entry); + public VascFrontendDataSelector createVascFrontendDataSelectorImpl(VascEntry entry); + public VascFrontendUserController createVascFrontendUserControllerImpl(VascEntry entry); + public VascFrontendUserSettingController createVascFrontendUserSettingControllerImpl(VascEntry entry); + + +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/actions/AbstractVascGlobalActionLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/actions/AbstractVascGlobalActionLocal.java new file mode 100644 index 0000000..32d00b1 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/actions/AbstractVascGlobalActionLocal.java @@ -0,0 +1,50 @@ +/* + * 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.core.actions; + +import net.forwardfire.vasc.core.base.AbstractVascBaseIdRoleViewOrderMetaLocal; + + +/** + * AbstractVascGlobalActionLocal + * + * @author Willem Cazander + * @version 1.0 Mar 30, 2007 + */ +@SuppressWarnings("serial") +abstract public class AbstractVascGlobalActionLocal extends AbstractVascBaseIdRoleViewOrderMetaLocal implements GlobalVascActionLocal { + + + public AbstractVascGlobalActionLocal() { + setId(getActionId()); + } + + abstract protected String getActionId(); + + @Override + public GlobalVascActionLocal clone() throws CloneNotSupportedException { + Object clone = cloneCreate(); + cloneFields(clone); + return (GlobalVascActionLocal)clone; + } +} \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/actions/AbstractVascRowActionLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/actions/AbstractVascRowActionLocal.java new file mode 100644 index 0000000..534d902 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/actions/AbstractVascRowActionLocal.java @@ -0,0 +1,50 @@ +/* + * 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.core.actions; + +import net.forwardfire.vasc.core.base.AbstractVascBaseIdRoleViewOrderMetaLocal; + + +/** + * AbstractVascRowActionLocal + * + * @author Willem Cazander + * @version 1.0 Mar 30, 2007 + */ +@SuppressWarnings("serial") +abstract public class AbstractVascRowActionLocal extends AbstractVascBaseIdRoleViewOrderMetaLocal implements RowVascActionLocal { + + + public AbstractVascRowActionLocal() { + setId(getActionId()); + } + + abstract protected String getActionId(); + + @Override + public RowVascActionLocal clone() throws CloneNotSupportedException { + Object clone = cloneCreate(); + cloneFields(clone); + return (RowVascActionLocal)clone; + } +} \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/actions/ColumnVascAction.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/actions/ColumnVascAction.java index 8a37140..abe9c3e 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/core/actions/ColumnVascAction.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/actions/ColumnVascAction.java @@ -26,6 +26,7 @@ import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntryField; /** + * ColumnVascAction * * @author Willem Cazander * @version 1.0 Mar 21, 2007 diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/actions/ColumnVascActionLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/actions/ColumnVascActionLocal.java new file mode 100644 index 0000000..ddc127a --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/actions/ColumnVascActionLocal.java @@ -0,0 +1,39 @@ +/* + * 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.core.actions; + +/** + * ColumnVascActionLocal + * + * @author Willem Cazander + * @version 1.0 Jun 4, 2012 + */ +public interface ColumnVascActionLocal extends ColumnVascAction,VascActionLocal { + + /** + * Force impl to have public clone methode + * @return + * @throws CloneNotSupportedException + */ + public ColumnVascActionLocal clone() throws CloneNotSupportedException; +} \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/actions/GlobalVascActionLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/actions/GlobalVascActionLocal.java new file mode 100644 index 0000000..e3bf76d --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/actions/GlobalVascActionLocal.java @@ -0,0 +1,39 @@ +/* + * 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.core.actions; + +/** + * GlobalVascActionLocal + * + * @author Willem Cazander + * @version 1.0 Jun 4, 2012 + */ +public interface GlobalVascActionLocal extends GlobalVascAction,VascActionLocal { + + /** + * Force impl to have public clone methode + * @return + * @throws CloneNotSupportedException + */ + public GlobalVascActionLocal clone() throws CloneNotSupportedException; +} \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/actions/RowVascAction.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/actions/RowVascAction.java index 6acf41a..2ffde7a 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/core/actions/RowVascAction.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/actions/RowVascAction.java @@ -34,4 +34,5 @@ public interface RowVascAction extends VascAction { public boolean isMultiRowAction(); public void doRowAction(VascEntry vascEntry,Object rowObject) throws Exception; + } \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/actions/RowVascActionLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/actions/RowVascActionLocal.java new file mode 100644 index 0000000..0b7a7da --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/actions/RowVascActionLocal.java @@ -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.core.actions; + + +/** + * RowVascActionLocal + * + * @author Willem Cazander + * @version 1.0 Jun 4, 2012 + */ +public interface RowVascActionLocal extends RowVascAction,VascActionLocal { + + /** + * Force impl to have public clone methode + * @return + * @throws CloneNotSupportedException + */ + public RowVascActionLocal clone() throws CloneNotSupportedException; +} \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/actions/VascAction.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/actions/VascAction.java index 1c9c729..03d9d99 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/core/actions/VascAction.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/actions/VascAction.java @@ -22,39 +22,13 @@ package net.forwardfire.vasc.core.actions; -import java.io.Serializable; +import net.forwardfire.vasc.core.base.VascBaseIdRoleViewOrderMeta; /** * * @author Willem Cazander * @version 1.0 Mar 21, 2007 */ -public interface VascAction extends Cloneable,Serializable { +public interface VascAction extends VascBaseIdRoleViewOrderMeta { - public String getId(); - - public void setId(String id); - - public String getName(); - - public void setName(String name); - - public String getDescription(); - - public void setDescription(String description); - - public String getImage(); - - public void setImage(String image); - - public String getHelpId(); - - public void setHelpId(String helpId); - - /** - * Force impl to have public clone methode - * @return - * @throws CloneNotSupportedException - */ - public VascAction clone() throws CloneNotSupportedException; } \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/actions/VascActionLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/actions/VascActionLocal.java new file mode 100644 index 0000000..e3158ac --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/actions/VascActionLocal.java @@ -0,0 +1,34 @@ +/* + * 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.core.actions; + +import net.forwardfire.vasc.core.base.VascBaseIdRoleViewOrderMetaLocal; + +/** + * + * @author Willem Cazander + * @version 1.0 Jun 3, 2012 + */ +public interface VascActionLocal extends VascAction,VascBaseIdRoleViewOrderMetaLocal { + +} \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/base/AbstractVascBaseClone.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/AbstractVascBaseClone.java new file mode 100644 index 0000000..aa980f9 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/AbstractVascBaseClone.java @@ -0,0 +1,25 @@ +package net.forwardfire.vasc.core.base; + +@SuppressWarnings("serial") +abstract public class AbstractVascBaseClone implements VascBaseClone { + + + /** + * @see net.forwardfire.vasc.core.base.VascBaseClone#cloneCreate() + */ + public Object cloneCreate() throws CloneNotSupportedException { + try { + return getClass().newInstance(); + } catch (InstantiationException e) { + throw new CloneNotSupportedException("Could not clone class: "+e.getMessage()); + } catch (IllegalAccessException e) { + throw new CloneNotSupportedException("Could not clone class: "+e.getMessage()); + } + } + + /** + * @see net.forwardfire.vasc.core.base.VascBaseClone#cloneFields(java.lang.Object) + */ + public void cloneFields(Object cloneObject) throws CloneNotSupportedException { + } +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/base/AbstractVascBaseIdLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/AbstractVascBaseIdLocal.java new file mode 100644 index 0000000..887fdb2 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/AbstractVascBaseIdLocal.java @@ -0,0 +1,30 @@ +package net.forwardfire.vasc.core.base; + +@SuppressWarnings("serial") +abstract public class AbstractVascBaseIdLocal extends AbstractVascBaseClone implements VascBaseIdLocal { + + private String id = null; + + /** + * @see net.forwardfire.vasc.core.base.VascBaseClone#cloneFields(java.lang.Object) + */ + public void cloneFields(Object cloneObject) throws CloneNotSupportedException { + super.cloneFields(cloneObject); + VascBaseIdLocal clone = (VascBaseIdLocal)cloneObject; + clone.setId(getId()); + } + + /** + * @return the id + */ + public String getId() { + return id; + } + + /** + * @param id the id to set + */ + public void setId(String id) { + this.id = id; + } +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/base/AbstractVascBaseIdRoleCrudLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/AbstractVascBaseIdRoleCrudLocal.java new file mode 100644 index 0000000..3ecde0d --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/AbstractVascBaseIdRoleCrudLocal.java @@ -0,0 +1,141 @@ +package net.forwardfire.vasc.core.base; + +@SuppressWarnings("serial") +abstract public class AbstractVascBaseIdRoleCrudLocal extends AbstractVascBaseIdRoleViewLocal implements VascBaseIdRoleCrudLocal { + + private Boolean list = null; + private Boolean create = null; + private Boolean edit = null; + private Boolean editReadOnly = null; + + private String rolesCreate = null; + private String rolesEdit = null; + private String rolesEditReadOnly = null; + private String rolesList = null; + + @Override + public void cloneFields(Object cloneObject) throws CloneNotSupportedException { + super.cloneFields(cloneObject); + VascBaseIdRoleCrudLocal clone = (VascBaseIdRoleCrudLocal)cloneObject; + clone.setList(getList()); + clone.setCreate(getCreate()); + clone.setEdit(getEdit()); + clone.setEditReadOnly(getEditReadOnly()); + clone.setRolesCreate(getRolesCreate()); + clone.setRolesEdit(getRolesEdit()); + clone.setEditReadOnly(getEditReadOnly()); + clone.setRolesList(getRolesList()); + } + + /** + * @return the create + */ + public Boolean getCreate() { + return create; + } + + /** + * @param create the create to set + */ + public void setCreate(Boolean create) { + this.create = create; + } + + /** + * @return the edit + */ + public Boolean getEdit() { + return edit; + } + + /** + * @param edit the edit to set + */ + public void setEdit(Boolean edit) { + this.edit = edit; + } + + /** + * @return the editReadOnly + */ + public Boolean getEditReadOnly() { + return editReadOnly; + } + + /** + * @param editReadOnly the editReadOnly to set + */ + public void setEditReadOnly(Boolean editReadOnly) { + this.editReadOnly = editReadOnly; + } + + /** + * @return the list + */ + public Boolean getList() { + return list; + } + + /** + * @param list the list to set + */ + public void setList(Boolean list) { + this.list = list; + } + + /** + * @return the rolesCreate + */ + public String getRolesCreate() { + return rolesCreate; + } + + /** + * @param rolesCreate the rolesCreate to set + */ + public void setRolesCreate(String rolesCreate) { + this.rolesCreate = rolesCreate; + } + + /** + * @return the rolesEdit + */ + public String getRolesEdit() { + return rolesEdit; + } + + /** + * @param rolesEdit the rolesEdit to set + */ + public void setRolesEdit(String rolesEdit) { + this.rolesEdit = rolesEdit; + } + + /** + * @return the rolesEditReadOnly + */ + public String getRolesEditReadOnly() { + return rolesEditReadOnly; + } + + /** + * @param rolesEditReadOnly the rolesEditReadOnly to set + */ + public void setRolesEditReadOnly(String rolesEditReadOnly) { + this.rolesEditReadOnly = rolesEditReadOnly; + } + + /** + * @return the rolesList + */ + public String getRolesList() { + return rolesList; + } + + /** + * @param rolesList the rolesList to set + */ + public void setRolesList(String rolesList) { + this.rolesList = rolesList; + } +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/base/AbstractVascBaseIdRoleCrudOrderLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/AbstractVascBaseIdRoleCrudOrderLocal.java new file mode 100644 index 0000000..892e7d5 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/AbstractVascBaseIdRoleCrudOrderLocal.java @@ -0,0 +1,76 @@ +package net.forwardfire.vasc.core.base; + +@SuppressWarnings("serial") +abstract public class AbstractVascBaseIdRoleCrudOrderLocal extends AbstractVascBaseIdRoleCrudLocal implements VascBaseIdRoleCrudOrderLocal { + + private Integer order = null; + private Integer orderCreate = null; + private Integer orderEdit = null; + private Integer orderList = null; + + @Override + public void cloneFields(Object cloneObject) throws CloneNotSupportedException { + super.cloneFields(cloneObject); + VascBaseIdRoleCrudOrderLocal clone = (VascBaseIdRoleCrudOrderLocal)cloneObject; + clone.setOrder(getOrder()); + clone.setOrderCreate(getOrderCreate()); + clone.setOrderEdit(getOrderEdit()); + clone.setOrderList(getOrderList()); + } + + /** + * @return the order + */ + public Integer getOrder() { + return order; + } + + /** + * @param order the order to set + */ + public void setOrder(Integer order) { + this.order=order; + } + + /** + * @return the orderCreate + */ + public Integer getOrderCreate() { + return orderCreate; + } + + /** + * @param orderCreate the orderCreate to set + */ + public void setOrderCreate(Integer orderCreate) { + this.orderCreate = orderCreate; + } + + /** + * @return the orderEdit + */ + public Integer getOrderEdit() { + return orderEdit; + } + + /** + * @param orderEdit the orderEdit to set + */ + public void setOrderEdit(Integer orderEdit) { + this.orderEdit = orderEdit; + } + + /** + * @return the orderList + */ + public Integer getOrderList() { + return orderList; + } + + /** + * @param orderList the orderList to set + */ + public void setOrderList(Integer orderList) { + this.orderList = orderList; + } +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/base/AbstractVascBaseIdRoleCrudOrderMetaLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/AbstractVascBaseIdRoleCrudOrderMetaLocal.java new file mode 100644 index 0000000..1aa2b1d --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/AbstractVascBaseIdRoleCrudOrderMetaLocal.java @@ -0,0 +1,76 @@ +package net.forwardfire.vasc.core.base; + +@SuppressWarnings("serial") +abstract public class AbstractVascBaseIdRoleCrudOrderMetaLocal extends AbstractVascBaseIdRoleCrudOrderLocal implements VascBaseIdRoleCrudOrderMetaLocal { + + private String name = null; + private String description = null; + private String helpId = null; + private String image = null; + + @Override + public void cloneFields(Object cloneObject) throws CloneNotSupportedException { + super.cloneFields(cloneObject); + VascBaseIdRoleCrudOrderMetaLocal clone = (VascBaseIdRoleCrudOrderMetaLocal)cloneObject; + clone.setName(getName()); + clone.setDescription(getDescription()); + clone.setHelpId(getHelpId()); + clone.setImage(getImage()); + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * @param description the description to set + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * @return the helpId + */ + public String getHelpId() { + return helpId; + } + + /** + * @param helpId the helpId to set + */ + public void setHelpId(String helpId) { + this.helpId = helpId; + } + + /** + * @return the image + */ + public String getImage() { + return image; + } + + /** + * @param image the image to set + */ + public void setImage(String image) { + this.image = image; + } +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/base/AbstractVascBaseIdRoleViewLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/AbstractVascBaseIdRoleViewLocal.java new file mode 100644 index 0000000..d8d536e --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/AbstractVascBaseIdRoleViewLocal.java @@ -0,0 +1,44 @@ +package net.forwardfire.vasc.core.base; + +@SuppressWarnings("serial") +abstract public class AbstractVascBaseIdRoleViewLocal extends AbstractVascBaseIdLocal implements VascBaseIdRoleViewLocal { + + private Boolean view = null; + private String rolesView = null; + + @Override + public void cloneFields(Object cloneObject) throws CloneNotSupportedException { + super.cloneFields(cloneObject); + VascBaseIdRoleViewLocal clone = (VascBaseIdRoleViewLocal)cloneObject; + clone.setView(getView()); + clone.setRolesView(getRolesView()); + } + + /** + * @see net.forwardfire.vasc.core.base.VascBaseIdRoleView#getView() + */ + public Boolean getView() { + return view; + } + + /** + * @see net.forwardfire.vasc.core.base.VascBaseIdRoleViewLocal#setView(java.lang.Boolean) + */ + public void setView(Boolean view) { + this.view=view; + } + + /** + * @see net.forwardfire.vasc.core.base.VascBaseIdRoleView#getRolesView() + */ + public String getRolesView() { + return rolesView; + } + + /** + * @see net.forwardfire.vasc.core.base.VascBaseIdRoleViewLocal#setRolesView(java.lang.String) + */ + public void setRolesView(String rolesView) { + this.rolesView=rolesView; + } +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/base/AbstractVascBaseIdRoleViewOrderLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/AbstractVascBaseIdRoleViewOrderLocal.java new file mode 100644 index 0000000..ca5c0a3 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/AbstractVascBaseIdRoleViewOrderLocal.java @@ -0,0 +1,28 @@ +package net.forwardfire.vasc.core.base; + +@SuppressWarnings("serial") +abstract public class AbstractVascBaseIdRoleViewOrderLocal extends AbstractVascBaseIdRoleViewLocal implements VascBaseIdRoleViewOrderLocal { + + private Integer order = null; + + @Override + public void cloneFields(Object cloneObject) throws CloneNotSupportedException { + super.cloneFields(cloneObject); + VascBaseIdRoleViewOrderLocal clone = (VascBaseIdRoleViewOrderLocal)cloneObject; + clone.setOrder(getOrder()); + } + + /** + * @return the order + */ + public Integer getOrder() { + return order; + } + + /** + * @param order the order to set + */ + public void setOrder(Integer order) { + this.order=order; + } +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/base/AbstractVascBaseIdRoleViewOrderMetaLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/AbstractVascBaseIdRoleViewOrderMetaLocal.java new file mode 100644 index 0000000..7c6fa40 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/AbstractVascBaseIdRoleViewOrderMetaLocal.java @@ -0,0 +1,76 @@ +package net.forwardfire.vasc.core.base; + +@SuppressWarnings("serial") +abstract public class AbstractVascBaseIdRoleViewOrderMetaLocal extends AbstractVascBaseIdRoleViewOrderLocal implements VascBaseIdRoleViewOrderMetaLocal { + + private String name = null; + private String description = null; + private String helpId = null; + private String image = null; + + @Override + public void cloneFields(Object cloneObject) throws CloneNotSupportedException { + super.cloneFields(cloneObject); + VascBaseIdRoleViewOrderMetaLocal clone = (VascBaseIdRoleViewOrderMetaLocal)cloneObject; + clone.setName(getName()); + clone.setDescription(getDescription()); + clone.setHelpId(getHelpId()); + clone.setImage(getImage()); + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * @param description the description to set + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * @return the helpId + */ + public String getHelpId() { + return helpId; + } + + /** + * @param helpId the helpId to set + */ + public void setHelpId(String helpId) { + this.helpId = helpId; + } + + /** + * @return the image + */ + public String getImage() { + return image; + } + + /** + * @param image the image to set + */ + public void setImage(String image) { + this.image = image; + } +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseClone.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseClone.java new file mode 100644 index 0000000..f473969 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseClone.java @@ -0,0 +1,11 @@ +package net.forwardfire.vasc.core.base; + +import java.io.Serializable; + +public interface VascBaseClone extends Cloneable,Serializable { + + /* moved to abstract for private + public Object cloneCreate() throws CloneNotSupportedException; + public void cloneFields(Object cloneObject) throws CloneNotSupportedException; + */ +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseId.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseId.java new file mode 100644 index 0000000..ec7f494 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseId.java @@ -0,0 +1,10 @@ +package net.forwardfire.vasc.core.base; + + +public interface VascBaseId extends VascBaseClone { + + /** + * @return the id + */ + public String getId(); +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdLocal.java new file mode 100644 index 0000000..35c3537 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdLocal.java @@ -0,0 +1,10 @@ +package net.forwardfire.vasc.core.base; + +public interface VascBaseIdLocal extends VascBaseId { + + /** + * @param id the id to set + */ + public void setId(String id); + +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdMetaData.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdMetaData.java new file mode 100644 index 0000000..7f795af --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdMetaData.java @@ -0,0 +1,25 @@ +package net.forwardfire.vasc.core.base; + +public interface VascBaseIdMetaData extends VascBaseId { + + /** + * @return the name + */ + public String getName(); + + /** + * @return the description + */ + public String getDescription(); + + /** + * @return the helpId + */ + public String getHelpId(); + + /** + * @return the image + */ + public String getImage(); + +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdMetaDataLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdMetaDataLocal.java new file mode 100644 index 0000000..d525ed9 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdMetaDataLocal.java @@ -0,0 +1,24 @@ +package net.forwardfire.vasc.core.base; + +public interface VascBaseIdMetaDataLocal extends VascBaseIdMetaData,VascBaseIdLocal { + + /** + * @param name the name to set + */ + public void setName(String name); + + /** + * @param description the description to set + */ + public void setDescription(String description); + + /** + * @param helpId the helpId to set + */ + public void setHelpId(String helpId); + + /** + * @param image the image to set + */ + public void setImage(String image); +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdRoleCrud.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdRoleCrud.java new file mode 100644 index 0000000..7ed33f8 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdRoleCrud.java @@ -0,0 +1,44 @@ +package net.forwardfire.vasc.core.base; + +public interface VascBaseIdRoleCrud extends VascBaseIdRoleView { + + /** + * @return the create + */ + public Boolean getCreate(); + + /** + * @return the edit + */ + public Boolean getEdit(); + + /** + * @return the editReadOnly + */ + public Boolean getEditReadOnly(); + + /** + * @return the list + */ + public Boolean getList(); + + /** + * @return the rolesCreate + */ + public String getRolesCreate(); + + /** + * @return the rolesEdit + */ + public String getRolesEdit(); + + /** + * @return the rolesEditReadOnly + */ + public String getRolesEditReadOnly(); + + /** + * @return the rolesList + */ + public String getRolesList(); +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdRoleCrudLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdRoleCrudLocal.java new file mode 100644 index 0000000..75bb0f3 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdRoleCrudLocal.java @@ -0,0 +1,44 @@ +package net.forwardfire.vasc.core.base; + +public interface VascBaseIdRoleCrudLocal extends VascBaseIdRoleCrud,VascBaseIdRoleViewLocal,VascBaseIdLocal { + + /** + * @param create the create to set + */ + public void setCreate(Boolean create); + + /** + * @param edit the edit to set + */ + public void setEdit(Boolean edit); + + /** + * @param editReadOnly the editReadOnly to set + */ + public void setEditReadOnly(Boolean editReadOnly); + + /** + * @param list the list to set + */ + public void setList(Boolean list); + + /** + * @param rolesCreate the rolesCreate to set + */ + public void setRolesCreate(String rolesCreate); + + /** + * @param rolesEdit the rolesEdit to set + */ + public void setRolesEdit(String rolesEdit); + + /** + * @param rolesEditReadOnly the rolesEditReadOnly to set + */ + public void setRolesEditReadOnly(String rolesEditReadOnly); + + /** + * @param rolesList the rolesList to set + */ + public void setRolesList(String rolesList); +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdRoleCrudOrder.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdRoleCrudOrder.java new file mode 100644 index 0000000..22e3965 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdRoleCrudOrder.java @@ -0,0 +1,19 @@ +package net.forwardfire.vasc.core.base; + +public interface VascBaseIdRoleCrudOrder extends VascBaseIdRoleCrudLocal { + + /** + * @return the orderCreate + */ + public Integer getOrderCreate(); + + /** + * @return the orderEdit + */ + public Integer getOrderEdit(); + + /** + * @return the orderCreate + */ + public Integer getOrderList(); +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdRoleCrudOrderLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdRoleCrudOrderLocal.java new file mode 100644 index 0000000..c8e4895 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdRoleCrudOrderLocal.java @@ -0,0 +1,19 @@ +package net.forwardfire.vasc.core.base; + +public interface VascBaseIdRoleCrudOrderLocal extends VascBaseIdRoleCrudOrder,VascBaseIdRoleViewOrderLocal { + + /** + * @param orderCreate the orderCreate to set + */ + public void setOrderCreate(Integer orderCreate); + + /** + * @param orderEdit the orderEdit to set + */ + public void setOrderEdit(Integer orderEdit); + + /** + * @param orderList the orderList to set + */ + public void setOrderList(Integer orderList); +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdRoleCrudOrderMeta.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdRoleCrudOrderMeta.java new file mode 100644 index 0000000..388b21a --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdRoleCrudOrderMeta.java @@ -0,0 +1,5 @@ +package net.forwardfire.vasc.core.base; + +public interface VascBaseIdRoleCrudOrderMeta extends VascBaseIdRoleCrudOrder,VascBaseIdMetaData { + +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdRoleCrudOrderMetaLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdRoleCrudOrderMetaLocal.java new file mode 100644 index 0000000..4ab9dc3 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdRoleCrudOrderMetaLocal.java @@ -0,0 +1,5 @@ +package net.forwardfire.vasc.core.base; + +public interface VascBaseIdRoleCrudOrderMetaLocal extends VascBaseIdRoleCrudOrderMeta,VascBaseIdRoleCrudOrderLocal,VascBaseIdMetaDataLocal { + +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdRoleView.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdRoleView.java new file mode 100644 index 0000000..159e2dc --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdRoleView.java @@ -0,0 +1,14 @@ +package net.forwardfire.vasc.core.base; + +public interface VascBaseIdRoleView extends VascBaseId { + + /** + * @return the view + */ + public Boolean getView(); + + /** + * @return the rolesView + */ + public String getRolesView(); +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdRoleViewLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdRoleViewLocal.java new file mode 100644 index 0000000..138dba8 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdRoleViewLocal.java @@ -0,0 +1,14 @@ +package net.forwardfire.vasc.core.base; + +public interface VascBaseIdRoleViewLocal extends VascBaseIdLocal,VascBaseIdRoleView { + + /** + * @param view the view to set + */ + public void setView(Boolean view); + + /** + * @param rolesView the rolesView to set + */ + public void setRolesView(String rolesView); +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdRoleViewOrder.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdRoleViewOrder.java new file mode 100644 index 0000000..80c4a8c --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdRoleViewOrder.java @@ -0,0 +1,9 @@ +package net.forwardfire.vasc.core.base; + +public interface VascBaseIdRoleViewOrder extends VascBaseIdRoleView { + + /** + * @return the order + */ + public Integer getOrder(); +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdRoleViewOrderLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdRoleViewOrderLocal.java new file mode 100644 index 0000000..e156963 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdRoleViewOrderLocal.java @@ -0,0 +1,9 @@ +package net.forwardfire.vasc.core.base; + +public interface VascBaseIdRoleViewOrderLocal extends VascBaseIdRoleViewOrder,VascBaseIdRoleViewLocal { + + /** + * @param order the order to set + */ + public void setOrder(Integer order); +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdRoleViewOrderMeta.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdRoleViewOrderMeta.java new file mode 100644 index 0000000..90e4052 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdRoleViewOrderMeta.java @@ -0,0 +1,5 @@ +package net.forwardfire.vasc.core.base; + +public interface VascBaseIdRoleViewOrderMeta extends VascBaseIdRoleViewOrder,VascBaseIdMetaData { + +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdRoleViewOrderMetaLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdRoleViewOrderMetaLocal.java new file mode 100644 index 0000000..1874d4d --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/base/VascBaseIdRoleViewOrderMetaLocal.java @@ -0,0 +1,5 @@ +package net.forwardfire.vasc.core.base; + +public interface VascBaseIdRoleViewOrderMetaLocal extends VascBaseIdRoleViewOrderMeta,VascBaseIdRoleViewOrderLocal,VascBaseIdMetaDataLocal { + +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/ui/VascOptionValueModelListener.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/ui/VascOptionValueModelListener.java index d762a08..b0dd9ef 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/core/ui/VascOptionValueModelListener.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/ui/VascOptionValueModelListener.java @@ -23,6 +23,7 @@ package net.forwardfire.vasc.core.ui; import net.forwardfire.vasc.core.VascEntryField; +import net.forwardfire.vasc.core.VascEntryListOption; import net.forwardfire.vasc.core.VascException; /** @@ -33,32 +34,36 @@ import net.forwardfire.vasc.core.VascException; */ public class VascOptionValueModelListener implements VascValueModelListener { - private VascEntryField vascEntryField = null; + private VascEntryListOption vascEntryListOption = null; public VascOptionValueModelListener() { } - public VascOptionValueModelListener(VascEntryField vascEntryField) { - setVascEntryField(vascEntryField); + public VascOptionValueModelListener(VascEntryListOption vascEntryListOption) { + setVascEntryListOption(vascEntryListOption); } public void valueUpdate(VascValueModel model) throws VascException { - String key = vascEntryField.getBackendName(); + String key = vascEntryListOption.getBackendName(); Object value = model.getValue(); - vascEntryField.getVascEntry().setEntryParameter(key, value); + if (value==null && vascEntryListOption.getOptional()!=null && vascEntryListOption.getOptional()) { + vascEntryListOption.getVascEntry().getVascFrontendController().getVascEntryState().getVascBackendState().removeDataParameter(key); // null is a value except if optional + return; + } + vascEntryListOption.getVascEntry().getVascFrontendController().getVascEntryState().getVascBackendState().setDataParameter(key, value); // TODO: check this } /** - * @return the vascEntryField + * @return the vascEntryListOption */ - public VascEntryField getVascEntryField() { - return vascEntryField; + public VascEntryListOption getVascEntryListOption() { + return vascEntryListOption; } /** - * @param vascEntryField the vascEntryField to set + * @param vascEntryListOption the vascEntryListOption to set */ - public void setVascEntryField(VascEntryField vascEntryField) { - this.vascEntryField = vascEntryField; + public void setVascEntryListOption(VascEntryListOption vascEntryListOption) { + this.vascEntryListOption = vascEntryListOption; } } \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/frontend/AbstractVascFrontend.java b/vasc-core/src/main/java/net/forwardfire/vasc/frontend/AbstractVascFrontend.java index cd68929..a073551 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/frontend/AbstractVascFrontend.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/frontend/AbstractVascFrontend.java @@ -38,11 +38,11 @@ abstract public class AbstractVascFrontend implements VascFrontend { protected VascEntry entry = null; public String i18n(String key,Object...params) { - return entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(key,params); + return entry.getVascFrontendController().getVascEntryResourceResolver().getTextValue(key,params); } public Object i18nImage(String key) { - return entry.getVascFrontendData().getVascEntryResourceImageResolver().getImageValue(entry,key); + return entry.getVascFrontendController().getVascEntryResourceImageResolver().getImageValue(entry,key); } @@ -56,12 +56,12 @@ abstract public class AbstractVascFrontend implements VascFrontend { * @see net.forwardfire.vasc.frontend.VascFrontend#initEntry(net.forwardfire.vasc.core.VascEntry) */ public void initEntry(VascEntry entry) throws Exception { - if (entry.getVascFrontendData().getVascFrontend()==null) { - Logger.getLogger(AbstractVascFrontend.class.getName()).fine("Bind frontend: "+this+" to: "+entry.getVascFrontendData()+" entry: "+entry.getId()); - entry.getVascFrontendData().setVascFrontend(this); + if (entry.getVascFrontendController().getVascFrontend()==null) { + Logger.getLogger(AbstractVascFrontend.class.getName()).fine("Bind frontend: "+this+" to: "+entry.getVascFrontendController()+" entry: "+entry.getId()); + entry.getVascFrontendController().setVascFrontend(this); } else { - if (entry.getVascFrontendData().getVascFrontend()!=this) { - throw new IllegalArgumentException("VascEntry '"+entry.getId()+"' data: "+entry.getVascFrontendData()+" frontend: "+this+" has already a differtent VascFrontend attected"); + if (entry.getVascFrontendController().getVascFrontend()!=this) { + throw new IllegalArgumentException("VascEntry '"+entry.getId()+"' data: "+entry.getVascFrontendController()+" frontend: "+this+" has already a differtent VascFrontend attected"); } } this.entry=entry; diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/frontend/VascFrontendActions.java b/vasc-core/src/main/java/net/forwardfire/vasc/frontend/VascFrontendActions.java index 5f20aa2..0f42b01 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/frontend/VascFrontendActions.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/frontend/VascFrontendActions.java @@ -30,7 +30,7 @@ import net.forwardfire.vasc.core.VascEntryField; * @author Willem Cazander * @version 1.0 Jan 22, 2012 */ -public interface VascFrontendActions { +public interface VascFrontendActions extends VascFrontendEntry { public void refreshData(); diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/frontend/VascFrontendController.java b/vasc-core/src/main/java/net/forwardfire/vasc/frontend/VascFrontendController.java new file mode 100644 index 0000000..ad2242e --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/frontend/VascFrontendController.java @@ -0,0 +1,135 @@ +/* + * 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.core.VascController; +import net.forwardfire.vasc.core.VascEntry; +import net.forwardfire.vasc.core.VascEntryField; +import net.forwardfire.vasc.core.VascEntryLocal; +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.VascEntryFrontendEventListener; +import net.forwardfire.vasc.core.entry.VascEntryResourceImageResolver; +import net.forwardfire.vasc.core.entry.VascEntryResourceResolver; +import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener.VascFrontendEventType; +import net.forwardfire.vasc.core.ui.VascUIComponent; + + + + +/** + * VascFrontendController holds all dynamic frontend code in one place. + * + * + * @author Willem Cazander + * @version 1.0 Mar 21, 2007 + */ +public interface VascFrontendController { + + /** + * @return the vascFrontend + */ + public VascFrontend getVascFrontend(); + + /** + * @param vascFrontend the vascFrontend to set + */ + public void setVascFrontend(VascFrontend vascFrontend); + + /** + * Gets the VascFrontendActions to make frontend actions simple. + */ + public VascFrontendActions getVascFrontendActions(); + + /** + * @return the vascFrontendPager + */ + public VascFrontendPager getVascFrontendPager(); + + /** + * @return the VascFrontendHelper + */ + public VascFrontendHelper getVascFrontendHelper(); + + /** + * @param vascFrontendHelper The VascFrontendHelper to set. + */ + public void setVascFrontendHelper(VascFrontendHelper vascFrontendHelper); + + /** + * @return the vascEntryResourceResolver + */ + public VascEntryResourceResolver getVascEntryResourceResolver(); + + + + + public void putVascUIComponent(String rendererId,String uiComponentClass); + + public VascUIComponent getVascUIComponent(String rendererId) throws VascException; + public String getVascUIComponentClass(String rendererId); + + public void setVascController(VascController vascController); + + public VascController getVascController(); + + public void addFieldVascUIComponents(VascEntryField field,VascUIComponent uiComponent,Object editor); + public VascUIComponent getFieldVascUIComponent(VascEntryField field); + public Object getFieldRealRenderer(VascEntryField field); + public void clearFieldRenderObjects(); + + /** + * @return the vascEntryResourceImageResolver + */ + public VascEntryResourceImageResolver getVascEntryResourceImageResolver(); + + + public List getVascValidatorServices(); + + public VascEntryState getVascEntryState(); + + + public void initFrontendListeners(VascEntryLocal entry,String frontendType) throws InstantiationException, IllegalAccessException; + public void addVascEntryFrontendEventListener(VascEntryFrontendEventListener listener); + public List getVascEntryFrontendEventListener(VascEntryFrontendEventListener.VascFrontendEventType type); + public void fireVascFrontendEvent(VascEntry entry,VascFrontendEventType type,Object data); + + + /** + * @return the vascFrontendDataSelector + */ + public VascFrontendDataSelector getVascFrontendDataSelector(); + + /** + * @return the vascFrontendUserController + */ + public VascFrontendUserController getVascFrontendUserController(); + + /** + * @return the vascFrontendUserSettingController + */ + public VascFrontendUserSettingController getVascFrontendUserSettingController(); +} \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/frontend/VascFrontendControllerLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/frontend/VascFrontendControllerLocal.java new file mode 100644 index 0000000..e1dd47c --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/frontend/VascFrontendControllerLocal.java @@ -0,0 +1,76 @@ +/* + * 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.VascEntryState; +import net.forwardfire.vasc.core.entry.VascEntryFieldValidatorService; +import net.forwardfire.vasc.core.entry.VascEntryResourceImageResolver; +import net.forwardfire.vasc.core.entry.VascEntryResourceResolver; + +/** + * VascFrontendControllerLocal removed all sets from VascFrontendController interface. + * + * @author Willem Cazander + * @version 1.0 Jun 2, 2012 + */ +public interface VascFrontendControllerLocal extends VascFrontendController { + + /** + * @param vascFrontendActions the vascFrontendActions to set + */ + public void setVascFrontendActions(VascFrontendActions vascFrontendActions); + + /** + * @param vascFrontendPager the vascFrontendPager to set + */ + public void setVascFrontendPager(VascFrontendPager vascFrontendPager); + + /** + * @param vascEntryResourceResolver the vascEntryResourceResolver to set + */ + public void setVascEntryResourceResolver(VascEntryResourceResolver vascEntryResourceResolver); + + /** + * @param vascEntryResourceImageResolver the vascEntryResourceImageResolver to set + */ + public void setVascEntryResourceImageResolver(VascEntryResourceImageResolver vascEntryResourceImageResolver); + + public void addVascValidatorService(VascEntryFieldValidatorService validatorService); + + public void setVascEntryState(VascEntryState state); + + /** + * @param vascFrontendDataSelector the vascFrontendDataSelector to set + */ + public void setVascFrontendDataSelector(VascFrontendDataSelector vascFrontendDataSelector); + + /** + * @param vascFrontendUserController the vascFrontendUserController to set + */ + public void setVascFrontendUserController(VascFrontendUserController vascFrontendUserController); + + /** + * @param vascFrontendUserSettingController the vascFrontendUserSettingController to set + */ + public void setVascFrontendUserSettingController(VascFrontendUserSettingController vascFrontendUserSettingController); +} \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/frontend/VascFrontendDataSelector.java b/vasc-core/src/main/java/net/forwardfire/vasc/frontend/VascFrontendDataSelector.java new file mode 100644 index 0000000..59d0910 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/frontend/VascFrontendDataSelector.java @@ -0,0 +1,53 @@ +/* + * 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.core.VascEntryField; +import net.forwardfire.vasc.core.actions.VascAction; + + +/** + * VascFrontendDataSelector orders and checks all vasc entry data to render. + * + * note all the get properties for different el parsers. + * + * @author Willem Cazander + * @version 1.0 Jun 1, 2012 + */ +public interface VascFrontendDataSelector extends VascFrontendEntry { + + public boolean isActionAllowed(VascAction action); + public boolean isFieldView(VascEntryField field); + public boolean isFieldCreate(VascEntryField field); + public boolean isFieldEdit(VascEntryField field); + public boolean isFieldEditReadOnly(VascEntryField field); + public boolean isFieldList(VascEntryField field); + + public List getFieldsList(); + + public List getFieldsCreate(); + + public List getFieldsEdit(); +} \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/frontend/VascFrontendEntry.java b/vasc-core/src/main/java/net/forwardfire/vasc/frontend/VascFrontendEntry.java new file mode 100644 index 0000000..14c84bb --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/frontend/VascFrontendEntry.java @@ -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.frontend; + +import net.forwardfire.vasc.core.VascEntry; + +/** + * VascFrontendEntry is base frontend interface to init on entry. + * + * + * @author Willem Cazander + * @version 1.0 Jun 2, 2012 + */ +public interface VascFrontendEntry { + + public void init(VascEntry entry); +} \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/frontend/VascFrontendHelper.java b/vasc-core/src/main/java/net/forwardfire/vasc/frontend/VascFrontendHelper.java index 87b79d1..eb5975d 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/frontend/VascFrontendHelper.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/frontend/VascFrontendHelper.java @@ -26,8 +26,8 @@ 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.VascEntryLink; +import net.forwardfire.vasc.core.VascEntryLinkType; import net.forwardfire.vasc.core.actions.GlobalVascAction; import net.forwardfire.vasc.core.actions.RowVascAction; @@ -39,6 +39,7 @@ import net.forwardfire.vasc.core.actions.RowVascAction; */ public interface VascFrontendHelper { + /* public boolean renderView(VascEntryField field); public boolean renderList(VascEntryField field); public boolean renderEdit(VascEntryField field); @@ -46,10 +47,11 @@ public interface VascFrontendHelper { public boolean renderCreate(VascEntryField field); public boolean renderGlobalVascAction(GlobalVascAction action); public boolean renderRowVascAction(RowVascAction action); + */ public Integer getTotalColumnsWidth(VascEntry entry); - public List getVascLinkEntryByType(VascEntry entry,VascLinkEntryType type); + public List getVascLinkEntryByType(VascEntry entry,VascEntryLinkType type); public List validateObjectField(VascEntryField field); diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/frontend/VascFrontendPager.java b/vasc-core/src/main/java/net/forwardfire/vasc/frontend/VascFrontendPager.java index a9261e3..b14abbd 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/frontend/VascFrontendPager.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/frontend/VascFrontendPager.java @@ -34,7 +34,7 @@ import net.forwardfire.vasc.backend.VascBackendPageNumber; * @author Willem Cazander * @version 1.0 Jan 22, 2012 */ -public interface VascFrontendPager { +public interface VascFrontendPager extends VascFrontendEntry { public long getPageStartCount(); public long getPageStopCount(); diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/frontend/VascFrontendUserController.java b/vasc-core/src/main/java/net/forwardfire/vasc/frontend/VascFrontendUserController.java new file mode 100644 index 0000000..12194c0 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/frontend/VascFrontendUserController.java @@ -0,0 +1,46 @@ +/* + * 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.Locale; + + +/** + * VascFrontendUserController is user intration interface for frontend. + * + * + * @author Willem Cazander + * @version 1.0 Jun 1, 2012 + */ +public interface VascFrontendUserController { + + public Locale getUserLocale(); + + public boolean isUser(); + + public Object getUserId(); + + public String getUserName(); + + public boolean hasUserRole(String role); +} \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/frontend/VascFrontendUserSettingController.java b/vasc-core/src/main/java/net/forwardfire/vasc/frontend/VascFrontendUserSettingController.java new file mode 100644 index 0000000..c5c82cd --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/frontend/VascFrontendUserSettingController.java @@ -0,0 +1,41 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.frontend; + +import java.util.List; + +import net.forwardfire.vasc.core.VascEntry; +import net.forwardfire.vasc.core.VascEntryField; + + +/** + * VascFrontendUserSettingController should load and save settings for user. + * + * + * @author Willem Cazander + * @version 1.0 Jun 1, 2012 + */ +public interface VascFrontendUserSettingController { + + +} \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascBackendState.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascBackendState.java index 9cc2d73..9964a74 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascBackendState.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascBackendState.java @@ -31,5 +31,6 @@ import net.forwardfire.vasc.backend.AbstractVascBackendState; * @version 1.0 May 26, 2009 */ public class DefaultVascBackendState extends AbstractVascBackendState { - private static final long serialVersionUID = 1L; + + private static final long serialVersionUID = 8828343641448595993L; } \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascController.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascController.java index 006d229..3e23344 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascController.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascController.java @@ -22,110 +22,15 @@ package net.forwardfire.vasc.impl; -import net.forwardfire.vasc.backend.VascBackendController; -import net.forwardfire.vasc.core.VascEntryConfigController; -import net.forwardfire.vasc.core.VascController; -import net.forwardfire.vasc.core.VascEntryController; -import net.forwardfire.vasc.core.VascEntryFieldTypeController; -import net.forwardfire.vasc.core.VascEventChannelController; -import net.forwardfire.vasc.core.VascUserRoleController; +import net.forwardfire.vasc.core.AbstractVascControllerLocal; /** - * + * DefaultVascController is default implemention to hold all core interfaces. * * @author Willem Cazander * @version 1.0 Sep 11, 2008 */ -public class DefaultVascController implements VascController { +public class DefaultVascController extends AbstractVascControllerLocal { - private VascEntryConfigController vascEntryConfigController = null; - private VascBackendController vascBackendController = null; - private VascEntryController vascEntryController = null; - private VascEntryFieldTypeController vascEntryFieldTypeController = null; - private VascEventChannelController vascEventChannelController = null; - private VascUserRoleController vascUserRoleController = null; - - /** - * @return the vascEntryConfigController - */ - public VascEntryConfigController getVascEntryConfigController() { - return vascEntryConfigController; - } - /** - * @param vascEntryConfigController the vascEntryConfigController to set - */ - public void setVascEntryConfigController(VascEntryConfigController vascEntryConfigController) { - this.vascEntryConfigController = vascEntryConfigController; - } - - /** - * @return the vascEventChannelController - */ - public VascEventChannelController getVascEventChannelController() { - return vascEventChannelController; - } - - /** - * @param vascEventChannelController the vascEventChannelController to set - */ - public void setVascEventChannelController(VascEventChannelController vascEventChannelController) { - this.vascEventChannelController = vascEventChannelController; - } - - /** - * @return the vascBackendController - */ - public VascBackendController getVascBackendController() { - return vascBackendController; - } - - /** - * @param vascBackendController the vascBackendController to set - */ - public void setVascBackendController(VascBackendController vascBackendController) { - this.vascBackendController = vascBackendController; - } - - /** - * @return the vascEntryController - */ - public VascEntryController getVascEntryController() { - return vascEntryController; - } - - /** - * @param vascEntryController the vascEntryController to set - */ - public void setVascEntryController(VascEntryController vascEntryController) { - this.vascEntryController = vascEntryController; - } - - /** - * @return the vascEntryFieldController - */ - public VascEntryFieldTypeController getVascEntryFieldTypeController() { - return vascEntryFieldTypeController; - } - - /** - * @param vascEntryFieldController the vascEntryFieldController to set - */ - public void setVascEntryFieldTypeController(VascEntryFieldTypeController vascEntryFieldTypeController) { - this.vascEntryFieldTypeController = vascEntryFieldTypeController; - } - - /** - * @return the vascUserRoleController - */ - public VascUserRoleController getVascUserRoleController() { - return vascUserRoleController; - } - - /** - * @param vascUserRoleController the vascUserRoleController to set - */ - public void setVascUserRoleController(VascUserRoleController vascUserRoleController) { - this.vascUserRoleController = vascUserRoleController; - } } \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascEntry.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascEntry.java index fe8e9ee..368c5ac 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascEntry.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascEntry.java @@ -22,865 +22,15 @@ package net.forwardfire.vasc.impl; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import net.forwardfire.vasc.backend.VascBackendFilter; -import net.forwardfire.vasc.core.VascEntry; -import net.forwardfire.vasc.core.VascEntryField; -import net.forwardfire.vasc.core.VascEntryFieldSet; -import net.forwardfire.vasc.core.VascLinkEntry; -import net.forwardfire.vasc.core.actions.ColumnVascAction; -import net.forwardfire.vasc.core.actions.GlobalVascAction; -import net.forwardfire.vasc.core.actions.RowVascAction; -import net.forwardfire.vasc.core.actions.VascAction; -import net.forwardfire.vasc.core.entry.VascEntryFieldEventChannel; -import net.forwardfire.vasc.frontend.VascFrontendData; - - +import net.forwardfire.vasc.core.AbstractVascEntryLocal; /** - * VascEntry + * DefaultVascEntry * * @author Willem Cazander * @version 1.0 Mar 21, 2007 */ -public class DefaultVascEntry implements VascEntry { - - private static final long serialVersionUID = 1L; - private String id = null; - private String name = null; - private String helpId = null; - private String image = null; - - private String listDescription = null; - private String listImage = null; - private String editDescription = null; - private String editImage = null; - private String deleteDescription = null; - private String deleteImage = null; - private String createDescription = null; - private String createImage = null; - - private String primaryKeyFieldId = null; - private String displayNameFieldId = null; - - private boolean vascDisplayOnly = false; - private boolean vascAdminList = true; - private boolean vascAdminEdit = true; - private boolean vascAdminCreate = true; - private boolean vascAdminDelete = true; - - private List vascFields = null; - - private List rowActions = null; - private List columnActions = null; - private List globalActions = null; - private List exportActions = null; - - private List vascEntryFieldSets = null; - private List vascLinkEntries = null; - private Map entryParameters = null; - private VascEntryFieldEventChannel vascEntryFieldEventChannel = null; - private Map> eventEntryFrontendEventListeners = null; - private List eventEntryBackendEventListeners = null; - private List listOptions = null; - private List backendFilters = null; - private Map> eventEntryFrontendActions = null; - - private String backendId = null; - private VascFrontendData vascFrontendData = null; - - /** - * Te constructor - */ - public DefaultVascEntry() { - vascFields = new ArrayList(20); - - rowActions = new ArrayList(10); - columnActions = new ArrayList(5); - globalActions = new ArrayList(5); - exportActions = new ArrayList(10); - - vascEntryFieldSets = new ArrayList(10); - vascLinkEntries = new ArrayList(10); - entryParameters = new HashMap(10); - - eventEntryFrontendActions = new HashMap>(10); - eventEntryFrontendEventListeners = new HashMap>(10); - eventEntryBackendEventListeners = new ArrayList(10); - listOptions = new ArrayList(5); - backendFilters = new ArrayList(3); - } - - /** - * @see java.lang.Object#clone() - */ - @Override - public VascEntry clone() throws CloneNotSupportedException { - - DefaultVascEntry result = new DefaultVascEntry(); - result.id=id; - result.name=name; - result.helpId=helpId; - result.image=image; - result.listDescription=listDescription; - result.listImage=listImage; - result.editDescription=editDescription; - result.editImage=editImage; - result.deleteDescription=deleteDescription; - result.deleteImage=deleteImage; - result.createDescription=createDescription; - result.createImage=createImage; - result.primaryKeyFieldId=primaryKeyFieldId; - result.displayNameFieldId=displayNameFieldId; - result.vascDisplayOnly=vascDisplayOnly; - result.vascAdminList=vascAdminList; - result.vascAdminCreate=vascAdminCreate; - result.vascAdminEdit=vascAdminEdit; - result.vascAdminDelete=vascAdminDelete; - result.backendId=backendId; - result.vascEntryFieldEventChannel=vascEntryFieldEventChannel; - result.eventEntryFrontendEventListeners.putAll(eventEntryFrontendEventListeners); - result.eventEntryBackendEventListeners.addAll(eventEntryBackendEventListeners); - result.eventEntryFrontendActions.putAll(eventEntryFrontendActions); - // skipping 'vascFrontendData' because it should always be null when cloning happens. - - for (VascEntryField f:vascFields) { - VascEntryField ff = f.clone(); - ff.setVascEntry(result); // mmm remove this ? - result.vascFields.add(ff); - } - for (VascAction a:rowActions) { - result.rowActions.add((RowVascAction)a.clone()); - } - for (VascAction a:columnActions) { - result.columnActions.add((ColumnVascAction)a.clone()); - } - for (VascAction a:globalActions) { - result.globalActions.add((GlobalVascAction)a.clone()); - } - for (VascAction a:exportActions) { - result.exportActions.add((GlobalVascAction)a.clone()); - } - for (VascEntryFieldSet s:vascEntryFieldSets) { - result.vascEntryFieldSets.add(s.clone()); - } - for (VascLinkEntry l:vascLinkEntries) { - result.vascLinkEntries.add(l.clone()); - } - for (VascEntryField listOption:listOptions) { - VascEntryField ff = listOption.clone(); - ff.setVascEntry(result); - result.listOptions.add(ff); - } - // for (VascBackendFilter f:backendFilters) { - // VascBackendFilter ff = f.clone(); - // result.backendFilters.add(ff); - // } - - - // no cloning of the values here ? - for (String key:entryParameters.keySet()) { - Object value = entryParameters.get(key); - result.setEntryParameter(key, value); - } - return result; - } +public class DefaultVascEntry extends AbstractVascEntryLocal { - - - - /** - * @return the id - */ - public String getId() { - return id; - } - - /** - * @param id the id to set - */ - public void setId(String id) { - this.id = id; - } - - /** - * @return the name - */ - public String getName() { - return name; - } - - /** - * @param name the name to set - */ - public void setName(String name) { - this.name = name; - } - - /** - * @return the helpId - */ - public String getHelpId() { - return helpId; - } - - /** - * @param helpId the helpId to set - */ - public void setHelpId(String helpId) { - this.helpId = helpId; - } - - /** - * @return the image - */ - public String getImage() { - return image; - } - - /** - * @param image the image to set - */ - public void setImage(String image) { - this.image = image; - } - - /** - * @return the listDescription - */ - public String getListDescription() { - return listDescription; - } - - /** - * @param listDescription the listDescription to set - */ - public void setListDescription(String listDescription) { - this.listDescription = listDescription; - } - - /** - * @return the listImage - */ - public String getListImage() { - return listImage; - } - - /** - * @param listImage the listImage to set - */ - public void setListImage(String listImage) { - this.listImage = listImage; - } - - /** - * @return the editDescription - */ - public String getEditDescription() { - return editDescription; - } - - /** - * @param editDescription the editDescription to set - */ - public void setEditDescription(String editDescription) { - this.editDescription = editDescription; - } - - /** - * @return the editImage - */ - public String getEditImage() { - return editImage; - } - - /** - * @param editImage the editImage to set - */ - public void setEditImage(String editImage) { - this.editImage = editImage; - } - - /** - * @return the deleteDescription - */ - public String getDeleteDescription() { - return deleteDescription; - } - - /** - * @param deleteDescription the deleteDescription to set - */ - public void setDeleteDescription(String deleteDescription) { - this.deleteDescription = deleteDescription; - } - - /** - * @return the deleteImage - */ - public String getDeleteImage() { - return deleteImage; - } - - /** - * @param deleteImage the deleteImage to set - */ - public void setDeleteImage(String deleteImage) { - this.deleteImage = deleteImage; - } - - /** - * @return the createDescription - */ - public String getCreateDescription() { - return createDescription; - } - - /** - * @param createDescription the createDescription to set - */ - public void setCreateDescription(String createDescription) { - this.createDescription = createDescription; - } - - /** - * @return the createImage - */ - public String getCreateImage() { - return createImage; - } - - /** - * @param createImage the createImage to set - */ - public void setCreateImage(String createImage) { - this.createImage = createImage; - } - - /** - * @return the primaryKeyFieldId - */ - public String getPrimaryKeyFieldId() { - return primaryKeyFieldId; - } - - /** - * @param primaryKeyFieldId the primaryKeyFieldId to set - */ - public void setPrimaryKeyFieldId(String primaryKeyFieldId) { - this.primaryKeyFieldId = primaryKeyFieldId; - } - - /** - * @return the displayNameFieldId - */ - public String getDisplayNameFieldId() { - return displayNameFieldId; - } - - /** - * @param displayNameFieldId the displayNameFieldId to set - */ - public void setDisplayNameFieldId(String displayNameFieldId) { - this.displayNameFieldId = displayNameFieldId; - } - - /** - * @return the vascAdminList - */ - public boolean isVascAdminList() { - return vascAdminList; - } - - /** - * @param vascAdminList the vascAdminList to set - */ - public void setVascAdminList(boolean vascAdminList) { - this.vascAdminList = vascAdminList; - } - - /** - * @return the vascAdminEdit - */ - public boolean isVascAdminEdit() { - return vascAdminEdit; - } - - /** - * @param vascAdminEdit the vascAdminEdit to set - */ - public void setVascAdminEdit(boolean vascAdminEdit) { - this.vascAdminEdit = vascAdminEdit; - } - - /** - * @return the vascAdminCreate - */ - public boolean isVascAdminCreate() { - return vascAdminCreate; - } - - /** - * @param vascAdminCreate the vascAdminCreate to set - */ - public void setVascAdminCreate(boolean vascAdminCreate) { - this.vascAdminCreate = vascAdminCreate; - } - - /** - * @return the vascAdminDelete - */ - public boolean isVascAdminDelete() { - return vascAdminDelete; - } - - /** - * @param vascAdminDelete the vascAdminDelete to set - */ - public void setVascAdminDelete(boolean vascAdminDelete) { - this.vascAdminDelete = vascAdminDelete; - } - - /** - * @return the vascFields - */ - public List getVascEntryFields() { - return vascFields; - } - - /** - * @param vascField the vascFields to add - */ - public void addVascEntryField(VascEntryField vascField) { - vascFields.add(vascField); - } - - /** - * @param vascField the vascFields to remove - */ - public void removeVascEntryField(VascEntryField vascField) { - vascFields.remove(vascField); - } - - /** - * @see net.forwardfire.vasc.core.VascEntry#getVascEntryFieldById(java.lang.String) - */ - public VascEntryField getVascEntryFieldById(String id) { - for (VascEntryField v:vascFields) { - if (v.getId().equals(id)) { - return v; - } - } - return null; - } - - /** - * @return the rowActions - */ - public List getRowActions() { - return rowActions; - } - - /** - * @return the RowVascAction - */ - public RowVascAction getRowActionById(String actionId) { - for (RowVascAction a:rowActions) { - if (a.getId().equals(actionId)) { - return a; - } - } - return null; - } - - /** - * @param rowAction the rowAction to add - */ - public void addRowAction(RowVascAction rowAction) { - rowActions.add(rowAction); - } - - /** - * @param rowAction the rowAction to remove - */ - public void removeRowAction(RowVascAction rowAction) { - rowActions.remove(rowAction); - } - - /** - * @return the columnActions - */ - public List getColumnActions() { - return columnActions; - } - - /** - * @return the ColumnVascAction - */ - public ColumnVascAction getColumnActionById(String actionId) { - for (ColumnVascAction a:columnActions) { - if (a.getId().equals(actionId)) { - return a; - } - } - return null; - } - - /** - * @param columnAction the columnActions to add - */ - public void addColumnAction(ColumnVascAction columnAction) { - columnActions.add(columnAction); - } - - /** - * @param columnAction the columnActions to remove - */ - public void removeColumnAction(ColumnVascAction columnAction) { - columnActions.remove(columnAction); - } - - /** - * @return the globalActions - */ - public List getGlobalActions() { - return globalActions; - } - - /** - * @return the GlobalVascAction - */ - public GlobalVascAction getGlobalActionById(String actionId) { - for (GlobalVascAction a:globalActions) { - if (a.getId().equals(actionId)) { - return a; - } - } - return null; - } - - /** - * @param globalAction the globalAction to add - */ - public void addGlobalAction(GlobalVascAction globalAction) { - globalActions.add(globalAction); - } - - /** - * @param globalAction the globalAction to remove - */ - public void removeGlobalAction(GlobalVascAction globalAction) { - globalActions.remove(globalAction); - } - - /** - * @return the exportActions - */ - public List getExportActions() { - return exportActions; - } - - /** - * @return the GlobalVascAction exportAction - */ - public GlobalVascAction getExportActionById(String actionId) { - for (GlobalVascAction a:exportActions) { - if (a.getId().equals(actionId)) { - return a; - } - } - return null; - } - - /** - * @param exportAction the exportAction to add - */ - public void addExportAction(GlobalVascAction exportAction) { - exportActions.add(exportAction); - } - - /** - * @param exportAction the exportAction to remove - */ - public void removeExportAction(GlobalVascAction exportAction) { - exportActions.remove(exportAction); - } - - /** - * @return the vascEntryFieldSets - */ - public List getVascEntryFieldSets() { - return vascEntryFieldSets; - } - - /** - * @return the VascEntryFieldSet - */ - public VascEntryFieldSet getVascEntryFieldSetById(String fieldSetId) { - for (VascEntryFieldSet a:vascEntryFieldSets) { - if (a.getId().equals(fieldSetId)) { - return a; - } - } - return null; - } - - /** - * @param vascEntryFieldSet the vascEntryFieldSet to add - */ - public void addVascEntryFieldSet(VascEntryFieldSet vascEntryFieldSet) { - vascEntryFieldSets.add(vascEntryFieldSet); - } - - /** - * @param vascEntryFieldSet the vascEntryFieldSet to add - */ - public void removeVascEntryFieldSet(VascEntryFieldSet vascEntryFieldSet) { - vascEntryFieldSets.remove(vascEntryFieldSet); - } - - /** - * @return the vascLinkEntries - */ - public List getVascLinkEntries() { - return vascLinkEntries; - } - - /** - * @return the VascLinkEntry - */ - public VascLinkEntry getVascLinkEntryById(String linkId) { - for (VascLinkEntry a:vascLinkEntries) { - if (a.getId().equals(linkId)) { - return a; - } - } - return null; - } - - /** - * @param vascLinkEntry the vascLinkEntry to set - */ - public void addVascLinkEntry(VascLinkEntry vascLinkEntry) { - vascLinkEntries.add(vascLinkEntry); - } - - /** - * @param vascLinkEntry the vascLinkEntry to remove - */ - public void removeVascLinkEntry(VascLinkEntry vascLinkEntry) { - vascLinkEntries.remove(vascLinkEntry); - } - - /** - * @see net.forwardfire.vasc.core.VascEntry#getEntryParameter(java.lang.String) - */ - public Object getEntryParameter(String key) { - return entryParameters.get(key); - } - - /** - * @see net.forwardfire.vasc.core.VascEntry#getEntryParameterKeys() - */ - public List getEntryParameterKeys() { - return new ArrayList(entryParameters.keySet()); - } - - /** - * @see net.forwardfire.vasc.core.VascEntry#setEntryParameter(java.lang.String, java.lang.Object) - */ - public void setEntryParameter(String key, Object value) { - entryParameters.put(key, value); - } - - /** - * @return the vascFrontendData - */ - public VascFrontendData getVascFrontendData() { - return vascFrontendData; - } - - /** - * @param vascFrontendData the vascFrontendData to set - */ - public void setVascFrontendData(VascFrontendData vascFrontendData) { - this.vascFrontendData = vascFrontendData; - } - - /** - * @return the backendId - */ - public String getBackendId() { - return backendId; - } - - /** - * @param backendId the backendId to set - */ - public void setBackendId(String backendId) { - this.backendId = backendId; - } - - /** - * @return the vascDisplayOnly - */ - public boolean isVascDisplayOnly() { - return vascDisplayOnly; - } - - /** - * @param vascDisplayOnly the vascDisplayOnly to set - */ - public void setVascDisplayOnly(boolean vascDisplayOnly) { - this.vascDisplayOnly = vascDisplayOnly; - } - - /** - * @return the vascEntryFieldEventChannel - */ - public VascEntryFieldEventChannel getVascEntryFieldEventChannel() { - return vascEntryFieldEventChannel; - } - - /** - * @param vascEntryFieldEventChannel the vascEntryFieldEventChannel to set - */ - public void setVascEntryFieldEventChannel(VascEntryFieldEventChannel vascEntryFieldEventChannel) { - this.vascEntryFieldEventChannel = vascEntryFieldEventChannel; - } - - /** - * Added an VascEntryBackendEventListener - * @param listener The class of the event listener. - */ - public void addVascEntryBackendEventListener(String listener) { - eventEntryBackendEventListeners.add(listener); - } - - /** - * Returns the list of VascEntryBackendEventListener - * @return - */ - public List getVascEntryBackendEventListeners() { - return eventEntryBackendEventListeners; - } - - /** - * Added an VascEntryFrontendEventListener - * @param listener The class of the event listener. - */ - public void addVascEntryFrontendEventListener(String listener,String frontendType) { - if (frontendType==null) { - frontendType = "__ALL__"; - } - if (frontendType.isEmpty() | "all".equalsIgnoreCase(frontendType)) { - frontendType = "__ALL__"; - } - List typeList = eventEntryFrontendEventListeners.get(frontendType); - if (typeList==null) { - typeList = new ArrayList(10); - eventEntryFrontendEventListeners.put(frontendType,typeList); - } - typeList.add(listener); - } - - /** - * Returns the list of VascEntryFrontendEventListener - * @return - */ - public List getVascEntryFrontendEventListenersByType(String frontendType) { - if (frontendType==null) { - frontendType = "__ALL__"; - } - if (frontendType.isEmpty() | "all".equalsIgnoreCase(frontendType)) { - frontendType = "__ALL__"; - } - List typeList = eventEntryFrontendEventListeners.get(frontendType); - if (typeList==null) { - typeList = new ArrayList(0); - } - if (frontendType.equals("__ALL__")==false) { - // also add all - List typeListAll = eventEntryFrontendEventListeners.get("__ALL__"); - if (typeListAll!=null) { - typeList.addAll(typeListAll); - } - } - return typeList; - } - - public void addVascEntryFrontendAction(String actionClass,String frontendType) { - if (frontendType==null) { - frontendType = "__ALL__"; - } - if (frontendType.isEmpty() | "all".equalsIgnoreCase(frontendType)) { - frontendType = "__ALL__"; - } - List typeList = eventEntryFrontendActions.get(frontendType); - if (typeList==null) { - typeList = new ArrayList(10); - eventEntryFrontendActions.put(frontendType,typeList); - } - typeList.add(actionClass); - } - - - public List getVascEntryFrontendActionsByType(String frontendType) { - if (frontendType==null) { - frontendType = "__ALL__"; - } - if (frontendType.isEmpty() | "all".equalsIgnoreCase(frontendType)) { - frontendType = "__ALL__"; - } - List typeList = eventEntryFrontendActions.get(frontendType); - if (typeList==null) { - typeList = new ArrayList(0); - } - if (frontendType.equals("__ALL__")==false) { - // also add all - List typeListAll = eventEntryFrontendActions.get("__ALL__"); - if (typeListAll!=null) { - typeList.addAll(typeListAll); - } - } - return typeList; - } - - - public void addListOption(VascEntryField listOption) { - if (listOption==null) { - throw new NullPointerException("can not add null listOption."); - } - listOptions.add(listOption); - } - - public List getListOptions() { - return listOptions; - } - - public VascEntryField getListOptionById(String listOptionId) { - for (VascEntryField vef:listOptions) { - if (vef.getId().equals(listOptionId)) { - return vef; - } - } - return null; - } - - public void removeListOption(VascEntryField listOption) { - listOptions.remove(listOption); - } - - - public void addVascBackendFilter(VascBackendFilter filter) { - backendFilters.add(filter); - } - - public List getVascBackendFilters() { - return backendFilters; - } -} \ No newline at end of file + private static final long serialVersionUID = -1065334591099689417L; +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascEntryConfigController.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascEntryConfigController.java index b9aed72..bd179ae 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascEntryConfigController.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascEntryConfigController.java @@ -30,17 +30,27 @@ import java.util.Map; import java.util.ResourceBundle; import net.forwardfire.vasc.backend.VascBackend; +import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.proxy.VascBackendProxy; import net.forwardfire.vasc.core.VascController; import net.forwardfire.vasc.core.VascEntry; -import net.forwardfire.vasc.core.VascEntryConfigController; +import net.forwardfire.vasc.core.VascEntryConfigControllerLocal; import net.forwardfire.vasc.core.VascEntryConfigFinalizer; import net.forwardfire.vasc.core.VascEntryField; +import net.forwardfire.vasc.core.VascEntryFieldLocal; +import net.forwardfire.vasc.core.VascEntryLocal; +import net.forwardfire.vasc.core.VascEntryState; import net.forwardfire.vasc.core.VascException; +import net.forwardfire.vasc.core.VascInterfaceKey; +import net.forwardfire.vasc.core.VascInterfaceKeyFrontend; +import net.forwardfire.vasc.core.VascInterfaceLoader; import net.forwardfire.vasc.core.entry.VascEntryExporter; import net.forwardfire.vasc.core.entry.VascEntryFieldValidatorService; import net.forwardfire.vasc.core.entry.VascEntryFieldValue; +import net.forwardfire.vasc.frontend.VascFrontendControllerLocal; +import net.forwardfire.vasc.frontend.VascFrontendEntry; import net.forwardfire.vasc.impl.entry.DefaultVascEntryResourceResolver; +import net.forwardfire.vasc.impl.frontend.DefaultVascFrontendHelper; /** * DefaultVascEntryConfigController runs all VascEntryConfigFinalizers on VascEntry. @@ -48,14 +58,16 @@ import net.forwardfire.vasc.impl.entry.DefaultVascEntryResourceResolver; * @author Willem Cazander * @version 1.0 May 9, 2012 */ -public class DefaultVascEntryConfigController implements VascEntryConfigController { +public class DefaultVascEntryConfigController implements VascEntryConfigControllerLocal { private List configFinalizers = null; private List backendProxies = null; private Map dataExporters = null; private List fieldValidators = null; - private int defaultPageSize = 100; - private int defaultPageSizeMax = 1000; + private Map> vascInterfaceImpls = null; + private Map> vascInterfaceImplFrontends = null; + private VascInterfaceLoader vascInterfaceLoader = null; + private VascBackendState masterVascBackendState = null; private String resourceBundle = null; public DefaultVascEntryConfigController() { @@ -63,15 +75,91 @@ public class DefaultVascEntryConfigController implements VascEntryConfigControll backendProxies = new ArrayList(10); dataExporters = new HashMap(10); fieldValidators = new ArrayList(5); + vascInterfaceImpls = new HashMap>(VascInterfaceKey.values().length); + vascInterfaceImplFrontends = new HashMap>(VascInterfaceKeyFrontend.values().length); + vascInterfaceLoader = new DefaultVascInterfaceLoader(this); + masterVascBackendState = new DefaultVascBackendState(); + masterVascBackendState.setPageSize(100); + masterVascBackendState.setPageSizeMax(1500); + } + + + /** + * @see net.forwardfire.vasc.core.VascEntryConfigController#getVascInterfaceLoader() + */ + public VascInterfaceLoader getVascInterfaceLoader() { + return vascInterfaceLoader; + } + + /** + * @see net.forwardfire.vasc.core.VascEntryConfigController#createVascInterfaceImplemention(net.forwardfire.vasc.core.VascInterfaceKey) + */ + public Object createVascInterfaceImplemention(VascInterfaceKey key) { + Class classImpl = vascInterfaceImpls.get(key); + if (classImpl==null) { + throw new IllegalStateException("Could not find impl class for key: "+key); + } + try { + Object objectImpl = classImpl.newInstance(); + return objectImpl; + } catch (Exception e) { + throw new RuntimeException("Could not instance of class: "+classImpl,e); + } } + /** + * @see net.forwardfire.vasc.core.VascEntryConfigControllerLocal#putVascInterfaceImplemention(net.forwardfire.vasc.core.VascInterfaceKey, java.lang.Class) + */ + public void putVascInterfaceImplemention(VascInterfaceKey key,Class interfaceImpl) { + if (key==null) { + throw new NullPointerException("Can't add null interface key."); + } + if (interfaceImpl==null) { + throw new NullPointerException("Can't add null interface class."); + } + vascInterfaceImpls.put(key,interfaceImpl); + } + + /** + * @see net.forwardfire.vasc.core.VascEntryConfigController#createVascInterfaceImplementionFrontend(net.forwardfire.vasc.core.VascInterfaceKeyFrontend, net.forwardfire.vasc.core.VascEntry) + */ + public Object createVascInterfaceImplementionFrontend(VascInterfaceKeyFrontend key, VascEntry entry) { + Class classImpl = vascInterfaceImplFrontends.get(key); + if (classImpl==null) { + throw new IllegalStateException("Could not find impl class for key: "+key); + } + try { + Object objectImpl = classImpl.newInstance(); + if (objectImpl instanceof VascFrontendEntry ) { + ((VascFrontendEntry)objectImpl).init(entry); + } + return objectImpl; + } catch (Exception e) { + throw new RuntimeException("Could not instance of class: "+classImpl,e); + } + } + + /** + * @see net.forwardfire.vasc.core.VascEntryConfigControllerLocal#putVascInterfaceImplementionFrontend(net.forwardfire.vasc.core.VascInterfaceKeyFrontend, java.lang.Class) + */ + public void putVascInterfaceImplementionFrontend(VascInterfaceKeyFrontend key, Class interfaceImpl) { + if (key==null) { + throw new NullPointerException("Can't add null interface key."); + } + if (interfaceImpl==null) { + throw new NullPointerException("Can't add null interface class."); + } + vascInterfaceImplFrontends.put(key,interfaceImpl); + } + + public VascEntry configVascEntry(VascController vascController,String entryId) throws VascException { - VascEntry vascEntry = vascController.getVascEntryController().getVascEntryById(entryId); + VascEntryLocal vascEntry = (VascEntryLocal)vascController.getVascEntryController().getVascEntryById(entryId); configVascEntry(vascController,vascEntry); return vascEntry; } - public void configVascEntry(VascController vascController,VascEntry vascEntry) throws VascException { + public void configVascEntry(VascController vascController,VascEntryLocal vascEntry) throws VascException { for (VascEntryConfigFinalizer finalizer:configFinalizers) { finalizer.configVascEntry(vascController,vascEntry); } @@ -82,6 +170,9 @@ public class DefaultVascEntryConfigController implements VascEntryConfigControll */ public VascBackend configVascBackendProxied(VascController vascController,VascEntry vascEntry) throws VascException { VascBackend realBackend = vascController.getVascBackendController().getVascBackendById(vascEntry.getBackendId()); + if (realBackend==null) { + throw new VascException("Could not find backend: "+vascEntry.getBackendId()); + } return configVascBackendProxied(vascController,vascEntry,realBackend); } @@ -106,52 +197,94 @@ public class DefaultVascEntryConfigController implements VascEntryConfigControll return backend; } - - /** * @throws VascException - * @see net.forwardfire.vasc.core.VascEntryConfigController#configVascFrontendData(net.forwardfire.vasc.core.VascController, net.forwardfire.vasc.core.VascEntry, java.util.Locale) + * @see net.forwardfire.vasc.core.VascEntryConfigController#configVascFrontendController(net.forwardfire.vasc.core.VascController, net.forwardfire.vasc.core.VascEntry, java.util.Locale) */ - public void configVascFrontendData(VascController vascController,VascEntry entry, Locale locale) throws VascException { + public void configVascFrontendController(VascController vascController,VascEntryLocal entry) throws VascException { - - DefaultVascFrontendData vascFrontendData = new DefaultVascFrontendData(); - DefaultVascEntryState state = new DefaultVascEntryState(); - DefaultVascBackendState backendState = new DefaultVascBackendState(); - - backendState.setPageSize(vascController.getVascEntryConfigController().getDefaultPageSize()); - backendState.setPageSizeMax(vascController.getVascEntryConfigController().getDefaultPageSizeMax()); + // get the interface loader and create some impl objects + VascInterfaceLoader loader = getVascInterfaceLoader(); + VascFrontendControllerLocal controller = loader.createVascFrontendControllerLocalImpl(); + VascBackendState backendState = loader.createVascBackendStateImpl(); + VascEntryState state = loader.createVascEntryStateImpl(); + // Add impl to tree state.setVascBackendState(backendState); - vascFrontendData.setVascEntryState(state); + controller.setVascEntryState(state); + controller.setVascController(vascController); + entry.setVascFrontendController(controller); // <------ This is the end result. + + // Add some generic frontend impl code. + controller.setVascFrontendPager( loader.createVascFrontendPagerImpl(entry)); + controller.setVascFrontendActions( loader.createVascFrontendActionsImpl(entry)); + controller.setVascFrontendDataSelector( loader.createVascFrontendDataSelectorImpl(entry)); + controller.setVascFrontendUserController( loader.createVascFrontendUserControllerImpl(entry)); + controller.setVascFrontendUserSettingController( loader.createVascFrontendUserSettingControllerImpl(entry)); + + // Config backend state from master template + VascBackendState master = getMasterVascBackendState(); + for (String key:master.getDataParameterKeys()) { + backendState.setDataParameter(key, master.getDataParameter(key)); + } + backendState.setPageSize(master.getPageSize()); + backendState.setPageSizeMax(master.getPageSizeMax()); - // init resource resultsers - vascFrontendData.setVascEntryResourceResolver(new DefaultVascEntryResourceResolver(ResourceBundle.getBundle(vascController.getVascEntryConfigController().getResourceBundle(), locale))); - vascFrontendData.setVascFrontendHelper(new DefaultVascFrontendHelper()); + // init resource loaders + if (getResourceBundle()==null) { + controller.setVascEntryResourceResolver(new DefaultVascEntryResourceResolver()); + } else { + Locale locale = controller.getVascFrontendUserController().getUserLocale(); + controller.setVascEntryResourceResolver(new DefaultVascEntryResourceResolver(ResourceBundle.getBundle(getResourceBundle(), locale))); + } + controller.setVascFrontendHelper(new DefaultVascFrontendHelper()); //vascFrontendData.setVascEntryResourceImageResolver(new ImageResources()); - for(VascEntryFieldValidatorService validator:vascController.getVascEntryConfigController().getVascEntryFieldValidatorServices()) { - vascFrontendData.addVascValidatorService(validator); + // Add validators + for(VascEntryFieldValidatorService validator:getVascEntryFieldValidatorServices()) { + controller.addVascValidatorService(validator); } - - vascFrontendData.setVascController(vascController); - entry.setVascFrontendData(vascFrontendData); + // Add backend to entry VascBackend backend = vascController.getVascEntryConfigController().configVascBackendProxied(vascController, entry); - vascFrontendData.getVascEntryState().setVascBackend(backend); - vascFrontendData.getVascEntryState().setVascEntry(entry); + controller.getVascEntryState().setVascBackend(backend); + controller.getVascEntryState().setVascEntry(entry); + // Fetch all data field value impl for this backend. for (VascEntryField field:entry.getVascEntryFields()) { if (field.getVascEntryFieldValue()==null) { VascEntryFieldValue v = backend.provideVascEntryFieldValue(field); - field.setVascEntryFieldValue(v); + ((VascEntryFieldLocal)field).setVascEntryFieldValue(v); } } - - vascFrontendData.setVascFrontendPager(new DefaultVascFrontendPager(entry)); - vascFrontendData.setVascFrontendActions(new DefaultVascFrontendActions(entry)); } +/* TODO check where this is left over + + 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 + } + + + */ + /** @@ -218,10 +351,10 @@ public class DefaultVascEntryConfigController implements VascEntryConfigControll } /** - * @see net.forwardfire.vasc.core.VascEntryConfigController#getVascEntryExporters() + * @see net.forwardfire.vasc.core.VascEntryConfigController#getVascEntryExporterIds() */ - public List getVascEntryExporters() { - return new ArrayList(dataExporters.values()); + public List getVascEntryExporterIds() { + return new ArrayList(dataExporters.keySet()); } /** @@ -238,34 +371,6 @@ public class DefaultVascEntryConfigController implements VascEntryConfigControll this.resourceBundle=resourceBundle; } - /** - * @see net.forwardfire.vasc.core.VascEntryConfigController#getDefaultPageSizeMax() - */ - public int getDefaultPageSizeMax() { - return defaultPageSizeMax; - } - - /** - * @see net.forwardfire.vasc.core.VascEntryConfigController#setDefaultPageSizeMax(int) - */ - public void setDefaultPageSizeMax(int defaultPageSizeMax) { - this.defaultPageSizeMax=defaultPageSizeMax; - } - - /** - * @see net.forwardfire.vasc.core.VascEntryConfigController#getDefaultPageSize() - */ - public int getDefaultPageSize() { - return defaultPageSize; - } - - /** - * @see net.forwardfire.vasc.core.VascEntryConfigController#setDefaultPageSize(int) - */ - public void setDefaultPageSize(int defaultPageSize) { - this.defaultPageSize=defaultPageSize; - } - /** * @see net.forwardfire.vasc.core.VascEntryConfigController#addVascEntryFieldValidatorService(net.forwardfire.vasc.core.entry.VascEntryFieldValidatorService) */ @@ -286,4 +391,11 @@ public class DefaultVascEntryConfigController implements VascEntryConfigControll public List getVascEntryFieldValidatorServices() { return fieldValidators; } + + /** + * @see net.forwardfire.vasc.core.VascEntryConfigControllerLocal#getMasterVascBackendState() + */ + public VascBackendState getMasterVascBackendState() { + return masterVascBackendState; + } } \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascEntryController.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascEntryController.java index ccf59d9..b53d5fe 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascEntryController.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascEntryController.java @@ -30,6 +30,7 @@ import java.util.Map; import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntryControllerLocal; +import net.forwardfire.vasc.core.VascEntryLocal; /** * DefaultVascEntryController holds the VascEntries which we can work with. @@ -39,16 +40,16 @@ import net.forwardfire.vasc.core.VascEntryControllerLocal; */ public class DefaultVascEntryController implements VascEntryControllerLocal { - private Map entries = null; + private Map entries = null; public DefaultVascEntryController() { - entries = new HashMap(); + entries = new HashMap(); } /** * @see net.forwardfire.vasc.core.VascEntryControllerLocal#addVascEntry(net.forwardfire.vasc.core.VascEntry) */ - public void addVascEntry(VascEntry entry) { + public void addVascEntry(VascEntryLocal entry) { if (entry==null) { throw new NullPointerException("Can't add null VascEntry."); } @@ -69,7 +70,7 @@ public class DefaultVascEntryController implements VascEntryControllerLocal { * @see net.forwardfire.vasc.core.VascEntryController#getVascEntryById(java.lang.String) */ public VascEntry getVascEntryById(String id) { - VascEntry entry = entries.get(id); + VascEntryLocal entry = entries.get(id); if (entry==null) { throw new NullPointerException("Could not find vasc entry with id: "+id); } @@ -83,8 +84,8 @@ public class DefaultVascEntryController implements VascEntryControllerLocal { /** * @see net.forwardfire.vasc.core.VascEntryControllerLocal#getMasterVascEntryById(java.lang.String) */ - public VascEntry getMasterVascEntryById(String entryId) { - VascEntry entry = entries.get(entryId); + public VascEntryLocal getMasterVascEntryById(String entryId) { + VascEntryLocal entry = entries.get(entryId); return entry; } diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascEntryField.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascEntryField.java index 6d226ef..d4bd3c8 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascEntryField.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascEntryField.java @@ -22,588 +22,16 @@ package net.forwardfire.vasc.impl; -import java.util.ArrayList; -import java.util.List; -import net.forwardfire.vasc.core.VascEntry; -import net.forwardfire.vasc.core.VascEntryField; -import net.forwardfire.vasc.core.VascEntryFieldType; -import net.forwardfire.vasc.core.entry.VascEntryFieldValue; -import net.forwardfire.vasc.validators.VascValidator; +import net.forwardfire.vasc.core.AbstractVascEntryFieldLocal; /** + * DefaultVascEntryField * * @author Willem Cazander * @version 1.0 Mar 21, 2007 */ -public class DefaultVascEntryField implements VascEntryField { +public class DefaultVascEntryField extends AbstractVascEntryFieldLocal { - private static final long serialVersionUID = 1L; - - private VascEntry vascEntry = null; - - private String id = null; - private String backendName = null; - private String displayName = null; - - private VascEntryFieldType vascEntryFieldType = null; - private VascEntryFieldValue vascEntryFieldValue = null; - private List vascValidators = null; - - private String name = null; - private String description = null; - private String helpId = null; - private String image = null; - private Integer orderIndex = null; - private Object defaultValue = null; - - private Integer sizeList = null; - private Integer sizeEdit = null; - private String styleList = null; - private String styleEdit = null; - - private String choices = null; - private Boolean choicesAsRadio = null; - - /** Defines if this columns is used in interface list,create,edit **/ - private Boolean view = null; - private Boolean optional = null; - - /** Defines per view state of this field **/ - private Boolean create = null; - private Boolean edit = null; - private Boolean editReadOnly = null; - private Boolean editBlank = null; - private Boolean list = null; - - /** Defines the roles stuff if all up is true **/ - private String rolesCreate = null; - private String rolesEdit = null; - private String rolesEditReadOnly = null; - private String rolesList = null; - - private Boolean sortable = null; - private Boolean sumable = null; - private Boolean graphable = null; - - public DefaultVascEntryField() { - vascValidators = new ArrayList(5); - } - - public DefaultVascEntryField(String id) { - this(); - setId(id); - } - - /** - * @see java.lang.Object#clone() - */ - @Override - public VascEntryField clone() throws CloneNotSupportedException { - DefaultVascEntryField result = new DefaultVascEntryField(); - result.id=id; - result.backendName=backendName; - result.displayName=displayName; - result.vascEntryFieldType=vascEntryFieldType; - result.name=name; - result.description=description; - result.helpId=helpId; - result.image=image; - result.defaultValue=defaultValue; - result.orderIndex=orderIndex; - result.sizeList=sizeList; - result.sizeEdit=sizeEdit; - result.styleList=styleList; - result.styleEdit=styleEdit; - result.choices=choices; - result.choicesAsRadio=choicesAsRadio; - result.view=view; - result.optional=optional; - result.create=create; - result.edit=edit; - result.editReadOnly=editReadOnly; - result.editBlank=editBlank; - result.list=list; - - result.rolesCreate=rolesCreate; - result.rolesEdit=rolesEdit; - result.rolesEditReadOnly=rolesEditReadOnly; - result.rolesList=rolesList; - - result.sortable=sortable; - result.sumable=sumable; - result.graphable=graphable; - - // this polls full backend.. - //result.vascEntryFieldValue=vascEntryFieldValue; - - for (VascValidator val:vascValidators) { - result.vascValidators.add(val.clone()); - } - - return result; - } - - public VascEntry getVascEntry() { - return vascEntry; - } - - public void setVascEntry(VascEntry vascEntry) { - this.vascEntry=vascEntry; - } - - /** - * @return the id - */ - public String getId() { - return id; - } - - /** - * @param id the id to set - */ - public void setId(String id) { - this.id = id; - } - - /** - * @return the vascEntryFieldType - */ - public VascEntryFieldType getVascEntryFieldType() { - return vascEntryFieldType; - } - - /** - * @param vascEntryFieldType the vascEntryFieldType to set - */ - public void setVascEntryFieldType(VascEntryFieldType vascEntryFieldType) { - this.vascEntryFieldType = vascEntryFieldType; - } - - /** - * @return the backendName - */ - public String getBackendName() { - return backendName; - } - - /** - * @param backendName the backendName to set - */ - public void setBackendName(String backendName) { - this.backendName = backendName; - } - - /** - * @return the vascEntryFieldValue - */ - public VascEntryFieldValue getVascEntryFieldValue() { - return vascEntryFieldValue; - } - - /** - * @param vascEntryFieldValue the vascEntryFieldValue to set - */ - public void setVascEntryFieldValue(VascEntryFieldValue vascEntryFieldValue) { - this.vascEntryFieldValue = vascEntryFieldValue; - } - - /** - * @return the vascValidators - */ - public List getVascValidators() { - return vascValidators; - } - - /** - * @param vascValidators the vascValidators to add - */ - public void addVascValidator(VascValidator vascValidator) { - this.vascValidators.add(vascValidator); - } - - /** - * @param vascValidators the vascValidators to remove - */ - public void removeVascValidator(VascValidator vascValidator) { - this.vascValidators.remove(vascValidator); - } - - /** - * @return the name - */ - public String getName() { - return name; - } - - /** - * @param name the name to set - */ - public void setName(String name) { - this.name = name; - } - - /** - * @return the description - */ - public String getDescription() { - return description; - } - - /** - * @param description the description to set - */ - public void setDescription(String description) { - this.description = description; - } - - /** - * @return the helpId - */ - public String getHelpId() { - return helpId; - } - - /** - * @param helpId the helpId to set - */ - public void setHelpId(String helpId) { - this.helpId = helpId; - } - - /** - * @return the image - */ - public String getImage() { - return image; - } - - /** - * @param image the image to set - */ - public void setImage(String image) { - this.image = image; - } - - /** - * @return the defaultValue - */ - public Object getDefaultValue() { - return defaultValue; - } - - /** - * @param defaultValue the defaultValue to set - */ - public void setDefaultValue(Object defaultValue) { - this.defaultValue = defaultValue; - } - - /** - * @return the sizeList - */ - public Integer getSizeList() { - return sizeList; - } - - /** - * @param sizeList the sizeList to set - */ - public void setSizeList(Integer sizeList) { - this.sizeList = sizeList; - } - - /** - * @return the sizeEdit - */ - public Integer getSizeEdit() { - return sizeEdit; - } - - /** - * @param sizeEdit the sizeEdit to set - */ - public void setSizeEdit(Integer sizeEdit) { - this.sizeEdit = sizeEdit; - } - - /** - * @return the styleList - */ - public String getStyleList() { - return styleList; - } - - /** - * @param styleList the styleList to set - */ - public void setStyleList(String styleList) { - this.styleList = styleList; - } - - /** - * @return the styleEdit - */ - public String getStyleEdit() { - return styleEdit; - } - - /** - * @param styleEdit the styleEdit to set - */ - public void setStyleEdit(String styleEdit) { - this.styleEdit = styleEdit; - } - - /** - * @return the choices - */ - public String getChoices() { - return choices; - } - - /** - * @param choices the choices to set - */ - public void setChoices(String choices) { - this.choices = choices; - } - - /** - * @return the view - */ - public Boolean getView() { - return view; - } - - /** - * @param view the view to set - */ - public void setView(Boolean view) { - this.view = view; - } - - /** - * @return the optional - */ - public Boolean getOptional() { - return optional; - } - - /** - * @param optional the optional to set - */ - public void setOptional(Boolean optional) { - this.optional = optional; - } - - /** - * @return the create - */ - public Boolean getCreate() { - return create; - } - - /** - * @param create the create to set - */ - public void setCreate(Boolean create) { - this.create = create; - } - - /** - * @return the edit - */ - public Boolean getEdit() { - return edit; - } - - /** - * @param edit the edit to set - */ - public void setEdit(Boolean edit) { - this.edit = edit; - } - - /** - * @return the editReadOnly - */ - public Boolean getEditReadOnly() { - return editReadOnly; - } - - /** - * @param editReadOnly the editReadOnly to set - */ - public void setEditReadOnly(Boolean editReadOnly) { - this.editReadOnly = editReadOnly; - } - - /** - * @return the list - */ - public Boolean getList() { - return list; - } - - /** - * @param list the list to set - */ - public void setList(Boolean list) { - this.list = list; - } - - /** - * @return the rolesCreate - */ - public String getRolesCreate() { - return rolesCreate; - } - - /** - * @param rolesCreate the rolesCreate to set - */ - public void setRolesCreate(String rolesCreate) { - this.rolesCreate = rolesCreate; - } - - /** - * @return the rolesEdit - */ - public String getRolesEdit() { - return rolesEdit; - } - - /** - * @param rolesEdit the rolesEdit to set - */ - public void setRolesEdit(String rolesEdit) { - this.rolesEdit = rolesEdit; - } - - /** - * @return the rolesEditReadOnly - */ - public String getRolesEditReadOnly() { - return rolesEditReadOnly; - } - - /** - * @param rolesEditReadOnly the rolesEditReadOnly to set - */ - public void setRolesEditReadOnly(String rolesEditReadOnly) { - this.rolesEditReadOnly = rolesEditReadOnly; - } - - /** - * @return the rolesList - */ - public String getRolesList() { - return rolesList; - } - - /** - * @param rolesList the rolesList to set - */ - public void setRolesList(String rolesList) { - this.rolesList = rolesList; - } - - /** - * @return the choicesAsRadio - */ - public Boolean getChoicesAsRadio() { - return choicesAsRadio; - } - - /** - * @param choicesAsRadio the choicesAsRadio to set - */ - public void setChoicesAsRadio(Boolean choicesAsRadio) { - this.choicesAsRadio = choicesAsRadio; - } - - /** - * @return the editBlank - */ - public Boolean getEditBlank() { - return editBlank; - } - - /** - * @param editBlank the editBlank to set - */ - public void setEditBlank(Boolean editBlank) { - this.editBlank = editBlank; - } - - /** - * @return the displayName - */ - public String getDisplayName() { - return displayName; - } - - /** - * @param displayName the displayName to set - */ - public void setDisplayName(String displayName) { - this.displayName = displayName; - } - - /** - * @return the orderIndex - */ - public Integer getOrderIndex() { - return orderIndex; - } - - /** - * @param orderIndex the orderIndex to set - */ - public void setOrderIndex(Integer orderIndex) { - this.orderIndex = orderIndex; - } - - /** - * @return the sortable - */ - public Boolean getSortable() { - return sortable; - } - - /** - * @param sortable the sortable to set - */ - public void setSortable(Boolean sortable) { - this.sortable = sortable; - } - - /** - * @return the sumable - */ - public Boolean getSumable() { - return sumable; - } - - /** - * @param sumable the sumable to set - */ - public void setSumable(Boolean sumable) { - this.sumable = sumable; - } - - /** - * @return the graphable - */ - public Boolean getGraphable() { - return graphable; - } - - /** - * @param graphable the graphable to set - */ - public void setGraphable(Boolean graphable) { - this.graphable = graphable; - } + private static final long serialVersionUID = -7441813124020844226L; } \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascEntryFieldSet.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascEntryFieldSet.java index b49fc42..e2daa29 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascEntryFieldSet.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascEntryFieldSet.java @@ -22,202 +22,15 @@ package net.forwardfire.vasc.impl; -import java.util.ArrayList; -import java.util.List; - -import net.forwardfire.vasc.core.VascEntryFieldSet; - +import net.forwardfire.vasc.core.AbstractVascEntryFieldSetLocal; /** + * DefaultVascEntryFieldSet * * @author Willem Cazander * @version 1.0 Mar 21, 2007 */ -public class DefaultVascEntryFieldSet implements VascEntryFieldSet { - - private String id = null; - - private String name = null; - private String description = null; - private String helpId = null; - private String image = null; +public class DefaultVascEntryFieldSet extends AbstractVascEntryFieldSetLocal { - private String styleList = null; - private String styleEdit = null; - - private boolean collapsed = false; - private boolean optional = false; - - private List vascEntryFieldIds = null; - - public DefaultVascEntryFieldSet() { - vascEntryFieldIds = new ArrayList(10); - } - - /** - * @see java.lang.Object#clone() - */ - @Override - public VascEntryFieldSet clone() throws CloneNotSupportedException { - DefaultVascEntryFieldSet result = new DefaultVascEntryFieldSet(); - result.id=id; - result.name=name; - result.description=description; - result.helpId=helpId; - result.image=image; - result.styleList=styleList; - result.styleEdit=styleEdit; - result.collapsed=collapsed; - result.optional=optional; - result.vascEntryFieldIds.addAll(vascEntryFieldIds); - return result; - } - - - /** - * @return the id - */ - public String getId() { - return id; - } - - /** - * @param id the id to set - */ - public void setId(String id) { - this.id = id; - } - - /** - * @return the name - */ - public String getName() { - return name; - } - - /** - * @param name the name to set - */ - public void setName(String name) { - this.name = name; - } - - /** - * @return the description - */ - public String getDescription() { - return description; - } - - /** - * @param description the description to set - */ - public void setDescription(String description) { - this.description = description; - } - - /** - * @return the helpId - */ - public String getHelpId() { - return helpId; - } - - /** - * @param helpId the helpId to set - */ - public void setHelpId(String helpId) { - this.helpId = helpId; - } - - /** - * @return the image - */ - public String getImage() { - return image; - } - - /** - * @param image the image to set - */ - public void setImage(String image) { - this.image = image; - } - - /** - * @return the styleList - */ - public String getStyleList() { - return styleList; - } - - /** - * @param styleList the styleList to set - */ - public void setStyleList(String styleList) { - this.styleList = styleList; - } - - /** - * @return the styleEdit - */ - public String getStyleEdit() { - return styleEdit; - } - - /** - * @param styleEdit the styleEdit to set - */ - public void setStyleEdit(String styleEdit) { - this.styleEdit = styleEdit; - } - - /** - * @return the collapsed - */ - public boolean isCollapsed() { - return collapsed; - } - - /** - * @param collapsed the collapsed to set - */ - public void setCollapsed(boolean collapsed) { - this.collapsed = collapsed; - } - - /** - * @return the optional - */ - public boolean isOptional() { - return optional; - } - - /** - * @param optional the optional to set - */ - public void setOptional(boolean optional) { - this.optional = optional; - } - - /** - * @return the vascEntryFieldIds - */ - public List getVascEntryFieldIds() { - return vascEntryFieldIds; - } - - /** - * @param vascEntryFieldIds the vascEntryFieldIds to set - */ - public void addVascEntryFieldId(String vascEntryFieldId) { - vascEntryFieldIds.add(vascEntryFieldId); - } - - /** - * @param vascEntryFieldIds the vascEntryFieldIds to set - */ - public void removeVascEntryFieldId(String vascEntryFieldId) { - vascEntryFieldIds.remove(vascEntryFieldId); - } + private static final long serialVersionUID = -7205732470572097379L; } \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascEntryLink.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascEntryLink.java new file mode 100644 index 0000000..251fe18 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascEntryLink.java @@ -0,0 +1,36 @@ +/* + * 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 net.forwardfire.vasc.core.AbstractVascEntryLinkLocal; + +/** + * DefaultVascEntryLink + * + * @author Willem Cazander + * @version 1.0 Oct 27, 2007 + */ +public class DefaultVascEntryLink extends AbstractVascEntryLinkLocal { + + private static final long serialVersionUID = 3531875301982217410L; +} \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascEntryListOption.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascEntryListOption.java new file mode 100644 index 0000000..b06531d --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascEntryListOption.java @@ -0,0 +1,36 @@ +/* + * 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 net.forwardfire.vasc.core.AbstractVascEntryListOptionLocal; + +/** + * DefaultVascEntryListOption + * + * @author Willem Cazander + * @version 1.0 Jun 3, 2012 + */ +public class DefaultVascEntryListOption extends AbstractVascEntryListOptionLocal { + + private static final long serialVersionUID = 714184775525590003L; +} \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascEntryState.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascEntryState.java index a089e38..994d610 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascEntryState.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascEntryState.java @@ -31,6 +31,6 @@ import net.forwardfire.vasc.core.AbstractVascEntryState; * @version 1.0 Dec 15, 2009 */ public class DefaultVascEntryState extends AbstractVascEntryState { - - private static final long serialVersionUID = 1L; + + private static final long serialVersionUID = -4795966794621554844L; } diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascFactory.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascFactory.java index 5942c60..adcff61 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascFactory.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascFactory.java @@ -22,10 +22,6 @@ package net.forwardfire.vasc.impl; -import java.util.Locale; -import java.util.ResourceBundle; - -import net.forwardfire.vasc.backend.VascBackend; import net.forwardfire.vasc.backend.proxy.VascBackendProxyCache; import net.forwardfire.vasc.backend.proxy.VascBackendProxyEventExecutor; import net.forwardfire.vasc.backend.proxy.VascBackendProxyFilter; @@ -36,11 +32,10 @@ import net.forwardfire.vasc.backend.proxy.VascBackendProxyTimerLogger; import net.forwardfire.vasc.core.VascController; import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntryControllerLocal; -import net.forwardfire.vasc.core.VascEntryField; +import net.forwardfire.vasc.core.VascEntryLocal; import net.forwardfire.vasc.core.VascException; -import net.forwardfire.vasc.core.entry.VascEntryFieldValue; -import net.forwardfire.vasc.frontend.VascFrontendData; -import net.forwardfire.vasc.impl.entry.DefaultVascEntryResourceResolver; +import net.forwardfire.vasc.core.VascInterfaceKey; +import net.forwardfire.vasc.core.VascInterfaceKeyFrontend; import net.forwardfire.vasc.impl.entry.VascValidatorsValidatorService; import net.forwardfire.vasc.impl.entry.config.VascActionsFinalizer; import net.forwardfire.vasc.impl.entry.config.VascDefaultsFinalizer; @@ -51,6 +46,12 @@ import net.forwardfire.vasc.impl.entry.config.VascIdCheckFinalizer; import net.forwardfire.vasc.impl.entry.export.VascEntryExporterCsv; import net.forwardfire.vasc.impl.entry.export.VascEntryExporterXml; import net.forwardfire.vasc.impl.entry.export.VascEntryExporterXmlTree; +import net.forwardfire.vasc.impl.frontend.DefaultVascFrontendActions; +import net.forwardfire.vasc.impl.frontend.DefaultVascFrontendController; +import net.forwardfire.vasc.impl.frontend.DefaultVascFrontendDataSelector; +import net.forwardfire.vasc.impl.frontend.DefaultVascFrontendPager; +import net.forwardfire.vasc.impl.frontend.DummyVascFrontendUserController; +import net.forwardfire.vasc.impl.frontend.DummyVascFrontendUserSettingController; import net.forwardfire.vasc.impl.type.DefaultVascEntryFieldTypeController; /** @@ -62,10 +63,28 @@ import net.forwardfire.vasc.impl.type.DefaultVascEntryFieldTypeController; public class DefaultVascFactory { - static public VascController getDefaultVascController(Long userId,String userName,String...roles) throws VascException { + static public VascController getDefaultVascController() throws VascException { + // Create DefaultVascEntryConfigController vascConfig = new DefaultVascEntryConfigController(); + vascConfig.putVascInterfaceImplemention(VascInterfaceKey.VASC_ENTRY, DefaultVascEntry.class); + vascConfig.putVascInterfaceImplemention(VascInterfaceKey.VASC_ENTRY_FIELD, DefaultVascEntryField.class); + vascConfig.putVascInterfaceImplemention(VascInterfaceKey.VASC_ENTRY_FIELD_SET, DefaultVascEntryFieldSet.class); + vascConfig.putVascInterfaceImplemention(VascInterfaceKey.VASC_ENTRY_STATE, DefaultVascEntryState.class); + vascConfig.putVascInterfaceImplemention(VascInterfaceKey.VASC_ENTRY_LINK, DefaultVascEntryLink.class); + vascConfig.putVascInterfaceImplemention(VascInterfaceKey.VASC_ENTRY_LIST_OPTION, DefaultVascEntryListOption.class); + + vascConfig.putVascInterfaceImplemention(VascInterfaceKey.VASC_BACKEND_STATE, DefaultVascBackendState.class); + vascConfig.putVascInterfaceImplemention(VascInterfaceKey.VASC_FRONTEND_CONTROLLER_LOCAL, DefaultVascFrontendController.class); + + vascConfig.putVascInterfaceImplementionFrontend(VascInterfaceKeyFrontend.VASC_FRONTEND_ACTIONS, DefaultVascFrontendActions.class); + vascConfig.putVascInterfaceImplementionFrontend(VascInterfaceKeyFrontend.VASC_FRONTEND_DATA_SELECTOR, DefaultVascFrontendDataSelector.class); + vascConfig.putVascInterfaceImplementionFrontend(VascInterfaceKeyFrontend.VASC_FRONTEND_PAGER, DefaultVascFrontendPager.class); + vascConfig.putVascInterfaceImplementionFrontend(VascInterfaceKeyFrontend.VASC_FRONTEND_USER_CONTROLLER, DummyVascFrontendUserController.class); + vascConfig.putVascInterfaceImplementionFrontend(VascInterfaceKeyFrontend.VASC_FRONTEND_USER_SETTING_CONTROLLER, DummyVascFrontendUserSettingController.class); + + // Add all backend proxy in ORDER vascConfig.addVascBackendProxy(new VascBackendProxyTimerLogger()); vascConfig.addVascBackendProxy(new VascBackendProxyEventExecutor()); @@ -88,125 +107,24 @@ public class DefaultVascFactory { vascConfig.addVascEntryExporter(new VascEntryExporterXml()); vascConfig.addVascEntryExporter(new VascEntryExporterCsv()); - // Add per default the internal vasc validator + // Add only the default internal vasc validator. vascConfig.addVascEntryFieldValidatorService(new VascValidatorsValidatorService()); + // Create default controller and fill resolvers. DefaultVascController c = new DefaultVascController(); c.setVascEntryConfigController(vascConfig); + c.setVascBackendController(new DefaultVascBackendController()); + c.setVascEntryController(new DefaultVascEntryController()); + c.setVascEntryFieldTypeController(new DefaultVascEntryFieldTypeController()); - DefaultVascBackendController vascBackendController = new DefaultVascBackendController(); - c.setVascBackendController(vascBackendController); - - DefaultVascEntryController vascEntryController = new DefaultVascEntryController(); - c.setVascEntryController(vascEntryController); - - DefaultVascEntryFieldTypeController vascEntryFieldTypeController = new DefaultVascEntryFieldTypeController(); - c.setVascEntryFieldTypeController(vascEntryFieldTypeController); - - DefaultVascUserRoleController vascUserRoleController = new DefaultVascUserRoleController(userId,userName,roles); - c.setVascUserRoleController(vascUserRoleController); - + // Ready to go return c; } - - static public VascFrontendData getDefaultVascFrontendData(String resourceBundle,Locale locale) { - ResourceBundle bundle = ResourceBundle.getBundle(resourceBundle, locale); - return getDefaultVascFrontendData(bundle); - } - - static public VascFrontendData getDefaultVascFrontendData(ResourceBundle resourceBundle) { - // Create default frontend data obj where controller is set by vasc - DefaultVascFrontendData vascFrontendData = new DefaultVascFrontendData(); // - vascFrontendData.setVascEntryState(new DefaultVascEntryState()); - vascFrontendData.getVascEntryState().setVascBackendState(new DefaultVascBackendState()); - vascFrontendData.getVascEntryState().getVascBackendState().setPageSize(100); - vascFrontendData.getVascEntryState().getVascBackendState().setPageSizeMax(1000); // max 1k records on screen. - - // init resource resultsers - vascFrontendData.setVascEntryResourceResolver(new DefaultVascEntryResourceResolver(resourceBundle)); - vascFrontendData.setVascFrontendHelper(new DefaultVascFrontendHelper()); - //vascFrontendData.setVascEntryResourceImageResolver(new ImageResources()); - - vascFrontendData.addVascValidatorService(new VascValidatorsValidatorService()); - return vascFrontendData; - } - - - static public void fillVascControllerLocalEntries(VascEntryControllerLocal c,VascController vascController) throws VascException { for (String id:c.getVascEntryIds()) { - VascEntry entry = c.getMasterVascEntryById(id); + VascEntryLocal entry = (VascEntryLocal)c.getMasterVascEntryById(id); vascController.getVascEntryConfigController().configVascEntry(vascController, entry); } } - - /* MOVED to VascEntryConfigController - - /* - 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) throws VascException { - frontendData.setVascController(vascController); - entry.setVascFrontendData(frontendData); - VascBackend backend = vascController.getVascEntryConfigController().configVascBackendProxied(vascController, entry); - frontendData.getVascEntryState().setVascBackend(backend); - frontendData.getVascEntryState().setVascEntry(entry); - - for (VascEntryField field:entry.getVascEntryFields()) { - if (field.getVascEntryFieldValue()==null) { - VascEntryFieldValue v = backend.provideVascEntryFieldValue(field); - field.setVascEntryFieldValue(v); - } - } - - frontendData.setVascFrontendPager(new DefaultVascFrontendPager(entry)); - frontendData.setVascFrontendActions(new DefaultVascFrontendActions(entry)); - } } \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascInterfaceLoader.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascInterfaceLoader.java new file mode 100644 index 0000000..48e8c6b --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascInterfaceLoader.java @@ -0,0 +1,155 @@ +/* + * 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 net.forwardfire.vasc.backend.VascBackendState; +import net.forwardfire.vasc.core.VascEntry; +import net.forwardfire.vasc.core.VascEntryConfigControllerLocal; +import net.forwardfire.vasc.core.VascEntryField; +import net.forwardfire.vasc.core.VascEntryFieldSet; +import net.forwardfire.vasc.core.VascEntryLink; +import net.forwardfire.vasc.core.VascEntryListOption; +import net.forwardfire.vasc.core.VascEntryState; +import net.forwardfire.vasc.core.VascInterfaceKey; +import net.forwardfire.vasc.core.VascInterfaceKeyFrontend; +import net.forwardfire.vasc.core.VascInterfaceLoader; +import net.forwardfire.vasc.frontend.VascFrontendActions; +import net.forwardfire.vasc.frontend.VascFrontendControllerLocal; +import net.forwardfire.vasc.frontend.VascFrontendDataSelector; +import net.forwardfire.vasc.frontend.VascFrontendPager; +import net.forwardfire.vasc.frontend.VascFrontendUserController; +import net.forwardfire.vasc.frontend.VascFrontendUserSettingController; + +/** + * DefaultVascInterfaceLoader is auto caster. + * + * @author Willem Cazander + * @version 1.0 May 9, 2012 + */ +public class DefaultVascInterfaceLoader implements VascInterfaceLoader { + + private VascEntryConfigControllerLocal localConfig = null; + + public DefaultVascInterfaceLoader(VascEntryConfigControllerLocal localConfig) { + this.localConfig=localConfig; + } + + private Object createImpl(VascInterfaceKey key) { + return localConfig.createVascInterfaceImplemention(key); + } + private Object createImpl(VascInterfaceKeyFrontend key,VascEntry entry) { + return localConfig.createVascInterfaceImplementionFrontend(key,entry); + } + + + /** + * @see net.forwardfire.vasc.core.VascInterfaceLoader#createVascEntryImpl() + */ + public VascEntry createVascEntryImpl() { + return (VascEntry)createImpl(VascInterfaceKey.VASC_ENTRY); + } + + /** + * @see net.forwardfire.vasc.core.VascInterfaceLoader#createVascEntryFieldImpl() + */ + public VascEntryField createVascEntryFieldImpl() { + return (VascEntryField)createImpl(VascInterfaceKey.VASC_ENTRY_FIELD); + } + + /** + * @see net.forwardfire.vasc.core.VascInterfaceLoader#createVascEntryStateImpl() + */ + public VascEntryState createVascEntryStateImpl() { + return (VascEntryState)createImpl(VascInterfaceKey.VASC_ENTRY_STATE); + } + + /** + * @see net.forwardfire.vasc.core.VascInterfaceLoader#createVascEntryFieldSetImpl() + */ + public VascEntryFieldSet createVascEntryFieldSetImpl() { + return (VascEntryFieldSet)createImpl(VascInterfaceKey.VASC_ENTRY_FIELD_SET); + } + + /** + * @see net.forwardfire.vasc.core.VascInterfaceLoader#createVascEntryLinkImpl() + */ + public VascEntryLink createVascEntryLinkImpl() { + return (VascEntryLink)createImpl(VascInterfaceKey.VASC_ENTRY_LINK); + } + + /** + * @see net.forwardfire.vasc.core.VascInterfaceLoader#createVascEntryListOptionImpl() + */ + public VascEntryListOption createVascEntryListOptionImpl() { + return (VascEntryListOption)createImpl(VascInterfaceKey.VASC_ENTRY_LIST_OPTION); + } + + /** + * @see net.forwardfire.vasc.core.VascInterfaceLoader#createVascBackendStateImpl() + */ + public VascBackendState createVascBackendStateImpl() { + return (VascBackendState)createImpl(VascInterfaceKey.VASC_BACKEND_STATE); + } + + /** + * @see net.forwardfire.vasc.core.VascInterfaceLoader#createVascFrontendControllerLocalImpl() + */ + public VascFrontendControllerLocal createVascFrontendControllerLocalImpl() { + return (VascFrontendControllerLocal)createImpl(VascInterfaceKey.VASC_FRONTEND_CONTROLLER_LOCAL); + } + + /** + * @see net.forwardfire.vasc.core.VascInterfaceLoader#createVascFrontendPagerImpl() + */ + public VascFrontendPager createVascFrontendPagerImpl(VascEntry entry) { + return (VascFrontendPager)createImpl(VascInterfaceKeyFrontend.VASC_FRONTEND_PAGER,entry); + } + + /** + * @see net.forwardfire.vasc.core.VascInterfaceLoader#createVascFrontendActionsImpl() + */ + public VascFrontendActions createVascFrontendActionsImpl(VascEntry entry) { + return (VascFrontendActions)createImpl(VascInterfaceKeyFrontend.VASC_FRONTEND_ACTIONS,entry); + } + + /** + * @see net.forwardfire.vasc.core.VascInterfaceLoader#createVascFrontendDataSelectorImpl() + */ + public VascFrontendDataSelector createVascFrontendDataSelectorImpl(VascEntry entry) { + return (VascFrontendDataSelector)createImpl(VascInterfaceKeyFrontend.VASC_FRONTEND_DATA_SELECTOR,entry); + } + + /** + * @see net.forwardfire.vasc.core.VascInterfaceLoader#createVascFrontendUserControllerImpl() + */ + public VascFrontendUserController createVascFrontendUserControllerImpl(VascEntry entry) { + return (VascFrontendUserController)createImpl(VascInterfaceKeyFrontend.VASC_FRONTEND_USER_CONTROLLER,entry); + } + + /** + * @see net.forwardfire.vasc.core.VascInterfaceLoader#createVascFrontendUserSettingControllerImpl() + */ + public VascFrontendUserSettingController createVascFrontendUserSettingControllerImpl(VascEntry entry) { + return (VascFrontendUserSettingController)createImpl(VascInterfaceKeyFrontend.VASC_FRONTEND_USER_SETTING_CONTROLLER,entry); + } +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/actions/AddRowAction.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/actions/AddRowAction.java index 3ed3f0b..3c811fc 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/actions/AddRowAction.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/actions/AddRowAction.java @@ -23,19 +23,17 @@ package net.forwardfire.vasc.impl.actions; import net.forwardfire.vasc.core.VascEntry; -import net.forwardfire.vasc.core.actions.AbstractVascAction; -import net.forwardfire.vasc.core.actions.RowVascAction; - - +import net.forwardfire.vasc.core.actions.AbstractVascRowActionLocal; /** + * AddRowAction * * @author Willem Cazander * @version 1.0 Mar 30, 2007 */ -public class AddRowAction extends AbstractVascAction implements RowVascAction { +public class AddRowAction extends AbstractVascRowActionLocal { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 3400966729022979875L; static public final String ACTION_ID = "addRowAction"; protected String getActionId() { @@ -44,10 +42,10 @@ public class AddRowAction extends AbstractVascAction implements RowVascAction { public void doRowAction(VascEntry entry,Object rowObject) throws Exception { - entry.getVascFrontendData().getVascEntryState().setEditCreate(true); - Object object = entry.getVascFrontendData().getVascFrontendActions().createObject(); - entry.getVascFrontendData().getVascEntryState().setEntryDataObject(object); - entry.getVascFrontendData().getVascFrontend().renderEdit(); + entry.getVascFrontendController().getVascEntryState().setEditCreate(true); + Object object = entry.getVascFrontendController().getVascFrontendActions().createObject(); + entry.getVascFrontendController().getVascEntryState().setEntryDataObject(object); + entry.getVascFrontendController().getVascFrontend().renderEdit(); } /** diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/actions/DeleteRowAction.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/actions/DeleteRowAction.java index c93a97d..4647f83 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/actions/DeleteRowAction.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/actions/DeleteRowAction.java @@ -23,19 +23,17 @@ package net.forwardfire.vasc.impl.actions; import net.forwardfire.vasc.core.VascEntry; -import net.forwardfire.vasc.core.actions.AbstractVascAction; -import net.forwardfire.vasc.core.actions.RowVascAction; - - +import net.forwardfire.vasc.core.actions.AbstractVascRowActionLocal; /** + * DeleteRowAction * * @author Willem Cazander * @version 1.0 Mar 30, 2007 */ -public class DeleteRowAction extends AbstractVascAction implements RowVascAction { +public class DeleteRowAction extends AbstractVascRowActionLocal { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1162940569489964980L; static public final String ACTION_ID = "deleteRowAction"; protected String getActionId() { @@ -46,8 +44,8 @@ public class DeleteRowAction extends AbstractVascAction implements RowVascAction if (rowObject==null) { return; // nothing selected } - entry.getVascFrontendData().getVascEntryState().setEntryDataObject(rowObject); - entry.getVascFrontendData().getVascFrontend().renderDelete(); + entry.getVascFrontendController().getVascEntryState().setEntryDataObject(rowObject); + entry.getVascFrontendController().getVascFrontend().renderDelete(); } /** diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/actions/EditRowAction.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/actions/EditRowAction.java index 167e8a3..3fcac79 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/actions/EditRowAction.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/actions/EditRowAction.java @@ -23,20 +23,18 @@ package net.forwardfire.vasc.impl.actions; import net.forwardfire.vasc.core.VascEntry; -import net.forwardfire.vasc.core.actions.AbstractVascAction; -import net.forwardfire.vasc.core.actions.RowVascAction; +import net.forwardfire.vasc.core.actions.AbstractVascRowActionLocal; import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener.VascFrontendEventType; - - /** + * EditRowAction * * @author Willem Cazander * @version 1.0 Mar 30, 2007 */ -public class EditRowAction extends AbstractVascAction implements RowVascAction { +public class EditRowAction extends AbstractVascRowActionLocal { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 8159548546452740185L; static public final String ACTION_ID = "editRowAction"; protected String getActionId() { @@ -48,10 +46,10 @@ public class EditRowAction extends AbstractVascAction implements RowVascAction { if (rowObject==null) { return; // nothing selected } - entry.getVascFrontendData().getVascEntryState().setEditCreate(false); - entry.getVascFrontendData().fireVascFrontendEvent(entry, VascFrontendEventType.SELECT, rowObject); - entry.getVascFrontendData().getVascEntryState().setEntryDataObject(rowObject); - entry.getVascFrontendData().getVascFrontend().renderEdit(); + entry.getVascFrontendController().getVascEntryState().setEditCreate(false); + entry.getVascFrontendController().fireVascFrontendEvent(entry, VascFrontendEventType.SELECT, rowObject); + entry.getVascFrontendController().getVascEntryState().setEntryDataObject(rowObject); + entry.getVascFrontendController().getVascFrontend().renderEdit(); } diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/actions/ExportDataGlobalAction.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/actions/ExportDataGlobalAction.java index a482145..e4c6000 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/actions/ExportDataGlobalAction.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/actions/ExportDataGlobalAction.java @@ -23,9 +23,7 @@ package net.forwardfire.vasc.impl.actions; import net.forwardfire.vasc.core.VascEntry; -import net.forwardfire.vasc.core.actions.AbstractVascAction; -import net.forwardfire.vasc.core.actions.GlobalVascAction; -import net.forwardfire.vasc.core.actions.VascAction; +import net.forwardfire.vasc.core.actions.AbstractVascGlobalActionLocal; import net.forwardfire.vasc.core.entry.VascEntryExporter; /** @@ -34,14 +32,18 @@ import net.forwardfire.vasc.core.entry.VascEntryExporter; * @author Willem Cazander * @version 1.0 May 10, 2012 */ -public class ExportDataGlobalAction extends AbstractVascAction implements GlobalVascAction { +public class ExportDataGlobalAction extends AbstractVascGlobalActionLocal { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 3474627214820048829L; private String exporterId = null; static public final String ACTION_POSTFIX = "ExportAction"; + public ExportDataGlobalAction() { + + } + public ExportDataGlobalAction(String exporterId) { - this.exporterId=exporterId; + setExporterId(exporterId); setId(exporterId+ACTION_POSTFIX); } @@ -50,23 +52,28 @@ public class ExportDataGlobalAction extends AbstractVascAction implements Global } public void doGlobalAction(VascEntry entry) throws Exception { - VascEntryExporter exporter = entry.getVascFrontendData().getVascController().getVascEntryConfigController().getVascEntryExporterById(exporterId); - entry.getVascFrontendData().getVascFrontend().renderExport(exporter); + VascEntryExporter exporter = entry.getVascFrontendController().getVascController().getVascEntryConfigController().getVascEntryExporterById(exporterId); + entry.getVascFrontendController().getVascFrontend().renderExport(exporter); + } + + @Override + public void cloneFields(Object cloneObject) throws CloneNotSupportedException { + super.cloneFields(cloneObject); + ExportDataGlobalAction clone = (ExportDataGlobalAction)cloneObject; + clone.setExporterId(getExporterId()); } /** - * @see net.forwardfire.vasc.core.actions.AbstractVascAction#clone() + * @return the exporterId */ - @Override - public VascAction clone() throws CloneNotSupportedException { - VascAction action = new ExportDataGlobalAction(exporterId); - action.setId(getId()); - action.setName(getName()); - action.setDescription(getDescription()); - action.setImage(getImage()); - action.setHelpId(getHelpId()); - return action; + public String getExporterId() { + return exporterId; + } + + /** + * @param exporterId the exporterId to set + */ + public void setExporterId(String exporterId) { + this.exporterId = exporterId; } - - } \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/actions/RefreshDataGlobalAction.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/actions/RefreshDataGlobalAction.java index d9b72a0..9d2f418 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/actions/RefreshDataGlobalAction.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/actions/RefreshDataGlobalAction.java @@ -23,27 +23,24 @@ package net.forwardfire.vasc.impl.actions; import net.forwardfire.vasc.core.VascEntry; -import net.forwardfire.vasc.core.actions.AbstractVascAction; -import net.forwardfire.vasc.core.actions.GlobalVascAction; - - +import net.forwardfire.vasc.core.actions.AbstractVascGlobalActionLocal; /** + * RefreshDataGlobalAction * * @author Willem Cazander * @version 1.0 Apr 28, 2007 */ -public class RefreshDataGlobalAction extends AbstractVascAction implements GlobalVascAction { +public class RefreshDataGlobalAction extends AbstractVascGlobalActionLocal { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = -5988959004156823956L; static public final String ACTION_ID = "refreshDataAction"; protected String getActionId() { return ACTION_ID; } - public void doGlobalAction(VascEntry entry) throws Exception { - entry.getVascFrontendData().getVascFrontendActions().refreshData(); // this wil also fire the event + entry.getVascFrontendController().getVascFrontendActions().refreshData(); // this wil also fire the event } } \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/HibernateValidatorService.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/HibernateValidatorService.java index 03e602c..f173a69 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/HibernateValidatorService.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/HibernateValidatorService.java @@ -162,7 +162,7 @@ public class HibernateValidatorService implements VascEntryFieldValidatorService if ( variable != null ) { buf.append( variable ); } else { - String string = vascEntry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(token); + String string = vascEntry.getVascFrontendController().getVascEntryResourceResolver().getTextValue(token); if ( string != null ) { buf.append(replace(string)); } diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/config/VascActionsFinalizer.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/config/VascActionsFinalizer.java index ba6c546..6d8c303 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/config/VascActionsFinalizer.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/config/VascActionsFinalizer.java @@ -25,8 +25,8 @@ package net.forwardfire.vasc.impl.entry.config; import net.forwardfire.vasc.core.VascController; import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntryConfigFinalizer; +import net.forwardfire.vasc.core.VascEntryLocal; import net.forwardfire.vasc.core.VascException; -import net.forwardfire.vasc.core.entry.VascEntryExporter; import net.forwardfire.vasc.impl.actions.AddRowAction; import net.forwardfire.vasc.impl.actions.DeleteRowAction; import net.forwardfire.vasc.impl.actions.EditRowAction; @@ -44,28 +44,31 @@ public class VascActionsFinalizer implements VascEntryConfigFinalizer { /** * @see net.forwardfire.vasc.core.VascEntryConfigFinalizer#configVascEntry(net.forwardfire.vasc.core.VascController, net.forwardfire.vasc.core.VascEntry) */ - public void configVascEntry(VascController vascController, VascEntry entry) throws VascException { + public void configVascEntry(VascController vascController, VascEntryLocal entry) throws VascException { if (entry.getExportActions().isEmpty()==false) { return; // hackje for calling multiple times on same entries. } + + entry.addRowAction(new AddRowAction()); + entry.addRowAction(new EditRowAction()); + entry.addRowAction(new DeleteRowAction()); + /* if (entry.isVascDisplayOnly()==false) { // TODO: redo to flags if (entry.isVascAdminCreate()) { - entry.addRowAction(new AddRowAction()); } if (entry.isVascAdminEdit()) { - entry.addRowAction(new EditRowAction()); } if (entry.isVascAdminDelete()) { - entry.addRowAction(new DeleteRowAction()); } } + */ entry.addGlobalAction(new RefreshDataGlobalAction()); // Add all exporter actions - for (VascEntryExporter export:vascController.getVascEntryConfigController().getVascEntryExporters()) { - entry.addExportAction(new ExportDataGlobalAction(export.getId())); + for (String exportId:vascController.getVascEntryConfigController().getVascEntryExporterIds()) { + entry.addExportAction(new ExportDataGlobalAction(exportId)); } }} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/config/VascDefaultsFinalizer.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/config/VascDefaultsFinalizer.java index d1ec2a9..1e51665 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/config/VascDefaultsFinalizer.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/config/VascDefaultsFinalizer.java @@ -22,20 +22,20 @@ package net.forwardfire.vasc.impl.entry.config; -import java.util.Collections; -import java.util.Comparator; import java.util.Locale; import org.x4o.xml.conv.ObjectConverterException; import net.forwardfire.vasc.backend.VascBackend; import net.forwardfire.vasc.core.VascController; -import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntryField; import net.forwardfire.vasc.core.VascEntryConfigFinalizer; +import net.forwardfire.vasc.core.VascEntryFieldLocal; +import net.forwardfire.vasc.core.VascEntryLinkLocal; +import net.forwardfire.vasc.core.VascEntryListOptionLocal; +import net.forwardfire.vasc.core.VascEntryLocal; import net.forwardfire.vasc.core.VascException; -import net.forwardfire.vasc.core.VascLinkEntry; -import net.forwardfire.vasc.core.VascLinkEntryType; +import net.forwardfire.vasc.core.VascEntryLinkType; /** * VascDefaultsFinalizer does set some default in objects of entry. @@ -48,7 +48,7 @@ public class VascDefaultsFinalizer implements VascEntryConfigFinalizer { /** * @see net.forwardfire.vasc.core.VascEntryConfigFinalizer#configVascEntry(net.forwardfire.vasc.core.VascController, net.forwardfire.vasc.core.VascEntry) */ - public void configVascEntry(VascController vascController, VascEntry entry) throws VascException { + public void configVascEntry(VascController vascController, VascEntryLocal entry) throws VascException { // First Check if we all have ids String id = entry.getId(); @@ -62,27 +62,42 @@ public class VascDefaultsFinalizer implements VascEntryConfigFinalizer { throw new IllegalArgumentException("The VascEntry backend is not found in backends: '"+entry.getBackendId()+"' in entryId: "+id); } - // boolean view helper - if (entry.isVascDisplayOnly()) { - entry.setVascAdminCreate(false); - entry.setVascAdminDelete(false); - entry.setVascAdminEdit(false); - } + // TODO boolean view helper + //if (entry.isVascDisplayOnly()) { + // entry.setVascAdminCreate(false); + // entry.setVascAdminDelete(false); + // entry.setVascAdminEdit(false); + //} // Set defaults field Id for key ad display if (entry.getPrimaryKeyFieldId()==null) { - entry.setPrimaryKeyFieldId(entry.getVascEntryFields().get(0).getId()); + for (VascEntryField field:entry.getVascEntryFields()) { + if ("id".equalsIgnoreCase(field.getId())) { + entry.setPrimaryKeyFieldId(field.getId()); + break; + } + } + if (entry.getPrimaryKeyFieldId()==null) { + for (VascEntryField field:entry.getVascEntryFields()) { + if ("id".equalsIgnoreCase(field.getId())) { + entry.setPrimaryKeyFieldId(field.getId()); + break; + } + } + } } if (entry.getDisplayNameFieldId()==null) { - entry.setDisplayNameFieldId(entry.getVascEntryFields().get(0).getId()); + entry.setDisplayNameFieldId(entry.getPrimaryKeyFieldId()); } // Check fields int orderIndex = 0; - for (VascEntryField vef:entry.getVascEntryFields()) { + for (VascEntryFieldLocal vef:entry.getVascEntryFieldsLocal()) { String vid = vef.getId(); + + // set manual stuff if (vef.getBackendName()==null) { vef.setBackendName(vid); @@ -91,10 +106,20 @@ public class VascDefaultsFinalizer implements VascEntryConfigFinalizer { vef.setVascEntry(entry); } - if (vef.getOrderIndex()==null) { - vef.setOrderIndex(orderIndex); + if (vef.getOrder()==null) { + vef.setOrder(orderIndex); } orderIndex = orderIndex+100; + if (vef.getOrderCreate()==null) { + vef.setOrderCreate(vef.getOrder()); + } + if (vef.getOrderEdit()==null) { + vef.setOrderEdit(vef.getOrder()); + } + if (vef.getOrderList()==null) { + vef.setOrderList(vef.getOrder()); + } + //if (vef.getDefaultValue()==null) { // vef.setDefaultValue("vasc.entry."+id+"."+vid+".defaultValue"); @@ -150,39 +175,19 @@ public class VascDefaultsFinalizer implements VascEntryConfigFinalizer { //} } - class OrderIndexComparator implements Comparator { - public int compare(VascEntryField v1, VascEntryField v2) { - return v1.getOrderIndex().compareTo(v2.getOrderIndex()); - } - } - Collections.sort(entry.getVascEntryFields(),new OrderIndexComparator()); - - // place primary key in front - int index = 0; - for (VascEntryField vef:entry.getVascEntryFields()) { - if (entry.getPrimaryKeyFieldId().equals(vef.getId())) { - break; - } - index++; - } - if (index==entry.getVascEntryFields().size()) { - // no primarry key found selecting the first field. - index=0; - } - VascEntryField idField = entry.getVascEntryFields().remove(index); - entry.getVascEntryFields().add(0, idField); + // Check if link entries excists - for (VascLinkEntry vle:entry.getVascLinkEntries()) { + for (VascEntryLinkLocal vle:entry.getVascEntryLinksLocal()) { if (vle.getVascEntryId()==null) { throw new IllegalArgumentException("All VascLinkEntry need an vascEntryId: "+id); } if (vle.getVascLinkEntryType()==null) { - vle.setVascLinkEntryType(VascLinkEntryType.DEFAULT_TYPE); + vle.setVascLinkEntryType(VascEntryLinkType.DEFAULT_TYPE); } } - for (VascEntryField vef:entry.getListOptions()) { + for (VascEntryListOptionLocal vef:entry.getVascEntryListOptionsLocal()) { String vid = vef.getId(); // set manual stuff if (vef.getBackendName()==null) { @@ -191,10 +196,19 @@ public class VascDefaultsFinalizer implements VascEntryConfigFinalizer { if (vef.getVascEntry()==null) { vef.setVascEntry(entry); } - if (vef.getOrderIndex()==null) { - vef.setOrderIndex(orderIndex); + if (vef.getOrder()==null) { + vef.setOrder(orderIndex); } orderIndex = orderIndex+100; + if (vef.getOrderCreate()==null) { + vef.setOrderCreate(vef.getOrder()); + } + if (vef.getOrderEdit()==null) { + vef.setOrderEdit(vef.getOrder()); + } + if (vef.getOrderList()==null) { + vef.setOrderList(vef.getOrder()); + } //if (vef.getDefaultValue()==null) { // vef.setDefaultValue("vasc.entry."+id+"."+vid+".defaultValue"); diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/config/VascHelpIdFinalizer.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/config/VascHelpIdFinalizer.java index 0d9ce93..a0ba58f 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/config/VascHelpIdFinalizer.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/config/VascHelpIdFinalizer.java @@ -23,13 +23,13 @@ package net.forwardfire.vasc.impl.entry.config; import net.forwardfire.vasc.core.VascController; -import net.forwardfire.vasc.core.VascEntry; -import net.forwardfire.vasc.core.VascEntryField; -import net.forwardfire.vasc.core.VascEntryFieldSet; +import net.forwardfire.vasc.core.VascEntryFieldLocal; import net.forwardfire.vasc.core.VascEntryConfigFinalizer; +import net.forwardfire.vasc.core.VascEntryFieldSetLocal; +import net.forwardfire.vasc.core.VascEntryLinkLocal; +import net.forwardfire.vasc.core.VascEntryLocal; import net.forwardfire.vasc.core.VascException; -import net.forwardfire.vasc.core.VascLinkEntry; -import net.forwardfire.vasc.core.actions.VascAction; +import net.forwardfire.vasc.core.actions.VascActionLocal; /** * VascHelpIdFinalizer copies the (optional)capitalized Id's into helpId field. @@ -45,48 +45,48 @@ public class VascHelpIdFinalizer implements VascEntryConfigFinalizer { /** * @see net.forwardfire.vasc.core.VascEntryConfigFinalizer#configVascEntry(net.forwardfire.vasc.core.VascController, net.forwardfire.vasc.core.VascEntry) */ - public void configVascEntry(VascController vascController, VascEntry entry) throws VascException { + public void configVascEntry(VascController vascController, VascEntryLocal entry) throws VascException { String id = entry.getId(); if (entry.getHelpId()==null) { entry.setHelpId(format(entry.getId())); } - for (VascEntryFieldSet s:entry.getVascEntryFieldSets()) { + for (VascEntryFieldSetLocal s:entry.getVascEntryFieldSetsLocal()) { if (s.getHelpId()==null) { s.setHelpId(format(id,s.getId())); } } - for (VascEntryField vef:entry.getVascEntryFields()) { + for (VascEntryFieldLocal vef:entry.getVascEntryFieldsLocal()) { if (vef.getHelpId()==null) { vef.setHelpId(format(id,vef.getId())); } } - for (VascLinkEntry vle:entry.getVascLinkEntries()) { + for (VascEntryLinkLocal vle:entry.getVascEntryLinksLocal()) { if (vle.getHelpId()==null) { vle.setHelpId(format(id,vle.getId())); } } - for (VascEntryField vef:entry.getListOptions()) { + for (VascEntryFieldLocal vef:entry.getVascEntryListOptionsLocal()) { if (vef.getHelpId()==null) { vef.setHelpId(format(id,vef.getId())); } } - for (VascAction action:entry.getGlobalActions()) { + for (VascActionLocal action:entry.getGlobalActionsLocal()) { if (action.getHelpId()==null) { action.setHelpId(format(id,action.getId())); } } - for (VascAction action:entry.getExportActions()) { + for (VascActionLocal action:entry.getExportActionsLocal()) { if (action.getHelpId()==null) { action.setHelpId(format(id,action.getId())); } } - for (VascAction action:entry.getRowActions()) { + for (VascActionLocal action:entry.getRowActionsLocal()) { if (action.getHelpId()==null) { action.setHelpId(format(id,action.getId())); } } - for (VascAction action:entry.getColumnActions()) { + for (VascActionLocal action:entry.getColumnActionsLocal()) { if (action.getHelpId()==null) { action.setHelpId(format(id,action.getId())); } diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/config/VascI18nFinalizer.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/config/VascI18nFinalizer.java index 4effaf1..1afb6ee 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/config/VascI18nFinalizer.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/config/VascI18nFinalizer.java @@ -23,13 +23,13 @@ package net.forwardfire.vasc.impl.entry.config; import net.forwardfire.vasc.core.VascController; -import net.forwardfire.vasc.core.VascEntry; -import net.forwardfire.vasc.core.VascEntryField; -import net.forwardfire.vasc.core.VascEntryFieldSet; +import net.forwardfire.vasc.core.VascEntryFieldLocal; import net.forwardfire.vasc.core.VascEntryConfigFinalizer; +import net.forwardfire.vasc.core.VascEntryFieldSetLocal; +import net.forwardfire.vasc.core.VascEntryLinkLocal; +import net.forwardfire.vasc.core.VascEntryLocal; import net.forwardfire.vasc.core.VascException; -import net.forwardfire.vasc.core.VascLinkEntry; -import net.forwardfire.vasc.core.actions.VascAction; +import net.forwardfire.vasc.core.actions.VascActionLocal; /** * VascI18NFinalizer fills all missing i18n fields. @@ -42,7 +42,7 @@ public class VascI18nFinalizer implements VascEntryConfigFinalizer { /** * @see net.forwardfire.vasc.core.VascEntryConfigFinalizer#configVascEntry(net.forwardfire.vasc.core.VascController, net.forwardfire.vasc.core.VascEntry) */ - public void configVascEntry(VascController vascController, VascEntry entry) throws VascException { + public void configVascEntry(VascController vascController, VascEntryLocal entry) throws VascException { // Fill up all not field i18n keys String id = entry.getId(); @@ -80,7 +80,7 @@ public class VascI18nFinalizer implements VascEntryConfigFinalizer { } // Field sets - for (VascEntryFieldSet s:entry.getVascEntryFieldSets()) { + for (VascEntryFieldSetLocal s:entry.getVascEntryFieldSetsLocal()) { String sid = s.getId(); if (s.getName()==null) { s.setName("vasc.entry."+id+"."+sid+".name"); @@ -94,7 +94,7 @@ public class VascI18nFinalizer implements VascEntryConfigFinalizer { } // Check fields - for (VascEntryField vef:entry.getVascEntryFields()) { + for (VascEntryFieldLocal vef:entry.getVascEntryFieldsLocal()) { String vid = vef.getId(); if (vef.getName()==null) { vef.setName("vasc.entry."+id+"."+vid+".name"); @@ -107,13 +107,13 @@ public class VascI18nFinalizer implements VascEntryConfigFinalizer { } } - for (VascLinkEntry vle:entry.getVascLinkEntries()) { + for (VascEntryLinkLocal vle:entry.getVascEntryLinksLocal()) { if (vle.getName()==null) { vle.setName("vasc.entry."+vle.getVascEntryId()+".name"); } } - for (VascEntryField vef:entry.getListOptions()) { + for (VascEntryFieldLocal vef:entry.getVascEntryListOptionsLocal()) { String vid = vef.getId(); if (vef.getName()==null) { vef.setName("vasc.entry."+id+"."+vid+".name"); @@ -126,7 +126,7 @@ public class VascI18nFinalizer implements VascEntryConfigFinalizer { } } - for (VascAction action:entry.getGlobalActions()) { + for (VascActionLocal action:entry.getGlobalActionsLocal()) { String aid = action.getId(); if (aid==null) { throw new IllegalArgumentException("Action has no id: "+action+" in entryId: "+id); @@ -141,7 +141,7 @@ public class VascI18nFinalizer implements VascEntryConfigFinalizer { action.setImage("vasc.action."+aid+".image"); } } - for (VascAction action:entry.getExportActions()) { + for (VascActionLocal action:entry.getExportActionsLocal()) { String aid = action.getId(); if (aid==null) { throw new IllegalArgumentException("Action has no id: "+action+" in entryId: "+id); @@ -156,7 +156,7 @@ public class VascI18nFinalizer implements VascEntryConfigFinalizer { action.setImage("vasc.action."+aid+".image"); } } - for (VascAction action:entry.getRowActions()) { + for (VascActionLocal action:entry.getRowActionsLocal()) { String aid = action.getId(); if (aid==null) { throw new IllegalArgumentException("Action has no id: "+action+" in entryId: "+id); @@ -171,7 +171,7 @@ public class VascI18nFinalizer implements VascEntryConfigFinalizer { action.setImage("vasc.action."+aid+".image"); } } - for (VascAction action:entry.getColumnActions()) { + for (VascActionLocal action:entry.getColumnActionsLocal()) { String aid = action.getId(); if (aid==null) { throw new IllegalArgumentException("Action has no id: "+action+" in entryId: "+id); diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/config/VascIdAutoFinalizer.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/config/VascIdAutoFinalizer.java index 9af21af..14d7606 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/config/VascIdAutoFinalizer.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/config/VascIdAutoFinalizer.java @@ -23,13 +23,13 @@ package net.forwardfire.vasc.impl.entry.config; import net.forwardfire.vasc.core.VascController; -import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntryField; import net.forwardfire.vasc.core.VascEntryFieldSet; import net.forwardfire.vasc.core.VascEntryConfigFinalizer; +import net.forwardfire.vasc.core.VascEntryLinkLocal; +import net.forwardfire.vasc.core.VascEntryLocal; import net.forwardfire.vasc.core.VascException; -import net.forwardfire.vasc.core.VascLinkEntry; -import net.forwardfire.vasc.core.actions.VascAction; +import net.forwardfire.vasc.core.actions.VascActionLocal; /** * VascAutoIdFinalizer fills the missing id automaticly. @@ -44,7 +44,7 @@ public class VascIdAutoFinalizer implements VascEntryConfigFinalizer { /** * @see net.forwardfire.vasc.core.VascEntryConfigFinalizer#configVascEntry(net.forwardfire.vasc.core.VascController, net.forwardfire.vasc.core.VascEntry) */ - public void configVascEntry(VascController vascController, VascEntry entry) throws VascException { + public void configVascEntry(VascController vascController, VascEntryLocal entry) throws VascException { // count all auto objects as one index int index = 0; @@ -52,7 +52,7 @@ public class VascIdAutoFinalizer implements VascEntryConfigFinalizer { if (id==null) { throw new IllegalArgumentException("The VascEntry need an id."); } - for (VascEntryField vef:entry.getListOptions()) { + for (VascEntryField vef:entry.getVascEntryListOptions()) { if (vef.getId()==null) { vef.setId(format(id,"list",""+index++)); } @@ -63,7 +63,7 @@ public class VascIdAutoFinalizer implements VascEntryConfigFinalizer { s.setId(format(id,"fieldset",""+index++)); } } - for (VascLinkEntry vle:entry.getVascLinkEntries()) { + for (VascEntryLinkLocal vle:entry.getVascEntryLinksLocal()) { String vid = vle.getId(); if (vid==null) { if (vle.getVascEntryId()==null) { @@ -73,25 +73,25 @@ public class VascIdAutoFinalizer implements VascEntryConfigFinalizer { } } } - for (VascAction action:entry.getGlobalActions()) { + for (VascActionLocal action:entry.getGlobalActionsLocal()) { String aid = action.getId(); if (aid==null) { action.setId(format(id,"action",""+index++)); } } - for (VascAction action:entry.getExportActions()) { + for (VascActionLocal action:entry.getExportActionsLocal()) { String aid = action.getId(); if (aid==null) { action.setId(format(id,"action",""+index++)); } } - for (VascAction action:entry.getRowActions()) { + for (VascActionLocal action:entry.getRowActionsLocal()) { String aid = action.getId(); if (aid==null) { action.setId(format(id,"action",""+index++)); } } - for (VascAction action:entry.getColumnActions()) { + for (VascActionLocal action:entry.getColumnActionsLocal()) { String aid = action.getId(); if (aid==null) { action.setId(format(id,"action",""+index++)); diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/config/VascIdCheckFinalizer.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/config/VascIdCheckFinalizer.java index 0470f65..cec8c71 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/config/VascIdCheckFinalizer.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/config/VascIdCheckFinalizer.java @@ -24,12 +24,12 @@ package net.forwardfire.vasc.impl.entry.config; import net.forwardfire.vasc.backend.VascBackend; import net.forwardfire.vasc.core.VascController; -import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntryField; import net.forwardfire.vasc.core.VascEntryFieldSet; import net.forwardfire.vasc.core.VascEntryConfigFinalizer; +import net.forwardfire.vasc.core.VascEntryLocal; import net.forwardfire.vasc.core.VascException; -import net.forwardfire.vasc.core.VascLinkEntry; +import net.forwardfire.vasc.core.VascEntryLink; import net.forwardfire.vasc.core.actions.VascAction; /** @@ -43,7 +43,7 @@ public class VascIdCheckFinalizer implements VascEntryConfigFinalizer { /** * @see net.forwardfire.vasc.core.VascEntryConfigFinalizer#configVascEntry(net.forwardfire.vasc.core.VascController, net.forwardfire.vasc.core.VascEntry) */ - public void configVascEntry(VascController vascController, VascEntry entry) throws VascException { + public void configVascEntry(VascController vascController, VascEntryLocal entry) throws VascException { // First Check if we all have ids String id = entry.getId(); @@ -58,7 +58,7 @@ public class VascIdCheckFinalizer implements VascEntryConfigFinalizer { throw new IllegalArgumentException("All VascEntryField need an id in entryId: "+id); } } - for (VascEntryField vef:entry.getListOptions()) { + for (VascEntryField vef:entry.getVascEntryListOptions()) { if (vef.getId()==null) { throw new IllegalArgumentException("All listOption VascEntryField to have an id in entryId: "+id); } @@ -86,7 +86,7 @@ public class VascIdCheckFinalizer implements VascEntryConfigFinalizer { } // Check if link entries excists - for (VascLinkEntry vle:entry.getVascLinkEntries()) { + for (VascEntryLink vle:entry.getVascEntryLinks()) { String vid = vle.getId(); if (vid==null) { throw new IllegalArgumentException("All VascLinkEntry need an id in entryId: "+id); diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/export/JRDynamicDataSourceVascEntry.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/export/JRDynamicDataSourceVascEntry.java index 75f32ea..2873fa6 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/export/JRDynamicDataSourceVascEntry.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/export/JRDynamicDataSourceVascEntry.java @@ -59,16 +59,16 @@ public class JRDynamicDataSourceVascEntry extends AbstractJRDynamicDataSource { throw new NullPointerException("vascEntry can't be null."); } this.vascEntry = vascEntry; - total = vascEntry.getVascFrontendData().getVascEntryState().getTotalBackendRecords(); + total = vascEntry.getVascFrontendController().getVascEntryState().getTotalBackendRecords(); // hackje until calc index to page and row. try { data = new ArrayList>(1000); - int pages = (int)total/vascEntry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageSize(); + int pages = (int)total/vascEntry.getVascFrontendController().getVascEntryState().getVascBackendState().getPageSize(); for (int page=0;page<=pages;page++) { - vascEntry.getVascFrontendData().getVascEntryState().getVascBackendState().setPageIndex(page); - vascEntry.getVascFrontendData().getVascFrontendActions().refreshData(); - for (Object o:vascEntry.getVascFrontendData().getVascEntryState().getEntryDataList()) { + vascEntry.getVascFrontendController().getVascEntryState().getVascBackendState().setPageIndex(page); + vascEntry.getVascFrontendController().getVascFrontendActions().refreshData(); + for (Object o:vascEntry.getVascFrontendController().getVascEntryState().getEntryDataList()) { List row = new ArrayList(30); for (VascEntryField c:vascEntry.getVascEntryFields()) { row.add(c.getVascEntryFieldValue().getDisplayValue(c, o)); @@ -90,9 +90,10 @@ public class JRDynamicDataSourceVascEntry extends AbstractJRDynamicDataSource { return data.get(index).get(Integer.parseInt(fieldName.substring(7))); } if (fieldName.startsWith(PREFIX_HEADER)) { - List fields = vascEntry.getVascEntryFields(); - VascEntryField field = fields.get(Integer.parseInt(fieldName.substring(7))); - return vascEntry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(field.getName()); + return "todo"; // TODO: fixme + //List fields = vascEntry.getVascEntryFields(); + //VascEntryField field = fields.get(Integer.parseInt(fieldName.substring(7))); + //return vascEntry.getVascFrontendController().getVascEntryResourceResolver().getTextValue(field.getName()); } throw new JRException("Unknown column name : " + fieldName); } diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/export/VascEntryExporterCsv.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/export/VascEntryExporterCsv.java index 2ba6c5a..4376247 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/export/VascEntryExporterCsv.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/export/VascEntryExporterCsv.java @@ -59,13 +59,13 @@ public class VascEntryExporterCsv implements VascEntryExporter { } p.write("\n"); - int oldIndex = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageIndex(); - Long total = entry.getVascFrontendData().getVascEntryState().getTotalBackendRecords(); - int pages = total.intValue()/entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageSize(); + int oldIndex = entry.getVascFrontendController().getVascEntryState().getVascBackendState().getPageIndex(); + Long total = entry.getVascFrontendController().getVascEntryState().getTotalBackendRecords(); + int pages = total.intValue()/entry.getVascFrontendController().getVascEntryState().getVascBackendState().getPageSize(); for (int page=0;page<=pages;page++) { - entry.getVascFrontendData().getVascEntryState().getVascBackendState().setPageIndex(page); - entry.getVascFrontendData().getVascFrontendActions().refreshData(); - for (Object o:entry.getVascFrontendData().getVascEntryState().getEntryDataList()) { + entry.getVascFrontendController().getVascEntryState().getVascBackendState().setPageIndex(page); + entry.getVascFrontendController().getVascFrontendActions().refreshData(); + for (Object o:entry.getVascFrontendController().getVascEntryState().getEntryDataList()) { for (VascEntryField c:entry.getVascEntryFields()) { p.write(c.getVascEntryFieldValue().getDisplayValue(c, o)+"\t"); } @@ -77,7 +77,7 @@ public class VascEntryExporterCsv implements VascEntryExporter { p.flush(); // restore old page size - entry.getVascFrontendData().getVascEntryState().getVascBackendState().setPageIndex(oldIndex); + entry.getVascFrontendController().getVascEntryState().getVascBackendState().setPageIndex(oldIndex); } diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/export/VascEntryExporterJR4O.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/export/VascEntryExporterJR4O.java index 066ef02..3d6abf7 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/export/VascEntryExporterJR4O.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/export/VascEntryExporterJR4O.java @@ -88,12 +88,12 @@ public class VascEntryExporterJR4O implements VascEntryExporter { public void doExport(OutputStream out, VascEntry entry) throws VascException { Map parameters = new HashMap(5); - parameters.put("title", entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(entry.getName())); - parameters.put("description", entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(entry.getListDescription())); - parameters.put("titleSubject", entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(entry.getId())); + parameters.put("title", entry.getVascFrontendController().getVascEntryResourceResolver().getTextValue(entry.getName())); + parameters.put("description", entry.getVascFrontendController().getVascEntryResourceResolver().getTextValue(entry.getListDescription())); + parameters.put("titleSubject", entry.getVascFrontendController().getVascEntryResourceResolver().getTextValue(entry.getId())); - int oldIndex = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageIndex(); - String bundle = entry.getVascFrontendData().getVascController().getVascEntryConfigController().getResourceBundle(); + int oldIndex = entry.getVascFrontendController().getVascEntryState().getVascBackendState().getPageIndex(); + String bundle = entry.getVascFrontendController().getVascController().getVascEntryConfigController().getResourceBundle(); JRDynamicDataSourceVascEntry dataSource = new JRDynamicDataSourceVascEntry(entry); JR4ODesignManager jr4o = new JR4ODesignManager(dataSource,bundle,parameters); try { @@ -108,7 +108,7 @@ public class VascEntryExporterJR4O implements VascEntryExporter { } catch (Exception e) { throw new VascException(e); } finally { - entry.getVascFrontendData().getVascEntryState().getVascBackendState().setPageIndex(oldIndex); // restore page index + entry.getVascFrontendController().getVascEntryState().getVascBackendState().setPageIndex(oldIndex); // restore page index } } diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/export/VascEntryExporterXml.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/export/VascEntryExporterXml.java index 5d2d8d5..7c6df8f 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/export/VascEntryExporterXml.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/export/VascEntryExporterXml.java @@ -57,13 +57,13 @@ public class VascEntryExporterXml implements VascEntryExporter { p.write("\n"); p.write("\n"); - int oldIndex = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageIndex(); - Long total = entry.getVascFrontendData().getVascEntryState().getTotalBackendRecords(); - int pages = total.intValue()/entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageSize(); + int oldIndex = entry.getVascFrontendController().getVascEntryState().getVascBackendState().getPageIndex(); + Long total = entry.getVascFrontendController().getVascEntryState().getTotalBackendRecords(); + int pages = total.intValue()/entry.getVascFrontendController().getVascEntryState().getVascBackendState().getPageSize(); for (int page=0;page<=pages;page++) { - entry.getVascFrontendData().getVascEntryState().getVascBackendState().setPageIndex(page); - entry.getVascFrontendData().getVascFrontendActions().refreshData(); - for (Object o:entry.getVascFrontendData().getVascEntryState().getEntryDataList()) { + entry.getVascFrontendController().getVascEntryState().getVascBackendState().setPageIndex(page); + entry.getVascFrontendController().getVascFrontendActions().refreshData(); + for (Object o:entry.getVascFrontendController().getVascEntryState().getEntryDataList()) { p.write("\t\n"); for (VascEntryField c:entry.getVascEntryFields()) { if (xmlTree) { @@ -84,7 +84,7 @@ public class VascEntryExporterXml implements VascEntryExporter { p.flush(); // restore old page size - entry.getVascFrontendData().getVascEntryState().getVascBackendState().setPageIndex(oldIndex); + entry.getVascFrontendController().getVascEntryState().getVascBackendState().setPageIndex(oldIndex); } /** diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendActions.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendActions.java new file mode 100644 index 0000000..bef47b4 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendActions.java @@ -0,0 +1,321 @@ +/* + * 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.frontend; + +import java.util.Date; +import java.util.logging.Logger; + +import net.forwardfire.vasc.backend.VascBackendFilter; +import net.forwardfire.vasc.backend.VascBackendState; +import net.forwardfire.vasc.core.VascEntry; +import net.forwardfire.vasc.core.VascEntryField; +import net.forwardfire.vasc.core.VascEntryLocal; +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 void init(VascEntry entry) { + this.entry=entry; + } + + /** + * @see net.forwardfire.vasc.frontend.VascFrontendHelper#initEditObject(net.forwardfire.vasc.core.VascEntry) + */ + public Object createObject() { + try { + entry.getVascFrontendController().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.PRE_CREATE, null); + Object object = entry.getVascFrontendController().getVascEntryState().getVascBackend().provideVascEntryRecordCreator(((VascEntryLocal)entry).clone()).newRecord(entry); // TODO fixme + 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.getVascFrontendController().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.POST_CREATE, object); + return object; + } catch (Exception e) { + entry.getVascFrontendController().getVascFrontendHelper().handleException(entry,e); + return null; /// ?? ,, + } + } + + protected int removeObjectFromDataList(Object object) { + int indexOld = entry.getVascFrontendController().getVascEntryState().getEntryDataList().indexOf(object); + if (entry.getVascFrontendController().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.getVascFrontendController().getVascEntryState().getEntryDataList()) { + field = entry.getVascEntryFieldById(entry.getPrimaryKeyFieldId()); + Object id = field.getVascEntryFieldValue().getValue(field, o); + if (idObject.equals(id)) { + break; + } + index++; + } + if (index backendState.getPageSizeMax()) { + backendState.setPageSize(backendState.getPageSizeMax()); + } + + // Clear and copy parameters to backend state for query. + backendState.removeDataParameterAll(); + for (String key:entry.getEntryParameterKeys()) { + Object value = entry.getEntryParameter(key); + backendState.setDataParameter(key, value); + } + + // Update total every time first + Long total = entry.getVascFrontendController().getVascEntryState().getVascBackend().fetchTotalExecuteSize(backendState); + entry.getVascFrontendController().getVascEntryState().setTotalBackendRecords(total); + + // Execute to get data. + entry.getVascFrontendController().getVascEntryState().setEntryDataList(entry.getVascFrontendController().getVascEntryState().getVascBackend().execute(backendState)); + + // check if we need to change the current page + int pages = new Long(total/backendState.getPageSize()).intValue(); + if (backendState.getPageIndex() > pages) { + backendState.setPageIndex(pages); + entry.getVascFrontendController().getVascEntryState().setEntryDataList(entry.getVascFrontendController().getVascEntryState().getVascBackend().execute(backendState)); + } + + + } catch (Exception e) { + entry.getVascFrontendController().getVascFrontendHelper().handleException(entry, e); + } + entry.getVascFrontendController().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.POST_READ, null); + } + + + public void sortAction(VascEntryField field) { + String curSort = entry.getVascFrontendController().getVascEntryState().getVascBackendState().getSortField(); + if (field.getBackendName().equals(curSort)) { + entry.getVascFrontendController().getVascEntryState().getVascBackendState().setSortAscending(!entry.getVascFrontendController().getVascEntryState().getVascBackendState().isSortAscending()); + } + String sortID = field.getBackendName(); + entry.getVascFrontendController().getVascEntryState().getVascBackendState().setSortField(sortID); + entry.getVascFrontendController().getVascEntryState().getVascBackendState().setPageIndex(0); + entry.getVascFrontendController().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.SORT, field); + + refreshData(); + try { + entry.getVascFrontendController().getVascFrontend().renderView(); + } catch (Exception e) { + entry.getVascFrontendController().getVascFrontendHelper().handleException(entry, e); + } + } + + public void searchAction(String searchString) { + entry.getVascFrontendController().getVascEntryState().getVascBackendState().setSearchString(searchString); + entry.getVascFrontendController().getVascEntryState().getVascBackendState().setSortField(null); + entry.getVascFrontendController().getVascEntryState().getVascBackendState().setPageIndex(0); + entry.getVascFrontendController().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.SEARCH, searchString); + + refreshData(); + + try { + entry.getVascFrontendController().getVascFrontend().renderView(); + } catch (Exception e) { + entry.getVascFrontendController().getVascFrontendHelper().handleException(entry, e); + } + } + + public void pageAction(Integer pageIndex) { + if (pageIndex<1) { + pageIndex = 0; + } + Long total = entry.getVascFrontendController().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.getVascFrontendController().getVascEntryState().getVascBackendState().getPageSize())) { + pageIndex = new Long(total/entry.getVascFrontendController().getVascEntryState().getVascBackendState().getPageSize()).intValue(); + } + + entry.getVascFrontendController().getVascEntryState().getVascBackendState().setPageIndex(pageIndex); + entry.getVascFrontendController().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.PAGE, pageIndex); + + // lets load data; + refreshData(); + + try { + entry.getVascFrontendController().getVascFrontend().renderView(); + } catch (Exception e) { + entry.getVascFrontendController().getVascFrontendHelper().handleException(entry, e); + } + } + + public void moveUpAction(Object record) { + if (entry.getVascFrontendController().getVascEntryState().getVascBackend().isRecordMoveable()) { + try { + VascEntryField p = entry.getVascEntryFieldById(entry.getPrimaryKeyFieldId()); + Object primaryId = p.getVascEntryFieldValue().getValue(p, record); + entry.getVascFrontendController().getVascEntryState().getVascBackend().doRecordMoveUpById(entry.getVascFrontendController().getVascEntryState().getVascBackendState(),primaryId); + } catch (Exception e) { + entry.getVascFrontendController().getVascFrontendHelper().handleException(entry, e); + } + + // lets load data; + refreshData(); + } + + try { + entry.getVascFrontendController().getVascFrontend().renderView(); + } catch (Exception e) { + entry.getVascFrontendController().getVascFrontendHelper().handleException(entry, e); + } + } + + public void moveDownAction(Object record) { + if (entry.getVascFrontendController().getVascEntryState().getVascBackend().isRecordMoveable()) { + try { + VascEntryField p = entry.getVascEntryFieldById(entry.getPrimaryKeyFieldId()); + Object primaryId = p.getVascEntryFieldValue().getValue(p, record); + entry.getVascFrontendController().getVascEntryState().getVascBackend().doRecordMoveDownById(entry.getVascFrontendController().getVascEntryState().getVascBackendState(),primaryId); + } catch (Exception e) { + entry.getVascFrontendController().getVascFrontendHelper().handleException(entry, e); + } + // lets load data; + refreshData(); + } + + try { + entry.getVascFrontendController().getVascFrontend().renderView(); + } catch (Exception e) { + entry.getVascFrontendController().getVascFrontendHelper().handleException(entry, e); + } + } +} \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendController.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendController.java new file mode 100644 index 0000000..6c07bfe --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendController.java @@ -0,0 +1,413 @@ +/* + * 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.frontend; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import net.forwardfire.vasc.core.VascController; +import net.forwardfire.vasc.core.VascEntry; +import net.forwardfire.vasc.core.VascEntryField; +import net.forwardfire.vasc.core.VascEntryConfigFinalizer; +import net.forwardfire.vasc.core.VascEntryLocal; +import net.forwardfire.vasc.core.VascEntryState; +import net.forwardfire.vasc.core.VascException; +import net.forwardfire.vasc.core.actions.ColumnVascActionLocal; +import net.forwardfire.vasc.core.actions.GlobalVascActionLocal; +import net.forwardfire.vasc.core.actions.RowVascActionLocal; +import net.forwardfire.vasc.core.actions.VascActionLocal; +import net.forwardfire.vasc.core.entry.VascEntryFieldValidatorService; +import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener; +import net.forwardfire.vasc.core.entry.VascEntryResourceImageResolver; +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.frontend.VascFrontend; +import net.forwardfire.vasc.frontend.VascFrontendActions; +import net.forwardfire.vasc.frontend.VascFrontendControllerLocal; +import net.forwardfire.vasc.frontend.VascFrontendDataSelector; +import net.forwardfire.vasc.frontend.VascFrontendHelper; +import net.forwardfire.vasc.frontend.VascFrontendPager; +import net.forwardfire.vasc.frontend.VascFrontendUserController; +import net.forwardfire.vasc.frontend.VascFrontendUserSettingController; + + +/** + * Stores state data for the frontend + * + * @author Willem Cazander + * @version 1.0 Mar 21, 2007 + */ +public class DefaultVascFrontendController implements VascFrontendControllerLocal { + + private VascFrontend vascFrontend = null; + private VascFrontendActions vascFrontendActions = null; + private VascFrontendPager vascFrontendPager = null; + private VascEntryConfigFinalizer vascEntryFinalizer = null; + private VascFrontendHelper vascFrontendHelper = null; + private VascEntryResourceResolver vascEntryResourceResolver = null; + private VascEntryResourceImageResolver vascEntryResourceImageResolver = null; + private Map uiComponents = null; + private VascController vascController = null; + private Map> vascEntryFrontendEventListeners = null; + private VascEntryState state = null; + private VascFrontendDataSelector vascFrontendDataSelector = null; + private VascFrontendUserController vascFrontendUserController = null; + private VascFrontendUserSettingController vascFrontendUserSettingController = null; + + + private Map fieldComps = null; + private Map fieldEditors = null; + private List validatorServices = null; + + public DefaultVascFrontendController() { + uiComponents = new HashMap(8); + fieldComps = new HashMap(8); + fieldEditors = new HashMap(8); + validatorServices = new ArrayList(4); + vascEntryFrontendEventListeners = new HashMap>(10); + } + + /** + * @return the vascFrontend + */ + public VascFrontend getVascFrontend() { + return vascFrontend; + } + + /** + * @param vascFrontend the vascFrontend to set + */ + public void setVascFrontend(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() + */ + public VascEntryConfigFinalizer getVascEntryFinalizer() { + return vascEntryFinalizer; + } + + /** + * @see net.forwardfire.vasc.core.VascBackendData#setVascEntryFinalizer(net.forwardfire.vasc.core.VascEntryConfigFinalizer) + */ + public void setVascEntryFinalizer(VascEntryConfigFinalizer vascEntryFinalizer) { + this.vascEntryFinalizer=vascEntryFinalizer; + } + + /** + * @return the vascFrontendHelper + */ + public VascFrontendHelper getVascFrontendHelper() { + return vascFrontendHelper; + } + + /** + * @param vascFrontendHelper the vascFrontendHelper to set + */ + public void setVascFrontendHelper(VascFrontendHelper vascFrontendHelper) { + this.vascFrontendHelper = vascFrontendHelper; + } + + /** + * @return the vascEntryResourceResolver + */ + public VascEntryResourceResolver getVascEntryResourceResolver() { + return vascEntryResourceResolver; + } + + /** + * @param vascEntryResourceResolver the vascEntryResourceResolver to set + */ + public void setVascEntryResourceResolver(VascEntryResourceResolver vascEntryResourceResolver) { + this.vascEntryResourceResolver = vascEntryResourceResolver; + } + + + public VascUIComponent getVascUIComponent(String rendererId) throws VascException { + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + if (cl == null) { + cl = rendererId.getClass().getClassLoader(); // fallback + } + String componentClass = getVascUIComponentClass(rendererId); + if (componentClass==null) { + + // TODO: auto wire text <-> object converts + + componentClass = getVascUIComponentClass(VascUIComponent.VASC_TEXT); + } + if (componentClass==null) { + throw new VascException("No component Class found for frontend UIComponent: "+rendererId); + } + try { + return (VascUIComponent)cl.loadClass(componentClass).newInstance(); + } catch (Exception e) { + throw new VascException(e); + } + } + + /** + * @see net.forwardfire.vasc.frontend.VascFrontendController#getVascUIComponent(java.lang.String) + */ + public String getVascUIComponentClass(String rendererId) { + return uiComponents.get(rendererId); + } + + /** + * @see net.forwardfire.vasc.frontend.VascFrontendController#putVascUIComponent(java.lang.String, java.lang.String) + */ + public void putVascUIComponent(String rendererId, String uiComponentClass) { + uiComponents.put(rendererId, uiComponentClass); + } + + /** + * @return the vascController + */ + public VascController getVascController() { + return vascController; + } + + /** + * @param vascController the vascController to set + */ + public void setVascController(VascController vascController) { + this.vascController = vascController; + } + + /** + * @see net.forwardfire.vasc.frontend.VascFrontendController#addFieldVascUIComponents(net.forwardfire.vasc.core.VascEntryField, net.forwardfire.vasc.core.ui.VascUIComponent, java.lang.Object) + */ + public void addFieldVascUIComponents(VascEntryField field,VascUIComponent uiComponent, Object editor) { + fieldComps.put(field, uiComponent); + fieldEditors.put(field, editor); + } + + public void clearFieldRenderObjects() { + fieldComps.clear(); + fieldEditors.clear(); + } + + /** + * @see net.forwardfire.vasc.frontend.VascFrontendController#getFieldRealRenderer(net.forwardfire.vasc.core.VascEntryField) + */ + public Object getFieldRealRenderer(VascEntryField field) { + return fieldEditors.get(field); + } + + /** + * @see net.forwardfire.vasc.frontend.VascFrontendController#getFieldVascUIComponent(net.forwardfire.vasc.core.VascEntryField) + */ + public VascUIComponent getFieldVascUIComponent(VascEntryField field) { + return fieldComps.get(field); + } + + /** + * @return the vascEntryResourceImageResolver + */ + public VascEntryResourceImageResolver getVascEntryResourceImageResolver() { + return vascEntryResourceImageResolver; + } + + /** + * @param vascEntryResourceImageResolver the vascEntryResourceImageResolver to set + */ + public void setVascEntryResourceImageResolver(VascEntryResourceImageResolver vascEntryResourceImageResolver) { + this.vascEntryResourceImageResolver = vascEntryResourceImageResolver; + } + + /** + * @see net.forwardfire.vasc.frontend.VascFrontendController#addVascValidatorService(net.forwardfire.vasc.core.entry.VascEntryFieldValidatorService) + */ + public void addVascValidatorService(VascEntryFieldValidatorService validatorService) { + validatorServices.add(validatorService); + } + + /** + * @see net.forwardfire.vasc.frontend.VascFrontendController#getVascValidatorServices() + */ + public List getVascValidatorServices() { + return validatorServices; + } + + public VascEntryState getVascEntryState() { + return state; + } + + public void setVascEntryState(VascEntryState state) { + this.state=state; + } + + // TODO move to config + public void initFrontendListeners(VascEntryLocal entry,String frontendType) throws InstantiationException, IllegalAccessException { + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + if (cl==null) { + cl = entry.getClass().getClassLoader(); + } + for (String clazz:entry.getVascEntryFrontendEventListenersByType(frontendType)) { + VascEntryFrontendEventListener listener; + try { + listener = (VascEntryFrontendEventListener)cl.loadClass(clazz).newInstance(); + } catch (ClassNotFoundException e) { + throw new RuntimeException("Could not load VascEntryFrontendEventListener of: "+clazz); + } + addVascEntryFrontendEventListener(listener); + } + + for (String clazz:entry.getVascEntryFrontendActionsByType(frontendType)) { + Object obj = null; + try { + obj = cl.loadClass(clazz).newInstance(); + } catch (ClassNotFoundException e) { + throw new RuntimeException("Could not load frontend action of: "+clazz); + } + if (obj instanceof VascActionLocal) { + VascActionLocal action = (VascActionLocal)obj; + String aid = action.getId(); + if (aid==null) { + throw new IllegalArgumentException("Action has no id: "+action+" in entryId: "+entry.getId()); + } + if (action.getName()==null) { + action.setName("vasc.action."+aid+".name"); + } + if (action.getDescription()==null) { + action.setDescription("vasc.action."+aid+".description"); + } + if (action.getImage()==null) { + action.setImage("vasc.action."+aid+".image"); + } + if (action.getHelpId()==null) { + action.setHelpId("vasc.action."+aid+".helpId"); + } + } + + if (obj instanceof RowVascActionLocal) { + entry.addRowAction((RowVascActionLocal)obj); + } + if (obj instanceof ColumnVascActionLocal) { + entry.addColumnAction((ColumnVascActionLocal)obj); + } + if (obj instanceof GlobalVascActionLocal) { + entry.addGlobalAction((GlobalVascActionLocal)obj); + } + } + } + + public void addVascEntryFrontendEventListener(VascEntryFrontendEventListener listener) { + for (VascEntryFrontendEventListener.VascFrontendEventType type:listener.getEventTypes()) { + List list = vascEntryFrontendEventListeners.get(type); + if (list==null) { + list = new ArrayList(10); + vascEntryFrontendEventListeners.put(type, list); + } + list.add(listener); + } + } + + public List getVascEntryFrontendEventListener(VascEntryFrontendEventListener.VascFrontendEventType type) { + List list = vascEntryFrontendEventListeners.get(type); + if (list==null) { + return new ArrayList(0); + } + return list; + } + + public void fireVascFrontendEvent(VascEntry entry,VascFrontendEventType type, Object data) { + List list = getVascEntryFrontendEventListener(type); + for (VascEntryFrontendEventListener l:list) { + l.vascEvent(entry, data); + } + } + + /** + * @return the vascFrontendDataSelector + */ + public VascFrontendDataSelector getVascFrontendDataSelector() { + return vascFrontendDataSelector; + } + + /** + * @param vascFrontendDataSelector the vascFrontendDataSelector to set + */ + public void setVascFrontendDataSelector(VascFrontendDataSelector vascFrontendDataSelector) { + this.vascFrontendDataSelector = vascFrontendDataSelector; + } + + /** + * @return the vascFrontendUserController + */ + public VascFrontendUserController getVascFrontendUserController() { + return vascFrontendUserController; + } + + /** + * @param vascFrontendUserController the vascFrontendUserController to set + */ + public void setVascFrontendUserController(VascFrontendUserController vascFrontendUserController) { + this.vascFrontendUserController = vascFrontendUserController; + } + + /** + * @return the vascFrontendUserSettingController + */ + public VascFrontendUserSettingController getVascFrontendUserSettingController() { + return vascFrontendUserSettingController; + } + + /** + * @param vascFrontendUserSettingController the vascFrontendUserSettingController to set + */ + public void setVascFrontendUserSettingController(VascFrontendUserSettingController vascFrontendUserSettingController) { + this.vascFrontendUserSettingController = vascFrontendUserSettingController; + } +} \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendDataSelector.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendDataSelector.java new file mode 100644 index 0000000..e22d358 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendDataSelector.java @@ -0,0 +1,147 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.impl.frontend; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + +import net.forwardfire.vasc.core.VascEntry; +import net.forwardfire.vasc.core.VascEntryField; +import net.forwardfire.vasc.core.actions.VascAction; +import net.forwardfire.vasc.frontend.VascFrontendDataSelector; + + +/** + * DefaultVascFrontendDataSelector orders and filters out vasc data. + * + * @author Willem Cazander + * @version 1.0 Jun 1, 2012 + */ +public class DefaultVascFrontendDataSelector implements VascFrontendDataSelector { + + private VascEntry entry = null; + + public void init(VascEntry entry) { + this.entry=entry; + } + + public boolean isActionAllowed(VascAction action) { + return true; + } + + + public boolean isFieldView(VascEntryField field) { + if (field.getView()==false) { + return false; + } + return true; + } + + public boolean isFieldCreate(VascEntryField field) { + if (isFieldView(field)==false) { + return false; + } + //VascUserRoleController u = field.getVascEntry().getVascFrontendData().getVascController().getVascUserRoleController(); + //if (field.getRolesCreate()!=null && u.hasRole(field.getRolesCreate())) { + // return true; + //} + if (field.getCreate()) { + return true; + } + return false; + } + public boolean isFieldEdit(VascEntryField field) { + if (isFieldView(field)==false) { + return false; + } + if (field.getEdit()) { + return true; + } + return false; + } + public boolean isFieldEditReadOnly(VascEntryField field) { + if (isFieldView(field)==false) { + return false; + } + if (field.getEditReadOnly()) { + return true; + } + return false; + } + public boolean isFieldList(VascEntryField field) { + if (isFieldView(field)==false) { + return false; + } + if (field.getList()) { + return true; + } + return false; + } + + /* + + class OrderIndexComparator implements Comparator { + public int compare(VascEntryField v1, VascEntryField v2) { + return v1.getOrderIndex().compareTo(v2.getOrderIndex()); + } + } + Collections.sort(entry.getVascEntryFields(),new OrderIndexComparator()); + + + // place primary key in front + int index = 0; + for (VascEntryField vef:entry.getVascEntryFields()) { + if (entry.getPrimaryKeyFieldId().equals(vef.getId())) { + break; + } + index++; + } + if (index==entry.getVascEntryFields().size()) { + // no primarry key found selecting the first field. + index=0; + } + VascEntryField idField = entry.getVascEntryFields().remove(index); + entry.getVascEntryFields().add(0, idField); + + */ + + public List getFieldsList() { + List result = new ArrayList(50); + result.addAll(entry.getVascEntryFields()); + return result; + } + + public List getFieldsCreate() { + List result = new ArrayList(50); + result.addAll(entry.getVascEntryFields()); + return result; + } + + public List getFieldsEdit() { + List result = new ArrayList(50); + result.addAll(entry.getVascEntryFields()); + return result; + } +} \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendHelper.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendHelper.java new file mode 100644 index 0000000..af98c1e --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendHelper.java @@ -0,0 +1,236 @@ +/* + * 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.frontend; + +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Logger; + +import net.forwardfire.vasc.core.VascEntry; +import net.forwardfire.vasc.core.VascEntryField; +import net.forwardfire.vasc.core.VascException; +import net.forwardfire.vasc.core.VascEntryLink; +import net.forwardfire.vasc.core.VascEntryLinkType; +import net.forwardfire.vasc.core.actions.RowVascAction; +import net.forwardfire.vasc.core.entry.VascEntryFieldValidatorService; +import net.forwardfire.vasc.core.entry.VascEntryFieldValue; +import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener.VascFrontendEventType; +import net.forwardfire.vasc.core.ui.VascUIComponent; +import net.forwardfire.vasc.frontend.VascFrontendHelper; + +/** + * + * @author Willem Cazander + * @version 1.0 Apr 28, 2007 + */ +public class DefaultVascFrontendHelper implements VascFrontendHelper { + + private Logger logger = Logger.getLogger(DefaultVascFrontendHelper.class.getName()); + + /** + * @see net.forwardfire.vasc.frontend.VascFrontendHelper#getTotalColumnsWidth(net.forwardfire.vasc.core.VascEntry) + */ + public Integer getTotalColumnsWidth(VascEntry entry) { + int result = 0; + for(VascEntryField c:entry.getVascEntryFields()) { + if(c.getSizeList()==null) { + logger.finer("Column no size: "+c.getName()); + } else { + result+=c.getSizeList(); + } + } + return result; + } + + public List getVascLinkEntryByType(VascEntry entry,VascEntryLinkType type) { + List result = new ArrayList(10); + for (VascEntryLink link:entry.getVascEntryLinks()) { + if (type==null) { + result.add(link); + continue; + } + if (type.equals(link.getVascLinkEntryType())) { + result.add(link); + } + } + return result; + } + + /** + * @see net.forwardfire.vasc.frontend.VascFrontendHelper#handleException(net.forwardfire.vasc.core.VascEntry,java.lang.Exception) + */ + public void handleException(VascEntry entry,Exception exception) { + entry.getVascFrontendController().fireVascFrontendEvent(entry,VascFrontendEventType.EXCEPTION , exception); + } + + public void headerOptionsCreatedFillData(VascEntry entry) { + + // fix conv defs of options to object. ? + + entry.getVascFrontendController().getVascFrontendActions().refreshData(); + } + + /** + * @see net.forwardfire.vasc.frontend.VascFrontendHelper#validateObjectField(net.forwardfire.vasc.core.VascEntryField, java.lang.Object) + */ + public List validateObjectField(VascEntryField field) { + if (field==null) { + throw new NullPointerException("Can't validate null field."); + } + VascEntry entry = field.getVascEntry(); + if (entry.getVascFrontendController().getVascEntryState().getEntryDataObject()==null) { + throw new NullPointerException("Can't validate null entry object."); + } + List error = new ArrayList(3); + + // skip non-create and non-edit fields + if (entry.getVascFrontendController().getVascFrontendDataSelector().isFieldCreate(field) == false & + entry.getVascFrontendController().getVascEntryState().isEditCreate()) { + return error; + } + if (entry.getVascFrontendController().getVascFrontendDataSelector().isFieldEditReadOnly(field) & + entry.getVascFrontendController().getVascEntryState().isEditCreate()==false) { + return error; + } + + try { + Object objectSelected = entry.getVascFrontendController().getVascEntryState().getEntryDataObject(); + Object objectValue = field.getVascEntryFieldValue().getValue(field, objectSelected); + for (VascEntryFieldValidatorService s:entry.getVascFrontendController().getVascValidatorServices()) { + error.addAll(s.validateObjectField(field, objectSelected, objectValue)); + } + } catch (VascException e) { + handleException(entry, e); + } + return error; + } + + /** + * + */ + public boolean validateAndSetErrorText(VascEntry entry) { + boolean hadError = false; + for (VascEntryField field:entry.getVascEntryFields()) { + VascUIComponent comp = entry.getVascFrontendController().getFieldVascUIComponent(field); + List error = validateObjectField(field); + logger.info("Check field: "+field.getId()+" comp: "+comp+" Errors: "+error.size()); + if (error.isEmpty()) { + if (comp!=null) { + comp.setErrorText(null); + } + continue; + } + if (comp==null) { + logger.warning("Field: "+field.getId()+" gives errors but no UI component to display."); + continue; + } + hadError=true; + StringBuffer buf = new StringBuffer(100); + for (String s:error) { + buf.append(s); + buf.append('\n'); + } + comp.setErrorText(buf.toString()); + } + return hadError; + } + + public void editReadOnlyUIComponents(VascEntry entry) { + // reset edit read only + for (VascEntryField field:entry.getVascEntryFields()) { + if (entry.getVascFrontendController().getFieldVascUIComponent(field)==null) { + continue; + } + + // TODO: move back to rendered when jsf fixes + if (entry.getVascFrontendController().getVascFrontendDataSelector().isFieldCreate(field) == false & + entry.getVascFrontendController().getVascEntryState().isEditCreate()) { + //entry.getVascFrontendData().getFieldVascUIComponent(f).setRendered(false); + entry.getVascFrontendController().getFieldVascUIComponent(field).setDisabled(true); + } else { + //entry.getVascFrontendData().getFieldVascUIComponent(f).setRendered(true); + entry.getVascFrontendController().getFieldVascUIComponent(field).setDisabled(false); + } + + // only when editing set edit readonlys + if (entry.getVascFrontendController().getVascFrontendDataSelector().isFieldEditReadOnly(field) & + entry.getVascFrontendController().getVascEntryState().isEditCreate()==false) { + entry.getVascFrontendController().getFieldVascUIComponent(field).setDisabled(true); + } else { + if (entry.getVascFrontendController().getVascEntryState().isEditCreate()==false) { // todo: remove when jsf fixes + entry.getVascFrontendController().getFieldVascUIComponent(field).setDisabled(false); + } + } + } + } + + public List getMultiRowActions(VascEntry entry) { + List result = new ArrayList(5); + for (RowVascAction a:entry.getRowActions()) { + if (a.isMultiRowAction()) { + result.add(a); + } + } + return result; + } + + public String getSelectedDisplayName(VascEntry entry) { + Object row = entry.getVascFrontendController().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.getVascFrontendController().getVascEntryState().getParent()==null) { + return ""; // no parent + } + + VascEntry parent = entry.getVascFrontendController().getVascEntryState().getParent().getVascEntry(); + Object row = entry.getVascFrontendController().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; + } + + + +} \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendPager.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendPager.java new file mode 100644 index 0000000..92d1033 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendPager.java @@ -0,0 +1,241 @@ +/* + * 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.frontend; + +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 pagers + * + * @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 pagesAll = null; + + public void init(VascEntry entry) { + this.entry=entry; + pagesAll = new ArrayList(0); + entry.getVascFrontendController().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.getVascFrontendController().getVascEntryState().getTotalBackendRecords(); + return result; + } + public long getPageSize() { + long result = entry.getVascFrontendController().getVascEntryState().getVascBackendState().getPageSize(); + return result; + } + public long getPageStartCount() { + int index = entry.getVascFrontendController().getVascEntryState().getVascBackendState().getPageIndex(); + int pageSize = entry.getVascFrontendController().getVascEntryState().getVascBackendState().getPageSize(); + long result = index*pageSize; + return result; + } + public long getPageStopCount() { + int index = entry.getVascFrontendController().getVascEntryState().getVascBackendState().getPageIndex(); + int pageSize = entry.getVascFrontendController().getVascEntryState().getVascBackendState().getPageSize(); + long result = (index*pageSize)+pageSize; + + // limit for small result sets. + if (result>entry.getVascFrontendController().getVascEntryState().getTotalBackendRecords()) { + result = entry.getVascFrontendController().getVascEntryState().getTotalBackendRecords(); + } + return result; + } + + public boolean getHasPageNextAction() { + int pageIndex = entry.getVascFrontendController().getVascEntryState().getVascBackendState().getPageIndex(); + pageIndex++; + // copyed from helper + Long total = entry.getVascFrontendController().getVascEntryState().getTotalBackendRecords(); + if (total!=null && pageIndex>(total/entry.getVascFrontendController().getVascEntryState().getVascBackendState().getPageSize())) { + return false; + } + return true; + } + + public boolean getHasPagePreviousAction() { + int pageIndex = entry.getVascFrontendController().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.getVascFrontendController().getVascEntryState().getVascBackendState().getPageIndex(); + if (page<5) { + return false; + } + int pages = pagesAll.size(); + if (page>pages-6) { + return false; + } + return true; + } + + public List getTablePagesFromBackend() { + List result = new ArrayList(30); + VascBackendState state = entry.getVascFrontendController().getVascEntryState().getVascBackendState(); + if (state.getPageSize()==0) { + return result; // paging disabled + } + Long total = entry.getVascFrontendController().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 getTablePagesNormal() { + if (getHasExtendedPageMode()) { + return new ArrayList(0); + } else { + return pagesAll; + } + } + + public List getTablePagesExtendedBegin() { + List result = new ArrayList(6); + if (pagesAll.size()>0) { + result.add(pagesAll.get(0)); + } + if (pagesAll.size()>1) { + result.add(pagesAll.get(1)); + } + if (pagesAll.size()>2) { + result.add(pagesAll.get(2)); + } + if (pagesAll.size()<=3) { + return result; + } + int page = entry.getVascFrontendController().getVascEntryState().getVascBackendState().getPageIndex(); + if (page==2 | page==3 | page==4) { + if (pagesAll.size()>3) { + result.add(pagesAll.get(3)); + } + } + if (page==3 | page==4) { + if (pagesAll.size()>4) { + result.add(pagesAll.get(4)); + } + } + if (page==4) { + if (pagesAll.size()>5) { + result.add(pagesAll.get(5)); + } + } + return result; + } + + public List getTablePagesExtendedEnd() { + List result = new ArrayList(6); + int pages = pagesAll.size(); + int page = entry.getVascFrontendController().getVascEntryState().getVascBackendState().getPageIndex(); + int off = pages-page; + + if (off==5 && pagesAll.size() > pages-6 && pages-6 > 0) { + result.add(pagesAll.get(pages-6)); + } + if ((off==4 | off==5) && pagesAll.size() > pages-5 && pages-5 > 0) { + result.add(pagesAll.get(pages-5)); + } + if ((off==3 | off==4 | off==5) && pagesAll.size() > pages-4 && pages-6 > 4) { + result.add(pagesAll.get(pages-4)); + } + + if (pages>4 && pagesAll.size() >= pages-1 && pages-1 > 0) { + result.add(pagesAll.get(pages-3)); + result.add(pagesAll.get(pages-2)); + result.add(pagesAll.get(pages-1)); + } + return result; + } + + public List getTablePagesExtendedCenter() { + List result = new ArrayList(3); + int page = entry.getVascFrontendController().getVascEntryState().getVascBackendState().getPageIndex(); + if (page>0 && pagesAll.size() > page-1) { + result.add(pagesAll.get(page-1)); + } + if (pagesAll.size() > page) { + result.add(pagesAll.get(page)); + } + if (pagesAll.size() > page+1) { + result.add(pagesAll.get(page+1)); + } + return result; + } +} \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DummyVascFrontendUserController.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DummyVascFrontendUserController.java new file mode 100644 index 0000000..b4cfd5e --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DummyVascFrontendUserController.java @@ -0,0 +1,73 @@ +/* + * 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.frontend; + +import java.util.Locale; + +import net.forwardfire.vasc.frontend.VascFrontendUserController; + + +/** + * DummyVascFrontendUserController + * + * + * @author Willem Cazander + * @version 1.0 Jun 1, 2012 + */ +public class DummyVascFrontendUserController implements VascFrontendUserController { + + /** + * @see net.forwardfire.vasc.frontend.VascFrontendUserController#isUser() + */ + public boolean isUser() { + return false; + } + + /** + * @see net.forwardfire.vasc.frontend.VascFrontendUserController#getUserId() + */ + public Object getUserId() { + return null; + } + + /** + * @see net.forwardfire.vasc.frontend.VascFrontendUserController#getUserName() + */ + public String getUserName() { + return ""; + } + + /** + * @see net.forwardfire.vasc.frontend.VascFrontendUserController#getUserLocale() + */ + public Locale getUserLocale() { + return Locale.ENGLISH; + } + + /** + * @see net.forwardfire.vasc.frontend.VascFrontendUserController#hasUserRole(java.lang.String) + */ + public boolean hasUserRole(String role) { + return false; + } +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DummyVascFrontendUserSettingController.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DummyVascFrontendUserSettingController.java new file mode 100644 index 0000000..79cdbed --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DummyVascFrontendUserSettingController.java @@ -0,0 +1,36 @@ +/* + * 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.frontend; + +import net.forwardfire.vasc.frontend.VascFrontendUserSettingController; + +/** + * DummyVascFrontendUserSettingController + * + * + * @author Willem Cazander + * @version 1.0 Jun 1, 2012 + */ +public class DummyVascFrontendUserSettingController implements VascFrontendUserSettingController { + +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/jndi/JndiVascControllerFactory.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/jndi/JndiVascControllerFactory.java new file mode 100644 index 0000000..ad57513 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/jndi/JndiVascControllerFactory.java @@ -0,0 +1,166 @@ +/* + * 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.jndi; + +import java.util.Enumeration; +import java.util.Hashtable; +import java.util.List; + +import javax.naming.Context; +import javax.naming.Name; +import javax.naming.RefAddr; +import javax.naming.Reference; +import javax.naming.spi.ObjectFactory; + +import net.forwardfire.vasc.backend.VascBackend; +import net.forwardfire.vasc.backend.VascBackendController; +import net.forwardfire.vasc.backend.VascBackendControllerLocal; +import net.forwardfire.vasc.core.VascController; +import net.forwardfire.vasc.core.VascControllerLocal; +import net.forwardfire.vasc.core.VascControllerProvider; +import net.forwardfire.vasc.core.VascEntry; +import net.forwardfire.vasc.core.VascEntryConfigController; +import net.forwardfire.vasc.core.VascEntryController; +import net.forwardfire.vasc.core.VascEntryControllerLocal; +import net.forwardfire.vasc.core.VascEntryFieldTypeController; +import net.forwardfire.vasc.core.VascEventChannelController; +import net.forwardfire.vasc.impl.DefaultVascFactory; + +/** + * JndiVascControllerFactory puts an new VascController into the jndi context. + * note: needs to be flags as singleton resource ! + * + * TODO: this needs to tested on real tomcat/ee env. + * + * @author Willem Cazander + * @version 1.0 May 18, 2012 + */ +public class JndiVascControllerFactory implements ObjectFactory { + + private VascController vascController = null; + private final static String CONF_PROVIDER = "vascControllerProvider"; + private final static String CONF_REMOVE_LOCAL = "removeLocal"; + + /** + * @see javax.naming.spi.ObjectFactory#getObjectInstance(java.lang.Object, javax.naming.Name, javax.naming.Context, java.util.Hashtable) + */ + public Object getObjectInstance(Object obj, Name name2, Context nameCtx,Hashtable env) throws Exception { + + if (vascController!=null) { + return vascController; + } + + // Fetch config parameters of this factory instance + String configProviderClass = null; + String configRemoveLocal = null; + Reference ref = (Reference) obj; + Enumeration addrs = ref.getAll(); + while (addrs.hasMoreElements()) { + RefAddr addr = (RefAddr) addrs.nextElement(); + String name = addr.getType(); + String value = (String) addr.getContent(); + if (CONF_PROVIDER.equals(name)) { + configProviderClass = value; + } else if (CONF_REMOVE_LOCAL.equals(name)) { + configRemoveLocal = value; + } + } + + // optional config via provider interface. + if (configProviderClass!=null && configProviderClass.isEmpty()==false) { + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + if (cl==null) { + cl = this.getClass().getClassLoader(); + } + Class prioviderClass = cl.loadClass(configProviderClass); + VascControllerProvider provider = (VascControllerProvider)prioviderClass.newInstance(); + vascController = provider.getVascController(); + } + + // Else create default + if (vascController==null) { + vascController = DefaultVascFactory.getDefaultVascController(); + } + + + // Remove all local interfaces of vasc beans so no changes of config are possible. + if (configRemoveLocal!=null && configRemoveLocal.isEmpty()==false && configRemoveLocal.equalsIgnoreCase("true")) { + removeLocalInterfaces(); + } + + return vascController; + } + + /** + * Wrap all local interfaces with non local interfaces. + */ + private void removeLocalInterfaces() { + if ((vascController instanceof VascControllerLocal)==false) { + return; + } + final VascControllerLocal vc = (VascControllerLocal)vascController; + if (vc.getVascBackendController() instanceof VascBackendControllerLocal) { + final VascBackendController backendController = vc.getVascBackendController(); + vc.setVascBackendController(new VascBackendController() { + public List getVascBackendIds() { + return backendController.getVascBackendIds(); + } + public VascBackend getVascBackendById(String id) { + return backendController.getVascBackendById(id); + } + }); + } + if (vc.getVascEntryController() instanceof VascEntryControllerLocal) { + final VascEntryController entryController = vc.getVascEntryController(); + vc.setVascEntryController(new VascEntryController() { + public List getVascEntryIds() { + return entryController.getVascEntryIds(); + } + public VascEntry getVascEntryById(String id) { + return entryController.getVascEntryById(id); + } + }); + } + + // TODO etc + + // Also wrap controller to non-local + vascController = new VascController() { + public VascEventChannelController getVascEventChannelController() { + return vc.getVascEventChannelController(); + } + public VascEntryFieldTypeController getVascEntryFieldTypeController() { + return vc.getVascEntryFieldTypeController(); + } + public VascEntryController getVascEntryController() { + return vc.getVascEntryController(); + } + public VascEntryConfigController getVascEntryConfigController() { + return vc.getVascEntryConfigController(); + } + public VascBackendController getVascBackendController() { + return vc.getVascBackendController(); + } + }; + } +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/jndi/JndiVascControllerProvider.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/jndi/JndiVascControllerProvider.java new file mode 100644 index 0000000..59fd82f --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/jndi/JndiVascControllerProvider.java @@ -0,0 +1,85 @@ +/* + * 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.jndi; + +import javax.naming.InitialContext; +import javax.naming.NamingException; + +import net.forwardfire.vasc.core.VascController; +import net.forwardfire.vasc.core.VascControllerProvider; + +/** + * JndiVascControllerProvider gets the VascController from jndi. + * + * @author Willem Cazander + * @version 1.0 May 16, 2012 + */ +public class JndiVascControllerProvider implements VascControllerProvider { + + private String jndiName = null; + + /** + * Default constructor. + */ + public JndiVascControllerProvider() { + } + + /** + * Constructor for in servlets/etc with "someJndiName@this.class.getName()" notation. + * @param jndiName + */ + public JndiVascControllerProvider(String jndiName) { + setJndiName(jndiName); + } + + /** + * Returns a VascController from jndi context. + * @see net.forwardfire.vasc.core.VascControllerProvider#getVascController() + */ + public VascController getVascController() { + try { + InitialContext context = new InitialContext(); + VascController vascController = (VascController)context.lookup(jndiName); + if (vascController == null) { + throw new NullPointerException("Cannot lookup vascController: "+jndiName); + } + return vascController; + } catch (NamingException e) { + throw new IllegalStateException("Naming error:"+e.getMessage()+" from name: "+jndiName,e); + } + } + + /** + * @return the jndiName + */ + public String getJndiName() { + return jndiName; + } + + /** + * @param jndiName the jndiName to set + */ + public void setJndiName(String jndiName) { + this.jndiName = jndiName; + } +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/type/DefaultVascEntryFieldType.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/type/DefaultVascEntryFieldType.java index ceec625..ef4094f 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/type/DefaultVascEntryFieldType.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/type/DefaultVascEntryFieldType.java @@ -23,34 +23,16 @@ package net.forwardfire.vasc.impl.type; -import net.forwardfire.vasc.core.AbstractVascEntryFieldType; -import net.forwardfire.vasc.core.VascEntryFieldType; +import net.forwardfire.vasc.core.AbstractVascEntryFieldTypeLocal; /** - * Only knows how to clone its self. + * DefaultVascEntryFieldType * * * @author Willem Cazander * @version 1.0 Sep 8, 2008 */ -public class DefaultVascEntryFieldType extends AbstractVascEntryFieldType { - - private static final long serialVersionUID = 1L; - @Override - public VascEntryFieldType clone() throws CloneNotSupportedException { - DefaultVascEntryFieldType clone = new DefaultVascEntryFieldType(); - clone.id=id; - if (objectConverter!=null) { - clone.objectConverter=objectConverter.clone(); - } - clone.autoDetectClass=autoDetectClass; - clone.uiComponentId=uiComponentId; - clone.inputMask=inputMask; - for (String key:properties.keySet()) { - clone.properties.put(key,properties.get(key)); - } - // mmm - clone.vascValidators.addAll(vascValidators); - return clone; - } +public class DefaultVascEntryFieldType extends AbstractVascEntryFieldTypeLocal { + + private static final long serialVersionUID = 6226483336359929394L; } \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/type/DefaultVascEntryFieldTypeController.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/type/DefaultVascEntryFieldTypeController.java index 0be723e..27b9ccd 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/type/DefaultVascEntryFieldTypeController.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/type/DefaultVascEntryFieldTypeController.java @@ -30,6 +30,7 @@ import java.util.Map; import net.forwardfire.vasc.core.VascEntryFieldType; import net.forwardfire.vasc.core.VascEntryFieldTypeControllerLocal; +import net.forwardfire.vasc.core.VascEntryFieldTypeLocal; import net.forwardfire.vasc.core.VascException; @@ -40,15 +41,15 @@ import net.forwardfire.vasc.core.VascException; */ public class DefaultVascEntryFieldTypeController implements VascEntryFieldTypeControllerLocal { - private Map vascEntryFieldTypes = null; + private Map vascEntryFieldTypes = null; public DefaultVascEntryFieldTypeController() throws VascException { try { FieldTypeParser parser = new FieldTypeParser(); parser.parseVascFieldTypes(); - vascEntryFieldTypes = new HashMap(35); - for(VascEntryFieldType v:parser.getTypes()) { + vascEntryFieldTypes = new HashMap(35); + for(VascEntryFieldTypeLocal v:parser.getTypes()) { vascEntryFieldTypes.put(v.getId(),v); } } catch (Exception e) { @@ -59,7 +60,7 @@ public class DefaultVascEntryFieldTypeController implements VascEntryFieldTypeCo /** * */ - public void addVascEntryFieldType(VascEntryFieldType vascEntryFieldType) { + public void addVascEntryFieldType(VascEntryFieldTypeLocal vascEntryFieldType) { if (vascEntryFieldType==null) { throw new NullPointerException("Can't add null vascEntryFieldType."); } @@ -70,7 +71,7 @@ public class DefaultVascEntryFieldTypeController implements VascEntryFieldTypeCo * @see net.forwardfire.vasc.core.VascEntryFieldTypeController#getVascEntryFieldTypeById(java.lang.String) */ public VascEntryFieldType getVascEntryFieldTypeById(String id) { - VascEntryFieldType result = vascEntryFieldTypes.get(id); + VascEntryFieldTypeLocal result = vascEntryFieldTypes.get(id); if (result==null) { throw new IllegalArgumentException("Field not found: "+id); } diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/type/FieldTypeParser.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/type/FieldTypeParser.java index ab95158..ed7a788 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/type/FieldTypeParser.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/type/FieldTypeParser.java @@ -29,7 +29,7 @@ import java.util.List; import javax.xml.parsers.ParserConfigurationException; -import net.forwardfire.vasc.core.VascEntryFieldType; +import net.forwardfire.vasc.core.VascEntryFieldTypeLocal; import org.xml.sax.SAXException; @@ -63,11 +63,11 @@ public class FieldTypeParser extends X4OParser { parseResource("META-INF/fieldtypes.xml"); } - public List getTypes() { - List result = new ArrayList(4); + public List getTypes() { + List result = new ArrayList(40); DefaultObjectConverterProvider convProvider = new DefaultObjectConverterProvider(true); for (Element e:getElementContext().getRootElement().getChilderen()) { - VascEntryFieldType a = (VascEntryFieldType)e.getElementObject(); + VascEntryFieldTypeLocal a = (VascEntryFieldTypeLocal)e.getElementObject(); if (a.getObjectConverter()==null && a.getAutoDetectClass()!=null) { ObjectConverter conv = convProvider.getObjectConverterForClass(a.getAutoDetectClass()); a.setObjectConverter(conv); // move to x4o or finalizer diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/type/MultiTextVascEntryFieldType.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/type/MultiTextVascEntryFieldType.java index 884ac8e..0bb09b2 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/type/MultiTextVascEntryFieldType.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/type/MultiTextVascEntryFieldType.java @@ -25,37 +25,20 @@ package net.forwardfire.vasc.impl.type; import java.util.List; import net.forwardfire.vasc.core.VascEntryField; -import net.forwardfire.vasc.core.VascEntryFieldType; import net.forwardfire.vasc.core.VascException; import net.forwardfire.vasc.core.ui.VascValueModel; - - /** - * Custem FieldType for multi text values. + * Custom FieldType for multi text values. * * @author Willem Cazander * @version 1.0 Nov 17, 2008 */ public class MultiTextVascEntryFieldType extends DefaultVascEntryFieldType { - private static final long serialVersionUID = 1L; - - @Override - public VascEntryFieldType clone() throws CloneNotSupportedException { - MultiTextVascEntryFieldType clone = new MultiTextVascEntryFieldType(); - clone.id=id; - clone.autoDetectClass=autoDetectClass; - clone.uiComponentId=uiComponentId; - clone.inputMask=inputMask; - for (String key:properties.keySet()) { - clone.properties.put(key,properties.get(key)); - } - // mmm - clone.vascValidators.addAll(vascValidators); - return clone; - } + private static final long serialVersionUID = -5990597417468690400L; + /* private Object getIndexValue(VascEntryField entryField,int index) throws VascException { @@ -105,7 +88,8 @@ public class MultiTextVascEntryFieldType extends DefaultVascEntryFieldType { throw new VascException("Unknown object type: "+value); } */ - + + /** * @see net.forwardfire.vasc.core.AbstractVascEntryFieldType#getUIComponentCount(net.forwardfire.vasc.core.VascEntryField) */ diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/ui/VascSelectItemModelEntry.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/ui/VascSelectItemModelEntry.java index 443cfa7..9c0bb9f 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/ui/VascSelectItemModelEntry.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/ui/VascSelectItemModelEntry.java @@ -31,6 +31,8 @@ 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.VascEntryFieldLocal; +import net.forwardfire.vasc.core.VascEntryLocal; import net.forwardfire.vasc.core.VascException; import net.forwardfire.vasc.core.entry.VascEntryFieldValue; import net.forwardfire.vasc.core.ui.VascSelectItem; @@ -51,6 +53,7 @@ public class VascSelectItemModelEntry implements VascSelectItemModel { private String displayFieldId = null; private String nullLabel = null; private String nullKeyValue = null; + private String nullObjectValue = null; private Boolean returnKeyValue = null; private Map entryParameterFieldIds = new HashMap(3); private Boolean useParentFields = null; @@ -60,17 +63,17 @@ public class VascSelectItemModelEntry implements VascSelectItemModel { */ public List getVascSelectItems(VascEntry currentEntry) throws VascException { List result = new ArrayList(100); - VascEntry entry = currentEntry.getVascFrontendData().getVascController().getVascEntryController().getVascEntryById(entryId); + VascEntryLocal entry = (VascEntryLocal)currentEntry.getVascFrontendController().getVascController().getVascEntryController().getVascEntryById(entryId); if (keyFieldId==null) { keyFieldId = entry.getPrimaryKeyFieldId(); } - VascEntryField key = entry.getVascEntryFieldById(keyFieldId); + VascEntryFieldLocal key = (VascEntryFieldLocal)entry.getVascEntryFieldById(keyFieldId); if (displayFieldId==null) { displayFieldId = entry.getDisplayNameFieldId(); } - VascEntryField dis = entry.getVascEntryFieldById(displayFieldId); + VascEntryFieldLocal dis = (VascEntryFieldLocal)entry.getVascEntryFieldById(displayFieldId); if (key==null) { throw new VascException("Could not find: "+keyFieldId+" from: "+entry.getId()); } @@ -79,16 +82,19 @@ public class VascSelectItemModelEntry implements VascSelectItemModel { } // set frontend data for new clone, we need te get better lifecycle management for stats/entry/etc - entry.setVascFrontendData(currentEntry.getVascFrontendData()); - VascBackend back = currentEntry.getVascFrontendData().getVascController().getVascEntryConfigController().configVascBackendProxied(currentEntry.getVascFrontendData().getVascController(), entry); + entry.setVascFrontendController(currentEntry.getVascFrontendController()); + VascBackend back = currentEntry.getVascFrontendController().getVascController().getVascEntryConfigController().configVascBackendProxied(currentEntry.getVascFrontendController().getVascController(), 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); + nullLabel = currentEntry.getVascFrontendController().getVascEntryResourceResolver().getTextValue(nullLabel); + if (nullObjectValue==null) { + result.add(new VascSelectItem(nullLabel,null,nullKeyValue)); + } else { + result.add(new VascSelectItem(nullLabel,nullObjectValue,nullKeyValue)); + } } // set def para @@ -101,7 +107,7 @@ public class VascSelectItemModelEntry implements VascSelectItemModel { } // set list para - for (VascEntryField vef:entry.getListOptions()) { + for (VascEntryField vef:entry.getVascEntryListOptions()) { Object def = vef.getDefaultValue(); if (def==null) { continue; @@ -115,23 +121,23 @@ public class VascSelectItemModelEntry implements VascSelectItemModel { VascEntry fieldEntry = currentEntry; if (useParentFields!=null && useParentFields==true) { - if (currentEntry.getVascFrontendData().getVascEntryState().getParent()==null) { + if (currentEntry.getVascFrontendController().getVascEntryState().getParent()==null) { throw new IllegalStateException("Requested to use parent state field values but no parent state found."); } - fieldEntry = currentEntry.getVascFrontendData().getVascEntryState().getParent().getVascEntry(); + fieldEntry = currentEntry.getVascFrontendController().getVascEntryState().getParent().getVascEntry(); } String paraValueId = entryParameterFieldIds.get(paraName); - VascEntryField fieldOrg = fieldEntry.getVascEntryFieldById(paraValueId); + VascEntryFieldLocal fieldOrg = (VascEntryFieldLocal)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); + VascEntryFieldValue v = fieldEntry.getVascFrontendController().getVascEntryState().getVascBackend().provideVascEntryFieldValue(field); - Object record = fieldEntry.getVascFrontendData().getVascEntryState().getEntryDataObject(); + Object record = fieldEntry.getVascFrontendController().getVascEntryState().getEntryDataObject(); if (record==null) { //System.out.println("could not get selected records from state."); continue; @@ -149,7 +155,7 @@ public class VascSelectItemModelEntry implements VascSelectItemModel { VascEntryField fieldClone = key.clone(); fieldClone.getVascValidators().clear(); - VascEntryFieldValue v = currentEntry.getVascFrontendData().getVascEntryState().getVascBackend().provideVascEntryFieldValue(fieldClone); + VascEntryFieldValue v = currentEntry.getVascFrontendController().getVascEntryState().getVascBackend().provideVascEntryFieldValue(fieldClone); key.setVascEntryFieldValue(v); } if (dis.getVascEntryFieldValue()==null) { @@ -157,7 +163,7 @@ public class VascSelectItemModelEntry implements VascSelectItemModel { VascEntryField fieldClone = dis.clone(); fieldClone.getVascValidators().clear(); - VascEntryFieldValue v = currentEntry.getVascFrontendData().getVascEntryState().getVascBackend().provideVascEntryFieldValue(fieldClone); + VascEntryFieldValue v = currentEntry.getVascFrontendController().getVascEntryState().getVascBackend().provideVascEntryFieldValue(fieldClone); dis.setVascEntryFieldValue(v); } @@ -287,4 +293,20 @@ public class VascSelectItemModelEntry implements VascSelectItemModel { public void setUseParentFields(Boolean useParentFields) { this.useParentFields = useParentFields; } + + /** + * @return the nullObjectValue + */ + public String getNullObjectValue() { + return nullObjectValue; + } + + /** + * @param nullObjectValue the nullObjectValue to set + */ + public void setNullObjectValue(String nullObjectValue) { + this.nullObjectValue = nullObjectValue; + } + + } \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/ui/VascSelectItemModelStringEnum.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/ui/VascSelectItemModelStringEnum.java index b44207b..7440fde 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/ui/VascSelectItemModelStringEnum.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/ui/VascSelectItemModelStringEnum.java @@ -55,6 +55,15 @@ public class VascSelectItemModelStringEnum implements VascSelectItemModel { public List getVascSelectItems(VascEntry currentEntry) throws VascException { List result = new ArrayList(100); + if (nullLabel!=null) { + if (nullKeyValue==null) { + nullKeyValue = "null"; + } + nullLabel = currentEntry.getVascFrontendController().getVascEntryResourceResolver().getTextValue(nullLabel); + VascSelectItem item = new VascSelectItem(nullLabel,null,nullKeyValue); + result.add(item); + } + if (enumClass!=null) { for (Object o:enumClass.getEnumConstants()) { String value = o.toString(); diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/AnnotationParserElement.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/AnnotationParserElement.java index 5e90320..681c539 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/AnnotationParserElement.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/AnnotationParserElement.java @@ -41,7 +41,10 @@ import net.forwardfire.vasc.annotations.VascEventListener; import net.forwardfire.vasc.core.VascController; import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntryField; +import net.forwardfire.vasc.core.VascEntryFieldLocal; import net.forwardfire.vasc.core.VascEntryFieldType; +import net.forwardfire.vasc.core.VascEntryFieldTypeLocal; +import net.forwardfire.vasc.core.VascEntryLocal; import net.forwardfire.vasc.impl.DefaultVascEntryField; import net.forwardfire.vasc.validators.VascValidator; import net.forwardfire.vasc.validators.VascValidatorClassParser; @@ -76,8 +79,8 @@ public class AnnotationParserElement extends AbstractElement { } VascAnnotationParser parser = new VascAnnotationParser(); - if (parentObject instanceof VascEntry) { - VascEntry entry = (VascEntry)parentObject; + if (parentObject instanceof VascEntryLocal) { + VascEntryLocal entry = (VascEntryLocal)parentObject; fillEntry(entry,modelClass,parser); if (addFields!=null && "false".equals(addFields)) { @@ -85,26 +88,21 @@ public class AnnotationParserElement extends AbstractElement { } else { addFields(entry,modelClass); } - for (VascEntryField field:entry.getVascEntryFields()) { + for (VascEntryFieldLocal field:entry.getVascEntryFieldsLocal()) { fillField(field,modelClass,parser); } entry.setDisplayNameFieldId(parser.getVascDisplayName(modelClass)); entry.setPrimaryKeyFieldId(parser.getVascPrimaryKey(modelClass)); - } else if (parentObject instanceof VascEntryField) { - VascEntryField field = (VascEntryField)parentObject; + } else if (parentObject instanceof VascEntryFieldLocal) { + VascEntryFieldLocal field = (VascEntryFieldLocal)parentObject; fillField(field,modelClass,parser); } else { throw new ElementException("Unknow parent object type: "+parentObject); } } - private void fillEntry(VascEntry entry,Class modelClass,VascAnnotationParser parser) throws ElementException { - - - if (entry.getId()==null) { - - } + private void fillEntry(VascEntryLocal entry,Class modelClass,VascAnnotationParser parser) throws ElementException { VascEventListener vc = parser.getVascEventListener(modelClass); if (vc!=null) { @@ -118,7 +116,7 @@ public class AnnotationParserElement extends AbstractElement { } - private void fillField(VascEntryField field,Class modelClass,VascAnnotationParser parser) { + private void fillField(VascEntryFieldLocal field,Class modelClass,VascAnnotationParser parser) { String value = null; value = parser.getVascFieldBackendName(modelClass, field.getId()); if (value!=null && "".equals(value)==false) { @@ -141,8 +139,17 @@ public class AnnotationParserElement extends AbstractElement { if (field.getHelpId()==null) { field.setHelpId( parser.getVascI18nHelpId (modelClass, field.getId())); } - if (field.getOrderIndex()==null) { - field.setOrderIndex( parser.getVascOrderIndex (modelClass, field.getId())); + if (field.getOrder()==null) { + field.setOrder( parser.getVascOrder (modelClass, field.getId())); + } + if (field.getOrderCreate()==null) { + field.setOrderCreate( parser.getVascOrderCreate (modelClass, field.getId())); + } + if (field.getOrderEdit()==null) { + field.setOrderEdit( parser.getVascOrderEdit (modelClass, field.getId())); + } + if (field.getOrderList()==null) { + field.setOrderList( parser.getVascOrderList (modelClass, field.getId())); } if (field.getCreate()==null) { field.setCreate( parser.getVascFieldCreate (modelClass, field.getId())); @@ -274,7 +281,7 @@ public class AnnotationParserElement extends AbstractElement { if (field.getVascEntryFieldType()==null) { String fieldType = parser.getVascFieldType (modelClass, field.getId()); if (fieldType!=null) { - VascEntryFieldType type = vascController.getVascEntryFieldTypeController().getVascEntryFieldTypeById(fieldType); + VascEntryFieldTypeLocal type = (VascEntryFieldTypeLocal)vascController.getVascEntryFieldTypeController().getVascEntryFieldTypeById(fieldType); field.setVascEntryFieldType(type); // copy properties @@ -391,7 +398,7 @@ public class AnnotationParserElement extends AbstractElement { } - private void addFields(VascEntry entry,Class modelClass) { + private void addFields(VascEntryLocal entry,Class modelClass) { for (Method method:modelClass.getMethods()) { if (method.getName().startsWith("get")==false) { //a bit durty continue; @@ -413,7 +420,7 @@ public class AnnotationParserElement extends AbstractElement { } String fieldId = method.getName().substring(3,4).toLowerCase()+method.getName().substring(4); - VascEntryField field = new DefaultVascEntryField(); + VascEntryFieldLocal field = new DefaultVascEntryField(); field.setId(fieldId); if (entry.getVascEntryFieldById(fieldId)==null) { diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/SetParameterElement.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/SetParameterElement.java index b6bc293..7a0fbd2 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/SetParameterElement.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/SetParameterElement.java @@ -24,8 +24,7 @@ package net.forwardfire.vasc.impl.x4o; import java.util.logging.Logger; - -import net.forwardfire.vasc.core.VascEntry; +import net.forwardfire.vasc.core.VascEntryLocal; import org.x4o.xml.element.AbstractElement; import org.x4o.xml.element.ElementException; @@ -48,7 +47,7 @@ public class SetParameterElement extends AbstractElement { String name = getAttributes().get("name"); String value = getAttributes().get("value"); String type = getAttributes().get("type"); - VascEntry entry = (VascEntry)getParent().getElementObject(); + VascEntryLocal entry = (VascEntryLocal)getParent().getElementObject(); logger.fine("Setting parameter name: "+name+" value: "+value+" type: "+type); if ("setUserParameter".equals(getElementClass().getTag())) { diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/VascEntryActionElement.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/VascEntryActionElement.java index e2db1bf..97297d5 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/VascEntryActionElement.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/VascEntryActionElement.java @@ -21,11 +21,11 @@ */ package net.forwardfire.vasc.impl.x4o; - import net.forwardfire.vasc.core.VascEntry; -import net.forwardfire.vasc.core.actions.ColumnVascAction; -import net.forwardfire.vasc.core.actions.GlobalVascAction; -import net.forwardfire.vasc.core.actions.RowVascAction; +import net.forwardfire.vasc.core.VascEntryLocal; +import net.forwardfire.vasc.core.actions.ColumnVascActionLocal; +import net.forwardfire.vasc.core.actions.GlobalVascActionLocal; +import net.forwardfire.vasc.core.actions.RowVascActionLocal; import org.x4o.xml.core.X4OParser; import org.x4o.xml.element.AbstractElement; @@ -56,7 +56,7 @@ public class VascEntryActionElement extends AbstractElement { if (getParent().getElementObject() instanceof VascEntry==false) { throw new ElementException("Parent object is not vasc entry."); } - VascEntry v = (VascEntry)getParent().getElementObject(); + VascEntryLocal v = (VascEntryLocal)getParent().getElementObject(); if ("backend".equalsIgnoreCase(type)) { Object obj = null; try { @@ -65,14 +65,14 @@ public class VascEntryActionElement extends AbstractElement { } catch (Exception e) { throw new ElementException("Could not load class: "+clazz); } - if (obj instanceof RowVascAction) { - v.addRowAction((RowVascAction)obj); + if (obj instanceof RowVascActionLocal) { + v.addRowAction((RowVascActionLocal)obj); } - if (obj instanceof ColumnVascAction) { - v.addColumnAction((ColumnVascAction)obj); + if (obj instanceof ColumnVascActionLocal) { + v.addColumnAction((ColumnVascActionLocal)obj); } - if (obj instanceof GlobalVascAction) { - v.addGlobalAction((GlobalVascAction)obj); + if (obj instanceof GlobalVascActionLocal) { + v.addGlobalAction((GlobalVascActionLocal)obj); } } else if ("frontend".equalsIgnoreCase(type)) { v.addVascEntryFrontendAction(clazz, frontendType); diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/VascEntryElementConfigurator.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/VascEntryElementConfigurator.java index 359bc60..52be4e4 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/VascEntryElementConfigurator.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/VascEntryElementConfigurator.java @@ -23,9 +23,9 @@ package net.forwardfire.vasc.impl.x4o; import net.forwardfire.vasc.core.VascController; -import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntryController; import net.forwardfire.vasc.core.VascEntryControllerLocal; +import net.forwardfire.vasc.core.VascEntryLocal; import org.x4o.xml.element.AbstractElementConfigurator; import org.x4o.xml.element.Element; @@ -43,7 +43,7 @@ public class VascEntryElementConfigurator extends AbstractElementConfigurator { * @see org.x4o.xml.element.AbstractElementConfigurator#doConfigEndTag(org.x4o.xml.element.Element) */ public void doConfigElement(Element element) throws ElementConfiguratorException { - VascEntry entry = (VascEntry)element.getElementObject(); + VascEntryLocal entry = (VascEntryLocal)element.getElementObject(); VascController vascController = VascParser.getVascController(element.getElementContext()); VascEntryController entryController = vascController.getVascEntryController(); diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/VascEntryFieldBindingHandler.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/VascEntryFieldBindingHandler.java index 5f23d07..c19420e 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/VascEntryFieldBindingHandler.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/VascEntryFieldBindingHandler.java @@ -22,9 +22,9 @@ package net.forwardfire.vasc.impl.x4o; - -import net.forwardfire.vasc.core.VascEntry; -import net.forwardfire.vasc.core.VascEntryField; +import net.forwardfire.vasc.core.VascEntryFieldLocal; +import net.forwardfire.vasc.core.VascEntryListOptionLocal; +import net.forwardfire.vasc.core.VascEntryLocal; import org.x4o.xml.element.AbstractElementBindingHandler; import org.x4o.xml.element.Element; @@ -50,8 +50,9 @@ public class VascEntryFieldBindingHandler extends AbstractElementBindingHandler Object child = element.getElementObject(); boolean p = false; boolean c = false; - if (parent instanceof VascEntry) { p=true; } - if (child instanceof VascEntryField) { c=true; } + if (parent instanceof VascEntryLocal) { p=true; } + if (child instanceof VascEntryFieldLocal) { c=true; } + if (child instanceof VascEntryListOptionLocal) { c=true; } if (p&c) { return true; } else { return false; } } @@ -61,15 +62,15 @@ public class VascEntryFieldBindingHandler extends AbstractElementBindingHandler public void doBind(Element element) throws ElementBindingHandlerException { Object childObject = element.getElementObject(); Object parentObject = element.getParent().getElementObject(); - if (parentObject instanceof VascEntry) { - VascEntry parent = (VascEntry)parentObject; - if (childObject instanceof VascEntryField) { - VascEntryField child = (VascEntryField) childObject; - if (element.getElementClass().getTag().equals("listOption")) { - parent.addListOption(child); - } else { - parent.addVascEntryField(child); - } + if (parentObject instanceof VascEntryLocal) { + VascEntryLocal parent = (VascEntryLocal)parentObject; + if (childObject instanceof VascEntryFieldLocal) { + VascEntryFieldLocal child = (VascEntryFieldLocal) childObject; + parent.addVascEntryField(child); + } + if (childObject instanceof VascEntryListOptionLocal) { + VascEntryListOptionLocal child = (VascEntryListOptionLocal) childObject; + parent.addVascEntryListOption(child); } } } diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/VascEntryFieldConfigurator.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/VascEntryFieldConfigurator.java index c9e288d..ee28215 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/VascEntryFieldConfigurator.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/VascEntryFieldConfigurator.java @@ -23,16 +23,15 @@ package net.forwardfire.vasc.impl.x4o; import net.forwardfire.vasc.core.VascController; -import net.forwardfire.vasc.core.VascEntryField; +import net.forwardfire.vasc.core.VascEntryFieldLocal; import net.forwardfire.vasc.core.VascEntryFieldType; import org.x4o.xml.element.AbstractElementConfigurator; import org.x4o.xml.element.Element; import org.x4o.xml.element.ElementConfiguratorException; - /** - * Maps the vasc + * VascEntryFieldConfigurator * * @author Willem Cazander * @version 1.0 Jan 20, 2012 @@ -52,6 +51,6 @@ public class VascEntryFieldConfigurator extends AbstractElementConfigurator { } VascController controller = VascParser.getVascController(element.getElementContext()); VascEntryFieldType result = controller.getVascEntryFieldTypeController().getVascEntryFieldTypeById(fieldID); - ((VascEntryField)element.getElementObject()).setVascEntryFieldType(result); + ((VascEntryFieldLocal)element.getElementObject()).setVascEntryFieldType(result); } } \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/VascEntryFieldSetElement.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/VascEntryFieldSetElement.java index 36231da..a03656b 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/VascEntryFieldSetElement.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/VascEntryFieldSetElement.java @@ -22,8 +22,7 @@ package net.forwardfire.vasc.impl.x4o; - -import net.forwardfire.vasc.core.VascEntryFieldSet; +import net.forwardfire.vasc.core.VascEntryFieldSetLocal; import org.x4o.xml.element.AbstractElement; import org.x4o.xml.element.ElementException; @@ -51,7 +50,7 @@ public class VascEntryFieldSetElement extends AbstractElement { } String[] ids = parameterValue.toString().split(","); - VascEntryFieldSet set = (VascEntryFieldSet)getElementObject(); + VascEntryFieldSetLocal set = (VascEntryFieldSetLocal)getElementObject(); for (String id:ids) { set.addVascEntryFieldId(id); } diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/VascEntryLinkParameterElement.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/VascEntryLinkParameterElement.java new file mode 100644 index 0000000..3a050ac --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/VascEntryLinkParameterElement.java @@ -0,0 +1,65 @@ +/* + * 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.x4o; + +import net.forwardfire.vasc.core.VascEntryLinkLocal; +import net.forwardfire.vasc.impl.ui.VascSelectItemModelEntry; + +import org.x4o.xml.element.AbstractElement; +import org.x4o.xml.element.ElementException; + +/** + * Adds the link is paramets + * + * @author Willem Cazander + * @version 1.0 Jun 09, 2009 + */ +public class VascEntryLinkParameterElement extends AbstractElement { + + /** + * @see org.x4o.xml.element.AbstractElement#doElementRun() + */ + @Override + public void doElementRun() throws ElementException { + String valueFieldId = getAttributes().get("valueFieldId"); + String parameterName = getAttributes().get("name"); + String selectedFieldId = getAttributes().get("selectedFieldId"); + + if (getParent().getElementObject() instanceof VascSelectItemModelEntry) { + VascSelectItemModelEntry m = (VascSelectItemModelEntry)getParent().getElementObject(); + m.addEntryParameterFieldId(parameterName, valueFieldId); + return; + } + if (getParent().getElementObject() instanceof VascEntryLinkLocal) { + VascEntryLinkLocal link = (VascEntryLinkLocal)getParent().getElementObject(); + if (parameterName!=null) { + // normal parameter + link.addEntryParameterFieldId(parameterName, valueFieldId); + } else { + link.addEntryCreateFieldValue(valueFieldId,selectedFieldId); + } + return; + } + throw new ElementException("Unsupported parent object: "+getParent().getElementObject()); + } +} \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/VascEventListenerElement.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/VascEventListenerElement.java index cebd244..c3c72c0 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/VascEventListenerElement.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/VascEventListenerElement.java @@ -22,8 +22,7 @@ package net.forwardfire.vasc.impl.x4o; - -import net.forwardfire.vasc.core.VascEntry; +import net.forwardfire.vasc.core.VascEntryLocal; import org.x4o.xml.element.AbstractElement; import org.x4o.xml.element.ElementException; @@ -50,10 +49,10 @@ public class VascEventListenerElement extends AbstractElement { if (clazz.isEmpty()) { throw new ElementException("class attribute is empty."); } - if (getParent().getElementObject() instanceof VascEntry==false) { + if (getParent().getElementObject() instanceof VascEntryLocal==false) { throw new ElementException("Parent object is not vasc entry."); } - VascEntry v = (VascEntry)getParent().getElementObject(); + VascEntryLocal v = (VascEntryLocal)getParent().getElementObject(); if ("backend".equalsIgnoreCase(type)) { v.addVascEntryBackendEventListener(clazz); } else if ("frontend".equalsIgnoreCase(type)) { diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/validators/VascValidatorMessages.java b/vasc-core/src/main/java/net/forwardfire/vasc/validators/VascValidatorMessages.java index 6d7658e..77c909e 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/validators/VascValidatorMessages.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/validators/VascValidatorMessages.java @@ -39,25 +39,25 @@ public class VascValidatorMessages { public String getErrorMessage(VascEntry entry,VascValidator val) { String key = getErrorI18nKey(val); - String message = entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(key); + String message = entry.getVascFrontendController().getVascEntryResourceResolver().getTextValue(key); if (val instanceof VascIntSizeValidator) { VascIntSizeValidator v = (VascIntSizeValidator)val; - message = entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(key,v.getMin(),v.getMax()); + message = entry.getVascFrontendController().getVascEntryResourceResolver().getTextValue(key,v.getMin(),v.getMax()); return message; } if (val instanceof VascLongSizeValidator) { VascLongSizeValidator v = (VascLongSizeValidator)val; - message = entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(key,v.getMin(),v.getMax()); + message = entry.getVascFrontendController().getVascEntryResourceResolver().getTextValue(key,v.getMin(),v.getMax()); return message; } if (val instanceof VascStringLengthValidator) { VascStringLengthValidator v = (VascStringLengthValidator)val; - message = entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(key,v.getMinLenght(),v.getMaxLenght()); + message = entry.getVascFrontendController().getVascEntryResourceResolver().getTextValue(key,v.getMinLenght(),v.getMaxLenght()); return message; } if (val instanceof VascStringRegexValidator) { VascStringRegexValidator v = (VascStringRegexValidator)val; - message = entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(key,v.getRegEx()); + message = entry.getVascFrontendController().getVascEntryResourceResolver().getTextValue(key,v.getRegEx()); return message; } return message; diff --git a/vasc-core/src/main/resources/META-INF/vasc/vasc-lang.eld b/vasc-core/src/main/resources/META-INF/vasc/vasc-lang.eld index ee4f028..e822c55 100644 --- a/vasc-core/src/main/resources/META-INF/vasc/vasc-lang.eld +++ b/vasc-core/src/main/resources/META-INF/vasc/vasc-lang.eld @@ -5,14 +5,14 @@ Fake root tag - - - - - - + + + + + + - + @@ -50,15 +50,15 @@ - - - + + + - - + + - + diff --git a/vasc-demo/vasc-demo-petstore-j2ee5/vasc-demo-petstore-j2ee5-ejb/pom.xml b/vasc-demo/vasc-demo-petstore-j2ee5/vasc-demo-petstore-j2ee5-ejb/pom.xml index f7b91d9..e706db8 100644 --- a/vasc-demo/vasc-demo-petstore-j2ee5/vasc-demo-petstore-j2ee5-ejb/pom.xml +++ b/vasc-demo/vasc-demo-petstore-j2ee5/vasc-demo-petstore-j2ee5-ejb/pom.xml @@ -5,9 +5,7 @@ net.forwardfire.vasc.demo 0.3.5-SNAPSHOT - net.forwardfire.vasc.demo vasc-demo-petstore-j2ee5-ejb - 0.3.5-SNAPSHOT ejb vasc-demo-petstore-j2ee5-ejb vasc-demo-petstore-j2ee5-ejb @@ -24,16 +22,11 @@ - - net.forwardfire.vasc - vasc-core - ${project.version} - - + javax.el el-api ${el-api.version} - + javax.ejb ejb-api diff --git a/vasc-demo/vasc-demo-petstore-j2ee5/vasc-demo-petstore-j2ee5-ejb/src/main/java/demo/petstore/models/AbstractPetStoreFieldTemplates.java b/vasc-demo/vasc-demo-petstore-j2ee5/vasc-demo-petstore-j2ee5-ejb/src/main/java/demo/petstore/models/AbstractPetStoreFieldTemplates.java index 0034436..14ea717 100644 --- a/vasc-demo/vasc-demo-petstore-j2ee5/vasc-demo-petstore-j2ee5-ejb/src/main/java/demo/petstore/models/AbstractPetStoreFieldTemplates.java +++ b/vasc-demo/vasc-demo-petstore-j2ee5/vasc-demo-petstore-j2ee5-ejb/src/main/java/demo/petstore/models/AbstractPetStoreFieldTemplates.java @@ -25,7 +25,7 @@ abstract public class AbstractPetStoreFieldTemplates { @VascI18n(name="generic.id.labelText",description="generic.id.toolTipText") @VascStyle(sizeList=50) @VascField(create=false,editReadOnly=true) - @VascFieldOrder(orderIndex=0) + @VascFieldOrder(order=0) abstract public Integer getId(); /** @@ -36,7 +36,7 @@ abstract public class AbstractPetStoreFieldTemplates { @VascObjectNotNull @VascStringLength(min=4,max=128) @VascStyle(sizeList=250,sizeEdit=40) - @VascFieldOrder(orderIndex=1) + @VascFieldOrder(order=1) abstract public String getName(); /** @@ -48,7 +48,7 @@ abstract public class AbstractPetStoreFieldTemplates { @VascField(list=false) @VascStringLength(max=4096) @VascObjectNotNull - @VascFieldOrder(orderIndex=2) + @VascFieldOrder(order=2) abstract public String getDescription(); /** @@ -57,7 +57,7 @@ abstract public class AbstractPetStoreFieldTemplates { @VascI18n(name="generic.active.labelText",description="generic.active.toolTipText") @VascDefaultValue(value="true") @VascObjectNotNull - @VascFieldOrder(orderIndex=4) + @VascFieldOrder(order=4) @VascField(create=false) @VascRoles(rolesEdit="datafeedsPowerRole",rolesList="datafeedsPowerRole") abstract public Boolean getActive(); diff --git a/vasc-demo/vasc-demo-tech/pom.xml b/vasc-demo/vasc-demo-tech/pom.xml index 41455c1..4b985b6 100644 --- a/vasc-demo/vasc-demo-tech/pom.xml +++ b/vasc-demo/vasc-demo-tech/pom.xml @@ -14,7 +14,6 @@ vasc-demo-tech-build vasc-demo-tech-editor vasc-demo-tech-web - vasc-demo-tech-ui vasc-demo-tech-core \ No newline at end of file diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/pom.xml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/pom.xml index 1591e3e..d6da6da 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/pom.xml +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/pom.xml @@ -15,9 +15,7 @@ org.apache.maven.plugins maven-assembly-plugin - - gnu - + ${maven-assembly-plugin.version} ui-dist-assembly @@ -38,7 +36,12 @@ net.forwardfire.vasc.demo - vasc-demo-tech-ui + vasc-demo-tech-core + ${project.version} + + + net.forwardfire.vasc.demo + vasc-demo-tech-web ${project.version} diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/assembly/bin.xml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/assembly/bin.xml index 829fa74..c1c2fdb 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/assembly/bin.xml +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/assembly/bin.xml @@ -63,6 +63,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ${project.basedir}/src/main/directory/ / + + conf/logback-server-console.xml + \ No newline at end of file diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/directory/conf/context.xml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/directory/conf/context.xml new file mode 100644 index 0000000..fa0eefd --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/directory/conf/context.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + WEB-INF/web.xml + + + + + \ No newline at end of file diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/directory/conf/logback-access.xml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/directory/conf/logback-access.xml new file mode 100644 index 0000000..0500f32 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/directory/conf/logback-access.xml @@ -0,0 +1,14 @@ + + + + + logs/http-access.log + + logs/http-access-%d{yyyy-MM-dd}.log.zip + + + combined + + + + \ No newline at end of file diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/directory/conf/logback-server-console.xml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/directory/conf/logback-server-console.xml new file mode 100644 index 0000000..4774479 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/directory/conf/logback-server-console.xml @@ -0,0 +1,32 @@ + + + + true + + + + logs/vasc-demo-tech.log + + %date %level [%thread] %logger{10} %msg%n + + + + + %date %level [%thread] %logger{10} %msg%n + + + + + + + + + + + + + + + + + diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/directory/conf/logback-server.xml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/directory/conf/logback-server.xml new file mode 100644 index 0000000..1e9fef6 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/directory/conf/logback-server.xml @@ -0,0 +1,29 @@ + + + + true + + + + logs/vasc-demo-tech.log + + logs/vasc-demo-tech-%d{yyyy-MM-dd}.log.zip + + + %date %level [%thread] %logger{10} %msg%n + + + + + + + + + + + + + + + + diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/directory/conf/server.xml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/directory/conf/server.xml new file mode 100644 index 0000000..2f2835e --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/directory/conf/server.xml @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/directory/conf/web.xml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/directory/conf/web.xml new file mode 100644 index 0000000..16f4906 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/directory/conf/web.xml @@ -0,0 +1,3734 @@ + + + + + 1 + + + index.html + index.htm + index.jsp + + + + default + org.apache.catalina.servlets.DefaultServlet + + debug + 0 + + + listings + false + + 1 + + + default + / + + + + jsp + org.apache.jasper.servlet.JspServlet + + fork + false + + + xpoweredBy + false + + 3 + + + jsp + *.jsp + *.jspx + + + + 123 + application/vnd.lotus-1-2-3 + + + 3dml + text/vnd.in3d.3dml + + + 3g2 + video/3gpp2 + + + 3gp + video/3gpp + + + 7z + application/x-7z-compressed + + + aab + application/x-authorware-bin + + + aac + audio/x-aac + + + aam + application/x-authorware-map + + + aas + application/x-authorware-seg + + + abs + audio/x-mpeg + + + abw + application/x-abiword + + + ac + application/pkix-attr-cert + + + acc + application/vnd.americandynamics.acc + + + ace + application/x-ace-compressed + + + acu + application/vnd.acucobol + + + acutc + application/vnd.acucorp + + + adp + audio/adpcm + + + aep + application/vnd.audiograph + + + afm + application/x-font-type1 + + + afp + application/vnd.ibm.modcap + + + ahead + application/vnd.ahead.space + + + ai + application/postscript + + + aif + audio/x-aiff + + + aifc + audio/x-aiff + + + aiff + audio/x-aiff + + + aim + application/x-aim + + + air + application/vnd.adobe.air-application-installer-package+zip + + + ait + application/vnd.dvb.ait + + + ami + application/vnd.amiga.ami + + + anx + application/annodex + + + apk + application/vnd.android.package-archive + + + application + application/x-ms-application + + + apr + application/vnd.lotus-approach + + + art + image/x-jg + + + asc + application/pgp-signature + + + asf + video/x-ms-asf + + + asm + text/x-asm + + + aso + application/vnd.accpac.simply.aso + + + asx + video/x-ms-asf + + + atc + application/vnd.acucorp + + + atom + application/atom+xml + + + atomcat + application/atomcat+xml + + + atomsvc + application/atomsvc+xml + + + atx + application/vnd.antix.game-component + + + au + audio/basic + + + avi + video/x-msvideo + + + avx + video/x-rad-screenplay + + + aw + application/applixware + + + axa + audio/annodex + + + axv + video/annodex + + + azf + application/vnd.airzip.filesecure.azf + + + azs + application/vnd.airzip.filesecure.azs + + + azw + application/vnd.amazon.ebook + + + bat + application/x-msdownload + + + bcpio + application/x-bcpio + + + bdf + application/x-font-bdf + + + bdm + application/vnd.syncml.dm+wbxml + + + bed + application/vnd.realvnc.bed + + + bh2 + application/vnd.fujitsu.oasysprs + + + bin + application/octet-stream + + + bmi + application/vnd.bmi + + + bmp + image/bmp + + + body + text/html + + + book + application/vnd.framemaker + + + box + application/vnd.previewsystems.box + + + boz + application/x-bzip2 + + + bpk + application/octet-stream + + + btif + image/prs.btif + + + bz + application/x-bzip + + + bz2 + application/x-bzip2 + + + c + text/x-c + + + c11amc + application/vnd.cluetrust.cartomobile-config + + + c11amz + application/vnd.cluetrust.cartomobile-config-pkg + + + c4d + application/vnd.clonk.c4group + + + c4f + application/vnd.clonk.c4group + + + c4g + application/vnd.clonk.c4group + + + c4p + application/vnd.clonk.c4group + + + c4u + application/vnd.clonk.c4group + + + cab + application/vnd.ms-cab-compressed + + + car + application/vnd.curl.car + + + cat + application/vnd.ms-pki.seccat + + + cc + text/x-c + + + cct + application/x-director + + + ccxml + application/ccxml+xml + + + cdbcmsg + application/vnd.contact.cmsg + + + cdf + application/x-cdf + + + cdkey + application/vnd.mediastation.cdkey + + + cdmia + application/cdmi-capability + + + cdmic + application/cdmi-container + + + cdmid + application/cdmi-domain + + + cdmio + application/cdmi-object + + + cdmiq + application/cdmi-queue + + + cdx + chemical/x-cdx + + + cdxml + application/vnd.chemdraw+xml + + + cdy + application/vnd.cinderella + + + cer + application/pkix-cert + + + cgm + image/cgm + + + chat + application/x-chat + + + chm + application/vnd.ms-htmlhelp + + + chrt + application/vnd.kde.kchart + + + cif + chemical/x-cif + + + cii + application/vnd.anser-web-certificate-issue-initiation + + + cil + application/vnd.ms-artgalry + + + cla + application/vnd.claymore + + + class + application/java + + + clkk + application/vnd.crick.clicker.keyboard + + + clkp + application/vnd.crick.clicker.palette + + + clkt + application/vnd.crick.clicker.template + + + clkw + application/vnd.crick.clicker.wordbank + + + clkx + application/vnd.crick.clicker + + + clp + application/x-msclip + + + cmc + application/vnd.cosmocaller + + + cmdf + chemical/x-cmdf + + + cml + chemical/x-cml + + + cmp + application/vnd.yellowriver-custom-menu + + + cmx + image/x-cmx + + + cod + application/vnd.rim.cod + + + com + application/x-msdownload + + + conf + text/plain + + + cpio + application/x-cpio + + + cpp + text/x-c + + + cpt + application/mac-compactpro + + + crd + application/x-mscardfile + + + crl + application/pkix-crl + + + crt + application/x-x509-ca-cert + + + cryptonote + application/vnd.rig.cryptonote + + + csh + application/x-csh + + + csml + chemical/x-csml + + + csp + application/vnd.commonspace + + + css + text/css + + + cst + application/x-director + + + csv + text/csv + + + cu + application/cu-seeme + + + curl + text/vnd.curl + + + cww + application/prs.cww + + + cxt + application/x-director + + + cxx + text/x-c + + + dae + model/vnd.collada+xml + + + daf + application/vnd.mobius.daf + + + dataless + application/vnd.fdsn.seed + + + davmount + application/davmount+xml + + + dcr + application/x-director + + + dcurl + text/vnd.curl.dcurl + + + dd2 + application/vnd.oma.dd2+xml + + + ddd + application/vnd.fujixerox.ddd + + + deb + application/x-debian-package + + + def + text/plain + + + deploy + application/octet-stream + + + der + application/x-x509-ca-cert + + + dfac + application/vnd.dreamfactory + + + dib + image/bmp + + + dic + text/x-c + + + dir + application/x-director + + + dis + application/vnd.mobius.dis + + + dist + application/octet-stream + + + distz + application/octet-stream + + + djv + image/vnd.djvu + + + djvu + image/vnd.djvu + + + dll + application/x-msdownload + + + dmg + application/octet-stream + + + dms + application/octet-stream + + + dna + application/vnd.dna + + + doc + application/msword + + + docm + application/vnd.ms-word.document.macroenabled.12 + + + docx + application/vnd.openxmlformats-officedocument.wordprocessingml.document + + + dot + application/msword + + + dotm + application/vnd.ms-word.template.macroenabled.12 + + + dotx + application/vnd.openxmlformats-officedocument.wordprocessingml.template + + + dp + application/vnd.osgi.dp + + + dpg + application/vnd.dpgraph + + + dra + audio/vnd.dra + + + dsc + text/prs.lines.tag + + + dssc + application/dssc+der + + + dtb + application/x-dtbook+xml + + + dtd + application/xml-dtd + + + dts + audio/vnd.dts + + + dtshd + audio/vnd.dts.hd + + + dump + application/octet-stream + + + dv + video/x-dv + + + dvi + application/x-dvi + + + dwf + model/vnd.dwf + + + dwg + image/vnd.dwg + + + dxf + image/vnd.dxf + + + dxp + application/vnd.spotfire.dxp + + + dxr + application/x-director + + + ecelp4800 + audio/vnd.nuera.ecelp4800 + + + ecelp7470 + audio/vnd.nuera.ecelp7470 + + + ecelp9600 + audio/vnd.nuera.ecelp9600 + + + ecma + application/ecmascript + + + edm + application/vnd.novadigm.edm + + + edx + application/vnd.novadigm.edx + + + efif + application/vnd.picsel + + + ei6 + application/vnd.pg.osasli + + + elc + application/octet-stream + + + eml + message/rfc822 + + + emma + application/emma+xml + + + eol + audio/vnd.digital-winds + + + eot + application/vnd.ms-fontobject + + + eps + application/postscript + + + epub + application/epub+zip + + + es3 + application/vnd.eszigno3+xml + + + esf + application/vnd.epson.esf + + + et3 + application/vnd.eszigno3+xml + + + etx + text/x-setext + + + exe + application/octet-stream + + + exi + application/exi + + + ext + application/vnd.novadigm.ext + + + ez + application/andrew-inset + + + ez2 + application/vnd.ezpix-album + + + ez3 + application/vnd.ezpix-package + + + f + text/x-fortran + + + f4v + video/x-f4v + + + f77 + text/x-fortran + + + f90 + text/x-fortran + + + fbs + image/vnd.fastbidsheet + + + fcs + application/vnd.isac.fcs + + + fdf + application/vnd.fdf + + + fe_launch + application/vnd.denovo.fcselayout-link + + + fg5 + application/vnd.fujitsu.oasysgp + + + fgd + application/x-director + + + fh + image/x-freehand + + + fh4 + image/x-freehand + + + fh5 + image/x-freehand + + + fh7 + image/x-freehand + + + fhc + image/x-freehand + + + fig + application/x-xfig + + + flac + audio/flac + + + fli + video/x-fli + + + flo + application/vnd.micrografx.flo + + + flv + video/x-flv + + + flw + application/vnd.kde.kivio + + + flx + text/vnd.fmi.flexstor + + + fly + text/vnd.fly + + + fm + application/vnd.framemaker + + + fnc + application/vnd.frogans.fnc + + + for + text/x-fortran + + + fpx + image/vnd.fpx + + + frame + application/vnd.framemaker + + + fsc + application/vnd.fsc.weblaunch + + + fst + image/vnd.fst + + + ftc + application/vnd.fluxtime.clip + + + fti + application/vnd.anser-web-funds-transfer-initiation + + + fvt + video/vnd.fvt + + + fxp + application/vnd.adobe.fxp + + + fxpl + application/vnd.adobe.fxp + + + fzs + application/vnd.fuzzysheet + + + g2w + application/vnd.geoplan + + + g3 + image/g3fax + + + g3w + application/vnd.geospace + + + gac + application/vnd.groove-account + + + gdl + model/vnd.gdl + + + geo + application/vnd.dynageo + + + gex + application/vnd.geometry-explorer + + + ggb + application/vnd.geogebra.file + + + ggt + application/vnd.geogebra.tool + + + ghf + application/vnd.groove-help + + + gif + image/gif + + + gim + application/vnd.groove-identity-message + + + gmx + application/vnd.gmx + + + gnumeric + application/x-gnumeric + + + gph + application/vnd.flographit + + + gqf + application/vnd.grafeq + + + gqs + application/vnd.grafeq + + + gram + application/srgs + + + gre + application/vnd.geometry-explorer + + + grv + application/vnd.groove-injector + + + grxml + application/srgs+xml + + + gsf + application/x-font-ghostscript + + + gtar + application/x-gtar + + + gtm + application/vnd.groove-tool-message + + + gtw + model/vnd.gtw + + + gv + text/vnd.graphviz + + + gxt + application/vnd.geonext + + + gz + application/x-gzip + + + h + text/x-c + + + h261 + video/h261 + + + h263 + video/h263 + + + h264 + video/h264 + + + hal + application/vnd.hal+xml + + + hbci + application/vnd.hbci + + + hdf + application/x-hdf + + + hh + text/x-c + + + hlp + application/winhlp + + + hpgl + application/vnd.hp-hpgl + + + hpid + application/vnd.hp-hpid + + + hps + application/vnd.hp-hps + + + hqx + application/mac-binhex40 + + + htc + text/x-component + + + htke + application/vnd.kenameaapp + + + htm + text/html + + + html + text/html + + + hvd + application/vnd.yamaha.hv-dic + + + hvp + application/vnd.yamaha.hv-voice + + + hvs + application/vnd.yamaha.hv-script + + + i2g + application/vnd.intergeo + + + icc + application/vnd.iccprofile + + + ice + x-conference/x-cooltalk + + + icm + application/vnd.iccprofile + + + ico + image/x-icon + + + ics + text/calendar + + + ief + image/ief + + + ifb + text/calendar + + + ifm + application/vnd.shana.informed.formdata + + + iges + model/iges + + + igl + application/vnd.igloader + + + igm + application/vnd.insors.igm + + + igs + model/iges + + + igx + application/vnd.micrografx.igx + + + iif + application/vnd.shana.informed.interchange + + + imp + application/vnd.accpac.simply.imp + + + ims + application/vnd.ms-ims + + + in + text/plain + + + ipfix + application/ipfix + + + ipk + application/vnd.shana.informed.package + + + irm + application/vnd.ibm.rights-management + + + irp + application/vnd.irepository.package+xml + + + iso + application/octet-stream + + + itp + application/vnd.shana.informed.formtemplate + + + ivp + application/vnd.immervision-ivp + + + ivu + application/vnd.immervision-ivu + + + jad + text/vnd.sun.j2me.app-descriptor + + + jam + application/vnd.jam + + + jar + application/java-archive + + + java + text/x-java-source + + + jisp + application/vnd.jisp + + + jlt + application/vnd.hp-jlyt + + + jnlp + application/x-java-jnlp-file + + + joda + application/vnd.joost.joda-archive + + + jpe + image/jpeg + + + jpeg + image/jpeg + + + jpg + image/jpeg + + + jpgm + video/jpm + + + jpgv + video/jpeg + + + jpm + video/jpm + + + js + application/javascript + + + jsf + text/plain + + + json + application/json + + + jspf + text/plain + + + kar + audio/midi + + + karbon + application/vnd.kde.karbon + + + kfo + application/vnd.kde.kformula + + + kia + application/vnd.kidspiration + + + kml + application/vnd.google-earth.kml+xml + + + kmz + application/vnd.google-earth.kmz + + + kne + application/vnd.kinar + + + knp + application/vnd.kinar + + + kon + application/vnd.kde.kontour + + + kpr + application/vnd.kde.kpresenter + + + kpt + application/vnd.kde.kpresenter + + + ksp + application/vnd.kde.kspread + + + ktr + application/vnd.kahootz + + + ktx + image/ktx + + + ktz + application/vnd.kahootz + + + kwd + application/vnd.kde.kword + + + kwt + application/vnd.kde.kword + + + lasxml + application/vnd.las.las+xml + + + latex + application/x-latex + + + lbd + application/vnd.llamagraphics.life-balance.desktop + + + lbe + application/vnd.llamagraphics.life-balance.exchange+xml + + + les + application/vnd.hhe.lesson-player + + + lha + application/octet-stream + + + link66 + application/vnd.route66.link66+xml + + + list + text/plain + + + list3820 + application/vnd.ibm.modcap + + + listafp + application/vnd.ibm.modcap + + + log + text/plain + + + lostxml + application/lost+xml + + + lrf + application/octet-stream + + + lrm + application/vnd.ms-lrm + + + ltf + application/vnd.frogans.ltf + + + lvp + audio/vnd.lucent.voice + + + lwp + application/vnd.lotus-wordpro + + + lzh + application/octet-stream + + + m13 + application/x-msmediaview + + + m14 + application/x-msmediaview + + + m1v + video/mpeg + + + m21 + application/mp21 + + + m2a + audio/mpeg + + + m2v + video/mpeg + + + m3a + audio/mpeg + + + m3u + audio/x-mpegurl + + + m3u8 + application/vnd.apple.mpegurl + + + m4a + audio/mp4 + + + m4b + audio/mp4 + + + m4r + audio/mp4 + + + m4u + video/vnd.mpegurl + + + m4v + video/mp4 + + + ma + application/mathematica + + + mac + image/x-macpaint + + + mads + application/mads+xml + + + mag + application/vnd.ecowin.chart + + + maker + application/vnd.framemaker + + + man + text/troff + + + mathml + application/mathml+xml + + + mb + application/mathematica + + + mbk + application/vnd.mobius.mbk + + + mbox + application/mbox + + + mc1 + application/vnd.medcalcdata + + + mcd + application/vnd.mcd + + + mcurl + text/vnd.curl.mcurl + + + mdb + application/x-msaccess + + + mdi + image/vnd.ms-modi + + + me + text/troff + + + mesh + model/mesh + + + meta4 + application/metalink4+xml + + + mets + application/mets+xml + + + mfm + application/vnd.mfmp + + + mgp + application/vnd.osgeo.mapguide.package + + + mgz + application/vnd.proteus.magazine + + + mid + audio/midi + + + midi + audio/midi + + + mif + application/x-mif + + + mime + message/rfc822 + + + mj2 + video/mj2 + + + mjp2 + video/mj2 + + + mlp + application/vnd.dolby.mlp + + + mmd + application/vnd.chipnuts.karaoke-mmd + + + mmf + application/vnd.smaf + + + mmr + image/vnd.fujixerox.edmics-mmr + + + mny + application/x-msmoney + + + mobi + application/x-mobipocket-ebook + + + mods + application/mods+xml + + + mov + video/quicktime + + + movie + video/x-sgi-movie + + + mp1 + audio/mpeg + + + mp2 + audio/mpeg + + + mp21 + application/mp21 + + + mp2a + audio/mpeg + + + mp3 + audio/mpeg + + + mp4 + video/mp4 + + + mp4a + audio/mp4 + + + mp4s + application/mp4 + + + mp4v + video/mp4 + + + mpa + audio/mpeg + + + mpc + application/vnd.mophun.certificate + + + mpe + video/mpeg + + + mpeg + video/mpeg + + + mpega + audio/x-mpeg + + + mpg + video/mpeg + + + mpg4 + video/mp4 + + + mpga + audio/mpeg + + + mpkg + application/vnd.apple.installer+xml + + + mpm + application/vnd.blueice.multipass + + + mpn + application/vnd.mophun.application + + + mpp + application/vnd.ms-project + + + mpt + application/vnd.ms-project + + + mpv2 + video/mpeg2 + + + mpy + application/vnd.ibm.minipay + + + mqy + application/vnd.mobius.mqy + + + mrc + application/marc + + + mrcx + application/marcxml+xml + + + ms + text/troff + + + mscml + application/mediaservercontrol+xml + + + mseed + application/vnd.fdsn.mseed + + + mseq + application/vnd.mseq + + + msf + application/vnd.epson.msf + + + msh + model/mesh + + + msi + application/x-msdownload + + + msl + application/vnd.mobius.msl + + + msty + application/vnd.muvee.style + + + mts + model/vnd.mts + + + mus + application/vnd.musician + + + musicxml + application/vnd.recordare.musicxml+xml + + + mvb + application/x-msmediaview + + + mwf + application/vnd.mfer + + + mxf + application/mxf + + + mxl + application/vnd.recordare.musicxml + + + mxml + application/xv+xml + + + mxs + application/vnd.triscape.mxs + + + mxu + video/vnd.mpegurl + + + n-gage + application/vnd.nokia.n-gage.symbian.install + + + n3 + text/n3 + + + nb + application/mathematica + + + nbp + application/vnd.wolfram.player + + + nc + application/x-netcdf + + + ncx + application/x-dtbncx+xml + + + ngdat + application/vnd.nokia.n-gage.data + + + nlu + application/vnd.neurolanguage.nlu + + + nml + application/vnd.enliven + + + nnd + application/vnd.noblenet-directory + + + nns + application/vnd.noblenet-sealer + + + nnw + application/vnd.noblenet-web + + + npx + image/vnd.net-fpx + + + nsf + application/vnd.lotus-notes + + + oa2 + application/vnd.fujitsu.oasys2 + + + oa3 + application/vnd.fujitsu.oasys3 + + + oas + application/vnd.fujitsu.oasys + + + obd + application/x-msbinder + + + oda + application/oda + + + + odb + application/vnd.oasis.opendocument.database + + + + odc + application/vnd.oasis.opendocument.chart + + + + odf + application/vnd.oasis.opendocument.formula + + + odft + application/vnd.oasis.opendocument.formula-template + + + + odg + application/vnd.oasis.opendocument.graphics + + + + odi + application/vnd.oasis.opendocument.image + + + + odm + application/vnd.oasis.opendocument.text-master + + + + odp + application/vnd.oasis.opendocument.presentation + + + + ods + application/vnd.oasis.opendocument.spreadsheet + + + + odt + application/vnd.oasis.opendocument.text + + + oga + audio/ogg + + + ogg + audio/ogg + + + ogv + video/ogg + + + + ogx + application/ogg + + + onepkg + application/onenote + + + onetmp + application/onenote + + + onetoc + application/onenote + + + onetoc2 + application/onenote + + + opf + application/oebps-package+xml + + + oprc + application/vnd.palm + + + org + application/vnd.lotus-organizer + + + osf + application/vnd.yamaha.openscoreformat + + + osfpvg + application/vnd.yamaha.openscoreformat.osfpvg+xml + + + otc + application/vnd.oasis.opendocument.chart-template + + + otf + application/x-font-otf + + + + otg + application/vnd.oasis.opendocument.graphics-template + + + + oth + application/vnd.oasis.opendocument.text-web + + + oti + application/vnd.oasis.opendocument.image-template + + + + otp + application/vnd.oasis.opendocument.presentation-template + + + + ots + application/vnd.oasis.opendocument.spreadsheet-template + + + + ott + application/vnd.oasis.opendocument.text-template + + + oxt + application/vnd.openofficeorg.extension + + + p + text/x-pascal + + + p10 + application/pkcs10 + + + p12 + application/x-pkcs12 + + + p7b + application/x-pkcs7-certificates + + + p7c + application/pkcs7-mime + + + p7m + application/pkcs7-mime + + + p7r + application/x-pkcs7-certreqresp + + + p7s + application/pkcs7-signature + + + p8 + application/pkcs8 + + + pas + text/x-pascal + + + paw + application/vnd.pawaafile + + + pbd + application/vnd.powerbuilder6 + + + pbm + image/x-portable-bitmap + + + pcf + application/x-font-pcf + + + pcl + application/vnd.hp-pcl + + + pclxl + application/vnd.hp-pclxl + + + pct + image/pict + + + pcurl + application/vnd.curl.pcurl + + + pcx + image/x-pcx + + + pdb + application/vnd.palm + + + pdf + application/pdf + + + pfa + application/x-font-type1 + + + pfb + application/x-font-type1 + + + pfm + application/x-font-type1 + + + pfr + application/font-tdpfr + + + pfx + application/x-pkcs12 + + + pgm + image/x-portable-graymap + + + pgn + application/x-chess-pgn + + + pgp + application/pgp-encrypted + + + pic + image/pict + + + pict + image/pict + + + pkg + application/octet-stream + + + pki + application/pkixcmp + + + pkipath + application/pkix-pkipath + + + plb + application/vnd.3gpp.pic-bw-large + + + plc + application/vnd.mobius.plc + + + plf + application/vnd.pocketlearn + + + pls + audio/x-scpls + + + pml + application/vnd.ctc-posml + + + png + image/png + + + pnm + image/x-portable-anymap + + + pnt + image/x-macpaint + + + portpkg + application/vnd.macports.portpkg + + + pot + application/vnd.ms-powerpoint + + + potm + application/vnd.ms-powerpoint.template.macroenabled.12 + + + potx + application/vnd.openxmlformats-officedocument.presentationml.template + + + ppam + application/vnd.ms-powerpoint.addin.macroenabled.12 + + + ppd + application/vnd.cups-ppd + + + ppm + image/x-portable-pixmap + + + pps + application/vnd.ms-powerpoint + + + ppsm + application/vnd.ms-powerpoint.slideshow.macroenabled.12 + + + ppsx + application/vnd.openxmlformats-officedocument.presentationml.slideshow + + + ppt + application/vnd.ms-powerpoint + + + pptm + application/vnd.ms-powerpoint.presentation.macroenabled.12 + + + pptx + application/vnd.openxmlformats-officedocument.presentationml.presentation + + + pqa + application/vnd.palm + + + prc + application/x-mobipocket-ebook + + + pre + application/vnd.lotus-freelance + + + prf + application/pics-rules + + + ps + application/postscript + + + psb + application/vnd.3gpp.pic-bw-small + + + psd + image/vnd.adobe.photoshop + + + psf + application/x-font-linux-psf + + + pskcxml + application/pskc+xml + + + ptid + application/vnd.pvi.ptid1 + + + pub + application/x-mspublisher + + + pvb + application/vnd.3gpp.pic-bw-var + + + pwn + application/vnd.3m.post-it-notes + + + pya + audio/vnd.ms-playready.media.pya + + + pyv + video/vnd.ms-playready.media.pyv + + + qam + application/vnd.epson.quickanime + + + qbo + application/vnd.intu.qbo + + + qfx + application/vnd.intu.qfx + + + qps + application/vnd.publishare-delta-tree + + + qt + video/quicktime + + + qti + image/x-quicktime + + + qtif + image/x-quicktime + + + qwd + application/vnd.quark.quarkxpress + + + qwt + application/vnd.quark.quarkxpress + + + qxb + application/vnd.quark.quarkxpress + + + qxd + application/vnd.quark.quarkxpress + + + qxl + application/vnd.quark.quarkxpress + + + qxt + application/vnd.quark.quarkxpress + + + ra + audio/x-pn-realaudio + + + ram + audio/x-pn-realaudio + + + rar + application/x-rar-compressed + + + ras + image/x-cmu-raster + + + rcprofile + application/vnd.ipunplugged.rcprofile + + + rdf + application/rdf+xml + + + rdz + application/vnd.data-vision.rdz + + + rep + application/vnd.businessobjects + + + res + application/x-dtbresource+xml + + + rgb + image/x-rgb + + + rif + application/reginfo+xml + + + rip + audio/vnd.rip + + + rl + application/resource-lists+xml + + + rlc + image/vnd.fujixerox.edmics-rlc + + + rld + application/resource-lists-diff+xml + + + rm + application/vnd.rn-realmedia + + + rmi + audio/midi + + + rmp + audio/x-pn-realaudio-plugin + + + rms + application/vnd.jcp.javame.midlet-rms + + + rnc + application/relax-ng-compact-syntax + + + roff + text/troff + + + rp9 + application/vnd.cloanto.rp9 + + + rpss + application/vnd.nokia.radio-presets + + + rpst + application/vnd.nokia.radio-preset + + + rq + application/sparql-query + + + rs + application/rls-services+xml + + + rsd + application/rsd+xml + + + rss + application/rss+xml + + + rtf + application/rtf + + + rtx + text/richtext + + + s + text/x-asm + + + saf + application/vnd.yamaha.smaf-audio + + + sbml + application/sbml+xml + + + sc + application/vnd.ibm.secure-container + + + scd + application/x-msschedule + + + scm + application/vnd.lotus-screencam + + + scq + application/scvp-cv-request + + + scs + application/scvp-cv-response + + + scurl + text/vnd.curl.scurl + + + sda + application/vnd.stardivision.draw + + + sdc + application/vnd.stardivision.calc + + + sdd + application/vnd.stardivision.impress + + + sdkd + application/vnd.solent.sdkm+xml + + + sdkm + application/vnd.solent.sdkm+xml + + + sdp + application/sdp + + + sdw + application/vnd.stardivision.writer + + + see + application/vnd.seemail + + + seed + application/vnd.fdsn.seed + + + sema + application/vnd.sema + + + semd + application/vnd.semd + + + semf + application/vnd.semf + + + ser + application/java-serialized-object + + + setpay + application/set-payment-initiation + + + setreg + application/set-registration-initiation + + + sfd-hdstx + application/vnd.hydrostatix.sof-data + + + sfs + application/vnd.spotfire.sfs + + + sgl + application/vnd.stardivision.writer-global + + + sgm + text/sgml + + + sgml + text/sgml + + + sh + application/x-sh + + + shar + application/x-shar + + + shf + application/shf+xml + + + + sig + application/pgp-signature + + + silo + model/mesh + + + sis + application/vnd.symbian.install + + + sisx + application/vnd.symbian.install + + + sit + application/x-stuffit + + + sitx + application/x-stuffitx + + + skd + application/vnd.koan + + + skm + application/vnd.koan + + + skp + application/vnd.koan + + + skt + application/vnd.koan + + + sldm + application/vnd.ms-powerpoint.slide.macroenabled.12 + + + sldx + application/vnd.openxmlformats-officedocument.presentationml.slide + + + slt + application/vnd.epson.salt + + + sm + application/vnd.stepmania.stepchart + + + smf + application/vnd.stardivision.math + + + smi + application/smil+xml + + + smil + application/smil+xml + + + snd + audio/basic + + + snf + application/x-font-snf + + + so + application/octet-stream + + + spc + application/x-pkcs7-certificates + + + spf + application/vnd.yamaha.smaf-phrase + + + spl + application/x-futuresplash + + + spot + text/vnd.in3d.spot + + + spp + application/scvp-vp-response + + + spq + application/scvp-vp-request + + + spx + audio/ogg + + + src + application/x-wais-source + + + sru + application/sru+xml + + + srx + application/sparql-results+xml + + + sse + application/vnd.kodak-descriptor + + + ssf + application/vnd.epson.ssf + + + ssml + application/ssml+xml + + + st + application/vnd.sailingtracker.track + + + stc + application/vnd.sun.xml.calc.template + + + std + application/vnd.sun.xml.draw.template + + + stf + application/vnd.wt.stf + + + sti + application/vnd.sun.xml.impress.template + + + stk + application/hyperstudio + + + stl + application/vnd.ms-pki.stl + + + str + application/vnd.pg.format + + + stw + application/vnd.sun.xml.writer.template + + + sub + image/vnd.dvb.subtitle + + + sus + application/vnd.sus-calendar + + + susp + application/vnd.sus-calendar + + + sv4cpio + application/x-sv4cpio + + + sv4crc + application/x-sv4crc + + + svc + application/vnd.dvb.service + + + svd + application/vnd.svd + + + svg + image/svg+xml + + + svgz + image/svg+xml + + + swa + application/x-director + + + swf + application/x-shockwave-flash + + + swi + application/vnd.aristanetworks.swi + + + sxc + application/vnd.sun.xml.calc + + + sxd + application/vnd.sun.xml.draw + + + sxg + application/vnd.sun.xml.writer.global + + + sxi + application/vnd.sun.xml.impress + + + sxm + application/vnd.sun.xml.math + + + sxw + application/vnd.sun.xml.writer + + + t + text/troff + + + tao + application/vnd.tao.intent-module-archive + + + tar + application/x-tar + + + tcap + application/vnd.3gpp2.tcap + + + tcl + application/x-tcl + + + teacher + application/vnd.smart.teacher + + + tei + application/tei+xml + + + teicorpus + application/tei+xml + + + tex + application/x-tex + + + texi + application/x-texinfo + + + texinfo + application/x-texinfo + + + text + text/plain + + + tfi + application/thraud+xml + + + tfm + application/x-tex-tfm + + + thmx + application/vnd.ms-officetheme + + + tif + image/tiff + + + tiff + image/tiff + + + tmo + application/vnd.tmobile-livetv + + + torrent + application/x-bittorrent + + + tpl + application/vnd.groove-tool-template + + + tpt + application/vnd.trid.tpt + + + tr + text/troff + + + tra + application/vnd.trueapp + + + trm + application/x-msterminal + + + tsd + application/timestamped-data + + + tsv + text/tab-separated-values + + + ttc + application/x-font-ttf + + + ttf + application/x-font-ttf + + + ttl + text/turtle + + + twd + application/vnd.simtech-mindmapper + + + twds + application/vnd.simtech-mindmapper + + + txd + application/vnd.genomatix.tuxedo + + + txf + application/vnd.mobius.txf + + + txt + text/plain + + + u32 + application/x-authorware-bin + + + udeb + application/x-debian-package + + + ufd + application/vnd.ufdl + + + ufdl + application/vnd.ufdl + + + ulw + audio/basic + + + umj + application/vnd.umajin + + + unityweb + application/vnd.unity + + + uoml + application/vnd.uoml+xml + + + uri + text/uri-list + + + uris + text/uri-list + + + urls + text/uri-list + + + ustar + application/x-ustar + + + utz + application/vnd.uiq.theme + + + uu + text/x-uuencode + + + uva + audio/vnd.dece.audio + + + uvd + application/vnd.dece.data + + + uvf + application/vnd.dece.data + + + uvg + image/vnd.dece.graphic + + + uvh + video/vnd.dece.hd + + + uvi + image/vnd.dece.graphic + + + uvm + video/vnd.dece.mobile + + + uvp + video/vnd.dece.pd + + + uvs + video/vnd.dece.sd + + + uvt + application/vnd.dece.ttml+xml + + + uvu + video/vnd.uvvu.mp4 + + + uvv + video/vnd.dece.video + + + uvva + audio/vnd.dece.audio + + + uvvd + application/vnd.dece.data + + + uvvf + application/vnd.dece.data + + + uvvg + image/vnd.dece.graphic + + + uvvh + video/vnd.dece.hd + + + uvvi + image/vnd.dece.graphic + + + uvvm + video/vnd.dece.mobile + + + uvvp + video/vnd.dece.pd + + + uvvs + video/vnd.dece.sd + + + uvvt + application/vnd.dece.ttml+xml + + + uvvu + video/vnd.uvvu.mp4 + + + uvvv + video/vnd.dece.video + + + uvvx + application/vnd.dece.unspecified + + + uvx + application/vnd.dece.unspecified + + + vcd + application/x-cdlink + + + vcf + text/x-vcard + + + vcg + application/vnd.groove-vcard + + + vcs + text/x-vcalendar + + + vcx + application/vnd.vcx + + + vis + application/vnd.visionary + + + viv + video/vnd.vivo + + + vor + application/vnd.stardivision.writer + + + vox + application/x-authorware-bin + + + vrml + model/vrml + + + vsd + application/vnd.visio + + + vsf + application/vnd.vsf + + + vss + application/vnd.visio + + + vst + application/vnd.visio + + + vsw + application/vnd.visio + + + vtu + model/vnd.vtu + + + vxml + application/voicexml+xml + + + w3d + application/x-director + + + wad + application/x-doom + + + wav + audio/x-wav + + + wax + audio/x-ms-wax + + + + wbmp + image/vnd.wap.wbmp + + + wbs + application/vnd.criticaltools.wbs+xml + + + wbxml + application/vnd.wap.wbxml + + + wcm + application/vnd.ms-works + + + wdb + application/vnd.ms-works + + + weba + audio/webm + + + webm + video/webm + + + webp + image/webp + + + wg + application/vnd.pmi.widget + + + wgt + application/widget + + + wks + application/vnd.ms-works + + + wm + video/x-ms-wm + + + wma + audio/x-ms-wma + + + wmd + application/x-ms-wmd + + + wmf + application/x-msmetafile + + + + wml + text/vnd.wap.wml + + + + wmlc + application/vnd.wap.wmlc + + + + wmls + text/vnd.wap.wmlscript + + + + wmlsc + application/vnd.wap.wmlscriptc + + + wmv + video/x-ms-wmv + + + wmx + video/x-ms-wmx + + + wmz + application/x-ms-wmz + + + woff + application/x-font-woff + + + wpd + application/vnd.wordperfect + + + wpl + application/vnd.ms-wpl + + + wps + application/vnd.ms-works + + + wqd + application/vnd.wqd + + + wri + application/x-mswrite + + + wrl + model/vrml + + + wsdl + application/wsdl+xml + + + wspolicy + application/wspolicy+xml + + + wtb + application/vnd.webturbo + + + wvx + video/x-ms-wvx + + + x32 + application/x-authorware-bin + + + x3d + application/vnd.hzn-3d-crossword + + + xap + application/x-silverlight-app + + + xar + application/vnd.xara + + + xbap + application/x-ms-xbap + + + xbd + application/vnd.fujixerox.docuworks.binder + + + xbm + image/x-xbitmap + + + xdf + application/xcap-diff+xml + + + xdm + application/vnd.syncml.dm+xml + + + xdp + application/vnd.adobe.xdp+xml + + + xdssc + application/dssc+xml + + + xdw + application/vnd.fujixerox.docuworks + + + xenc + application/xenc+xml + + + xer + application/patch-ops-error+xml + + + xfdf + application/vnd.adobe.xfdf + + + xfdl + application/vnd.xfdl + + + xht + application/xhtml+xml + + + xhtml + application/xhtml+xml + + + xhvml + application/xv+xml + + + xif + image/vnd.xiff + + + xla + application/vnd.ms-excel + + + xlam + application/vnd.ms-excel.addin.macroenabled.12 + + + xlc + application/vnd.ms-excel + + + xlm + application/vnd.ms-excel + + + xls + application/vnd.ms-excel + + + xlsb + application/vnd.ms-excel.sheet.binary.macroenabled.12 + + + xlsm + application/vnd.ms-excel.sheet.macroenabled.12 + + + xlsx + application/vnd.openxmlformats-officedocument.spreadsheetml.sheet + + + xlt + application/vnd.ms-excel + + + xltm + application/vnd.ms-excel.template.macroenabled.12 + + + xltx + application/vnd.openxmlformats-officedocument.spreadsheetml.template + + + xlw + application/vnd.ms-excel + + + xml + application/xml + + + xo + application/vnd.olpc-sugar + + + xop + application/xop+xml + + + xpi + application/x-xpinstall + + + xpm + image/x-xpixmap + + + xpr + application/vnd.is-xpr + + + xps + application/vnd.ms-xpsdocument + + + xpw + application/vnd.intercon.formnet + + + xpx + application/vnd.intercon.formnet + + + xsl + application/xml + + + xslt + application/xslt+xml + + + xsm + application/vnd.syncml+xml + + + xspf + application/xspf+xml + + + xul + application/vnd.mozilla.xul+xml + + + xvm + application/xv+xml + + + xvml + application/xv+xml + + + xwd + image/x-xwindowdump + + + xyz + chemical/x-xyz + + + yang + application/yang + + + yin + application/yin+xml + + + z + application/x-compress + + + Z + application/x-compress + + + zaz + application/vnd.zzazz.deck+xml + + + zip + application/zip + + + zir + application/vnd.zul + + + zirz + application/vnd.zul + + + zmm + application/vnd.handheld-entertainment+xml + + + \ No newline at end of file diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/directory/demo/csv/csv-vasc.xml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/directory/demo/csv/csv-vasc.xml index b33ba1f..6d399c3 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/directory/demo/csv/csv-vasc.xml +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/directory/demo/csv/csv-vasc.xml @@ -39,7 +39,7 @@ - + \ No newline at end of file diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/directory/deploy/conf-server.xml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/directory/deploy/conf-server.xml new file mode 100644 index 0000000..45b9d96 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/directory/deploy/conf-server.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/directory/deploy/manager.xml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/directory/deploy/manager.xml new file mode 100644 index 0000000..4dab608 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/directory/deploy/manager.xml @@ -0,0 +1,100 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/directory/deploy/readme.txt b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/directory/deploy/readme.txt index 1262c52..d62d0b9 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/directory/deploy/readme.txt +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/directory/deploy/readme.txt @@ -1 +1,7 @@ -All *.xml in this dir are automaticly started. \ No newline at end of file + +== Deploy directory == + +-- All *.xml files are deployed on startup. +-- Directory get scanned every 3 secs. +-- Files get redeployed when md5sum changes. +-- No undeploy and no removal of vasc entries only ADD/replace. diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/directory/logs/vasc-demo-tech.log b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/directory/logs/vasc-demo-tech.log new file mode 100644 index 0000000..3fb37e2 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/directory/logs/vasc-demo-tech.log @@ -0,0 +1 @@ +1234-56-78 90:12:34,123 INFO [install] Thank you for trying this vasc demo tech. diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/files/readme.txt b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/files/readme.txt index 5805e3e..f4fe1ad 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/files/readme.txt +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/files/readme.txt @@ -3,4 +3,18 @@ Readme for Vasc Tech Demo application. To start: -execute: run.sh or run.bat \ No newline at end of file +execute: run.sh or run.bat + + +Custom i18n keys web: + +Application.web.meta.robots = index, follow +Application.web.meta.description = Vasc Tech Demo Web Frontends +Application.web.meta.keywords = demo,forwardfire,x4o,vasc,java +Application.web.header.logo.alt = Vasc Tech Demo Logo +Application.web.footer.center = Vasc Tech Demo Web Based on JSF and Faclets and Richfaces. +Application.web.footer.left = Copyright © 2012 +Application.web.footer.right = Version 0.4.x(beta) + + + diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/scripts/run.bat b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/scripts/run.bat index 98faaaa..1354d3c 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/scripts/run.bat +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/scripts/run.bat @@ -28,7 +28,7 @@ cd /d %~dp0 :: Config variables set JAVA_OPTS=-Xms64m -Xmx256m -set MAIN_CLASS=net.forwardfire.vasc.demo.tech.ui.TechUI +set MAIN_CLASS=net.forwardfire.vasc.demo.tech.core.VascTechDemo set CP=lib\* :: Launch application diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/scripts/run.sh b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/scripts/run.sh index 237670d..ef06490 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/scripts/run.sh +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/scripts/run.sh @@ -28,7 +28,7 @@ cd `dirname $0`; # Config variables JAVA="java"; JAVA_OPTS="-Xms64m -Xmx256m"; -MAIN_CLASS="net.forwardfire.vasc.demo.tech.ui.TechUI"; +MAIN_CLASS="net.forwardfire.vasc.demo.tech.core.VascTechDemo"; CP=`echo lib/*.jar | sed 's/ /:/g'`; # Launch application diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/.project b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/.project index 46bb916..7e55be9 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/.project +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/.project @@ -16,12 +16,12 @@ - org.eclipse.m2e.core.maven2Builder + org.eclipse.wst.validation.validationbuilder - org.eclipse.wst.validation.validationbuilder + org.eclipse.m2e.core.maven2Builder diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/pom.xml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/pom.xml index 61bfac8..7411db7 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/pom.xml +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/pom.xml @@ -10,10 +10,214 @@ vasc-demo-tech-core vasc-demo-tech-core + + org.x4o + x4o-core + ${x4o-core.version} + + + javax.el + el-api + + + + + net.forwardfire.vasc.demo + vasc-demo-tech-web + ${project.version} + jar + net.forwardfire.vasc vasc-core ${project.version} + + net.forwardfire.vasc + vasc-frontend-swing + ${project.version} + + + net.forwardfire.vasc + vasc-frontend-web-jsf + ${project.version} + + + net.forwardfire.vasc + vasc-frontend-web-export + ${project.version} + + + net.forwardfire.vasc + vasc-frontend-cxf-server + ${project.version} + + + net.forwardfire.vasc + vasc-backend-ldap + ${project.version} + + + net.forwardfire.vasc + vasc-backend-mongodb + ${project.version} + + + net.forwardfire.vasc + vasc-backend-metamodel + ${project.version} + + + net.forwardfire.vasc + vasc-backend-jdbc + ${project.version} + + + net.forwardfire.vasc.lib + vasc-lib-i18n + ${project.version} + + + net.forwardfire.vasc.lib + vasc-lib-editor + ${project.version} + + + net.forwardfire.vasc.test + vasc-test-i18n + ${project.version} + + + org.jdesktop.bsaf + bsaf + ${bsaf.version} + + + jnlp + javax.jnlp + + + + + commons-io + commons-io + ${commons-io.version} + + + net.jawr + jawr + ${jawr.version} + + + de.tudarmstadt.ukp.wikipedia + de.tudarmstadt.ukp.wikipedia.api + 0.9.1 + + + log4j + log4j + + + + + + + org.apache.tomcat.embed + tomcat-embed-core + 7.0.27 + + + org.apache.tomcat.embed + tomcat-embed-jasper + 7.0.27 + + + org.apache.tomcat + tomcat-jasper + 7.0.27 + + + org.apache.tomcat + tomcat-jdbc + 7.0.27 + + + + + javax.servlet + jstl + ${jstl.version} + + + org.glassfish + javax.faces + ${javax.faces.version} + + + + + org.richfaces.core + richfaces-core-impl + + + org.richfaces.ui + richfaces-components-ui + + + org.ocpsoft.rewrite + rewrite-servlet + ${rewrite-servlet.version} + + + + + com.h2database + h2 + ${h2.version} + + + postgresql + postgresql + ${postgresql.version} + + + mysql + mysql-connector-java + ${mysql-connector-java.version} + + + org.apache.derby + derby + ${derby.version} + + + + + ch.qos.logback + logback-access + ${logback-access.version} + + + ch.qos.logback + logback-classic + ${logback-classic.version} + + + org.slf4j + jul-to-slf4j + ${jul-to-slf4j.version} + + + org.slf4j + log4j-over-slf4j + ${log4j-over-slf4j.version} + \ No newline at end of file diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/VascTechDemo.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/VascTechDemo.java new file mode 100644 index 0000000..af49682 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/VascTechDemo.java @@ -0,0 +1,248 @@ +/* + * 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.demo.tech.core; + +import java.io.File; +import java.io.IOException; +import java.net.MalformedURLException; +import java.util.logging.Handler; +import java.util.logging.Logger; + +import org.apache.commons.io.FileUtils; +import org.slf4j.bridge.SLF4JBridgeHandler; + +import net.forwardfire.vasc.demo.tech.core.service.DatabaseService; +import net.forwardfire.vasc.demo.tech.core.service.ServerConfigService; +import net.forwardfire.vasc.demo.tech.core.service.ServerConfigService.ServerConfigKey; +import net.forwardfire.vasc.demo.tech.core.service.tomcat.TomcatService; +import net.forwardfire.vasc.demo.tech.core.service.SwingGuiService; +import net.forwardfire.vasc.demo.tech.core.service.VascControllerService; +import net.forwardfire.vasc.demo.tech.core.service.VascDeployService; + +/** + * VascTechDemo init and starts the VascTechDemo + * + * @author Willem Cazander + * @version 1.0 May 3, 2012 + */ +public class VascTechDemo { + + private Logger logger = null; + private ServerConfigService serverConfigService = null; + private DatabaseService databaseService = null; + private TomcatService tomcatService = null; + private VascControllerService vascControllerService = null; + private VascDeployService vascDeployService = null; + private SwingGuiService swingGuiService = null; + static private VascTechDemo instance = null; + + /** + * Starts this VascTechDemo instance + * @param args + */ + static public void main(String[] args) { + instance = new VascTechDemo(); + instance.initialize(args); + instance.startup(); + } + + /** + * Copy copfig/etc directory stucture to root of project in maven/eclipse run. + * @throws IOException + */ + private void setupAutoDir() throws IOException { + + File deployDir = new File("deploy"); + File workDir = new File("workdir"); + File workDirTmp = new File("workdir/tmp"); + if (deployDir.exists()==false) { + deployDir.mkdir(); + } + if (workDir.exists()==false) { + workDir.mkdir(); + } + if (workDirTmp.exists()==false) { + workDirTmp.mkdir(); + } + System.setProperty("java.io.tmpdir", workDirTmp.getAbsolutePath()); + File tmpFile = File.createTempFile("test", "new-tmp"); + if (tmpFile.getAbsolutePath().contains(workDirTmp.getName())==false) { + // Cant change tmp location. + } + tmpFile.delete(); + + File confDir = new File("conf"); + if (confDir.exists()) { + return; + } + if (isMavenRun()==false) { + throw new RuntimeException("Can't start without conf dir."); + } + FileUtils.copyDirectory(new File("../vasc-demo-tech-build/src/main/directory/"), new File(".")); + } + + /** + * Config logging and setup logger object. + */ + private void setupLogging() { + + // Set Config file property + if (System.getProperty("logback.configurationFile")==null) { + File logConfig = null; + if (isMavenRun()) { + logConfig = new File("conf/logback-server-console.xml"); + } else { + logConfig = new File("conf/logback-server.xml"); + } + try { + System.setProperty("logback.configurationFile", logConfig.toURI().toURL().toExternalForm()); + } catch (MalformedURLException e) { + e.printStackTrace(); + } + } + Logger rootLogger = Logger.getAnonymousLogger(); + while (rootLogger.getParent()!=null) { + rootLogger = rootLogger.getParent(); + } + for (Handler h:rootLogger.getHandlers()) { + rootLogger.removeHandler(h); + } + rootLogger.addHandler(new SLF4JBridgeHandler()); // This does also the init for us. + + // Logback offical init method. + //LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); + //StatusPrinter.print(lc); + + // Create an JUL logger for our application. + logger = Logger.getLogger(VascTechDemo.class.getName()); + logger.info("Logging is ready for application log;"); + } + + /** + * Init all demo service beans. + * @param argu + */ + protected void initialize(String[] argu) { + long startTime = System.currentTimeMillis(); + try { + Thread.currentThread().setName("startup"); + setupAutoDir(); + setupLogging(); + logger.info("VascTechDemo initializing ..."); + databaseService = new DatabaseService(); + tomcatService = new TomcatService(); + serverConfigService = new ServerConfigService(); + vascControllerService = new VascControllerService(); + vascDeployService = new VascDeployService(); + vascDeployService.setDeployDir(new File("deploy")); + swingGuiService = new SwingGuiService(); + long stopTime = System.currentTimeMillis(); + logger.info("VascTechDemo initialized in "+(stopTime-startTime)+" ms."); + } catch (Exception e1) { + e1.printStackTrace(); + System.exit(1); + } + } + + /** + * Startup and deploy all service beans. + */ + protected void startup() { + try { + long startTime = System.currentTimeMillis(); + + databaseService.start(); + tomcatService.start(); + serverConfigService.start(); + vascControllerService.start(); + if (serverConfigService.isServerConfigValueTrue(ServerConfigKey.START_GUI)) { + swingGuiService.start(); + } + if (serverConfigService.isServerConfigValueTrue(ServerConfigKey.START_EDITOR)) { + vascControllerService.startEditor(); + } + vascDeployService.start(); + tomcatService.deploy(serverConfigService.getServerConfigValue(ServerConfigKey.DEPLOY_PATH)); + if (serverConfigService.isServerConfigValueTrue(ServerConfigKey.DEPLOY_DEBUG)) { + tomcatService.deployDebug(); + } + long stopTime = System.currentTimeMillis(); + logger.info("VascTechDemo startup in "+(stopTime-startTime)+" ms."); + } catch (Exception e) { + e.printStackTrace(); + System.exit(1); + } + } + + public void shutdown() { + if (instance==null) { + return; + } + + Thread t = new Thread(new Runnable() { + public void run() { + try { + long startTime = System.currentTimeMillis(); + vascDeployService.stop(); + vascControllerService.stop(); + serverConfigService.stop(); + tomcatService.stop(); + databaseService.stop(); + long stopTime = System.currentTimeMillis(); + logger.info("VascTechDemo shutdown in "+(stopTime-startTime)+" ms."); + } catch (Exception e) { + e.printStackTrace(); + System.exit(1); + } finally { + instance = null; + } + } + }); + t.setName("shutdown"); + t.start(); + } + + static public VascTechDemo getInstance() { + return instance; + } + + public boolean isMavenRun() { + return System.getProperty("java.class.path").contains("classes"); + } + + public VascControllerService getVascControllerService() { + return vascControllerService; + } + + public VascDeployService getVascDeployService() { + return vascDeployService; + } + + public TomcatService getTomcatService() { + return tomcatService; + } + + public SwingGuiService getSwingGuiService() { + return swingGuiService; + } +} diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/VascTechDemoControllerConfig.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/VascTechDemoControllerConfig.java new file mode 100644 index 0000000..ea89807 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/VascTechDemoControllerConfig.java @@ -0,0 +1,72 @@ +/* + * 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.demo.tech.core; + +import net.forwardfire.vasc.core.VascController; +import net.forwardfire.vasc.core.VascControllerProvider; +import net.forwardfire.vasc.core.VascEntryConfigControllerLocal; +import net.forwardfire.vasc.core.VascException; +import net.forwardfire.vasc.impl.DefaultVascFactory; +import net.forwardfire.vasc.impl.entry.export.VascEntryExporterJR4O; +import net.forwardfire.vasc.lib.jr4o.JR4ODesignManager.JRExportType; + +/** + * DemoVascControllerProvider gets the static local jvm vasc controller for this tech demo. + * + * @author Willem Cazander + * @version 1.0 May 12, 2012 + */ +public class VascTechDemoControllerConfig implements VascControllerProvider { + + /** + * @see net.forwardfire.vasc.core.VascControllerProvider#getVascController() + */ + public VascController getVascController() { + + try { + VascController vascController = DefaultVascFactory.getDefaultVascController(); + + VascEntryConfigControllerLocal vecc = (VascEntryConfigControllerLocal)vascController.getVascEntryConfigController(); + + // Config all report export engines for demo. + vecc.addVascEntryExporter(new VascEntryExporterJR4O("jrPdfLandscape",JRExportType.PDF,"generic-landscape","net/forwardfire/vasc/lib/jr4o/reports/dynamic-reports.xml")); + vecc.addVascEntryExporter(new VascEntryExporterJR4O("jrPdfPortrait",JRExportType.PDF,"generic-portrait","net/forwardfire/vasc/lib/jr4o/reports/dynamic-reports.xml")); + vecc.addVascEntryExporter(new VascEntryExporterJR4O("jrRtf",JRExportType.RTF,"generic-landscape","net/forwardfire/vasc/lib/jr4o/reports/dynamic-reports.xml")); + vecc.addVascEntryExporter(new VascEntryExporterJR4O("jrXls",JRExportType.XLS,"generic-landscape","net/forwardfire/vasc/lib/jr4o/reports/dynamic-reports.xml")); + vecc.addVascEntryExporter(new VascEntryExporterJR4O("jrXml",JRExportType.XML,"generic-landscape","net/forwardfire/vasc/lib/jr4o/reports/dynamic-reports.xml")); + vecc.addVascEntryExporter(new VascEntryExporterJR4O("jrCsv",JRExportType.CSV,"generic-landscape","net/forwardfire/vasc/lib/jr4o/reports/dynamic-reports.xml")); + + // Config root bundle to load all resources. + vecc.setResourceBundle("net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle"); + + // Increase some config defaults + vecc.getMasterVascBackendState().setPageSize(200); + vecc.getMasterVascBackendState().setPageSizeMax(2000); + + return vascController; + } catch (VascException e) { + throw new RuntimeException(e); + } + + } +} diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/service/DatabaseService.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/service/DatabaseService.java new file mode 100644 index 0000000..dcca425 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/service/DatabaseService.java @@ -0,0 +1,149 @@ +/* + * 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.demo.tech.core.service; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Logger; + +import org.h2.tools.Server; + +/** + * DatabaseService starts and stops the embedded H2 demo database. + * + * @author Willem Cazander + * @version 1.0 May 13, 2012 + */ +public class DatabaseService { + + private Logger logger = null; + private Server server = null; + + public DatabaseService() { + logger = Logger.getLogger(DatabaseService.class.getName()); + } + + public void start() { + List argu = new ArrayList(10); + argu.add("-tcp"); + argu.add("-tcpPort"); argu.add("9092"); + argu.add("-tcpPassword"); argu.add("stopSecret"); + argu.add("-baseDir"); argu.add("data/db"); + String[] args = new String[argu.size()]; + args = argu.toArray(args); + StringBuffer buf = new StringBuffer(); + for (String a:args) { + buf.append(a); + buf.append(" "); + } + logger.info("Start H2 Server with: "+buf); + try { + server = Server.createTcpServer(args).start(); + } catch (SQLException e) { + e.printStackTrace(); + } + if (server.isRunning(true)) { + initDB(); + } + } + + public void stop() { + if (server==null) { + return; + } + logger.info("Stopping H2 Server"); + server.stop(); + } + + private void initDB() { + Connection conn = null; + try { + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + if (cl==null) { + cl = this.getClass().getClassLoader(); + } + cl.loadClass("org.h2.Driver"); + conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9092/vasc-demo"); + + ResultSet rs = conn.prepareStatement("show tables").executeQuery(); + if (rs.next()) { + logger.info("Tables found so skipping auto init."); + rs.close(); + return; + } + rs.close(); + + String allSql = readResourceAsString("net/forwardfire/vasc/demo/tech/core/service/resources/init-db.sql"); + String[] allSqlData = allSql.split(";"); + for(String sql:allSqlData) { + sql = sql.trim(); + if (sql.isEmpty()) { + continue; + } + conn.prepareStatement(sql+";").executeUpdate(); + } + logger.info("Done auto init total statements done: "+allSqlData.length); + + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (conn!=null) { + try { + conn.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + } + + private String readResourceAsString(String resource) throws IOException { + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + if (cl==null) { + cl = this.getClass().getClassLoader(); + } + StringBuffer fileData = new StringBuffer(1000); + BufferedReader reader = new BufferedReader(new InputStreamReader(cl.getResourceAsStream(resource))); + try { + char[] buf = new char[1024]; + int numRead=0; + while((numRead=reader.read(buf)) != -1){ + String readData = String.valueOf(buf, 0, numRead); + fileData.append(readData); + buf = new char[1024]; + } + } finally { + if (reader!=null) { + reader.close(); + } + } + return fileData.toString(); + } +} diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/service/ServerConfigService.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/service/ServerConfigService.java new file mode 100644 index 0000000..742dbda --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/service/ServerConfigService.java @@ -0,0 +1,87 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.demo.tech.core.service; + +import javax.naming.Context; +import javax.naming.NamingException; + +import net.forwardfire.vasc.demo.tech.core.VascTechDemo; + +/** + * ServerConfigService reads demo server config parameters from jndi. + * + * @author Willem Cazander + * @version 1.0 May 19, 2012 + */ +public class ServerConfigService { + + public ServerConfigService() { + } + + public void start() { + } + + public void stop() { + } + + private Object readConfigKey(ServerConfigKey key) { + try { + Context context = VascTechDemo.getInstance().getTomcatService().getServer().getGlobalNamingContext(); + return context.lookup("config/"+key.name()); + } catch (NamingException e) { + throw new IllegalStateException("Naming error:"+e.getMessage()+" from key: "+key.name(),e); + } + } + + public String getServerConfigValue(ServerConfigKey key) { + if (key==null) { + throw new NullPointerException("Can't get value for null key."); + } + Object v = readConfigKey(key); + if (v==null) { + return key.getDefaultValue(); + } + return v.toString(); + } + + public boolean isServerConfigValueTrue(ServerConfigKey key) { + String value = getServerConfigValue(key); + return "true".equalsIgnoreCase(value); + } + + public enum ServerConfigKey { + + START_GUI("true"), + START_EDITOR("true"), + DEPLOY_DEBUG("true"), + DEPLOY_PATH("/demo"); + + private String defaultValue = null; + private ServerConfigKey(String defaultValue) { + this.defaultValue=defaultValue; + } + public String getDefaultValue() { + return defaultValue; + } + } +} diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/service/SwingGuiService.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/service/SwingGuiService.java new file mode 100644 index 0000000..f84d801 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/service/SwingGuiService.java @@ -0,0 +1,58 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.demo.tech.core.service; + +import javax.swing.JTabbedPane; + +import net.forwardfire.vasc.demo.tech.core.ui.JApplication; +import net.forwardfire.vasc.demo.tech.core.ui.JMainPanel; + +import org.jdesktop.application.Application; +import org.jdesktop.application.FrameView; +import org.jdesktop.application.SingleFrameApplication; + +/** + * SwingGuiService Shows the demo swing gui and vasc swing frontend. + * + * @author Willem Cazander + * @version 1.0 May 19, 2012 + */ +public class SwingGuiService { + + + public void start() { + Application.launch(JApplication.class, new String[] {}); + } + + public void stop() { + + } + + // move + public JTabbedPane getTabPane() { + SingleFrameApplication a = (SingleFrameApplication)JApplication.getInstance(); // BIG NOTE because of 'launch' for auto conf swing. + FrameView mainView = a.getMainView(); + JMainPanel mainPanel = (JMainPanel)mainView.getComponent(); + return mainPanel.getTabPane(); + } +} diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/service/VascControllerService.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/service/VascControllerService.java new file mode 100644 index 0000000..3713ec6 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/service/VascControllerService.java @@ -0,0 +1,130 @@ +/* + * 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.demo.tech.core.service; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Logger; + +import net.forwardfire.vasc.backend.VascBackendControllerLocal; +import net.forwardfire.vasc.core.VascController; +import net.forwardfire.vasc.core.VascEntryControllerLocal; +import net.forwardfire.vasc.demo.tech.core.VascTechDemo; +import net.forwardfire.vasc.impl.DefaultVascFactory; +import net.forwardfire.vasc.impl.x4o.VascParser; + +/** + * VascControllerService manages the demo vasc controller which gets init by jndi factory. + * + * @author Willem Cazander + * @version 1.0 May 18, 2012 + */ +public class VascControllerService { + + private Logger logger = null; + private VascController vascController = null; + private List vascServiceListeners = null; + + public VascControllerService() { + logger = Logger.getLogger(VascControllerService.class.getName()); + vascServiceListeners = new ArrayList(10); + } + + public void start() { + logger.finer("Starting vascmanager"); + if (vascController!=null) { + throw new RuntimeException("VascManager is already started."); + } + try { + // Fetch from jndi + vascController = (VascController)VascTechDemo.getInstance().getTomcatService().getServer().getGlobalNamingContext().lookup("vasc/DemoVascController"); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + public void stop() { + if (vascController==null) { + return; + } + VascBackendControllerLocal backends = (VascBackendControllerLocal)vascController.getVascBackendController(); + backends.clearAndStopBackends(); + + vascController = null; + logger.info("Stop manager, cleared all."); + } + + public void startEditor() { + try { + VascParser parser = new VascParser(vascController); + parser.addGlobalELBean("vascController", vascController); + parser.parseResource("net/forwardfire/vasc/lib/editor/vasc-edit.xml"); + + DefaultVascFactory.fillVascControllerLocalEntries((VascEntryControllerLocal) vascController.getVascEntryController(), vascController); + } catch (Exception e) { + e.printStackTrace(); + } finally { + fireChangeEvent(); + } + } + + + public void openFile(File file) { + logger.info("Vasc open file: "+file.getAbsoluteFile()); + try { + VascParser parser = new VascParser(vascController); + //File f = File.createTempFile("test-vasc", ".xml"); + //parser.setDebugOutputStream(new FileOutputStream(f)); + parser.parseFile(file); + + DefaultVascFactory.fillVascControllerLocalEntries((VascEntryControllerLocal) vascController.getVascEntryController(), vascController); + + + } catch (Exception e) { + e.printStackTrace(); + } finally { + fireChangeEvent(); + } + } + + + public VascController getVascController() { + return vascController; + } + + + public void fireChangeEvent() { + for (VascServiceListener listener:vascServiceListeners) { + listener.changeEvent(); + } + } + + public void addVascServiceListener(VascServiceListener listener) { + vascServiceListeners.add(listener); + } + + public interface VascServiceListener { + public void changeEvent(); + } +} diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/service/VascDeployService.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/service/VascDeployService.java new file mode 100644 index 0000000..969bd66 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/service/VascDeployService.java @@ -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.demo.tech.core.service; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.math.BigInteger; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.HashMap; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.naming.NamingException; + +import org.apache.catalina.Server; +import org.apache.naming.ContextBindings; + +import net.forwardfire.vasc.demo.tech.core.VascTechDemo; + +/** + * VascDeployService parses "deploy/*.xml" automaticly for hotdeployments. + * + * @author Willem Cazander + * @version 1.0 May 10, 2012 + */ +public class VascDeployService { + + private Logger logger = null; + private File deployDir = null; + private int scanPeriod = 3; + private AutoDeployManager autoDeployManager = null; + private Map fileCheckSums = null; + + public VascDeployService() { + logger = Logger.getLogger(VascDeployService.class.getName()); + fileCheckSums = new HashMap(20); + } + + public void start() { + if (deployDir==null) { + throw new NullPointerException("Can't deploy with null deployDir."); + } + if (deployDir.exists()==false) { + throw new IllegalStateException("Can't deploy with non-existing deployDir."); + } + if (deployDir.isDirectory()==false) { + throw new IllegalStateException("Can't deploy with non-directory deployDir."); + } + + // Start scan thread for auto (re)deployments + Thread scanThread = new Thread(new AutoDeployManager()); + scanThread.setName("hotdeploy-scanner"); + scanThread.start(); + } + + public void stop() { + if (autoDeployManager==null) { + return; + } + autoDeployManager.stop(); + } + + + public String createMd5Sum(File file) throws IOException, NoSuchAlgorithmException { + FileInputStream in = new FileInputStream(file.getAbsolutePath()); + try { + byte[] b = new byte[1024 * 64]; + int num = 0; + MessageDigest md = MessageDigest.getInstance("MD5"); + while ((num = in.read(b)) != -1) { + md.update(b, 0, num); + } + byte[] hashBytes = md.digest(); + BigInteger hashResult = new BigInteger(hashBytes); + String hashString = hashResult.toString(16); + return hashString; + } finally { + if (in != null) { + in.close(); + } + } + } + + + private void hotDeployVasc() throws NoSuchAlgorithmException, IOException { + int deployed = 0; + long startTime = System.currentTimeMillis(); + for (File file:deployDir.listFiles()) { + if (file.canRead()==false) { + continue; + } + if (file.getName().endsWith("xml")==false) { + continue; + } + String md5File = createMd5Sum(file); + String md5Deploy = fileCheckSums.get(file); + if (md5Deploy!=null && md5Deploy.equals(md5File)) { + continue; + } + fileCheckSums.put(file, md5File); + deployed++; + VascTechDemo.getInstance().getVascControllerService().openFile(file); + } + if (deployed > 0) { + long stopTime = System.currentTimeMillis(); + logger.info("Done deploying total files read: "+deployed+" in "+(stopTime-startTime)+" ms."); + /* + try { + StringBuffer buf = new StringBuffer(); + InitialContext context = new InitialContext(); + JdniTreePrinter jndi = new JdniTreePrinter(); + jndi.printJNDITree(context, "java:", buf); + logger.info("JDNI Tree:\n"+buf.toString()); + + } catch (Exception e) { + e.printStackTrace(); + } */ + } + } + + protected class AutoDeployManager implements Runnable { + private volatile boolean run = true; + public void run() { + try { + Thread.sleep(2000); // let gui+tomcat start + logger.info("AutoDeployManager started"); + + Server server = VascTechDemo.getInstance().getTomcatService().getServer(); + Object token = "secretToken"; + String bindName = "autoDeployThread"; + try { + ContextBindings.bindContext(bindName, server.getGlobalNamingContext(),token); + ContextBindings.bindThread(bindName,token); + } catch (NamingException e) { + e.printStackTrace(); + } + + + while(run) { + try { + hotDeployVasc(); + } catch (Exception e) { + logger.log(Level.WARNING,"Error while depoying: "+e.getMessage(),e); + } + + if (scanPeriod == 0) { + scanPeriod = 1; + } + try { + Thread.sleep(1000*scanPeriod); + } catch (InterruptedException ie) { + logger.info("Interrupted sleep"); + break; + } + } + + ContextBindings.unbindThread(bindName,token); + ContextBindings.unbindContext(bindName,token); + + + } catch (Exception e) { + logger.log(Level.SEVERE,"Error in run: "+e.getMessage(),e); + } finally { + logger.info("AutoDeployManager stoped"); + } + } + public void stop() { + run = false; + this.notify(); + } + } + + /** + * @return the deployDir + */ + public File getDeployDir() { + return deployDir; + } + + /** + * @param deployDir the deployDir to set + */ + public void setDeployDir(File deployDir) { + this.deployDir = deployDir; + } + + /** + * @return the scanPeriod + */ + public int getScanPeriod() { + return scanPeriod; + } + + /** + * @param scanPeriod the scanPeriod to set + */ + public void setScanPeriod(int scanPeriod) { + this.scanPeriod = scanPeriod; + } +} diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/service/tomcat/AuthSessionTimeoutValve.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/service/tomcat/AuthSessionTimeoutValve.java new file mode 100644 index 0000000..5ff27db --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/service/tomcat/AuthSessionTimeoutValve.java @@ -0,0 +1,126 @@ +/* + * 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.demo.tech.core.service.tomcat; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpSession; + +import org.apache.catalina.connector.Request; +import org.apache.catalina.connector.Response; +import org.apache.catalina.valves.ValveBase; + +/** + * AuthSessionTimeoutValve sets sessions timeout for Sessions which has user pricaiap. + * + * @author Willem Cazander + * @version 1.0 May 27, 2012 + */ +public class AuthSessionTimeoutValve extends ValveBase { + + private boolean logInfo = false; + private int minTimeout = 60; + private int maxTimeout = 60*60; + private int authTimeout = 60*20; + + /** + * The descriptive information about this implementation. + */ + protected static final String info = AuthSessionTimeoutValve.class.getName()+"/1.0"; + + @Override + public void invoke(Request request, Response response) throws IOException,ServletException { + getNext().invoke(request, response); + HttpSession session = request.getSession(false); + if (session==null) { + return; + } + int curSessionTimeout = session.getMaxInactiveInterval(); + int newSessionTimeout = curSessionTimeout; + if (curSessionTimeout < minTimeout) { + newSessionTimeout = minTimeout; + } + if (curSessionTimeout > maxTimeout) { + newSessionTimeout = maxTimeout; + } + if (request.getUserPrincipal()!=null) { + newSessionTimeout = authTimeout; + } + if (curSessionTimeout != newSessionTimeout) { + session.setMaxInactiveInterval(newSessionTimeout); + logChange(session.getId(),curSessionTimeout,newSessionTimeout); + } + } + + private void logChange(String sessionId,int curSessionTimeout,int newSessionTimeout) { + String log = "Changed session: "+sessionId+" from timeout: "+curSessionTimeout+" to: "+newSessionTimeout; + if (logInfo) { + getContainer().getLogger().info(log); + } else { + getContainer().getLogger().debug(log); + } + } + + /** + * @return the minTimeout + */ + public int getMinTimeout() { + return minTimeout; + } + + /** + * @param minTimeout the minTimeout to set + */ + public void setMinTimeout(int minTimeout) { + this.minTimeout = minTimeout; + } + + /** + * @return the maxTimeout + */ + public int getMaxTimeout() { + return maxTimeout; + } + + /** + * @param maxTimeout the maxTimeout to set + */ + public void setMaxTimeout(int maxTimeout) { + this.maxTimeout = maxTimeout; + } + + /** + * @return the authTimeout + */ + public int getAuthTimeout() { + return authTimeout; + } + + /** + * @param authTimeout the authTimeout to set + */ + public void setAuthTimeout(int authTimeout) { + this.authTimeout = authTimeout; + } +} \ No newline at end of file diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/service/tomcat/JdniTreePrinter.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/service/tomcat/JdniTreePrinter.java new file mode 100644 index 0000000..7139e86 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/service/tomcat/JdniTreePrinter.java @@ -0,0 +1,52 @@ +package net.forwardfire.vasc.demo.tech.core.service.tomcat; + +import javax.naming.NameClassPair; +import javax.naming.NamingException; + +public class JdniTreePrinter { + public JdniTreePrinter() { + + } + + public void printJNDITree(javax.naming.Context context,String ct,StringBuffer buf) { + try { + printNE(context,context.list(ct), ct,buf); + } catch (NamingException e) { + //ignore leaf node exception + } + } + + private void printNE(javax.naming.Context context,javax.naming.NamingEnumeration ne, String parentctx,StringBuffer buf) throws NamingException { + while (ne.hasMoreElements()) { + NameClassPair next = (NameClassPair) ne.nextElement(); + printEntry(next,buf); + increaseIndent(); + printJNDITree(context,(parentctx.length() == 0) ? next.getName() : parentctx + "/" + next.getName(),buf); + decreaseIndent(); + } + } + + private void printEntry(javax.naming.NameClassPair next,StringBuffer buf) { + printIndent(buf); + buf.append("-->"); + buf.append(next); + buf.append("\n"); + } + + + private int indentLevel = 0; + + private void increaseIndent() { + indentLevel += 4; + } + + private void decreaseIndent() { + indentLevel -= 4; + } + + private void printIndent(StringBuffer buf) { + for (int i = 0; i < indentLevel; i++) { + buf.append(" "); + } + } +} diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/service/tomcat/JndiDebugServlet.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/service/tomcat/JndiDebugServlet.java new file mode 100644 index 0000000..ad7d7b5 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/service/tomcat/JndiDebugServlet.java @@ -0,0 +1,39 @@ +package net.forwardfire.vasc.demo.tech.core.service.tomcat; + +import java.io.IOException; +import java.io.PrintWriter; + +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import net.forwardfire.vasc.demo.tech.core.VascTechDemo; + +public class JndiDebugServlet extends HttpServlet { + private static final long serialVersionUID = -7624183395089913214L; + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse response) throws ServletException, IOException { + try { + Context context = new InitialContext(); + if (req.getRequestURI().endsWith("global")) { + context = VascTechDemo.getInstance().getTomcatService().getServer().getGlobalNamingContext(); + } + StringBuffer buf = new StringBuffer(); + JdniTreePrinter jndi = new JdniTreePrinter(); + if (req.getRequestURI().endsWith("global")) { + jndi.printJNDITree(context,"",buf); + } else { + jndi.printJNDITree(context,"java:",buf); + } + PrintWriter out = response.getWriter(); + out.append(buf.toString()); + out.flush(); + } catch (Exception e) { + e.printStackTrace(); + } + + } +} \ No newline at end of file diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/service/tomcat/MongoRealm.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/service/tomcat/MongoRealm.java new file mode 100644 index 0000000..de452ab --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/service/tomcat/MongoRealm.java @@ -0,0 +1,343 @@ +/* + * 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.demo.tech.core.service.tomcat; + +import java.net.UnknownHostException; +import java.security.Principal; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Logger; + +import org.apache.catalina.LifecycleException; +import org.apache.catalina.realm.GenericPrincipal; +import org.apache.catalina.realm.RealmBase; + +import com.mongodb.BasicDBObject; +import com.mongodb.DB; +import com.mongodb.DBCollection; +import com.mongodb.DBCursor; +import com.mongodb.DBObject; +import com.mongodb.Mongo; +import com.mongodb.MongoOptions; +import com.mongodb.ServerAddress; + +/** + * MongoRealm does auth to mongo collections. + * + * @author Willem Cazander + * @version 1.0 May 13, 2012 + */ +public class MongoRealm extends RealmBase { + + private Logger logger = Logger.getLogger(MongoRealm.class.getName()); + private String hostname = "localhost"; + private int port = 27017; + private String database = null; + private String authUser = null; + private String authPass = null; + private String userCollection = null; + private String userField = "username"; + private String userPassField = "password"; + private String roleCollection = null; + private String roleField = "role"; + private String roleUserField = userField; + private boolean roleUserIdRef = false; + private Mongo mongo = null; + private DB db = null; + + @Override + protected String getName() { + return this.getClass().getSimpleName(); + } + + @Override + protected String getPassword(String username) { + DBObject user = getUser(username); + if (user==null) { + return null; + } + String password = (String) user.get(getUserPassField()); + return password; + } + + protected DBObject getUser(String username) { + DBCollection coll = db.getCollection(getUserCollection()); + DBObject query = new BasicDBObject(); + query.put(getUserField(), username); + DBCursor cur = coll.find(query); + if (cur.hasNext()==false) { + return null; + } + DBObject user = cur.next(); + return user; + } + + @Override + protected Principal getPrincipal(String username) { + String password = getPassword(username); + if (password==null) { + return null; + } + DBCollection coll = db.getCollection(getRoleCollection()); + DBObject query = new BasicDBObject(); + if (isRoleUserIdRef()) { + DBObject user = getUser(username); + query.put(getRoleUserField(), user.get("_id")); + } else { + query.put(getRoleUserField(), username); + } + DBCursor cur = coll.find(query); + if (cur.hasNext()==false) { + return null; + } + List roles = new ArrayList(30); + while (cur.hasNext()) { + DBObject row = cur.next(); + String role = (String)row.get(getRoleField()); + roles.add(role); + } + return new GenericPrincipal(username, password, roles); + } + + /** + * @see org.apache.catalina.realm.RealmBase#startInternal() + */ + @Override + protected void startInternal() throws LifecycleException { + super.startInternal(); + if (database==null) { + throw new LifecycleException("database is null."); + } + if (userCollection==null) { + throw new LifecycleException("userCollection is null."); + } + if (roleCollection==null) { + throw new LifecycleException("roleCollection is null."); + } + createMongoConnection(); + logger.fine("Started mongo realm to database: "+getDatabase()); + } + + /** + * @see org.apache.catalina.realm.RealmBase#stopInternal() + */ + @Override + protected void stopInternal() throws LifecycleException { + super.stopInternal(); + if (mongo==null) { + return; + } + mongo.close(); + logger.fine("Stopped mongo realm."); + } + + private void createMongoConnection() throws LifecycleException { + ServerAddress server; + try { + server = new ServerAddress(hostname,port); + } catch (UnknownHostException e) { + throw new LifecycleException(e); + } + MongoOptions options = new MongoOptions(); + mongo = new Mongo(server,options); + db = mongo.getDB(database); + if (authUser!=null && authUser.isEmpty()==false && authPass!=null && authPass.isEmpty()==false) { + boolean auth = db.authenticate(authUser, authPass.toCharArray()); + authPass = null; + if (auth==false) { + throw new LifecycleException("Could not auth to db: "+database+" with username: "+authUser); + } + + } + db.setReadOnly(true); + logger.finer("Connection to: "+db.getName()); + } + + /** + * @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 authUser + */ + public String getAuthUser() { + return authUser; + } + + /** + * @param authUser the authUser to set + */ + public void setAuthUser(String authUser) { + this.authUser = authUser; + } + + /** + * @return the authPass + */ + public String getAuthPass() { + return authPass; + } + + /** + * @param authPass the authPass to set + */ + public void setAuthPass(String authPass) { + this.authPass = authPass; + } + + /** + * @return the userCollection + */ + public String getUserCollection() { + return userCollection; + } + + /** + * @param userCollection the userCollection to set + */ + public void setUserCollection(String userCollection) { + this.userCollection = userCollection; + } + + /** + * @return the userField + */ + public String getUserField() { + return userField; + } + + /** + * @param userField the userField to set + */ + public void setUserField(String userField) { + this.userField = userField; + } + + /** + * @return the roleCollection + */ + public String getRoleCollection() { + return roleCollection; + } + + /** + * @param roleCollection the roleCollection to set + */ + public void setRoleCollection(String roleCollection) { + this.roleCollection = roleCollection; + } + + /** + * @return the roleField + */ + public String getRoleField() { + return roleField; + } + + /** + * @param roleField the roleField to set + */ + public void setRoleField(String roleField) { + this.roleField = roleField; + } + + /** + * @return the roleUserField + */ + public String getRoleUserField() { + return roleUserField; + } + + /** + * @param roleUserField the roleUserField to set + */ + public void setRoleUserField(String roleUserField) { + this.roleUserField = roleUserField; + } + + /** + * @return the userPassField + */ + public String getUserPassField() { + return userPassField; + } + + /** + * @param userPassField the userPassField to set + */ + public void setUserPassField(String userPassField) { + this.userPassField = userPassField; + } + + /** + * @return the roleUserIdRef + */ + public boolean isRoleUserIdRef() { + return roleUserIdRef; + } + + /** + * @param roleUserIdRef the roleUserIdRef to set + */ + public void setRoleUserIdRef(boolean roleUserIdRef) { + this.roleUserIdRef = roleUserIdRef; + } +} \ No newline at end of file diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/service/tomcat/TomcatService.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/service/tomcat/TomcatService.java new file mode 100644 index 0000000..ee2610b --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/service/tomcat/TomcatService.java @@ -0,0 +1,218 @@ +/* + * 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.demo.tech.core.service.tomcat; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.Enumeration; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.logging.Logger; + +import net.forwardfire.vasc.demo.tech.core.VascTechDemo; + +import org.apache.catalina.Context; +import org.apache.catalina.Host; +import org.apache.catalina.Server; +import org.apache.catalina.Service; +import org.apache.catalina.Wrapper; +import org.apache.catalina.core.StandardContext; +import org.apache.catalina.startup.Bootstrap; +import org.apache.catalina.startup.ContextConfig; +import org.apache.naming.resources.VirtualDirContext; + +/** + * TomcatService config and starts Tomcat in semi embedded mode. + * + * @author Willem Cazander + * @version 1.0 May 10, 2012 + */ +public class TomcatService { + + private Logger logger = null; + private Server server = null; + private ClassLoader commonLoader = null; + private Context applicationContext = null; + + public TomcatService() { + logger = Logger.getLogger(TomcatService.class.getName()); + } + + public void start() throws Exception { + + + Bootstrap boot = new Bootstrap(); + boot.setCatalinaHome(System.getProperty("user.dir")); + boot.init(); + boot.start(); + + /// After startup get the server object from private method. + for (Method m:boot.getClass().getDeclaredMethods()) { + if (m.getName().equals("getServer")) { + m.setAccessible(true); + server = (Server)m.invoke(boot); + } + } + if (server==null) { + throw new RuntimeException("Could not get server by reflection from BootStrap."); + } + for (Field f:boot.getClass().getDeclaredFields()) { + if (f.getName().equals("commonLoader")) { + f.setAccessible(true); + commonLoader = (ClassLoader)f.get(boot); + } + } + } + + public void deploy(String deployContext) throws Exception { + Service service = server.findService("Catalina"); + Host host = (Host)service.getContainer().findChild("localhost"); + + String deployPath = null; + if (VascTechDemo.getInstance().isMavenRun()) { + String webappPathLocation = "../vasc-demo-tech-web/src/main/webapp/"; + deployPath = new File(webappPathLocation).getAbsolutePath(); + logger.info("Deploy demo app from workspace path: "+deployPath); + } else { + + File techWarFile = null; + for (File file:new File("lib").listFiles()) { + if (file.getName().contains("vasc-demo-tech-web")) { + techWarFile = file; + break; + } + } + if (techWarFile==null) { + throw new NullPointerException("Could not locate war file in lib directory."); + } + File destDir = new File("workdir","tomcat.wars"+File.separator+techWarFile.getName()); + + if (destDir.exists()==false) { + destDir.mkdirs(); + JarFile jar = new JarFile(techWarFile); + Enumeration jars = jar.entries(); + while (jars.hasMoreElements()) { + JarEntry file = jars.nextElement(); + File f = new File(destDir+File.separator+file.getName()); + if (file.isDirectory()) { + f.mkdir(); + continue; + } + InputStream is = jar.getInputStream(file); + FileOutputStream fos = new FileOutputStream(f); + while (is.available() > 0) { + fos.write(is.read()); // slow copy + } + fos.close(); + is.close(); + } + } + deployPath = destDir.getAbsolutePath(); + logger.info("Deploy war path: "+deployPath); + } + + + Context ctx = new StandardContext(); + ctx.setName(deployContext); + ctx.setPath(deployContext); + ctx.setDocBase(deployPath); + //ctx.setParentClassLoader(commonLoader); + ctx.setConfigured(true); + + ContextConfig ctxCfg = new ContextConfig(); + ctx.addLifecycleListener(ctxCfg); + + VirtualDirContext vDir = new VirtualDirContext(); + vDir.setExtraResourcePaths("../vasc-demo-tech-web/target/classes"); + + ctx.setResources(vDir); + + //VirtualWebappLoader loader = new VirtualWebappLoader(); + //String cl = System.getProperty("java.class.path").replace(":", ";"); + //logger.info("Virtal class path: "+cl); + //loader.setVirtualClasspath(cl); + //loader.setSearchVirtualFirst(true); + //ctx.setLoader(loader); + + //ctx.getJarScanner().scan + host.addChild(ctx); + + applicationContext = ctx; + } + + public void deployDebug() throws Exception { + if (applicationContext==null) { + throw new NullPointerException("Can only deploy debug after deploy."); + } + long startTime = System.currentTimeMillis(); + + addServlet(applicationContext,"jdbcConsole","org.h2.server.web.WebServlet"); + applicationContext.addServletMapping("/debug/jdbc/console/*", "jdbcConsole"); + + addServlet(applicationContext,"jndiView","net.forwardfire.vasc.demo.tech.core.service.tomcat.JndiDebugServlet"); + applicationContext.addServletMapping("/debug/jndi/view", "jndiView"); + applicationContext.addServletMapping("/debug/jndi/view/global", "jndiView"); + + addServlet(applicationContext,"logbackClassicStatus","ch.qos.logback.classic.ViewStatusMessagesServlet"); + applicationContext.addServletMapping("/debug/logback/status/classic", "logbackClassicStatus"); + + addServlet(applicationContext,"logbackAccessStatus","ch.qos.logback.access.ViewStatusMessagesServlet"); + applicationContext.addServletMapping("/debug/logback/status/access", "logbackAccessStatus"); + + long stopTime = System.currentTimeMillis(); + logger.info("Deployed all debug resources in: "+(stopTime-startTime)+" ms."); + } + + public Wrapper addServlet(Context ctx,String servletName,String servletClass) { + Wrapper sw = ctx.createWrapper(); + sw.setServletClass(servletClass); + sw.setName(servletName); + ctx.addChild(sw); + return sw; + } + + public void stop() throws Exception { + if (server==null) { + return; + } + server.stop(); + } + + public ClassLoader getClassLoaderCommon() { + return commonLoader; + } + + public Server getServer() { + return server; + } + + /** + * @return the applicationContext + */ + public Context getApplicationContext() { + return applicationContext; + } +} diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/ui/JApplication.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/ui/JApplication.java new file mode 100644 index 0000000..3c432f3 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/ui/JApplication.java @@ -0,0 +1,35 @@ +package net.forwardfire.vasc.demo.tech.core.ui; + +import java.awt.Dimension; +import java.util.EventObject; + + +import net.forwardfire.vasc.demo.tech.core.VascTechDemo; + +import org.jdesktop.application.FrameView; +import org.jdesktop.application.SingleFrameApplication; + +public class JApplication extends SingleFrameApplication { + + protected void startup() { + addExitListener(new ShutdownManager()); + FrameView mainView = getMainView(); + mainView.setComponent(new JMainPanel()); + mainView.setMenuBar(new JMainPanelMenuBar()); + mainView.getFrame().setMinimumSize(new Dimension(1024-64,768-128)); + show(mainView); + } + + static public JApplication getInstance() { + return getInstance(JApplication.class); + } + + class ShutdownManager implements ExitListener { + public boolean canExit(EventObject e) { + return true; + } + public void willExit(EventObject event) { + VascTechDemo.getInstance().shutdown(); + } + } +} diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/ui/JConsolePanel.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/ui/JConsolePanel.java new file mode 100644 index 0000000..c784326 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/ui/JConsolePanel.java @@ -0,0 +1,180 @@ +/* + * 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.demo.tech.core.ui; + +import java.awt.Color; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Enumeration; +import java.util.logging.Handler; +import java.util.logging.Level; +import java.util.logging.LogManager; +import java.util.logging.LogRecord; +import java.util.logging.Logger; +import java.util.logging.SimpleFormatter; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import javax.swing.ScrollPaneConstants; +import javax.swing.SpringLayout; +import javax.swing.SwingUtilities; + +/** + * JConsolePanel binds to JUL and display log messages in texteara. + * + * @author Willem Cazander + * @version 1.0 May 12, 2012 + */ +public class JConsolePanel extends JPanel implements ActionListener { + + private static final long serialVersionUID = 485766723433479054L; + private UILogHandler logHandler = null; + private JButton clearButton = null; + private JComboBox levelBox = null; + private JTextArea logTextArea = null; + private JCheckBox autoScrollBox = null; + private int logLinesMax = 255; + + public JConsolePanel() { + setLayout(new FlowLayout(FlowLayout.LEFT)); + JPanel wrap = new JPanel(); + wrap.setLayout(new SpringLayout()); + wrap.add(createHeader()); + wrap.add(createEditor()); + SpringLayoutGrid.makeCompactGrid(wrap,2,1); + add(wrap); + + Logger rootLogger = Logger.getAnonymousLogger(); + while (rootLogger.getParent()!=null) { + rootLogger = rootLogger.getParent(); + } + + logHandler = new UILogHandler(); + logHandler.setFormatter(new SimpleFormatter()); + rootLogger.addHandler(logHandler); + + } + + /** + * This needs release if playing the the this tab add/removal very multiple times. + */ + public void release() { + Logger rootLogger = Logger.getAnonymousLogger(); + while (rootLogger.getParent()!=null) { + rootLogger = rootLogger.getParent(); + } + rootLogger.removeHandler(logHandler); + } + + private JPanel createHeader() { + JPanel result = new JPanel(); + result.setBorder(BorderFactory.createLineBorder(Color.BLUE)); + result.setLayout(new FlowLayout(FlowLayout.LEFT)); + result.add(new JLabel("Log Level")); + levelBox = new JComboBox(new Level[] {Level.OFF,Level.SEVERE,Level.WARNING,Level.INFO,Level.FINE,Level.FINER,Level.FINEST,Level.ALL}); + levelBox.setSelectedItem(Level.INFO); + levelBox.addActionListener(this); + result.add(levelBox); + clearButton = new JButton("Clear"); + clearButton.addActionListener(this); + result.add(clearButton); + autoScrollBox = new JCheckBox("Autoscroll"); + autoScrollBox.setSelected(true); + result.add(autoScrollBox); + return result; + } + + private JPanel createEditor() { + JPanel result = new JPanel(); + result.setBorder(BorderFactory.createLineBorder(Color.BLUE)); + logTextArea = new JTextArea(5, 80); + logTextArea.setAutoscrolls(true); + logTextArea.setEditable(false); + JScrollPane logScrollPane = new JScrollPane(logTextArea); + logScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); + logScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); + logScrollPane.getViewport().setOpaque(false); + result.add(logScrollPane); + return result; + } + + public void actionPerformed(ActionEvent e) { + if (clearButton.equals(e.getSource())) { + logTextArea.setText(""); + } else if (levelBox.equals(e.getSource()) && levelBox.getSelectedIndex()!=-1) { + Level level = (Level)levelBox.getSelectedItem(); + logHandler.setLevel(level); + Enumeration loggers = LogManager.getLogManager().getLoggerNames(); + while (loggers.hasMoreElements()) { + String name = loggers.nextElement(); + Logger logger = LogManager.getLogManager().getLogger(name); + if (logger!=null && name.contains("pulsefire")) { + logger.setLevel(level); // only set pulsefire code loggers + } + } + } + } + + class UILogHandler extends Handler { + @Override + public void close() throws SecurityException { + } + @Override + public void flush() { + } + @Override + public void publish(LogRecord record) { + final String recordStr = getFormatter().format(record); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + logTextArea.append(recordStr); + if (logTextArea.getLineCount() > logLinesMax) { + String t = logTextArea.getText(); + int l = 0; + int rm = logLinesMax/2; + for (int i=0;i keys = new HashMap(300); + VascBundleCheckEntryKeys checker = new VascBundleCheckEntryKeys(ResourceBundle.getBundle("net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle")); + for (String veId:vascManager.getVascController().getVascEntryController().getVascEntryIds()) { + VascEntry ve = vascManager.getVascController().getVascEntryController().getVascEntryById(veId); + keys.putAll(checker.generateMissingKeys(ve)); + } + if (keys.isEmpty()==false) { + Properties p = new Properties(); + File dataDir = new File("data"); + + if (dataDir.exists()==false) { + dataDir.mkdirs(); + } + File resourceFile = new File("data/vasc-bundle.properties"); + if (resourceFile.exists()) { + readPropertiesFile(p,resourceFile); + } + for (String key:keys.keySet()) { + if (key==null) { + continue; + } + if (keys.get(key)==null) { + continue; + } + p.put(key, keys.get(key)); + } + writePropertiesFile(p,resourceFile); + + ResourceBundle.clearCache(); + } + } + + public JTabbedPane getTabPane() { + return tabPane; + } + + protected void writePropertiesFile(Properties p,File file) { + try { + writePropertiesStream(p,new FileOutputStream(file)); + } catch (Exception e) { + throw new RuntimeException("Could not load resource file error: "+e.getMessage(),e); + } + } + + + protected void readPropertiesFile(Properties p,File file) { + try { + readPropertiesStream(p,new FileInputStream(file)); + } catch (Exception e) { + throw new RuntimeException("Could not load resource file error: "+e.getMessage(),e); + } + } + + protected void writePropertiesStream(Properties p,OutputStream out) { + try { + p.store(out, "Saved by vasc auto i18n."); + } catch (Exception e) { + throw new RuntimeException("Could not load properties error: "+e.getMessage(),e); + } finally { + if (out!=null) { + try { + out.close(); + } catch (IOException e) { + } + } + } + } + + protected void readPropertiesStream(Properties p,InputStream in) { + try { + p.load(in); + } catch (Exception e) { + throw new RuntimeException("Could not load properties error: "+e.getMessage(),e); + } finally { + if (in!=null) { + try { + in.close(); + } catch (IOException e) { + } + } + } + } + + public void changeEvent() { + rebuildTree(); + } + +} diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/ui/JMainPanelMenuBar.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/ui/JMainPanelMenuBar.java new file mode 100644 index 0000000..8ae8c05 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/ui/JMainPanelMenuBar.java @@ -0,0 +1,188 @@ +/* + * 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.demo.tech.core.ui; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; + +import javax.swing.JFileChooser; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.JTabbedPane; + +import net.forwardfire.vasc.backend.VascBackendControllerLocal; +import net.forwardfire.vasc.core.VascEntryControllerLocal; +import net.forwardfire.vasc.demo.tech.core.VascTechDemo; +import net.forwardfire.vasc.demo.tech.core.ui.actions.JDialogMetaCsv; +import net.forwardfire.vasc.demo.tech.core.ui.actions.JDialogMetaJdbc; +import net.forwardfire.vasc.demo.tech.core.ui.actions.JDialogMetaMongodb; + +/** + * JMainPanelMenuBar Adds all menu bar items. + * + * @author Willem Cazander + * @version 1.0 May 12, 2012 + */ +public class JMainPanelMenuBar extends JMenuBar { + + private static final long serialVersionUID = -2828428804621352725L; + JMenu fileMenu = new JMenu("File"); + JMenu vascMenu = new JMenu("Vasc"); + JMenu tabMenu = new JMenu("Tabs"); + + public JMainPanelMenuBar() { + createMenuItems(); + add(fileMenu); + add(vascMenu); + add(tabMenu); + } + + + private void createMenuItems() { + JMenuItem openXmlItem = new JMenuItem("Import Xml"); + openXmlItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + try { + final JFileChooser fc = new JFileChooser(); + //fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + int returnVal = fc.showOpenDialog((JMenuItem)e.getSource()); + if (returnVal == JFileChooser.APPROVE_OPTION) { + File file = fc.getSelectedFile(); + VascTechDemo.getInstance().getVascControllerService().openFile(file); + } + } catch (Exception e1) { + e1.printStackTrace(); + } + } + + }); + fileMenu.add(openXmlItem); + //JMenuItem closeXmlItem = new JMenuItem("Close"); + //fileMenu.add(closeXmlItem); + fileMenu.addSeparator(); + JMenuItem exitItem = new JMenuItem("Exit"); + exitItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + JApplication.getInstance().exit(); + } + }); + fileMenu.add(exitItem); + + JMenuItem connectVascItem = new JMenuItem("Add Vasc"); + connectVascItem.setEnabled(false); + connectVascItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + + } + }); + vascMenu.add(connectVascItem); + + JMenuItem connectLdapItem = new JMenuItem("Add Ldap"); + connectLdapItem.setEnabled(false); + vascMenu.add(connectLdapItem); + vascMenu.addSeparator(); + JMenuItem connectMetaCsvItem = new JMenuItem("Add meta csv"); + connectMetaCsvItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + JDialogMetaCsv d = new JDialogMetaCsv(JApplication.getInstance().getMainFrame()); + d.setVisible(true); + } + }); + vascMenu.add(connectMetaCsvItem); + JMenuItem connectMetaXmlItem = new JMenuItem("Add meta xml"); + connectMetaXmlItem.setEnabled(false); + vascMenu.add(connectMetaXmlItem); + JMenuItem connectMetaMongoItem = new JMenuItem("Add meta mongo"); + connectMetaMongoItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + JDialogMetaMongodb d = new JDialogMetaMongodb(JApplication.getInstance().getMainFrame()); + d.setVisible(true); + } + }); + vascMenu.add(connectMetaMongoItem); + JMenuItem connectMetaJdbcItem = new JMenuItem("Add meta jdbc"); + connectMetaJdbcItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + JDialogMetaJdbc d = new JDialogMetaJdbc(JApplication.getInstance().getMainFrame()); + d.setVisible(true); + } + }); + vascMenu.add(connectMetaJdbcItem); + + vascMenu.addSeparator(); + JMenuItem removeEntryItem = new JMenuItem("Remove entry"); + removeEntryItem.setEnabled(false); + removeEntryItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + } + }); + vascMenu.add(removeEntryItem); + + JMenuItem removeAllItem = new JMenuItem("Remove all"); + removeAllItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + VascBackendControllerLocal backends = (VascBackendControllerLocal)VascTechDemo.getInstance().getVascControllerService().getVascController().getVascBackendController(); + VascEntryControllerLocal entries = (VascEntryControllerLocal)VascTechDemo.getInstance().getVascControllerService().getVascController().getVascEntryController(); + for (String entryId:entries.getVascEntryIds()) { + if (entryId.startsWith("Vasc")) { + continue; + } + entries.removeVascEntry(entryId); + } + for (String backendId:backends.getVascBackendIds()) { + if (backendId.startsWith("Vasc")) { + continue; + } + backends.removeVascBackendById(backendId); + } + VascTechDemo.getInstance().getVascControllerService().fireChangeEvent(); + } + }); + vascMenu.add(removeAllItem); + + JMenuItem item = new JMenuItem("Close tab"); + item.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + JTabbedPane tabPane = VascTechDemo.getInstance().getSwingGuiService().getTabPane(); + if (tabPane.getSelectedIndex()>=0) { + tabPane.removeTabAt(tabPane.getSelectedIndex()); // todo release vasc frontend + } + } + + }); + tabMenu.add(item); + JMenuItem itemAll = new JMenuItem("Close All tabs"); + itemAll.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + JTabbedPane tabPane = VascTechDemo.getInstance().getSwingGuiService().getTabPane(); + for (int i=tabPane.getTabCount();i>0;i--) { + tabPane.removeTabAt(i-1); // todo release vasc frontend + } + } + + }); + tabMenu.add(itemAll); + } +} diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/ui/SpringLayoutGrid.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/ui/SpringLayoutGrid.java new file mode 100644 index 0000000..ddf654e --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/ui/SpringLayoutGrid.java @@ -0,0 +1,214 @@ +/* + * Copyright (c) 2011, Willem Cazander + * 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.demo.tech.core.ui; + +import java.awt.Component; +import java.awt.Container; + +import javax.swing.Spring; +import javax.swing.SpringLayout; + + +/** + * SpringLayoutGrid, someone should create an JCP to get these functions into + * SpringLayout object because this code is to much duplicated on many projects. + * + * A 1.4 file that provides utility methods for creating form- or grid-style + * layouts with SpringLayout. These utilities are used by several programs, such + * as SpringBox and SpringCompactGrid. + */ +public class SpringLayoutGrid { + + + /** + * Aligns the first rows*cols components of + * parent in a grid. Each component is as big as the maximum + * preferred width and height of the components. The parent is made just big + * enough to fit them all. + * + * @param rows + * number of rows + * @param cols + * number of columns + * @param initialX + * x location to start the grid at + * @param initialY + * y location to start the grid at + * @param xPad + * x padding between cells + * @param yPad + * y padding between cells + */ + public static void makeGrid(Container parent, int rows, int cols,int initialX, int initialY, int xPad, int yPad) { + SpringLayout layout; + try { + layout = (SpringLayout) parent.getLayout(); + } catch (ClassCastException exc) { + throw new IllegalArgumentException("parent container has not StringLayout layoutmanager."); + } + + Spring xPadSpring = Spring.constant(xPad); + Spring yPadSpring = Spring.constant(yPad); + Spring initialXSpring = Spring.constant(initialX); + Spring initialYSpring = Spring.constant(initialY); + int max = rows * cols; + + //Calculate Springs that are the max of the width/height so that all + //cells have the same size. + Spring maxWidthSpring = layout.getConstraints(parent.getComponent(0)) + .getWidth(); + Spring maxHeightSpring = layout.getConstraints(parent.getComponent(0)) + .getWidth(); + for (int i = 1; i < max; i++) { + SpringLayout.Constraints cons = layout.getConstraints(parent + .getComponent(i)); + + maxWidthSpring = Spring.max(maxWidthSpring, cons.getWidth()); + maxHeightSpring = Spring.max(maxHeightSpring, cons.getHeight()); + } + + //Apply the new width/height Spring. This forces all the + //components to have the same size. + for (int i = 0; i < max; i++) { + SpringLayout.Constraints cons = layout.getConstraints(parent + .getComponent(i)); + + cons.setWidth(maxWidthSpring); + cons.setHeight(maxHeightSpring); + } + + //Then adjust the x/y constraints of all the cells so that they + //are aligned in a grid. + SpringLayout.Constraints lastCons = null; + SpringLayout.Constraints lastRowCons = null; + for (int i = 0; i < max; i++) { + SpringLayout.Constraints cons = layout.getConstraints(parent + .getComponent(i)); + if (i % cols == 0) { //start of new row + lastRowCons = lastCons; + cons.setX(initialXSpring); + } else { //x position depends on previous component + cons.setX(Spring.sum(lastCons.getConstraint(SpringLayout.EAST), + xPadSpring)); + } + + if (i / cols == 0) { //first row + cons.setY(initialYSpring); + } else { //y position depends on previous row + cons.setY(Spring.sum(lastRowCons + .getConstraint(SpringLayout.SOUTH), yPadSpring)); + } + lastCons = cons; + } + + //Set the parent's size. + SpringLayout.Constraints pCons = layout.getConstraints(parent); + pCons.setConstraint(SpringLayout.SOUTH, Spring.sum(Spring + .constant(yPad), lastCons.getConstraint(SpringLayout.SOUTH))); + pCons.setConstraint(SpringLayout.EAST, Spring.sum( + Spring.constant(xPad), lastCons + .getConstraint(SpringLayout.EAST))); + } + + /* Used by makeCompactGrid. */ + private static SpringLayout.Constraints getConstraintsForCell(int row, + int col, Container parent, int cols) { + SpringLayout layout = (SpringLayout) parent.getLayout(); + Component c = parent.getComponent(row * cols + col); + return layout.getConstraints(c); + } + + + public static void makeCompactGrid(Container parent, int rows, int cols) { + makeCompactGrid(parent,rows,cols,6,6,6,6); + } + + /** + * Aligns the first rows*cols components of + * parent in a grid. Each component in a column is as wide as + * the maximum preferred width of the components in that column; height is + * similarly determined for each row. The parent is made just big enough to + * fit them all. + * + * @param rows + * number of rows + * @param cols + * number of columns + * @param initialX + * x location to start the grid at + * @param initialY + * y location to start the grid at + * @param xPad + * x padding between cells + * @param yPad + * y padding between cells + */ + public static void makeCompactGrid(Container parent, int rows, int cols,int initialX, int initialY, int xPad, int yPad) { + SpringLayout layout; + try { + layout = (SpringLayout) parent.getLayout(); + } catch (ClassCastException exc) { + throw new IllegalArgumentException("parent container has not StringLayout layoutmanager."); + } + + //Align all cells in each column and make them the same width. + Spring x = Spring.constant(initialX); + for (int c = 0; c < cols; c++) { + Spring width = Spring.constant(0); + for (int r = 0; r < rows; r++) { + width = Spring.max(width, getConstraintsForCell(r, c, parent, + cols).getWidth()); + } + for (int r = 0; r < rows; r++) { + SpringLayout.Constraints constraints = getConstraintsForCell(r, + c, parent, cols); + constraints.setX(x); + constraints.setWidth(width); + } + x = Spring.sum(x, Spring.sum(width, Spring.constant(xPad))); + } + + //Align all cells in each row and make them the same height. + Spring y = Spring.constant(initialY); + for (int r = 0; r < rows; r++) { + Spring height = Spring.constant(0); + for (int c = 0; c < cols; c++) { + height = Spring.max(height, getConstraintsForCell(r, c, parent, + cols).getHeight()); + } + for (int c = 0; c < cols; c++) { + SpringLayout.Constraints constraints = getConstraintsForCell(r, + c, parent, cols); + constraints.setY(y); + constraints.setHeight(height); + } + y = Spring.sum(y, Spring.sum(height, Spring.constant(yPad))); + } + + //Set the parent's size. + SpringLayout.Constraints pCons = layout.getConstraints(parent); + pCons.setConstraint(SpringLayout.SOUTH, y); + pCons.setConstraint(SpringLayout.EAST, x); + } +} diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/ui/actions/JDialogMetaCsv.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/ui/actions/JDialogMetaCsv.java new file mode 100644 index 0000000..3ab9a61 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/ui/actions/JDialogMetaCsv.java @@ -0,0 +1,112 @@ +/* + * 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.demo.tech.core.ui.actions; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.io.File; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JPanel; + +import net.forwardfire.vasc.backend.metamodel.MetaModelDataContextCsv; +import net.forwardfire.vasc.backend.metamodel.MetaModelSchemaAutoEntry; +import net.forwardfire.vasc.demo.tech.core.VascTechDemo; + +/** + * JDialogMetaCsv Add and runs MetaModel Schema Auto Entry code. + * + * @author Willem Cazander + * @version 1.0 May 9, 2012 + */ +public class JDialogMetaCsv extends JDialog implements ActionListener { + + private static final long serialVersionUID = -8638394652416472734L; + + public JDialogMetaCsv(Frame aFrame) { + setTitle("Add csv file"); + setMinimumSize(new Dimension(640,480)); + setPreferredSize(new Dimension(999,666)); + setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent we) { + clearAndHide(); + } + }); + JPanel mainPanel = new JPanel(); + mainPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); + mainPanel.setLayout(new BorderLayout()); + //mainPanel.add(createPanelTop(),BorderLayout.NORTH); + mainPanel.add(createPanelCenter(),BorderLayout.CENTER); + //mainPanel.add(createPanelBottom(),BorderLayout.SOUTH); + getContentPane().add(mainPanel); + pack(); + setLocationRelativeTo(aFrame); + } + + public void clearAndHide() { + setVisible(false); + } + + public JPanel createPanelCenter() { + JPanel result = new JPanel(); + //result.setLayout(new SpringLayout()); + + result.add(new JLabel("File")); + JButton fileButton = new JButton("Open"); + fileButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + final JFileChooser fc = new JFileChooser(); + int returnVal = fc.showOpenDialog((JButton)e.getSource()); + if (returnVal == JFileChooser.APPROVE_OPTION) { + File file = fc.getSelectedFile(); + MetaModelDataContextCsv ds = new MetaModelDataContextCsv(); + ds.setFile(file.getAbsolutePath()); + + MetaModelSchemaAutoEntry schema = new MetaModelSchemaAutoEntry(); + schema.setDataContextProvider(ds); + schema.setEntryPrefix(file.getName()); + schema.autoCreateEntries(VascTechDemo.getInstance().getVascControllerService().getVascController()); + VascTechDemo.getInstance().getVascControllerService().fireChangeEvent(); + } + } + }); + result.add(fileButton); + + return result; + } + + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + + } +} diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/ui/actions/JDialogMetaJdbc.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/ui/actions/JDialogMetaJdbc.java new file mode 100644 index 0000000..ca63158 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/ui/actions/JDialogMetaJdbc.java @@ -0,0 +1,136 @@ +/* + * 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.demo.tech.core.ui.actions; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.SpringLayout; + +import net.forwardfire.vasc.backend.metamodel.MetaModelDataContextJdbc; +import net.forwardfire.vasc.backend.metamodel.MetaModelSchemaAutoEntry; +import net.forwardfire.vasc.demo.tech.core.VascTechDemo; +import net.forwardfire.vasc.demo.tech.core.ui.SpringLayoutGrid; + +/** + * JDialogMetaJdbc Add and runs MetaModel Schema Auto Entry code. + * + * @author Willem Cazander + * @version 1.0 May 9, 2012 + */ +public class JDialogMetaJdbc extends JDialog implements ActionListener { + + private static final long serialVersionUID = -8638394652416472734L; + private JComboBox driverClassBox = null; + private JTextField connectUrlField = null; + private JTextField usernameField = null; + private JTextField passwordField = null; + + + public JDialogMetaJdbc(Frame aFrame) { + setTitle("Add jdbc"); + setMinimumSize(new Dimension(300,200)); + setPreferredSize(new Dimension(500,400)); + setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent we) { + clearAndHide(); + } + }); + JPanel mainPanel = new JPanel(); + mainPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); + mainPanel.setLayout(new BorderLayout()); + //mainPanel.add(createPanelTop(),BorderLayout.NORTH); + mainPanel.add(createPanelCenter(),BorderLayout.CENTER); + //mainPanel.add(createPanelBottom(),BorderLayout.SOUTH); + getContentPane().add(mainPanel); + pack(); + setLocationRelativeTo(aFrame); + } + + public void clearAndHide() { + setVisible(false); + } + + public JPanel createPanelCenter() { + JPanel result = new JPanel(); + result.setLayout(new SpringLayout()); + + result.add(new JLabel("Driver")); + driverClassBox = new JComboBox(new String[] {"org.postgresql.Driver","com.mysql.jdbc.Driver","org.apache.derby.jdbc.EmbeddedDriver","org.hsqldb.jdbcDriver","org.sqlite.JDBC"}); + driverClassBox.setSelectedIndex(0); + result.add(driverClassBox); + + result.add(new JLabel("Url")); + connectUrlField = new JTextField("jdbc:postgresql://localhost/dellstore2"); + result.add(connectUrlField); + + result.add(new JLabel("Username")); + usernameField = new JTextField("postgres"); + result.add(usernameField); + + result.add(new JLabel("Password")); + passwordField = new JTextField("postgresql"); + result.add(passwordField); + + JButton fileButton = new JButton("Connect"); + fileButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + String url = connectUrlField.getText(); + MetaModelDataContextJdbc ds = new MetaModelDataContextJdbc(); + ds.setDriverClass((String)driverClassBox.getSelectedItem()); + ds.setConnectUrl(url); + ds.setUsername(usernameField.getText()); + ds.setPassword(passwordField.getText()); + String dbName = url.substring(url.lastIndexOf('/')+1,url.length()); + MetaModelSchemaAutoEntry schema = new MetaModelSchemaAutoEntry(); + schema.setDataContextProvider(ds); + schema.setEntryPrefix(dbName); + schema.autoCreateEntries(VascTechDemo.getInstance().getVascControllerService().getVascController()); + VascTechDemo.getInstance().getVascControllerService().fireChangeEvent(); + } + }); + result.add(fileButton); + result.add(new JLabel("")); + + SpringLayoutGrid.makeCompactGrid(result, 5, 2); + return result; + } + + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + + } +} diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/ui/actions/JDialogMetaMongodb.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/ui/actions/JDialogMetaMongodb.java new file mode 100644 index 0000000..a31fef9 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/ui/actions/JDialogMetaMongodb.java @@ -0,0 +1,126 @@ +/* + * 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.demo.tech.core.ui.actions; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.SpringLayout; + +import net.forwardfire.vasc.backend.metamodel.MetaModelDataContextMongodb; +import net.forwardfire.vasc.backend.metamodel.MetaModelSchemaAutoEntry; +import net.forwardfire.vasc.demo.tech.core.VascTechDemo; +import net.forwardfire.vasc.demo.tech.core.ui.SpringLayoutGrid; + +/** + * JDialogMetaMongodb Add and runs MetaModel Schema Auto Entry code. + * + * @author Willem Cazander + * @version 1.0 May 9, 2012 + */ +public class JDialogMetaMongodb extends JDialog implements ActionListener { + + private static final long serialVersionUID = -8638394652416472734L; + private JTextField hostNameField = null; + private JTextField hostPortField = null; + private JTextField databaseField = null; + + public JDialogMetaMongodb(Frame aFrame) { + setTitle("Add mongodb"); + setMinimumSize(new Dimension(300,200)); + setPreferredSize(new Dimension(400,300)); + setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent we) { + clearAndHide(); + } + }); + JPanel mainPanel = new JPanel(); + mainPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); + mainPanel.setLayout(new BorderLayout()); + //mainPanel.add(createPanelTop(),BorderLayout.NORTH); + mainPanel.add(createPanelCenter(),BorderLayout.CENTER); + //mainPanel.add(createPanelBottom(),BorderLayout.SOUTH); + getContentPane().add(mainPanel); + pack(); + setLocationRelativeTo(aFrame); + } + + public void clearAndHide() { + setVisible(false); + } + + public JPanel createPanelCenter() { + JPanel result = new JPanel(); + result.setLayout(new SpringLayout()); + + result.add(new JLabel("Hostname")); + hostNameField = new JTextField("localhost"); + result.add(hostNameField); + + result.add(new JLabel("Port")); + hostPortField = new JTextField("27017"); + result.add(hostPortField); + + result.add(new JLabel("Database")); + databaseField = new JTextField("lefiona"); + result.add(databaseField); + + JButton fileButton = new JButton("Connect"); + fileButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + MetaModelDataContextMongodb ds = new MetaModelDataContextMongodb(); + ds.setHostname(hostNameField.getText()); + ds.setPort(new Integer(hostPortField.getText())); + ds.setDatabase(databaseField.getText()); + + MetaModelSchemaAutoEntry schema = new MetaModelSchemaAutoEntry(); + schema.setDataContextProvider(ds); + schema.setEntryPrefix(ds.getDatabase()); + schema.autoCreateEntries(VascTechDemo.getInstance().getVascControllerService().getVascController()); + VascTechDemo.getInstance().getVascControllerService().fireChangeEvent(); + } + }); + result.add(fileButton); + result.add(new JLabel("")); + + SpringLayoutGrid.makeCompactGrid(result, 4, 2); + return result; + } + + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + + } +} diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/x4o/vasc/TomcatResourceElement.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/x4o/vasc/TomcatResourceElement.java new file mode 100644 index 0000000..4aabc4d --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/x4o/vasc/TomcatResourceElement.java @@ -0,0 +1,103 @@ +/* + * 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.demo.tech.core.x4o.vasc; + +import java.util.Map; +import java.util.logging.Logger; + +import net.forwardfire.vasc.demo.tech.core.VascTechDemo; +import net.forwardfire.vasc.demo.tech.core.service.tomcat.TomcatService; + +import org.apache.catalina.Server; +import org.apache.catalina.deploy.ContextResource; +import org.apache.catalina.deploy.NamingResources; +import org.x4o.xml.element.AbstractElement; +import org.x4o.xml.element.ElementException; + +/** + * TomcatResourceElement Add a global DataSource to tomcat jndi context. + * + * @author Willem Cazander + * @version 1.0 May 13, 2012 + */ +public class TomcatResourceElement extends AbstractElement { + + private Logger logger = Logger.getLogger(TomcatResourceElement.class.getName()); + + /** + * @see org.x4o.xml.element.AbstractElement#doElementRun() + */ + @Override + public void doElementRun() throws ElementException { + + // Check needed attributes + Map attr = getAttributes(); + if (attr.containsKey("name")==false) { + throw new ElementException("No attribute name found."); + } + if (attr.containsKey("auth")==false) { + throw new ElementException("No attribute auth found."); + } + if (attr.containsKey("type")==false) { + throw new ElementException("No attribute type found."); + } + + // Set resource object fields. + ContextResource resource = new ContextResource(); + String name = attr.remove("name"); + resource.setName(name); + String auth = attr.remove("auth"); + resource.setAuth(auth); + String type = attr.remove("type"); + resource.setType(type); + String scope = attr.remove("scope"); + if (scope!=null) { + resource.setScope(scope); + } + String closeMethod = attr.remove("closeMethod"); + if (closeMethod!=null) { + resource.setCloseMethod(closeMethod); + } + String singleton = attr.remove("singleton"); + if (singleton!=null) { + resource.setSingleton("true".equalsIgnoreCase(singleton)); + } + String description = attr.remove("description"); + if (description!=null) { + resource.setDescription(description); + } + + // copy other stuff + for (String key:attr.keySet()) { + String value = attr.get(key); + resource.setProperty(key, value); + } + + // add to tomcat + TomcatService tm = VascTechDemo.getInstance().getTomcatService(); + Server server = tm.getServer(); + NamingResources jndiContext = server.getGlobalNamingResources(); + jndiContext.addResource(resource); + logger.info("Added jndi global resource: "+resource.getName()); + } +} diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/resources/META-INF/root-bundle.properties b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/resources/META-INF/root-bundle.properties new file mode 100644 index 0000000..420d223 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/resources/META-INF/root-bundle.properties @@ -0,0 +1,11 @@ + +config.charset=UTF-8 +config.bundles=bundle1,bundle2 + +# bundle list to merge and load +bundle1.uri=net.forwardfire.vasc.demo.tech.core.ui.resources.JApplication + +bundle2.uri=data/vasc-bundle.properties +bundle2.type=FILE +bundle2.optional=true + diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/resources/META-INF/vasc/vasc-namespaces.xml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/resources/META-INF/vasc/vasc-namespaces.xml new file mode 100644 index 0000000..adc9b86 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/resources/META-INF/vasc/vasc-namespaces.xml @@ -0,0 +1,8 @@ + + + + + Vasc namespace for the vasc tech demo + + vasc-tech-demo.eld + \ No newline at end of file diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/resources/META-INF/vasc/vasc-tech-demo.eld b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/resources/META-INF/vasc/vasc-tech-demo.eld new file mode 100644 index 0000000..0871f0c --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/resources/META-INF/vasc/vasc-tech-demo.eld @@ -0,0 +1,5 @@ + + + + + diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/resources/net/forwardfire/vasc/demo/tech/core/service/resources/init-db.sql b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/resources/net/forwardfire/vasc/demo/tech/core/service/resources/init-db.sql new file mode 100644 index 0000000..8561ccf --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/resources/net/forwardfire/vasc/demo/tech/core/service/resources/init-db.sql @@ -0,0 +1,136 @@ +-- +-- Create vasc demo database. +-- + +CREATE TABLE vasc_user ( + id IDENTITY not null primary key, + username varchar not null, + password varchar not null, + description varchar not null, +); +CREATE UNIQUE INDEX vasc_user_username_idx ON vasc_user(username); + +CREATE TABLE vasc_user_role ( + id IDENTITY not null primary key, + username varchar not null, + role varchar not null +); +CREATE INDEX vasc_user_role_username_idx ON vasc_user_role(username); + +CREATE TABLE vasc_user_change_field ( + id IDENTITY not null primary key, + field varchar not null, + name varchar not null, + active boolean not null +); +CREATE INDEX vasc_user_change_field_active_idx ON vasc_user_change_field(active); + +CREATE TABLE vasc_user_change_log ( + id IDENTITY not null primary key, + user_id integer not null, + change_field_id integer not null, + value_old varchar not null, + value_new varchar not null +); +CREATE INDEX vasc_user_change_log_user_id_idx ON vasc_user_change_log(user_id); +CREATE INDEX vasc_user_change_log_id_idx ON vasc_user_change_log(user_id); + +CREATE TABLE vasc_page ( + id IDENTITY not null primary key, + slug varchar not null, + title varchar not null, + i18n_key boolean not null, + active boolean not null, + sitemap boolean not null, + roles varchar not null +); +CREATE INDEX vasc_page_slug_idx ON vasc_page(slug); +CREATE INDEX vasc_page_sitemap_idx ON vasc_page(sitemap); + +CREATE TABLE vasc_page_part ( + id IDENTITY not null primary key, + page_id integer not null, + title varchar not null, + text varchar not null, + i18n_key boolean not null, + active boolean not null, + sitemap boolean not null, + part_order integer not null, + part_type varchar not null, + roles varchar not null +); +CREATE INDEX vasc_page_part_page_id_idx ON vasc_page_part(page_id); +CREATE INDEX vasc_page_part_active_idx ON vasc_page_part(active); +CREATE INDEX vasc_page_part_sitemap_idx ON vasc_page_part(sitemap); + +CREATE TABLE vasc_menu ( + id IDENTITY not null primary key, + href varchar not null, + title varchar not null, + target varchar not null, + active BOOLEAN NOT NULL, + roles varchar not null, + menu_order integer not null, + menu_type varchar not null +); +CREATE INDEX vasc_menu_active_idx ON vasc_menu(active); +CREATE INDEX vasc_menu_type_idx ON vasc_menu(menu_type); + +-- +-- Insert demo data. +-- + +INSERT INTO vasc_user VALUES(1, 'admin','admin123','Demo Admin user'); +INSERT INTO vasc_user VALUES(2, 'demo', 'demo123', 'Demo user'); + +INSERT INTO vasc_user_role VALUES(1, 'admin', 'login'); +INSERT INTO vasc_user_role VALUES(2, 'admin', 'admin'); +INSERT INTO vasc_user_role VALUES(3, 'demo', 'login'); + +INSERT INTO vasc_user_change_field VALUES(1,'Username', 'username', TRUE); +INSERT INTO vasc_user_change_field VALUES(2,'Password', 'password', TRUE); +INSERT INTO vasc_user_change_field VALUES(3,'Description', 'description', TRUE); +INSERT INTO vasc_user_change_field VALUES(4,'Birthdate', 'date_age', TRUE); + +-- ID SLUG TITLE I18N ACTIVE SITEMAP +INSERT INTO vasc_page VALUES(4, 'debug', 'Debug', FALSE, TRUE, FALSE); +INSERT INTO vasc_page VALUES(5, 'contact', '', TRUE, TRUE, TRUE); +INSERT INTO vasc_page VALUES(6, 'help', '', TRUE, TRUE, TRUE); + +INSERT INTO vasc_page_part VALUES(1, 4, 'vasc', '', TRUE,TRUE,TRUE,1,'HTML'); +INSERT INTO vasc_page_part VALUES(2, 4, 'jdbc', '', TRUE,TRUE,TRUE,2,'HTML'); +INSERT INTO vasc_page_part VALUES(3, 4, 'jndi', '', TRUE,TRUE,TRUE,3,'HTML'); +INSERT INTO vasc_page_part VALUES(4, 4, 'logback', '', TRUE,TRUE,TRUE,3,'HTML'); + +INSERT INTO vasc_page_part VALUES(5, 5, 'project', '', TRUE,TRUE,TRUE,1,'WIKI'); +INSERT INTO vasc_page_part VALUES(6, 5, 'support', '', TRUE,TRUE,TRUE,2,'WIKI'); +INSERT INTO vasc_page_part VALUES(7, 5, 'location', '', TRUE,TRUE,TRUE,3,'HTML'); + +INSERT INTO vasc_page_part VALUES(8, 6, 'server', '', TRUE,TRUE,TRUE,1,'WIKI'); +INSERT INTO vasc_page_part VALUES(9, 6, 'vasc', '', TRUE,TRUE,TRUE,2,'WIKI'); +INSERT INTO vasc_page_part VALUES(10,6, 'metamodel','', TRUE,TRUE,TRUE,3,'WIKI'); + + + +-- INSERT INTO vasc_page VALUES(1, 'home','home','Welcome to the vasc demo, please login as admin to view all stuff.'); + +INSERT INTO vasc_menu VALUES(1, '/html/index.jsf','Home','',true,'',1,'BAR_RIGHT'); +INSERT INTO vasc_menu VALUES(2, '/html/admin/debug.jsf','Debug','',true,'admin',2,'BAR_RIGHT'); +INSERT INTO vasc_menu VALUES(3, '/html/admin/index.jsf','Admin','',true,'admin',3,'BAR_RIGHT'); + +INSERT INTO vasc_menu VALUES(4, '/html/index.jsf','Home', '',true,'',1,'BAR_BOTTOM'); +INSERT INTO vasc_menu VALUES(5, '/html/index.jsf','Contact', '',true,'',2,'BAR_BOTTOM'); +INSERT INTO vasc_menu VALUES(6, '/html/index.jsf','Help', '',true,'',3,'BAR_BOTTOM'); +INSERT INTO vasc_menu VALUES(7, '/html/index.jsf','Techno', '',true,'',3,'BAR_BOTTOM'); +INSERT INTO vasc_menu VALUES(8, '/html/index.jsf','Licences', '',true,'',3,'BAR_BOTTOM'); + +INSERT INTO vasc_menu VALUES(10, '/vasc/AdminVascUser/list.jsf', 'Users', '',true,'admin',4,'PAGE_ADMIN'); +INSERT INTO vasc_menu VALUES(11, '/vasc/AdminVascUserRole/list.jsf', 'UserRoles', '',true,'admin',5,'PAGE_ADMIN'); +INSERT INTO vasc_menu VALUES(12, '/vasc/AdminVascUserChangeField/list.jsf', 'ChangeField', '',true,'admin',5,'PAGE_ADMIN'); +INSERT INTO vasc_menu VALUES(13, '/vasc/AdminVascUserChangeLog/list.jsf', 'ChangeFieldLog', '',true,'admin',5,'PAGE_ADMIN'); + +INSERT INTO vasc_menu VALUES(14, '/vasc/AdminVascPage/list.jsf', 'Pages', '',true,'admin',5,'PAGE_ADMIN'); +INSERT INTO vasc_menu VALUES(15, '/vasc/AdminVascPagePart/list.jsf', 'PageParts', '',true,'admin',5,'PAGE_ADMIN'); +INSERT INTO vasc_menu VALUES(16, '/vasc/AdminVascMenu/list.jsf', 'Menu', '',true,'admin',4,'PAGE_ADMIN'); + + diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/resources/net/forwardfire/vasc/demo/tech/core/ui/resources/JApplication.properties b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/resources/net/forwardfire/vasc/demo/tech/core/ui/resources/JApplication.properties new file mode 100644 index 0000000..dd21e39 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/resources/net/forwardfire/vasc/demo/tech/core/ui/resources/JApplication.properties @@ -0,0 +1,148 @@ +# +# Copyright (c) 2011, Willem Cazander +# 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. +# + +# Application's properties +Application.name = Vasc Demo Tech +Application.title = VascDemoTech +Application.vendor = Willem Cazander +Application.homepage = http://vasc.forwardfire.org/ +Application.vendorId = vasc +Application.id = vascdemotech +Application.lookAndFeel = com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel +#Application.icon = images/icon.png + +Application.web.meta.robots = index, follow +Application.web.meta.description = Vasc Tech Demo Web Frontends +Application.web.meta.keywords = demo,forwardfire,x4o,vasc,java + +Application.web.header.logo.alt = Vasc Tech Demo Logo +Application.web.header.login = Login +Application.web.header.logout = Logout + +Application.web.footer.center = Vasc Tech Demo Web Based on JSF and Faclets and Richfaces. +Application.web.footer.left = Copyright © 2012 +Application.web.footer.right = Version 0.4.x(beta) + +generic.active.labelText = active +generic.active.toolTipText = active +generic.createdDate.labelText = createdDate +generic.createdDate.toolTipText = createdDate +generic.description.labelText = description +generic.description.toolTipText = description +generic.id.labelText = id +generic.id.toolTipText = id +generic.modifiedDate.labelText = modifiedDate +generic.modifiedDate.toolTipText = modifiedDate +generic.name.labelText = name +generic.name.toolTipText = name +generic.orderNumber.labelText = orderNumber +generic.orderNumber.toolTipText = orderNumber + +# hibernate validators +validator.assertFalse=assertion failed +validator.assertTrue=assertion failed +validator.future=Date must lie in the future +validator.length=Field must contain between {min} and {max} characters. +validator.max=Value must be equal to or lower than {value} +validator.min=Value must be equal to or higher than {value} +validator.notNull=A value must be entered +validator.past=Date must lie in the future +validator.pattern=Value must conform to "{regex}" +validator.range=Value must lie between {min} and {max} +validator.size=There must be between {min} and {max} characters +validator.email=The value must be a valid e-mail address + +# vasc validators +vasc.validator.VascDateFutureValidator=The date must lie in the future. +vasc.validator.VascDatePastValidator=The date must lie in the past. +vasc.validator.VascIntSizeValidator=Value must lie between {0} and {1} +vasc.validator.VascLongSizeValidator=Value must lie between {0} and {1} +vasc.validator.VascObjectNotNullValidator=A value must be entered +vasc.validator.VascObjectNullValidator=No value may be entered +vasc.validator.VascStringEmailValidator=The value must be a valid e-mail address +vasc.validator.VascStringLengthValidator=There must be at least {0} and at most {1} items +vasc.validator.VascStringRegexValidator=Value must conform to "{0}" +vasc.validator.VascStringZipCodeValidator=Value must be a valid post code. + +# Vasc actions labels +vasc.action.addRowAction.description = add a new record +vasc.action.addRowAction.name = Add +vasc.action.deleteRowAction.description = delete +vasc.action.deleteRowAction.name = delete +vasc.action.downloadAction.description = Select this record. +vasc.action.downloadAction.name = Select +vasc.action.editRowAction.description = edit +vasc.action.editRowAction.name = Edit + +vasc.action.csvExportAction.description = CSV +vasc.action.csvExportAction.name = CSV +vasc.action.xmlExportAction.description = XML +vasc.action.xmlExportAction.name = XML +vasc.action.xmltreeExportAction.description = XMLTree +vasc.action.xmltreeExportAction.name = XMLTree +vasc.action.jrPdfLandscapeExportAction.description = jrPdfLandscape +vasc.action.jrPdfLandscapeExportAction.name = PDF-Landscape +vasc.action.jrPdfPortraitExportAction.description = jrPdfPortrait +vasc.action.jrPdfPortraitExportAction.name = PDF-Portrait +vasc.action.jrRtfExportAction.description = RTF +vasc.action.jrRtfExportAction.name = RTF +vasc.action.jrXlsExportAction.description = XLS +vasc.action.jrXlsExportAction.name = XLS +vasc.action.jrXmlExportAction.description = JR-XML +vasc.action.jrXmlExportAction.name = JR-XML +vasc.action.jrCsvExportAction.description = JR-CSV +vasc.action.jrCsvExportAction.name = JR-CSV + + +# Temp jsf +generic.vasc.jsf.listOption.header = Searchoptions +generic.vasc.jsf.listOption.search = Searh\: +generic.vasc.jsf.listOption.sumbit = Search +generic.vasc.jsf.pager.previous = Previous +generic.vasc.jsf.pager.next = Next +generic.vasc.jsf.table.rows = Row Numbers\: +generic.vasc.jsf.table.pagerDirect = Go to\: +generic.vasc.jsf.table.downloadDirect = Download\: +generic.vasc.jsf.table.resultText = Results {0}-{1} from {2} rows +generic.vasc.jsf.table.download.img = Save table data. +generic.vasc.jsf.table.printer.img = Shows the table in printer friendly format. +generic.vasc.jsf.table.export.select = ... +generic.vasc.jsf.table.export.select.alt = Select Export +generic.vasc.jsf.table.page.select = ... +generic.vasc.jsf.table.page.select.alt = Select Page +generic.vasc.jsf.table.page.name = Page: +generic.vasc.jsf.table.page.description = Goto page: +generic.vasc.jsf.tableHeader.fields = Fields +generic.vasc.jsf.tableHeader.links = Links +generic.vasc.jsf.tableHeader.actions = Actions +generic.vasc.jsf.multiAction.selectAll = Select all: +generic.vasc.jsf.multiAction.name = ... +generic.vasc.jsf.multiAction.description = Select Action +generic.vasc.jsf.action.save = Save +generic.vasc.jsf.action.cancel = Cancel +generic.vasc.jsf.action.back = Back +generic.vasc.jsf.parentSelected = Selected: + +vasc.dialog.edit.message = Edit +vasc.dialog.save.name = Save +vasc.dialog.cancel.name = Cancel \ No newline at end of file diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/pom.xml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/pom.xml index 0b0ac5f..4f3e269 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/pom.xml +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/pom.xml @@ -20,7 +20,7 @@ - + net.forwardfire.vasc vasc-frontend-web-jsf @@ -28,37 +28,45 @@ provided - net.forwardfire.vasc.demo - vasc-demo-tech-core + net.forwardfire.vasc + vasc-backend-metamodel ${project.version} provided - - + + javax + javaee-api + ${javaee-api.version} + provided + - com.sun.facelets - jsf-facelets - 1.1.15.B1 + org.glassfish + javax.faces + ${javax.faces.version} provided - javax.servlet - jstl - 1.2 - provided + org.richfaces.ui + richfaces-components-ui + provided - javax.faces - jsf-api - 1.2_12 - provided + net.jawr + jawr + ${jawr.version} + provided - javax.faces - jsf-impl - 1.2_12 - provided + de.tudarmstadt.ukp.wikipedia + de.tudarmstadt.ukp.wikipedia.api + 0.9.1 + provided - + + org.ocpsoft.rewrite + rewrite-servlet + ${rewrite-servlet.version} + provided + \ No newline at end of file diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/beans/ContextPathController.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/beans/ContextPathController.java new file mode 100644 index 0000000..2e9abbc --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/beans/ContextPathController.java @@ -0,0 +1,46 @@ +/* + * Copyright 2009-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.demo.tech.web.beans; + +import javax.faces.context.FacesContext; + +/** + * ContextPathController removes the / from application.contextPath so root and non-root deployments work correct. + * This a workaround of bug in servlet impl or jsf impl. + * + * @author Willem Cazander + * @version 1.0 May 16, 2012 + */ +//@ManagedBean(name="contextPathController",eager=true) +//@ApplicationScoped +public class ContextPathController { + + public String getRootPath() { + FacesContext context = FacesContext.getCurrentInstance(); + String contextPath = context.getExternalContext().getRequestContextPath(); + if (contextPath.endsWith("/")==false) { + return contextPath; + } + return contextPath.substring(0,contextPath.length()-1); + } +} \ No newline at end of file diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/beans/ExportController.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/beans/ExportController.java index eb4a6e8..629b1cc 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/beans/ExportController.java +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/beans/ExportController.java @@ -6,8 +6,7 @@ import java.util.List; import javax.faces.model.SelectItem; import net.forwardfire.vasc.core.VascController; -import net.forwardfire.vasc.core.entry.VascEntryExporter; -import net.forwardfire.vasc.demo.tech.core.DemoVascControllerProvider; +import net.forwardfire.vasc.impl.jndi.JndiVascControllerProvider; public class ExportController { @@ -17,15 +16,25 @@ public class ExportController { private VascController vascController = null; public ExportController() { - DemoVascControllerProvider provider = new DemoVascControllerProvider(); - vascController = provider.getVascController(); + try { + JndiVascControllerProvider p = new JndiVascControllerProvider(); + p.setJndiName("java:comp/env/vasc/DemoVascController"); + vascController = p.getVascController(); + } catch (Exception e) { + e.printStackTrace(); + } } public List getEntryIdSelectItems() { List result = new ArrayList(); for (String entryId:vascController.getVascEntryController().getVascEntryIds()) { SelectItem i = new SelectItem(); - i.setLabel(entryId); + String label = entryId; + while (label.length()>40) { + label = label.substring(10); + } + i.setLabel("..."+label); + i.setDescription(entryId); i.setValue(entryId); result.add(i); } @@ -34,10 +43,10 @@ public class ExportController { public List getExportTypeSelectItems() { List result = new ArrayList(); - for (VascEntryExporter ex:vascController.getVascEntryConfigController().getVascEntryExporters()) { + for (String exportId:vascController.getVascEntryConfigController().getVascEntryExporterIds()) { SelectItem i = new SelectItem(); - i.setLabel(ex.getId()); - i.setValue(ex.getId()); + i.setLabel(exportId); + i.setValue(exportId); result.add(i); } return result; @@ -46,7 +55,7 @@ public class ExportController { public String getBuildExportUrl() { StringBuilder buff = new StringBuilder(); if (exportTree) { - buff.append("export-tree/"); + buff.append("export/"); buff.append(getEntryId()); buff.append('/'); buff.append(getExportType()); @@ -101,6 +110,4 @@ public class ExportController { public void setExportTree(boolean exportTree) { this.exportTree = exportTree; } - - } diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/beans/UserController.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/beans/UserController.java index b7f63ea..2387795 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/beans/UserController.java +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/beans/UserController.java @@ -22,8 +22,13 @@ package net.forwardfire.vasc.demo.tech.web.beans; +import java.io.IOException; import java.io.Serializable; +import javax.faces.context.FacesContext; +import javax.faces.event.ActionEvent; +import javax.servlet.http.HttpSession; + import net.forwardfire.vasc.demo.tech.web.models.WebUser; /** @@ -34,39 +39,69 @@ import net.forwardfire.vasc.demo.tech.web.models.WebUser; public class UserController implements Serializable { private static final long serialVersionUID = 1L; - private WebUser webUser = null; + static public final String WEB_USER_SESSION_KEY = "webUser"; - public void loginFilter() { + public String getWebUserName() { + WebUser user = getWebUser(); + if (user!=null) { + return user.getFullName(); + } + return "No-name"; + } + + public WebUser getWebUser() { + WebUser user = (WebUser)FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get(WEB_USER_SESSION_KEY); + if (user!=null) { + return user; + } + if (isUserLoggedin()==false) { + try { + FacesContext.getCurrentInstance().getExternalContext().redirect("/demo/html/auth/error.jsf"); + } catch (IOException ioe) { + throw new RuntimeException("Could not redirect user to login-form.: "+ioe.getMessage(),ioe); + } + } + + HttpSession session = (HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(true); + session.setMaxInactiveInterval(20*60); // 20 minutes. + + // fetch user info and settings/etc/etc from db. + user = new WebUser(); + user.setId(123l); + user.setFullName(FacesContext.getCurrentInstance().getExternalContext().getRemoteUser()); + user.setLoginName(FacesContext.getCurrentInstance().getExternalContext().getRemoteUser()); + FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put(WEB_USER_SESSION_KEY, user); + + return user; + } + + public void logoutAction(ActionEvent event) { + HttpSession session = (HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(true); + session.invalidate(); try { - //logUser = loginManager.getUser(); - //logRightRoles = loginManager.getClientRoles(); - - webUser = new WebUser(); - webUser.setLoginName( "test123"); - webUser.setFullName( "test1234567890"); - - } catch (Exception e) { - throw new RuntimeException(e); + FacesContext.getCurrentInstance().getExternalContext().redirect("/demo/html/auth/logout.jsf"); + } catch (IOException ioe) { + throw new RuntimeException("Could not redirect user to login-form.: "+ioe.getMessage(),ioe); } } - public void logoutFilter() { - webUser = null; - //logRightRoles = null; + public boolean hasUserPrincipal() { + return FacesContext.getCurrentInstance().getExternalContext().getUserPrincipal()!=null; + } + + public boolean hasUserRole(String role) { + return FacesContext.getCurrentInstance().getExternalContext().isUserInRole(role); } public boolean isUserLoggedin() { - if (webUser==null) { - return false; - } - return true; + return hasUserRole("login"); } - public WebUser getUser() { - return webUser; + public boolean isRoleUserLogin() { + return hasUserRole("login"); } - //public List getRightRoles() { - // return logRightRoles; - //} + public boolean isRoleUserAdmin() { + return hasUserRole("admin"); + } } \ No newline at end of file diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/faces/NoneLoadStyleResourceEventListener.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/faces/NoneLoadStyleResourceEventListener.java new file mode 100644 index 0000000..2fe406c --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/faces/NoneLoadStyleResourceEventListener.java @@ -0,0 +1,137 @@ +package net.forwardfire.vasc.demo.tech.web.faces; + +import java.io.InputStream; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Properties; +import java.util.concurrent.atomic.AtomicReference; + + +import javax.faces.component.UIViewRoot; +import javax.faces.context.FacesContext; +import javax.faces.event.AbortProcessingException; +import javax.faces.event.PreRenderViewEvent; +import javax.faces.event.SystemEvent; +import javax.faces.event.SystemEventListener; + + +import org.richfaces.resource.ResourceKey; + + +import com.sun.faces.renderkit.html_basic.ScriptRenderer; +import com.sun.faces.renderkit.html_basic.StylesheetRenderer; + + +/** + *

+ * Satisfies that links for selected RichFaces won't be put to renderer view. + *

+ * + *

+ * Resource which should not be loaded are selected by condition in {@link #shouldNotBeLoaded(ResourceKey, String)}. + *

+ * + * @author Lukas Fryc + */ +public class NoneLoadStyleResourceEventListener implements SystemEventListener { + + + private static final String STATIC_MAPPING_FILE = "META-INF/richfaces/staticResourceMapping/Static.properties"; + + + private AtomicReference propertiesRef = new AtomicReference(); + + + public void processEvent(SystemEvent event) throws AbortProcessingException { + if (event instanceof PreRenderViewEvent) { + putSelectedResourceKeysToContextMap(); + } + } + + public boolean isListenerForSource(Object source) { + return source instanceof UIViewRoot; + } + + + /** + *

+ * Adds all keys of resources which meets {@link #shouldNotBeLoaded(ResourceKey, String)} condition to context map. + *

+ * + *

+ * Adding resource key to context map ensures that {@link ScriptRenderer} {@link StylesheetRenderer} won't render the link + * to page. + *

+ */ + private void putSelectedResourceKeysToContextMap() { + FacesContext facesContext = FacesContext.getCurrentInstance(); + loadStaticResourceMappingProperties(); + for (Entry entry : propertiesRef.get().entrySet()) { + ResourceKey resourceKey = ResourceKey.create((String) entry.getKey()); + if (shouldNotBeLoaded(resourceKey)) { + putResourceKeyToContextMap(facesContext, resourceKey); + } + } + } + + + /** + * Loads configuration of static resource mapping which lists all RichFaces resources. + */ + private void loadStaticResourceMappingProperties() { + if (propertiesRef.get() == null) { + Properties loadedProperties = new Properties(); + InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(STATIC_MAPPING_FILE); + try { + loadedProperties.load(inputStream); + } catch (Exception e) { + throw new RuntimeException("Unable to load resource-mapping configuration file", e); + } + propertiesRef.compareAndSet(null, loadedProperties); + } + } + + /** + *

+ * Adds resource key to context map. + *

+ * + *

+ * Adding resource key to context map ensures that {@link ScriptRenderer} {@link StylesheetRenderer} won't render the link + * to page. + *

+ * + * @param facesContext the current {@link FacesContext} instance + * @param resourceKey the key of the resource + */ + private void putResourceKeyToContextMap(FacesContext facesContext, ResourceKey resourceKey) { + Map contextMap = facesContext.getAttributes(); + + String resourceName = resourceKey.getResourceName(); + String libraryName = resourceKey.getLibraryName(); + String key = resourceName + libraryName; + if (!contextMap.containsKey(key)) { // stylesheets (with this name + library) will not be rendered multiple + // times per request + contextMap.put(key, Boolean.TRUE); + } + if (libraryName == null || libraryName.isEmpty()) { // also store this in the context map with library as + // "null" + libraryName = "null"; + key = resourceName + libraryName; + if (!contextMap.containsKey(key)) { + contextMap.put(key, Boolean.TRUE); + } + } + } + + /** + * Returns true if given resourceKey should not be loaded for current view. + * + * @param resourceKey the key of the resource + * @return true if given resourceKey should not be loaded for current view; false otherwise + */ + private boolean shouldNotBeLoaded(ResourceKey resourceKey) { + String resourceName = resourceKey.getResourceName(); + return resourceName.endsWith(".js") || resourceName.endsWith(".css") || resourceName.endsWith(".ecss"); + } +} \ No newline at end of file diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/faces/UrlRewriteConfigurationProvider.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/faces/UrlRewriteConfigurationProvider.java new file mode 100644 index 0000000..404805f --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/faces/UrlRewriteConfigurationProvider.java @@ -0,0 +1,103 @@ +package net.forwardfire.vasc.demo.tech.web.faces; + +import javax.servlet.ServletContext; + +import org.ocpsoft.rewrite.config.And; +import org.ocpsoft.rewrite.config.Condition; +import org.ocpsoft.rewrite.config.Configuration; +import org.ocpsoft.rewrite.config.ConfigurationBuilder; +import org.ocpsoft.rewrite.config.Direction; +import org.ocpsoft.rewrite.config.Operation; +import org.ocpsoft.rewrite.context.EvaluationContext; +import org.ocpsoft.rewrite.event.Rewrite; +import org.ocpsoft.rewrite.servlet.config.Forward; +import org.ocpsoft.rewrite.servlet.config.HttpCondition; +import org.ocpsoft.rewrite.servlet.config.HttpConfigurationProvider; +import org.ocpsoft.rewrite.servlet.config.Path; +import org.ocpsoft.rewrite.servlet.config.Redirect; +import org.ocpsoft.rewrite.servlet.config.rule.Join; +import org.ocpsoft.rewrite.servlet.http.event.HttpServletRewrite; + +public class UrlRewriteConfigurationProvider extends HttpConfigurationProvider { + + public Configuration getConfiguration(ServletContext context) { + HttpCondition authUser = new HttpCondition() { + @Override + public boolean evaluateHttp(HttpServletRewrite httpRewrite,EvaluationContext context) { + return httpRewrite.getRequest().getUserPrincipal()!=null; + } + }; + HttpCondition authUserAdmin = new HttpCondition() { + @Override + public boolean evaluateHttp(HttpServletRewrite httpRewrite,EvaluationContext context) { + return httpRewrite.getRequest().isUserInRole("admin"); + } + }; + + return ConfigurationBuilder.begin() + + .addRule(Join.path("/yoyo").to("/html/index.jsf")) + + .defineRule() + .when(Direction.isInbound(). + and(Path.matches("/login")). + andNot(authUser) + ). + perform( + Redirect.temporary("/html/user/index.jsf") + ) + .defineRule() + .when(Direction.isInbound(). + and(Path.matches("/login")). + and(authUser) + ). + perform( + Forward.to("/html/user/index.jsf") + ) + + + .defineRule() + .when(Direction.isInbound(). + and(Path.matches("/home")). + andNot(authUser) + ). + perform( + Forward.to("/html/index.jsf") + ) + .defineRule() + .when(Direction.isInbound(). + and(Path.matches("/home")). + and(authUserAdmin) + ). + perform( + Forward.to("/html/admin/index.jsf") + ) + .defineRule() + .when(Direction.isInbound(). + and(Path.matches("/home")). + and(authUser) + ). + perform( + Forward.to("/html/user/index.jsf") + ) + + + ; + + /* + .addRule(Join.path("/").to("/pages/loggedOffHome.xhtml") + .when(loggedIn) + + .defineRule() + .when(Direction.isInbound() + .and(Path.matches("/(signup|login)") + .andNot(loggedIn))) + .perform(Redirect.temporary(context.getContextPath() + "/")); + + */ + } + + public int priority() { + return 0; + } +} diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/menu/MenuController.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/menu/MenuController.java new file mode 100644 index 0000000..ed05830 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/menu/MenuController.java @@ -0,0 +1,212 @@ +/* + * Copyright 2009-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.demo.tech.web.menu; + +import java.io.Serializable; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import javax.sql.DataSource; + +import net.forwardfire.vasc.demo.tech.web.beans.UserController; +import net.forwardfire.vasc.demo.tech.web.menu.model.VascMenu; +import net.forwardfire.vasc.demo.tech.web.menu.model.VascMenuType; + +/** + * MenuController Shows the menu for the user. + * + * @author Willem Cazander + * @version 1.0 May 19, 2012 + */ +public class MenuController implements Serializable { + + private static final long serialVersionUID = -6820749860984575869L; + private List userVascMenu = null; + private VascMenuComparator vascMenuComparator = null; + private UserController userController = null; + + + public List fetchVascMenu() { + //if (userVascMenu!=null) { + // return userVascMenu; + //} + vascMenuComparator = new VascMenuComparator(); + userVascMenu = new ArrayList(50); + + /* + MetaModelDataContextJndiDataSource dsFactory = new MetaModelDataContextJndiDataSource(); + dsFactory.setJndiName("java:comp/env/jdbc/vascDemoDS"); + DataContext ds = dsFactory.getDataContext(); + Table table = ds.getDefaultSchema().getTableByName("vasc_menu"); + DataSet data = ds.query().from(table).select(table.getColumns()).execute(); + List result = new ArrayList(50); + Iterator i = data.iterator(); + while (i.hasNext()) { + Row row = i.next(); + }*/ + + + Connection connection = null; + try { + DataSource ds = getDataSource("java:comp/env/jdbc/DemoManagerDataDS"); + connection = ds.getConnection(); + Statement s = connection.createStatement(); + s.execute("SELECT * FROM VASC_MENU"); + ResultSet rs = s.getResultSet(); + //int cols = rs.getMetaData().getColumnCount(); + while (rs.next()) { + VascMenu menu = new VascMenu(); + menu.setId(rs.getInt(1)); + menu.setHref(rs.getString(2)); + menu.setTitle(rs.getString(3)); + menu.setTarget(rs.getString(4)); + menu.setActive(rs.getBoolean(5)); + menu.setRoles(rs.getString(6)); + menu.setMenuOrder(rs.getInt(7)); + menu.setMenuType(VascMenuType.valueOf(rs.getString(8))); + if (filterVascMenuRoles(menu)==false) { + continue; + } + userVascMenu.add(menu); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (connection!=null) { + try { + connection.close(); + } catch (Exception e) { + } + } + } + + return userVascMenu; + } + + private DataSource getDataSource(String name) throws SQLException { + try { + Context initialContext = new InitialContext(); + DataSource datasource = (DataSource)initialContext.lookup(name); + if ( datasource == null ) { + throw new SQLException("Cannot lookup datasource: "+name); + } + return datasource; + } catch ( NamingException e ) { + throw new SQLException("Cannot get connection " + e,e); + } + } + + private boolean filterVascMenuRoles(VascMenu menu) { + if (menu.getActive()!=null && menu.getActive()==false) { + return false; + } + if (menu.getRoles()!=null && menu.getRoles().isEmpty()==false) { + String[] roles = menu.getRoles().split(","); + for (String role:roles) { + if (role.isEmpty()) { + continue; + } + if (userController.hasUserRole(role)==false) { + return false; + } + } + } + return true; + } + + private List getMenuFiltered(VascMenuType type) { + if (type==null) { + throw new NullPointerException("Can't filter on null type."); + } + List result = new ArrayList(15); + for (VascMenu menu:fetchVascMenu()) { + if (type.equals(menu.getMenuType())) { + result.add(menu); + } + } + Collections.sort(result,vascMenuComparator); + return result; + } + + public List getMenuBarLeft() { + return getMenuFiltered(VascMenuType.BAR_LEFT); + } + + public List getMenuBarRight() { + return getMenuFiltered(VascMenuType.BAR_RIGHT); + } + + public List getMenuBarBottom() { + return getMenuFiltered(VascMenuType.BAR_BOTTOM); + } + + public List getMenuPageIndex() { + return getMenuFiltered(VascMenuType.PAGE_INDEX); + } + + public List getMenuPageUserLeft() { + return getMenuFiltered(VascMenuType.PAGE_USER_LEFT); + } + + public List getMenuPageUserRight() { + return getMenuFiltered(VascMenuType.PAGE_USER_RIGHT); + } + + public List getMenuPageAdmin() { + return getMenuFiltered(VascMenuType.PAGE_ADMIN); + } + + public List getMenu0() { + return getMenuFiltered(VascMenuType.MENU0); + } + + public List getMenu1() { + return getMenuFiltered(VascMenuType.MENU1); + } + + public List getMenu2() { + return getMenuFiltered(VascMenuType.MENU2); + } + + /** + * @return the userController + */ + public UserController getUserController() { + return userController; + } + + /** + * @param userController the userController to set + */ + public void setUserController(UserController userController) { + this.userController = userController; + } +} \ No newline at end of file diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/menu/VascMenuComparator.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/menu/VascMenuComparator.java new file mode 100644 index 0000000..b87f0bb --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/menu/VascMenuComparator.java @@ -0,0 +1,50 @@ +/* + * Copyright 2009-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.demo.tech.web.menu; + +import java.io.Serializable; +import java.util.Comparator; + +import net.forwardfire.vasc.demo.tech.web.menu.model.VascMenu; + + +/** + * VascMenuComparator orders the menu items. + * + * @author Willem Cazander + * @version 1.0 May 19, 2012 + */ +public class VascMenuComparator implements Serializable,Comparator { + + private static final long serialVersionUID = 386631856823832371L; + + public int compare(VascMenu m1, VascMenu m2) { + if (m1.getMenuOrder()==null) { + return 1; + } + if (m2.getMenuOrder()==null) { + return -1; + } + return m1.getMenuOrder().compareTo(m2.getMenuOrder()); + } +} \ No newline at end of file diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/menu/model/VascMenu.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/menu/model/VascMenu.java new file mode 100644 index 0000000..4be8125 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/menu/model/VascMenu.java @@ -0,0 +1,153 @@ +/* + * Copyright 2009-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.demo.tech.web.menu.model; + +/** + * VascMenu stores menu item information. + * + * @author Willem Cazander + * @version 1.0 May 19, 2012 + */ +public class VascMenu { + + private Integer id = null; + private String href = null; + private String title = null; + private String target = null; + private Boolean active = null; + private String roles = null; + private Integer menuOrder = null; + private VascMenuType menuType = null; + + /** + * @return the id + */ + public Integer getId() { + return id; + } + + /** + * @param id the id to set + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * @return the href + */ + public String getHref() { + return href; + } + + /** + * @param href the href to set + */ + public void setHref(String href) { + this.href = href; + } + + /** + * @return the title + */ + public String getTitle() { + return title; + } + + /** + * @param title the title to set + */ + public void setTitle(String title) { + this.title = title; + } + + /** + * @return the target + */ + public String getTarget() { + return target; + } + + /** + * @param target the target to set + */ + public void setTarget(String target) { + this.target = target; + } + + /** + * @return the active + */ + public Boolean getActive() { + return active; + } + + /** + * @param active the active to set + */ + public void setActive(Boolean active) { + this.active = active; + } + + /** + * @return the roles + */ + public String getRoles() { + return roles; + } + + /** + * @param roles the roles to set + */ + public void setRoles(String roles) { + this.roles = roles; + } + + /** + * @return the menuOrder + */ + public Integer getMenuOrder() { + return menuOrder; + } + + /** + * @param menuOrder the menuOrder to set + */ + public void setMenuOrder(Integer menuOrder) { + this.menuOrder = menuOrder; + } + + /** + * @return the menuType + */ + public VascMenuType getMenuType() { + return menuType; + } + + /** + * @param menuType the menuType to set + */ + public void setMenuType(VascMenuType menuType) { + this.menuType = menuType; + } +} diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/menu/model/VascMenuType.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/menu/model/VascMenuType.java new file mode 100644 index 0000000..fc66fd0 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/menu/model/VascMenuType.java @@ -0,0 +1,46 @@ +/* + * Copyright 2009-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.demo.tech.web.menu.model; + +/** + * VascMenuType defines all menu lists on page. + * + * @author Willem Cazander + * @version 1.0 May 26, 2012 + */ +public enum VascMenuType { + + BAR_LEFT, + BAR_RIGHT, + BAR_BOTTOM, + + MENU0, + MENU1, + MENU2, + + PAGE_INDEX, + PAGE_USER_LEFT, + PAGE_USER_RIGHT, + PAGE_ADMIN, + PAGE_HELP +} diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/models/WebUser.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/models/WebUser.java index be7ffb9..6a89c55 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/models/WebUser.java +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/models/WebUser.java @@ -1,16 +1,24 @@ package net.forwardfire.vasc.demo.tech.web.models; -import java.util.ArrayList; -import java.util.List; public class WebUser { + private Long id = null; private String loginName = null; private String fullName = null; - private List groups = null; - - public WebUser() { - groups = new ArrayList(20); + + /** + * @return the id + */ + public Long getId() { + return id; + } + + /** + * @param id the id to set + */ + public void setId(Long id) { + this.id = id; } /** @@ -40,11 +48,4 @@ public class WebUser { public void setFullName(String fullName) { this.fullName = fullName; } - - /** - * @return the groups - */ - public List getGroups() { - return groups; - } } diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/pages/VascPageController.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/pages/VascPageController.java new file mode 100644 index 0000000..dcb0a70 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/pages/VascPageController.java @@ -0,0 +1,167 @@ +/* + * Copyright 2009-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.demo.tech.web.pages; + +import java.io.Serializable; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import javax.sql.DataSource; + +import net.forwardfire.vasc.demo.tech.web.beans.UserController; +import net.forwardfire.vasc.demo.tech.web.menu.VascMenuComparator; + +/** + * MenuController Shows the menu for the user. + * + * @author Willem Cazander + * @version 1.0 May 19, 2012 + */ +public class VascPageController implements Serializable { + + private static final long serialVersionUID = -6820749860984575869L; + //private List userVascMenu = null; + //private VascMenuComparator vascMenuComparator = null; + private UserController userController = null; + + /* + public List fetchVascPage() { + + vascMenuComparator = new VascMenuComparator(); + userVascMenu = new ArrayList(50); + + + + Connection connection = null; + try { + DataSource ds = getDataSource("java:comp/env/jdbc/DemoManagerDataDS"); + connection = ds.getConnection(); + Statement s = connection.createStatement(); + s.execute("SELECT * FROM VASC_MENU"); + ResultSet rs = s.getResultSet(); + //int cols = rs.getMetaData().getColumnCount(); + while (rs.next()) { + VascMenu menu = new VascMenu(); + menu.setId(rs.getInt(1)); + menu.setHref(rs.getString(2)); + menu.setTitle(rs.getString(3)); + menu.setTarget(rs.getString(4)); + menu.setActive(rs.getBoolean(5)); + menu.setRoles(rs.getString(6)); + menu.setMenuOrder(rs.getInt(7)); + menu.setMenuType(VascMenuType.valueOf(rs.getString(8))); + if (filterVascMenuRoles(menu)==false) { + continue; + } + userVascMenu.add(menu); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (connection!=null) { + try { + connection.close(); + } catch (Exception e) { + } + } + } + + return userVascMenu; + } + + private DataSource getDataSource(String name) throws SQLException { + try { + Context initialContext = new InitialContext(); + DataSource datasource = (DataSource)initialContext.lookup(name); + if ( datasource == null ) { + throw new SQLException("Cannot lookup datasource: "+name); + } + return datasource; + } catch ( NamingException e ) { + throw new SQLException("Cannot get connection " + e,e); + } + } + + private boolean filterVascMenuRoles(VascMenu menu) { + if (menu.getActive()!=null && menu.getActive()==false) { + return false; + } + if (menu.getRoles()!=null && menu.getRoles().isEmpty()==false) { + String[] roles = menu.getRoles().split(","); + for (String role:roles) { + if (role.isEmpty()) { + continue; + } + if (userController.hasUserRole(role)==false) { + return false; + } + } + } + return true; + } + + private List getMenuFiltered(VascMenuType type) { + if (type==null) { + throw new NullPointerException("Can't filter on null type."); + } + List result = new ArrayList(15); + for (VascMenu menu:fetchVascMenu()) { + if (type.equals(menu.getMenuType())) { + result.add(menu); + } + } + Collections.sort(result,vascMenuComparator); + return result; + } + + public List getMenuBarLeft() { + return getMenuFiltered(VascMenuType.BAR_LEFT); + } + + public List getMenuBarRight() { + return getMenuFiltered(VascMenuType.BAR_RIGHT); + } +*/ + + /** + * @return the userController + */ + public UserController getUserController() { + return userController; + } + + /** + * @param userController the userController to set + */ + public void setUserController(UserController userController) { + this.userController = userController; + } +} \ No newline at end of file diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/pages/model/VascPage.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/pages/model/VascPage.java new file mode 100644 index 0000000..8848299 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/pages/model/VascPage.java @@ -0,0 +1,139 @@ +/* + * Copyright 2009-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.demo.tech.web.pages.model; + + + +/** + * VascPage stores dynamic page information. + * + * @author Willem Cazander + * @version 1.0 May 31, 2012 + */ +public class VascPage { + + private Integer id = null; + private String slug = null; + private String title = null; + private Boolean i18nKey = null; + private Boolean active = null; + private Boolean sitemap = null; + private String roles = null; + + /** + * @return the id + */ + public Integer getId() { + return id; + } + /** + * @param id the id to set + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * @return the slug + */ + public String getSlug() { + return slug; + } + + /** + * @param slug the slug to set + */ + public void setSlug(String slug) { + this.slug = slug; + } + + /** + * @return the title + */ + public String getTitle() { + return title; + } + + /** + * @param title the title to set + */ + public void setTitle(String title) { + this.title = title; + } + + /** + * @return the i18nKey + */ + public Boolean getI18nKey() { + return i18nKey; + } + + /** + * @param i18nKey the i18nKey to set + */ + public void setI18nKey(Boolean i18nKey) { + this.i18nKey = i18nKey; + } + + /** + * @return the active + */ + public Boolean getActive() { + return active; + } + + /** + * @param active the active to set + */ + public void setActive(Boolean active) { + this.active = active; + } + + /** + * @return the sitemap + */ + public Boolean getSitemap() { + return sitemap; + } + + /** + * @param sitemap the sitemap to set + */ + public void setSiteMap(Boolean sitemap) { + this.sitemap = sitemap; + } + + /** + * @return the roles + */ + public String getRoles() { + return roles; + } + + /** + * @param roles the roles to set + */ + public void setRoles(String roles) { + this.roles = roles; + } +} diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/pages/model/VascPagePart.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/pages/model/VascPagePart.java new file mode 100644 index 0000000..b72d7eb --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/pages/model/VascPagePart.java @@ -0,0 +1,185 @@ +/* + * Copyright 2009-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.demo.tech.web.pages.model; + + + +/** + * VascPage stores dynamic page part data. + * + * @author Willem Cazander + * @version 1.0 May 31, 2012 + */ +public class VascPagePart { + + private Integer id = null; + private VascPage vascPage = null; + private String title = null; + private String text = null; + private Boolean i18nKey = null; + private Boolean active = null; + private Boolean sitemap = null; + private Integer partOrder = null; + private VascPagePartType partType = null; + private String roles = null; + + /** + * @return the id + */ + public Integer getId() { + return id; + } + + /** + * @param id the id to set + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * @return the vascPage + */ + public VascPage getVascPage() { + return vascPage; + } + + /** + * @param vascPage the vascPage to set + */ + public void setVascPage(VascPage vascPage) { + this.vascPage = vascPage; + } + + /** + * @return the title + */ + public String getTitle() { + return title; + } + + /** + * @param title the title to set + */ + public void setTitle(String title) { + this.title = title; + } + + /** + * @return the text + */ + public String getText() { + return text; + } + + /** + * @param text the text to set + */ + public void setText(String text) { + this.text = text; + } + + /** + * @return the i18nKey + */ + public Boolean getI18nKey() { + return i18nKey; + } + + /** + * @param i18nKey the i18nKey to set + */ + public void setI18nKey(Boolean i18nKey) { + this.i18nKey = i18nKey; + } + + /** + * @return the active + */ + public Boolean getActive() { + return active; + } + + /** + * @param active the active to set + */ + public void setActive(Boolean active) { + this.active = active; + } + + /** + * @return the sitemap + */ + public Boolean getSitemap() { + return sitemap; + } + + /** + * @param sitemap the sitemap to set + */ + public void setSitemap(Boolean sitemap) { + this.sitemap = sitemap; + } + + /** + * @return the partOrder + */ + public Integer getPartOrder() { + return partOrder; + } + + /** + * @param partOrder the partOrder to set + */ + public void setPartOrder(Integer partOrder) { + this.partOrder = partOrder; + } + + /** + * @return the partType + */ + public VascPagePartType getPartType() { + return partType; + } + + /** + * @param partType the partType to set + */ + public void setPartType(VascPagePartType partType) { + this.partType = partType; + } + + /** + * @return the roles + */ + public String getRoles() { + return roles; + } + + /** + * @param roles the roles to set + */ + public void setRoles(String roles) { + this.roles = roles; + } +} diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/pages/model/VascPagePartType.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/pages/model/VascPagePartType.java new file mode 100644 index 0000000..7447b50 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/pages/model/VascPagePartType.java @@ -0,0 +1,36 @@ +/* + * Copyright 2009-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.demo.tech.web.pages.model; + +/** + * VascPagePartType defines value type of text. + * + * @author Willem Cazander + * @version 1.0 May 31, 2012 + */ +public enum VascPagePartType { + + HTML, + PRE, + WIKI +} diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/servlets/TestServlet.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/servlets/TestServlet.java new file mode 100644 index 0000000..de6e61f --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/servlets/TestServlet.java @@ -0,0 +1,34 @@ +package net.forwardfire.vasc.demo.tech.web.servlets; + +import java.io.IOException; +import java.io.PrintWriter; + +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +@WebServlet(name="testServlet",value={"/test"}) +public class TestServlet extends HttpServlet { + + private static final long serialVersionUID = -7624183395089913214L; + + /** + * Prints test + * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) + */ + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse response) throws ServletException, IOException { + try { + StringBuffer buf = new StringBuffer(); + buf.append("test"); + PrintWriter out = response.getWriter(); + out.append(buf.toString()); + out.flush(); + } catch (Exception e) { + e.printStackTrace(); + } + + } +} diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/META-INF/jawr.properties b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/META-INF/jawr.properties new file mode 100644 index 0000000..2ed6100 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/META-INF/jawr.properties @@ -0,0 +1,87 @@ +# +# Vasc Tech Demo Jawr config file. +# +# Takes care of our js and css of this web site. +# + +# Common jawr properties +jawr.gzip.on=true +jawr.gzip.ie6.on=false +jawr.charset.name=UTF-8 +jawr.debug.overrideKey=jawr_debug +jawr.config.reload.refreshKey=jawr_refresh + +# Development mode flags +jawr.debug.on=true +jawr.config.reload.interval=3 + + +# +# Define common js properties +# +jawr.js.bundle.basedir=/js +#jawr.js.bundle.factory.bundlepostprocessors=YUI,license + +# Define js bundle mappings +jawr.js.bundle.names=map_default,map_vasc,map_wiki,map_skin +jawr.js.bundle.map_default.id=/jawr/default.js +jawr.js.bundle.map_default.composite=true +jawr.js.bundle.map_default.child.names=richfaces +jawr.js.bundle.map_vasc.id=/jawr/vasc.js +jawr.js.bundle.map_vasc.composite=true +jawr.js.bundle.map_vasc.child.names=richfaces,vasc +jawr.js.bundle.map_wiki.id=/jawr/wiki.js +jawr.js.bundle.map_wiki.composite=true +jawr.js.bundle.map_wiki.child.names=richfaces,richfaces-ckeditor +jawr.js.bundle.map_skin.id=/jawr/skin.js +jawr.js.bundle.map_skin.composite=true +jawr.js.bundle.map_skin.child.names=richfaces,skin-switcher + +# Define js bundle resources +jawr.js.bundle.skin-switcher.mappings=skinSwitcher:switcher.js +jawr.js.bundle.vasc.mappings=/js/vasc-jsf.js + +jawr.js.bundle.richfaces.mappings=\ +jar:/META-INF/resources/jquery.js,\ +jar:/META-INF/resources/jquery.focus.js,\ +jar:/META-INF/resources/jquery.position.js,\ +jar:/META-INF/resources/richfaces.js,\ +jar:/META-INF/resources/richfaces-base-component.js,\ +jar:/META-INF/resources/richfaces-utils.js,\ +jar:/META-INF/resources/richfaces-queue.js,\ +jar:/META-INF/resources/richfaces-event.js,\ +jar:/META-INF/resources/richfaces-selection.js,\ +jar:/META-INF/resources/richfaces-jsf-event.js,\ +jar:/META-INF/resources/richfaces-jsf-log.js + +jawr.js.bundle.richfaces-atmosphere.mappings=\ +jar:/META-INF/resources/net.java.dev.atmosphere/jquery-atmosphere.js + +jawr.js.bundle.richfaces-ckeditor.mappings=\ +jar:/META-INF/resources/org.richfaces.ckeditor/ckeditor.js + +# +# Define common css properties +# +jawr.css.bundle.basedir=/css +jawr.csslinks.flavor=xhtml_ext +jawr.css.skin.default.root.dirs=/css/skins/default + +# Define css bundle mappings +jawr.css.bundle.names=map_default +jawr.css.bundle.map_default.id=/jawr/default.css +jawr.css.bundle.map_default.composite=true +jawr.css.bundle.map_default.child.names=html,skin + +# Define css bundles resources +jawr.css.bundle.html.mappings=/css/html.css +jawr.css.bundle.skin.mappings=\ +skin:/css/skins/default/layout.css,\ +skin:/css/skins/default/style.css,\ +skin:/css/skins/default/richfaces.css,\ +skin:/css/skins/default/vasc-jsf.css,\ +skin:/css/skins/default/theme.css + + + + diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/META-INF/services/org.ocpsoft.rewrite.config.ConfigurationProvider b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/META-INF/services/org.ocpsoft.rewrite.config.ConfigurationProvider new file mode 100644 index 0000000..2045b70 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/META-INF/services/org.ocpsoft.rewrite.config.ConfigurationProvider @@ -0,0 +1 @@ +net.forwardfire.vasc.demo.tech.web.faces.UrlRewriteConfigurationProvider diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/faces-config.xml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/faces-config.xml new file mode 100644 index 0000000..0c0b3db --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/faces-config.xml @@ -0,0 +1,65 @@ + + + + + + net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle + i18n + + + en + + + net.forwardfire.vasc.demo.tech.web.faces.NoneLoadStyleResourceEventListener + javax.faces.event.PreRenderViewEvent + + + + + Fixes the context path for root vs non-root deployments. + contextPathController + net.forwardfire.vasc.demo.tech.web.beans.ContextPathController + application + + + + Controls the Users + userController + net.forwardfire.vasc.demo.tech.web.beans.UserController + application + + + + Controls the display of the dynamic menus. + menuController + net.forwardfire.vasc.demo.tech.web.menu.MenuController + session + + userController + #{userController} + + + + + Controls Vasc Export Url Generator + exportController + net.forwardfire.vasc.demo.tech.web.beans.ExportController + session + + + + + jawr.JavascriptBundle + net.jawr.web.taglib.jsf.JavascriptBundleTag + + + jawr.CSSBundle + net.jawr.web.taglib.jsf.CSSBundleTag + + + \ No newline at end of file diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/page-error.xhtml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/page-error.xhtml new file mode 100644 index 0000000..a29b028 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/page-error.xhtml @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/page-no-js.xhtml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/page-no-js.xhtml new file mode 100644 index 0000000..8f7402d --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/page-no-js.xhtml @@ -0,0 +1,3 @@ + + + diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/page-public.xhtml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/page-public.xhtml new file mode 100644 index 0000000..d5da9df --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/page-public.xhtml @@ -0,0 +1,7 @@ + + diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/page-user.xhtml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/page-user.xhtml new file mode 100644 index 0000000..d5da9df --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/page-user.xhtml @@ -0,0 +1,7 @@ + + diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/page-vasc.xhtml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/page-vasc.xhtml new file mode 100644 index 0000000..224f8ed --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/page-vasc.xhtml @@ -0,0 +1,307 @@ + + + + + + + + + + + + +

+ + + +

+ + + + +
+
+ + + + +

+ + + +

+ + + +
+
+ + + + +

+ + + + + + +

+ +
    +
  • + +
  • +
    +
+ + + +
+
+ + +

+ + +

+
+
+
+ + + + +

+ + + +

+ +

+ + + +

+
+ + + + + +
    +
  • + + + + +
  • + +
  • +
    +
+ + + + + + + + +
+ +
    +
  • + + +
  • + +
  • + + +
  • +
    + + +
  • + + +
  • +
    + +
  • ...
  • + +
  • + + +
  • +
    +
    +
  • ...
  • + +
  • + + +
  • +
    +
    +
  • + + +
  • +
+
+ + + + + + + + + + + #{entrySupport.i18nMap['generic.vasc.jsf.table.download.img']} + + + + + + #{entrySupport.i18nMap['generic.vasc.jsf.table.printer.img']} + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + #{entrySupport.i18nMap['generic.vasc.jsf.table.download.img']} + + + + + + #{entrySupport.i18nMap['generic.vasc.jsf.table.printer.img']} + + + + + + + + +
    +
  • + + +
  • + +
  • + + +
  • +
    + + +
  • + + +
  • +
    + +
  • ...
  • + +
  • + + +
  • +
    +
    +
  • ...
  • + +
  • + + +
  • +
    +
    +
  • + + +
  • +
+
+
+
+
+
+ +

+ +

+
+
+
+
+ +
+
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/page-wiki.xhtml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/page-wiki.xhtml new file mode 100644 index 0000000..5a4f401 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/page-wiki.xhtml @@ -0,0 +1,18 @@ + + + + + + + + + +

+ +
+
+
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-body-decorator.xhtml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-body-decorator.xhtml new file mode 100644 index 0000000..a26a050 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-body-decorator.xhtml @@ -0,0 +1,52 @@ + + +
+
+

+ +

+ +
+
+

+ +

+ +
+
+

+ +

+ +
+
+
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-body-footer.xhtml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-body-footer.xhtml new file mode 100644 index 0000000..a22b473 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-body-footer.xhtml @@ -0,0 +1,27 @@ + + + diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-body-header.xhtml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-body-header.xhtml new file mode 100644 index 0000000..6de2e35 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-body-header.xhtml @@ -0,0 +1,36 @@ + + + diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-body.xhtml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-body.xhtml new file mode 100644 index 0000000..6f3c07b --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-body.xhtml @@ -0,0 +1,30 @@ + + +
+ + + + +
+

+ + + + + + + + +
+
+
+
+
+
+
\ No newline at end of file diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-head.xhtml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-head.xhtml new file mode 100644 index 0000000..174afbf --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-head.xhtml @@ -0,0 +1,28 @@ + + + + + + + + + + + <ui:insert name="main_head_title"> + <ui:insert name="page_title"/> + </ui:insert> + + + + + + + + diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main.xhtml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main.xhtml new file mode 100644 index 0000000..97141e6 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main.xhtml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/web.xml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/web.xml index 15e698a..56851f0 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/web.xml +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/web.xml @@ -1,84 +1,19 @@ - - + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> + Vasc Demo Tech Web Application - /jsp/index_jsp.jsp + /html/index.jsf 4 - - - XHTML - *.xhtml - - - Include files - No direct access to include files. - /jsp/includes/* - POST - GET - - - No direct browser access to include files. - inaccessible - - - NONE - - - - - - - FORM - VascDemoSecurity - - /jsp/login/login.jsf - /jsp/login/login-error.jsf - - - - + user @@ -91,6 +26,83 @@ inaccessible + + + Protect Resources + *.xhtml + + + + + + User Required + + User pages + /html/user/* + + + login + + + + + Admin User Required + + Admin pages + /html/admin/* + + + admin + + + + + + FORM + VascDemoSecurity + + /html/auth/login.jsf + /html/auth/error.jsf + + + + + 400 + /html/error/status/400-bad-request.jsf + + + 401 + /html/error/status/401-unauthorized.jsf + + + 403 + /html/error/status/403-forbidden.jsf + + + 404 + /html/error/status/404-not-found.jsf + + + 405 + /html/error/status/405-method-not-allowed.jsf + + + 414 + /html/error/status/414-request-uri-too-long.jsf + + + 500 + /html/error/status/500-internal-error.jsf + + + javax.faces.application.ViewExpiredException + /html/error/view-expired.jsf + + + java.lang.Throwable + /html/error/throwable.jsf + + - + + + + - - Comma separated list of URIs of (additional) faces - config files.(e.g./WEB-INF/my-config.xml) See JSF1.0 PRD 2,10.3.2 - - javax.faces.CONFIG_FILES - /WEB-INF/faces.xml + javax.faces.PARTIAL_STATE_SAVING + false javax.faces.STATE_SAVING_METHOD server - - javax.faces.DEFAULT_SUFFIX - .xhtml - - - facelets.REFRESH_PERIOD - 2 - - - facelets.DEVELOPMENT - true - - - - - com.sun.faces.config.ConfigureListener - - - The JSF Servlet facesServlet javax.faces.webapp.FacesServlet 1 @@ -146,100 +138,121 @@ facesServlet *.jsf - - + + + - org.richfaces.SKIN - vasc-demo-tech + org.richfaces.enableControlSkinning + false + - - - org.richfaces.CONTROL_SKINNING - enable - + + JsServlet + net.jawr.web.servlet.JawrServlet + + configLocation + /META-INF/jawr.properties + + + mapping + /_js/ + + 2 + + + CssServlet + net.jawr.web.servlet.JawrServlet + + configLocation + /META-INF/jawr.properties + + + mapping + /_css/ + + + type + css + + 3 + + + JsServlet + /_js/* + + + CssServlet + /_css/* + - - - RichFaces Filter - richfaces - org.ajax4jsf.Filter - - - richfaces - facesServlet - REQUEST - FORWARD - INCLUDE - - - + + VASC Filter vascFilter net.forwardfire.vasc.frontend.web.jsf.VascRequestFacesFilter templateFile - /jsp/includes/vasc-template.jsf + /WEB-INF/template/page-vasc.jsf - resourceBundle - net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle + vascControllerProvider + java:comp/env/vasc/DemoVascController@net.forwardfire.vasc.impl.jndi.JndiVascControllerProvider - vascFilter /vasc/* REQUEST + - vascExportServlet net.forwardfire.vasc.frontend.web.export.VascExportServlet vascControllerProvider - net.forwardfire.vasc.demo.tech.core.DemoVascControllerProvider + java:comp/env/vasc/DemoVascController@net.forwardfire.vasc.impl.jndi.JndiVascControllerProvider + 4 vascExportServlet /export - - - - vascExportServletTree - net.forwardfire.vasc.frontend.web.export.VascExportServlet - - vascControllerProvider - net.forwardfire.vasc.demo.tech.core.DemoVascControllerProvider - - - exportTree - true - - - vascExportServletTree - /export-tree/* + vascExportServlet + /export/* - vascCXFServlet net.forwardfire.vasc.frontend.cxf.server.web.VascCXFServlet vascControllerProvider - net.forwardfire.vasc.demo.tech.core.DemoVascControllerProvider + java:comp/env/vasc/DemoVascController@net.forwardfire.vasc.impl.jndi.JndiVascControllerProvider + 5 vascCXFServlet /cxf/* + + diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/css/html.css b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/css/html.css new file mode 100644 index 0000000..a7395e6 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/css/html.css @@ -0,0 +1,19 @@ + +* { + margin:0px; + padding:0px; +} + +ul { + margin-left:1em; + padding-left:1em; +} + +a { + text-decoration:none; +} + +object, embed { + outline:0; +} + diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/css/site.css b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/css/site.css index 2da186b..125f5cc 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/css/site.css +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/css/site.css @@ -1,18 +1,7 @@ -/* HTML STYLES */ - -* { - margin:0px; - padding:0px; -} - body { - font-family: Arial, Helvetica, sans-serif; - font-size: 15px; - color: #000000; - margin: 0px; - padding: 0px; - background-color:white; + color:#000000; + background-color:#FFFFFF; } h1 { @@ -22,26 +11,19 @@ h1 { } h2 { - -moz-border-radius:3px; - -webkit-border-radius:3px; - -khtml-border-radius:3px; + border-radius:3px; display:block; font-size:1.0em; font-weight:bold; padding:10px 10px 10px 10px; } -a { - color:#004DEB; - text-decoration:underline; -} - p { margin:10px 10px 10px 10px; } img { - border: none; + border:none; vertical-align: middle; } @@ -49,42 +31,13 @@ ul { margin-left:10px; } +a { + text-decoration:underline; +} + + /* DIVS */ -#page_wrap{ - margin:10px; - margin-top:0px; - float:none; -} - -#page_header{ - height:80px; - font-size:18px; - border-bottom:1px solid #DDCCCC; - position:relative; -} - -#page_header a img{ - border:none; - padding-right:10px; - vertical-align:middle; -} - -#page_content { - margin-top:5px; -} - -#page_footer { - margin-top:35px; - padding: 5px; - font-size: 12px; - border-color:#e5e5e5; - border-style:solid; - border-width:1px 1px 1px 1px; - -moz-border-radius:3px; - -webkit-border-radius:3px; - -khtml-border-radius:3px; -} /* MENU */ @@ -139,88 +92,6 @@ ul { } -.actionbox{ - background-color:#DDCCCC; - -moz-border-radius:3px; - -webkit-border-radius:3px; - -khtml-border-radius:3px; - border:none; - -moz-border-radius-topleft:0; - -webkit-border-top-left-radius:0; - -khtml-border-radius-topleft:0; - clear:both; - padding:3px 0 3px 3px; - display:block; -} -.actionbox label{display:inline;} -ul.actionboxtab{margin:0;padding:0;} -ul.actionboxtab li{list-style-type:none;float:left;margin:0;padding:0;} -ul.actionboxtab li a { - border:solid 1px #ddd; - border-bottom-width:0; - -moz-border-radius-topleft:3px; - -moz-border-radius-topright:3px; - -khtml-border-radius-topright:3px; - -webkit-border-top-left-radius:3px; - -webkit-border-top-right-radius:3px; - -khtml-border-radius-topleft:3px; - font-weight:700; - display:block; - margin-right:5px;color:#000; - padding:3px 15px; -} -ul.actionboxtab li a.active{background-color:#DDCCCC;border:solid 1px #DDCCCC;text-decoration:none;} -ul.actionboxtab li a:hover{background-color:#DDCCCC;border:solid 1px #DDCCCC;text-decoration:none;} -td.tableactions{border-bottom-color:#bbb;text-align:left;} - - -ul.paging{ - clear:both; - margin-bottom:5px; - margin-top:5px; - display:block; - float:left; - padding-top:3px; - padding-bottom:3px; - width:100%; - list-style:none; -} -ul.paging li,ul.paging span{float:left;margin:0 2px 0 2px;} -.paging_thispage{font-weight:700;padding:0 6px;} -ul.paging .paging_atstart{margin-right:10px;}ul.paging .paging_atend{margin-left:10px;} -ul.paging .paging_atstart a,ul.paging .nolink.paging_atstart{ - padding-left:15px; -} -ul.paging .paging_atend a,ul.paging .nolink.paging_atend{ - padding-right:15px; -} -ul.paging .paging_next{ - margin-left:20px; - border:1px solid #DDD; - -moz-border-radius:3px; - -webkit-border-radius:3px; - -khtml-border-radius:3px; - padding:2px 6px; -} - -ul.paging .paging_prev{ - margin-right:20px; - border:1px solid #DDD; - -moz-border-radius:3px; - -webkit-border-radius:3px; - -khtml-border-radius:3px; - padding:2px 6px; -} -ul.paging a,ul.paging .paging_link{ - border:1px solid #DDD; - -moz-border-radius:3px; - -webkit-border-radius:3px; - -khtml-border-radius:3px; - padding:2px 6px; -} -ul.paging .paging_break{ - font-weight:700;padding:2px 6px; -} @@ -311,50 +182,9 @@ table.table5 tr:nth-child(even) { } -.rich-table-subheader { - background-color:#DDCCCC; - border-top: 1px solid #C0C0C0; - border-left: 1px solid #C0C0C0; -} -.rich-table { - border-top: none; - border-left: none; -} -.rich-table-row { - border-left: 1px solid #C0C0C0; -} -.rich-table-headercell,.rich-table-footercell { - background-color: #FFF; - border: none; - padding-left: 0px; - padding-right: 0px; - font-weight: none; -} - -.rich-table-thead { - border: none; -} - -.rich-table-header { - background: none; -} - -.homepage_stats { - margin-top:10px; - margin-bottom:10px; -} - - .homepage_stats_big { - color:#004DEB; - margin-top:5px; - margin-bottom:5px; - font-size: 20px; - display:block; - font-weight: normal; - } /* MESSAGES */ @@ -436,41 +266,7 @@ table.table5 tr:nth-child(even) { /* LOGINBOX */ -/* Text styles */ -.text_justify { - text-align:justify; -} - -.text_left { - text-align:left; -} - -.text_right { - text-align:right; -} - -.text_center { - text-align:center; -} - -.text_middle { - vertical-align:middle!important; -} - -.text_top { - vertical-align:top; -} - -/* OTHER STYLES */ - -.no_wrap { - white-space: nowrap; -} - -.no_border { - border:none; -} /* diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/css/skins/default/layout.css b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/css/skins/default/layout.css new file mode 100644 index 0000000..9b51d91 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/css/skins/default/layout.css @@ -0,0 +1,54 @@ + + +body { + margin: 10px; +} + +#body-content { + margin: 10px auto; + padding: 10px; +} + +#page-header { + height: 1.5em; +} + +#page-header-left { + float:left; +} + +#page-header-info { + float:right; + padding-right: 20%; +} + +#page-header-right { + float:right; +} + +#page-header-left,#page-header-right { + padding-top: 10px; +} + + + + +#body-footer { + text-align: center; + padding: 5px; + margin-left:20em; + margin-right:20em; + margin-top:1em; +} + +#body-deco-logo { + position: absolute; + right: 20px; + top: 50px; +} + +#body-deco-menu { + position: absolute; + right: 20px; + top: 150px; +} diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/css/skins/default/richfaces.css b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/css/skins/default/richfaces.css new file mode 100644 index 0000000..d95b8c6 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/css/skins/default/richfaces.css @@ -0,0 +1,34 @@ + + +.rf-p { + padding: 10px; + +} + +.rf-p-hdr { + padding-bottom: 10px; +} + +.rf-p-b { + +} + + +.rf-dt-shdr { +} + +.rf-dt { +} + +.rf-dt-r { +} + +.rf-dt-hdr { +} + +.rf-dt-hdr-c,.rf-dt-ftr-c { +} + +.rf-dt-thd { +} + diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/css/skins/default/style.css b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/css/skins/default/style.css new file mode 100644 index 0000000..599477e --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/css/skins/default/style.css @@ -0,0 +1,34 @@ + + + +.text-justify { + text-align:justify; +} + +.text-left { + text-align:left; +} + +.text-right { + text-align:right; +} + +.text-center { + text-align:center; +} + +.text-middle { + vertical-align:middle!important; +} + +.text-top { + vertical-align:top; +} + +.no-wrap { + white-space: nowrap; +} + +.no-border { + border:none; +} \ No newline at end of file diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/css/skins/default/theme.css b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/css/skins/default/theme.css new file mode 100644 index 0000000..92ca226 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/css/skins/default/theme.css @@ -0,0 +1,170 @@ + + +body { + font-size:85%; + font-family: Georgia, serif; + color: #462102; + background-image: url(/demo/img/skin/default/body-bg.jpg); +} + +#body-content { + border: 1px solid #ccc; + background-image: url(/demo/img/skin/default/body-view-bg.png); +} + +#page-header-left a,#page-header-right a,#page-header-info-body { + padding:10px; + padding-bottom:5px; +} +#page-header-left a,#page-header-right a,#page-header-info-body { + background-color:#DDCCCC; + font-weight:bold; + border-top-left-radius:5px; + border-top-right-radius:5px; +} + +#body-footer { + border-color:#e5e5e5; + border-style:solid; + border-width:1px 1px 1px 1px; + border-radius:3px; +} + + + +h1 { + padding: 0; + font-style: italic; + color: #2d1100; + font-size: xx-large; +} + +h2 { + font-style: italic; + float: right; + margin-top: -45px; + padding: 10px; + color: #2d1100; +} + +h3 { + font-family: Georgia, serif; + color: #2d1100; + font-style: italic; + margin-top: 20px; + margin-bottom: 5px; +} + +h3 span { + border-top-left-radius:5px; + border-left: 1px solid #BBBBBB; + border-top: 1px solid #BBBBBB; + padding-top:2px; + padding-left:5px; + padding-right: 40px; + padding-bottom: 4x; +} + + +/* + +#summary { + float: left; + width: 200px; + margin-right: 15px; + text-align: center; + border: 1px solid #ccc; + padding: 5px; + font-family: Georgia, serif; + font-style: italic; + +} + +*/ + +#body-deco-logo { + +} +#body-deco-menu { + padding:10px; +} + +#body-deco-logo-div,#body-deco-menu0-div,#body-deco-menu1-div,#body-deco-menu2-div { + /* + font: 10px verdana, sans-serif; + padding: 10px; + margin-top: 130px; + width: 130px; + border: 1px solid #ccc; + background-image: url(../../../img/skin/default/wrapper2.png); +*/ +} + + +#body-deco-menu { + border-radius:5px; + border: 1px solid #BBBBBB; +} + + + +.rf-p { + border-radius:5px; + border: 1px solid #BBBBBB; + margin: 5px; + padding: 0px; +} + +.rf-p-hdr { + padding:5px; + border-bottom: 1px solid #BBBBBB; + font-weight:bold; +} + +.rf-p-b { + + padding-top:10px; + padding-left:5px; + padding-bottom:10px; + padding-right:5px; +} + + + + + + +input,textarea,select{ + padding: 3px; + background: none repeat scroll 0 0 transparent; + border: 2px solid rgba(66, 60, 24, 0.6); + border-radius:3px; + margin-right: 5px; + margin-bottom: 2px; +} + +input:hover,textarea:hover,select:hover{ + border: 2px solid rgba(200, 224, 64, 0.6); +} + +.even { + background-color:rgba(170, 180, 60, 0.6); +} + +.odd { + background-color:rgba(210, 230, 120, 0.6); +} + +#page-header-left a,#page-header-right a,#page-header-info-body,.rf-dt-shdr-c a,.table_sub_header { + background-color:rgba(218, 247, 82, 0.6); +} + +.table_options_bottom, .table_options_top, .actionbox, ul.actionboxtab li a.active,.rf-p-hdr { + background-color:rgba(200, 224, 64, 0.6); +} + +ul.actionboxtab li a:hover,#page-header-left a:hover,#page-header-right a:hover,#page-header-info-body:hover { + background-color:rgba(165, 182, 33, 0.6); +} + + diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/css/skins/default/vasc-jsf.css b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/css/skins/default/vasc-jsf.css new file mode 100644 index 0000000..6725fca --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/css/skins/default/vasc-jsf.css @@ -0,0 +1,168 @@ + + +.actionbox{ + background-color:#DDCCCC; + border-radius:3px; + border-top-left-radius:0; + border:none; + clear:both; + padding:3px 0 3px 3px; + /* display:block; */ +} +.actionbox label{display:inline;} +ul.actionboxtab{margin:0;padding:0;} +ul.actionboxtab li{list-style-type:none;float:left;margin:0;padding:0;} +ul.actionboxtab li a { + background-color:rgba(218, 247, 82, 0.6); + border-bottom-width:0; + border-top-left-radius:3px; + border-top-right-radius:3px; + font-weight:700; + display:block; + margin-right:5px;color:#000; + padding:3px 15px; +} +ul.actionboxtab li a.active{background-color:#DDCCCC;text-decoration:none;} +ul.actionboxtab li a:hover{background-color:#DDCCCC;text-decoration:none;} +td.tableactions{border-bottom-color:#bbb;text-align:left;} + + +ul.paging{ + clear:both; + margin-bottom:5px; + margin-top:5px; + display:block; + float:left; + padding-top:3px; + padding-bottom:3px; + width:100%; + list-style:none; +} +ul.paging li,ul.paging span{float:left;margin:0 2px 0 2px;} +.paging_thispage{font-weight:700;padding:0 6px;} +ul.paging .paging_atstart{margin-right:10px;}ul.paging .paging_atend{margin-left:10px;} +ul.paging .paging_atstart a,ul.paging .nolink.paging_atstart{ + padding-left:15px; +} +ul.paging .paging_atend a,ul.paging .nolink.paging_atend{ + padding-right:15px; +} +ul.paging .paging_next{ + margin-left:20px; + border:1px solid #DDD; + border-radius:3px; + padding:2px 6px; +} + +ul.paging .paging_prev{ + margin-right:20px; + border:1px solid #DDD; + border-radius:3px; + padding:2px 6px; +} +ul.paging a,ul.paging .paging_link{ + border:1px solid #DDD; + border-radius:3px; + padding:2px 6px; +} +ul.paging .paging_break{ + font-weight:700;padding:2px 6px; +} + + + + +.rf-dt-shdr { + border-top:1px solid #BBBBBB; +} + +.rf-dt-shdr-c a { + background-color:rgba(233, 233, 233, 0.6); + border-bottom-left-radius:5px; + border-bottom-right-radius:5px; + border-left: 1px solid #BBBBBB; + border-right: 1px solid #BBBBBB; + border-bottom: 1px solid #BBBBBB; + padding-left:5px; + padding-right:5px; + padding-bottom:2px; + display: block; +} + +.rf-dt-shdr-c { + font-size:14px; + font-weight:700; + padding-top:0px; + padding-bottom:5px; +} + +.rf-dt { + border-collapse:collapse; +} + +.rf-dt-r { +} + +.rf-dt-c { + padding:3px 7px 2px 7px; + border-left: 1px solid #BBBBBB; + border-right: 1px solid #BBBBBB; +} + +.rf-dt-hdr { + background: none; +} + +.rf-dt-hdr-c,.rf-dt-ftr-c { + /* background-color: #FFF; */ + border: none; + padding-left: 0px; + padding-right: 0px; + font-weight: none; +} + +.rf-dt-thd { + border: none; +} + + +.table_options_top { + border-top-left-radius:3px; + border-top-right-radius:3px; + background-color:#DDCCCC; + font-size:12px; + font-weight:700; + padding:6px 15px; + display: block; +} + +.table_options_bottom { + border-bottom-left-radius:3px; + border-bottom-right-radius:3px; + background-color:#DDCCCC; + font-size:12px; + font-weight:700; + padding:6px 15px; + margin-top:5px; + display: block; +} + + +.table_sub_header { + border-top-left-radius:5px; + border-top-right-radius:5px; + background-color:rgba(233, 233, 233, 0.6); + border-top:1px solid #BBBBBB; + border-left:1px solid #BBBBBB; + border-right:1px solid #BBBBBB; + display:block; + font-size:14px; + font-weight:700; + margin-left:0px; + margin-right:0px; + margin-top:2px; + padding-top:2px; + text-align:center; +} + + diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/css/skins/green/theme.css b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/css/skins/green/theme.css new file mode 100644 index 0000000..be0bae5 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/css/skins/green/theme.css @@ -0,0 +1,5 @@ + +body { + color: #00FF00; +} + diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/css/skins/notheme/theme.css b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/css/skins/notheme/theme.css new file mode 100644 index 0000000..7aa2316 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/css/skins/notheme/theme.css @@ -0,0 +1,4 @@ + + +/* No theme */ + diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/admin/debug-style.xhtml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/admin/debug-style.xhtml new file mode 100644 index 0000000..8897940 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/admin/debug-style.xhtml @@ -0,0 +1,42 @@ + + Debug Style + +
+

+

Here all css styles should be showed to tune.

+
+
+

+

Sample text

+
+
+

+

Sample text

+
+
+

+

Sample text

+
+
+

+

Sample text

+
+
+
+

Sample text

+
+
+
+

Sample text

+
+
+

etc

+
+
+
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/admin/debug.xhtml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/admin/debug.xhtml new file mode 100644 index 0000000..ea795a4 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/admin/debug.xhtml @@ -0,0 +1,45 @@ + + Debug Tools + +
+

+

Here is is possible to edit all editable tables.

+

+ +

+
+
+

+

Check all resources in jndi tree's.

+

+

    +
  • +
  • +
+

+
+
+

+

Raw access to the embedded db.

+

+ +

+
+
+

+

Status servlet of logback.

+

+

    +
  • +
  • +
+

+
+
+
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/admin/index.xhtml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/admin/index.xhtml new file mode 100644 index 0000000..6046d2d --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/admin/index.xhtml @@ -0,0 +1,63 @@ + + Admin Index + + + + + + +

Manage you data.

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/auth/error.xhtml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/auth/error.xhtml new file mode 100644 index 0000000..9d4c88d --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/auth/error.xhtml @@ -0,0 +1,11 @@ + + Error + + + + \ No newline at end of file diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/auth/forgot.xhtml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/auth/forgot.xhtml new file mode 100644 index 0000000..25df96b --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/auth/forgot.xhtml @@ -0,0 +1,11 @@ + + Forgot + + + + diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/auth/login.xhtml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/auth/login.xhtml new file mode 100644 index 0000000..05fccbb --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/auth/login.xhtml @@ -0,0 +1,26 @@ + + Login + +
+ + + + + + + + + + + + + +
+
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/auth/logout.xhtml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/auth/logout.xhtml new file mode 100644 index 0000000..70acf33 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/auth/logout.xhtml @@ -0,0 +1,11 @@ + + Logout + + + + diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/error/status/400-bad-request.xhtml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/error/status/400-bad-request.xhtml new file mode 100644 index 0000000..deb4d75 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/error/status/400-bad-request.xhtml @@ -0,0 +1,7 @@ + + + + diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/error/status/404-not-found.xhtml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/error/status/404-not-found.xhtml new file mode 100644 index 0000000..3d56322 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/error/status/404-not-found.xhtml @@ -0,0 +1,7 @@ + + + + diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/error/view-expired.xhtml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/error/view-expired.xhtml new file mode 100644 index 0000000..8421829 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/error/view-expired.xhtml @@ -0,0 +1,7 @@ + + + + diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/index.xhtml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/index.xhtml new file mode 100644 index 0000000..e9c287f --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/index.xhtml @@ -0,0 +1,29 @@ + + Index + + + + + + + + + + + + + + + + + diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/user/index.xhtml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/user/index.xhtml new file mode 100644 index 0000000..23a69f3 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/user/index.xhtml @@ -0,0 +1,33 @@ + + User Index + + + + + + + + + + + + + + + + + diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/user/profile.xhtml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/user/profile.xhtml new file mode 100644 index 0000000..cfec6f0 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/user/profile.xhtml @@ -0,0 +1,26 @@ + + + + + Skins + + + + + + + + + diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/img/logo.png b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/img/logo.png new file mode 100644 index 0000000..7c2a57d Binary files /dev/null and b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/img/logo.png differ diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/img/skin/default/body-bg.jpg b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/img/skin/default/body-bg.jpg new file mode 100644 index 0000000..49391a5 Binary files /dev/null and b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/img/skin/default/body-bg.jpg differ diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/img/skin/default/body-view-bg.png b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/img/skin/default/body-view-bg.png new file mode 100644 index 0000000..914e8a3 Binary files /dev/null and b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/img/skin/default/body-view-bg.png differ diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/js/vasc-jsf.js b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/js/vasc-jsf.js new file mode 100644 index 0000000..c821a1e --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/js/vasc-jsf.js @@ -0,0 +1,10 @@ + +function selectAllCheckboxes(x) { + for (var i=0,l=x.form.length; i javax.jws jsr181-api - 1.0-MR1 + ${jsr181-api.version}
\ No newline at end of file diff --git a/vasc-frontend/vasc-frontend-cxf/vasc-frontend-cxf-server/pom.xml b/vasc-frontend/vasc-frontend-cxf/vasc-frontend-cxf-server/pom.xml index 51eaec9..e0c0f0b 100644 --- a/vasc-frontend/vasc-frontend-cxf/vasc-frontend-cxf-server/pom.xml +++ b/vasc-frontend/vasc-frontend-cxf/vasc-frontend-cxf-server/pom.xml @@ -23,27 +23,27 @@ org.apache.cxf cxf-rt-transports-http - 2.6.0 + ${cxf-rt.version} org.apache.cxf cxf-rt-databinding-jaxb - 2.6.0 + ${cxf-rt.version} org.apache.cxf cxf-rt-frontend-jaxws - 2.6.0 + ${cxf-rt.version} org.apache.cxf cxf-rt-frontend-jaxrs - 2.6.0 + ${cxf-rt.version} javax.servlet servlet-api - 2.5 + ${servlet-api.version} jar provided diff --git a/vasc-frontend/vasc-frontend-cxf/vasc-frontend-cxf-server/src/main/java/net/forwardfire/vasc/frontend/cxf/server/web/VascCXFServlet.java b/vasc-frontend/vasc-frontend-cxf/vasc-frontend-cxf-server/src/main/java/net/forwardfire/vasc/frontend/cxf/server/web/VascCXFServlet.java index 0edc912..33053b5 100644 --- a/vasc-frontend/vasc-frontend-cxf/vasc-frontend-cxf-server/src/main/java/net/forwardfire/vasc/frontend/cxf/server/web/VascCXFServlet.java +++ b/vasc-frontend/vasc-frontend-cxf/vasc-frontend-cxf-server/src/main/java/net/forwardfire/vasc/frontend/cxf/server/web/VascCXFServlet.java @@ -63,13 +63,23 @@ public class VascCXFServlet extends CXFNonSpringServlet { if (exportTreeStr!=null && "true".equalsIgnoreCase(exportTreeStr)) { exportTree = true; } + String classArgument = null; + int atIndex = className.indexOf('@'); + if (atIndex > 0) { + classArgument = className.substring(0,atIndex); + className = className.substring(atIndex+1); + } try { ClassLoader cl = Thread.currentThread().getContextClassLoader(); if (cl == null) { cl = className.getClass().getClassLoader(); } Class clazz = cl.loadClass(className); - vascControllerProvider = (VascControllerProvider)clazz.newInstance(); + if (classArgument==null) { + vascControllerProvider = (VascControllerProvider)clazz.newInstance(); + } else { + vascControllerProvider = (VascControllerProvider)clazz.getConstructor(String.class).newInstance(classArgument); + } } catch (Exception e) { throw new ServletException("Could not create VascControllerProvider: "+e.getMessage(),e); } diff --git a/vasc-frontend/vasc-frontend-swing/pom.xml b/vasc-frontend/vasc-frontend-swing/pom.xml index 1a16857..191b5bd 100644 --- a/vasc-frontend/vasc-frontend-swing/pom.xml +++ b/vasc-frontend/vasc-frontend-swing/pom.xml @@ -16,17 +16,16 @@ com.michaelbaranov microba - 0.4.4.1 + ${microba.version} de.odysseus.juel @@ -35,7 +34,7 @@ test - net.forwardfire.vasc + net.forwardfire.vasc.test vasc-test-frontend-data ${project.version} test diff --git a/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/SwingActionPanel.java b/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/SwingActionPanel.java index 2a6b248..c2890da 100644 --- a/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/SwingActionPanel.java +++ b/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/SwingActionPanel.java @@ -66,7 +66,7 @@ public class SwingActionPanel extends JPanel implements VascEntryFrontendEventLi result.add(new JLabel("Row Numbers: ")); rowNumberField = new JTextField(6); rowNumberField.addActionListener(this); - rowNumberField.setText(""+vascEntry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageSize()); + rowNumberField.setText(""+vascEntry.getVascFrontendController().getVascEntryState().getVascBackendState().getPageSize()); result.add(rowNumberField); result.add(new JLabel("Go to: ")); gotoDirectPage = new JComboBox(); @@ -83,7 +83,7 @@ public class SwingActionPanel extends JPanel implements VascEntryFrontendEventLi //add(result); - vascEntry.getVascFrontendData().addVascEntryFrontendEventListener(this); + vascEntry.getVascFrontendController().addVascEntryFrontendEventListener(this); } class DownloadListCellRenderer extends JLabel implements ListCellRenderer { @@ -105,14 +105,14 @@ public class SwingActionPanel extends JPanel implements VascEntryFrontendEventLi } if (rowNumberField.equals(event.getSource())) { int pageSize = new Integer(rowNumberField.getText()); - vascEntry.getVascFrontendData().getVascEntryState().getVascBackendState().setPageSize(pageSize); - vascEntry.getVascFrontendData().getVascFrontendActions().refreshData(); + vascEntry.getVascFrontendController().getVascEntryState().getVascBackendState().setPageSize(pageSize); + vascEntry.getVascFrontendController().getVascFrontendActions().refreshData(); } if (gotoDirectPage.equals(event.getSource())) { if (gotoDirectPage.getSelectedIndex()==0) { return; } - vascEntry.getVascFrontendData().getVascFrontendActions().pageAction(gotoDirectPage.getSelectedIndex() - 1); + vascEntry.getVascFrontendController().getVascFrontendActions().pageAction(gotoDirectPage.getSelectedIndex() - 1); gotoDirectPage.setSelectedIndex(0); } if (gotoDownload.equals(event.getSource())) { @@ -130,7 +130,7 @@ public class SwingActionPanel extends JPanel implements VascEntryFrontendEventLi try { action.doGlobalAction(vascEntry); } catch (Exception e) { - vascEntry.getVascFrontendData().getVascFrontendHelper().handleException(vascEntry, e); + vascEntry.getVascFrontendController().getVascFrontendHelper().handleException(vascEntry, e); } // restore normal view for next request. @@ -160,10 +160,10 @@ public class SwingActionPanel extends JPanel implements VascEntryFrontendEventLi init = true; - long pageSize = entry.getVascFrontendData().getVascFrontendPager().getPageSize(); - long pageStart = entry.getVascFrontendData().getVascFrontendPager().getPageStartCount(); - long pageStop = entry.getVascFrontendData().getVascFrontendPager().getPageStopCount(); - long pageTotalCount = entry.getVascFrontendData().getVascFrontendPager().getPageTotalRecordCount(); + long pageSize = entry.getVascFrontendController().getVascFrontendPager().getPageSize(); + long pageStart = entry.getVascFrontendController().getVascFrontendPager().getPageStartCount(); + long pageStop = entry.getVascFrontendController().getVascFrontendPager().getPageStopCount(); + long pageTotalCount = entry.getVascFrontendController().getVascFrontendPager().getPageTotalRecordCount(); String format = "Results %1$d-%2$d from %3$d rows"; resultLabel.setText(String.format(format, pageStart, pageStop, pageTotalCount)); rowNumberField.setText(""+pageSize); @@ -171,7 +171,7 @@ public class SwingActionPanel extends JPanel implements VascEntryFrontendEventLi gotoDirectPage.removeAllItems(); gotoDirectPage.addItem("Goto..."); - List pages = vascEntry.getVascFrontendData().getVascFrontendPager().getTablePagesFromBackend(); + List pages = vascEntry.getVascFrontendController().getVascFrontendPager().getTablePagesFromBackend(); int i=0; for (VascBackendPageNumber page:pages) { //pages.setRowIndex(i); @@ -259,8 +259,33 @@ public class SwingActionPanel extends JPanel implements VascEntryFrontendEventLi public GlobalVascAction clone() { return this; } + + public Integer getOrder() { + // TODO Auto-generated method stub + return null; + } + + public Boolean getView() { + // TODO Auto-generated method stub + return null; + } + + public String getRolesView() { + // TODO Auto-generated method stub + return null; + } + + public Object cloneCreate() throws CloneNotSupportedException { + // TODO Auto-generated method stub + return null; + } + + public void cloneFields(Object cloneObject) + throws CloneNotSupportedException { + // TODO Auto-generated method stub + + } }; - empty.setName("..."); gotoDownload.addItem(empty); for (GlobalVascAction a:entry.getExportActions()) { diff --git a/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/SwingPagerPanel.java b/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/SwingPagerPanel.java index 29fbb86..ef0df5b 100644 --- a/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/SwingPagerPanel.java +++ b/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/SwingPagerPanel.java @@ -51,14 +51,14 @@ public class SwingPagerPanel extends JPanel implements VascEntryFrontendEventLis this.vascEntry=vascEntry; result = new JPanel(); add(result); - vascEntry.getVascFrontendData().addVascEntryFrontendEventListener(this); + vascEntry.getVascFrontendController().addVascEntryFrontendEventListener(this); } public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof JButton) { JButton but = (JButton)e.getSource(); Integer page = new Integer(but.getText()); - vascEntry.getVascFrontendData().getVascFrontendActions().pageAction(page); + vascEntry.getVascFrontendController().getVascFrontendActions().pageAction(page); } } @@ -68,14 +68,14 @@ public class SwingPagerPanel extends JPanel implements VascEntryFrontendEventLis this.next=next; } public void actionPerformed(ActionEvent e) { - int pageIndex = vascEntry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageIndex(); + int pageIndex = vascEntry.getVascFrontendController().getVascEntryState().getVascBackendState().getPageIndex(); if (next) { - if (vascEntry.getVascFrontendData().getVascFrontendPager().getHasPageNextAction()) { - vascEntry.getVascFrontendData().getVascFrontendActions().pageAction(pageIndex+1); + if (vascEntry.getVascFrontendController().getVascFrontendPager().getHasPageNextAction()) { + vascEntry.getVascFrontendController().getVascFrontendActions().pageAction(pageIndex+1); } } else { - if (vascEntry.getVascFrontendData().getVascFrontendPager().getHasPagePreviousAction()) { - vascEntry.getVascFrontendData().getVascFrontendActions().pageAction(pageIndex-1); + if (vascEntry.getVascFrontendController().getVascFrontendPager().getHasPagePreviousAction()) { + vascEntry.getVascFrontendController().getVascFrontendActions().pageAction(pageIndex-1); } } } @@ -91,12 +91,12 @@ public class SwingPagerPanel extends JPanel implements VascEntryFrontendEventLis result.removeAll(); - if (entry.getVascFrontendData().getVascFrontendPager().getHasExtendedPageMode()) { + if (entry.getVascFrontendController().getVascFrontendPager().getHasExtendedPageMode()) { JButton prev = new JButton("Previous"); prev.addActionListener(new NextAction(false)); - prev.setEnabled(entry.getVascFrontendData().getVascFrontendPager().getHasPagePreviousAction()); + prev.setEnabled(entry.getVascFrontendController().getVascFrontendPager().getHasPagePreviousAction()); result.add(prev); - List pages = entry.getVascFrontendData().getVascFrontendPager().getTablePagesExtendedBegin(); + List pages = entry.getVascFrontendController().getVascFrontendPager().getTablePagesExtendedBegin(); for(VascBackendPageNumber page:pages) { JButton but = new JButton(""+page.getPageNumber()); but.addActionListener(this); @@ -106,8 +106,8 @@ public class SwingPagerPanel extends JPanel implements VascEntryFrontendEventLis result.add(but); } result.add(new JLabel("...")); - if (entry.getVascFrontendData().getVascFrontendPager().getHasExtendedPageModeCenter()) { - pages = entry.getVascFrontendData().getVascFrontendPager().getTablePagesExtendedCenter(); + if (entry.getVascFrontendController().getVascFrontendPager().getHasExtendedPageModeCenter()) { + pages = entry.getVascFrontendController().getVascFrontendPager().getTablePagesExtendedCenter(); for(VascBackendPageNumber page:pages) { JButton but = new JButton(""+page.getPageNumber()); but.addActionListener(this); @@ -118,7 +118,7 @@ public class SwingPagerPanel extends JPanel implements VascEntryFrontendEventLis } result.add(new JLabel("...")); } - pages = entry.getVascFrontendData().getVascFrontendPager().getTablePagesExtendedEnd(); + pages = entry.getVascFrontendController().getVascFrontendPager().getTablePagesExtendedEnd(); for(VascBackendPageNumber page:pages) { JButton but = new JButton(""+page.getPageNumber()); but.addActionListener(this); @@ -128,15 +128,15 @@ public class SwingPagerPanel extends JPanel implements VascEntryFrontendEventLis result.add(but); } JButton next = new JButton("Next"); - next.setEnabled(entry.getVascFrontendData().getVascFrontendPager().getHasPageNextAction()); + next.setEnabled(entry.getVascFrontendController().getVascFrontendPager().getHasPageNextAction()); next.addActionListener(new NextAction(true)); result.add(next); } else { JButton prev = new JButton("Previous"); prev.addActionListener(new NextAction(false)); - prev.setEnabled(entry.getVascFrontendData().getVascFrontendPager().getHasPagePreviousAction()); + prev.setEnabled(entry.getVascFrontendController().getVascFrontendPager().getHasPagePreviousAction()); result.add(prev); - List pages = entry.getVascFrontendData().getVascFrontendPager().getTablePagesNormal(); + List pages = entry.getVascFrontendController().getVascFrontendPager().getTablePagesNormal(); for(VascBackendPageNumber page:pages) { JButton but = new JButton(""+page.getPageNumber()); but.addActionListener(this); @@ -146,7 +146,7 @@ public class SwingPagerPanel extends JPanel implements VascEntryFrontendEventLis result.add(but); } JButton next = new JButton("Next"); - next.setEnabled(entry.getVascFrontendData().getVascFrontendPager().getHasPageNextAction()); + next.setEnabled(entry.getVascFrontendController().getVascFrontendPager().getHasPageNextAction()); next.addActionListener(new NextAction(true)); result.add(next); } diff --git a/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/SwingPanelFrame.java b/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/SwingPanelFrame.java index 94daf7d..7e9edc5 100644 --- a/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/SwingPanelFrame.java +++ b/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/SwingPanelFrame.java @@ -60,13 +60,14 @@ public class SwingPanelFrame implements SwingPanelIntegration { public void createNewVascView(VascEntry entry) throws Exception { // define redering JPanel panel = initVascView(); + SwingVascFrontend render = new SwingVascFrontend(panel,this); // render render.initEntry(entry); render.renderView(); - entry.getVascFrontendData().addVascEntryFrontendEventListener(new VascEntryFrontendEventListener() { + entry.getVascFrontendController().addVascEntryFrontendEventListener(new VascEntryFrontendEventListener() { private static final long serialVersionUID = -6801954395965101748L; public void vascEvent(VascEntry entry, Object data) { if (data instanceof Exception) { @@ -80,7 +81,7 @@ public class SwingPanelFrame implements SwingPanelIntegration { }); // get data - entry.getVascFrontendData().getVascFrontendActions().refreshData(); + entry.getVascFrontendController().getVascFrontendActions().refreshData(); openVascView(panel, entry); } @@ -98,14 +99,12 @@ public class SwingPanelFrame implements SwingPanelIntegration { JMenu vascMenu = new JMenu("Vasc Entries"); if (addVascMenu) { - for (final String id:entry.getVascFrontendData().getVascController().getVascEntryController().getVascEntryIds()) { + for (final String id:entry.getVascFrontendController().getVascController().getVascEntryController().getVascEntryIds()) { JMenuItem item = new JMenuItem(id); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { - VascEntry ee = entry.getVascFrontendData().getVascController().getVascEntryController().getVascEntryById(id).clone(); - //TestModelEntry.fill(ee,entry.getVascFrontendData().getVascController()); - DefaultVascFactory.fillVascEntryFrontend(ee, entry.getVascFrontendData().getVascController(), DefaultVascFactory.getDefaultVascFrontendData(null)); + VascEntry ee = entry.getVascFrontendController().getVascController().getVascEntryController().getVascEntryById(id); createNewVascView(ee); } catch (Exception e1) { e1.printStackTrace(); diff --git a/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/SwingPanelTabbed.java b/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/SwingPanelTabbed.java index 100e880..0d15f53 100644 --- a/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/SwingPanelTabbed.java +++ b/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/SwingPanelTabbed.java @@ -53,7 +53,7 @@ public class SwingPanelTabbed implements SwingPanelIntegration { render.initEntry(entry); render.renderView(); - entry.getVascFrontendData().addVascEntryFrontendEventListener(new VascEntryFrontendEventListener() { + entry.getVascFrontendController().addVascEntryFrontendEventListener(new VascEntryFrontendEventListener() { private static final long serialVersionUID = -6801954395965101748L; public void vascEvent(VascEntry entry, Object data) { if (data instanceof Exception) { @@ -67,7 +67,7 @@ public class SwingPanelTabbed implements SwingPanelIntegration { }); // get data - entry.getVascFrontendData().getVascFrontendActions().refreshData(); + entry.getVascFrontendController().getVascFrontendActions().refreshData(); openVascView(panel, entry); } diff --git a/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/SwingVascEditDialog.java b/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/SwingVascEditDialog.java index 73399ed..4818e0b 100644 --- a/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/SwingVascEditDialog.java +++ b/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/SwingVascEditDialog.java @@ -37,11 +37,11 @@ import javax.swing.SpringLayout; import net.forwardfire.vasc.core.VascController; import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntryField; -import net.forwardfire.vasc.core.VascLinkEntry; +import net.forwardfire.vasc.core.VascEntryLink; +import net.forwardfire.vasc.core.VascEntryLocal; import net.forwardfire.vasc.core.ui.VascColumnValueModelListener; import net.forwardfire.vasc.core.ui.VascUIComponent; import net.forwardfire.vasc.core.ui.VascValueModel; -import net.forwardfire.vasc.impl.DefaultVascFactory; /** * SwingVascEditDialog renders vasc entry edit dialog @@ -91,14 +91,14 @@ public class SwingVascEditDialog extends JPanel { JPanel b = new JPanel(); b.setLayout(new SpringLayout()); - for (final VascLinkEntry vle:entry.getVascLinkEntries()) { + for (final VascEntryLink vle:entry.getVascEntryLinks()) { JButton but = new JButton(vle.getName()); but.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { - VascController vc = entry.getVascFrontendData().getVascController(); - VascEntry ee = vc.getVascEntryController().getVascEntryById(vle.getVascEntryId()).clone(); - DefaultVascFactory.fillVascEntryFrontend(ee, vc, DefaultVascFactory.getDefaultVascFrontendData(null)); + VascController vc = entry.getVascFrontendController().getVascController(); + VascEntryLocal ee = (VascEntryLocal)vc.getVascEntryController().getVascEntryById(vle.getVascEntryId()); + vc.getVascEntryConfigController().configVascFrontendController(vc, ee); // Set parameters try { @@ -117,7 +117,7 @@ public class SwingVascEditDialog extends JPanel { Object selectedValue = v.getVascEntryFieldValue().getValue(v, selected); // set data parameter on new vasc entry - ee.getVascFrontendData().getVascEntryState().getVascBackendState().setDataParameter(parameterName, selectedValue); + ee.getVascFrontendController().getVascEntryState().getVascBackendState().setDataParameter(parameterName, selectedValue); //System.out.println("Setting link parameter: "+parameterName+" with: "+selectedValue); } @@ -177,7 +177,7 @@ public class SwingVascEditDialog extends JPanel { column++; if (i==0) { - entry.getVascFrontendData().addFieldVascUIComponents(c, editor,g); + entry.getVascFrontendController().addFieldVascUIComponents(c, editor,g); } } } @@ -197,12 +197,12 @@ public class SwingVascEditDialog extends JPanel { // return; //} result = bean; - entry.getVascFrontendData().getVascEntryState().setEntryDataObject(result); + entry.getVascFrontendController().getVascEntryState().setEntryDataObject(result); - if (entry.getVascFrontendData().getVascEntryState().isEditCreate()) { - entry.getVascFrontendData().getVascFrontendActions().persistObject(); + if (entry.getVascFrontendController().getVascEntryState().isEditCreate()) { + entry.getVascFrontendController().getVascFrontendActions().persistObject(); } else { - entry.getVascFrontendData().getVascFrontendActions().mergeObject(); + entry.getVascFrontendController().getVascFrontendActions().mergeObject(); } panels.closeVascView(editView, SwingVascEditDialog.this.entry); diff --git a/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/SwingVascFrontend.java b/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/SwingVascFrontend.java index 34aff93..baeda49 100644 --- a/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/SwingVascFrontend.java +++ b/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/SwingVascFrontend.java @@ -61,6 +61,7 @@ import javax.swing.table.TableColumn; import javax.swing.table.TableColumnModel; import net.forwardfire.vasc.core.VascEntryField; +import net.forwardfire.vasc.core.VascEntryListOption; import net.forwardfire.vasc.core.VascException; import net.forwardfire.vasc.core.actions.GlobalVascAction; import net.forwardfire.vasc.core.actions.RowVascAction; @@ -70,7 +71,7 @@ import net.forwardfire.vasc.core.ui.VascUIComponent; import net.forwardfire.vasc.core.ui.VascValueModel; import net.forwardfire.vasc.frontend.AbstractVascFrontend; -import net.forwardfire.vasc.frontend.VascFrontendData; +import net.forwardfire.vasc.frontend.VascFrontendController; import net.forwardfire.vasc.frontend.swing.ui.SwingBoolean; import net.forwardfire.vasc.frontend.swing.ui.SwingButton; import net.forwardfire.vasc.frontend.swing.ui.SwingColorChooser; @@ -112,7 +113,7 @@ public class SwingVascFrontend extends AbstractVascFrontend { * Add swing implmented ui components */ protected void addUiComponents() { - VascFrontendData vfd = getVascEntry().getVascFrontendData(); + VascFrontendController vfd = getVascEntry().getVascFrontendController(); // required UI components vfd.putVascUIComponent(VascUIComponent.VASC_LABEL,SwingLabel.class.getName()); @@ -129,7 +130,7 @@ public class SwingVascFrontend extends AbstractVascFrontend { public ImageIcon getImageIcon(String imageResource) { /// TODO hack beter - String key = entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(imageResource); + String key = entry.getVascFrontendController().getVascEntryResourceResolver().getTextValue(imageResource); //logger.fine("KEY======================="+key); if (key.startsWith("vasc.entry")) { @@ -152,7 +153,7 @@ public class SwingVascFrontend extends AbstractVascFrontend { public void renderEdit() throws Exception { logger.fine("Rending Edit View"); - Object rowBean = entry.getVascFrontendData().getVascEntryState().getEntryDataObject(); + Object rowBean = entry.getVascFrontendController().getVascEntryState().getEntryDataObject(); String beanValue = rowBean.toString(); if (entry.getDisplayNameFieldId()!=null) { VascEntryField v = entry.getVascEntryFieldById(entry.getDisplayNameFieldId()); @@ -171,12 +172,12 @@ public class SwingVascFrontend extends AbstractVascFrontend { JPanel editPanel = panels.initVascView(); SwingVascEditDialog dialog = new SwingVascEditDialog(this,editPanel,entry,rowBean,beanValue,panels); - entry.getVascFrontendData().getVascFrontendHelper().editReadOnlyUIComponents(entry); + entry.getVascFrontendController().getVascFrontendHelper().editReadOnlyUIComponents(entry); panels.openVascView(editPanel,entry); } public void renderDelete() throws Exception { - Object rowBean = entry.getVascFrontendData().getVascEntryState().getEntryDataObject(); + Object rowBean = entry.getVascFrontendController().getVascEntryState().getEntryDataObject(); String beanValue = rowBean.toString(); VascEntryField v = entry.getVascEntryFieldById(entry.getDisplayNameFieldId()); @@ -196,7 +197,7 @@ public class SwingVascFrontend extends AbstractVascFrontend { , null // Default button's label ); if (response==JOptionPane.YES_OPTION) { - entry.getVascFrontendData().getVascFrontendActions().deleteObject(); + entry.getVascFrontendController().getVascFrontendActions().deleteObject(); } } @@ -225,7 +226,7 @@ public class SwingVascFrontend extends AbstractVascFrontend { try { exporter.doExport(out, entry); } catch (Exception e) { - entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e); + entry.getVascFrontendController().getVascFrontendHelper().handleException(entry, e); } finally { if (out!=null) { out.close(); @@ -305,7 +306,7 @@ public class SwingVascFrontend extends AbstractVascFrontend { body.setLayout(new SpringLayout()); int column = 0; try { - for(VascEntryField c:entry.getListOptions()) { + for(VascEntryListOption c:entry.getVascEntryListOptions()) { for (int i=0;i list = new ArrayList(); for(VascEntryField c:entry.getVascEntryFields()) { - if (c.getList()==false) { + if (c.getList()!=null && c.getList()==false) { continue; } diff --git a/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/ui/SwingBoolean.java b/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/ui/SwingBoolean.java index 6f09cc0..5017f2a 100644 --- a/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/ui/SwingBoolean.java +++ b/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/ui/SwingBoolean.java @@ -130,7 +130,7 @@ class SelectActionListener implements ActionListener { try { model.setValue(value); } catch (Exception ee) { - entry.getVascFrontendData().getVascFrontendHelper().handleException(entry,ee); + entry.getVascFrontendController().getVascFrontendHelper().handleException(entry,ee); } } } \ No newline at end of file diff --git a/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/ui/SwingColorChooser.java b/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/ui/SwingColorChooser.java index 1584327..968b3c2 100644 --- a/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/ui/SwingColorChooser.java +++ b/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/ui/SwingColorChooser.java @@ -140,7 +140,7 @@ class SelectActionListener3 implements ActionListener { try { model.setValue(newColor); } catch (Exception ee) { - entry.getVascFrontendData().getVascFrontendHelper().handleException(entry,ee); + entry.getVascFrontendController().getVascFrontendHelper().handleException(entry,ee); } } else { String cur=null; @@ -159,7 +159,7 @@ class SelectActionListener3 implements ActionListener { String newColorString = "#"+Integer.toHexString( newColor.getRGB() & 0x00ffffff ); model.setValue(newColorString); } catch (Exception ee) { - entry.getVascFrontendData().getVascFrontendHelper().handleException(entry,ee); + entry.getVascFrontendController().getVascFrontendHelper().handleException(entry,ee); } } } diff --git a/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/ui/SwingDate.java b/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/ui/SwingDate.java index 635870d..aee0671 100644 --- a/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/ui/SwingDate.java +++ b/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/ui/SwingDate.java @@ -133,7 +133,7 @@ class SelectActionListener2 implements ActionListener { try { model.setValue(value); } catch (Exception ee) { - entry.getVascFrontendData().getVascFrontendHelper().handleException(entry,ee); + entry.getVascFrontendController().getVascFrontendHelper().handleException(entry,ee); } } } \ No newline at end of file diff --git a/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/ui/SwingList.java b/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/ui/SwingList.java index f153590..34d714b 100644 --- a/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/ui/SwingList.java +++ b/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/ui/SwingList.java @@ -70,7 +70,7 @@ public class SwingList implements VascUIComponent { try { model.setValue(i.getValue()); } catch (Exception ee) { - entry.getVascFrontendData().getVascFrontendHelper().handleException(entry,ee); + entry.getVascFrontendController().getVascFrontendHelper().handleException(entry,ee); } } }); diff --git a/vasc-frontend/vasc-frontend-swing/src/test/java/net/forwardfire/vasc/SwingTest.java b/vasc-frontend/vasc-frontend-swing/src/test/java/net/forwardfire/vasc/SwingTest.java index ae1da53..46ef933 100644 --- a/vasc-frontend/vasc-frontend-swing/src/test/java/net/forwardfire/vasc/SwingTest.java +++ b/vasc-frontend/vasc-frontend-swing/src/test/java/net/forwardfire/vasc/SwingTest.java @@ -23,11 +23,10 @@ package net.forwardfire.vasc; import net.forwardfire.vasc.core.VascController; -import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntryControllerLocal; +import net.forwardfire.vasc.core.VascEntryLocal; import net.forwardfire.vasc.frontend.swing.SwingPanelFrame; import net.forwardfire.vasc.frontend.swing.SwingPanelIntegration; -import net.forwardfire.vasc.impl.DefaultVascFactory; import net.forwardfire.vasc.test.frontend.data.TestModelData; import junit.framework.TestCase; @@ -60,8 +59,8 @@ public class SwingTest extends TestCase { VascController vc = testData.getTestVascController(); testData.createVascEntries(vc,(VascEntryControllerLocal)vc.getVascEntryController()); - VascEntry ve = testData.getTestEntry(vc); - DefaultVascFactory.fillVascEntryFrontend(ve, vc, DefaultVascFactory.getDefaultVascFrontendData(null)); + VascEntryLocal ve = testData.getTestEntry(vc); + vc.getVascEntryConfigController().configVascFrontendController(vc, ve); spi.createNewVascView(ve); } } \ No newline at end of file diff --git a/vasc-frontend/vasc-frontend-swing/src/test/java/net/forwardfire/vasc/SwingTestTabbed.java b/vasc-frontend/vasc-frontend-swing/src/test/java/net/forwardfire/vasc/SwingTestTabbed.java index c696e37..f8f302e 100644 --- a/vasc-frontend/vasc-frontend-swing/src/test/java/net/forwardfire/vasc/SwingTestTabbed.java +++ b/vasc-frontend/vasc-frontend-swing/src/test/java/net/forwardfire/vasc/SwingTestTabbed.java @@ -35,6 +35,7 @@ import javax.swing.JTabbedPane; import net.forwardfire.vasc.core.VascController; import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntryControllerLocal; +import net.forwardfire.vasc.core.VascEntryLocal; import net.forwardfire.vasc.frontend.swing.SwingPanelIntegration; import net.forwardfire.vasc.frontend.swing.SwingPanelTabbed; import net.forwardfire.vasc.impl.DefaultVascFactory; @@ -85,9 +86,9 @@ public class SwingTestTabbed extends TestCase { item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { - VascEntry ee = vc.getVascEntryController().getVascEntryById(id).clone(); - DefaultVascFactory.fillVascEntryFrontend(ee, vc, DefaultVascFactory.getDefaultVascFrontendData(null)); - spi.createNewVascView(ee); + VascEntryLocal ve = (VascEntryLocal)vc.getVascEntryController().getVascEntryById(id); + vc.getVascEntryConfigController().configVascFrontendController(vc, ve); + spi.createNewVascView(ve); } catch (Exception e1) { e1.printStackTrace(); } @@ -114,8 +115,8 @@ public class SwingTestTabbed extends TestCase { frame.pack(); frame.setVisible(true); - VascEntry ve = testData.getTestEntry(vc); - DefaultVascFactory.fillVascEntryFrontend(ve, vc, DefaultVascFactory.getDefaultVascFrontendData(null)); + VascEntryLocal ve = testData.getTestEntry(vc); + vc.getVascEntryConfigController().configVascFrontendController(vc, ve); spi.createNewVascView(ve); } } \ No newline at end of file diff --git a/vasc-frontend/vasc-frontend-swt/pom.xml b/vasc-frontend/vasc-frontend-swt/pom.xml index 9cd2d9f..eb87b4e 100644 --- a/vasc-frontend/vasc-frontend-swt/pom.xml +++ b/vasc-frontend/vasc-frontend-swt/pom.xml @@ -27,7 +27,7 @@ org.eclipse jface - 3.3.0-I20070606-0010 + ${jface.version} compile @@ -36,7 +36,7 @@ org.eclipse jface - 3.2.1-M20060908-1000 + ${jface.version} jar compile @@ -65,7 +65,7 @@ test - net.forwardfire.vasc + net.forwardfire.vasc.test vasc-test-frontend-data ${project.version} test diff --git a/vasc-frontend/vasc-frontend-swt/src/main/java/net/forwardfire/vasc/frontend/swt/SwtActionPanel.java b/vasc-frontend/vasc-frontend-swt/src/main/java/net/forwardfire/vasc/frontend/swt/SwtActionPanel.java index 550c259..5e68ca3 100644 --- a/vasc-frontend/vasc-frontend-swt/src/main/java/net/forwardfire/vasc/frontend/swt/SwtActionPanel.java +++ b/vasc-frontend/vasc-frontend-swt/src/main/java/net/forwardfire/vasc/frontend/swt/SwtActionPanel.java @@ -61,7 +61,7 @@ public class SwtActionPanel implements VascEntryFrontendEventListener { public SwtActionPanel(VascEntry entry) { this.entry=entry; - entry.getVascFrontendData().addVascEntryFrontendEventListener(this); + entry.getVascFrontendController().addVascEntryFrontendEventListener(this); } public void createComposite(Composite parent) { @@ -75,15 +75,15 @@ public class SwtActionPanel implements VascEntryFrontendEventListener { Label l = new Label(actionRow, SWT.CENTER); l.setText("Row Numbers"); rowNumberField = new Text(actionRow, SWT.NONE | SWT.BORDER); - rowNumberField.setText(""+entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageSize()+" "); + rowNumberField.setText(""+entry.getVascFrontendController().getVascEntryState().getVascBackendState().getPageSize()+" "); rowNumberField.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent arg0) { if (vascEvent) { return; } int pageSize = new Integer(rowNumberField.getText()); - entry.getVascFrontendData().getVascEntryState().getVascBackendState().setPageSize(pageSize); - entry.getVascFrontendData().getVascFrontendActions().refreshData(); + entry.getVascFrontendController().getVascEntryState().getVascBackendState().setPageSize(pageSize); + entry.getVascFrontendController().getVascFrontendActions().refreshData(); } }); @@ -93,7 +93,7 @@ public class SwtActionPanel implements VascEntryFrontendEventListener { pageBox = new Combo(actionRow,SWT.SINGLE | SWT.BORDER); pageBox.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { - entry.getVascFrontendData().getVascFrontendActions().pageAction(pageBox.getSelectionIndex()-1); + entry.getVascFrontendController().getVascFrontendActions().pageAction(pageBox.getSelectionIndex()-1); pageBox.select(0); } }); @@ -128,10 +128,10 @@ public class SwtActionPanel implements VascEntryFrontendEventListener { public void vascEvent(VascEntry entry,Object dataNotUsed) { vascEvent = true; - long pageSize = entry.getVascFrontendData().getVascFrontendPager().getPageSize(); - long pageStart = entry.getVascFrontendData().getVascFrontendPager().getPageStartCount(); - long pageStop = entry.getVascFrontendData().getVascFrontendPager().getPageStopCount(); - long pageTotalCount = entry.getVascFrontendData().getVascFrontendPager().getPageTotalRecordCount(); + long pageSize = entry.getVascFrontendController().getVascFrontendPager().getPageSize(); + long pageStart = entry.getVascFrontendController().getVascFrontendPager().getPageStartCount(); + long pageStop = entry.getVascFrontendController().getVascFrontendPager().getPageStopCount(); + long pageTotalCount = entry.getVascFrontendController().getVascFrontendPager().getPageTotalRecordCount(); String format = "Results %1$d-%2$d from %3$d rows"; resultLabel.setText(String.format(format, pageStart, pageStop, pageTotalCount)); resultLabel.redraw(); @@ -140,7 +140,7 @@ public class SwtActionPanel implements VascEntryFrontendEventListener { pageBox.removeAll(); pageBox.add("Goto..."); - List pages = entry.getVascFrontendData().getVascFrontendPager().getTablePagesFromBackend(); + List pages = entry.getVascFrontendController().getVascFrontendPager().getTablePagesFromBackend(); int i=0; for (VascBackendPageNumber page:pages) { pageBox.add("page: "+page.getPageNumber()+" "+(i*pageSize)+"-"+((i*pageSize)+pageSize)); diff --git a/vasc-frontend/vasc-frontend-swt/src/main/java/net/forwardfire/vasc/frontend/swt/SwtPagerPanel.java b/vasc-frontend/vasc-frontend-swt/src/main/java/net/forwardfire/vasc/frontend/swt/SwtPagerPanel.java index 5640abf..6f191ce 100644 --- a/vasc-frontend/vasc-frontend-swt/src/main/java/net/forwardfire/vasc/frontend/swt/SwtPagerPanel.java +++ b/vasc-frontend/vasc-frontend-swt/src/main/java/net/forwardfire/vasc/frontend/swt/SwtPagerPanel.java @@ -52,7 +52,7 @@ public class SwtPagerPanel implements VascEntryFrontendEventListener { public SwtPagerPanel(VascEntry entry) { this.entry=entry; - entry.getVascFrontendData().addVascEntryFrontendEventListener(this); + entry.getVascFrontendController().addVascEntryFrontendEventListener(this); } public void createComposite(Composite parent) { diff --git a/vasc-frontend/vasc-frontend-swt/src/main/java/net/forwardfire/vasc/frontend/swt/SwtVascEditDialog.java b/vasc-frontend/vasc-frontend-swt/src/main/java/net/forwardfire/vasc/frontend/swt/SwtVascEditDialog.java index f4846d4..a459966 100644 --- a/vasc-frontend/vasc-frontend-swt/src/main/java/net/forwardfire/vasc/frontend/swt/SwtVascEditDialog.java +++ b/vasc-frontend/vasc-frontend-swt/src/main/java/net/forwardfire/vasc/frontend/swt/SwtVascEditDialog.java @@ -63,14 +63,14 @@ public class SwtVascEditDialog extends Dialog { } protected String i18n(String key,Object...params) { - return entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(key,params); + return entry.getVascFrontendController().getVascEntryResourceResolver().getTextValue(key,params); } protected Object i18nImage(String key) { - if (entry.getVascFrontendData().getVascEntryResourceImageResolver()==null) { + if (entry.getVascFrontendController().getVascEntryResourceImageResolver()==null) { return null; } - return entry.getVascFrontendData().getVascEntryResourceImageResolver().getImageValue(entry,key); + return entry.getVascFrontendController().getVascEntryResourceImageResolver().getImageValue(entry,key); } public void open() throws VascException { @@ -124,7 +124,7 @@ public class SwtVascEditDialog extends Dialog { } String name = null; try { - Object bean = entry.getVascFrontendData().getVascEntryState().getEntryDataObject(); + Object bean = entry.getVascFrontendController().getVascEntryState().getEntryDataObject(); name = dis.getVascEntryFieldValue().getDisplayValue(dis, bean); } catch (VascException e) { throw new RuntimeException("Could not display value from "+entry.getId(),e); @@ -134,7 +134,7 @@ public class SwtVascEditDialog extends Dialog { header.setBackground(c); Label img = new Label(header, SWT.NONE); - if (entry.getVascFrontendData().getVascEntryState().isEditCreate()) { + if (entry.getVascFrontendController().getVascEntryState().isEditCreate()) { img.setImage((Image)i18nImage(entry.getCreateImage())); } else { img.setImage((Image)i18nImage(entry.getEditImage())); @@ -143,7 +143,7 @@ public class SwtVascEditDialog extends Dialog { Font headerFont = new Font(header.getDisplay(), "verdana", 14, SWT.NONE); Label l = new Label(header, SWT.CENTER); - if (entry.getVascFrontendData().getVascEntryState().isEditCreate()) { + if (entry.getVascFrontendController().getVascEntryState().isEditCreate()) { l.setText(i18n(entry.getCreateDescription(),name)); } else { l.setText(i18n(entry.getEditDescription(),name)); @@ -155,12 +155,12 @@ public class SwtVascEditDialog extends Dialog { public void createBody(Composite body) throws VascException { body.setLayout(new GridLayout(2, true)); body.setLayoutData(new GridData(GridData.FILL_BOTH)); - Object bean = entry.getVascFrontendData().getVascEntryState().getEntryDataObject(); + Object bean = entry.getVascFrontendController().getVascEntryState().getEntryDataObject(); - entry.getVascFrontendData().clearFieldRenderObjects(); // only needed for swt use + entry.getVascFrontendController().clearFieldRenderObjects(); // only needed for swt use for (VascEntryField c:entry.getVascEntryFields()) { - if (entry.getVascFrontendData().getVascFrontendHelper().renderEdit(c)==false) { + if (entry.getVascFrontendController().getVascFrontendDataSelector().isFieldEdit(c)==false) { continue; } @@ -188,11 +188,11 @@ public class SwtVascEditDialog extends Dialog { } if (i==0) { - entry.getVascFrontendData().addFieldVascUIComponents(c, editor,edit); + entry.getVascFrontendController().addFieldVascUIComponents(c, editor,edit); } } } - entry.getVascFrontendData().getVascFrontendHelper().editReadOnlyUIComponents(entry); + entry.getVascFrontendController().getVascFrontendHelper().editReadOnlyUIComponents(entry); } public void createFooter(Composite body) { @@ -203,11 +203,11 @@ public class SwtVascEditDialog extends Dialog { saveButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { try { - boolean error = entry.getVascFrontendData().getVascFrontendHelper().validateAndSetErrorText(entry); + boolean error = entry.getVascFrontendController().getVascFrontendHelper().validateAndSetErrorText(entry); if (error) { return; } - entry.getVascFrontendData().getVascFrontendActions().mergeObject(); + entry.getVascFrontendController().getVascFrontendActions().mergeObject(); shell.dispose(); } catch (Exception ee) { ee.printStackTrace(); @@ -220,7 +220,7 @@ public class SwtVascEditDialog extends Dialog { cancelButton.setToolTipText(i18n("vasc.action.cancelAction.description")); cancelButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { - entry.getVascFrontendData().getVascEntryState().setEntryDataObject(null); + entry.getVascFrontendController().getVascEntryState().setEntryDataObject(null); shell.dispose(); } }); diff --git a/vasc-frontend/vasc-frontend-swt/src/main/java/net/forwardfire/vasc/frontend/swt/SwtVascFrontend.java b/vasc-frontend/vasc-frontend-swt/src/main/java/net/forwardfire/vasc/frontend/swt/SwtVascFrontend.java index 5fc5504..236db4a 100644 --- a/vasc-frontend/vasc-frontend-swt/src/main/java/net/forwardfire/vasc/frontend/swt/SwtVascFrontend.java +++ b/vasc-frontend/vasc-frontend-swt/src/main/java/net/forwardfire/vasc/frontend/swt/SwtVascFrontend.java @@ -29,6 +29,7 @@ import java.util.logging.Logger; import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntryField; +import net.forwardfire.vasc.core.VascEntryListOption; import net.forwardfire.vasc.core.VascException; import net.forwardfire.vasc.core.actions.GlobalVascAction; import net.forwardfire.vasc.core.actions.RowVascAction; @@ -39,7 +40,7 @@ import net.forwardfire.vasc.core.ui.VascUIComponent; import net.forwardfire.vasc.core.ui.VascValueModel; import net.forwardfire.vasc.core.ui.VascValueModelListener; import net.forwardfire.vasc.frontend.AbstractVascFrontend; -import net.forwardfire.vasc.frontend.VascFrontendData; +import net.forwardfire.vasc.frontend.VascFrontendController; import net.forwardfire.vasc.frontend.swt.ui.SwtBoolean; import net.forwardfire.vasc.frontend.swt.ui.SwtButton; import net.forwardfire.vasc.frontend.swt.ui.SwtLabel; @@ -113,7 +114,7 @@ public class SwtVascFrontend extends AbstractVascFrontend { * Add swt implmented ui components */ protected void addUiComponents() { - VascFrontendData vfd = getVascEntry().getVascFrontendData(); + VascFrontendController vfd = getVascEntry().getVascFrontendController(); // required UI components vfd.putVascUIComponent(VascUIComponent.VASC_LABEL,SwtLabel.class.getName()); @@ -145,10 +146,10 @@ public class SwtVascFrontend extends AbstractVascFrontend { @Override public Object i18nImage(String key) { - if (entry.getVascFrontendData().getVascEntryResourceImageResolver()==null) { + if (entry.getVascFrontendController().getVascEntryResourceImageResolver()==null) { return null; } - return entry.getVascFrontendData().getVascEntryResourceImageResolver().getImageValue(entry,key); + return entry.getVascFrontendController().getVascEntryResourceImageResolver().getImageValue(entry,key); } private static final String[] FILTER_NAMES = { @@ -194,7 +195,7 @@ public class SwtVascFrontend extends AbstractVascFrontend { return; } // yes - entry.getVascFrontendData().getVascFrontendActions().deleteObject(); + entry.getVascFrontendController().getVascFrontendActions().deleteObject(); } private boolean askDelete(Shell shell) { @@ -266,7 +267,7 @@ public class SwtVascFrontend extends AbstractVascFrontend { ToolBar toolBar = new ToolBar(headerBar, SWT.NONE); for (GlobalVascAction action:entry.getGlobalActions()) { - if (entry.getVascFrontendData().getVascFrontendHelper().renderGlobalVascAction(action)==false) { + if (entry.getVascFrontendController().getVascFrontendDataSelector().isActionAllowed(action)==false) { continue; } ToolItem item = new ToolItem(toolBar, SWT.PUSH); @@ -318,7 +319,7 @@ public class SwtVascFrontend extends AbstractVascFrontend { headerOptions.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); try { - for (VascEntryField option:entry.getListOptions()) { + for (VascEntryListOption option:entry.getVascEntryListOptions()) { for (int i=0;i javax.servlet servlet-api - 2.5 + ${servlet-api.version} jar provided diff --git a/vasc-frontend/vasc-frontend-web-export/src/main/java/net/forwardfire/vasc/frontend/web/export/VascExportServlet.java b/vasc-frontend/vasc-frontend-web-export/src/main/java/net/forwardfire/vasc/frontend/web/export/VascExportServlet.java index 4741a15..a36afd8 100644 --- a/vasc-frontend/vasc-frontend-web-export/src/main/java/net/forwardfire/vasc/frontend/web/export/VascExportServlet.java +++ b/vasc-frontend/vasc-frontend-web-export/src/main/java/net/forwardfire/vasc/frontend/web/export/VascExportServlet.java @@ -35,6 +35,7 @@ import javax.servlet.http.HttpServletResponse; import net.forwardfire.vasc.core.VascController; import net.forwardfire.vasc.core.VascControllerProvider; import net.forwardfire.vasc.core.VascEntry; +import net.forwardfire.vasc.core.VascEntryLocal; import net.forwardfire.vasc.core.VascException; import net.forwardfire.vasc.core.entry.VascEntryExporter; @@ -49,7 +50,7 @@ public class VascExportServlet extends HttpServlet { private Logger logger = Logger.getLogger(VascExportServlet.class.getName()); private static final long serialVersionUID = 6165530418422144322L; private VascControllerProvider vascControllerProvider = null; - private boolean exportTree = false; + private boolean forceTree = false; /** * @see javax.servlet.GenericServlet#init() @@ -61,9 +62,15 @@ public class VascExportServlet extends HttpServlet { if (className==null) { throw new ServletException("Can't start with null vascControllerProvider init parameter."); } - String exportTreeStr = getInitParameter("exportTree"); + String exportTreeStr = getInitParameter("forceTree"); if (exportTreeStr!=null && "true".equalsIgnoreCase(exportTreeStr)) { - exportTree = true; + forceTree = true; + } + String classArgument = null; + int atIndex = className.indexOf('@'); + if (atIndex > 0) { + classArgument = className.substring(0,atIndex); + className = className.substring(atIndex+1); } try { ClassLoader cl = Thread.currentThread().getContextClassLoader(); @@ -71,11 +78,15 @@ public class VascExportServlet extends HttpServlet { cl = className.getClass().getClassLoader(); } Class clazz = cl.loadClass(className); - vascControllerProvider = (VascControllerProvider)clazz.newInstance(); + if (classArgument==null) { + vascControllerProvider = (VascControllerProvider)clazz.newInstance(); + } else { + vascControllerProvider = (VascControllerProvider)clazz.getConstructor(String.class).newInstance(classArgument); + } } catch (Exception e) { throw new ServletException("Could not create VascControllerProvider: "+e.getMessage(),e); } - logger.info("Export servlet started. (exportTree: "+exportTree+")"); + logger.info("Export servlet started with forceTree: "+forceTree+" prov: "+classArgument+"@"+className); } /** @@ -102,8 +113,13 @@ public class VascExportServlet extends HttpServlet { String entryId = null; String exportId = null; - if (exportTree) { - int index = path.indexOf("/"); + int index = path.indexOf("/"); + if (forceTree && index<0) { + response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Only tree request allowed."); + return; + } + + if (index>0) { String actionString = null; if (index>0) { actionString = path.substring(index+1); @@ -135,16 +151,33 @@ public class VascExportServlet extends HttpServlet { exportId = request.getParameter("et"); } + if (entryId==null) { + response.sendError(HttpServletResponse.SC_BAD_REQUEST, "No entry given"); + return; + } + if (entryId.isEmpty()) { + response.sendError(HttpServletResponse.SC_BAD_REQUEST, "No entry given"); + return; + } + if (exportId==null) { + response.sendError(HttpServletResponse.SC_BAD_REQUEST, "No export type given"); + return; + } + if (exportId.isEmpty()) { + response.sendError(HttpServletResponse.SC_BAD_REQUEST, "No export type given"); + return; + } + //out = new PrintWriter(new OutputStreamWriter(response.getOutputStream(), response.getCharacterEncoding()), true); OutputStream out = response.getOutputStream(); try { VascController vc = vascControllerProvider.getVascController(); - VascEntry ve = vc.getVascEntryConfigController().configVascEntry(vc, entryId); - vc.getVascEntryConfigController().configVascFrontendData(vc, ve, new Locale("en")); + VascEntryLocal ve = (VascEntryLocal)vc.getVascEntryConfigController().configVascEntry(vc, entryId); + vc.getVascEntryConfigController().configVascFrontendController(vc, ve); // Update total every time first - Long total = ve.getVascFrontendData().getVascEntryState().getVascBackend().fetchTotalExecuteSize(ve.getVascFrontendData().getVascEntryState().getVascBackendState()); - ve.getVascFrontendData().getVascEntryState().setTotalBackendRecords(total); + Long total = ve.getVascFrontendController().getVascEntryState().getVascBackend().fetchTotalExecuteSize(ve.getVascFrontendController().getVascEntryState().getVascBackendState()); + ve.getVascFrontendController().getVascEntryState().setTotalBackendRecords(total); VascEntryExporter ex = vc.getVascEntryConfigController().getVascEntryExporterById(exportId); String filename = entryId+"-export."+ex.getFileType(); diff --git a/vasc-frontend/vasc-frontend-web-jsf/pom.xml b/vasc-frontend/vasc-frontend-web-jsf/pom.xml index ec5121c..83850bf 100644 --- a/vasc-frontend/vasc-frontend-web-jsf/pom.xml +++ b/vasc-frontend/vasc-frontend-web-jsf/pom.xml @@ -20,46 +20,30 @@ ${project.version} provided - - javax.faces - jsf-api - 1.2 - provided + + javax.servlet + servlet-api + ${servlet-api.version} + jar + provided javax.servlet jstl - 1.2 + ${jstl.version} provided javax.servlet.jsp jsp-api - 2.1 + ${jsp-api.version} provided - javax.faces - jsf-impl - 1.2_04 + org.glassfish + javax.faces + ${javax.faces.version} provided - - - - - javax.servlet - servlet-api - 2.5 - jar - provided - \ No newline at end of file diff --git a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/AbstractJSFVascFacesControllerBase.java b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/AbstractJSFVascFacesControllerBase.java index 8759867..922a3e7 100644 --- a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/AbstractJSFVascFacesControllerBase.java +++ b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/AbstractJSFVascFacesControllerBase.java @@ -29,7 +29,8 @@ import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.core.VascController; import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntryField; -import net.forwardfire.vasc.frontend.VascFrontendData; +import net.forwardfire.vasc.core.VascEntryLocal; +import net.forwardfire.vasc.frontend.VascFrontendController; import net.forwardfire.vasc.impl.DefaultVascFactory; /** @@ -40,7 +41,7 @@ import net.forwardfire.vasc.impl.DefaultVascFactory; */ public abstract class AbstractJSFVascFacesControllerBase { - abstract public VascFrontendData getNewVascFrontendData(); + abstract public VascFrontendController getNewVascFrontendData(); abstract public VascController getVascController(); public void setVascController(VascController vascController) { @@ -52,18 +53,24 @@ public abstract class AbstractJSFVascFacesControllerBase { public List executeVascList(String entryId,Map para) { try { // plug all object - VascEntry entry = getVascController().getVascEntryController().getVascEntryById(entryId); - DefaultVascFactory.fillVascEntryFrontend(entry, getVascController(), getNewVascFrontendData()); + VascEntryLocal entry = (VascEntryLocal)getVascController().getVascEntryController().getVascEntryById(entryId); + getVascController().getVascEntryConfigController().configVascFrontendController(getVascController(), entry); // set def para - VascBackendState state = entry.getVascFrontendData().getVascEntryState().getVascBackendState(); + VascBackendState state = entry.getVascFrontendController().getVascEntryState().getVascBackendState(); for (String key2:entry.getEntryParameterKeys()) { Object value = entry.getEntryParameter(key2); state.setDataParameter(key2, value); } + // copy para + if (para!=null) { + for (String key:para.keySet()) { + state.setDataParameter(key, para.get(key)); + } + } // set list para - for (VascEntryField vef:entry.getListOptions()) { + for (VascEntryField vef:entry.getVascEntryListOptions()) { Object def = vef.getDefaultValue(); if (def==null) { continue; @@ -72,16 +79,9 @@ public abstract class AbstractJSFVascFacesControllerBase { state.setDataParameter(backendName, def); } - // copy para - if (para!=null) { - for (String key:para.keySet()) { - entry.setEntryParameter(key, para.get(key)); - } - } - // done, execute and return data. - entry.getVascFrontendData().getVascFrontendActions().refreshData(); - return entry.getVascFrontendData().getVascEntryState().getEntryDataList(); + entry.getVascFrontendController().getVascFrontendActions().refreshData(); + return entry.getVascFrontendController().getVascEntryState().getEntryDataList(); } catch (Exception e) { throw new RuntimeException("Could not execute list: "+e.getMessage(),e); } diff --git a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/AbstractJSFVascFacesControllerEJB.java b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/AbstractJSFVascFacesControllerEJB.java index 59967a8..a7fea4b 100644 --- a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/AbstractJSFVascFacesControllerEJB.java +++ b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/AbstractJSFVascFacesControllerEJB.java @@ -45,12 +45,13 @@ import net.forwardfire.vasc.core.VascController; import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntryControllerLocal; import net.forwardfire.vasc.core.VascEntryField; +import net.forwardfire.vasc.core.VascEntryLocal; import net.forwardfire.vasc.core.VascException; import net.forwardfire.vasc.core.entry.VascEntryFieldValue; import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener; import net.forwardfire.vasc.core.entry.VascEntryRecordCreator; import net.forwardfire.vasc.ejb3.VascServiceManager; -import net.forwardfire.vasc.frontend.VascFrontendData; +import net.forwardfire.vasc.frontend.VascFrontendController; import net.forwardfire.vasc.impl.DefaultVascFactory; import net.forwardfire.vasc.impl.entry.DefaultVascEntryResourceResolver; import net.forwardfire.vasc.impl.entry.SetParameterBackendListener; @@ -125,9 +126,8 @@ abstract public class AbstractJSFVascFacesControllerEJB extends AbstractJSFVascF /** * Config vasc frontend data object for jsf component to use. * - * @return - */ - public VascFrontendData getNewVascFrontendData() { + + public VascFrontendController getNewVascFrontendData() { Locale locale = FacesContext.getCurrentInstance().getViewRoot().getLocale(); MergedResourceBundle bundle = new MergedResourceBundle(); bundle.addDataBundle(ResourceBundle.getBundle(getResourceBundleWEB(), locale)); @@ -141,7 +141,7 @@ abstract public class AbstractJSFVascFacesControllerEJB extends AbstractJSFVascF throw new RuntimeException("Could not get the ejb resource bundle: "+e.getMessage(),e); } - VascFrontendData vascFrontendData = DefaultVascFactory.getDefaultVascFrontendData(bundle); + VascFrontendController vascFrontendData = DefaultVascFactory.getDefaultVascFrontendData(bundle); vascFrontendData.addVascEntryFrontendEventListener(new VascEntryFrontendEventListener() { private static final long serialVersionUID = 1L; public VascFrontendEventType[] getEventTypes() { @@ -154,7 +154,7 @@ abstract public class AbstractJSFVascFacesControllerEJB extends AbstractJSFVascF } } }); - + // config frontend data for ISF usage if (getDisableI18N()) { vascFrontendData.setVascEntryResourceResolver(new DefaultVascEntryResourceResolver()); @@ -163,7 +163,9 @@ abstract public class AbstractJSFVascFacesControllerEJB extends AbstractJSFVascF } return vascFrontendData; } - + * @return + */ + class RemoteVascBackend implements VascBackend { @@ -279,10 +281,10 @@ abstract public class AbstractJSFVascFacesControllerEJB extends AbstractJSFVascF } public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) { - VascEntry clone = null; + VascEntryLocal clone = null; try { - clone = vascEntry.clone(); - clone.setVascFrontendData(null); + clone = ((VascEntryLocal)vascEntry).clone(); + clone.setVascFrontendController(null); clone.setVascEntryFieldEventChannel(null); } catch (CloneNotSupportedException e) { // TODO Auto-generated catch block @@ -345,7 +347,7 @@ abstract public class AbstractJSFVascFacesControllerEJB extends AbstractJSFVascF // get local jvm plugging controller - VascController c = DefaultVascFactory.getDefaultVascController(vui.userId, vui.username, vui.roles); + VascController c = DefaultVascFactory.getDefaultVascController(); /* DefaultVascEntryController con = new DefaultVascEntryController() { @@ -366,7 +368,7 @@ abstract public class AbstractJSFVascFacesControllerEJB extends AbstractJSFVascF VascEntryControllerLocal localEntryController = (VascEntryControllerLocal)c.getVascEntryController(); VascBackendControllerLocal localBackendController = (VascBackendControllerLocal)c.getVascBackendController(); for (String id:entryIds) { - VascEntry ve = vascManager.getVascEntry(id); + VascEntryLocal ve = (VascEntryLocal)vascManager.getVascEntry(id); String backendId = ve.getBackendId(); VascBackend vb = new RemoteVascBackend(backendId,vascManager); diff --git a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/AbstractJSFVascFacesControllerLocal.java b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/AbstractJSFVascFacesControllerLocal.java index 2a4b0fb..45b58b7 100644 --- a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/AbstractJSFVascFacesControllerLocal.java +++ b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/AbstractJSFVascFacesControllerLocal.java @@ -36,7 +36,7 @@ import net.forwardfire.vasc.core.VascController; import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntryControllerLocal; import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener; -import net.forwardfire.vasc.frontend.VascFrontendData; +import net.forwardfire.vasc.frontend.VascFrontendController; import net.forwardfire.vasc.impl.DefaultVascFactory; import net.forwardfire.vasc.impl.entry.DefaultVascEntryResourceResolver; import net.forwardfire.vasc.impl.x4o.VascParser; @@ -93,15 +93,13 @@ abstract public class AbstractJSFVascFacesControllerLocal extends AbstractJSFVas /** * Config vasc frontend data object for jsf component to use. - * - * @return - */ - public VascFrontendData getNewVascFrontendData() { + + public VascFrontendController getNewVascFrontendData() { Locale locale = FacesContext.getCurrentInstance().getViewRoot().getLocale(); MergedResourceBundle bundle = new MergedResourceBundle(); bundle.addDataBundle(ResourceBundle.getBundle(getResourceBundleWEB(), locale)); - VascFrontendData vascFrontendData = DefaultVascFactory.getDefaultVascFrontendData(bundle); + VascFrontendController vascFrontendData = DefaultVascFactory.getDefaultVascFrontendData(bundle); vascFrontendData.addVascEntryFrontendEventListener(new VascEntryFrontendEventListener() { private static final long serialVersionUID = 1L; public VascFrontendEventType[] getEventTypes() { @@ -123,6 +121,9 @@ abstract public class AbstractJSFVascFacesControllerLocal extends AbstractJSFVas } return vascFrontendData; } + * + * @return + */ /** * @return the vascController @@ -134,7 +135,7 @@ abstract public class AbstractJSFVascFacesControllerLocal extends AbstractJSFVas try { // get local jvm plugging controller VascUserInfo vui = getVascUserInfo(); - VascController c = DefaultVascFactory.getDefaultVascController(vui.userId, vui.username, vui.roles); + VascController c = DefaultVascFactory.getDefaultVascController(); // Load vasc resources for (String res:getVascParseResources()) { diff --git a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascEntryEventListener.java b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascEntryEventListener.java index 0947db3..826c08c 100644 --- a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascEntryEventListener.java +++ b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascEntryEventListener.java @@ -74,7 +74,7 @@ public class JSFVascEntryEventListener implements VascEntryFrontendEventListener throw new RuntimeException(e); } */ - List data = entry.getVascFrontendData().getVascEntryState().getEntryDataList(); + List data = entry.getVascFrontendController().getVascEntryState().getEntryDataList(); List result = new ArrayList(data.size()); int index = 0; for (Object o:data) { @@ -86,6 +86,6 @@ public class JSFVascEntryEventListener implements VascEntryFrontendEventListener ValueExpression ve2 = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{"+entrySupportVar+".tableDataModel.wrappedData}", Object.class); ve2.setValue(FacesContext.getCurrentInstance().getELContext(), result); ValueExpression ve3 = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{"+entrySupportVar+".tablePagesDataModel.wrappedData}", Object.class); - ve3.setValue(FacesContext.getCurrentInstance().getELContext(), entry.getVascFrontendData().getVascFrontendPager().getTablePagesFromBackend()); + ve3.setValue(FacesContext.getCurrentInstance().getELContext(), entry.getVascFrontendController().getVascFrontendPager().getTablePagesFromBackend()); } } diff --git a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascEntrySupportBean.java b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascEntrySupportBean.java index 35b66bc..9bbeacb 100644 --- a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascEntrySupportBean.java +++ b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascEntrySupportBean.java @@ -52,8 +52,8 @@ import net.forwardfire.vasc.backend.VascBackendPageNumber; import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntryField; import net.forwardfire.vasc.core.VascEntryState; -import net.forwardfire.vasc.core.VascLinkEntry; -import net.forwardfire.vasc.core.VascLinkEntryType; +import net.forwardfire.vasc.core.VascEntryLink; +import net.forwardfire.vasc.core.VascEntryLinkType; import net.forwardfire.vasc.core.actions.GlobalVascAction; import net.forwardfire.vasc.core.actions.RowVascAction; import net.forwardfire.vasc.core.entry.VascEntryExporter; @@ -104,7 +104,7 @@ public class JSFVascEntrySupportBean implements Serializable { editSelectItemModels = new HashMap(6); // cache some values - VascBackend backend = entry.getVascFrontendData().getVascEntryState().getVascBackend(); + VascBackend backend = entry.getVascFrontendController().getVascEntryState().getVascBackend(); backendPageable = backend.isPageable(); backendMoveable = backend.isRecordMoveable(); backendSearchable = backend.isSearchable(); @@ -134,11 +134,11 @@ public class JSFVascEntrySupportBean implements Serializable { } public String getParentSelectedDisplayName() { - return entry.getVascFrontendData().getVascFrontendHelper().getParentSelectedDisplayName(entry); + return entry.getVascFrontendController().getVascFrontendHelper().getParentSelectedDisplayName(entry); } public String getSelectedDisplayName() { - return entry.getVascFrontendData().getVascFrontendHelper().getSelectedDisplayName(entry); + return entry.getVascFrontendController().getVascFrontendHelper().getSelectedDisplayName(entry); } public int getTotalColumnCount() { @@ -155,7 +155,7 @@ public class JSFVascEntrySupportBean implements Serializable { t++; // auto add of select boxes } for (VascEntryField c:entry.getVascEntryFields()) { - if (entry.getVascFrontendData().getVascFrontendHelper().renderList(c)==false) { + if (entry.getVascFrontendController().getVascFrontendDataSelector().isFieldList(c)==false) { continue; } t++; @@ -165,7 +165,7 @@ public class JSFVascEntrySupportBean implements Serializable { public int getTotalActionColumnCount() { int t = 0; - if (entry.getVascFrontendData().getVascEntryState().getVascBackend().isRecordMoveable()) { + if (entry.getVascFrontendController().getVascEntryState().getVascBackend().isRecordMoveable()) { t++; t++; } @@ -177,33 +177,33 @@ public class JSFVascEntrySupportBean implements Serializable { return getVascLinkEntriesList().size(); } - public List getVascLinkEntriesList() { - return entry.getVascFrontendData().getVascFrontendHelper().getVascLinkEntryByType(entry,VascLinkEntryType.LIST); + public List getVascLinkEntriesList() { + return entry.getVascFrontendController().getVascFrontendHelper().getVascLinkEntryByType(entry,VascEntryLinkType.LIST); } - public List getVascLinkEntriesEditTab() { - return entry.getVascFrontendData().getVascFrontendHelper().getVascLinkEntryByType(entry,VascLinkEntryType.EDIT_TAB); + public List getVascLinkEntriesEditTab() { + return entry.getVascFrontendController().getVascFrontendHelper().getVascLinkEntryByType(entry,VascEntryLinkType.EDIT_TAB); } - public List getVascLinkEntriesEditInline() { - return entry.getVascFrontendData().getVascFrontendHelper().getVascLinkEntryByType(entry,VascLinkEntryType.EDIT_INLINE); + public List getVascLinkEntriesEditInline() { + return entry.getVascFrontendController().getVascFrontendHelper().getVascLinkEntryByType(entry,VascEntryLinkType.EDIT_INLINE); } - public List getVascLinkEntriesEditTabParentState() { - if (entry.getVascFrontendData().getVascEntryState().getParent()==null) { - List result = new ArrayList(0); + public List getVascLinkEntriesEditTabParentState() { + if (entry.getVascFrontendController().getVascEntryState().getParent()==null) { + List result = new ArrayList(0); return result; } - return entry.getVascFrontendData().getVascFrontendHelper().getVascLinkEntryByType(entry.getVascFrontendData().getVascEntryState().getParent().getVascEntry(),VascLinkEntryType.EDIT_TAB); + return entry.getVascFrontendController().getVascFrontendHelper().getVascLinkEntryByType(entry.getVascFrontendController().getVascEntryState().getParent().getVascEntry(),VascEntryLinkType.EDIT_TAB); } public long getPageTotalRecordCount() { - return entry.getVascFrontendData().getVascFrontendPager().getPageTotalRecordCount(); + return entry.getVascFrontendController().getVascFrontendPager().getPageTotalRecordCount(); } public long getPageStartCount() { - return entry.getVascFrontendData().getVascFrontendPager().getPageStartCount(); + return entry.getVascFrontendController().getVascFrontendPager().getPageStartCount(); } public long getPageStopCount() { - return entry.getVascFrontendData().getVascFrontendPager().getPageStopCount(); + return entry.getVascFrontendController().getVascFrontendPager().getPageStopCount(); } public List getGlobalExportItems() { @@ -232,7 +232,7 @@ public class JSFVascEntrySupportBean implements Serializable { s.setValue("null"); result.add(s); - int pageSize = getVascEntry().getVascFrontendData().getVascEntryState().getVascBackendState().getPageSize(); + int pageSize = getVascEntry().getVascFrontendController().getVascEntryState().getVascBackendState().getPageSize(); for (int i=0;i getTablePagesExtendedBegin() { - return entry.getVascFrontendData().getVascFrontendPager().getTablePagesExtendedBegin(); + return entry.getVascFrontendController().getVascFrontendPager().getTablePagesExtendedBegin(); } public List getTablePagesExtendedEnd() { - return entry.getVascFrontendData().getVascFrontendPager().getTablePagesExtendedEnd(); + return entry.getVascFrontendController().getVascFrontendPager().getTablePagesExtendedEnd(); } public List getTablePagesExtendedCenter() { - return entry.getVascFrontendData().getVascFrontendPager().getTablePagesExtendedCenter(); + return entry.getVascFrontendController().getVascFrontendPager().getTablePagesExtendedCenter(); } private String getComponentType(UIComponent comp) { @@ -285,10 +285,10 @@ public class JSFVascEntrySupportBean implements Serializable { public List getParentCustomRowActions() { List result = new ArrayList(5); VascEntry entry = getVascEntry(); - if (entry.getVascFrontendData().getVascEntryState().getParent()==null) { + if (entry.getVascFrontendController().getVascEntryState().getParent()==null) { return result; } - VascEntry parent = entry.getVascFrontendData().getVascEntryState().getParent().getVascEntry(); + VascEntry parent = entry.getVascFrontendController().getVascEntryState().getParent().getVascEntry(); for (RowVascAction action:parent.getRowActions()) { String actionId = action.getId(); if (AddRowAction.ACTION_ID.equals(actionId)) { @@ -310,25 +310,25 @@ public class JSFVascEntrySupportBean implements Serializable { logger.fine("parentCustomRowaction: "+actionIdString); JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(event.getComponent()); VascEntry entry = comp.getVascEntry(); - if (entry.getVascFrontendData().getVascEntryState().getParent()==null) { + if (entry.getVascFrontendController().getVascEntryState().getParent()==null) { return; } - VascEntry parent = entry.getVascFrontendData().getVascEntryState().getParent().getVascEntry(); + VascEntry parent = entry.getVascFrontendController().getVascEntryState().getParent().getVascEntry(); RowVascAction action = parent.getRowActionById(actionIdString); - Object parentSelected = entry.getVascFrontendData().getVascEntryState().getParent().getEntryDataObject(); + Object parentSelected = entry.getVascFrontendController().getVascEntryState().getParent().getEntryDataObject(); logger.fine("parentCustomRowaction do on: "+action+" parentSelection: "+parentSelected); try { action.doRowAction(parent,parentSelected); } catch (Exception e) { - entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e); + entry.getVascFrontendController().getVascFrontendHelper().handleException(entry, e); } logger.fine("parentCustomRowaction DONE"); } public boolean getHasMultiRowActions() { - int size = getVascEntry().getVascFrontendData().getVascFrontendHelper().getMultiRowActions(getVascEntry()).size(); + int size = getVascEntry().getVascFrontendController().getVascFrontendHelper().getMultiRowActions(getVascEntry()).size(); if (size==0) { return false; } @@ -343,7 +343,7 @@ public class JSFVascEntrySupportBean implements Serializable { s.setValue("null"); result.add(s); - for (RowVascAction a:getVascEntry().getVascFrontendData().getVascFrontendHelper().getMultiRowActions(getVascEntry())) { + for (RowVascAction a:getVascEntry().getVascFrontendController().getVascFrontendHelper().getMultiRowActions(getVascEntry())) { s = new SelectItem(); s.setLabel(i18nMap.get(a.getName())); s.setDescription(i18nMap.get(a.getDescription())); @@ -390,7 +390,7 @@ public class JSFVascEntrySupportBean implements Serializable { return; } RowVascAction action = vascEntry.getRowActionById(actionId); - VascEntryState state = vascEntry.getVascFrontendData().getVascEntryState(); + VascEntryState state = vascEntry.getVascFrontendController().getVascEntryState(); try { setSelectedMultiRowAction("null"); // reset to selected ... value @@ -427,7 +427,7 @@ public class JSFVascEntrySupportBean implements Serializable { logger.fine("searchAction"); JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(event.getComponent()); VascEntry entry = comp.getVascEntry(); - entry.getVascFrontendData().getVascFrontendActions().searchAction(searchString); + entry.getVascFrontendController().getVascFrontendActions().searchAction(searchString); } public void sortAction(ActionEvent event) { @@ -436,18 +436,18 @@ public class JSFVascEntrySupportBean implements Serializable { JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(event.getComponent()); VascEntry entry = comp.getVascEntry(); VascEntryField field = entry.getVascEntryFieldById(fieldIdString); - entry.getVascFrontendData().getVascFrontendActions().sortAction(field); - sortOrder = entry.getVascFrontendData().getVascEntryState().getVascBackendState().isSortAscending(); + entry.getVascFrontendController().getVascFrontendActions().sortAction(field); + sortOrder = entry.getVascFrontendController().getVascEntryState().getVascBackendState().isSortAscending(); sortField = field.getId(); } public boolean getRenderBackAction() { - return getVascEntry().getVascFrontendData().getVascEntryState().getParent()!=null; + return getVascEntry().getVascFrontendController().getVascEntryState().getParent()!=null; } public boolean getRenderBackEditAction() { - if (getVascEntry().getVascFrontendData().getVascEntryState().getParent()!=null) { - if (getVascEntry().getVascFrontendData().getVascEntryState().getParent().getVascEntry().getRowActionById("editRowAction")==null) { + if (getVascEntry().getVascFrontendController().getVascEntryState().getParent()!=null) { + if (getVascEntry().getVascFrontendController().getVascEntryState().getParent().getVascEntry().getRowActionById("editRowAction")==null) { return false; // parent is not editable } return true; @@ -458,11 +458,11 @@ public class JSFVascEntrySupportBean implements Serializable { public void backAction(ActionEvent event) { logger.fine("backAction"); JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(event.getComponent()); - comp.initGoto(entry.getVascFrontendData().getVascEntryState().getParent()); + comp.initGoto(entry.getVascFrontendController().getVascEntryState().getParent()); try { - entry.getVascFrontendData().getVascFrontend().renderView(); + entry.getVascFrontendController().getVascFrontend().renderView(); } catch (Exception e) { - entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e); + entry.getVascFrontendController().getVascFrontendHelper().handleException(entry, e); } } @@ -472,8 +472,8 @@ public class JSFVascEntrySupportBean implements Serializable { VascEntry entry = getVascEntry(); // select record to edit - Object rowObject = entry.getVascFrontendData().getVascEntryState().getParent().getEntryDataObject(); - comp.initGoto(entry.getVascFrontendData().getVascEntryState().getParent(),rowObject); + Object rowObject = entry.getVascFrontendController().getVascEntryState().getParent().getEntryDataObject(); + comp.initGoto(entry.getVascFrontendController().getVascEntryState().getParent(),rowObject); } @@ -483,7 +483,7 @@ public class JSFVascEntrySupportBean implements Serializable { JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(event.getComponent()); VascEntry entry = comp.getVascEntry(); selectedDirectPage=pageIndex+""; - entry.getVascFrontendData().getVascFrontendActions().pageAction(pageIndex); + entry.getVascFrontendController().getVascFrontendActions().pageAction(pageIndex); } public void pageNextAction(ActionEvent event) { @@ -491,14 +491,14 @@ public class JSFVascEntrySupportBean implements Serializable { JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(event.getComponent()); VascEntry entry = comp.getVascEntry(); - int pageIndex = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageIndex(); + int pageIndex = entry.getVascFrontendController().getVascEntryState().getVascBackendState().getPageIndex(); pageIndex++; selectedDirectPage=pageIndex+""; - entry.getVascFrontendData().getVascFrontendActions().pageAction(pageIndex); + entry.getVascFrontendController().getVascFrontendActions().pageAction(pageIndex); try { - entry.getVascFrontendData().getVascFrontend().renderView(); + entry.getVascFrontendController().getVascFrontend().renderView(); } catch (Exception e) { - entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e); + entry.getVascFrontendController().getVascFrontendHelper().handleException(entry, e); } } @@ -507,23 +507,23 @@ public class JSFVascEntrySupportBean implements Serializable { JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(event.getComponent()); VascEntry entry = comp.getVascEntry(); - int pageIndex = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageIndex(); + int pageIndex = entry.getVascFrontendController().getVascEntryState().getVascBackendState().getPageIndex(); pageIndex--; selectedDirectPage=pageIndex+""; - entry.getVascFrontendData().getVascFrontendActions().pageAction(pageIndex); + entry.getVascFrontendController().getVascFrontendActions().pageAction(pageIndex); try { - entry.getVascFrontendData().getVascFrontend().renderView(); + entry.getVascFrontendController().getVascFrontend().renderView(); } catch (Exception e) { - entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e); + entry.getVascFrontendController().getVascFrontendHelper().handleException(entry, e); } } public boolean getHasPageNextAction() { - return entry.getVascFrontendData().getVascFrontendPager().getHasPageNextAction(); + return entry.getVascFrontendController().getVascFrontendPager().getHasPageNextAction(); } public boolean getHasPagePreviousAction() { - return entry.getVascFrontendData().getVascFrontendPager().getHasPagePreviousAction(); + return entry.getVascFrontendController().getVascFrontendPager().getHasPagePreviousAction(); } @@ -547,7 +547,7 @@ public class JSFVascEntrySupportBean implements Serializable { action.doRowAction(entry, selected.getRecord()); } } catch (Exception e) { - entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e); + entry.getVascFrontendController().getVascFrontendHelper().handleException(entry, e); } logger.fine("RowAction DONE"); } @@ -561,7 +561,7 @@ public class JSFVascEntrySupportBean implements Serializable { try { action.doGlobalAction(entry); } catch (Exception e) { - entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e); + entry.getVascFrontendController().getVascFrontendHelper().handleException(entry, e); } } @@ -574,7 +574,7 @@ public class JSFVascEntrySupportBean implements Serializable { try { action.doRowAction(entry, null); } catch (Exception e) { - entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e); + entry.getVascFrontendController().getVascFrontendHelper().handleException(entry, e); } } @@ -585,13 +585,13 @@ public class JSFVascEntrySupportBean implements Serializable { VascDataBackendBean selected = comp.getSupportBean().getSelectedTableRecord(); logger.finer("Set selected: "+selected); VascEntry entry = comp.getVascEntry(); - entry.getVascFrontendData().getVascEntryState().setEntryDataObject(selected.getRecord()); - VascLinkEntry l = entry.getVascLinkEntryById(linkId); + entry.getVascFrontendController().getVascEntryState().setEntryDataObject(selected.getRecord()); + VascEntryLink l = entry.getVascEntryLinkById(linkId); comp.initGoto(l); try { - entry.getVascFrontendData().getVascFrontend().renderView(); + entry.getVascFrontendController().getVascFrontend().renderView(); } catch (Exception e) { - entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e); + entry.getVascFrontendController().getVascFrontendHelper().handleException(entry, e); } this.selected=selected; // renderView clears selected ! } @@ -602,10 +602,10 @@ public class JSFVascEntrySupportBean implements Serializable { JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(event.getComponent()); Object selected = comp.getSupportBean().getSelectedTableRecord().getRecord(); if ("up".equals(moveAction)) { - entry.getVascFrontendData().getVascFrontendActions().moveUpAction(selected); + entry.getVascFrontendController().getVascFrontendActions().moveUpAction(selected); } if ("down".equals(moveAction)) { - entry.getVascFrontendData().getVascFrontendActions().moveDownAction(selected); + entry.getVascFrontendController().getVascFrontendActions().moveDownAction(selected); } } @@ -616,12 +616,12 @@ public class JSFVascEntrySupportBean implements Serializable { VascDataBackendBean selected = this.selected; logger.fine("Set selected: "+selected); VascEntry entry = comp.getVascEntry(); - VascLinkEntry l = entry.getVascLinkEntryById(linkId); + VascEntryLink l = entry.getVascEntryLinkById(linkId); comp.initGoto(l); try { - entry.getVascFrontendData().getVascFrontend().renderView(); + entry.getVascFrontendController().getVascFrontend().renderView(); } catch (Exception e) { - entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e); + entry.getVascFrontendController().getVascFrontendHelper().handleException(entry, e); } this.selected=selected; // renderView clears selected ! } @@ -630,17 +630,17 @@ public class JSFVascEntrySupportBean implements Serializable { logger.fine("linkListAction"); String linkId = getComponentType(event.getComponent()); JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(event.getComponent()); - VascLinkEntry link = comp.getVascEntry().getVascFrontendData().getVascEntryState().getParent().getVascEntry().getVascLinkEntryById(linkId); - comp.initGoto(link,comp.getVascEntry().getVascFrontendData().getVascEntryState().getParent()); + VascEntryLink link = comp.getVascEntry().getVascFrontendController().getVascEntryState().getParent().getVascEntry().getVascEntryLinkById(linkId); + comp.initGoto(link,comp.getVascEntry().getVascFrontendController().getVascEntryState().getParent()); - Object o = comp.getVascEntry().getVascFrontendData().getVascEntryState().getParent().getEntryDataObject(); - int index = comp.getVascEntry().getVascFrontendData().getVascEntryState().getParent().getEntryDataList().indexOf(o); + Object o = comp.getVascEntry().getVascFrontendController().getVascEntryState().getParent().getEntryDataObject(); + int index = comp.getVascEntry().getVascFrontendController().getVascEntryState().getParent().getEntryDataList().indexOf(o); VascDataBackendBean selected = new VascDataBackendBean(entry,o,index); this.selected=selected; try { - entry.getVascFrontendData().getVascFrontend().renderView(); + entry.getVascFrontendController().getVascFrontend().renderView(); } catch (Exception e) { - entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e); + entry.getVascFrontendController().getVascFrontendHelper().handleException(entry, e); } this.selected=selected; } @@ -652,11 +652,11 @@ public class JSFVascEntrySupportBean implements Serializable { if (getSelected()!=null) { getSelected().setRealValue(false); } - entry.getVascFrontendData().getVascEntryState().setEntryDataObject(null); + entry.getVascFrontendController().getVascEntryState().setEntryDataObject(null); try { - entry.getVascFrontendData().getVascFrontend().renderView(); + entry.getVascFrontendController().getVascFrontend().renderView(); } catch (Exception e) { - entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e); + entry.getVascFrontendController().getVascFrontendHelper().handleException(entry, e); } } @@ -679,18 +679,18 @@ public class JSFVascEntrySupportBean implements Serializable { } */ - entry.getVascFrontendData().getVascEntryState().setEntryDataObject(selected.getRecord()); + entry.getVascFrontendController().getVascEntryState().setEntryDataObject(selected.getRecord()); - if (entry.getVascFrontendData().getVascEntryState().isEditCreate()) { - entry.getVascFrontendData().getVascFrontendActions().persistObject(); + if (entry.getVascFrontendController().getVascEntryState().isEditCreate()) { + entry.getVascFrontendController().getVascFrontendActions().persistObject(); } else { - entry.getVascFrontendData().getVascFrontendActions().mergeObject(); + entry.getVascFrontendController().getVascFrontendActions().mergeObject(); } try { - entry.getVascFrontendData().getVascFrontend().renderView(); + entry.getVascFrontendController().getVascFrontend().renderView(); } catch (Exception e) { - entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e); + entry.getVascFrontendController().getVascFrontendHelper().handleException(entry, e); } } @@ -698,7 +698,7 @@ public class JSFVascEntrySupportBean implements Serializable { logger.fine("deleteAction"); JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(event.getComponent()); VascEntry entry = comp.getVascEntry(); - VascEntryState state = entry.getVascFrontendData().getVascEntryState(); + VascEntryState state = entry.getVascFrontendController().getVascEntryState(); List sels = new ArrayList(5); for (Integer rowId:state.getMultiActionSelection().keySet()) { @@ -711,18 +711,18 @@ public class JSFVascEntrySupportBean implements Serializable { } if (sels.isEmpty()==false) { for (Object row:sels) { - entry.getVascFrontendData().getVascEntryState().setEntryDataObject(row); - entry.getVascFrontendData().getVascFrontendActions().deleteObject(); + entry.getVascFrontendController().getVascEntryState().setEntryDataObject(row); + entry.getVascFrontendController().getVascFrontendActions().deleteObject(); } state.getMultiActionSelection().clear(); // after down deselect all options } else { - entry.getVascFrontendData().getVascFrontendActions().deleteObject(); + entry.getVascFrontendController().getVascFrontendActions().deleteObject(); } try { - entry.getVascFrontendData().getVascFrontend().renderView(); + entry.getVascFrontendController().getVascFrontend().renderView(); } catch (Exception e) { - entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e); + entry.getVascFrontendController().getVascFrontendHelper().handleException(entry, e); } } @@ -751,7 +751,7 @@ public class JSFVascEntrySupportBean implements Serializable { try { action.doGlobalAction(entry); } catch (Exception e) { - entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e); + entry.getVascFrontendController().getVascFrontendHelper().handleException(entry, e); } // restore normal view for next request. @@ -777,7 +777,7 @@ public class JSFVascEntrySupportBean implements Serializable { ex.doExport(out, entry); out.close(); } catch (Exception e) { - entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e); + entry.getVascFrontendController().getVascFrontendHelper().handleException(entry, e); } finally { fc.responseComplete(); } @@ -807,10 +807,10 @@ public class JSFVascEntrySupportBean implements Serializable { //selectedDirectPage = "null"; try { - entry.getVascFrontendData().getVascFrontendActions().pageAction(new Integer(id)); - entry.getVascFrontendData().getVascFrontend().renderView(); + entry.getVascFrontendController().getVascFrontendActions().pageAction(new Integer(id)); + entry.getVascFrontendController().getVascFrontend().renderView(); } catch (Exception e) { - entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e); + entry.getVascFrontendController().getVascFrontendHelper().handleException(entry, e); } } @@ -999,7 +999,7 @@ class JSFVascSupportI18nMapController implements Map { } public String get(Object key) { - String result = entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue((String)key); + String result = entry.getVascFrontendController().getVascEntryResourceResolver().getTextValue((String)key); return result; } diff --git a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascFrontendRenderer.java b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascFrontendRenderer.java index 77bb88b..608819d 100644 --- a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascFrontendRenderer.java +++ b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascFrontendRenderer.java @@ -30,7 +30,7 @@ import javax.faces.context.FacesContext; import net.forwardfire.vasc.core.entry.VascEntryExporter; import net.forwardfire.vasc.frontend.AbstractVascFrontend; -import net.forwardfire.vasc.frontend.VascFrontendData; +import net.forwardfire.vasc.frontend.VascFrontendController; import net.forwardfire.vasc.frontend.web.jsf.ui.JSFBoolean; import net.forwardfire.vasc.frontend.web.jsf.ui.JSFLabel; import net.forwardfire.vasc.frontend.web.jsf.ui.JSFList; @@ -66,7 +66,7 @@ public class JSFVascFrontendRenderer extends AbstractVascFrontend implements Ser protected void addUiComponents() { - VascFrontendData vfd = getVascEntry().getVascFrontendData(); + VascFrontendController vfd = getVascEntry().getVascFrontendController(); // required UI components vfd.putVascUIComponent(net.forwardfire.vasc.core.ui.VascUIComponent.VASC_LABEL,JSFLabel.class.getName()); @@ -100,12 +100,12 @@ public class JSFVascFrontendRenderer extends AbstractVascFrontend implements Ser UIViewRoot viewRoot = FacesContext.getCurrentInstance().getViewRoot(); JSFVascUIComponent comp = JSFVascUIComponent.findVascChild(viewRoot,getVascEntry().getId()); comp.setRenderFacetState("editView"); - entry.getVascFrontendData().getVascFrontendHelper().editReadOnlyUIComponents(entry); + entry.getVascFrontendController().getVascFrontendHelper().editReadOnlyUIComponents(entry); VascDataBackendBean selBean = null; - if (entry.getVascFrontendData().getVascEntryState().isEditCreate()) { - int index = entry.getVascFrontendData().getVascEntryState().getEntryDataList().size()+1; - selBean = new VascDataBackendBean(entry,entry.getVascFrontendData().getVascEntryState().getEntryDataObject(),index); + if (entry.getVascFrontendController().getVascEntryState().isEditCreate()) { + int index = entry.getVascFrontendController().getVascEntryState().getEntryDataList().size()+1; + selBean = new VascDataBackendBean(entry,entry.getVascFrontendController().getVascEntryState().getEntryDataObject(),index); } else { selBean = comp.getSupportBean().getSelectedTableRecord(); } diff --git a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascUIComponent.java b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascUIComponent.java index e6845ca..83f9635 100644 --- a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascUIComponent.java +++ b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascUIComponent.java @@ -26,6 +26,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.util.Locale; import java.util.logging.Logger; import javax.el.ValueExpression; @@ -36,14 +37,14 @@ import javax.faces.context.FacesContext; import net.forwardfire.vasc.core.VascController; import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntryField; +import net.forwardfire.vasc.core.VascEntryLocal; import net.forwardfire.vasc.core.VascEntryState; import net.forwardfire.vasc.core.VascException; -import net.forwardfire.vasc.core.VascLinkEntry; +import net.forwardfire.vasc.core.VascEntryLink; import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener; import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener.VascFrontendEventType; -import net.forwardfire.vasc.frontend.VascFrontendData; +import net.forwardfire.vasc.frontend.VascFrontendController; import net.forwardfire.vasc.frontend.web.jsf.ui.JSFListModel; -import net.forwardfire.vasc.impl.DefaultVascFactory; /** * Renders an JSF vasc entry views. @@ -56,9 +57,6 @@ import net.forwardfire.vasc.impl.DefaultVascFactory; public class JSFVascUIComponent extends UIComponentBase { public static final String FAMILY = "vasc.jsf.component.family"; - public static final String VASC_CONTROLLER_KEY = "vascController"; - public static final String VASC_FRONTEND_DATA_KEY = "vascFrontendData"; - public static final String ENTRY_NAME_KEY = "entryName"; public static final String ENTRY_SUPPORT_VAR_KEY = "entrySupportVar"; public static final String TABLE_RECORD_VAR_KEY = "tableRecordVar"; public static final String INJECT_EDIT_FIELDS_ID = "injectEditFieldsId"; @@ -70,7 +68,7 @@ public class JSFVascUIComponent extends UIComponentBase { private JSFVascFrontendRenderer renderer = null; private JSFVascEntrySupportBean supportBean = null; private String renderFacetState = null; - private VascLinkEntry link = null; + private VascEntryLink link = null; private VascEntryState linkState = null; private VascEntryState state = null; private Object stateEditId = null; @@ -89,15 +87,12 @@ public class JSFVascUIComponent extends UIComponentBase { @Override public Object saveState(FacesContext facesContext) { logger.fine("Save State"); - Object values[] = new Object[8]; + Object values[] = new Object[5]; values[0] = super.saveState(facesContext); - values[1] = this.getAttributes().get(VASC_CONTROLLER_KEY); - values[2] = this.getAttributes().get(VASC_FRONTEND_DATA_KEY); - values[3] = this.getAttributes().get(ENTRY_NAME_KEY); - values[4] = renderer; - values[5] = supportBean; - values[6] = renderFacetState; - values[7] = this.getAttributes().get(INJECT_TABLE_OPTIONS_ON_CHANGE); + values[1] = renderer; + values[2] = supportBean; + values[3] = renderFacetState; + values[4] = this.getAttributes().get(INJECT_TABLE_OPTIONS_ON_CHANGE); return values; } @@ -107,13 +102,10 @@ public class JSFVascUIComponent extends UIComponentBase { logger.fine("Resotre State"); Object values[] = (Object[])state; super.restoreState(facesContext, values[0]); - this.getAttributes().put(VASC_CONTROLLER_KEY, values[1]); - this.getAttributes().put(VASC_FRONTEND_DATA_KEY, values[2]); - this.getAttributes().put(ENTRY_NAME_KEY, values[3]); - renderer = (JSFVascFrontendRenderer) values[4]; - supportBean = (JSFVascEntrySupportBean) values[5]; - renderFacetState = (String) values[6]; - injectTableOptionOnChange = (String) values[7]; + renderer = (JSFVascFrontendRenderer) values[1]; + supportBean = (JSFVascEntrySupportBean) values[2]; + renderFacetState = (String) values[3]; + injectTableOptionOnChange = (String) values[4]; // TODO: check if we can move this some day... String entrySupportVar = (String)getAttributes().get(JSFVascUIComponent.ENTRY_SUPPORT_VAR_KEY); @@ -175,11 +167,11 @@ public class JSFVascUIComponent extends UIComponentBase { return renderer.getVascEntry(); } - protected void initGoto(VascLinkEntry link) { + protected void initGoto(VascEntryLink link) { logger.fine("init goto "+link); this.link=link; } - protected void initGoto(VascLinkEntry link,VascEntryState state) { + protected void initGoto(VascEntryLink link,VascEntryState state) { logger.fine("init goto link: "+link); this.link=link; this.linkState=state; @@ -220,7 +212,7 @@ public class JSFVascUIComponent extends UIComponentBase { } supportBean = new JSFVascEntrySupportBean(entry); // copy search string for preadded search string from application layer - supportBean.setSearchString(entry.getVascFrontendData().getVascEntryState().getVascBackendState().getSearchString()); + supportBean.setSearchString(entry.getVascFrontendController().getVascEntryState().getVascBackendState().getSearchString()); init = true; } @@ -237,10 +229,10 @@ public class JSFVascUIComponent extends UIComponentBase { // edit action copyed try { VascEntry entry = supportBean.getVascEntry(); - entry.getVascFrontendData().getVascEntryState().setEditCreate(false); - entry.getVascFrontendData().fireVascFrontendEvent(entry, VascFrontendEventType.SELECT, rowObject); - entry.getVascFrontendData().getVascEntryState().setEntryDataObject(rowObject); - entry.getVascFrontendData().getVascFrontend().renderEdit(); + entry.getVascFrontendController().getVascEntryState().setEditCreate(false); + entry.getVascFrontendController().fireVascFrontendEvent(entry, VascFrontendEventType.SELECT, rowObject); + entry.getVascFrontendController().getVascEntryState().setEntryDataObject(rowObject); + entry.getVascFrontendController().getVascFrontend().renderEdit(); } catch (Exception e) { throw new RuntimeException("Could not renderEdit: "+e.getMessage(),e); } @@ -306,44 +298,34 @@ public class JSFVascUIComponent extends UIComponentBase { public VascEntry createClonedVascEntry() { - String entryName = null; - VascController vascController = null; - VascFrontendData frontendData = null; - - if (getAttributes().get(VASC_CONTROLLER_KEY) instanceof String) { - // fix for JSP tag handler - logger.finer("Getting expression: "+getAttributes().get(VASC_CONTROLLER_KEY)); - ValueExpression ve1 = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), (String)getAttributes().get(VASC_CONTROLLER_KEY), Object.class); - ValueExpression ve2 = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), (String)getAttributes().get(VASC_FRONTEND_DATA_KEY), Object.class); - ValueExpression ve3 = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), (String)getAttributes().get(ENTRY_NAME_KEY), String.class); - vascController = (VascController)ve1.getValue( FacesContext.getCurrentInstance().getELContext()); - frontendData = (VascFrontendData)ve2.getValue( FacesContext.getCurrentInstance().getELContext()); - entryName = (String)ve3.getValue( FacesContext.getCurrentInstance().getELContext()); - } else { - vascController = (VascController)getAttributes().get(VASC_CONTROLLER_KEY); - frontendData = (VascFrontendData)getAttributes().get(VASC_FRONTEND_DATA_KEY); - entryName = (String)getAttributes().get(ENTRY_NAME_KEY); - } + VascController vascController = (VascController)FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get(VascRequestFacesFilter.REQ_VASC_CONTOLLER); + String entryId = (String)FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get(VascRequestFacesFilter.REQ_VASC_ENTRY_ID); + if (link!=null) { - entryName = link.getVascEntryId(); + entryId = link.getVascEntryId(); } if (state!=null) { - entryName = state.getVascEntry().getId(); + entryId = state.getVascEntry().getId(); } - VascEntry entry = vascController.getVascEntryController().getVascEntryById(entryName); + VascEntryLocal entry = (VascEntryLocal)vascController.getVascEntryController().getVascEntryById(entryId); if (entry==null) { - throw new NullPointerException("Could not locate '"+entryName+"' from : "+vascController); + throw new NullPointerException("Could not get '"+entryId+"' from : "+vascController); } - frontendData.setVascFrontend(null); // reset data obj. todo rm this. + try { - DefaultVascFactory.fillVascEntryFrontend(entry, vascController, frontendData); - frontendData.initFrontendListeners(entry,"jsf"); + vascController.getVascEntryConfigController().configVascFrontendController(vascController, entry); } catch (Exception e1) { throw new RuntimeException(e1); } + VascFrontendController frontendData = entry.getVascFrontendController(); + try { + frontendData.initFrontendListeners(entry,"jsf"); + } catch (Exception e1) { + e1.printStackTrace(); + } if (state!=null) { // copy prevois parent @@ -353,7 +335,7 @@ public class JSFVascUIComponent extends UIComponentBase { if (link!=null) { // save state if (linkState==null) { - frontendData.getVascEntryState().setParent(getVascEntry().getVascFrontendData().getVascEntryState()); + frontendData.getVascEntryState().setParent(getVascEntry().getVascFrontendController().getVascEntryState()); } else { frontendData.getVascEntryState().setParent(linkState); } @@ -375,7 +357,7 @@ public class JSFVascUIComponent extends UIComponentBase { Object selectedValue = v.getVascEntryFieldValue().getValue(v, selected); // set data parameter on new vasc entry - entry.getVascFrontendData().getVascEntryState().getVascBackendState().setDataParameter(parameterName, selectedValue); + entry.getVascFrontendController().getVascEntryState().getVascBackendState().setDataParameter(parameterName, selectedValue); logger.fine("Setting link parameter: "+parameterName+" with: "+selectedValue); } @@ -388,7 +370,7 @@ public class JSFVascUIComponent extends UIComponentBase { } // create listener for new objects - entry.getVascFrontendData().addVascEntryFrontendEventListener(new CreateEntryFieldValuesListener2(fieldId,selectedValue)); + entry.getVascFrontendController().addVascEntryFrontendEventListener(new CreateEntryFieldValuesListener2(fieldId,selectedValue)); } } catch (Exception e) { throw new RuntimeException("error: "+e.getMessage(),e); @@ -397,7 +379,7 @@ public class JSFVascUIComponent extends UIComponentBase { String entrySupportVar = (String)getAttributes().get(JSFVascUIComponent.ENTRY_SUPPORT_VAR_KEY); - entry.getVascFrontendData().addVascEntryFrontendEventListener(new JSFVascEntryEventListener(entrySupportVar)); + entry.getVascFrontendController().addVascEntryFrontendEventListener(new JSFVascEntryEventListener(entrySupportVar)); return entry; } @@ -422,7 +404,7 @@ public class JSFVascUIComponent extends UIComponentBase { try { field.getVascEntryFieldValue().setValue(field, data, value); } catch (VascException e) { - entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e); + entry.getVascFrontendController().getVascFrontendHelper().handleException(entry, e); } } } diff --git a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascUIComponentRenderer.java b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascUIComponentRenderer.java index 1d2922b..03e1aa9 100644 --- a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascUIComponentRenderer.java +++ b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascUIComponentRenderer.java @@ -63,9 +63,10 @@ import javax.faces.validator.ValidatorException; import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntryField; +import net.forwardfire.vasc.core.VascEntryListOption; import net.forwardfire.vasc.core.VascException; -import net.forwardfire.vasc.core.VascLinkEntry; -import net.forwardfire.vasc.core.VascLinkEntryType; +import net.forwardfire.vasc.core.VascEntryLink; +import net.forwardfire.vasc.core.VascEntryLinkType; import net.forwardfire.vasc.core.actions.RowVascAction; import net.forwardfire.vasc.core.ui.VascOptionValueModelListener; import net.forwardfire.vasc.core.ui.VascUIComponent; @@ -106,7 +107,7 @@ public class JSFVascUIComponentRenderer extends Renderer { // hack for edit back action to set field disabled VascEntry entry = comp.getVascEntry(); - entry.getVascFrontendData().getVascFrontendHelper().editReadOnlyUIComponents(entry); + entry.getVascFrontendController().getVascFrontendHelper().editReadOnlyUIComponents(entry); } // render the current facet of the vasc component @@ -160,7 +161,7 @@ public class JSFVascUIComponentRenderer extends Renderer { } private String i18n(VascEntry entry,String key,Object...params) { - return entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(key,params); + return entry.getVascFrontendController().getVascEntryResourceResolver().getTextValue(key,params); } @@ -177,7 +178,7 @@ public class JSFVascUIComponentRenderer extends Renderer { String entrySupportVar = (String)comp.getAttributes().get(JSFVascUIComponent.ENTRY_SUPPORT_VAR_KEY); for (VascEntryField c:entry.getVascEntryFields()) { - if (entry.getVascFrontendData().getVascFrontendHelper().renderEdit(c)==false) { + if (entry.getVascFrontendController().getVascFrontendDataSelector().isFieldEdit(c)==false) { continue; } for (int i=0;i errors = entry.getVascFrontendData().getVascFrontendHelper().validateObjectField(field); + List errors = entry.getVascFrontendController().getVascFrontendHelper().validateObjectField(field); logger.fine("Validate: "+component+" errors: "+errors.size()+" value: "+object); if (errors.isEmpty()) { return; // no errors @@ -283,7 +284,7 @@ public class JSFVascUIComponentRenderer extends Renderer { //JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(grid); VascEntry entry = comp.getVascEntry(); - for (VascEntryField option:entry.getListOptions()) { + for (VascEntryListOption option:entry.getVascEntryListOptions()) { for (int i=0;ientry.getVascEntryFields().size()) { throw new IllegalArgumentException("Index is bigger then total field size: "+index); } - return entry.getVascEntryFields().get(index); + return entry.getVascFrontendController().getVascFrontendDataSelector().getFieldsList().get(index); } static public int getIndexId(VascEntryField field) { diff --git a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/VascRequestFacesFilter.java b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/VascRequestFacesFilter.java index 4f13c43..9ec938c 100644 --- a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/VascRequestFacesFilter.java +++ b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/VascRequestFacesFilter.java @@ -23,8 +23,6 @@ package net.forwardfire.vasc.frontend.web.jsf; import java.io.IOException; -import java.util.Locale; -import java.util.ResourceBundle; import java.util.logging.Level; import java.util.logging.Logger; @@ -45,6 +43,10 @@ import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import net.forwardfire.vasc.core.VascController; +import net.forwardfire.vasc.core.VascControllerProvider; +import net.forwardfire.vasc.core.VascEntry; + /** * Parses the Request info path info 3 vasc attributes an dispatches the request to the templateFile. * @@ -56,7 +58,11 @@ public class VascRequestFacesFilter implements Filter { private Logger logger = null; private String templateFile = null; private ServletContext servletContext = null; - private String resourceBundle = null; + private VascController vascController = null; + private VascControllerProvider vascControllerProvider = null; + static public final String REQ_VASC_CONTOLLER = "requestScopeVascController"; + static public final String REQ_VASC_ENTRY_ID = "requestScopeVascEntryId"; + static public final String REQ_VASC_URI_PATH = "requestScopeVascUriPath"; /** * @see javax.servlet.Filter#destroy() @@ -77,11 +83,30 @@ public class VascRequestFacesFilter implements Filter { if (templateFile==null) { throw new ServletException("No templateFile init-param found."); } - resourceBundle=config.getInitParameter("resourceBundle"); - if (resourceBundle==null) { - return; //throw new ServletException("No resourceBundle init-param found."); + String className = config.getInitParameter("vascControllerProvider"); + if (className==null) { + throw new ServletException("Can't start with null vascControllerProvider init parameter."); + } + String classArgument = null; + int atIndex = className.indexOf('@'); + if (atIndex > 0) { + classArgument = className.substring(0,atIndex); + className = className.substring(atIndex+1); + } + try { + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + if (cl == null) { + cl = className.getClass().getClassLoader(); + } + Class clazz = cl.loadClass(className); + if (classArgument==null) { + vascControllerProvider = (VascControllerProvider)clazz.newInstance(); + } else { + vascControllerProvider = (VascControllerProvider)clazz.getConstructor(String.class).newInstance(classArgument); + } + } catch (Exception e) { + throw new ServletException("Could not create VascControllerProvider: "+e.getMessage(),e); } - ResourceBundle.getBundle(resourceBundle); // test if it loads } @@ -101,7 +126,7 @@ public class VascRequestFacesFilter implements Filter { } // stuff to fill - String entityName = null; + String entryId = null; String actionName = null; String actionRecordId = null; @@ -111,9 +136,9 @@ public class VascRequestFacesFilter implements Filter { String actionString = null; if (index>0) { actionString = path.substring(index+1); - entityName = path.substring(0,index); + entryId = path.substring(0,index); } else { - entityName = path; + entryId = path; } if (actionString!=null) { @@ -132,7 +157,7 @@ public class VascRequestFacesFilter implements Filter { //log if (logger.isLoggable(Level.FINE)) { - logger.log(Level.FINE,"entityName="+entityName+" actionName="+actionName+" actionRecordId="+actionRecordId); + logger.log(Level.FINE,"entryId="+entryId+" actionName="+actionName+" actionRecordId="+actionRecordId); } // Acquire the FacesContext instance for this request @@ -145,42 +170,34 @@ public class VascRequestFacesFilter implements Filter { facesContext = facesContextFactory.getFacesContext(servletContext, request, response, lifecycle); ProtectedFacesContext.setFacesContextAsCurrentInstance(facesContext); - UIViewRoot viewRoot = facesContext.getApplication().getViewHandler().createView(facesContext,entityName+actionName); + UIViewRoot viewRoot = facesContext.getApplication().getViewHandler().createView(facesContext,entryId+actionName); facesContext.setViewRoot(viewRoot); } - // add to response - request.setAttribute("requestScopeVascEntityName", entityName); - request.setAttribute("requestScopeVascActionName", actionName); - request.setAttribute("requestScopeVascRecordId" , actionRecordId); - request.setAttribute("requestScopeVascPath" , request.getRequestURI()); - - // Set page title - Locale locale = facesContext.getViewRoot().getLocale(); - if (locale==null) { - logger.info("Failling back to defualt."); - locale = new Locale("nl"); - } - try { - if (resourceBundle!=null) { - ResourceBundle i18n = ResourceBundle.getBundle(resourceBundle,locale); - String titleI18n = i18n.getString("vasc.entry."+entityName+".name"); - request.setAttribute("requestScopeVascEntityNameI18n" ,titleI18n); - } else { - request.setAttribute("requestScopeVascEntityNameI18n" ,entityName); + if (vascController==null) { + synchronized (this) { + vascController = vascControllerProvider.getVascController(); } - } catch (Exception e) { - e.printStackTrace(); - request.setAttribute("requestScopeVascEntityNameI18n" ,entityName); } + // Fetch entry and do checks + VascEntry vascEntry = vascController.getVascEntryController().getVascEntryById(entryId); + if (vascEntry == null) { + response.sendRedirect("/"); + return; + } + + // add to request attributes + request.setAttribute(REQ_VASC_CONTOLLER, vascController); + request.setAttribute(REQ_VASC_ENTRY_ID, vascEntry.getId()); + request.setAttribute(REQ_VASC_URI_PATH, request.getRequestURI()); + + // And dispatch to the vasc template file. try { request.getRequestDispatcher(templateFile).forward(request, response); } catch (ViewExpiredException e) { - // lets try again - response.sendRedirect(request.getRequestURL().toString()); + response.sendRedirect(request.getRequestURL().toString()); // lets try again } - // done } private abstract static class ProtectedFacesContext extends FacesContext { diff --git a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/VascViewHandler.java b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/VascViewHandler.java index d461a88..d26047d 100644 --- a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/VascViewHandler.java +++ b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/VascViewHandler.java @@ -52,12 +52,11 @@ public class VascViewHandler extends ViewHandler { */ @Override public String getActionURL(FacesContext context, String name) { - HttpServletRequest request = (HttpServletRequest)context.getExternalContext().getRequest(); - if (request.getAttribute("requestScopeVascPath")==null) { + if (request.getAttribute(VascRequestFacesFilter.REQ_VASC_URI_PATH)==null) { return parentViewHandler.getActionURL(context, name); } - String path = (String)request.getAttribute("requestScopeVascPath"); + String path = (String)request.getAttribute(VascRequestFacesFilter.REQ_VASC_URI_PATH); return path; } diff --git a/vasc-lib/pom.xml b/vasc-lib/pom.xml index 812742c..f9b9f21 100644 --- a/vasc-lib/pom.xml +++ b/vasc-lib/pom.xml @@ -14,5 +14,6 @@ vasc-lib-i18n vasc-lib-jr4o + vasc-lib-editor \ No newline at end of file diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-editor/.project b/vasc-lib/vasc-lib-editor/.project similarity index 100% rename from vasc-demo/vasc-demo-tech/vasc-demo-tech-editor/.project rename to vasc-lib/vasc-lib-editor/.project diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-editor/pom.xml b/vasc-lib/vasc-lib-editor/pom.xml similarity index 58% rename from vasc-demo/vasc-demo-tech/vasc-demo-tech-editor/pom.xml rename to vasc-lib/vasc-lib-editor/pom.xml index 87d658d..e2a0f40 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-editor/pom.xml +++ b/vasc-lib/vasc-lib-editor/pom.xml @@ -1,12 +1,12 @@ 4.0.0 - vasc-demo-tech - net.forwardfire.vasc.demo + vasc-lib + net.forwardfire.vasc.lib 0.3.5-SNAPSHOT .. - vasc-demo-tech-editor - vasc-demo-tech-editor - vasc-demo-tech-editor + vasc-lib-editor + vasc-lib-editor + vasc-lib-editor \ No newline at end of file diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-editor/src/main/resources/net/forwardfire/vasc/editor/vasc-edit.xml b/vasc-lib/vasc-lib-editor/src/main/resources/net/forwardfire/vasc/editor/vasc-edit.xml similarity index 100% rename from vasc-demo/vasc-demo-tech/vasc-demo-tech-editor/src/main/resources/net/forwardfire/vasc/editor/vasc-edit.xml rename to vasc-lib/vasc-lib-editor/src/main/resources/net/forwardfire/vasc/editor/vasc-edit.xml diff --git a/vasc-lib/vasc-lib-editor/src/main/resources/net/forwardfire/vasc/lib/editor/vasc-edit.xml b/vasc-lib/vasc-lib-editor/src/main/resources/net/forwardfire/vasc/lib/editor/vasc-edit.xml new file mode 100644 index 0000000..71df6d6 --- /dev/null +++ b/vasc-lib/vasc-lib-editor/src/main/resources/net/forwardfire/vasc/lib/editor/vasc-edit.xml @@ -0,0 +1,145 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/AbstractRootApplicationBundle.java b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/AbstractRootApplicationBundle.java index b16b4f9..ccc21ef 100644 --- a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/AbstractRootApplicationBundle.java +++ b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/AbstractRootApplicationBundle.java @@ -63,8 +63,8 @@ abstract public class AbstractRootApplicationBundle extends MergeableResourceBun config.parseConfig(); applicationSupportedLocales = config.getApplicationSupportedLocales(); bundleConfigs = config.getBundleConfigs(); - for (BundleConfig bc:bundleConfigs) { - addBundleData(config.loadBundleConfig(bc,getLocale())); + for (BundleConfig bundleConfig:bundleConfigs) { + addBundleData(config.loadBundleConfigData(bundleConfig,getLocale())); } } diff --git a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/MergeableResourceBundle.java b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/MergeableResourceBundle.java index 8a68a39..15b330c 100644 --- a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/MergeableResourceBundle.java +++ b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/MergeableResourceBundle.java @@ -27,7 +27,6 @@ import java.util.Enumeration; import java.util.HashMap; import java.util.Map; import java.util.ResourceBundle; -import java.util.logging.Logger; /** * MergeableResourceBundle is an ResourceBundle which can merge different bundles into one. @@ -37,14 +36,12 @@ import java.util.logging.Logger; */ public class MergeableResourceBundle extends ResourceBundle { - private Logger logger = null; private Map bundleData = null; /** * Creates an new MergeableResourceBundle instance. */ public MergeableResourceBundle() { - logger = Logger.getLogger(MergeableResourceBundle.class.getName()); bundleData = new HashMap(500); init(); } @@ -59,7 +56,6 @@ public class MergeableResourceBundle extends ResourceBundle { * Protected method to clear the bundle data. */ protected void clear() { - logger.fine("Clearing bundle data current size: "+bundleData.size()); bundleData.clear(); } @@ -84,9 +80,7 @@ public class MergeableResourceBundle extends ResourceBundle { * @param dataMap */ public void addBundleData(Map dataMap) { - int startSize = bundleData.size(); bundleData.putAll(dataMap); - logger.fine("Adding bundle data: "+dataMap.size()+" orgSize: "+startSize+" newSize: "+bundleData.size()); } /** @@ -94,11 +88,9 @@ public class MergeableResourceBundle extends ResourceBundle { * @param bundle */ public void addBundleData(ResourceBundle bundle) { - int startSize = bundleData.size(); for (String key:bundle.keySet()) { String value = bundle.getString(key); bundleData.put(key, value); } - logger.fine("Adding bundle data: "+bundle.keySet().size()+" orgSize: "+startSize+" newSize: "+bundleData.size()); } } diff --git a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle.java b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle.java index 153b753..0c98d52 100644 --- a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle.java +++ b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle.java @@ -33,6 +33,8 @@ import net.forwardfire.vasc.lib.i18n.SupportedBundleLocale; */ public class RootApplicationBundle extends AbstractRootApplicationBundle { + static public final String URI = RootApplicationBundle.class.getName(); + @Override public SupportedBundleLocale getSupportedBundleLocale() { return SupportedBundleLocale.DEFAULT_LOCALE; diff --git a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/config/BundleCharSetControl.java b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/config/BundleCharSetControl.java new file mode 100644 index 0000000..19dd021 --- /dev/null +++ b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/config/BundleCharSetControl.java @@ -0,0 +1,64 @@ +package net.forwardfire.vasc.lib.i18n.config; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; +import java.net.URLConnection; +import java.nio.charset.Charset; +import java.util.Locale; +import java.util.PropertyResourceBundle; +import java.util.ResourceBundle; +import java.util.ResourceBundle.Control; + +/** + * BundleCharSetControl load ResourceBundles with correct CharSet. + * + * @author Willem Cazander + * @version 1.0 May 8, 2012 + */ +public class BundleCharSetControl extends Control { + + /** The default extension for bundles. */ + protected static final String BUNDLE_EXTENSION = "properties"; + + /** The charSet to load with **/ + protected Charset charSet = null; + + /** + * Creates BundleCharSetControl to read ResourceBundle with charSet. + */ + public BundleCharSetControl(Charset charSet) { + this.charSet=charSet; + } + + /** + * Does the loading of the ResourceBundle + */ + public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IllegalAccessException, InstantiationException, IOException { + String bundleName = toBundleName(baseName, locale); + String resourceName = toResourceName(bundleName, BUNDLE_EXTENSION); + ResourceBundle bundle = null; + InputStream stream = null; + if (reload) { + URL url = loader.getResource(resourceName); + if (url != null) { + URLConnection connection = url.openConnection(); + if (connection != null) { + connection.setUseCaches(false); + stream = connection.getInputStream(); + } + } + } else { + stream = loader.getResourceAsStream(resourceName); + } + if (stream != null) { + try { + bundle = new PropertyResourceBundle(new InputStreamReader(stream, charSet)); + } finally { + stream.close(); + } + } + return bundle; + } +} diff --git a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/config/BundleConfig.java b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/config/BundleConfig.java index 76c1cce..fb31718 100644 --- a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/config/BundleConfig.java +++ b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/config/BundleConfig.java @@ -22,6 +22,8 @@ package net.forwardfire.vasc.lib.i18n.config; +import java.nio.charset.Charset; + /** * BundleConfig holds the config to load one bundle. * @@ -35,7 +37,7 @@ public class BundleConfig { private String exclude = null; private BundleURIType uriType = BundleURIType.RESOURCE; private BundleFormat format = BundleFormat.BUNDLE; - private boolean utf8 = true; + private Charset charSet = null; private boolean optional = false; /** @@ -109,19 +111,19 @@ public class BundleConfig { } /** - * @return the utf8 + * @return the charSet */ - public boolean isUtf8() { - return utf8; + public Charset getCharSet() { + return charSet; } - + /** - * @param utf8 the utf8 to set + * @param charSet the charSet to set */ - public void setUtf8(boolean utf8) { - this.utf8 = utf8; + public void setCharSet(Charset charSet) { + this.charSet = charSet; } - + /** * @return the optional */ diff --git a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/config/BundleConfigParser.java b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/config/BundleConfigParser.java index 8e3b3f4..f483b11 100644 --- a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/config/BundleConfigParser.java +++ b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/config/BundleConfigParser.java @@ -25,19 +25,18 @@ package net.forwardfire.vasc.lib.i18n.config; import java.io.File; import java.io.FileInputStream; import java.io.IOException; -import java.io.InputStream; import java.io.InputStreamReader; +import java.io.Reader; import java.net.URL; -import java.net.URLConnection; +import java.nio.charset.Charset; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Properties; -import java.util.PropertyResourceBundle; import java.util.ResourceBundle; -import java.util.ResourceBundle.Control; import java.util.logging.Logger; /** @@ -50,34 +49,51 @@ public class BundleConfigParser { private Logger logger = null; public static final String CONFIG_RESOURCE_DEFAULT = "META-INF/root-bundle.properties"; - protected static final String BUNDLE_EXTENSION = "properties"; - protected static final Control UTF8_CONTROL = new UTF8Control(); + protected static final String DEFAULT_CHAR_SET = "UTF-8"; protected List applicationSupportedLocales = null; - protected List bundlesConfigs = null; - + protected List bundlesConfigs = null; + protected List bundleNames = null; + protected Charset defaultCharSet = null; + + /** + * Creates new BundleConfigParser object. + */ public BundleConfigParser() { logger = Logger.getLogger(BundleConfigParser.class.getName()); applicationSupportedLocales = new ArrayList(10); bundlesConfigs = new ArrayList(10); + defaultCharSet = Charset.forName(DEFAULT_CHAR_SET); + bundleNames = new ArrayList(10); } - + + /** + * Cleans config and + */ public void parseConfig() { - bundlesConfigs.clear(); - applicationSupportedLocales.clear(); + cleanConfig(); Properties properties = new Properties(); - readPropertiesResource(properties,CONFIG_RESOURCE_DEFAULT); + readPropertiesConfig(properties); parseProperties(properties); } + /** + * Returns List of supported locales by this root bundle config. + */ public List getApplicationSupportedLocales() { return applicationSupportedLocales; } + /** + * Returns List of ordered bundle configs to load into root bundle. + */ public List getBundleConfigs() { return bundlesConfigs; } - public Map loadBundleConfig(BundleConfig bundle,Locale locale) { + /** + * Loads BundleConfig and returns localized data as map. + */ + public Map loadBundleConfigData(BundleConfig bundle,Locale locale) { Properties properties = new Properties(); try { switch (bundle.getUriType()) { @@ -86,10 +102,10 @@ public class BundleConfigParser { readPropertiesBundle(properties,bundle,locale); break; case URL: - readPropertiesStream(properties,new URL(bundle.getUri()).openStream()); + readPropertiesBundleUrl(properties,bundle,new URL(bundle.getUri())); break; case FILE: - readPropertiesFile(properties,new File(bundle.getUri())); + readPropertiesBundleFile(properties,bundle,new File(bundle.getUri())); break; } } catch (Exception e) { @@ -113,55 +129,17 @@ public class BundleConfigParser { return result; } - protected void readPropertiesFile(Properties p,File file) { - logger.info("Reading bundle file: "+file.getAbsoluteFile()); - try { - readPropertiesStream(p,new FileInputStream(file)); - } catch (Exception e) { - throw new RuntimeException("Could not load resource file error: "+e.getMessage(),e); - } - } - - protected void readPropertiesBundle(Properties p,BundleConfig bundle,Locale locale) { - ResourceBundle bundleReal = null; - if (bundle.isUtf8()) { - bundleReal = ResourceBundle.getBundle(bundle.getUri(),locale,UTF8_CONTROL); - } else { - bundleReal = ResourceBundle.getBundle(bundle.getUri(),locale); - } - for (String key:bundleReal.keySet()) { - String value = bundleReal.getString(key); - p.put(key, value); - } - } - - protected void readPropertiesResource(Properties p,String resource) { - try { - ClassLoader cl = Thread.currentThread().getContextClassLoader(); - if (cl == null) { - cl = p.getClass().getClassLoader(); // fallback - } - readPropertiesStream(p,cl.getResourceAsStream(resource)); - } catch (Exception e) { - throw new RuntimeException("Could not load resource: "+resource+" error: "+e.getMessage(),e); - } - } - - protected void readPropertiesStream(Properties p,InputStream in) { - try { - p.load(in); - } catch (Exception e) { - throw new RuntimeException("Could not load properties error: "+e.getMessage(),e); - } finally { - if (in!=null) { - try { - in.close(); - } catch (IOException e) { - } - } - } + /** + * Cleans bundle configs and supported locales. + */ + protected void cleanConfig() { + bundlesConfigs.clear(); + applicationSupportedLocales.clear(); } + /** + * Parsed the root-bundle.properties file format. + */ protected void parseProperties(Properties p) { Map bundles = new HashMap(10); for (Object keyO:p.keySet()) { @@ -177,6 +155,15 @@ public class BundleConfigParser { applicationSupportedLocales.add(new Locale(keyField)); continue; } + if ("config".equals(keyConfig)) { + if ("charset".equals(keyField)) { + defaultCharSet = Charset.forName(value); + } else if ("bundles".equals(keyField)) { + String[] configBundles = value.split(","); + bundleNames.addAll(Arrays.asList(configBundles)); + } + continue; + } BundleConfig c = bundles.get(keyConfig); if (c==null) { @@ -194,44 +181,90 @@ public class BundleConfigParser { c.setFormat(BundleFormat.valueOf(value)); } else if ("optional".equals(keyField)) { c.setOptional(new Boolean(value)); - } else if ("utf8".equals(keyField)) { - c.setUtf8(new Boolean(value)); + } else if ("charset".equals(keyField)) { + c.setCharSet(Charset.forName(value)); + } + } + if (bundleNames.isEmpty()) { + bundlesConfigs.addAll(bundles.values()); + } else { + for (String bundleName:bundleNames) { + BundleConfig bundle = bundles.get(bundleName); + bundlesConfigs.add(bundle); + } + } + for (BundleConfig bundle:bundlesConfigs) { + if (bundle.getCharSet()==null) { + bundle.setCharSet(defaultCharSet); } } - bundlesConfigs.addAll(bundles.values()); } - - protected static class UTF8Control extends Control { - public ResourceBundle newBundle - (String baseName, Locale locale, String format, ClassLoader loader, boolean reload) - throws IllegalAccessException, InstantiationException, IOException - { - // The below code is copied from default Control#newBundle() implementation. - // Only the PropertyResourceBundle line is changed to read the file as UTF-8. - String bundleName = toBundleName(baseName, locale); - String resourceName = toResourceName(bundleName, BUNDLE_EXTENSION); - ResourceBundle bundle = null; - InputStream stream = null; - if (reload) { - URL url = loader.getResource(resourceName); - if (url != null) { - URLConnection connection = url.openConnection(); - if (connection != null) { - connection.setUseCaches(false); - stream = connection.getInputStream(); - } - } - } else { - stream = loader.getResourceAsStream(resourceName); - } - if (stream != null) { - try { - bundle = new PropertyResourceBundle(new InputStreamReader(stream, "UTF-8")); - } finally { - stream.close(); - } - } - return bundle; - } - } + + /** + * Reads properties file from disk. + */ + protected void readPropertiesBundleFile(Properties p,BundleConfig bundle,File file) { + logger.fine("Reading bundle file: "+file.getAbsoluteFile()); + try { + readProperties(p,new InputStreamReader(new FileInputStream(file),bundle.getCharSet())); + } catch (Exception e) { + throw new RuntimeException("Could not load resource file error: "+e.getMessage(),e); + } + } + + /** + * Reads properties file from url. + */ + protected void readPropertiesBundleUrl(Properties p,BundleConfig bundle,URL url) { + logger.fine("Reading bundle url: "+url.toString()); + try { + readProperties(p,new InputStreamReader(url.openStream(),bundle.getCharSet())); + } catch (Exception e) { + throw new RuntimeException("Could not load resource file error: "+e.getMessage(),e); + } + } + + /** + * Read ResourceBundle from classpath. + */ + protected void readPropertiesBundle(Properties p,BundleConfig bundle,Locale locale) { + ResourceBundle bundleReal = ResourceBundle.getBundle(bundle.getUri(),locale,new BundleCharSetControl(bundle.getCharSet())); + for (String key:bundleReal.keySet()) { + String value = bundleReal.getString(key); + p.put(key, value); + } + } + + /** + * Read properties from Reader and close Reader. + */ + protected void readProperties(Properties p,Reader in) { + try { + p.load(in); + } catch (Exception e) { + throw new RuntimeException("Could not load properties error: "+e.getMessage(),e); + } finally { + if (in!=null) { + try { + in.close(); + } catch (IOException e) { + } + } + } + } + + /** + * Read properties file from resource classpath. + */ + protected void readPropertiesConfig(Properties p) { + try { + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + if (cl == null) { + cl = p.getClass().getClassLoader(); // fallback + } + readProperties(p,new InputStreamReader(cl.getResourceAsStream(CONFIG_RESOURCE_DEFAULT),defaultCharSet)); + } catch (Exception e) { + throw new RuntimeException("Could not load resource: "+CONFIG_RESOURCE_DEFAULT+" error: "+e.getMessage(),e); + } + } } diff --git a/vasc-lib/vasc-lib-i18n/src/test/java/net/forwardfire/vasc/lib/i18n/RootBundleTest.java b/vasc-lib/vasc-lib-i18n/src/test/java/net/forwardfire/vasc/lib/i18n/RootBundleTest.java index 44b10c4..21ce0a9 100644 --- a/vasc-lib/vasc-lib-i18n/src/test/java/net/forwardfire/vasc/lib/i18n/RootBundleTest.java +++ b/vasc-lib/vasc-lib-i18n/src/test/java/net/forwardfire/vasc/lib/i18n/RootBundleTest.java @@ -1,8 +1,11 @@ package net.forwardfire.vasc.lib.i18n; +import java.util.List; import java.util.Locale; import java.util.ResourceBundle; +import net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle; +import net.forwardfire.vasc.lib.i18n.config.BundleConfig; import net.forwardfire.vasc.lib.i18n.config.BundleConfigParser; import junit.framework.TestCase; @@ -15,16 +18,34 @@ import junit.framework.TestCase; */ public class RootBundleTest extends TestCase { + static private final String TEST_BUNDLE = RootApplicationBundle.URI; + static private final Locale TEST_LOCALE = new Locale("en"); + static private final Locale TEST_LOCALE_NL = new Locale("nl"); + public void testParser() { BundleConfigParser p = new BundleConfigParser(); p.parseConfig(); assertEquals(2,p.getBundleConfigs().size()); assertEquals(2,p.getApplicationSupportedLocales().size()); } + + public void testBundleOrder() { + BundleConfigParser p = new BundleConfigParser(); + p.parseConfig(); + List conf = p.getBundleConfigs(); + assertTrue(conf.isEmpty()==false); + BundleConfig bundle = conf.get(0); + assertEquals("bundle2",bundle.getName()); + } + + public void testBundleOrderValue() { + ResourceBundle bundle = ResourceBundle.getBundle(TEST_BUNDLE,TEST_LOCALE); + assertEquals("bundle1",bundle.getString("bundle.key")); + } public void testValues_en() { - ResourceBundle bundle = ResourceBundle.getBundle("net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle",new Locale("en")); - assertEquals(6,bundle.keySet().size()); + ResourceBundle bundle = ResourceBundle.getBundle(TEST_BUNDLE,TEST_LOCALE); + assertEquals(7,bundle.keySet().size()); assertEquals("key1_en",bundle.getString("bundle1.key1")); assertEquals("key2_en",bundle.getString("bundle1.key2")); assertEquals("key3_en",bundle.getString("bundle1.key3")); @@ -34,8 +55,8 @@ public class RootBundleTest extends TestCase { } public void testValues_nl() { - ResourceBundle bundle = ResourceBundle.getBundle("net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle",new Locale("nl")); - assertEquals(6,bundle.keySet().size()); + ResourceBundle bundle = ResourceBundle.getBundle(TEST_BUNDLE,TEST_LOCALE_NL); + assertEquals(7,bundle.keySet().size()); assertEquals("key1_nl",bundle.getString("bundle1.key1")); assertEquals("key2_nl",bundle.getString("bundle1.key2")); assertEquals("key3_nl",bundle.getString("bundle1.key3")); diff --git a/vasc-lib/vasc-lib-i18n/src/test/resources/META-INF/root-bundle.properties b/vasc-lib/vasc-lib-i18n/src/test/resources/META-INF/root-bundle.properties index 76a2be5..9708e38 100644 --- a/vasc-lib/vasc-lib-i18n/src/test/resources/META-INF/root-bundle.properties +++ b/vasc-lib/vasc-lib-i18n/src/test/resources/META-INF/root-bundle.properties @@ -1,4 +1,8 @@ +# Default config +config.charset=UTF-8 +config.bundles=bundle2,bundle1 + # We only suport 2 languages. locale.nl=true locale.en=true @@ -7,12 +11,13 @@ locale.en=true bundle1.uri=net.forwardfire.vasc.lib.i18n.resources.TestBundle1 bundle2.uri=net.forwardfire.vasc.lib.i18n.resources.TestBundle2 -# TODO: +# +# Bundle options; # # bundle2.type=RESOURCE # bundle2.exclude=yoyo.* # bundle2.format=PROPERTIES -# bundle2.utf8=true +# bundle2.charset=UTF-8 # bundle2.optional=false # # bundle3.uri=http://foo.bar/some/path/bundle.properties diff --git a/vasc-lib/vasc-lib-i18n/src/test/resources/net/forwardfire/vasc/lib/i18n/resources/TestBundle1_en.properties b/vasc-lib/vasc-lib-i18n/src/test/resources/net/forwardfire/vasc/lib/i18n/resources/TestBundle1_en.properties index e742510..0e0c989 100644 --- a/vasc-lib/vasc-lib-i18n/src/test/resources/net/forwardfire/vasc/lib/i18n/resources/TestBundle1_en.properties +++ b/vasc-lib/vasc-lib-i18n/src/test/resources/net/forwardfire/vasc/lib/i18n/resources/TestBundle1_en.properties @@ -1,4 +1,6 @@ # Test bundle +bundle.key = bundle1 bundle1.key1 = key1_en bundle1.key2 = key2_en bundle1.key3 = key3_en + diff --git a/vasc-lib/vasc-lib-i18n/src/test/resources/net/forwardfire/vasc/lib/i18n/resources/TestBundle1_nl.properties b/vasc-lib/vasc-lib-i18n/src/test/resources/net/forwardfire/vasc/lib/i18n/resources/TestBundle1_nl.properties index 59d2987..cd8a56f 100644 --- a/vasc-lib/vasc-lib-i18n/src/test/resources/net/forwardfire/vasc/lib/i18n/resources/TestBundle1_nl.properties +++ b/vasc-lib/vasc-lib-i18n/src/test/resources/net/forwardfire/vasc/lib/i18n/resources/TestBundle1_nl.properties @@ -1,4 +1,5 @@ # Test bundle +bundle.key = bundle1 bundle1.key1 = key1_nl bundle1.key2 = key2_nl bundle1.key3 = key3_nl diff --git a/vasc-lib/vasc-lib-i18n/src/test/resources/net/forwardfire/vasc/lib/i18n/resources/TestBundle2_en.properties b/vasc-lib/vasc-lib-i18n/src/test/resources/net/forwardfire/vasc/lib/i18n/resources/TestBundle2_en.properties index e5f317e..7debd5d 100644 --- a/vasc-lib/vasc-lib-i18n/src/test/resources/net/forwardfire/vasc/lib/i18n/resources/TestBundle2_en.properties +++ b/vasc-lib/vasc-lib-i18n/src/test/resources/net/forwardfire/vasc/lib/i18n/resources/TestBundle2_en.properties @@ -1,4 +1,5 @@ # Test bundle +bundle.key = bundle2 bundle2.key1 = key1_en bundle2.key2 = key2_en bundle2.key3 = key3_en diff --git a/vasc-lib/vasc-lib-i18n/src/test/resources/net/forwardfire/vasc/lib/i18n/resources/TestBundle2_nl.properties b/vasc-lib/vasc-lib-i18n/src/test/resources/net/forwardfire/vasc/lib/i18n/resources/TestBundle2_nl.properties index 0ab610d..64d028c 100644 --- a/vasc-lib/vasc-lib-i18n/src/test/resources/net/forwardfire/vasc/lib/i18n/resources/TestBundle2_nl.properties +++ b/vasc-lib/vasc-lib-i18n/src/test/resources/net/forwardfire/vasc/lib/i18n/resources/TestBundle2_nl.properties @@ -1,4 +1,5 @@ # Test bundle +bundle.key = bundle2 bundle2.key1 = key1_nl bundle2.key2 = key2_nl bundle2.key3 = key3_nl diff --git a/vasc-lib/vasc-lib-jr4o/pom.xml b/vasc-lib/vasc-lib-jr4o/pom.xml index 5c678ef..48e8a80 100644 --- a/vasc-lib/vasc-lib-jr4o/pom.xml +++ b/vasc-lib/vasc-lib-jr4o/pom.xml @@ -18,7 +18,7 @@ net.sf.jasperreports jasperreports - 4.5.1 + ${jasperreports.version} \ No newline at end of file diff --git a/vasc-test/vasc-test-frontend-data/pom.xml b/vasc-test/vasc-test-frontend-data/pom.xml index 55dbeed..44d8f1c 100644 --- a/vasc-test/vasc-test-frontend-data/pom.xml +++ b/vasc-test/vasc-test-frontend-data/pom.xml @@ -2,11 +2,14 @@ 4.0.0 vasc-test - net.forwardfire.vasc + net.forwardfire.vasc.test 0.3.5-SNAPSHOT .. vasc-test-frontend-data + jar + vasc-test-frontend-data + vasc-test-frontend-data net.forwardfire.vasc diff --git a/vasc-test/vasc-test-frontend-data/src/main/java/net/forwardfire/vasc/test/frontend/data/TestModelData.java b/vasc-test/vasc-test-frontend-data/src/main/java/net/forwardfire/vasc/test/frontend/data/TestModelData.java index 0c8ec45..f180ba4 100644 --- a/vasc-test/vasc-test-frontend-data/src/main/java/net/forwardfire/vasc/test/frontend/data/TestModelData.java +++ b/vasc-test/vasc-test-frontend-data/src/main/java/net/forwardfire/vasc/test/frontend/data/TestModelData.java @@ -27,8 +27,10 @@ import net.forwardfire.vasc.core.VascController; import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntryControllerLocal; import net.forwardfire.vasc.core.VascEntryField; +import net.forwardfire.vasc.core.VascEntryLocal; import net.forwardfire.vasc.impl.DefaultVascEntry; import net.forwardfire.vasc.impl.DefaultVascEntryField; +import net.forwardfire.vasc.impl.DefaultVascEntryListOption; import net.forwardfire.vasc.impl.DefaultVascFactory; /** @@ -40,7 +42,7 @@ import net.forwardfire.vasc.impl.DefaultVascFactory; public class TestModelData { public VascController getTestVascController() throws Exception { - VascController c = DefaultVascFactory.getDefaultVascController(1234L,"Nice UserName","user","role_admin"); + VascController c = DefaultVascFactory.getDefaultVascController(); // for test TestModelVascDataSource backends = new TestModelVascDataSource(); @@ -55,16 +57,16 @@ public class TestModelData { return c; } - public VascEntry getTestEntry(VascController vc) { - return vc.getVascEntryController().getVascEntryById("orderModel"); + public VascEntryLocal getTestEntry(VascController vc) { + return (VascEntryLocal)vc.getVascEntryController().getVascEntryById("orderModel"); } public void createVascEntries(VascController vc,VascEntryControllerLocal vecl) throws Exception { - VascEntry ve = new DefaultVascEntry(); + DefaultVascEntry ve = new DefaultVascEntry(); ve.setId("orderModel"); ve.setBackendId("orderModelBackend"); - VascEntryField field = new DefaultVascEntryField(); + DefaultVascEntryField field = new DefaultVascEntryField(); field.setId("name"); ve.addVascEntryField(field); @@ -93,13 +95,13 @@ public class TestModelData { ve.addVascEntryField(field); // table options - field = new DefaultVascEntryField(); - field.setId("active"); - field.setVascEntryFieldType(vc.getVascEntryFieldTypeController().getVascEntryFieldTypeById("BooleanField")); - field.setBackendName("active"); - field.setDefaultValue("true"); // obj does also work ! we are first need to fix string defaults. + DefaultVascEntryListOption option = new DefaultVascEntryListOption(); + option.setId("active"); + option.setVascEntryFieldType(vc.getVascEntryFieldTypeController().getVascEntryFieldTypeById("BooleanField")); + option.setBackendName("active"); + option.setDefaultValue("true"); // obj does also work ! we are first need to fix string defaults. - ve.addListOption(field); + ve.addVascEntryListOption(option); vecl.addVascEntry(ve); diff --git a/vasc-test/vasc-test-i18n/src/main/java/net/forwardfire/vasc/test/i18n/VascBundleCheckEntryKeys.java b/vasc-test/vasc-test-i18n/src/main/java/net/forwardfire/vasc/test/i18n/VascBundleCheckEntryKeys.java index 42c2da7..ad013af 100644 --- a/vasc-test/vasc-test-i18n/src/main/java/net/forwardfire/vasc/test/i18n/VascBundleCheckEntryKeys.java +++ b/vasc-test/vasc-test-i18n/src/main/java/net/forwardfire/vasc/test/i18n/VascBundleCheckEntryKeys.java @@ -32,7 +32,7 @@ import java.util.ResourceBundle; import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntryField; import net.forwardfire.vasc.core.VascEntryFieldSet; -import net.forwardfire.vasc.core.VascLinkEntry; +import net.forwardfire.vasc.core.VascEntryLink; import net.forwardfire.vasc.core.actions.VascAction; @@ -76,12 +76,12 @@ public class VascBundleCheckEntryKeys { keys.put(s.getDescription(), s.getId()); keys.put(s.getImage(), s.getId()); } - for (VascEntryField vef:ve.getListOptions()) { + for (VascEntryField vef:ve.getVascEntryListOptions()) { keys.put(vef.getName(), vef.getId()); keys.put(vef.getImage(), vef.getId()); keys.put(vef.getDescription(), vef.getId()); } - for (VascLinkEntry vef:ve.getVascLinkEntries()) { + for (VascEntryLink vef:ve.getVascEntryLinks()) { keys.put(vef.getName(), vef.getId()); } for (VascAction a:ve.getGlobalActions()) { diff --git a/vasc-xpql-ejb3-client/pom.xml b/vasc-xpql-ejb3-client/pom.xml index 5aae5ac..9d00352 100644 --- a/vasc-xpql-ejb3-client/pom.xml +++ b/vasc-xpql-ejb3-client/pom.xml @@ -18,7 +18,7 @@ javax.ejb ejb-api - 3.0 + ${ejb-api.version} provided diff --git a/vasc-xpql-ejb3-server/pom.xml b/vasc-xpql-ejb3-server/pom.xml index 5a6122f..f978891 100644 --- a/vasc-xpql-ejb3-server/pom.xml +++ b/vasc-xpql-ejb3-server/pom.xml @@ -19,19 +19,19 @@ javax.ejb ejb-api - 3.0 + ${ejb-api.version} provided javax.persistence persistence-api - 1.0 + ${persistence-api.version} provided javax.transaction jta - 1.1 + ${jta.version} provided diff --git a/vasc-xpql/pom.xml b/vasc-xpql/pom.xml index d6db436..17d2df4 100644 --- a/vasc-xpql/pom.xml +++ b/vasc-xpql/pom.xml @@ -20,7 +20,7 @@ javax.servlet.jsp jsp-api - 2.1 + ${jsp-api.version} provided