"Enke, Michael" wrote:
>
> Vadim Gritsenko wrote:
> >
> > Enke, Michael wrote:
> >
> > >I tried it now under Windows ME:
> > >The swap file C:\WINDOWS\WIN386.SWP
> > >was growing until C:\ was full (swap file size about 500 MB) :-(
> > >
> >
> > But this means that this is not related to Java - Java's total memory is
> > limited to ... whatever you specify.
> >
> > Or this can be bug in JDK (less possible). What do you think?
here I post the problematic file. I let it run from command line after setting
CLASSPATH:
java -Djdbc.drivers=$my_DB_driver_class org.apache.cocoon.Main -c . -u ERROR
test801.xml
(no further transformation).
Interesting are only the last few lines where I produce the mass data
(for loop with createRow method). I print the rownumber to System.out.
1) I changed the namespace for esql logicsheet so that esql is not applied:
At line 1271 there is a one second delay,
after this it is going on. That's probably the gc? I don't know.
The memory consumption is ok (20 ... 25 percent).
2) With correct namespace, when esql is applied, it blocks at rowNumber 1271,
sometimes for one minute, sometimes forever.
I use only one sql statement: String SQL_QUERY="select 0,0" (I have postgres)
so you can easily change for other DB system, e.g. select 0 from dual (for Oracle)
I watch the memory usage with the command "top" (on linux), delay between updates
1 second, sort by memory usage. The percent MEM is: 20% ... 30% ... 40% ...
50% ... 82% ... 42% ... 60% ... 70% ... 80% ... 80% ... 80% ... always 80%
I have 320MB physical memory and 264MB swap space.
StoreJanitor settings are the default values from cocoon.xconf
If I cut some code before the for loop (which has no relevance to the loop),
the blocking disappears, than there is only delay of 1 second ... 1 minute,
depends how mutch code is removed.
Maybe this a problem of StoreJanitor?
I appreciate for any help.
Michael
<?xml version="1.0" encoding="UTF-8"?>
<xsp:page
xmlns:xsp="http://apache.org/xsp"
xmlns:esql="http://apache.org/cocoon/SQL/v2-myown"
xmlns:xsp-request="http://apache.org/xsp/request/2.0"
xmlns:i18n="http://apache.org/cocoon/i18n/2.0" encoding="UTF-8"
xmlns:util="http://apache.org/xsp/util/2.0"
>
<xsp:structure>
<!-- ME: REMOVE IF DB RUNNING -->
<xsp:include>java.io.*</xsp:include>
<!-- ME: REMOVE IF DB RUNNING -->
<xsp:include>java.lang.reflect.*</xsp:include>
<xsp:include>java.util.*</xsp:include>
<xsp:include>java.text.*</xsp:include>
<xsp:include>java.net.URLEncoder</xsp:include>
<xsp:include>org.apache.cocoon.acting.LocaleAction</xsp:include>
</xsp:structure>
<xsp:logic>
String SQL_QUERY="select 0,0";
// which encoding the html-request uses (same as in
// sitemap defined - if not: default is UTF-8)
static final String formEncoding = "UTF-8",
// will become unnecessary in a future postgres version
// dbEncoding and calypsoEncoding must be the
// postgres names for the encodings
// encoding of database
dbEncoding="UNICODE",
// encoding of Calypso data
calypsoEncoding="LATIN1";
static final int unknown = 0, html = 1, fo = 2, csv = 3, xml = 4,
Header = 0, Rows = 1, Footer = 2, Misc = 3, MaxA = Misc,
/* the next one are bits! so only use 2^x */
RETURN_NEXT_ROW_DIFFERENT = 1,
RETURN_NEXT_ROW_NOT_DIFFERENT = 2,
RETURN_NEXT_ROW_FROM_METHOD = 4,
RETURN_HIDE_ROW = 8;
String label[], column[], width[], span[],
widthG[][] = new String[Footer + 1][],
spanG[][] = new String[Footer + 1][],
th_align[], align[],
color[], linkDescText[][],
linkDescTextG[][][] = new String[Footer + 1][][],
replaceGFound[][] = new String[Footer + 1][],
replaceGNew[][] = new String[Footer + 1][],
replaceFound[], replaceNew[];
String alignG[][] = new String[Footer + 1][],
colorG[][] = new String[Footer + 1][];
boolean percentBool[], percent3Bool[], numberBool[], num3Bool[], bits[],
timeBool[], dateTimeBool[], timeDiffBool[], priceBool[],
textI18nBool[],
percentGBool[][] = new boolean[Footer + 1][],
percent3GBool[][] = new boolean[Footer + 1][],
numberGBool[][] = new boolean[Footer + 1][],
num3GBool[][] = new boolean[Footer + 1][],
timeGBool[][] = new boolean[Footer + 1][],
dateTimeGBool[][] = new boolean[Footer + 1][],
timeDiffGBool[][] = new boolean[Footer + 1][],
priceGBool[][] = new boolean[Footer + 1][],
textI18nGBool[][] = new boolean[Footer + 1][],
boldGBool[][] = new boolean[Footer + 1][],
replaceGBool[][] = new boolean[Footer + 1][],
wrapBoolG[][] = new boolean[Footer + 1][],
linkGBool[][] = new boolean[Footer + 1][],
boldBool[], replaceBool[], sumAllBool[], wrapBool[],
linkBool[], groupOnBool[];
int cc, linkDescNum[][], thisPageFormat, groupOnIndex[],
linkDescNumG[][][] = new int[Footer + 1][][], bitsNum[],
numColsInSUM;
double sumAllDouble[], sumPartDouble[];
String httpRequest, httpRequestForLink, calypsoLocale,
specialFormatS, commonFormatS = "", linkPageExt,
specialFormatA[][] = new String[MaxA + 1][],
commonFormatA[][] = new String[MaxA + 1][],
groupOnOld[], storeLocale;
StringBuffer queryCond = null;
DateFormat df, tf;
final int LINKLEN = 4;
double merk[] = new double[2];
private String composeQuery(String q, String q_cond) {
int indexOf$conditions$ = 0;
while((indexOf$conditions$ = q.indexOf("$conditions$", indexOf$conditions$)) != -1) {
if(q_cond.length() == 0) {
String behind$conditions$ = q.substring(indexOf$conditions$ +
"$conditions$".length()).trim();
if(behind$conditions$.startsWith("and ")) {
q = q.substring(0,indexOf$conditions$+"$conditions$".length());
q = q + " where ";
q = q + behind$conditions$.substring("and ".length());
}
}
indexOf$conditions$++;
}
return q.replaceAll("\\$conditions\\$", q_cond).replaceAll("\\$locale\\$",
calypsoLocale);
}
static private String conv_bytes(String column, int startWith){
StringBuffer sb = new StringBuffer();
boolean p_first = true;
for(int i=0;i<column.length();i++) {
if(column.charAt(i)=='1') {
if(!p_first) sb.append(", ");
else p_first = false;
sb.append(i+startWith);
}
}
return sb.toString();
}
static private String delete(String string, String from, String to) {
String tailString = "";
if(string != null && string.length() > 0) {
int ind = string.indexOf(from);
if(ind != -1) {
if(string.indexOf(to,ind)!= -1)
tailString = string.substring(string.indexOf(to,ind)+1);
string = string.substring(0,ind) + tailString;
}
}
else string = "";
return string;
}
private int getInt(int ret, String pattern, int rowType, int elem) {
String s = getString(pattern, rowType, elem);
if(s != null) {
try {
ret = Integer.parseInt(s);
} catch(NumberFormatException nfe) {}
}
return ret;
}
private String getString(String pattern, int rowType, int elem) {
String[] _first = specialFormatA[rowType];
String[] _second = commonFormatA[rowType];
String ret = null;
int startIndex, endIndex;
String first = ( _first != null && _first.length > elem) ?
_first[elem] : null;
String second = (_second != null && _second.length > elem) ?
_second[elem] : null;
if(second != null) {
if((startIndex = second.indexOf(pattern)) != -1) {
if(startIndex > 0 && second.charAt(startIndex - 1) != ',') {
/* this is if pattern is part of string accidentally, e.g. hnumber contains
number */
startIndex = second.indexOf("," + pattern);
if(startIndex != -1) startIndex++;
}
if(startIndex != -1) {
startIndex += pattern.length();
endIndex = second.indexOf(",",startIndex);
if(endIndex == -1) endIndex = second.length();
ret = second.substring(startIndex, endIndex);
}
}
}
if(first != null) {
if((startIndex = first.indexOf(pattern)) != -1) {
if(startIndex > 0 && first.charAt(startIndex - 1) != ',') {
/* this is if pattern is part of string accidentally, e.g. hnumber contains
number */
startIndex = first.indexOf("," + pattern);
if(startIndex != -1) startIndex++;
}
if(startIndex != -1) {
startIndex += pattern.length();
endIndex = first.indexOf(",",startIndex);
if(endIndex == -1) endIndex = first.length();
ret = first.substring(startIndex, endIndex);
}
}
}
return ret;
}
private boolean getBoolean(String pattern, int rowType, int elem) {
return (getString(pattern, rowType, elem) == null) ? false : true;
}
private String getWidth(String pattern, int rowType, int elem) {
String ret = getString(pattern, rowType, elem);
if(ret == null || ret.length() == 0) {
if(thisPageFormat == html) ret = "50";
else if(thisPageFormat == fo) ret = "30mm";
else ret = "50";
}
return ret;
}
private boolean getReplace(String pattern, int rowType, int elem) {
boolean ret = false;
int col = elem;
String s = getString(pattern, rowType, elem);
if(s != null) {
ret = true;
int index = s.indexOf("|");
if(index == -1) {
replaceGFound[rowType][col] = null;
replaceGNew[rowType][col] = s;
} else {
replaceGFound[rowType][col] = s.substring(0,index);
replaceGNew[rowType][col] = s.substring(index+1,s.length());
}
}
return ret;
}
private boolean getLink(String pattern, int rowType, int elem) {
boolean ret = false;
int col = elem;
String s = getString(pattern, rowType, elem);
if(s != null && s.length() > 0) {
ret = true;
linkDescTextG[rowType][col] = new String[LINKLEN];
linkDescNumG[rowType][col] = new int[LINKLEN];
StringTokenizer st = new StringTokenizer(s,"$");
for(int i=0;i < LINKLEN; i++) {
if(st.hasMoreTokens()) {
linkDescTextG[rowType][col][i] = st.nextToken();
}
else linkDescTextG[rowType][col][i] = "";
if(st.hasMoreTokens()) {
String nextToken = st.nextToken();
try {
linkDescNumG[rowType][col][i] = Integer.parseInt(nextToken);
/* if column %3D (=) is in link, remove conditions
* %3E%3D (<=) and %3C%3D (>=)
*/
int end = -1;
int start = linkDescTextG[rowType][col][i].lastIndexOf("&");
/* last codeline means: column name in httpRequest must be
* prepended with & and not with ? -> must be one arg
* before, e.g. the report id
*/
String columnName = null;
if(start > -1) {
columnName = linkDescTextG[rowType][col][i].substring(start+1);
/* start+1: delete() deletes inclusive last string-arg (&) */
end = columnName.indexOf("%3D");
if(end > -1) {
columnName = columnName.substring(0,end);
httpRequestForLink = delete(httpRequestForLink,columnName+"%3E%3D","&");
httpRequestForLink = delete(httpRequestForLink,columnName+"%3C%3D","&");
}
}
} catch(NumberFormatException nfe) {
if(nextToken.equals("-")) {
linkDescNumG[rowType][col][i] = -2;
} else {
linkDescNumG[rowType][col][i] = -1;
}
}
} else linkDescNumG[rowType][col][i] = -1;
if(i==0 && linkDescTextG[rowType][col][i] != null)
linkDescTextG[rowType][col][i] =
linkDescTextG[rowType][col][i].replaceFirst("\\.htmlpdf", linkPageExt);
}
}
return ret;
}
private void copyArrays(int rowType) {
System.arraycopy(widthG[rowType],0,width,0,cc);
System.arraycopy(spanG[rowType],0,span,0,cc);
System.arraycopy(alignG[rowType],0,align,0,cc);
System.arraycopy(colorG[rowType],0,color,0,cc);
System.arraycopy(numberGBool[rowType],0,numberBool,0,cc);
System.arraycopy(percentGBool[rowType],0,percentBool,0,cc);
System.arraycopy(percent3GBool[rowType],0,percent3Bool,0,cc);
System.arraycopy(num3GBool[rowType],0,num3Bool,0,cc);
System.arraycopy(timeGBool[rowType],0,timeBool,0,cc);
System.arraycopy(dateTimeGBool[rowType],0,dateTimeBool,0,cc);
System.arraycopy(timeDiffGBool[rowType],0,timeDiffBool,0,cc);
System.arraycopy(priceGBool[rowType],0,priceBool,0,cc);
System.arraycopy(textI18nGBool[rowType],0,textI18nBool,0,cc);
System.arraycopy(boldGBool[rowType],0,boldBool,0,cc);
System.arraycopy(linkGBool[rowType],0,linkBool,0,cc);
System.arraycopy(linkDescTextG[rowType],0,linkDescText,0,cc);
System.arraycopy(linkDescNumG[rowType],0,linkDescNum,0,cc);
System.arraycopy(replaceGBool[rowType],0,replaceBool,0,cc);
System.arraycopy(replaceGFound[rowType],0,replaceFound,0,cc);
System.arraycopy(replaceGNew[rowType],0,replaceNew,0,cc);
System.arraycopy(wrapBoolG[rowType],0,wrapBool,0,cc);
}
private String[] getFormatA(String s, String type, java.sql.ResultSetMetaData rmd) {
if(s == null) return null;
int typeFound = s.indexOf(type+"[");
if(typeFound == -1) return null;
String array1[] = s.substring(typeFound+(type+"[").length(),
s.indexOf("]",typeFound)).split(";", -1);
if(rmd == null) return array1;
String array2[] = new String[cc];
String match = "";
boolean foundOne = false;
for(int i=0;i<cc;i++) {
try {
match=rmd.getColumnLabel(i+1)+":";
} catch(java.sql.SQLException sqle) {}
for(int j=0;j<array1.length;j++) {
if(array1[j].startsWith(match)) {
array2[i] = array1[j].substring(match.length());
foundOne = true;
}
}
}
if(foundOne) return array2;
else return array1;
}
private void createRow(int colNum, AttributesImpl xspAttr)
throws SAXException {
<xsp:content>
<row><xsp:logic>
for (int i = 0; i < colNum; i++) {
<c><v><xsp:expr>column[i]</xsp:expr></v></c>
}
</xsp:logic></row>
</xsp:content>
}
</xsp:logic>
<page>
<esql:connection>
<esql:use-limit-clause/>
<esql:pool>calypso</esql:pool>
<xsp:logic>
Object reflectionObject = null, reflectionArglist[] = null;
int groupOnCount = 0, rownumCol = -1;
int numberAllRows = 0, numberPartRows = 0, numberGroupRows = 0,
col_num = -1, rowMethodReturn = 0;
final String[] fileDateTimeFor = {"srvlog", "ej"};
final String[] fileDateTimeColumn = {"ultimestamp", "datetime"};
final String[] fileDateTimeName = {"Server Log:", "Datacapture:"};
boolean nextPage = false, nextDifferent = false, hadMoreResults;
String thisPage=<xsp-request:get-uri/>;
String report = "";
{
int start, end;
start = thisPage.lastIndexOf("/")+1;
end = thisPage.indexOf(".");
if(end > 0) report = thisPage.substring(start, end);
else report = thisPage.substring(start);
}
int MAXROWS = 999999999;
int maxRows = 200;
if(thisPage.endsWith(".html")) { thisPageFormat = html; linkPageExt = ".html"; }
else if(thisPage.endsWith(".fo")) { thisPageFormat = fo; linkPageExt = ".fo"; }
else if(thisPage.endsWith(".pdf")) { thisPageFormat = fo; linkPageExt = ".pdf"; }
else if(thisPage.endsWith(".ps")) { thisPageFormat = fo; linkPageExt = ".ps"; }
else if(thisPage.endsWith(".rtf")) { thisPageFormat = fo; linkPageExt = ".rtf"; }
else if(thisPage.endsWith(".csv")) { thisPageFormat = csv; linkPageExt = ".csv"; }
else if(thisPage.endsWith(".xml")) { thisPageFormat = xml; linkPageExt = ".xml";
maxRows = 20000; }
else { thisPageFormat = unknown; linkPageExt = ".unknown"; }
int skipRows = 0;
long count = 0;
String skipRowsS = <xsp-request:get-parameter name="skipRows"/>;
if(skipRowsS != null && skipRowsS.length() > 0)
try { skipRows = Integer.parseInt(skipRowsS); }
catch(NumberFormatException pe) { }
httpRequest = <xsp-request:get-query-string/>;
httpRequestForLink = httpRequest;
String reportTitle = "", directTitle = "", userMethods = "",
translationPrefix = "";
String printDuplex = <xsp-request:get-parameter name="printDuplex"/>;
if(printDuplex == null) printDuplex = "";
String abbrevList = "";
df = DateFormat.getDateTimeInstance
(DateFormat.MEDIUM,DateFormat.MEDIUM,Locale.US);
tf = DateFormat.getTimeInstance
(DateFormat.MEDIUM,Locale.US);
Date date = new Date(0);
Locale locale = Locale.getDefault();
String l = Locale.getDefault().getLanguage(),
c = Locale.getDefault().getCountry(),
v = Locale.getDefault().getVariant();
try {
String lc = LocaleAction.getLocaleAttribute(objectModel, "locale");
String[] matches = lc.split("[_@.]");
if(matches.length > 0) {
l = matches[0]; c=""; v="";
c = matches.length > 1 ? matches[1] : c;
v = matches.length > 2 ? matches[2] : v;
}
locale = new Locale(l, c, v);
} catch(Exception e) { System.out.println(e);}
calypsoLocale = "en"; // default locale
/* THIS IS ONLY FOR SUPINT:FUNCDESC!!! IF REQUIRED FOR OTHERS
* IT HAS TO BE IMPLEMENTED
* The problem here is: It may exist funcdesc.en and funcdesc.en_US but
* only prof_hlp.en, no prof_hlp.en_US
*/
<xsp:content>
<esql:execute-query>
<esql:query>
<xsp:expr>SQL_QUERY</xsp:expr>
<!--select distinct locale from translations where
file = 'supint.funcdesc' and
(lower(locale) like '<xsp:expr>l.toLowerCase()</xsp:expr>' or
lower(locale) like
'<xsp:expr>l.toLowerCase()</xsp:expr>_<xsp:expr>c.toLowerCase()</xsp:expr>' or
lower(locale) like
'<xsp:expr>l.toLowerCase()</xsp:expr>_<xsp:expr>c.toLowerCase()</xsp:expr>_<xsp:expr>v.toLowerCase()</xsp:expr>'
)
order by locale desc limit 1 -->
</esql:query>
<esql:results>
<esql:row-results>
<xsp:logic>
calypsoLocale = "en";
//<!--esql:get-string column="locale" null="en"/-->;
</xsp:logic>
</esql:row-results>
</esql:results>
</esql:execute-query>
</xsp:content>
boolean sumAllTrue = false;
DateFormat dfs = DateFormat.getDateInstance
(DateFormat.MEDIUM, locale);
NumberFormat nfQty = NumberFormat.getInstance(Locale.US);
nfQty.setMinimumFractionDigits(3);
nfQty.setMaximumFractionDigits(3);
if(report == null) report = "";
</xsp:logic>
<body>
<xsp:logic>
if(printDuplex.length() > 0) {
<print-duplex><xsp:expr>printDuplex</xsp:expr></print-duplex>
}
</xsp:logic>
<print-date-time><i18n:date-time pattern="medium"/></print-date-time>
<xsp:logic>
if(report.startsWith("C006")) {
if(<xsp-request:get-parameter name="uchpriceoption="/> != null &&
!<xsp-request:get-parameter name="uchpriceoption="/>.equals("0"))
report = "C006a"+<xsp-request:get-parameter name="uchpriceoption="/>;
}
<!-- ME: REMOVE IF DB RUNNING -->
Runtime rt = Runtime.getRuntime();
try { Process p = rt.exec("/var/lib/pgsql/webapp/DB/xrefill.sh "+report);
p.waitFor(); }
catch(InterruptedException ie) {}
catch(IOException io) {}
<!-- ME: REMOVE IF DB RUNNING -->
String query = "", countQuery = "";
queryCond = new StringBuffer(" where ");
</xsp:logic>
<store>
<i18n:text>store number</i18n:text>
<esql:execute-query>
<esql:query>
<xsp:expr>SQL_QUERY</xsp:expr>
<!--select name from poslits where id = 101;-->
</esql:query>
<esql:results>
<esql:row-results>
<esql:get-string column="1" encoding="UTF-8" null="store name is null"/>
</esql:row-results>
</esql:results>
<esql:no-results>
<name>No Store Name found!</name>
</esql:no-results>
</esql:execute-query>
</store>
<!-- get the storeLocale -->
<esql:execute-query>
<esql:query>
<xsp:expr>SQL_QUERY</xsp:expr>
<!--select locale from media where medcurrnmbr = 0 and medcurrflag = 0-->
</esql:query>
<esql:results>
<esql:row-results>
<xsp:logic>
storeLocale = "en_US";
// <!--esql:get-string column="1" null="en_US"/-->;
</xsp:logic>
</esql:row-results>
</esql:results>
<esql:no-results>
<xsp:logic>storeLocale = "en_US";</xsp:logic>
</esql:no-results>
</esql:execute-query>
<report-heading>
<esql:execute-query>
<esql:query>
<xsp:expr>SQL_QUERY</xsp:expr>
<!--select text from scf where
structmember = 'gstBcfParam.stRptOptions.aszRpt80ColLiterals' and
index = 0-->
</esql:query>
<esql:results>
<esql:row-results>
<esql:get-string column="1" encoding="UTF-8" null=""/>
</esql:row-results>
</esql:results>
</esql:execute-query>
</report-heading>
<esql:execute-query>
<esql:query>
<xsp:expr>SQL_QUERY</xsp:expr>
<!--select direct_title, query, user_methods,
html_format, pdf_format, common_format,
abbrevlist, count_query
from r_menu where id = '<xsp:expr>report</xsp:expr>'-->
</esql:query>
<esql:results>
<esql:row-results>
<xsp:logic>
directTitle = "a";
//<!--esql:get-string column="direct_title" null=""/-->;
userMethods = "";
//<!--esql:get-string column="user_methods" null=""/-->;
if(thisPageFormat == fo) {
specialFormatS = "";
//<!--esql:get-string column="pdf_format" null=""/-->;
}
else { /* for html and all other */
specialFormatS = "";
//<!--esql:get-string column="html_format" null=""/-->;
}
commonFormatS = "";
//<!--esql:get-string column="common_format" null=""/-->;
if(commonFormatS.indexOf("group-on") != -1) maxRows=MAXROWS;
specialFormatA[Misc]=getFormatA(specialFormatS, "MISC", null);
commonFormatA[Misc]=getFormatA(commonFormatS, "MISC", null);
if(thisPageFormat == fo && getBoolean("landscape",Misc,0))
{<landscape/>}
reportTitle = getString("caption=",Misc,0);
if(reportTitle == null || reportTitle.length() == 0) {
reportTitle = report + "_caption";
}
query = SQL_QUERY;
//<!--esql:get-string column="query" null=""/-->;
String specialQuery = getString("query=",Misc,0);
if(specialQuery != null && specialQuery.length() > 0) query =
specialQuery;
translationPrefix = getString("transprefix=",Misc,0);
if(translationPrefix == null || translationPrefix.length() == 0) {
translationPrefix = report;
}
/* START: PATCH THE ORDER BY CLAUSE */
int orderBy = query.indexOf("order by ");
if(orderBy != -1) {
StringTokenizer stOrderBy = new StringTokenizer(query.
substring(orderBy+"order by ".length()),",");
StringBuffer querySB = new StringBuffer(
query.substring(0,orderBy+"order by ".length()));
while(stOrderBy.hasMoreTokens()) {
String tmpS = stOrderBy.nextToken().trim();
StringTokenizer spaceST = new StringTokenizer(tmpS," ");
String col = spaceST.nextToken();
String colWoDot = null;
if(col.indexOf(".") == -1) colWoDot = col;
else colWoDot = col.substring(col.indexOf(".")+1);
<esql:execute-query>
<esql:query>
<xsp:expr>SQL_QUERY</xsp:expr>
<!--select length, lpad_order from datatypes where colname =
'<xsp:expr>colWoDot</xsp:expr>'-->
</esql:query>
<esql:results>
<esql:row-results>
<xsp:logic>
if(true) {
querySB.append("lpad(" + col + "," +
"a" + ",'").
append("b").append("')");
}
else querySB.append(col);
</xsp:logic>
</esql:row-results>
</esql:results>
<esql:no-results>
<xsp:logic>
querySB.append(col);
</xsp:logic>
</esql:no-results>
</esql:execute-query>
if(spaceST.countTokens() > 0) {
while(spaceST.hasMoreTokens()) querySB.append(" " + spaceST.nextToken());
break;
}
if(stOrderBy.countTokens() > 0) querySB.append(", ");
}
while(stOrderBy.hasMoreTokens()) querySB.append("," + stOrderBy.nextToken());
query = querySB.toString();
}
/* END: PATCH THE ORDER BY CLAUSE */
if(query.indexOf(" group ") != -1) maxRows = MAXROWS;
abbrevList = "";
//<!--esql:get-string column="abbrevlist" null=""/-->;
countQuery="";
//<!--esql:get-string column="count_query" null=""/-->;
</xsp:logic>
</esql:row-results>
</esql:results>
</esql:execute-query>
<xsp:logic>
/* to avoid an exception in case no query was given */
if(query.length() < 7)
query = SQL_QUERY;
Method methodHandleQuery = null, methodHandleHeader = null,
methodHandleRows = null, methodHandleFooter = null;
if(userMethods.length() > 0) {
Class argType[] = null;
try {
argType = new Class[] {
String.class,
java.sql.ResultSetMetaData.class,
java.sql.Connection.class,
String.class,
String[].class,
(new double[0]).getClass(),
(new double[0]).getClass(),
Object[].class
};
// allocate new reflectionArglist here because of performance:
// don't allocate for every row!!!
reflectionArglist = new Object[argType.length];
} catch (Exception e) { System.out.println("Exception in reflection: "+e); }
StringTokenizer stum = new StringTokenizer(userMethods,",");
while(stum.hasMoreTokens()) {
String userMethod = stum.nextToken();
String classString = userMethod.substring(0,userMethod.lastIndexOf("."));
String methodString = userMethod.substring(userMethod.lastIndexOf(".")+1);
try {
Class newClass = Class.forName(classString);
reflectionObject = newClass.newInstance();
if(methodString.indexOf("HandleQuery") > -1)
methodHandleQuery = newClass.getMethod(methodString, argType);
else if(methodString.indexOf("HandleHeader") > -1)
methodHandleHeader = newClass.getMethod(methodString, argType);
else if(methodString.indexOf("HandleRows") > -1)
methodHandleRows = newClass.getMethod(methodString, argType);
else if(methodString.indexOf("HandleFooter") > -1)
methodHandleFooter = newClass.getMethod(methodString, argType);
} catch (Exception e) {System.out.println("Exception in forName: "+e); }
}
}
</xsp:logic>
<title>
<xsp:logic>
if(directTitle.length() > 0) {
<xsp:content><xsp:expr>directTitle</xsp:expr></xsp:content>
}
else {
<xsp:content><i18n:text><xsp:expr>reportTitle</xsp:expr></i18n:text></xsp:content>
}
</xsp:logic>
</title>
<count-condition-abbrev>
<xsp:logic>
if(query.indexOf("$conditions$") > -1) {
<esql:execute-query>
<esql:query>
<xsp:expr>SQL_QUERY</xsp:expr>
<!--select t1.dbcolumn as dbcolumn, t1.relation as relation,
t1.i18n_title as i18n_title,
t1.input_type as input_type, t1.direct_title as direct_title,
t1.input_value as input_value
from formular t1, r_menu t2 where
t1.id = t2.id and
t2.id = '<xsp:expr>report</xsp:expr>' and
t1.dbcolumn != 'reportformat'
order by t1.order_by-->
</esql:query>
<esql:results>
<esql:row-results>
<xsp:logic>
String dbColumn = "a";
//<!--esql:get-string column="dbcolumn"/-->;
String relation = "b";
//<!--esql:get-string column="relation"/-->;
String i18nTitle = "";
//<!--esql:get-string column="i18n_title" encoding="UTF-8" null=""/-->;
if(i18nTitle.length() == 0) i18nTitle = dbColumn;
String dbColumn2 = null;
if(dbColumn.indexOf(".") != -1) {
dbColumn2 = dbColumn.substring(dbColumn.indexOf(".") + 1);
}
else dbColumn2 = dbColumn;
String inputType = "";
//<!--esql:get-string column="input_type" encoding="UTF-8" null=""/-->;
String inputValue = "";
//<!--esql:get-string column="input_value" encoding="UTF-8" null=""/-->;
String paramValue = ((XSPRequestHelper.getParameter
(objectModel, dbColumn + relation, null, formEncoding,
null)));
/* handle MSIE error where the "=" is part of the value! */
if(relation.equals("=") &&
(paramValue == null || paramValue.length() == 0)) {
String paramValueMSIE = ((XSPRequestHelper.getParameter
(objectModel, dbColumn, null, formEncoding, null)));
if(paramValueMSIE != null &&
paramValueMSIE.length() > 1 &&
paramValueMSIE.charAt(0) == '=') paramValue =
paramValueMSIE.substring(1);
}
if(paramValue != null && paramValue.length() > 0) {
<xsp:content>
<condition>
<description><i18n:text><xsp:expr>relation</xsp:expr></i18n:text>
<i18n:text><xsp:expr>i18nTitle</xsp:expr></i18n:text>:</description>
<xsp:logic>
String direct_title = "a";
//<!--esql:get-string column="direct_title" encoding="UTF-8"/-->;
if(direct_title != null && direct_title.length() > 0) {
if(direct_title.startsWith(" select ")) {
<esql:execute-query>
<esql:query>
<xsp:expr>SQL_QUERY</xsp:expr>
<!--<xsp:expr>direct_title</xsp:expr>-->
</esql:query>
<esql:results>
<esql:row-results>
<direct-description><i18n:text><xsp:expr>relation</xsp:expr></i18n:text>
asd:</direct-description>
</esql:row-results>
</esql:results>
</esql:execute-query>
}
else {
<direct-description><i18n:text><xsp:expr>relation</xsp:expr></i18n:text>
<xsp:expr>direct_title</xsp:expr>:</direct-description>
}
}
if(inputType.equals("text")) {
if(relation.startsWith("like")) {
paramValue = paramValue.toLowerCase();
// This will become unnecessary in a future version of postgres
queryCond.append("convert(lower(convert(").
append(dbColumn).
append(", '").
append(dbEncoding).
append("','").
append(calypsoEncoding).
append("')), '").
append(calypsoEncoding).
append("','").
append("UNICODE"). // to compare with java string
append("') ");
queryCond.append(" like ");
boolean escape = relation.equals("like-esc");
String escapedParamValue = paramValue, searchString;
boolean escapeFound = false;
char escapeSign = '|';
if(escape) {
if(paramValue.indexOf("%") != -1 || paramValue.indexOf("_") != -1) {
escapeFound = true;
escapedParamValue = paramValue.replaceAll("%", "" + escapeSign +
"%");
escapedParamValue = escapedParamValue.replaceAll("_", "" +
escapeSign + "_");
}
StringTokenizer stLike = new StringTokenizer(escapedParamValue);
searchString = stLike.nextToken();
while(stLike.hasMoreTokens()) { searchString = searchString + "%" +
stLike.nextToken(); }
queryCond.append("'%").append(searchString).append("%' ");
} else {
queryCond.append("'").append(paramValue).append("' ");
}
if(escapeFound) queryCond.append("escape
'").append(escapeSign).append("' ");
queryCond.append("and ");
} else {
queryCond.append(dbColumn).append(relation);
queryCond.append("'").append(paramValue).append("' and ");
}
<value><xsp:expr>paramValue</xsp:expr></value>
}
else {
if(inputType.startsWith("select")) {
StringTokenizer stsel = new StringTokenizer(inputValue,":");
stsel.nextToken();
String table = stsel.nextToken();
String col = stsel.nextToken();
<esql:execute-query>
<esql:query>
<xsp:expr>SQL_QUERY</xsp:expr>
<!--select * from <xsp:expr>table</xsp:expr>
where <xsp:expr>col</xsp:expr> = '<xsp:expr>paramValue</xsp:expr>'-->
</esql:query>
<esql:results>
<esql:row-results>
<xsp:logic>
if(true) {
<value><i18n:text>asd</i18n:text></value>
}
else {
<value>asd</value>
}
</xsp:logic>
</esql:row-results>
</esql:results>
<esql:no-results>
<value><xsp:expr>paramValue</xsp:expr> (?)</value>
</esql:no-results>
</esql:execute-query>
}
else if(inputType.startsWith("date")) {
try {
date = dfs.parse(paramValue);
if(relation.equals("<=")) {
date.setTime(date.getTime()+86399000);
/* (24*60*60-1)*1000 */
}
paramValue = "" + (date.getTime()/1000);
} catch(ParseException pe) {
/* test if time is given as integer as
time in seconds since 01.01.1970 */
try {
date.setTime(Long.parseLong(paramValue) * 1000);
} catch(NumberFormatException nfe) {
paramValue = "0";
date.setTime(0);
}
}
<value><xsp:expr>dfs.format(date)</xsp:expr></value>
}
else if(inputType.equals("interval")) {
try {
int i = Integer.parseInt(paramValue);
if(i < 1) throw new NumberFormatException("value too low");
}
catch(NumberFormatException nfe) {
paramValue = inputValue;
}
<value><xsp:expr>paramValue</xsp:expr></value>
}
else if(inputType.equals("num3")) {
double d = 0;
try {
d = Double.parseDouble(paramValue);
} catch(NumberFormatException nfe) {}
paramValue = "" + d*1000;
<value><i18n:number
fraction-digits="3"><xsp:expr>d</xsp:expr></i18n:number></value>
}
else if(inputType.equals("price")) {
double d = 0;
int numOfFractionDigits =
Currency.getInstance(locale).getDefaultFractionDigits();
int multWith = 1;
for(int i=0; i < numOfFractionDigits; i++) multWith *= 10;
try {
d = Double.parseDouble(paramValue) * multWith;
} catch(NumberFormatException nfe) {
/* try localized form of input */
try {
NumberFormat nfcur = NumberFormat.getInstance(locale);
d = nfcur.parse(paramValue).doubleValue() * multWith;
} catch(ParseException nfeN) { }
}
paramValue = "" + (int)d;
<value><i18n:number type="int-currency"
src-locale="en_US"><xsp:expr>d</xsp:expr></i18n:number></value>
}
/* construct queryCond for all what is not text */
<esql:execute-query>
<esql:query>
<xsp:expr>SQL_QUERY</xsp:expr>
<!--select length, lpad_order from datatypes where colname =
'<xsp:expr>dbColumn2</xsp:expr>'-->
</esql:query>
<esql:results>
<esql:row-results>
<xsp:logic>
if(false) {
queryCond.append("lpad(");
queryCond.append(dbColumn);
queryCond.append(",").append("a").
append(",'").append("b").append("')");
queryCond.append(relation);
queryCond.append("lpad('");
queryCond.append(paramValue);
queryCond.append("',").append("1").
append(",'").append("2").append("') and ");
}
else {
queryCond.append(dbColumn).append(relation);
queryCond.append("'").append(paramValue).append("' and ");
}
</xsp:logic>
</esql:row-results>
</esql:results>
<esql:no-results>
<xsp:logic>
queryCond.append(dbColumn).append(relation);
queryCond.append(paramValue).append(" and ");
</xsp:logic>
</esql:no-results>
</esql:execute-query>
<value><xsp:expr>paramValue</xsp:expr></value>
}
</xsp:logic>
</condition>
</xsp:content>
} /* paramValue != null */
</xsp:logic>
</esql:row-results>
</esql:results>
</esql:execute-query>
} // if query.indexOf("$conditions$") > -1)
if(queryCond.length() <= 7) {
/* " where ", initial assigned */
queryCond = new StringBuffer();
}
else {
if(queryCond.toString().endsWith(" and "))
queryCond.setLength(queryCond.length()-4);
}
query = composeQuery(query, queryCond.toString());
/* test if less than "select 0" */
if(countQuery.length() < 7) {
String distinct = "*";
int distinctI = query.toLowerCase().indexOf("distinct");
if(distinctI != -1)
distinct = query.substring(distinctI,query.indexOf(" ",distinctI+9));
int fromI = query.toLowerCase().lastIndexOf(" from ");
if(fromI != -1) countQuery = "select count("+distinct+") "+
query.substring(fromI);
countQuery = composeQuery(countQuery, queryCond.toString());
}
else countQuery = composeQuery(countQuery, queryCond.toString());
if(countQuery.length() < 7) countQuery = "select 0";
/* countQuery without group by or order by: */
int cutCountQuery = countQuery.indexOf(" group ");
if(cutCountQuery > -1) countQuery = countQuery.substring(0,cutCountQuery);
cutCountQuery = countQuery.indexOf(" order ");
if(cutCountQuery > -1) countQuery = countQuery.substring(0,cutCountQuery);
if(methodHandleQuery != null) {
reflectionArglist[0] = report;
// this would caus a NullPointerException
// reflectionArglist[1] = _esql_query.getResultSetMetaData();
//reflectionArglist[2] = _esql_connection.connection;
reflectionArglist[3] = queryCond.toString();
reflectionArglist[4] = column;
Object doubleObjectAll = sumAllDouble;
reflectionArglist[5] = doubleObjectAll;
Object doubleObjectPart = sumPartDouble;
reflectionArglist[6] = doubleObjectPart;
Object compoundObject[] = new Object[] {
boldBool, priceBool, num3Bool, numberBool,
percent3Bool, replaceBool, linkBool, wrapBool,
span, width, new Integer(numberGroupRows),
new Integer(numColsInSUM), query, httpRequest, dfs,
textI18nBool, dateTimeBool, timeBool };
reflectionArglist[7] = compoundObject;
try {
Object object = methodHandleQuery.invoke(reflectionObject, reflectionArglist);
query = (String)object;
} catch (Exception e) { System.out.println("Exception in invocation
methodHandleQuery: "+e); e.printStackTrace(); }
}
</xsp:logic>
<esql:execute-query>
<esql:query>
<xsp:expr>SQL_QUERY</xsp:expr>
<!--<xsp:expr>countQuery</xsp:expr>-->
</esql:query>
<esql:results>
<esql:row-results>
<xsp:logic>
count = 1;
if(count > maxRows + skipRows) nextPage = true;
if(count > 0) {
if(abbrevList.equals("y")) {
<abbrev-list>
<para><xsp:expr>report</xsp:expr></para>
<description><i18n:text>abbrevList</i18n:text></description>
</abbrev-list>
}
if(skipRows == 0) {
<count>
<description><i18n:text>count-matching</i18n:text>:</description>
<value><i18n:number><xsp:expr>count</xsp:expr></i18n:number></value>
</count>
} else {
<count>
<description><i18n:text>skipRows</i18n:text>:</description>
<value><i18n:number><xsp:expr>skipRows</xsp:expr></i18n:number></value>
</count>
}
}
<print-pdf>
<href>
<xsp:expr>thisPage.replaceAll(".html",".pdf")+"?"+httpRequest</xsp:expr>
</href>
<alt><i18n:text>PrintVersion</i18n:text></alt>
</print-pdf>
</xsp:logic>
</esql:row-results>
</esql:results>
</esql:execute-query>
</count-condition-abbrev>
<xsp:logic>
col_num = getInt(0, "col-num=", Misc, 0);
if(col_num > 0) {<col-num><xsp:expr>col_num</xsp:expr></col-num>}
<!-- System.out.println("mememe query: "+query); -->
int fromIndex = query.indexOf("from");
for(int i=0;i < fileDateTimeFor.length;i++) {
if(query.indexOf(" "+fileDateTimeFor[i], fromIndex) != -1) {
/* no +" " after fileDateTimeFor[i]: ej is also good for ejitem, ... */
<files-date-time>
<xsp:logic>
if(query.indexOf(" "+fileDateTimeFor[i], fromIndex) != -1) {
<file-date-time>
<!--
******************************************************************
GET TIMES FROM FILE
******************************************************************
-->
<esql:execute-query>
<esql:query>
<xsp:expr>SQL_QUERY</xsp:expr>
<!--select min(<xsp:expr>fileDateTimeColumn[i]</xsp:expr>),
max(<xsp:expr>fileDateTimeColumn[i]</xsp:expr>)
from <xsp:expr>fileDateTimeFor[i]</xsp:expr>-->
</esql:query>
<esql:results>
<esql:row-results>
<xsp:logic>
Date minDate = new Date(1000*1);
Date maxDate = new Date(1000*2);
<name><xsp:expr>fileDateTimeName[i]</xsp:expr></name>
<begin>
<descr><i18n:text>minultimestamp</i18n:text></descr>
<value><i18n:date-time src-locale="en_US" src-pattern="medium"
pattern="medium">
<xsp:expr>df.format(minDate)</xsp:expr></i18n:date-time>
</value>
</begin>
<end>
<descr><i18n:text>maxultimestamp</i18n:text></descr>
<value><i18n:date-time src-locale="en_US" src-pattern="medium"
pattern="medium">
<xsp:expr>df.format(maxDate)</xsp:expr></i18n:date-time>
</value>
</end>
</xsp:logic>
</esql:row-results>
</esql:results>
</esql:execute-query>
</file-date-time>
}
</xsp:logic>
</files-date-time>
}
}
</xsp:logic>
<table>
<thead>
<xsp:logic>
cc = 10;
column = new String[cc];
</xsp:logic>
</thead>
<tbody>
<xsp:logic>
for(int ar = 0; ar < 20000; ar++) {
System.out.println(ar);
for (int i = 0; i < cc; i++) {
column[i] = "row="+ar+", col="+i;
}
createRow(cc, xspAttr);
}
</xsp:logic>
</tbody>
</table>
</body>
</esql:connection>
</page>
</xsp:page>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]