WIP: left over open files for long...
This commit is contained in:
parent
0a2398c5c1
commit
76aa74990e
165 changed files with 4299 additions and 3373 deletions
|
|
@ -1,47 +1,30 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>vasc-lib</artifactId>
|
||||
<groupId>net.forwardfire.vasc.lib</groupId>
|
||||
<version>0.4.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>vasc-lib-xpql</artifactId>
|
||||
<name>vasc-lib-xpql</name>
|
||||
<description>vasc xpql parser for queries.</description>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.x4o</groupId>
|
||||
<artifactId>x4o-driver</artifactId>
|
||||
<version>${x4o.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.x4o</groupId>
|
||||
<artifactId>x4o-meta</artifactId>
|
||||
<version>${x4o.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet.jsp</groupId>
|
||||
<artifactId>jsp-api</artifactId>
|
||||
<version>${jsp-api.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.ejb</groupId>
|
||||
<artifactId>ejb-api</artifactId>
|
||||
<version>${ejb-api.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.persistence</groupId>
|
||||
<artifactId>persistence-api</artifactId>
|
||||
<version>${persistence-api.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.transaction</groupId>
|
||||
<artifactId>jta</artifactId>
|
||||
<version>${jta.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>vasc-lib</artifactId>
|
||||
<groupId>net.forwardfire.vasc.lib</groupId>
|
||||
<version>0.4.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>vasc-lib-xpql</artifactId>
|
||||
<name>vasc-lib-xpql</name>
|
||||
<description>vasc xpql parser for queries.</description>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.x4o</groupId>
|
||||
<artifactId>x4o-driver</artifactId>
|
||||
<version>${x4o.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.x4o</groupId>
|
||||
<artifactId>x4o-meta</artifactId>
|
||||
<version>${x4o.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax</groupId>
|
||||
<artifactId>javaee-api</artifactId>
|
||||
<version>${javaee-api.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -161,10 +161,8 @@ public class XpqlQueryManagerImpl implements XpqlQueryManager.ILocal,XpqlQueryMa
|
|||
|
||||
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 +="=========== Edit: "+q.getName()+"\n";
|
||||
out +=q.toEdit(q);
|
||||
out +="=========== Prepard: "+q.getName()+"\n";
|
||||
out +=q.toPreparedSQL(q)+"\n";
|
||||
logger.finer("FOUND Query: "+out);
|
||||
|
|
|
|||
|
|
@ -30,18 +30,11 @@ import net.forwardfire.vasc.xpql.query.QueryPart;
|
|||
/**
|
||||
* This class defines an executable SQL query.
|
||||
*
|
||||
* @author Willem Cazander, Arjan Tijms
|
||||
* @version 1.0 17/11/2004
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 4, 2007
|
||||
* @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 net.forwardfire.vasc.xpql.query.AbstractQueryPart#toEdit()
|
||||
|
|
@ -54,7 +47,7 @@ public class DefaultQuery extends AbstractQuery {
|
|||
}
|
||||
return queryBuffer.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.xpql.query.AbstractQueryPart#toPreparedSQL()
|
||||
*/
|
||||
|
|
@ -67,7 +60,7 @@ public class DefaultQuery extends AbstractQuery {
|
|||
}
|
||||
return queryBuffer.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.xpql.query.AbstractQueryPart#toSQL()
|
||||
*/
|
||||
|
|
@ -79,49 +72,6 @@ public class DefaultQuery extends AbstractQuery {
|
|||
}
|
||||
return queryBuffer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.xpql.query.AbstractQueryPart#toXML()
|
||||
*/
|
||||
@Override
|
||||
public String toXML(Query query) {
|
||||
StringBuffer queryBuffer = new StringBuffer();
|
||||
|
||||
queryBuffer.append("\t<query name=\""+getName()+"\" type=\""+getType()+"\">\n");
|
||||
|
||||
for (String key:getPropertyKeys()) {
|
||||
queryBuffer.append("\t\t<x4o:property name=\""+key+"\" value=\""+getPropertyString(key)+"\"/>\n");
|
||||
}
|
||||
|
||||
queryBuffer.append("\t\t<sql>");
|
||||
for ( QueryPart queryPart:getQueryParts() ) {
|
||||
queryBuffer.append( queryPart.toXML(query) );
|
||||
}
|
||||
queryBuffer.append("</sql>\n");
|
||||
|
||||
for ( String comment:getQueryComments()) {
|
||||
queryBuffer.append("\t\t<comment>");
|
||||
queryBuffer.append(comment);
|
||||
queryBuffer.append("</comment>\n");
|
||||
}
|
||||
|
||||
for ( QueryParameterValue qpv:getLocalQueryParameterValues()) {
|
||||
queryBuffer.append("\t\t<parameterValue ");
|
||||
queryBuffer.append("name=\""+qpv.getName()+"\" ");
|
||||
if (qpv.getValue()!=null) {
|
||||
queryBuffer.append("value=\""+qpv.getValue()+"\" ");
|
||||
}
|
||||
if (qpv.getDefaultValue()!=null) {
|
||||
queryBuffer.append("defaultValue=\""+qpv.getDefaultValue()+"\" ");
|
||||
}
|
||||
queryBuffer.append("type=\""+qpv.getType()+"\" ");
|
||||
queryBuffer.append("/>\n");
|
||||
}
|
||||
|
||||
queryBuffer.append("\t</query>\n");
|
||||
|
||||
return queryBuffer.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query clone() throws CloneNotSupportedException {
|
||||
|
|
|
|||
|
|
@ -26,51 +26,48 @@ import org.x4o.xml.io.X4OReader;
|
|||
|
||||
import net.forwardfire.vasc.xpql.QueryStore;
|
||||
import net.forwardfire.vasc.xpql.XPQLDriver;
|
||||
import net.forwardfire.vasc.xpql.query.AbstractQueryPart;
|
||||
import net.forwardfire.vasc.xpql.query.Query;
|
||||
import net.forwardfire.vasc.xpql.query.QueryPart;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Handled included query parts
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 4, 2007
|
||||
*/
|
||||
public class QueryInclude extends AbstractQueryPart {
|
||||
public class QueryInclude implements QueryPart {
|
||||
|
||||
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) {
|
||||
|
|
@ -105,14 +102,6 @@ public class QueryInclude extends AbstractQueryPart {
|
|||
return query.getQueryStore().getQuery(getName()).toPreparedSQL(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toXML(Query query) {
|
||||
if (resource==null) {
|
||||
return "<include name=\""+name+"\"/>";
|
||||
}
|
||||
return "<include name=\""+name+"\" resource=\""+resource+"\"/>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toEdit(Query query) {
|
||||
if (resource==null) {
|
||||
|
|
@ -128,4 +117,4 @@ public class QueryInclude extends AbstractQueryPart {
|
|||
include.setResource(getResource());
|
||||
return include;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,20 +26,18 @@ import java.util.ArrayList;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import net.forwardfire.vasc.xpql.query.AbstractQueryPart;
|
||||
import net.forwardfire.vasc.xpql.query.Query;
|
||||
import net.forwardfire.vasc.xpql.query.Query.QueryType;
|
||||
import net.forwardfire.vasc.xpql.query.QueryParameterValue;
|
||||
import net.forwardfire.vasc.xpql.query.QueryPart;
|
||||
|
||||
|
||||
/**
|
||||
* QueryParameter.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 4, 2007
|
||||
*/
|
||||
public class QueryParameter extends AbstractQueryPart {
|
||||
public class QueryParameter implements QueryPart {
|
||||
|
||||
private String name = null;
|
||||
|
||||
|
|
@ -49,7 +47,7 @@ public class QueryParameter extends AbstractQueryPart {
|
|||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param name the name to set
|
||||
*/
|
||||
|
|
@ -199,11 +197,6 @@ public class QueryParameter extends AbstractQueryPart {
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toXML(Query query) {
|
||||
return "<parameter name=\"" + getName() + "\"/>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toEdit(Query query) {
|
||||
return "@"+getName();
|
||||
|
|
@ -215,4 +208,4 @@ public class QueryParameter extends AbstractQueryPart {
|
|||
p.setName(getName());
|
||||
return p;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
package net.forwardfire.vasc.xpql.impl;
|
||||
|
||||
import net.forwardfire.vasc.xpql.query.AbstractQueryPart;
|
||||
import net.forwardfire.vasc.xpql.query.Query;
|
||||
import net.forwardfire.vasc.xpql.query.QueryPart;
|
||||
|
||||
|
|
@ -31,7 +30,7 @@ import net.forwardfire.vasc.xpql.query.QueryPart;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 4, 2007
|
||||
*/
|
||||
public class QueryText extends AbstractQueryPart {
|
||||
public class QueryText implements QueryPart {
|
||||
|
||||
String text = null;
|
||||
|
||||
|
|
@ -54,10 +53,20 @@ public class QueryText extends AbstractQueryPart {
|
|||
return text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toPreparedSQL(Query query) {
|
||||
return toSQL(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toEdit(Query query) {
|
||||
return toSQL(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryPart clone() throws CloneNotSupportedException {
|
||||
QueryText text = new QueryText();
|
||||
text.setText(getText());
|
||||
return text;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ import net.forwardfire.vasc.xpql.impl.DefaultQueryParameterValue;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 4, 2007
|
||||
*/
|
||||
abstract public class AbstractQuery extends AbstractQueryPart implements Query {
|
||||
abstract public class AbstractQuery implements Query {
|
||||
|
||||
private String name = null;
|
||||
private List<QueryPart> queryParts = null;
|
||||
|
|
|
|||
|
|
@ -1,92 +0,0 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.xpql.query;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 4, 2007
|
||||
*/
|
||||
abstract public class AbstractQueryPart implements QueryPart {
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.xpql.query.QueryPart#toSQL()
|
||||
*/
|
||||
@Override
|
||||
abstract public String toSQL(Query query);
|
||||
|
||||
/**
|
||||
* Returns the toSQL() retult.
|
||||
* @see net.forwardfire.vasc.xpql.query.QueryPart#toPreparedSQL()
|
||||
*/
|
||||
@Override
|
||||
public String toPreparedSQL(Query query) {
|
||||
return toSQL(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* XML escapes the toSQL() return String.
|
||||
* @see net.forwardfire.vasc.xpql.query.QueryPart#toXML()
|
||||
*/
|
||||
@Override
|
||||
public String toXML(Query query) {
|
||||
return escapeXML(toSQL(query));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the toSQL() retult.
|
||||
* @see net.forwardfire.vasc.xpql.query.QueryPart#toEdit()
|
||||
*/
|
||||
@Override
|
||||
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();
|
||||
}
|
||||
|
||||
@Override
|
||||
abstract public QueryPart clone() throws CloneNotSupportedException;
|
||||
}
|
||||
|
|
@ -23,7 +23,7 @@
|
|||
package net.forwardfire.vasc.xpql.query;
|
||||
|
||||
/**
|
||||
* QueryPart
|
||||
* QueryPart is a sub part of a full query.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 4, 2007
|
||||
|
|
@ -44,13 +44,6 @@ public interface QueryPart extends Cloneable {
|
|||
*/
|
||||
String toPreparedSQL(Query query);
|
||||
|
||||
/**
|
||||
* This method is for building the XML version of the query part.
|
||||
* This version is intended for storage.
|
||||
* @return
|
||||
*/
|
||||
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.
|
||||
|
|
@ -59,7 +52,7 @@ public interface QueryPart extends Cloneable {
|
|||
String toEdit(Query query);
|
||||
|
||||
/**
|
||||
* Force impl to have public clone methode
|
||||
* Force impl to have public clone method.
|
||||
* @return
|
||||
* @throws CloneNotSupportedException
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue