diff --git a/pom.xml b/pom.xml index 96a44f0..79c6171 100644 --- a/pom.xml +++ b/pom.xml @@ -4,75 +4,50 @@ 4.0.0 com.idcanet.vasc vasc-base -0.3-SNAPSHOT +0.3.1-SNAPSHOT pom vasc -Simple crud'ing for all. +Very Amazing/Advanced/Amplified Simple CRUD'ing for all. http://www.x4o.org/vasc +2007 IDCA http://www.idca.nl - Trac https://decaid.idca.nl/trac/oss/ + + + BSD + http://repository.idcanet.com/licenses/bsd.txt + + - scm:svn:https://decaid.idca.nl/svn/oss/com.idcanet.vasc/ - scm:svn:https://decaid.idca.nl/svn/oss/com.idcanet.vasc/ - https://decaid.idca.nl/svn/oss/com.idcanet.vasc/ + https://decaid.idca.nl/hg/com.idcanet.vasc/ + scm:hg:${hg.repo.url} + https://decaid.idca.nl/hg/com.idcanet.vasc/file/ - - - - willem.cazander - Willem Cazander - w.cazander@gmail.com - IDCA - +2 - - Project Manager - Architect - - - - sqrbass - Bas van Oostveen - - IDCA - +2 - - Architect Reviewer - - - - - - - jboss - JBoss Repository Switchboard - default - http://repository.jboss.com/maven2/ - true - false - - - ops4j-microba - ops4j.org - default - http://repository.ops4j.org/maven2/ - false - - - + + vasc-backend-jpa + vasc-backend-ldap + vasc-frontend-swing + vasc-frontend-swt + vasc-frontend-web-jsf + vasc-core + vasc-ejb3 + vasc-xpql + vasc-xpql-ejb3 + + https://decaid.idca.nl/hg/com.idcanet.vasc/ + file://${project.build.directory}/target-maven-repo UTF-8 2.1.0 5.8 - 0.8-SNAPSHOT + 0.8.1 4.3 - 0.6-SNAPSHOT @@ -196,36 +171,29 @@ - + + + org.apache.maven.plugins + maven-release-plugin + 2.1 + + clean install verify + + clean install javadoc:javadoc deploy + -Prelease -DaltDeploymentRepository="${altDeploymentRepository}" + + + + + + + org.apache.maven.plugins + maven-release-plugin + 2.1 + + + @@ -285,15 +253,205 @@ - - vasc-backend-jpa - vasc-backend-ldap - vasc-frontend-swing - vasc-frontend-swt - vasc-frontend-web-jsf - vasc-core - vasc-ejb3 - + + + + jboss + JBoss Repository Switchboard + default + http://repository.jboss.com/maven2/ + true + false + + + ops4j-microba + ops4j.org + default + http://repository.ops4j.org/maven2/ + false + + + + + + + releases + Internal Releases + http://localhost:8081/nexus/content/repositories/releases + + + snapshots + Internal Snapshots + http://localhost:8081/nexus/content/repositories/snapshots + + + + + + willem.cazander + Willem Cazander + w.cazander@gmail.com + IDCA + +2 + + Project Manager + Architect + + + + sqrbass + Bas van Oostveen + + IDCA + +2 + + Architect Reviewer + + + + + + + + release + + file://${project.build.directory}/dummy-hg-repo + release-repo-hudson::default::${staging.mvn.repo.url} + + + + + 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-jpa/pom.xml b/vasc-backend-jpa/pom.xml index e8952e5..45ba1f3 100644 --- a/vasc-backend-jpa/pom.xml +++ b/vasc-backend-jpa/pom.xml @@ -3,11 +3,11 @@ vasc-base com.idcanet.vasc - 0.3-SNAPSHOT + 0.3.1-SNAPSHOT com.idcanet.vasc vasc-backend-jpa - 0.3-SNAPSHOT + 0.3.1-SNAPSHOT com.idcanet.vasc diff --git a/vasc-backend-jpa/src/main/java/com/idcanet/vasc/backends/jpa/XpqlHibernateVascBackend.java b/vasc-backend-jpa/src/main/java/com/idcanet/vasc/backends/jpa/XpqlHibernateVascBackend.java index f241dac..0c81b86 100644 --- a/vasc-backend-jpa/src/main/java/com/idcanet/vasc/backends/jpa/XpqlHibernateVascBackend.java +++ b/vasc-backend-jpa/src/main/java/com/idcanet/vasc/backends/jpa/XpqlHibernateVascBackend.java @@ -40,7 +40,7 @@ import com.idcanet.vasc.core.VascEntryField; import com.idcanet.vasc.core.VascException; import com.idcanet.vasc.core.entry.VascEntryFieldValue; import com.idcanet.vasc.core.entry.VascEntryRecordCreator; -import com.idcanet.xtes.xpql.query.QueryParameterValue; +import com.idcanet.vasc.xpql.query.QueryParameterValue; /** * Manages persistance with xpql queries @@ -52,17 +52,17 @@ public class XpqlHibernateVascBackend extends AbstractHibernateVascBackend { private HibernateSessionProvider hibernateSessionProvider = null; - private com.idcanet.xtes.xpql.query.Query query = null; + private com.idcanet.vasc.xpql.query.Query query = null; - private com.idcanet.xtes.xpql.query.Query queryTotal = null; + private com.idcanet.vasc.xpql.query.Query queryTotal = null; - private com.idcanet.xtes.xpql.query.Query queryMoveUp = null; + private com.idcanet.vasc.xpql.query.Query queryMoveUp = null; - private com.idcanet.xtes.xpql.query.Query queryMoveUpDown = null; + private com.idcanet.vasc.xpql.query.Query queryMoveUpDown = null; - private com.idcanet.xtes.xpql.query.Query queryMoveDown = null; + private com.idcanet.vasc.xpql.query.Query queryMoveDown = null; - private com.idcanet.xtes.xpql.query.Query queryMoveDownUp = null; + private com.idcanet.vasc.xpql.query.Query queryMoveDownUp = null; private Class resultClass = null; @@ -136,28 +136,28 @@ public class XpqlHibernateVascBackend extends AbstractHibernateVascBackend { /** * @return the query */ - public com.idcanet.xtes.xpql.query.Query getQuery() { + public com.idcanet.vasc.xpql.query.Query getQuery() { return query; } /** * @param query the query to set */ - public void setQuery(com.idcanet.xtes.xpql.query.Query query) { + public void setQuery(com.idcanet.vasc.xpql.query.Query query) { this.query = query; } /** * @return the queryTotal */ - public com.idcanet.xtes.xpql.query.Query getQueryTotal() { + public com.idcanet.vasc.xpql.query.Query getQueryTotal() { return queryTotal; } /** * @param queryTotal the queryTotal to set */ - public void setQueryTotal(com.idcanet.xtes.xpql.query.Query queryTotal) { + public void setQueryTotal(com.idcanet.vasc.xpql.query.Query queryTotal) { this.queryTotal = queryTotal; } @@ -378,56 +378,56 @@ public class XpqlHibernateVascBackend extends AbstractHibernateVascBackend { /** * @return the queryMoveUp */ - public com.idcanet.xtes.xpql.query.Query getQueryMoveUp() { + public com.idcanet.vasc.xpql.query.Query getQueryMoveUp() { return queryMoveUp; } /** * @param queryMoveUp the queryMoveUp to set */ - public void setQueryMoveUp(com.idcanet.xtes.xpql.query.Query queryMoveUp) { + public void setQueryMoveUp(com.idcanet.vasc.xpql.query.Query queryMoveUp) { this.queryMoveUp = queryMoveUp; } /** * @return the queryMoveDown */ - public com.idcanet.xtes.xpql.query.Query getQueryMoveDown() { + public com.idcanet.vasc.xpql.query.Query getQueryMoveDown() { return queryMoveDown; } /** * @param queryMoveDown the queryMoveDown to set */ - public void setQueryMoveDown(com.idcanet.xtes.xpql.query.Query queryMoveDown) { + public void setQueryMoveDown(com.idcanet.vasc.xpql.query.Query queryMoveDown) { this.queryMoveDown = queryMoveDown; } /** * @return the queryMoveUpDown */ - public com.idcanet.xtes.xpql.query.Query getQueryMoveUpDown() { + public com.idcanet.vasc.xpql.query.Query getQueryMoveUpDown() { return queryMoveUpDown; } /** * @param queryMoveUpDown the queryMoveUpDown to set */ - public void setQueryMoveUpDown(com.idcanet.xtes.xpql.query.Query queryMoveUpDown) { + public void setQueryMoveUpDown(com.idcanet.vasc.xpql.query.Query queryMoveUpDown) { this.queryMoveUpDown = queryMoveUpDown; } /** * @return the queryMoveDownUp */ - public com.idcanet.xtes.xpql.query.Query getQueryMoveDownUp() { + public com.idcanet.vasc.xpql.query.Query getQueryMoveDownUp() { return queryMoveDownUp; } /** * @param queryMoveDownUp the queryMoveDownUp to set */ - public void setQueryMoveDownUp(com.idcanet.xtes.xpql.query.Query queryMoveDownUp) { + public void setQueryMoveDownUp(com.idcanet.vasc.xpql.query.Query queryMoveDownUp) { this.queryMoveDownUp = queryMoveDownUp; } } \ No newline at end of file diff --git a/vasc-backend-jpa/src/main/java/com/idcanet/vasc/backends/jpa/XpqlPersistanceVascBackend.java b/vasc-backend-jpa/src/main/java/com/idcanet/vasc/backends/jpa/XpqlPersistanceVascBackend.java index 94497c8..159b8d8 100644 --- a/vasc-backend-jpa/src/main/java/com/idcanet/vasc/backends/jpa/XpqlPersistanceVascBackend.java +++ b/vasc-backend-jpa/src/main/java/com/idcanet/vasc/backends/jpa/XpqlPersistanceVascBackend.java @@ -39,7 +39,7 @@ import com.idcanet.vasc.core.VascEntryField; import com.idcanet.vasc.core.VascException; import com.idcanet.vasc.core.entry.VascEntryFieldValue; import com.idcanet.vasc.core.entry.VascEntryRecordCreator; -import com.idcanet.xtes.xpql.query.QueryParameterValue; +import com.idcanet.vasc.xpql.query.QueryParameterValue; /** * Manages persistance with xpql queries @@ -51,17 +51,17 @@ public class XpqlPersistanceVascBackend extends AbstractPersistenceVascBackend private EntityManagerProvider entityManagerProvider = null; - private com.idcanet.xtes.xpql.query.Query query = null; + private com.idcanet.vasc.xpql.query.Query query = null; - private com.idcanet.xtes.xpql.query.Query queryTotal = null; + private com.idcanet.vasc.xpql.query.Query queryTotal = null; - private com.idcanet.xtes.xpql.query.Query queryMoveUp = null; + private com.idcanet.vasc.xpql.query.Query queryMoveUp = null; - private com.idcanet.xtes.xpql.query.Query queryMoveUpDown = null; + private com.idcanet.vasc.xpql.query.Query queryMoveUpDown = null; - private com.idcanet.xtes.xpql.query.Query queryMoveDown = null; + private com.idcanet.vasc.xpql.query.Query queryMoveDown = null; - private com.idcanet.xtes.xpql.query.Query queryMoveDownUp = null; + private com.idcanet.vasc.xpql.query.Query queryMoveDownUp = null; private Class resultClass = null; @@ -141,28 +141,28 @@ public class XpqlPersistanceVascBackend extends AbstractPersistenceVascBackend /** * @return the query */ - public com.idcanet.xtes.xpql.query.Query getQuery() { + public com.idcanet.vasc.xpql.query.Query getQuery() { return query; } /** * @param query the query to set */ - public void setQuery(com.idcanet.xtes.xpql.query.Query query) { + public void setQuery(com.idcanet.vasc.xpql.query.Query query) { this.query = query; } /** * @return the queryTotal */ - public com.idcanet.xtes.xpql.query.Query getQueryTotal() { + public com.idcanet.vasc.xpql.query.Query getQueryTotal() { return queryTotal; } /** * @param queryTotal the queryTotal to set */ - public void setQueryTotal(com.idcanet.xtes.xpql.query.Query queryTotal) { + public void setQueryTotal(com.idcanet.vasc.xpql.query.Query queryTotal) { this.queryTotal = queryTotal; } @@ -371,56 +371,56 @@ public class XpqlPersistanceVascBackend extends AbstractPersistenceVascBackend /** * @return the queryMoveUp */ - public com.idcanet.xtes.xpql.query.Query getQueryMoveUp() { + public com.idcanet.vasc.xpql.query.Query getQueryMoveUp() { return queryMoveUp; } /** * @param queryMoveUp the queryMoveUp to set */ - public void setQueryMoveUp(com.idcanet.xtes.xpql.query.Query queryMoveUp) { + public void setQueryMoveUp(com.idcanet.vasc.xpql.query.Query queryMoveUp) { this.queryMoveUp = queryMoveUp; } /** * @return the queryMoveDown */ - public com.idcanet.xtes.xpql.query.Query getQueryMoveDown() { + public com.idcanet.vasc.xpql.query.Query getQueryMoveDown() { return queryMoveDown; } /** * @param queryMoveDown the queryMoveDown to set */ - public void setQueryMoveDown(com.idcanet.xtes.xpql.query.Query queryMoveDown) { + public void setQueryMoveDown(com.idcanet.vasc.xpql.query.Query queryMoveDown) { this.queryMoveDown = queryMoveDown; } /** * @return the queryMoveUpDown */ - public com.idcanet.xtes.xpql.query.Query getQueryMoveUpDown() { + public com.idcanet.vasc.xpql.query.Query getQueryMoveUpDown() { return queryMoveUpDown; } /** * @param queryMoveUpDown the queryMoveUpDown to set */ - public void setQueryMoveUpDown(com.idcanet.xtes.xpql.query.Query queryMoveUpDown) { + public void setQueryMoveUpDown(com.idcanet.vasc.xpql.query.Query queryMoveUpDown) { this.queryMoveUpDown = queryMoveUpDown; } /** * @return the queryMoveDownUp */ - public com.idcanet.xtes.xpql.query.Query getQueryMoveDownUp() { + public com.idcanet.vasc.xpql.query.Query getQueryMoveDownUp() { return queryMoveDownUp; } /** * @param queryMoveDownUp the queryMoveDownUp to set */ - public void setQueryMoveDownUp(com.idcanet.xtes.xpql.query.Query queryMoveDownUp) { + public void setQueryMoveDownUp(com.idcanet.vasc.xpql.query.Query queryMoveDownUp) { this.queryMoveDownUp = queryMoveDownUp; } diff --git a/vasc-backend-ldap/pom.xml b/vasc-backend-ldap/pom.xml index 9c963ae..324fbbb 100644 --- a/vasc-backend-ldap/pom.xml +++ b/vasc-backend-ldap/pom.xml @@ -3,11 +3,11 @@ vasc-base com.idcanet.vasc - 0.3-SNAPSHOT + 0.3.1-SNAPSHOT com.idcanet.vasc vasc-backend-ldap - 0.3-SNAPSHOT + 0.3.1-SNAPSHOT diff --git a/vasc-core/pom.xml b/vasc-core/pom.xml index 23913af..fc6aa27 100644 --- a/vasc-core/pom.xml +++ b/vasc-core/pom.xml @@ -3,21 +3,21 @@ vasc-base com.idcanet.vasc - 0.3-SNAPSHOT + 0.3.1-SNAPSHOT com.idcanet.vasc vasc-core - 0.3-SNAPSHOT + 0.3.1-SNAPSHOT com.idcanet.x4o x4o-core ${x4o-core.version} - - com.idcanet.xtes - xtes-xpql - ${xtes-xpql.version} + + com.idcanet.vasc + vasc-xpql + ${project.version} javax.persistence diff --git a/vasc-core/src/main/java/com/idcanet/vasc/backends/jdbc/JdbcXpqlVascBackend.java b/vasc-core/src/main/java/com/idcanet/vasc/backends/jdbc/JdbcXpqlVascBackend.java index 4815af7..3aa0e53 100644 --- a/vasc-core/src/main/java/com/idcanet/vasc/backends/jdbc/JdbcXpqlVascBackend.java +++ b/vasc-core/src/main/java/com/idcanet/vasc/backends/jdbc/JdbcXpqlVascBackend.java @@ -43,7 +43,7 @@ import com.idcanet.vasc.core.VascEntryField; import com.idcanet.vasc.core.VascException; import com.idcanet.vasc.core.entry.VascEntryFieldValue; import com.idcanet.vasc.core.entry.VascEntryRecordCreator; -import com.idcanet.xtes.xpql.query.QueryParameterValue; +import com.idcanet.vasc.xpql.query.QueryParameterValue; /** * @@ -54,7 +54,7 @@ public class JdbcXpqlVascBackend extends AbstractVascBackend { private JdbcConnectionProvider jdbcConnectionProvider = null; - private com.idcanet.xtes.xpql.query.Query query = null; + private com.idcanet.vasc.xpql.query.Query query = null; /** * @return the JdbcConnectionProvider @@ -73,14 +73,14 @@ public class JdbcXpqlVascBackend extends AbstractVascBackend { /** * @return the query */ - public com.idcanet.xtes.xpql.query.Query getQuery() { + public com.idcanet.vasc.xpql.query.Query getQuery() { return query; } /** * @param query the query to set */ - public void setQuery(com.idcanet.xtes.xpql.query.Query query) { + public void setQuery(com.idcanet.vasc.xpql.query.Query query) { this.query = query; } diff --git a/vasc-core/src/main/java/com/idcanet/vasc/impl/DefaultVascFactory.java b/vasc-core/src/main/java/com/idcanet/vasc/impl/DefaultVascFactory.java index 5d05d1a..78a451d 100644 --- a/vasc-core/src/main/java/com/idcanet/vasc/impl/DefaultVascFactory.java +++ b/vasc-core/src/main/java/com/idcanet/vasc/impl/DefaultVascFactory.java @@ -35,7 +35,6 @@ import com.idcanet.vasc.core.VascController; import com.idcanet.vasc.core.VascEntry; import com.idcanet.vasc.core.VascException; import com.idcanet.vasc.core.VascFrontendData; -import com.idcanet.vasc.core.entry.VascEntryFrontendEventListener; import com.idcanet.vasc.impl.entry.DefaultVascEntryResourceResolver; import com.idcanet.vasc.impl.entry.VascValidatorsValidatorService; import com.idcanet.vasc.impl.type.DefaultVascEntryFieldTypeController; diff --git a/vasc-ejb3/pom.xml b/vasc-ejb3/pom.xml index 97742b6..3ea2d47 100644 --- a/vasc-ejb3/pom.xml +++ b/vasc-ejb3/pom.xml @@ -3,11 +3,11 @@ vasc-base com.idcanet.vasc - 0.3-SNAPSHOT + 0.3.1-SNAPSHOT com.idcanet.vasc vasc-ejb3 - 0.3-SNAPSHOT + 0.3.1-SNAPSHOT com.idcanet.vasc @@ -32,9 +32,9 @@ provided - com.idcanet.xtes - xtes-xpql-ejb3 - 0.6-SNAPSHOT + com.idcanet.vasc + vasc-xpql-ejb3 + ${project.version} provided diff --git a/vasc-ejb3/src/main/java/com/idcanet/vasc/ejb3/VascServiceManagerImpl.java b/vasc-ejb3/src/main/java/com/idcanet/vasc/ejb3/VascServiceManagerImpl.java index 3611a60..79f5251 100644 --- a/vasc-ejb3/src/main/java/com/idcanet/vasc/ejb3/VascServiceManagerImpl.java +++ b/vasc-ejb3/src/main/java/com/idcanet/vasc/ejb3/VascServiceManagerImpl.java @@ -52,6 +52,7 @@ import com.idcanet.vasc.core.VascBackend; import com.idcanet.vasc.core.VascBackendControllerLocal; import com.idcanet.vasc.core.VascController; import com.idcanet.vasc.core.VascEntry; + import com.idcanet.vasc.impl.DefaultVascBackedEntryFinalizer; import com.idcanet.vasc.impl.DefaultVascEntryController; import com.idcanet.vasc.impl.DefaultVascFactory; @@ -63,14 +64,16 @@ import com.idcanet.vasc.impl.actions.EditRowAction; import com.idcanet.vasc.impl.actions.XMLExportGlobalAction; import com.idcanet.vasc.impl.entry.DefaultVascEntryResourceResolver; import com.idcanet.vasc.impl.x4o.VascParser; + +import com.idcanet.vasc.xpql.ejb3.XpqlQueryManager; +import com.idcanet.vasc.xpql.query.Query; + import com.idcanet.x4o.core.AbstractX4OPhaseHandler; import com.idcanet.x4o.core.X4OPhase; import com.idcanet.x4o.core.X4OPhaseException; import com.idcanet.x4o.core.X4OPhaseHandler; import com.idcanet.x4o.element.Element; import com.idcanet.x4o.element.ElementContext; -import com.idcanet.xtes.xpql.ejb3.XpqlQueryManager; -import com.idcanet.xtes.xpql.query.Query; /** * diff --git a/vasc-frontend-swing/pom.xml b/vasc-frontend-swing/pom.xml index 26fd8bd..3c193ef 100644 --- a/vasc-frontend-swing/pom.xml +++ b/vasc-frontend-swing/pom.xml @@ -3,11 +3,11 @@ vasc-base com.idcanet.vasc - 0.3-SNAPSHOT + 0.3.1-SNAPSHOT com.idcanet.vasc vasc-frontend-swing - 0.3-SNAPSHOT + 0.3.1-SNAPSHOT com.idcanet.vasc diff --git a/vasc-frontend-swt/pom.xml b/vasc-frontend-swt/pom.xml index 8be7d9c..c442aea 100644 --- a/vasc-frontend-swt/pom.xml +++ b/vasc-frontend-swt/pom.xml @@ -3,11 +3,11 @@ vasc-base com.idcanet.vasc - 0.3-SNAPSHOT + 0.3.1-SNAPSHOT com.idcanet.vasc vasc-frontend-swt - 0.3-SNAPSHOT + 0.3.1-SNAPSHOT com.idcanet.vasc diff --git a/vasc-frontend-web-jsf/pom.xml b/vasc-frontend-web-jsf/pom.xml index b8769b2..5d6d3de 100644 --- a/vasc-frontend-web-jsf/pom.xml +++ b/vasc-frontend-web-jsf/pom.xml @@ -3,11 +3,11 @@ vasc-base com.idcanet.vasc - 0.3-SNAPSHOT + 0.3.1-SNAPSHOT com.idcanet.vasc vasc-frontend-web-jsf - 0.3-SNAPSHOT + 0.3.1-SNAPSHOT com.idcanet.vasc diff --git a/vasc-frontend-web-jsf/src/main/java/com/idcanet/vasc/frontends/web/jsf/AbstractJSFVascFacesController.java b/vasc-frontend-web-jsf/src/main/java/com/idcanet/vasc/frontends/web/jsf/AbstractJSFVascFacesController.java index f252891..9124ef1 100644 --- a/vasc-frontend-web-jsf/src/main/java/com/idcanet/vasc/frontends/web/jsf/AbstractJSFVascFacesController.java +++ b/vasc-frontend-web-jsf/src/main/java/com/idcanet/vasc/frontends/web/jsf/AbstractJSFVascFacesController.java @@ -57,7 +57,6 @@ import com.idcanet.vasc.core.entry.VascEntryFrontendEventListener; import com.idcanet.vasc.core.entry.VascEntryRecordCreator; import com.idcanet.vasc.ejb3.VascServiceManager; import com.idcanet.vasc.impl.DefaultVascBackedEntryFinalizer; -import com.idcanet.vasc.impl.DefaultVascEntryState; import com.idcanet.vasc.impl.DefaultVascFactory; import com.idcanet.vasc.impl.VascBackendProxyEventExecutor; import com.idcanet.vasc.impl.entry.DefaultVascEntryResourceResolver; @@ -183,6 +182,24 @@ abstract public class AbstractJSFVascFacesController { entry.getVascFrontendData().getVascEntryState().setVascBackend(backend); entry.getVascFrontendData().getVascEntryState().setVascEntry(entry); + // set def para + VascBackendState state = entry.getVascFrontendData().getVascEntryState().getVascBackendState(); + for (String key2:entry.getEntryParameterKeys()) { + Object value = entry.getEntryParameter(key2); + //System.out.println("Copy paras name: "+key2+" value: "+value+" class: "+value.getClass().getName()); + state.setDataParameter(key2, value); + } + + // set list para + for (VascEntryField vef:entry.getListOptions()) { + Object def = vef.getDefaultValue(); + if (def==null) { + continue; + } + String backendName = vef.getBackendName(); + state.setDataParameter(backendName, def); + } + // copy para if (para!=null) { for (String key:para.keySet()) { @@ -409,7 +426,7 @@ abstract public class AbstractJSFVascFacesController { SetParameterBackendListener listener = new SetParameterBackendListener(vui.userId,vui.username); listener.setName(key); listener.setType(type); - // listener.setValue(paraTypeValue); + listener.setValue(paraTypeValue); List listeners=new ArrayList(10); listeners.add(listener); diff --git a/vasc-frontend-web-jsf/src/main/java/com/idcanet/vasc/frontends/web/jsf/JSFVascUIComponent.java b/vasc-frontend-web-jsf/src/main/java/com/idcanet/vasc/frontends/web/jsf/JSFVascUIComponent.java index cb08923..f054ca1 100644 --- a/vasc-frontend-web-jsf/src/main/java/com/idcanet/vasc/frontends/web/jsf/JSFVascUIComponent.java +++ b/vasc-frontend-web-jsf/src/main/java/com/idcanet/vasc/frontends/web/jsf/JSFVascUIComponent.java @@ -53,7 +53,7 @@ import com.idcanet.vasc.impl.DefaultVascFactory; /** * Renders an JSF vasc entry views. * - * This is a bit hacky because I'm not a JSF guro. + * This is a already less hacky this is second incarnation of this bean * * @author Willem Cazander * @version 1.0 Nov 16, 2008 diff --git a/vasc-xpql-ejb3/.classpath b/vasc-xpql-ejb3/.classpath new file mode 100644 index 0000000..f42fb64 --- /dev/null +++ b/vasc-xpql-ejb3/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/vasc-xpql-ejb3/.project b/vasc-xpql-ejb3/.project new file mode 100644 index 0000000..0a4e861 --- /dev/null +++ b/vasc-xpql-ejb3/.project @@ -0,0 +1,23 @@ + + + vasc-xpql-ejb3 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.maven.ide.eclipse.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.maven.ide.eclipse.maven2Nature + + diff --git a/vasc-xpql-ejb3/.settings/org.eclipse.jdt.core.prefs b/vasc-xpql-ejb3/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..1c947e9 --- /dev/null +++ b/vasc-xpql-ejb3/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,6 @@ +#Mon Jan 10 02:21:44 CET 2011 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/vasc-xpql-ejb3/.settings/org.maven.ide.eclipse.prefs b/vasc-xpql-ejb3/.settings/org.maven.ide.eclipse.prefs new file mode 100644 index 0000000..0e483ca --- /dev/null +++ b/vasc-xpql-ejb3/.settings/org.maven.ide.eclipse.prefs @@ -0,0 +1,9 @@ +#Mon Jan 10 02:21:43 CET 2011 +activeProfiles= +eclipse.preferences.version=1 +fullBuildGoals=process-test-resources +includeModules=false +resolveWorkspaceProjects=true +resourceFilterGoals=process-resources resources\:testResources +skipCompilerPlugin=true +version=1 diff --git a/vasc-xpql-ejb3/pom.xml b/vasc-xpql-ejb3/pom.xml new file mode 100644 index 0000000..c5ac947 --- /dev/null +++ b/vasc-xpql-ejb3/pom.xml @@ -0,0 +1,38 @@ + + 4.0.0 + + vasc-base + com.idcanet.vasc + 0.3.1-SNAPSHOT + + com.idcanet.vasc + vasc-xpql-ejb3 + 0.3.1-SNAPSHOT + vasc-xpql-ejb3 + xpql parsing service for ejb3 + + + com.idcanet.vasc + vasc-xpql + 0.3.1-SNAPSHOT + + + javax.ejb + ejb-api + 3.0 + provided + + + javax.persistence + persistence-api + 1.0 + provided + + + org.hibernate + hibernate-annotations + 3.4.0.GA + provided + + + \ No newline at end of file diff --git a/vasc-xpql-ejb3/src/main/java/com/idcanet/vasc/xpql/ejb3/XpqlQueryManager.java b/vasc-xpql-ejb3/src/main/java/com/idcanet/vasc/xpql/ejb3/XpqlQueryManager.java new file mode 100644 index 0000000..20cccab --- /dev/null +++ b/vasc-xpql-ejb3/src/main/java/com/idcanet/vasc/xpql/ejb3/XpqlQueryManager.java @@ -0,0 +1,40 @@ + +package com.idcanet.vasc.xpql.ejb3; + +import java.util.List; +import java.util.Map; + +import javax.ejb.Local; +import javax.ejb.Remote; + +import com.idcanet.vasc.xpql.query.Query; + +/** + * + * @author Willem Cazander + * @version 1.0 17 Sep 2010 + */ +public interface XpqlQueryManager { + + public Query getQuery(String name); + + public List execute(Query query); + + public Object executeObject(Query query); + + public Integer executeUpdate(Query query); + + public List execute(String query,Map parameters); + + public Object executeObject(String query,Map parameters); + + public Integer executeUpdate(String query,Map parameters); + + @Local + public interface ILocal extends XpqlQueryManager { + } + + @Remote + public interface IRemote extends XpqlQueryManager { + } +} diff --git a/vasc-xpql-ejb3/src/main/java/com/idcanet/vasc/xpql/ejb3/XpqlQueryManagerImpl.java b/vasc-xpql-ejb3/src/main/java/com/idcanet/vasc/xpql/ejb3/XpqlQueryManagerImpl.java new file mode 100644 index 0000000..8dc8d30 --- /dev/null +++ b/vasc-xpql-ejb3/src/main/java/com/idcanet/vasc/xpql/ejb3/XpqlQueryManagerImpl.java @@ -0,0 +1,321 @@ + +package com.idcanet.vasc.xpql.ejb3; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.logging.Logger; + +import javax.annotation.PostConstruct; +import javax.annotation.Resource; +import javax.ejb.Stateless; +import javax.ejb.TransactionManagement; +import javax.ejb.TransactionManagementType; +import javax.naming.InitialContext; +import javax.persistence.EntityManager; +import javax.transaction.UserTransaction; + +import com.idcanet.vasc.xpql.QueryStore; +import com.idcanet.vasc.xpql.XPQLParser; +import com.idcanet.vasc.xpql.query.Query; +import com.idcanet.vasc.xpql.query.QueryParameterValue; + +/** + * + * @author Willem Cazander + * @version 1.0 16 Jul 2007 + */ +@Stateless(name="ejb/xpqlQueryManager") +@TransactionManagement(TransactionManagementType.BEAN) +public class XpqlQueryManagerImpl implements XpqlQueryManager.ILocal,XpqlQueryManager.IRemote { + + private static final Logger logger = Logger.getLogger(XpqlQueryManagerImpl.class.getName()); + + private EntityManager entityManager; + + @Resource + private UserTransaction utx; + + private Map queries = new HashMap(100); + + @PostConstruct + public void loadAll() { + logger.fine("XtesManager created now loading resources..."); + try { + long s = System.currentTimeMillis(); + + Map keys = loadKeys(); + for (String key:keys.keySet()) { + String value = keys.get(key); + if (key.startsWith("load")) { + loadResource(value); + } + if ("persistenceUnit".equals(key)) { + logger.fine("getting EntityManager: "+value); + entityManager = (EntityManager)new InitialContext().lookup(value); + } + } + long t = System.currentTimeMillis()-s; + logger.info("Total loaded xpql queries: "+queries.size()+" in "+t+" ms."); + } catch (Exception e) { + throw new RuntimeException("Error while load xpql resources error: "+e.getMessage(),e); + } + } + + /** + * Loads xtes-xpql-ejb3.xml from meta-inf and gives the keys + */ + protected Map loadKeys() throws IOException { + + Properties properties = new Properties(); + + logger.fine("Getting urls"); + Enumeration e = Thread.currentThread().getContextClassLoader().getResources("META-INF/xtes-xpql-ejb3.xml"); + while(e.hasMoreElements()) { + URL u = e.nextElement(); + logger.finer("Loading reletive namespaces of: "+u+" for: META-INF/xtes-xpql-ejb3.xml"); + InputStream in = u.openStream(); + try { + properties.loadFromXML(in); + } finally { + if (in!=null) { + in.close(); + } + } + } + + + e = Thread.currentThread().getContextClassLoader().getResources("/META-INF/xtes-xpql-ejb3.xml"); + while(e.hasMoreElements()) { + URL u = e.nextElement(); + logger.finer("Loading root namespaces of: "+u+" for: /META-INF/xtes-xpql-ejb3.xml"); + InputStream in = u.openStream(); + try { + properties.loadFromXML(in); + } finally { + if (in!=null) { + in.close(); + } + } + } + logger.fine("done loading"); + + Map result = new HashMap(20); + for (Object key:properties.keySet()) { + if (key instanceof String) { + String key2 = (String) key; + String value = properties.getProperty(key2); + result.put(key2, value); + } + } + return result; + } + + + private void loadResource(String resource) { + XPQLParser parser = new XPQLParser(); + logger.fine("Try loading: "+resource); + try { + parser.parseResource(resource); + } catch (Exception e) { + throw new RuntimeException("Could not load xpql resource: "+resource+" error: "+e.getMessage(),e); + } + QueryStore store = parser.getQueryStore(); + + for (String key:store.getQueryNames()) { + Query q = store.getQuery(key); + + queries.put(q.getName(),q); + + String out = "\n\n=========== SQL: "+q.getName()+"\n"; + //out +=q.toSQL(q); + out +="=========== XML: "+q.getName()+"\n"; + out +=q.toXML(q); + //out +="=========== Edit: "+q.getName()+"\n"; + //out +=q.toEdit(q); + out +="=========== Prepard: "+q.getName()+"\n"; + out +=q.toPreparedSQL(q)+"\n"; + logger.finer("FOUND Query: "+out); + } + } + + public Query getQuery(String name) { + Query q = queries.get(name); + return q; + } + + @SuppressWarnings("unchecked") + public List execute(Query query) { + String sql = query.toPreparedSQL(query); + logger.finer("Executing: "+query.getName()+" sql: "+sql); + javax.persistence.Query q2 = null; + if (Query.QueryType.hql==query.getType()) { + q2 = entityManager.createQuery(sql); + } + if (Query.QueryType.sql==query.getType()) { + q2 = entityManager.createNativeQuery(sql); + } + + // TODO: move this hack to xtest xpql + if (query.getProperty("limit")!=null) { + int max = new Integer(query.getPropertyString("limit")); + q2.setMaxResults(max); + } + if (query.getProperty("offset")!=null) { + int offset = new Integer(query.getPropertyString("offset")); + q2.setFirstResult(offset); + } + + + List options = query.getOrderQueryParameterValues(); + int i=1; + for ( QueryParameterValue value : options ) { + Object para = value.getValue(); + if(para==null) { + para = value.getDefaultValue(); + } + logger.finest( "nr: " + i + " value: " + para+" name: "+value.getName()); + q2.setParameter(i,para); + i++; + } + return q2.getResultList(); + } + + @SuppressWarnings("unchecked") + public Object executeObject(Query query) { + String sql = query.toPreparedSQL(query); + logger.finer("Executing: "+query.getName()+" sql: "+sql); + javax.persistence.Query q2 = null; + if (Query.QueryType.hql==query.getType()) { + q2 = entityManager.createQuery(sql); + } + if (Query.QueryType.sql==query.getType()) { + q2 = entityManager.createNativeQuery(sql); + } + + + // TODO: move this hack to xtest xpql + if (query.getProperty("limit")!=null) { + int max = new Integer(query.getPropertyString("limit")); + q2.setMaxResults(max); + } + if (query.getProperty("offset")!=null) { + int offset = new Integer(query.getPropertyString("offset")); + q2.setFirstResult(offset); + } + + List options = query.getOrderQueryParameterValues(); + int i=1; + for ( QueryParameterValue value : options ) { + Object para = value.getValue(); + if(para==null) { + para = value.getDefaultValue(); + } + logger.finest( "nr: " + i + " value: " + para+" name: "+value.getName()); + q2.setParameter(i,para); + i++; + } + try { + utx.begin(); + Object result = null; + try { + result = q2.getSingleResult(); + utx.commit(); + } finally { + if (result==null) { + utx.rollback(); + } + } + return result; + } catch (Exception se) { + throw new RuntimeException("Transaction error: "+se.getMessage(),se); + } + } + + public List execute(String name,Map parameters) { + Query query = getQuery(name); + if (parameters!=null) { + for (String key:parameters.keySet()) { + Object value = parameters.get(key); + query.setQueryParameter(key, value); + } + } + return execute(query); + } + + public Object executeObject(String name,Map parameters) { + Query query = getQuery(name); + if (parameters!=null) { + for (String key:parameters.keySet()) { + Object value = parameters.get(key); + query.setQueryParameter(key, value); + } + } + return executeObject(query); + } + + public Integer executeUpdate(Query query) { + String sql = query.toPreparedSQL(query); + logger.fine("Executing: "+query.getName()+" sql: "+sql); + try { + javax.persistence.Query q2 = null; + if (Query.QueryType.hql==query.getType()) { + q2 = entityManager.createQuery(sql); + List options = query.getOrderQueryParameterValues(); + int i=1; + for ( QueryParameterValue value : options ) { + Object para = value.getValue(); + if(para==null) { + para = value.getDefaultValue(); + } + logger.finest( "nr: " + i + " value: " + para+" name: "+value.getName()); + q2.setParameter(i,para); + i++; + } + utx.begin(); + Integer result = q2.executeUpdate(); + utx.commit(); + return result; + } + + if (Query.QueryType.sql==query.getType()) { + q2 = entityManager.createNativeQuery(sql); + List options = query.getOrderQueryParameterValues(); + int i=1; + for ( QueryParameterValue value : options ) { + Object para = value.getValue(); + if(para==null) { + para = value.getDefaultValue(); + } + logger.finest( "nr: " + i + " value: " + para+" name: "+value.getName()); + q2.setParameter(i,para); + i++; + } + utx.begin(); + Integer result = q2.executeUpdate(); + utx.commit(); + return result; + } + } catch (Exception se) { + throw new RuntimeException("Transaction error: "+se.getMessage(),se); + } + throw new IllegalStateException("unknow query type"); + } + + /** + * @see com.idcanet.showplanner.ejb.services.XtesManagerLocal#executeUpdate(java.lang.String, java.lang.String, java.util.Map) + */ + public Integer executeUpdate(String name,Map parameters) { + Query query = getQuery(name); + for (String key:parameters.keySet()) { + Object value = parameters.get(key); + query.setQueryParameter(key, value); + } + return executeUpdate(query); + } +} diff --git a/vasc-xpql-ejb3/src/main/resources/.empty b/vasc-xpql-ejb3/src/main/resources/.empty new file mode 100644 index 0000000..e69de29 diff --git a/vasc-xpql-ejb3/src/test/java/.empty b/vasc-xpql-ejb3/src/test/java/.empty new file mode 100644 index 0000000..e69de29 diff --git a/vasc-xpql-ejb3/src/test/resources/.empty b/vasc-xpql-ejb3/src/test/resources/.empty new file mode 100644 index 0000000..e69de29 diff --git a/vasc-xpql/.classpath b/vasc-xpql/.classpath new file mode 100644 index 0000000..f42fb64 --- /dev/null +++ b/vasc-xpql/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/vasc-xpql/.project b/vasc-xpql/.project new file mode 100644 index 0000000..d850219 --- /dev/null +++ b/vasc-xpql/.project @@ -0,0 +1,23 @@ + + + vasc-xpql + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.maven.ide.eclipse.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.maven.ide.eclipse.maven2Nature + + diff --git a/vasc-xpql/.settings/org.eclipse.jdt.core.prefs b/vasc-xpql/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..0c22575 --- /dev/null +++ b/vasc-xpql/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,6 @@ +#Mon Jan 10 02:20:38 CET 2011 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/vasc-xpql/.settings/org.maven.ide.eclipse.prefs b/vasc-xpql/.settings/org.maven.ide.eclipse.prefs new file mode 100644 index 0000000..6e28e06 --- /dev/null +++ b/vasc-xpql/.settings/org.maven.ide.eclipse.prefs @@ -0,0 +1,9 @@ +#Mon Jan 10 02:20:38 CET 2011 +activeProfiles= +eclipse.preferences.version=1 +fullBuildGoals=process-test-resources +includeModules=false +resolveWorkspaceProjects=true +resourceFilterGoals=process-resources resources\:testResources +skipCompilerPlugin=true +version=1 diff --git a/vasc-xpql/pom.xml b/vasc-xpql/pom.xml new file mode 100644 index 0000000..31d262e --- /dev/null +++ b/vasc-xpql/pom.xml @@ -0,0 +1,36 @@ + + 4.0.0 + + vasc-base + com.idcanet.vasc + 0.3.1-SNAPSHOT + + com.idcanet.vasc + vasc-xpql + 0.3.1-SNAPSHOT + vasc-xpql + vasc xpql parser for queries. + + + com.idcanet.x4o + x4o-core + ${x4o-core.version} + + + + javax.servlet.jsp + jsp-api + 2.1 + provided + + + + \ No newline at end of file diff --git a/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/QueryStore.java b/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/QueryStore.java new file mode 100644 index 0000000..3ea4c58 --- /dev/null +++ b/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/QueryStore.java @@ -0,0 +1,65 @@ +/* + * Copyright 2004-2010 IDCA. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the + * following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and + * the following disclaimer. + * 2. 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 IDCA 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 IDCA 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. + * + * The views and conclusions contained in the software and documentation are those of the authors and + * should not be interpreted as representing official policies, either expressed or implied, of IDCA. + */ + +package com.idcanet.vasc.xpql; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import com.idcanet.vasc.xpql.query.Query; + +/** + * Holds all the queries. + * + * @author Willem Cazander + * @version 1.0 Aug 30, 2010 + */ +public class QueryStore { + + private Map queryMap = new HashMap(100); + + public void addQuery(Query query) { + if (query==null) { + throw new NullPointerException("Can't add null query."); + } + if (query.getName()==null) { + throw new NullPointerException("Can't add query with null name."); + } + if (query.getName().isEmpty()) { + throw new IllegalArgumentException("Can't add query with empty name."); + } + queryMap.put(query.getName(),query); + } + + public Query getQuery(String name) { + return queryMap.get(name); + } + + public Set getQueryNames() { + return queryMap.keySet(); + } +} \ No newline at end of file diff --git a/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/XPQLParser.java b/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/XPQLParser.java new file mode 100644 index 0000000..63e244a --- /dev/null +++ b/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/XPQLParser.java @@ -0,0 +1,71 @@ +/* + * Copyright 2004-2010 IDCA. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the + * following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and + * the following disclaimer. + * 2. 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 IDCA 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 IDCA 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. + * + * The views and conclusions contained in the software and documentation are those of the authors and + * should not be interpreted as representing official policies, either expressed or implied, of IDCA. + */ + +package com.idcanet.vasc.xpql; + +import javax.el.ValueExpression; + +import com.idcanet.x4o.core.X4OParser; +import com.idcanet.x4o.element.ElementContext; + +/** + * Parse an xpql file/resource + * + * @author Willem Cazander + * @version 1.0 Aug 29, 2010 + */ +public class XPQLParser extends X4OParser { + + static public String XPQL_LANGUAGE = "xpql"; + + private QueryStore queryStore = null; + + public XPQLParser() { + this(new QueryStore()); + } + + public XPQLParser(QueryStore queryStore) { + super(XPQL_LANGUAGE); + if (queryStore==null) { + throw new NullPointerException("Can work with null QueryStore."); + } + this.queryStore=queryStore; + addGlobalELBean("__queryStore__", queryStore); + } + + public QueryStore getQueryStore() { + return queryStore; + } + + static public QueryStore getQueryStore(ElementContext elementContext) { + if (elementContext==null) { + throw new NullPointerException("ElementContext may not be null."); + } + ValueExpression ee = elementContext.getExpressionFactory().createValueExpression(elementContext.getELContext(),"${__queryStore__}",QueryStore.class); + QueryStore qs = (QueryStore)ee.getValue(elementContext.getELContext()); + return qs; + } +} \ No newline at end of file diff --git a/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/impl/DefaultQuery.java b/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/impl/DefaultQuery.java new file mode 100644 index 0000000..fe9a7f0 --- /dev/null +++ b/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/impl/DefaultQuery.java @@ -0,0 +1,151 @@ +/* + * Copyright 2004-2007 IDCA. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the + * following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and + * the following disclaimer. + * 2. 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 IDCA 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 IDCA 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. + * + * The views and conclusions contained in the software and documentation are those of the authors and + * should not be interpreted as representing official policies, either expressed or implied, of IDCA. + */ + +package com.idcanet.vasc.xpql.impl; + +import com.idcanet.vasc.xpql.query.AbstractQuery; +import com.idcanet.vasc.xpql.query.Query; +import com.idcanet.vasc.xpql.query.QueryParameterValue; +import com.idcanet.vasc.xpql.query.QueryPart; + +/** + * This class defines an executable SQL query. + * + * @author Willem Cazander, Arjan Tijms + * @version 1.0 17/11/2004 + * @since 1.0 + */ +public class DefaultQuery extends AbstractQuery { + + + /** Is set as option values when value is null */ + static final String NULL_STRING = ""; + + + // ========= QueryPart interface + + /** + * @see com.idcanet.xtes.xpql.query.AbstractQueryPart#toEdit() + */ + @Override + public String toEdit(Query query) { + StringBuffer queryBuffer = new StringBuffer(); + for ( QueryPart queryPart:getQueryParts() ) { + queryBuffer.append( queryPart.toEdit(query) ); + } + return queryBuffer.toString(); + } + + /** + * @see com.idcanet.xtes.xpql.query.AbstractQueryPart#toPreparedSQL() + */ + @Override + public String toPreparedSQL(Query query) { + this.getOrderQueryParameterValues().clear(); + StringBuffer queryBuffer = new StringBuffer(); + for ( QueryPart queryPart:getQueryParts() ) { + queryBuffer.append( queryPart.toPreparedSQL(query) ); + } + return queryBuffer.toString(); + } + + /** + * @see com.idcanet.xtes.xpql.query.AbstractQueryPart#toSQL() + */ + @Override + public String toSQL(Query query) { + StringBuffer queryBuffer = new StringBuffer(); + for ( QueryPart queryPart:getQueryParts() ) { + queryBuffer.append( queryPart.toSQL(query) ); + } + return queryBuffer.toString(); + } + + /** + * @see com.idcanet.xtes.xpql.query.AbstractQueryPart#toXML() + */ + @Override + public String toXML(Query query) { + StringBuffer queryBuffer = new StringBuffer(); + + queryBuffer.append("\t\n"); + + for (String key:getPropertyKeys()) { + queryBuffer.append("\t\t\n"); + } + + queryBuffer.append("\t\t"); + for ( QueryPart queryPart:getQueryParts() ) { + queryBuffer.append( queryPart.toXML(query) ); + } + queryBuffer.append("\n"); + + for ( String comment:getQueryComments()) { + queryBuffer.append("\t\t"); + queryBuffer.append(comment); + queryBuffer.append("\n"); + } + + for ( QueryParameterValue qpv:getLocalQueryParameterValues()) { + queryBuffer.append("\t\t\n"); + } + + queryBuffer.append("\t\n"); + + return queryBuffer.toString(); + } + + public Query clone() throws CloneNotSupportedException { + Query query = new DefaultQuery(); + //query.setTemplateStore(getTemplateStore()); + query.setName(getName()); + query.setType(getType()); + + for (String key:getPropertyKeys()) { + query.setProperty(key,getProperty(key)); + } + for (QueryPart part:getQueryParts()) { + query.addQueryPart(part.clone()); + } + for (String com:getQueryComments()) { + query.addQueryComment(com); + } + + for (QueryParameterValue q:getLocalQueryParameterValues()) { + query.addQueryParameterValue(q.clone()); + } + return query; + } +} diff --git a/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/impl/DefaultQueryParameterValue.java b/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/impl/DefaultQueryParameterValue.java new file mode 100644 index 0000000..5a285c5 --- /dev/null +++ b/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/impl/DefaultQueryParameterValue.java @@ -0,0 +1,49 @@ +/* + * Copyright 2004-2007 IDCA. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the + * following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and + * the following disclaimer. + * 2. 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 IDCA 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 IDCA 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. + * + * The views and conclusions contained in the software and documentation are those of the authors and + * should not be interpreted as representing official policies, either expressed or implied, of IDCA. + */ + +package com.idcanet.vasc.xpql.impl; + +import com.idcanet.vasc.xpql.query.AbstractQueryParameterValue; +import com.idcanet.vasc.xpql.query.QueryParameterValue; + +/** + * + * @author Willem Cazander + * @version 1.0 Mar 4, 2007 + */ +public class DefaultQueryParameterValue extends AbstractQueryParameterValue { + + public QueryParameterValue clone() throws CloneNotSupportedException { + QueryParameterValue p = new DefaultQueryParameterValue(); + p.setDefaultValue(getDefaultValue()); + p.setName(getName()); + p.setType(getType()); + p.setValue(getValue()); + p.setValueType(getValueType()); + return p; + } + +} \ No newline at end of file diff --git a/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/impl/QueryInclude.java b/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/impl/QueryInclude.java new file mode 100644 index 0000000..eafd263 --- /dev/null +++ b/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/impl/QueryInclude.java @@ -0,0 +1,122 @@ +/* + * Copyright 2004-2007 IDCA. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the + * following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and + * the following disclaimer. + * 2. 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 IDCA 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 IDCA 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. + * + * The views and conclusions contained in the software and documentation are those of the authors and + * should not be interpreted as representing official policies, either expressed or implied, of IDCA. + */ + +package com.idcanet.vasc.xpql.impl; + +import com.idcanet.vasc.xpql.XPQLParser; +import com.idcanet.vasc.xpql.query.AbstractQueryPart; +import com.idcanet.vasc.xpql.query.Query; +import com.idcanet.vasc.xpql.query.QueryPart; + +/** + * Handled included query parts + * + * @author Willem Cazander + * @version 1.0 Mar 4, 2007 + */ +public class QueryInclude extends AbstractQueryPart { + + private String name = null; + private String resource = null; + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return the resource + */ + public String getResource() { + return resource; + } + + /** + * @param resource the resource to set + */ + public void setResource(String resource) { + this.resource = resource; + } + + @Override + public String toSQL(Query query) { + if (query.getQueryStore().getQuery(getName())==null) { + if (resource!=null) { + try { + XPQLParser parser = new XPQLParser(query.getQueryStore()); + parser.parseResource(resource); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + return query.getQueryStore().getQuery(getName()).toSQL(query); + } + + public String toPreparedSQL(Query query) { + if (query.getQueryStore().getQuery(getName())==null) { + if (resource!=null) { + try { + XPQLParser parser = new XPQLParser(query.getQueryStore()); + parser.parseResource(resource); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + return query.getQueryStore().getQuery(getName()).toPreparedSQL(query); + } + + public String toXML(Query query) { + if (resource==null) { + return ""; + } + return ""; + } + + public String toEdit(Query query) { + if (resource==null) { + return "@inc:"+name; + } + return "@inc:"+name+"@"+resource; + } + + public QueryPart clone() throws CloneNotSupportedException { + QueryInclude include = new QueryInclude(); + include.setName(getName()); + include.setResource(getResource()); + return include; + } +} \ No newline at end of file diff --git a/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/impl/QueryParameter.java b/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/impl/QueryParameter.java new file mode 100644 index 0000000..3140ae8 --- /dev/null +++ b/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/impl/QueryParameter.java @@ -0,0 +1,206 @@ +/* + * Copyright 2004-2007 IDCA. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the + * following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and + * the following disclaimer. + * 2. 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 IDCA 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 IDCA 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. + * + * The views and conclusions contained in the software and documentation are those of the authors and + * should not be interpreted as representing official policies, either expressed or implied, of IDCA. + */ + +package com.idcanet.vasc.xpql.impl; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import com.idcanet.vasc.xpql.query.AbstractQueryPart; +import com.idcanet.vasc.xpql.query.Query; +import com.idcanet.vasc.xpql.query.QueryParameterValue; +import com.idcanet.vasc.xpql.query.QueryPart; + +/** + * + * @author Willem Cazander + * @version 1.0 Mar 4, 2007 + */ +public class QueryParameter extends AbstractQueryPart { + + private String name = null; + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name the name to set + */ + public void setName(String name) { + this.name = name; + } + + @SuppressWarnings("unchecked") + public String toSQL(Query query) { + QueryParameterValue value = query.getQueryParameterValue(getName()); + if ( value == null ) { + return ""; + } + if ( value.getValue() == null) { + if (value.getDefaultValue() == null ) { + return ""; + } + return value.getDefaultValue().toString(); + } + + if (value.getType()==null) { + value.setType(QueryParameterValue.QueryParameterType.parameter); + } + if (value.getType()==QueryParameterValue.QueryParameterType.parameterList) { + List valueList = null; + if (value.getValue() instanceof List) { + valueList = (List)value.getValue(); + } + if (value.getValue() instanceof String) { + valueList = new ArrayList(); + String[] array = ((String)value.getValue()).split(","); + for (String a:array) { + valueList.add(a); + } + } + if (valueList==null) { + valueList = new ArrayList(); + valueList.add(value.getValue()); + } + StringBuilder builder = new StringBuilder(valueList.size()+3); + Iterator i = valueList.iterator(); + while (i.hasNext()) { + Object v = i.next(); + builder.append(v.toString()); + if (i.hasNext()) { + builder.append(','); + } + } + return builder.toString(); + } + + return value.getValue().toString(); + } + + @SuppressWarnings("unchecked") + public String toPreparedSQL(Query query) { + + QueryParameterValue value = query.getQueryParameterValue(getName()); + if ( value == null ) { + return ""; + } + if (value.getType()==null) { + value.setType(QueryParameterValue.QueryParameterType.parameter); + } + + String result = null; + switch (value.getType()) { + default: + case parameter: + //if (query.getOrderQueryParameterValues().contains(value)==false) { + query.addOrderQueryParameterValue(value); + result = "?"; + break; + case parameterList: + + // add extra method so , toObjectList, which does al the prepare work. + + Object valueO = value.getValue(); + if (valueO==null) { + return ""; + } + List valueList = null; + if (valueO instanceof List) { + valueList = (List)valueO; + } + if (valueO instanceof String) { + valueList = new ArrayList(); + String[] array = ((String)valueO).split(","); + for (String a:array) { + valueList.add(a); + } + } + if (valueList==null) { + valueList = new ArrayList(); + valueList.add(value); + } + + + //boolean doAdd = false; + //if (query.getOrderQueryParameterValues().contains(value)==false) { + //} + + StringBuilder builder = new StringBuilder(valueList.size()+3); + Iterator i = valueList.iterator(); + while (i.hasNext()) { + Object v = i.next(); + builder.append('?'); + //if (doAdd) { + QueryParameterValue vv = new DefaultQueryParameterValue(); + vv.setName(value.getName()); + vv.setValue(v); + vv.setType(QueryParameterValue.QueryParameterType.parameter); + query.addOrderQueryParameterValue(vv); + //} + if (i.hasNext()) { + builder.append(','); + } + } + result = builder.toString(); + break; + case raw: + // The structural type of a "value" indicates that we're dealing with a SQL construct + // instead of a 'value' in the sense of values for prepared statements. In the XPQL dialect, + // options can be structure as well as values. + if (value.getValue()!=null) { + result = value.getValue().toString(); + } else if (value.getDefaultValue()!=null) { + result = value.getDefaultValue().toString(); + } else { + result = ""; + } + break; + case xpql: + result = null; + break; + } + return result; + } + + public String toXML(Query query) { + return ""; + } + + public String toEdit(Query query) { + return "@"+getName(); + } + + public QueryPart clone() throws CloneNotSupportedException { + QueryParameter p = new QueryParameter(); + p.setName(getName()); + return p; + } +} \ No newline at end of file diff --git a/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/impl/QueryText.java b/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/impl/QueryText.java new file mode 100644 index 0000000..a73d3f0 --- /dev/null +++ b/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/impl/QueryText.java @@ -0,0 +1,66 @@ +/* + * Copyright 2004-2007 IDCA. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the + * following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and + * the following disclaimer. + * 2. 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 IDCA 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 IDCA 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. + * + * The views and conclusions contained in the software and documentation are those of the authors and + * should not be interpreted as representing official policies, either expressed or implied, of IDCA. + */ + +package com.idcanet.vasc.xpql.impl; + +import com.idcanet.vasc.xpql.query.AbstractQueryPart; +import com.idcanet.vasc.xpql.query.Query; +import com.idcanet.vasc.xpql.query.QueryPart; + +/** + * + * @author Willem Cazander + * @version 1.0 Mar 4, 2007 + */ +public class QueryText extends AbstractQueryPart { + + String text = null; + + /** + * @return the text + */ + public String getText() { + return text; + } + + /** + * @param text the text to set + */ + public void setText(String text) { + this.text = text; + } + + @Override + public String toSQL(Query query) { + return text; + } + + public QueryPart clone() throws CloneNotSupportedException { + QueryText text = new QueryText(); + text.setText(getText()); + return text; + } +} \ No newline at end of file diff --git a/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/impl/x4o/CommentElement.java b/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/impl/x4o/CommentElement.java new file mode 100644 index 0000000..7f68ce9 --- /dev/null +++ b/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/impl/x4o/CommentElement.java @@ -0,0 +1,76 @@ +/* + * Copyright 2004-2006 IDCA. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the + * following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and + * the following disclaimer. + * 2. 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 IDCA 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 IDCA 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. + * + * The views and conclusions contained in the software and documentation are those of the authors and + * should not be interpreted as representing official policies, either expressed or implied, of IDCA. + */ + +package com.idcanet.vasc.xpql.impl.x4o; + +import com.idcanet.x4o.element.AbstractElement; +import com.idcanet.x4o.element.ElementException; +import com.idcanet.vasc.xpql.query.Query; + +/** + * + * + * @author Willem Cazander + * @version 1.0 Aug 20, 2006 + */ +public class CommentElement extends AbstractElement { + + private StringBuffer comment = null; + + public CommentElement() { + comment = new StringBuffer(20); + } + + /** + * @see com.idcanet.x4o.element.AbstractElement#doCharacters(java.lang.String) + */ + @Override + public void doCharacters(String arg0) { + comment.append(arg0); + } + + /** + * @see com.idcanet.x4o.element.AbstractElement#doComment(java.lang.String) + */ + @Override + public void doComment(String arg0) { + comment.append(arg0); + } + + /** + * @see com.idcanet.x4o.element.AbstractElement#doElementEnd() + */ + @Override + public void doElementEnd() throws ElementException { + if (getParent()==null) { + throw new ElementException("No parent element"); + } + if ((getParent().getElementObject() instanceof Query)==false) { + throw new ElementException("No query parent element object"); + } + ((Query)getParent().getElementObject()).addQueryComment(comment.toString()); + } +} \ No newline at end of file diff --git a/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/impl/x4o/ParameterTypeAttributeConverter.java b/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/impl/x4o/ParameterTypeAttributeConverter.java new file mode 100644 index 0000000..527d41e --- /dev/null +++ b/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/impl/x4o/ParameterTypeAttributeConverter.java @@ -0,0 +1,51 @@ +/* + * Copyright 2004-2006 IDCA. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the + * following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and + * the following disclaimer. + * 2. 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 IDCA 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 IDCA 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. + * + * The views and conclusions contained in the software and documentation are those of the authors and + * should not be interpreted as representing official policies, either expressed or implied, of IDCA. + */ + +package com.idcanet.vasc.xpql.impl.x4o; + +import com.idcanet.x4o.element.AbstractElementAttributeConverter; +import com.idcanet.x4o.element.Element; +import com.idcanet.x4o.element.ElementAttributeConverterException; +import com.idcanet.vasc.xpql.query.QueryParameterValue.QueryParameterType; + +/** + * + * @author Willem Cazander + * @version 1.0 Jan 21, 2007 + */ +public class ParameterTypeAttributeConverter extends AbstractElementAttributeConverter { + + /** + * @see com.idcanet.x4o.element.AbstractElementClassParameterConverter#doConvertAttribute(com.idcanet.x4o.element.Element, java.lang.Object) + */ + public Object doConvertAttribute(Element arg0, Object value) throws ElementAttributeConverterException { + try { + return QueryParameterType.valueOf(""+value); + } catch (Exception ex) { + throw new ElementAttributeConverterException(this,"Could not convert to QueryParameterType value="+value,ex); + } + } +} \ No newline at end of file diff --git a/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/impl/x4o/QueryBindingHandler.java b/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/impl/x4o/QueryBindingHandler.java new file mode 100644 index 0000000..fcd0744 --- /dev/null +++ b/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/impl/x4o/QueryBindingHandler.java @@ -0,0 +1,84 @@ +/* + * Copyright 2004-2006 IDCA. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the + * following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and + * the following disclaimer. + * 2. 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 IDCA 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 IDCA 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. + * + * The views and conclusions contained in the software and documentation are those of the authors and + * should not be interpreted as representing official policies, either expressed or implied, of IDCA. + */ + +package com.idcanet.vasc.xpql.impl.x4o; + +import com.idcanet.x4o.element.AbstractElementBindingHandler; +import com.idcanet.x4o.element.Element; +import com.idcanet.x4o.element.ElementBindingHandlerException; +import com.idcanet.vasc.xpql.impl.QueryInclude; +import com.idcanet.vasc.xpql.impl.QueryParameter; +import com.idcanet.vasc.xpql.query.Query; +import com.idcanet.vasc.xpql.query.QueryParameterValue; +import com.idcanet.vasc.xpql.query.QueryPart; + +/** + * + * @author Willem Cazander + * @version 1.0 Jan 21, 2007 + */ +public class QueryBindingHandler extends AbstractElementBindingHandler { + + public boolean canBind(Element element) { + Object parent = element.getParent().getElementObject(); + Object child = element.getElementObject(); + boolean p = false; + boolean c = false; + if(parent instanceof Query) { p=true; } + if(child instanceof QueryPart) { c=true; } + if(child instanceof QueryParameterValue) { c=true; } + + // remove recuive stack + if(element instanceof SQLElement) { c=false; } + + if(p&c) { return true; } else { return false; } + } + + public void doBind(Element element) throws ElementBindingHandlerException { + Object parent = element.getParent().getElementObject(); + Object child = element.getElementObject(); + if(parent instanceof Query) { + Query query = (Query)parent; + + // skip those with diffent life cycle because of sql characters adding elements in sax phase. + if (child instanceof QueryParameter) { + return; + } + if (child instanceof QueryInclude) { + return; + } + + if (child instanceof QueryPart) { + query.addQueryPart((QueryPart)child); + } + if (child instanceof QueryParameterValue) { + query.addLocalQueryParameterValue((QueryParameterValue)child); + query.addQueryParameterValue((QueryParameterValue)child); + } + } + } + +} \ No newline at end of file diff --git a/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/impl/x4o/QueryElementConfigurator.java b/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/impl/x4o/QueryElementConfigurator.java new file mode 100644 index 0000000..1ba933b --- /dev/null +++ b/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/impl/x4o/QueryElementConfigurator.java @@ -0,0 +1,55 @@ +/* + * Copyright 2004-2006 IDCA. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the + * following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and + * the following disclaimer. + * 2. 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 IDCA 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 IDCA 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. + * + * The views and conclusions contained in the software and documentation are those of the authors and + * should not be interpreted as representing official policies, either expressed or implied, of IDCA. + */ + +package com.idcanet.vasc.xpql.impl.x4o; + +import com.idcanet.x4o.element.AbstractElementConfigurator; +import com.idcanet.x4o.element.Element; +import com.idcanet.x4o.element.ElementConfiguratorException; +import com.idcanet.vasc.xpql.QueryStore; +import com.idcanet.vasc.xpql.XPQLParser; +import com.idcanet.vasc.xpql.query.Query; + +/** + * + * @author Willem Cazander + * @version 1.0 Mar 21, 2007 + */ +public class QueryElementConfigurator extends AbstractElementConfigurator { + + /** + * @see com.idcanet.x4o.element.ElementConfigurator#doConfigElement(com.idcanet.x4o.element.Element) + */ + public void doConfigElement(Element element) throws ElementConfiguratorException { + if ((element.getElementObject() instanceof Query)==false) { + throw new ElementConfiguratorException(this,"No query element object"); + } + QueryStore store = XPQLParser.getQueryStore(element.getElementContext()); + Query query = (Query)element.getElementObject(); + query.setQueryStore(store); + store.addQuery(query); + } +} \ No newline at end of file diff --git a/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/impl/x4o/QueryIncludeElement.java b/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/impl/x4o/QueryIncludeElement.java new file mode 100644 index 0000000..95dba0a --- /dev/null +++ b/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/impl/x4o/QueryIncludeElement.java @@ -0,0 +1,58 @@ +/* + * Copyright 2004-2006 IDCA. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the + * following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and + * the following disclaimer. + * 2. 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 IDCA 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 IDCA 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. + * + * The views and conclusions contained in the software and documentation are those of the authors and + * should not be interpreted as representing official policies, either expressed or implied, of IDCA. + */ + +package com.idcanet.vasc.xpql.impl.x4o; + +import com.idcanet.x4o.element.AbstractElement; +import com.idcanet.x4o.element.ElementException; +import com.idcanet.vasc.xpql.query.Query; +import com.idcanet.vasc.xpql.query.QueryPart; + +/** + * Inserts the query inlude element direct on start-tag + * + * @author Willem Cazander + * @version 1.0 Dec 2, 2009 + */ +public class QueryIncludeElement extends AbstractElement { + + /** + * @see com.idcanet.x4o.element.AbstractElement#doElementEnd() + */ + @Override + public void doElementStart() throws ElementException { + if (getParent()==null) { + throw new ElementException("No parent element"); + } + if ((getParent().getElementObject() instanceof Query)==false) { + throw new ElementException("No query parent element object"); + } + if ((getElementObject() instanceof QueryPart)==false) { + throw new ElementException("No QueryPart element object"); + } + ((Query)getParent().getElementObject()).addQueryPart((QueryPart)getElementObject()); + } +} \ No newline at end of file diff --git a/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/impl/x4o/QueryParameterElement.java b/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/impl/x4o/QueryParameterElement.java new file mode 100644 index 0000000..c0352a1 --- /dev/null +++ b/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/impl/x4o/QueryParameterElement.java @@ -0,0 +1,58 @@ +/* + * Copyright 2004-2006 IDCA. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the + * following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and + * the following disclaimer. + * 2. 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 IDCA 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 IDCA 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. + * + * The views and conclusions contained in the software and documentation are those of the authors and + * should not be interpreted as representing official policies, either expressed or implied, of IDCA. + */ + +package com.idcanet.vasc.xpql.impl.x4o; + +import com.idcanet.x4o.element.AbstractElement; +import com.idcanet.x4o.element.ElementException; +import com.idcanet.vasc.xpql.query.Query; +import com.idcanet.vasc.xpql.query.QueryPart; + +/** + * Inserts the query element direct on start-tag + * + * @author Willem Cazander + * @version 1.0 Mar 24, 2009 + */ +public class QueryParameterElement extends AbstractElement { + + /** + * @see com.idcanet.x4o.element.AbstractElement#doElementEnd() + */ + @Override + public void doElementStart() throws ElementException { + if (getParent()==null) { + throw new ElementException("No parent element"); + } + if ((getParent().getElementObject() instanceof Query)==false) { + throw new ElementException("No query parent element object"); + } + if ((getElementObject() instanceof QueryPart)==false) { + throw new ElementException("No QueryPart element object"); + } + ((Query)getParent().getElementObject()).addQueryPart((QueryPart)getElementObject()); + } +} \ No newline at end of file diff --git a/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/impl/x4o/QueryTypeAttributeConverter.java b/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/impl/x4o/QueryTypeAttributeConverter.java new file mode 100644 index 0000000..5583243 --- /dev/null +++ b/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/impl/x4o/QueryTypeAttributeConverter.java @@ -0,0 +1,51 @@ +/* + * Copyright 2004-2006 IDCA. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the + * following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and + * the following disclaimer. + * 2. 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 IDCA 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 IDCA 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. + * + * The views and conclusions contained in the software and documentation are those of the authors and + * should not be interpreted as representing official policies, either expressed or implied, of IDCA. + */ + +package com.idcanet.vasc.xpql.impl.x4o; + +import com.idcanet.x4o.element.AbstractElementAttributeConverter; +import com.idcanet.x4o.element.Element; +import com.idcanet.x4o.element.ElementAttributeConverterException; +import com.idcanet.vasc.xpql.query.Query.QueryType; + +/** + * + * @author Willem Cazander + * @version 1.0 Jan 21, 2007 + */ +public class QueryTypeAttributeConverter extends AbstractElementAttributeConverter { + + /** + * @see com.idcanet.x4o.element.AbstractElementClassParameterConverter#doConvertAttribute(com.idcanet.x4o.element.Element, java.lang.Object) + */ + public Object doConvertAttribute(Element arg0, Object value) throws ElementAttributeConverterException { + try { + return QueryType.valueOf(""+value); + } catch (Exception ex) { + throw new ElementAttributeConverterException(this,"Could not convert to QueryType value="+value,ex); + } + } +} \ No newline at end of file diff --git a/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/impl/x4o/SQLElement.java b/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/impl/x4o/SQLElement.java new file mode 100644 index 0000000..f7b63a8 --- /dev/null +++ b/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/impl/x4o/SQLElement.java @@ -0,0 +1,79 @@ +/* + * Copyright 2004-2006 IDCA. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the + * following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and + * the following disclaimer. + * 2. 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 IDCA 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 IDCA 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. + * + * The views and conclusions contained in the software and documentation are those of the authors and + * should not be interpreted as representing official policies, either expressed or implied, of IDCA. + */ + +package com.idcanet.vasc.xpql.impl.x4o; + +import com.idcanet.x4o.element.AbstractElement; +import com.idcanet.x4o.element.ElementException; +import com.idcanet.vasc.xpql.impl.QueryText; +import com.idcanet.vasc.xpql.query.Query; + +/** + * + * + * @author Willem Cazander + * @version 1.0 Aug 20, 2006 + */ +public class SQLElement extends AbstractElement { + + private StringBuffer sql = null; + + public SQLElement() { + sql = new StringBuffer(20); + } + + /** + * @see com.idcanet.x4o.element.AbstractElement#doCharacters(java.lang.String) + */ + @Override + public void doCharacters(String text) throws ElementException { + if (getParent()==null) { + throw new ElementException("No parent element"); + } + if ((getParent().getElementObject() instanceof Query)==false) { + throw new ElementException("No query parent element object"); + } + QueryText q = new QueryText(); + q.setText(text); + ((Query)getParent().getElementObject()).addQueryPart(q); + } + + /** + * @see com.idcanet.x4o.element.AbstractElement#doComment(java.lang.String) + */ + @Override + public void doComment(String arg0) { + sql.append("/* "+arg0+" */"); + } + + /** + * @see com.idcanet.x4o.element.AbstractElement#getElementObject() + */ + @Override + public Object getElementObject() { + return getParent().getElementObject(); + } +} \ No newline at end of file diff --git a/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/query/AbstractQuery.java b/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/query/AbstractQuery.java new file mode 100644 index 0000000..8727889 --- /dev/null +++ b/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/query/AbstractQuery.java @@ -0,0 +1,259 @@ +/* + * Copyright 2004-2007 IDCA. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the + * following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and + * the following disclaimer. + * 2. 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 IDCA 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 IDCA 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. + * + * The views and conclusions contained in the software and documentation are those of the authors and + * should not be interpreted as representing official policies, either expressed or implied, of IDCA. + */ + +package com.idcanet.vasc.xpql.query; + +import java.lang.reflect.Constructor; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.idcanet.vasc.xpql.QueryStore; +import com.idcanet.vasc.xpql.impl.DefaultQueryParameterValue; + +/** + * + * @author Willem Cazander + * @version 1.0 Mar 4, 2007 + */ +abstract public class AbstractQuery extends AbstractQueryPart implements Query { + + private String name = null; + private List queryParts = null; + private Map localQueryParameterValues = null; + private Map queryParameterValues = null; + private List orderQueryParameterValues = null; + private List queryComments = null; + private Map properties = null; + private QueryType type = null; + private QueryStore queryStore = null; + + /** + * Init all fields. + */ + public AbstractQuery() { + queryParts = new ArrayList(10); + localQueryParameterValues = new HashMap(6); + queryParameterValues = new HashMap(6); + orderQueryParameterValues = new ArrayList(6); + queryComments = new ArrayList(2); + properties = new HashMap(5); + } + + /** + * @see com.idcanet.xtes.xpql.query.Query#getName() + */ + public String getName() { + return name; + } + + /** + * @see com.idcanet.xtes.xpql.query.Query#setName(java.lang.String) + */ + public void setName(String name) { + this.name=name; + } + + /** + * @see com.idcanet.xtes.xpql.query.Query#addQueryComment(java.lang.String) + */ + public void addQueryComment(String comment) { + queryComments.add(comment); + } + + /** + * @see com.idcanet.xtes.xpql.query.Query#addQueryParameterValue(com.idcanet.xtes.xpql.query.QueryParameterValue) + */ + public void addQueryParameterValue(QueryParameterValue value) { + queryParameterValues.put(value.getName(), value); + } + + /** + * @see com.idcanet.xtes.xpql.query.Query#addLocalQueryParameterValue(com.idcanet.xtes.xpql.query.QueryParameterValue) + */ + public void addLocalQueryParameterValue(QueryParameterValue value) { + localQueryParameterValues.put(value.getName(), value); + } + + /** + * @see com.idcanet.xtes.xpql.query.Query#addOrderQueryParameterValue(com.idcanet.xtes.xpql.query.QueryParameterValue) + */ + public void addOrderQueryParameterValue(QueryParameterValue value) { + orderQueryParameterValues.add(value); + } + + /** + * @see com.idcanet.xtes.xpql.query.Query#addQueryPart(com.idcanet.xtes.xpql.query.QueryPart) + */ + public void addQueryPart(QueryPart queryPart) { + queryParts.add(queryPart); + } + + /** + * @see com.idcanet.xtes.xpql.query.Query#getProperty(java.lang.String) + */ + public Object getProperty(String name) { + return properties.get(name); + } + + /** + * @see com.idcanet.xtes.xpql.query.Query#getPropertyString(java.lang.String) + */ + public String getPropertyString(String name) { + return getProperty(name).toString(); + } + + /** + * @see com.idcanet.xtes.xpql.query.Query#getQueryComments() + */ + public List getQueryComments() { + return queryComments; + } + + /** + * @see com.idcanet.xtes.xpql.query.Query#getQueryParameterValue(java.lang.String) + */ + public QueryParameterValue getQueryParameterValue(String name) { + return queryParameterValues.get(name); + } + + /** + * @see com.idcanet.xtes.xpql.query.Query#getQueryParts() + */ + public List getQueryParts() { + return queryParts; + } + + /** + * @see com.idcanet.xtes.xpql.query.Query#setProperty(java.lang.String, java.lang.Object) + */ + public void setProperty(String name, Object value) { + properties.put(name,value); + } + + /** + * @see com.idcanet.xtes.xpql.query.Query#getPropertyKeys() + */ + public Collection getPropertyKeys() { + return properties.keySet(); + } + + /** + * @see com.idcanet.xtes.xpql.query.Query#getQueryParameters() + */ + public List getQueryParameters() { + return null; + } + + /** + * @see com.idcanet.xtes.xpql.query.Query#getQueryParameterValues() + */ + public Collection getQueryParameterValues() { + return queryParameterValues.values(); + } + + /** + * @see com.idcanet.xtes.xpql.query.Query#getLocalQueryParameterValues() + */ + public Collection getLocalQueryParameterValues() { + return localQueryParameterValues.values(); + } + + /** + * @see com.idcanet.xtes.xpql.query.Query#getOrderQueryParameterValues() + */ + public List getOrderQueryParameterValues() { + return orderQueryParameterValues; + } + + /** + * @see com.idcanet.xtes.xpql.query.Query#setQueryParameter(java.lang.String, java.lang.Object) + */ + public void setQueryParameter(String name, Object value) { + if (name==null) { + throw new NullPointerException("name can't be null."); + } + QueryParameterValue parameter = getQueryParameterValue(name); + if (parameter==null) { + // not found create new one + parameter = new DefaultQueryParameterValue(); + parameter.setName(name); + parameter.setType(QueryParameterValue.QueryParameterType.parameter); + addQueryParameterValue(parameter); + } + + // check if we need to convert + //System.out.println("Con: "+parameter.getValueType()+" value: "+value+" valueClass: "+value.getClass()); + if (parameter.getValueType()!=null && value instanceof String) { + try { + Constructor c = parameter.getValueType().getConstructor(String.class); + value = c.newInstance(value); + } catch (Exception e) { + // TODO: fix + throw new RuntimeException(e); + } + } + parameter.setValue(value); + } + + public void setQueryParameters(Map parameters) { + for (String key:parameters.keySet()) { + setQueryParameter(key,parameters.get(key)); + } + } + + /** + * @see com.idcanet.xtes.xpql.query.Query#getType() + */ + public QueryType getType() { + return type; + } + + /** + * @see com.idcanet.xtes.xpql.query.Query#setType(com.idcanet.xtes.xpql.query.Query.QueryType) + */ + public void setType(QueryType type) { + this.type=type; + } + + /** + * @see com.idcanet.xtes.xpql.query.Query#getQueryStore() + */ + public QueryStore getQueryStore() { + return queryStore; + } + + /** + * @see com.idcanet.xtes.xpql.query.Query#setQueryStore(com.idcanet.xtes.xpql.QueryStore) + */ + public void setQueryStore(QueryStore store) { + this.queryStore=store; + } + + abstract public Query clone() throws CloneNotSupportedException; +} \ No newline at end of file diff --git a/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/query/AbstractQueryParameterValue.java b/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/query/AbstractQueryParameterValue.java new file mode 100644 index 0000000..37372d0 --- /dev/null +++ b/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/query/AbstractQueryParameterValue.java @@ -0,0 +1,113 @@ +/* + * Copyright 2004-2007 IDCA. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the + * following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and + * the following disclaimer. + * 2. 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 IDCA 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 IDCA 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. + * + * The views and conclusions contained in the software and documentation are those of the authors and + * should not be interpreted as representing official policies, either expressed or implied, of IDCA. + */ + +package com.idcanet.vasc.xpql.query; + +/** + * + * @author Willem Cazander + * @version 1.0 Mar 4, 2007 + */ +abstract public class AbstractQueryParameterValue implements QueryParameterValue { + + private String name = null; + private Object value = null; + private Object defaultValue = null; + private QueryParameterType type = null; + private Class valueType = null; + + /** + * @see com.idcanet.xtes.xpql.query.QueryParameterValue#getName() + */ + public String getName() { + return name; + } + + /** + * @see com.idcanet.xtes.xpql.query.QueryParameterValue#setName(java.lang.String) + */ + public void setName(String name) { + this.name=name; + } + + /** + * @see com.idcanet.xtes.xpql.query.QueryParameterValue#getDefaultValue() + */ + public Object getDefaultValue() { + return defaultValue; + } + + /** + * @see com.idcanet.xtes.xpql.query.QueryParameterValue#setDefaultValue(java.lang.Object) + */ + public void setDefaultValue(Object defaultValue) { + this.defaultValue=defaultValue; + } + + /** + * @see com.idcanet.xtes.xpql.query.QueryParameterValue#getValue() + */ + public Object getValue() { + return value; + } + + /** + * @see com.idcanet.xtes.xpql.query.QueryParameterValue#setType(com.idcanet.xtes.xpql.query.QueryParameterValue.QueryParameterType) + */ + public void setType(QueryParameterType type) { + this.type=type; + } + + /** + * @see com.idcanet.xtes.xpql.query.QueryParameterValue#getType() + */ + public QueryParameterType getType() { + return type; + } + + /** + * @see com.idcanet.xtes.xpql.query.QueryParameterValue#setValue(java.lang.Object) + */ + public void setValue(Object value) { + this.value=value; + } + + /** + * @return the valueType + */ + public Class getValueType() { + return valueType; + } + + /** + * @param valueType the valueType to set + */ + public void setValueType(Class valueType) { + this.valueType = valueType; + } + + abstract public QueryParameterValue clone() throws CloneNotSupportedException; +} diff --git a/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/query/AbstractQueryPart.java b/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/query/AbstractQueryPart.java new file mode 100644 index 0000000..9aa2b2c --- /dev/null +++ b/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/query/AbstractQueryPart.java @@ -0,0 +1,91 @@ +/* + * Copyright 2004-2007 IDCA. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the + * following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and + * the following disclaimer. + * 2. 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 IDCA 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 IDCA 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. + * + * The views and conclusions contained in the software and documentation are those of the authors and + * should not be interpreted as representing official policies, either expressed or implied, of IDCA. + */ + +package com.idcanet.vasc.xpql.query; + +/** + * + * @author Willem Cazander + * @version 1.0 Mar 4, 2007 + */ +abstract public class AbstractQueryPart implements QueryPart { + + /** + * @see com.idcanet.xtes.xpql.query.QueryPart#toSQL() + */ + abstract public String toSQL(Query query); + + /** + * Returns the toSQL() retult. + * @see com.idcanet.xtes.xpql.query.QueryPart#toPreparedSQL() + */ + public String toPreparedSQL(Query query) { + return toSQL(query); + } + + /** + * XML escapes the toSQL() return String. + * @see com.idcanet.xtes.xpql.query.QueryPart#toXML() + */ + public String toXML(Query query) { + return escapeXML(toSQL(query)); + } + + /** + * Returns the toSQL() retult. + * @see com.idcanet.xtes.xpql.query.QueryPart#toEdit() + */ + public String toEdit(Query query) { + return toSQL(query); + } + + // helper method + public static String escapeXML(String input) { + StringBuffer filtered = new StringBuffer(); + + for ( char c : input.toCharArray() ) { + switch (c) { + case '<': + filtered.append("<"); + break; + case '>': + filtered.append(">"); + break; + case '"': + filtered.append("""); + break; + case '&': + filtered.append("&"); + break; + default: + filtered.append(c); + } + } + return filtered.toString(); + } + + abstract public QueryPart clone() throws CloneNotSupportedException; +} \ No newline at end of file diff --git a/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/query/Query.java b/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/query/Query.java new file mode 100644 index 0000000..c96cdd4 --- /dev/null +++ b/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/query/Query.java @@ -0,0 +1,86 @@ +/* + * Copyright 2004-2007 IDCA. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the + * following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and + * the following disclaimer. + * 2. 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 IDCA 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 IDCA 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. + * + * The views and conclusions contained in the software and documentation are those of the authors and + * should not be interpreted as representing official policies, either expressed or implied, of IDCA. + */ + +package com.idcanet.vasc.xpql.query; + +import java.util.Collection; +import java.util.List; +import java.util.Map; + +import com.idcanet.vasc.xpql.QueryStore; + +/** + * TODO: add clonale support + * + * @author Willem Cazander + * @version 1.0 Mar 4, 2007 + */ +public interface Query extends QueryPart { + + static public enum QueryType { + sql, + hql + } + + public void setName(String name); + public String getName(); + + public void setType(QueryType type); + public QueryType getType(); + + public void addQueryPart(QueryPart queryPart); + public List getQueryParts(); + + public void addQueryComment(String comment); + public List getQueryComments(); + + public void addQueryParameterValue(QueryParameterValue value); + public void addLocalQueryParameterValue(QueryParameterValue value); + public void addOrderQueryParameterValue(QueryParameterValue value); + public Collection getQueryParameterValues(); + public Collection getLocalQueryParameterValues(); + public List getOrderQueryParameterValues(); + public QueryParameterValue getQueryParameterValue(String name); + + public void setQueryParameter(String name,Object value); + public void setQueryParameters(Map parameters); + public List getQueryParameters(); + + public void setProperty(String name,Object value); + public Object getProperty(String name); + public String getPropertyString(String name); + public Collection getPropertyKeys(); + + public void setQueryStore(QueryStore store); + public QueryStore getQueryStore(); + + /** + * Force impl to have public clone methode + * @return + * @throws CloneNotSupportedException + */ + public Query clone() throws CloneNotSupportedException; +} diff --git a/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/query/QueryParameterValue.java b/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/query/QueryParameterValue.java new file mode 100644 index 0000000..fb1ea87 --- /dev/null +++ b/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/query/QueryParameterValue.java @@ -0,0 +1,116 @@ +/* + * Copyright 2004-2007 IDCA. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the + * following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and + * the following disclaimer. + * 2. 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 IDCA 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 IDCA 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. + * + * The views and conclusions contained in the software and documentation are those of the authors and + * should not be interpreted as representing official policies, either expressed or implied, of IDCA. + */ + +package com.idcanet.vasc.xpql.query; + +/** + * A QueryParameterValue + * + * + * @author Willem Cazander + * @version 1.0 Mar 4, 2007 + */ +public interface QueryParameterValue { + + /** + * The value type + */ + static public enum QueryParameterType { + /** one parameter value */ + parameter, + /** Multiple value */ + parameterList, + /** parser the value as xpql syntax */ + xpql, + /** Put the value in raw in the output */ + raw + } + + /** + * Sets the name + * @param name The name to set. + */ + public void setName(String name); + + /** + * Gets the name + * @return Returns the name + */ + public String getName(); + + /** + * Sets the value + * @param value The value to set. + */ + public void setValue(Object value); + + /** + * Gets the value + * @return Returns the value + */ + public Object getValue(); + + /** + * Sets the defaultValue + * @param defaultValue The defaultValue to set. + */ + public void setDefaultValue(Object defaultValue); + + /** + * Gets the defaultValue + * @return Returns the defaultValue + */ + public Object getDefaultValue(); + + /** + * Sets type value Type + * @param type The type to set. + */ + public void setType(QueryParameterType type); + + /** + * Gets the type. + * @return Returns the type + */ + public QueryParameterType getType(); + + /** + * @return the valueType + */ + public Class getValueType(); + + /** + * @param valueType the valueType to set + */ + public void setValueType(Class valueType); + + /** + * Force impl to have public clone methode + * @return + * @throws CloneNotSupportedException + */ + public QueryParameterValue clone() throws CloneNotSupportedException; +} \ No newline at end of file diff --git a/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/query/QueryPart.java b/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/query/QueryPart.java new file mode 100644 index 0000000..3a296f3 --- /dev/null +++ b/vasc-xpql/src/main/java/com/idcanet/vasc/xpql/query/QueryPart.java @@ -0,0 +1,70 @@ +/* + * Copyright 2004-2007 IDCA. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the + * following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and + * the following disclaimer. + * 2. 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 IDCA 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 IDCA 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. + * + * The views and conclusions contained in the software and documentation are those of the authors and + * should not be interpreted as representing official policies, either expressed or implied, of IDCA. + */ + +package com.idcanet.vasc.xpql.query; + +/** + * + * @author Willem Cazander + * @version 1.0 Mar 4, 2007 + */ +public interface QueryPart extends Cloneable { + + /** + * This method is for building the SQL version of the query part. + * This version is intended for execution. + * @return + */ + public String toSQL(Query query); + + /** + * This method is for building the prepared statement SQL version of the query part. + * This version is intended for execution via a prepared statement. + * @return + */ + public String toPreparedSQL(Query query); + + /** + * This method is for building the XML version of the query part. + * This version is intended for storage. + * @return + */ + public String toXML(Query query); + + /** + * This method is for building the edit mode version of the query part. + * This version is intended for humans working with the format in an editor. + * @return + */ + public String toEdit(Query query); + + /** + * Force impl to have public clone methode + * @return + * @throws CloneNotSupportedException + */ + public QueryPart clone() throws CloneNotSupportedException; +} \ No newline at end of file diff --git a/vasc-xpql/src/test/java/.empty b/vasc-xpql/src/test/java/.empty new file mode 100644 index 0000000..e69de29 diff --git a/vasc-xpql/src/test/resources/META-INF/logging.properties b/vasc-xpql/src/test/resources/META-INF/logging.properties new file mode 100644 index 0000000..d29c852 --- /dev/null +++ b/vasc-xpql/src/test/resources/META-INF/logging.properties @@ -0,0 +1,20 @@ +# +# Enables all logging for debugging unit tests. + +# Specify the handlers to create in the root logger +# (all loggers are children of the root logger) +# The following creates two handlers +handlers = java.util.logging.ConsoleHandler + +# Set the default logging level for new ConsoleHandler instances +java.util.logging.ConsoleHandler.level = ALL + +# Set the default logging level for the root logger +.level = ALL + +com.idcanet.x4o = ALL + +# Java 6 has internal logging on many builtin libs +sun.level=OFF +java.level=OFF +javax.level=OFF \ No newline at end of file diff --git a/vasc-xpql/src/test/resources/xpql/test-all.xml b/vasc-xpql/src/test/resources/xpql/test-all.xml new file mode 100644 index 0000000..bbbc0b4 --- /dev/null +++ b/vasc-xpql/src/test/resources/xpql/test-all.xml @@ -0,0 +1,87 @@ + + + + + LIMIT + + + + + + OFFSET + + + + + + + + + + SELECT + USERS.USERNAME AS USERNAME + USERS.PASSWD AS PASSWORD + FROM + USERS + + Bla bla + Also see this site http://www.google.com + + + + + + + + + + + + + + + + + + + + + + + + Beste ,
+
+ Hier is uw factuur;
+ datum:
+ total:
+ clickje +
+
+ + + + +
+
+ Groeten,
+
+
+ + + + + + + + + AND role is in + + + + + + + +
\ No newline at end of file diff --git a/vasc-xpql/src/test/resources/xpql/test-meta.xml b/vasc-xpql/src/test/resources/xpql/test-meta.xml new file mode 100644 index 0000000..245cb2a --- /dev/null +++ b/vasc-xpql/src/test/resources/xpql/test-meta.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/vasc-xpql/src/test/resources/xpql/tests.xml b/vasc-xpql/src/test/resources/xpql/tests.xml new file mode 100644 index 0000000..6e2df4a --- /dev/null +++ b/vasc-xpql/src/test/resources/xpql/tests.xml @@ -0,0 +1,47 @@ + + + + + LIMIT + + + + + + OFFSET + + + + + + + + + + SELECT + USERS.USERNAME AS USERNAME + USERS.PASSWD AS PASSWORD + FROM + USERS + + Bla bla + Also see this site http://www.google.com + + + + + + + + + AND role is in + + + + + + + + \ No newline at end of file