You can subscribe to this list here.
| 2003 |
Jan
|
Feb
(14) |
Mar
(107) |
Apr
(211) |
May
(93) |
Jun
(158) |
Jul
(159) |
Aug
(368) |
Sep
(188) |
Oct
(151) |
Nov
(115) |
Dec
(98) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(25) |
Feb
|
Mar
(33) |
Apr
(28) |
May
(116) |
Jun
(2) |
Jul
(117) |
Aug
(19) |
Sep
(9) |
Oct
(2) |
Nov
|
Dec
(4) |
| 2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
(9) |
Dec
|
| 2006 |
Jan
|
Feb
|
Mar
(22) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2007 |
Jan
|
Feb
|
Mar
(6) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(267) |
Sep
|
Oct
|
Nov
(6) |
Dec
(512) |
| 2008 |
Jan
(187) |
Feb
|
Mar
|
Apr
|
May
|
Jun
(3) |
Jul
(6) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
|
| 2012 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <mic...@us...> - 2003-12-01 00:24:51
|
Update of /cvsroot/babeldoc/babeldoc/modules/jfreereports/src/com/babeldoc/utils
In directory sc8-pr-cvs1:/tmp/cvs-serv6835/modules/jfreereports/src/com/babeldoc/utils
Modified Files:
Tag: TEMP_MIKEA
XMLTableModel.java XMLTableModelTest.java
Log Message:
Completed initial implementation
Index: XMLTableModel.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/jfreereports/src/com/babeldoc/utils/Attic/XMLTableModel.java,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -C2 -d -r1.1.2.4 -r1.1.2.5
*** XMLTableModel.java 29 Nov 2003 02:32:14 -0000 1.1.2.4
--- XMLTableModel.java 1 Dec 2003 00:24:48 -0000 1.1.2.5
***************
*** 1,8 ****
! /*
! * Created on 19-Nov-2003
*
- * To change the template for this generated file go to
- * Window>Preferences>Java>Code Generation>Code and Comments
*/
package com.babeldoc.utils;
--- 1,68 ----
! /* ====================================================================
! * The Apache Software License, Version 1.1
! *
! * Copyright (c) 2000 The Apache Software Foundation. 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.
! *
! * 3. The end-user documentation included with the redistribution,
! * if any, must include the following acknowledgment:
! * "This product includes software developed by the
! * Apache Software Foundation (http://www.apache.org/)."
! * Alternately, this acknowledgment may appear in the software itself,
! * if and wherever such third-party acknowledgments normally appear.
! *
! * 4. The names "Apache" and "Apache Software Foundation" must
! * not be used to endorse or promote products derived from this
! * software without prior written permission. For written
! * permission, please contact ap...@ap....
! *
! * 5. Products derived from this software may not be called "Apache",
! * nor may "Apache" appear in their name, without prior written
! * permission of the Apache Software Foundation.
! *
! * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED 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 APACHE SOFTWARE FOUNDATION OR
! * ITS 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.
! * ====================================================================
! *
! * This software consists of voluntary contributions made by many
! * individuals on behalf of the Apache Software Foundation. For more
! * information on the Apache Software Foundation, please see
! * <http://www.apache.org/>.
! *
! * Portions of this software are based upon public domain software
! * originally written at the National Center for Supercomputing Applications,
! * University of Illinois, Urbana-Champaign.
! * ====================================================================
! *
! * Babeldoc: The Universal Document Processor
! *
! * $Header$
! * $DateTime$
! * $Author$
*
*/
+
package com.babeldoc.utils;
***************
*** 16,24 ****
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableModel;
- import javax.swing.table.DefaultTableModel;
import javax.xml.transform.TransformerException;
import org.apache.xpath.objects.XNumber;
- import org.apache.xpath.objects.XObject;
import org.apache.xpath.XPathAPI;
--- 76,82 ----
***************
*** 31,69 ****
/**
* @author mikea
*
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
*/
public class XMLTableModel extends AbstractTableModel implements TableModel {
private static LogService log =
LogService.getInstance(XMLTableModel.class.getName());
public static final String XML_MIME_TYPE = "text/xml";
! public static final String QUERY_RESULTS = "queryresults";
! public static final String QUERY = "query";
! public static final String QUERY_NAME = "query-name";
! public static final String QUERY_NUMBER = "query-number";
! public static final String ROW = "row";
public static final String ROW_NUMBER = "row-number";
! public static final String COLUMN = "column";
public static final String COLUMN_NAME = "column-name";
public static final String COLUMN_NUMBER = "column-number";
public static final String COLUMN_CLASS = "column-class";
public static final String DEFAULT_CLASS_NAME = "java.lang.String";
public static final Class DEFAULT_CLASS = java.lang.String.class;
private Document xmlData;
private int columnCount = -1;
private int rowCount = -1;
private Class[] columnClasses;
private String[] columnNames;
private Map columnNumbers = new HashMap();
public XMLTableModel() {
xmlData = null;
}
! public XMLTableModel(org.dom4j.Document data) throws org.dom4j.DocumentException {
xmlData = transformToDOM(data);
columnClasses = new Class[getColumnCount()];
--- 89,159 ----
/**
+ * A class to provide an AbstractTableModel implementation for data held in
+ * XML format.
+ *
* @author mikea
*
*/
public class XMLTableModel extends AbstractTableModel implements TableModel {
+ /** static: log service */
private static LogService log =
LogService.getInstance(XMLTableModel.class.getName());
+ /** constant: document mime type */
public static final String XML_MIME_TYPE = "text/xml";
! /** instance: root path for data */
! public String QUERY_RESULTS = "";
! /** instance: element identifier for rows */
! public String ROW = "row";
! /** constant: element identifier for row numbers,
! * TODO: should be configurable by the user */
public static final String ROW_NUMBER = "row-number";
! /** instance: element identifier for columns */
! public String COLUMN = "column";
! /** constant: element identifier for column names,
! * TODO: should be configurable by the user */
public static final String COLUMN_NAME = "column-name";
+ /** constant: element identifier for column numbers,
+ * TODO: should be configurable by the user */
public static final String COLUMN_NUMBER = "column-number";
+ /** constant: element identifier for column class identifiers,
+ * TODO: should be configurable by the user */
public static final String COLUMN_CLASS = "column-class";
+ /** constant: the default column class identifier */
public static final String DEFAULT_CLASS_NAME = "java.lang.String";
+ /** constant: the default column class */
public static final Class DEFAULT_CLASS = java.lang.String.class;
+ /** instance: the data */
private Document xmlData;
+ /** instance: cache of the column count */
private int columnCount = -1;
+ /** instance: cache of the row count */
private int rowCount = -1;
+ /** instance: cache of the column classes */
private Class[] columnClasses;
+ /** instance: cache of the column names */
private String[] columnNames;
+ /** instance: cache of the column ordinal positions keyed on name */
private Map columnNumbers = new HashMap();
+ /**
+ * The default constructor
+ *
+ */
public XMLTableModel() {
xmlData = null;
}
! /**
! * Constructor with data document and root path to data
! *
! * @param data the data document
! * @param rootPath the string representation of the path to the
! * data within the document
! *
! */
! public XMLTableModel(org.dom4j.Document data, String rootPath) throws org.dom4j.DocumentException {
! QUERY_RESULTS = rootPath;
xmlData = transformToDOM(data);
columnClasses = new Class[getColumnCount()];
***************
*** 71,78 ****
}
! public void setDocument(org.dom4j.Document doc) throws org.dom4j.DocumentException {
xmlData = transformToDOM(doc);
columnClasses = new Class[getColumnCount()];
columnNames = new String[getColumnCount()];
}
--- 161,177 ----
}
! /**
! * Set the data document and clear the cached information
! *
! * @param info
! */
! public void setDocument(org.dom4j.Document doc, String rootPath) throws org.dom4j.DocumentException {
! QUERY_RESULTS = rootPath;
xmlData = transformToDOM(doc);
+ columnCount = -1;
+ rowCount = -1;
columnClasses = new Class[getColumnCount()];
columnNames = new String[getColumnCount()];
+ columnNumbers = new HashMap();
}
***************
*** 89,93 ****
String xpath = "count(" +
QUERY_RESULTS + "/" +
- QUERY + "/" +
ROW + "[@row-number=\"0\"]/" +
COLUMN +
--- 188,191 ----
***************
*** 102,106 ****
}
- // Get the result value from the node and cache
columnCount = new Double(n.num()).intValue();
--- 200,203 ----
***************
*** 120,124 ****
String xpath = "count(" +
QUERY_RESULTS + "/" +
- QUERY + "/" +
ROW +
")";
--- 217,220 ----
***************
*** 147,151 ****
// This is the xpath for a cell in an XML data document from the SqlQuery
// pipeline stage
! String xpath = QUERY_RESULTS + "/" + QUERY + "/" +
ROW + "[@" + ROW_NUMBER + "=\"" + rowIndex + "\"]/" +
COLUMN + "[@" + COLUMN_NUMBER + "=\"" + (columnIndex + 1) + "\"]";
--- 243,247 ----
// This is the xpath for a cell in an XML data document from the SqlQuery
// pipeline stage
! String xpath = QUERY_RESULTS + "/" +
ROW + "[@" + ROW_NUMBER + "=\"" + rowIndex + "\"]/" +
COLUMN + "[@" + COLUMN_NUMBER + "=\"" + (columnIndex + 1) + "\"]";
***************
*** 175,182 ****
}
} catch (Exception e) {
! e.printStackTrace();
! //log.logWarn(e.getMessage());
! v = "";
! //v = new String("[" + I18n.get("jfr.104", className) + "]");
}
--- 271,276 ----
}
} catch (Exception e) {
! log.logWarn(e.getMessage());
! v = new String("[" + I18n.get("jfr.104", className) + "]");
}
***************
*** 184,187 ****
--- 278,286 ----
}
+ /**
+ * Convert the document to w3c format
+ *
+ * @param info
+ */
private org.w3c.dom.Document transformToDOM(org.dom4j.Document doc) throws DocumentException {
DOMWriter writer = new DOMWriter();
***************
*** 193,199 ****
*
* @param columnIndex the column being queried
! * @return the Object.class
*/
public Class getColumnClass(int columnIndex) {
Class c = columnClasses[columnIndex];
if (c == null) {
--- 292,299 ----
*
* @param columnIndex the column being queried
! * @return the Object.class, or null if the position is not valid
*/
public Class getColumnClass(int columnIndex) {
+ if ((columnIndex < 0) || (columnIndex >= columnClasses.length)) return (null); // Invalid index
Class c = columnClasses[columnIndex];
if (c == null) {
***************
*** 203,207 ****
// This is the xpath for a cell in an XML data document from the SqlQuery
// pipeline stage
! String xpath = QUERY_RESULTS + "/" + QUERY + "/" +
ROW + "[@row-number=\"0\"]/" +
COLUMN + "[@" + COLUMN_NUMBER + "=\"" + (columnIndex + 1) + "\"]";
--- 303,307 ----
// This is the xpath for a cell in an XML data document from the SqlQuery
// pipeline stage
! String xpath = QUERY_RESULTS + "/" +
ROW + "[@row-number=\"0\"]/" +
COLUMN + "[@" + COLUMN_NUMBER + "=\"" + (columnIndex + 1) + "\"]";
***************
*** 214,217 ****
--- 314,318 ----
}
+ if (n == null) return (null); // Column position not found
NamedNodeMap attrs = n.getAttributes();
String className = attrs.getNamedItem(COLUMN_CLASS).getNodeValue();
***************
*** 235,242 ****
*
* @param column the column being queried
! * @return a string containing the default name of <code>column</code>
*/
public String getColumnName(int column) {
String name;
name = columnNames[column];
if (name == null) {
--- 336,345 ----
*
* @param column the column being queried
! * @return a string containing the name of <code>column</code> or
! * an empty string if not found
*/
public String getColumnName(int column) {
String name;
+ if ((column < 0) || (column >= columnNames.length)) return (""); // Invalid index
name = columnNames[column];
if (name == null) {
***************
*** 245,249 ****
// This is the xpath for a cell in an XML data document from the SqlQuery
// pipeline stage
! String xpath = QUERY_RESULTS + "/" + QUERY + "/" +
ROW + "[@row-number=\"0\"]/" +
COLUMN + "[@" + COLUMN_NUMBER + "=\"" + (column + 1) + "\"]";
--- 348,352 ----
// This is the xpath for a cell in an XML data document from the SqlQuery
// pipeline stage
! String xpath = QUERY_RESULTS + "/" +
ROW + "[@row-number=\"0\"]/" +
COLUMN + "[@" + COLUMN_NUMBER + "=\"" + (column + 1) + "\"]";
***************
*** 256,259 ****
--- 359,363 ----
}
+ if (n == null) return (""); // Column position not found
NamedNodeMap attrs = n.getAttributes();
name = attrs.getNamedItem(COLUMN_NAME).getNodeValue();
***************
*** 279,283 ****
// This is the xpath for the count of columns in the first row
! String xpath = QUERY_RESULTS + "/" + QUERY + "/" +
ROW + "[@row-number=\"0\"]/" +
COLUMN + "[@" + COLUMN_NAME + "=\"" + columnName + "\"]";
--- 383,387 ----
// This is the xpath for the count of columns in the first row
! String xpath = QUERY_RESULTS + "/" +
ROW + "[@row-number=\"0\"]/" +
COLUMN + "[@" + COLUMN_NAME + "=\"" + columnName + "\"]";
***************
*** 290,293 ****
--- 394,398 ----
}
+ if (n == null) return (-1); // Column name not found
NamedNodeMap attrs = n.getAttributes();
columnNumber = new Integer(attrs.getNamedItem(COLUMN_NUMBER).getNodeValue());
***************
*** 298,301 ****
--- 403,422 ----
return (columnNumber.intValue() - 1);
+ }
+
+ public String getColumnID() {
+ return COLUMN;
+ }
+
+ public void setColumnID(String column) {
+ COLUMN = column;
+ }
+
+ public String getRowID() {
+ return ROW;
+ }
+
+ public void setRowID(String row) {
+ ROW = row;
}
Index: XMLTableModelTest.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/jfreereports/src/com/babeldoc/utils/Attic/XMLTableModelTest.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -C2 -d -r1.1.2.2 -r1.1.2.3
*** XMLTableModelTest.java 29 Nov 2003 02:34:40 -0000 1.1.2.2
--- XMLTableModelTest.java 1 Dec 2003 00:24:48 -0000 1.1.2.3
***************
*** 29,33 ****
" <column column-name=\"last_name\" column-number=\"3\" column-class=\"java.lang.String\">Abel</column>" +
" <column column-name=\"first_name\" column-number=\"4\" column-class=\"java.lang.String\">Peter</column>" +
! " <column column-name=\"main_phone\" column-number=\"5\" column-class=\"java.lang.String\">(510)555-8188</column>" +
" <column column-name=\"fk_seminar_code\" column-number=\"6\" column-class=\"java.lang.String\">001</column>" +
" <column column-name=\"seminar_tmpl_name\" column-number=\"7\" column-class=\"java.lang.String\">Annual Update</column>" +
--- 29,33 ----
" <column column-name=\"last_name\" column-number=\"3\" column-class=\"java.lang.String\">Abel</column>" +
" <column column-name=\"first_name\" column-number=\"4\" column-class=\"java.lang.String\">Peter</column>" +
! " <column column-name=\"main_phone\" column-number=\"5\" column-class=\"java.lang.String\">(888)555-8188</column>" +
" <column column-name=\"fk_seminar_code\" column-number=\"6\" column-class=\"java.lang.String\">001</column>" +
" <column column-name=\"seminar_tmpl_name\" column-number=\"7\" column-class=\"java.lang.String\">Annual Update</column>" +
***************
*** 45,49 ****
" <column column-name=\"last_name\" column-number=\"3\" column-class=\"java.lang.String\">Bartley</column>" +
" <column column-name=\"first_name\" column-number=\"4\" column-class=\"java.lang.String\">David</column>" +
! " <column column-name=\"main_phone\" column-number=\"5\" column-class=\"java.lang.String\">(415)555-7703</column>" +
" <column column-name=\"fk_seminar_code\" column-number=\"6\" column-class=\"java.lang.String\">001</column>" +
" <column column-name=\"seminar_tmpl_name\" column-number=\"7\" column-class=\"java.lang.String\">Annual Update</column>" +
--- 45,49 ----
" <column column-name=\"last_name\" column-number=\"3\" column-class=\"java.lang.String\">Bartley</column>" +
" <column column-name=\"first_name\" column-number=\"4\" column-class=\"java.lang.String\">David</column>" +
! " <column column-name=\"main_phone\" column-number=\"5\" column-class=\"java.lang.String\">(888)555-7703</column>" +
" <column column-name=\"fk_seminar_code\" column-number=\"6\" column-class=\"java.lang.String\">001</column>" +
" <column column-name=\"seminar_tmpl_name\" column-number=\"7\" column-class=\"java.lang.String\">Annual Update</column>" +
***************
*** 65,69 ****
try {
doc = DocumentHelper.parseText(strDoc);
! tm = new XMLTableModel(doc);
// Column and row counts
--- 65,69 ----
try {
doc = DocumentHelper.parseText(strDoc);
! tm = new XMLTableModel(doc, "/queryresults/query");
// Column and row counts
***************
*** 76,79 ****
--- 76,85 ----
System.out.println("Position: " + i + ", Name: " + name + ", Ordinal: " + tm.findColumn(name) + ", Class: " + tm.getColumnClass(i).getName());
}
+ // Find a non-existent column name
+ System.out.println(tm.findColumn("XXX"));
+ // Find a non-existent column position
+ System.out.println(tm.getColumnName(15));
+ // Find a non-existent column class
+ System.out.println(tm.getColumnClass(15));
// getValueAt
|
|
From: <mic...@us...> - 2003-12-01 00:24:51
|
Update of /cvsroot/babeldoc/babeldoc/modules/jfreereports/src/com/babeldoc/jfreereports/pipeline/stage
In directory sc8-pr-cvs1:/tmp/cvs-serv6835/modules/jfreereports/src/com/babeldoc/jfreereports/pipeline/stage
Modified Files:
Tag: TEMP_MIKEA
JFRPipelineStage.java
Log Message:
Completed initial implementation
Index: JFRPipelineStage.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/jfreereports/src/com/babeldoc/jfreereports/pipeline/stage/Attic/JFRPipelineStage.java,v
retrieving revision 1.1.2.8
retrieving revision 1.1.2.9
diff -C2 -d -r1.1.2.8 -r1.1.2.9
*** JFRPipelineStage.java 28 Nov 2003 09:16:28 -0000 1.1.2.8
--- JFRPipelineStage.java 1 Dec 2003 00:24:48 -0000 1.1.2.9
***************
*** 115,137 ****
/**
! * @author mikea
*
! */
public class JFRPipelineStage extends PipelineStage {
private static LogService log =
LogService.getInstance(JFRPipelineStage.class.getName());
! /**
! * constants
! */
public static final String XML_MIME_TYPE = "text/xml";
public final static String REPORT_DEF = "reportDefinition";
public final static String REPORT_DEF_URL = "reportDefinitionUrl";
/**
! * Construct with this stages info
! */
! public JFRPipelineStage() {
super(new PipelineStageInfo() {
public String getName() {
--- 115,143 ----
/**
! * Make a JFreeReport from SqlQuery output.
*
! * @author michaelansley
! * @version 1.0
! **/
public class JFRPipelineStage extends PipelineStage {
private static LogService log =
LogService.getInstance(JFRPipelineStage.class.getName());
! /** constant: mime type for XML */
public static final String XML_MIME_TYPE = "text/xml";
+ /** constant: Report definition attribute/config property */
public final static String REPORT_DEF = "reportDefinition";
+ /** constant: Report definition URL attribute/config property */
public final static String REPORT_DEF_URL = "reportDefinitionUrl";
+
+ /** instance: Counter for unique file numbers */
+ private static int tempFileCount = 0;
/**
! * Construct the stage information for this stage
! *
! */
! public JFRPipelineStage() {
super(new PipelineStageInfo() {
public String getName() {
***************
*** 163,167 ****
throw new PipelineException(I18n.get("jfr.101"));
}
!
// Find the report definition
String xmlReportDefinition = getReportDefinition();
--- 169,173 ----
throw new PipelineException(I18n.get("jfr.101"));
}
!
// Find the report definition
String xmlReportDefinition = getReportDefinition();
***************
*** 170,183 ****
String outputFile = null;
try {
! // Set up the table model
TableModel tm = getTableModel();
! // Create a report with the correct definition
log.logDebug(xmlReportDefinition);
StringReader reader = new StringReader (xmlReportDefinition);
URL contentBaseURL = new URL ("file:///");
report = ReportGenerator.getInstance().parseReport(new InputSource(reader), contentBaseURL);
! // Put the data in
report.setData(tm);
! // Generate the report output
outputFile = getTempFilename() + ".pdf";
PDFReportUtil.createPDF(report, outputFile);
--- 176,192 ----
String outputFile = null;
try {
! log.logDebug("Get the table model");
TableModel tm = getTableModel();
!
! log.logDebug("Create a report with the correct definition");
log.logDebug(xmlReportDefinition);
StringReader reader = new StringReader (xmlReportDefinition);
URL contentBaseURL = new URL ("file:///");
report = ReportGenerator.getInstance().parseReport(new InputSource(reader), contentBaseURL);
!
! log.logDebug("Set the data for the report");
report.setData(tm);
!
! log.logDebug("Generate the report output");
outputFile = getTempFilename() + ".pdf";
PDFReportUtil.createPDF(report, outputFile);
***************
*** 196,201 ****
}
PipelineDocument newDocument = null;
! if (outputFile == null || outputFile.equals("")) {
try {
byte[] data = getBytesFromFile(new File(outputFile));
--- 205,211 ----
}
+ log.logDebug("Create the pipeline document from the temp file");
PipelineDocument newDocument = null;
! if (outputFile != null && !(outputFile.equals(""))) {
try {
byte[] data = getBytesFromFile(new File(outputFile));
***************
*** 203,206 ****
--- 213,217 ----
newDocument.setBinary(true);
newDocument.setMimeType("application/pdf");
+ new File(outputFile).delete();
} catch (java.io.IOException e) {
log.logError(e);
***************
*** 212,216 ****
}
! /*
* Find the report definition. First search the document attributes for a
* report definition, then a report definition URL. Then check the pipeline
--- 223,227 ----
}
! /**
* Find the report definition. First search the document attributes for a
* report definition, then a report definition URL. Then check the pipeline
***************
*** 218,222 ****
*
* @return String The report definition
- *
* @throws ResourceException Any exceptions encountered are converted to
* ResourceException
--- 229,232 ----
***************
*** 285,289 ****
}
! tm.setDocument(doc);
return (tm);
}
--- 295,299 ----
}
! tm.setDocument(doc, "/queryresults/query");
return (tm);
}
***************
*** 294,297 ****
--- 304,308 ----
// Get the size of the file
long length = file.length();
+ log.logInfo("File size: " + length);
// You cannot create an array using a long type.
***************
*** 324,328 ****
private String getTempFilename() {
! return ("tempfile");
}
--- 335,339 ----
private String getTempFilename() {
! return ("/tmp/done/tempfile" + getFileCounter());
}
***************
*** 339,342 ****
--- 350,357 ----
}
return (s);
+ }
+
+ private synchronized int getFileCounter() {
+ return (++tempFileCount);
}
}
|
|
From: <mic...@us...> - 2003-11-29 02:34:48
|
Update of /cvsroot/babeldoc/babeldoc/modules/jfreereports/src/com/babeldoc/utils
In directory sc8-pr-cvs1:/tmp/cvs-serv18590/modules/jfreereports/src/com/babeldoc/utils
Modified Files:
Tag: TEMP_MIKEA
XMLTableModelTest.java
Log Message:
Changed some test data
Index: XMLTableModelTest.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/jfreereports/src/com/babeldoc/utils/Attic/XMLTableModelTest.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -d -r1.1.2.1 -r1.1.2.2
*** XMLTableModelTest.java 29 Nov 2003 02:32:14 -0000 1.1.2.1
--- XMLTableModelTest.java 29 Nov 2003 02:34:40 -0000 1.1.2.2
***************
*** 26,37 ****
" <row row-number=\"0\">" +
" <column column-name=\"quiz\" column-number=\"1\" column-class=\"java.lang.String\">Yes</column>" +
! " <column column-name=\"company_name\" column-number=\"2\" column-class=\"java.lang.String\">Peter Abel, CPA</column>" +
" <column column-name=\"last_name\" column-number=\"3\" column-class=\"java.lang.String\">Abel</column>" +
" <column column-name=\"first_name\" column-number=\"4\" column-class=\"java.lang.String\">Peter</column>" +
! " <column column-name=\"main_phone\" column-number=\"5\" column-class=\"java.lang.String\">(510)420-8188</column>" +
" <column column-name=\"fk_seminar_code\" column-number=\"6\" column-class=\"java.lang.String\">001</column>" +
! " <column column-name=\"seminar_tmpl_name\" column-number=\"7\" column-class=\"java.lang.String\">Annual Tax Update Seminar</column>" +
! " <column column-name=\"start_date\" column-number=\"8\" column-class=\"java.lang.String\">11/17/2003</column>" +
! " <column column-name=\"hotel_place\" column-number=\"9\" column-class=\"java.lang.String\">Corte Madera, CA</column>" +
" <column column-name=\"amount_paid\" column-number=\"10\" column-class=\"java.math.BigDecimal\">200.000000</column>" +
" <column column-name=\"id_booking\" column-number=\"11\" column-class=\"java.lang.Integer\">65703</column>" +
--- 26,37 ----
" <row row-number=\"0\">" +
" <column column-name=\"quiz\" column-number=\"1\" column-class=\"java.lang.String\">Yes</column>" +
! " <column column-name=\"company_name\" column-number=\"2\" column-class=\"java.lang.String\">Peter Abel</column>" +
" <column column-name=\"last_name\" column-number=\"3\" column-class=\"java.lang.String\">Abel</column>" +
" <column column-name=\"first_name\" column-number=\"4\" column-class=\"java.lang.String\">Peter</column>" +
! " <column column-name=\"main_phone\" column-number=\"5\" column-class=\"java.lang.String\">(510)555-8188</column>" +
" <column column-name=\"fk_seminar_code\" column-number=\"6\" column-class=\"java.lang.String\">001</column>" +
! " <column column-name=\"seminar_tmpl_name\" column-number=\"7\" column-class=\"java.lang.String\">Annual Update</column>" +
! " <column column-name=\"start_date\" column-number=\"8\" column-class=\"java.lang.String\">11/17/1999</column>" +
! " <column column-name=\"hotel_place\" column-number=\"9\" column-class=\"java.lang.String\">Corte, CA</column>" +
" <column column-name=\"amount_paid\" column-number=\"10\" column-class=\"java.math.BigDecimal\">200.000000</column>" +
" <column column-name=\"id_booking\" column-number=\"11\" column-class=\"java.lang.Integer\">65703</column>" +
***************
*** 42,53 ****
" <row row-number=\"1\">" +
" <column column-name=\"quiz\" column-number=\"1\" column-class=\"java.lang.String\">Yes</column>" +
! " <column column-name=\"company_name\" column-number=\"2\" column-class=\"java.lang.String\">David J. Bartley, CPA</column>" +
" <column column-name=\"last_name\" column-number=\"3\" column-class=\"java.lang.String\">Bartley</column>" +
" <column column-name=\"first_name\" column-number=\"4\" column-class=\"java.lang.String\">David</column>" +
! " <column column-name=\"main_phone\" column-number=\"5\" column-class=\"java.lang.String\">(415)883-7703</column>" +
" <column column-name=\"fk_seminar_code\" column-number=\"6\" column-class=\"java.lang.String\">001</column>" +
! " <column column-name=\"seminar_tmpl_name\" column-number=\"7\" column-class=\"java.lang.String\">Annual Tax Update Seminar</column>" +
! " <column column-name=\"start_date\" column-number=\"8\" column-class=\"java.lang.String\">11/18/2002</column>" +
! " <column column-name=\"hotel_place\" column-number=\"9\" column-class=\"java.lang.String\">Corte Madera, CA</column>" +
" <column column-name=\"amount_paid\" column-number=\"10\" column-class=\"java.math.BigDecimal\">165.000000</column>" +
" <column column-name=\"id_booking\" column-number=\"11\" column-class=\"java.lang.Integer\">50989</column>" +
--- 42,53 ----
" <row row-number=\"1\">" +
" <column column-name=\"quiz\" column-number=\"1\" column-class=\"java.lang.String\">Yes</column>" +
! " <column column-name=\"company_name\" column-number=\"2\" column-class=\"java.lang.String\">David Bartley</column>" +
" <column column-name=\"last_name\" column-number=\"3\" column-class=\"java.lang.String\">Bartley</column>" +
" <column column-name=\"first_name\" column-number=\"4\" column-class=\"java.lang.String\">David</column>" +
! " <column column-name=\"main_phone\" column-number=\"5\" column-class=\"java.lang.String\">(415)555-7703</column>" +
" <column column-name=\"fk_seminar_code\" column-number=\"6\" column-class=\"java.lang.String\">001</column>" +
! " <column column-name=\"seminar_tmpl_name\" column-number=\"7\" column-class=\"java.lang.String\">Annual Update</column>" +
! " <column column-name=\"start_date\" column-number=\"8\" column-class=\"java.lang.String\">11/18/1999</column>" +
! " <column column-name=\"hotel_place\" column-number=\"9\" column-class=\"java.lang.String\">Corte, CA</column>" +
" <column column-name=\"amount_paid\" column-number=\"10\" column-class=\"java.math.BigDecimal\">165.000000</column>" +
" <column column-name=\"id_booking\" column-number=\"11\" column-class=\"java.lang.Integer\">50989</column>" +
|
|
From: <mic...@us...> - 2003-11-29 02:32:17
|
Update of /cvsroot/babeldoc/babeldoc/modules/jfreereports/src/com/babeldoc/utils
In directory sc8-pr-cvs1:/tmp/cvs-serv18248/modules/jfreereports/src/com/babeldoc/utils
Modified Files:
Tag: TEMP_MIKEA
XMLTableModel.java
Added Files:
Tag: TEMP_MIKEA
XMLTableModelTest.java
Log Message:
Added unit tests for XMLTableModel, and corrected outstanding issues
--- NEW FILE: XMLTableModelTest.java ---
/*
* Created on 28-Nov-2003
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package com.babeldoc.utils;
import junit.framework.TestCase;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
/**
* @author mikea
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class XMLTableModelTest extends TestCase {
private XMLTableModelTest() {
String strDoc = new String("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<queryresults>" +
" <query query-name=\"query1\" query-number=\"0\">" +
" <row row-number=\"0\">" +
" <column column-name=\"quiz\" column-number=\"1\" column-class=\"java.lang.String\">Yes</column>" +
" <column column-name=\"company_name\" column-number=\"2\" column-class=\"java.lang.String\">Peter Abel, CPA</column>" +
" <column column-name=\"last_name\" column-number=\"3\" column-class=\"java.lang.String\">Abel</column>" +
" <column column-name=\"first_name\" column-number=\"4\" column-class=\"java.lang.String\">Peter</column>" +
" <column column-name=\"main_phone\" column-number=\"5\" column-class=\"java.lang.String\">(510)420-8188</column>" +
" <column column-name=\"fk_seminar_code\" column-number=\"6\" column-class=\"java.lang.String\">001</column>" +
" <column column-name=\"seminar_tmpl_name\" column-number=\"7\" column-class=\"java.lang.String\">Annual Tax Update Seminar</column>" +
" <column column-name=\"start_date\" column-number=\"8\" column-class=\"java.lang.String\">11/17/2003</column>" +
" <column column-name=\"hotel_place\" column-number=\"9\" column-class=\"java.lang.String\">Corte Madera, CA</column>" +
" <column column-name=\"amount_paid\" column-number=\"10\" column-class=\"java.math.BigDecimal\">200.000000</column>" +
" <column column-name=\"id_booking\" column-number=\"11\" column-class=\"java.lang.Integer\">65703</column>" +
" <column column-name=\"shipping_address\" column-number=\"12\" column-class=\"java.lang.String\"></column>" +
" <column column-name=\"city\" column-number=\"13\" column-class=\"java.lang.String\">Oakland</column>" +
" <column column-name=\"attended\" column-number=\"14\" column-class=\"java.lang.String\">No</column>" +
" </row>" +
" <row row-number=\"1\">" +
" <column column-name=\"quiz\" column-number=\"1\" column-class=\"java.lang.String\">Yes</column>" +
" <column column-name=\"company_name\" column-number=\"2\" column-class=\"java.lang.String\">David J. Bartley, CPA</column>" +
" <column column-name=\"last_name\" column-number=\"3\" column-class=\"java.lang.String\">Bartley</column>" +
" <column column-name=\"first_name\" column-number=\"4\" column-class=\"java.lang.String\">David</column>" +
" <column column-name=\"main_phone\" column-number=\"5\" column-class=\"java.lang.String\">(415)883-7703</column>" +
" <column column-name=\"fk_seminar_code\" column-number=\"6\" column-class=\"java.lang.String\">001</column>" +
" <column column-name=\"seminar_tmpl_name\" column-number=\"7\" column-class=\"java.lang.String\">Annual Tax Update Seminar</column>" +
" <column column-name=\"start_date\" column-number=\"8\" column-class=\"java.lang.String\">11/18/2002</column>" +
" <column column-name=\"hotel_place\" column-number=\"9\" column-class=\"java.lang.String\">Corte Madera, CA</column>" +
" <column column-name=\"amount_paid\" column-number=\"10\" column-class=\"java.math.BigDecimal\">165.000000</column>" +
" <column column-name=\"id_booking\" column-number=\"11\" column-class=\"java.lang.Integer\">50989</column>" +
" <column column-name=\"shipping_address\" column-number=\"12\" column-class=\"java.lang.String\"></column>" +
" <column column-name=\"city\" column-number=\"13\" column-class=\"java.lang.String\">Novato</column>" +
" <column column-name=\"attended\" column-number=\"14\" column-class=\"java.lang.String\">Yes</column>" +
" </row>" +
" </query>" +
"</queryresults>"
);
Document doc;
XMLTableModel tm;
try {
doc = DocumentHelper.parseText(strDoc);
tm = new XMLTableModel(doc);
// Column and row counts
System.out.println("Column count: " + tm.getColumnCount());
System.out.println("Row count: " + tm.getRowCount());
// Column names and ordinals
for (int i = 0; i < tm.getColumnCount(); i++) {
String name = tm.getColumnName(i);
System.out.println("Position: " + i + ", Name: " + name + ", Ordinal: " + tm.findColumn(name) + ", Class: " + tm.getColumnClass(i).getName());
}
// getValueAt
for (int row = 0; row < tm.getRowCount(); row++) {
for (int col = 0; col < tm.getColumnCount(); col++) {
String name = tm.getColumnName(col);
Object o = tm.getValueAt(row, col);
String value;
if (o == null) {
value = "null";
} else {
value = o.toString();
}
System.out.println("Row: " + row + ", Column: " + name + ", Value: " + value);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
XMLTableModelTest test = new XMLTableModelTest();
}
}
Index: XMLTableModel.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/jfreereports/src/com/babeldoc/utils/Attic/XMLTableModel.java,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -C2 -d -r1.1.2.3 -r1.1.2.4
*** XMLTableModel.java 28 Nov 2003 09:16:29 -0000 1.1.2.3
--- XMLTableModel.java 29 Nov 2003 02:32:14 -0000 1.1.2.4
***************
*** 16,19 ****
--- 16,20 ----
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableModel;
+ import javax.swing.table.DefaultTableModel;
import javax.xml.transform.TransformerException;
***************
*** 66,69 ****
--- 67,72 ----
public XMLTableModel(org.dom4j.Document data) throws org.dom4j.DocumentException {
xmlData = transformToDOM(data);
+ columnClasses = new Class[getColumnCount()];
+ columnNames = new String[getColumnCount()];
}
***************
*** 71,74 ****
--- 74,78 ----
xmlData = transformToDOM(doc);
columnClasses = new Class[getColumnCount()];
+ columnNames = new String[getColumnCount()];
}
***************
*** 85,89 ****
String xpath = "count(" +
QUERY_RESULTS + "/" +
! ROW + "[1]/" +
COLUMN +
")";
--- 89,94 ----
String xpath = "count(" +
QUERY_RESULTS + "/" +
! QUERY + "/" +
! ROW + "[@row-number=\"0\"]/" +
COLUMN +
")";
***************
*** 115,118 ****
--- 120,124 ----
String xpath = "count(" +
QUERY_RESULTS + "/" +
+ QUERY + "/" +
ROW +
")";
***************
*** 141,147 ****
// This is the xpath for a cell in an XML data document from the SqlQuery
// pipeline stage
! String xpath = QUERY_RESULTS + "/" +
! ROW + "[@" + ROW_NUMBER + "=" + rowIndex + "]/" +
! COLUMN + "[@" + COLUMN_NUMBER + "=" + columnIndex + "]";
Node n;
--- 147,153 ----
// This is the xpath for a cell in an XML data document from the SqlQuery
// pipeline stage
! String xpath = QUERY_RESULTS + "/" + QUERY + "/" +
! ROW + "[@" + ROW_NUMBER + "=\"" + rowIndex + "\"]/" +
! COLUMN + "[@" + COLUMN_NUMBER + "=\"" + (columnIndex + 1) + "\"]";
Node n;
***************
*** 161,170 ****
Object v;
try {
! Class c = Class.forName(className).getClass();
Constructor cons = c.getConstructor(new Class[] {String.class});
! v = cons.newInstance(new Object[] {n.getNodeValue()});
} catch (Exception e) {
! log.logWarn(e.getMessage());
! v = new String("[" + I18n.get("jfr.104", className) + "]");
}
--- 167,182 ----
Object v;
try {
! Class c = Class.forName(className);
Constructor cons = c.getConstructor(new Class[] {String.class});
! if (n.getFirstChild() == null) {
! v = null;
! } else {
! v = cons.newInstance(new Object[] {n.getFirstChild().getNodeValue()});
! }
} catch (Exception e) {
! e.printStackTrace();
! //log.logWarn(e.getMessage());
! v = "";
! //v = new String("[" + I18n.get("jfr.104", className) + "]");
}
***************
*** 191,198 ****
// This is the xpath for a cell in an XML data document from the SqlQuery
// pipeline stage
! String xpath = QUERY_RESULTS + "/" +
! ROW + "[1]/" +
! COLUMN + "[@" + COLUMN_NUMBER + "=" + columnIndex + "]";
!
Node n;
try {
--- 203,209 ----
// This is the xpath for a cell in an XML data document from the SqlQuery
// pipeline stage
! String xpath = QUERY_RESULTS + "/" + QUERY + "/" +
! ROW + "[@row-number=\"0\"]/" +
! COLUMN + "[@" + COLUMN_NUMBER + "=\"" + (columnIndex + 1) + "\"]";
Node n;
try {
***************
*** 208,214 ****
className = DEFAULT_CLASS_NAME;
}
!
try {
! c = Class.forName(className).getClass();
} catch (ClassNotFoundException e) {
log.logWarn(e.getMessage());
--- 219,225 ----
className = DEFAULT_CLASS_NAME;
}
!
try {
! c = Class.forName(className);
} catch (ClassNotFoundException e) {
log.logWarn(e.getMessage());
***************
*** 217,221 ****
columnClasses[columnIndex] = c;
}
! return c;
}
--- 228,232 ----
columnClasses[columnIndex] = c;
}
! return (c);
}
***************
*** 227,241 ****
*/
public String getColumnName(int column) {
! String name = columnNames[column];
if (name == null) {
-
if (xmlData == null) return (null);
// This is the xpath for a cell in an XML data document from the SqlQuery
// pipeline stage
! String xpath = QUERY_RESULTS + "/" +
! ROW + "[1]/" +
! COLUMN + "[@" + COLUMN_NUMBER + "=" + column + "]";
!
Node n;
try {
--- 238,251 ----
*/
public String getColumnName(int column) {
! String name;
! name = columnNames[column];
if (name == null) {
if (xmlData == null) return (null);
// This is the xpath for a cell in an XML data document from the SqlQuery
// pipeline stage
! String xpath = QUERY_RESULTS + "/" + QUERY + "/" +
! ROW + "[@row-number=\"0\"]/" +
! COLUMN + "[@" + COLUMN_NUMBER + "=\"" + (column + 1) + "\"]";
Node n;
try {
***************
*** 269,276 ****
// This is the xpath for the count of columns in the first row
! String xpath = QUERY_RESULTS + "/" +
! ROW + "[1]/" +
! COLUMN + "[@" + COLUMN_NAME + "=" + columnName + "]";
!
Node n;
try {
--- 279,285 ----
// This is the xpath for the count of columns in the first row
! String xpath = QUERY_RESULTS + "/" + QUERY + "/" +
! ROW + "[@row-number=\"0\"]/" +
! COLUMN + "[@" + COLUMN_NAME + "=\"" + columnName + "\"]";
Node n;
try {
***************
*** 282,286 ****
NamedNodeMap attrs = n.getAttributes();
! columnNumber = new Integer(attrs.getNamedItem(COLUMN_NAME).getNodeValue());
columnNumbers.put(columnName, columnNumber);
--- 291,295 ----
NamedNodeMap attrs = n.getAttributes();
! columnNumber = new Integer(attrs.getNamedItem(COLUMN_NUMBER).getNodeValue());
columnNumbers.put(columnName, columnNumber);
***************
*** 288,292 ****
}
! return (columnNumber.intValue());
}
--- 297,301 ----
}
! return (columnNumber.intValue() - 1);
}
|
|
From: <mic...@us...> - 2003-11-28 09:16:32
|
Update of /cvsroot/babeldoc/babeldoc/modules/jfreereports/src/com/babeldoc/jfreereports/pipeline/stage
In directory sc8-pr-cvs1:/tmp/cvs-serv31272/modules/jfreereports/src/com/babeldoc/jfreereports/pipeline/stage
Modified Files:
Tag: TEMP_MIKEA
JFRPipelineStage.java
Log Message:
Added some implementations of AbstractTableModel default methods
Index: JFRPipelineStage.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/jfreereports/src/com/babeldoc/jfreereports/pipeline/stage/Attic/JFRPipelineStage.java,v
retrieving revision 1.1.2.7
retrieving revision 1.1.2.8
diff -C2 -d -r1.1.2.7 -r1.1.2.8
*** JFRPipelineStage.java 26 Nov 2003 17:14:09 -0000 1.1.2.7
--- JFRPipelineStage.java 28 Nov 2003 09:16:28 -0000 1.1.2.8
***************
*** 173,176 ****
--- 173,177 ----
TableModel tm = getTableModel();
// Create a report with the correct definition
+ log.logDebug(xmlReportDefinition);
StringReader reader = new StringReader (xmlReportDefinition);
URL contentBaseURL = new URL ("file:///");
***************
*** 259,263 ****
--- 260,267 ----
URL urlReportDefinitionUrl;
try {
+ log.logDebug("Report definition URL found in stage options");
xmlReportDefinition = getStringFromFile(new File(strReportDefinitionUrl));
+ } catch (java.net.MalformedURLException e) {
+ throw new PipelineException(I18n.get("jfr.102"), e);
} catch (IOException e) {
throw new PipelineException(I18n.get("jfr.103"), e);
|
|
From: <mic...@us...> - 2003-11-28 09:16:32
|
Update of /cvsroot/babeldoc/babeldoc/modules/jfreereports/src/com/babeldoc/utils
In directory sc8-pr-cvs1:/tmp/cvs-serv31272/modules/jfreereports/src/com/babeldoc/utils
Modified Files:
Tag: TEMP_MIKEA
XMLTableModel.java
Log Message:
Added some implementations of AbstractTableModel default methods
Index: XMLTableModel.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/jfreereports/src/com/babeldoc/utils/Attic/XMLTableModel.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -C2 -d -r1.1.2.2 -r1.1.2.3
*** XMLTableModel.java 25 Nov 2003 08:01:31 -0000 1.1.2.2
--- XMLTableModel.java 28 Nov 2003 09:16:29 -0000 1.1.2.3
***************
*** 8,14 ****
import com.babeldoc.core.LogService;
-
import com.babeldoc.core.I18n;
import java.lang.reflect.Constructor;
import javax.swing.table.AbstractTableModel;
--- 8,16 ----
import com.babeldoc.core.LogService;
import com.babeldoc.core.I18n;
+
import java.lang.reflect.Constructor;
+ import java.util.HashMap;
+ import java.util.Map;
import javax.swing.table.AbstractTableModel;
***************
*** 16,19 ****
--- 18,23 ----
import javax.xml.transform.TransformerException;
+ import org.apache.xpath.objects.XNumber;
+ import org.apache.xpath.objects.XObject;
import org.apache.xpath.XPathAPI;
***************
*** 46,54 ****
public static final String COLUMN_NUMBER = "column-number";
public static final String COLUMN_CLASS = "column-class";
! public static final String DEFAULT_CLASS = "java.lang.String";
private Document xmlData;
private int columnCount = -1;
private int rowCount = -1;
public XMLTableModel() {
--- 50,62 ----
public static final String COLUMN_NUMBER = "column-number";
public static final String COLUMN_CLASS = "column-class";
! public static final String DEFAULT_CLASS_NAME = "java.lang.String";
! public static final Class DEFAULT_CLASS = java.lang.String.class;
private Document xmlData;
private int columnCount = -1;
private int rowCount = -1;
+ private Class[] columnClasses;
+ private String[] columnNames;
+ private Map columnNumbers = new HashMap();
public XMLTableModel() {
***************
*** 62,65 ****
--- 70,74 ----
public void setDocument(org.dom4j.Document doc) throws org.dom4j.DocumentException {
xmlData = transformToDOM(doc);
+ columnClasses = new Class[getColumnCount()];
}
***************
*** 80,86 ****
")";
! Node n;
try {
! n = XPathAPI.selectSingleNode(xmlData, xpath);
} catch (TransformerException e) {
log.logError(e);
--- 89,95 ----
")";
! XNumber n;
try {
! n = (XNumber) XPathAPI.eval(xmlData, xpath);
} catch (TransformerException e) {
log.logError(e);
***************
*** 89,93 ****
// Get the result value from the node and cache
! columnCount = new Integer(n.getNodeValue()).intValue();
return (columnCount);
--- 98,102 ----
// Get the result value from the node and cache
! columnCount = new Double(n.num()).intValue();
return (columnCount);
***************
*** 109,115 ****
")";
! Node n;
try {
! n = XPathAPI.selectSingleNode(xmlData, xpath);
} catch (TransformerException e) {
log.logError(e);
--- 118,124 ----
")";
! XNumber n;
try {
! n = (XNumber) XPathAPI.eval(xmlData, xpath);
} catch (TransformerException e) {
log.logError(e);
***************
*** 118,122 ****
// Get the result value from the node and cache
! rowCount = new Integer(n.getNodeValue()).intValue();
return (rowCount);
--- 127,131 ----
// Get the result value from the node and cache
! rowCount = new Double(n.num()).intValue();
return (rowCount);
***************
*** 147,151 ****
String className = attrs.getNamedItem(COLUMN_CLASS).getNodeValue();
if (className == null || className.equals("")) {
! className = DEFAULT_CLASS;
}
--- 156,160 ----
String className = attrs.getNamedItem(COLUMN_CLASS).getNodeValue();
if (className == null || className.equals("")) {
! className = DEFAULT_CLASS_NAME;
}
***************
*** 167,169 ****
--- 176,293 ----
return writer.write(doc);
}
+
+ /**
+ * Returns the class of the column specified
+ *
+ * @param columnIndex the column being queried
+ * @return the Object.class
+ */
+ public Class getColumnClass(int columnIndex) {
+ Class c = columnClasses[columnIndex];
+ if (c == null) {
+
+ if (xmlData == null) return (null);
+
+ // This is the xpath for a cell in an XML data document from the SqlQuery
+ // pipeline stage
+ String xpath = QUERY_RESULTS + "/" +
+ ROW + "[1]/" +
+ COLUMN + "[@" + COLUMN_NUMBER + "=" + columnIndex + "]";
+
+ Node n;
+ try {
+ n = XPathAPI.selectSingleNode(xmlData, xpath);
+ } catch (TransformerException e) {
+ log.logError(e);
+ return null;
+ }
+
+ NamedNodeMap attrs = n.getAttributes();
+ String className = attrs.getNamedItem(COLUMN_CLASS).getNodeValue();
+ if (className == null || className.equals("")) {
+ className = DEFAULT_CLASS_NAME;
+ }
+
+ try {
+ c = Class.forName(className).getClass();
+ } catch (ClassNotFoundException e) {
+ log.logWarn(e.getMessage());
+ c = DEFAULT_CLASS;
+ }
+ columnClasses[columnIndex] = c;
+ }
+ return c;
+ }
+
+ /**
+ * Returns the column name for the column index specified
+ *
+ * @param column the column being queried
+ * @return a string containing the default name of <code>column</code>
+ */
+ public String getColumnName(int column) {
+ String name = columnNames[column];
+ if (name == null) {
+
+ if (xmlData == null) return (null);
+
+ // This is the xpath for a cell in an XML data document from the SqlQuery
+ // pipeline stage
+ String xpath = QUERY_RESULTS + "/" +
+ ROW + "[1]/" +
+ COLUMN + "[@" + COLUMN_NUMBER + "=" + column + "]";
+
+ Node n;
+ try {
+ n = XPathAPI.selectSingleNode(xmlData, xpath);
+ } catch (TransformerException e) {
+ log.logError(e);
+ return null;
+ }
+
+ NamedNodeMap attrs = n.getAttributes();
+ name = attrs.getNamedItem(COLUMN_NAME).getNodeValue();
+
+ columnNames[column] = name;
+ }
+ return (name);
+ }
+
+ /**
+ * Returns a column index given its name.
+ *
+ * @param columnName string containing name of column to be located
+ * @return the column with <code>columnName</code>, or -1 if not found
+ */
+ public int findColumn(String columnName) {
+
+ if (xmlData == null) return (-1);
+
+ Integer columnNumber = (Integer) columnNumbers.get(columnName);
+
+ if (columnNumber == null) {
+
+ // This is the xpath for the count of columns in the first row
+ String xpath = QUERY_RESULTS + "/" +
+ ROW + "[1]/" +
+ COLUMN + "[@" + COLUMN_NAME + "=" + columnName + "]";
+
+ Node n;
+ try {
+ n = XPathAPI.selectSingleNode(xmlData, xpath);
+ } catch (TransformerException e) {
+ log.logError(e);
+ return -1;
+ }
+
+ NamedNodeMap attrs = n.getAttributes();
+ columnNumber = new Integer(attrs.getNamedItem(COLUMN_NAME).getNodeValue());
+
+ columnNumbers.put(columnName, columnNumber);
+
+ }
+
+ return (columnNumber.intValue());
+ }
+
}
|
|
From: <mic...@us...> - 2003-11-26 17:14:12
|
Update of /cvsroot/babeldoc/babeldoc/modules/jfreereports/src/com/babeldoc/jfreereports/pipeline/stage
In directory sc8-pr-cvs1:/tmp/cvs-serv14486/modules/jfreereports/src/com/babeldoc/jfreereports/pipeline/stage
Modified Files:
Tag: TEMP_MIKEA
JFRPipelineStage.java
Log Message:
Some gentle refactoring...
Index: JFRPipelineStage.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/jfreereports/src/com/babeldoc/jfreereports/pipeline/stage/Attic/JFRPipelineStage.java,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -C2 -d -r1.1.2.6 -r1.1.2.7
*** JFRPipelineStage.java 26 Nov 2003 13:24:30 -0000 1.1.2.6
--- JFRPipelineStage.java 26 Nov 2003 17:14:09 -0000 1.1.2.7
***************
*** 237,249 ****
URL urlReportDefinitionUrl;
try {
! File file = new File(strReportDefinitionUrl);
! BufferedInputStream in = new BufferedInputStream(new FileInputStream(file));
! byte[] b = new byte[in.available()];
! in.read(b, 0, b.length);
! String s = new String(b, 0, b.length);
! in.close();
! xmlReportDefinition = s;
! } catch (java.net.MalformedURLException e) {
! throw new PipelineException(I18n.get("jfr.102"), e);
} catch (IOException e) {
throw new PipelineException(I18n.get("jfr.103"), e);
--- 237,241 ----
URL urlReportDefinitionUrl;
try {
! xmlReportDefinition = getStringFromFile(new File(strReportDefinitionUrl));
} catch (IOException e) {
throw new PipelineException(I18n.get("jfr.103"), e);
***************
*** 267,279 ****
URL urlReportDefinitionUrl;
try {
! File file = new File(strReportDefinitionUrl);
! BufferedInputStream in = new BufferedInputStream(new FileInputStream(file));
! byte[] b = new byte[in.available()];
! in.read(b, 0, b.length);
! String s = new String(b, 0, b.length);
! in.close();
! xmlReportDefinition = s;
! } catch (java.net.MalformedURLException e) {
! throw new PipelineException(I18n.get("jfr.102"), e);
} catch (IOException e) {
throw new PipelineException(I18n.get("jfr.103"), e);
--- 259,263 ----
URL urlReportDefinitionUrl;
try {
! xmlReportDefinition = getStringFromFile(new File(strReportDefinitionUrl));
} catch (IOException e) {
throw new PipelineException(I18n.get("jfr.103"), e);
***************
*** 334,340 ****
return bytes;
}
!
private String getTempFilename() {
return ("tempfile");
}
}
--- 318,338 ----
return bytes;
}
!
private String getTempFilename() {
return ("tempfile");
+ }
+
+ private String getStringFromFile(File file) throws java.io.IOException {
+ String s = null;
+ try {
+ BufferedInputStream in = new BufferedInputStream(new FileInputStream(file));
+ byte[] b = new byte[in.available()];
+ in.read(b, 0, b.length);
+ s = new String(b, 0, b.length);
+ in.close();
+ } catch (java.io.FileNotFoundException e1) {
+ s = "";
+ }
+ return (s);
}
}
|
|
From: <mic...@us...> - 2003-11-26 13:24:33
|
Update of /cvsroot/babeldoc/babeldoc/modules/jfreereports/src/com/babeldoc/jfreereports/pipeline/stage
In directory sc8-pr-cvs1:/tmp/cvs-serv32146/modules/jfreereports/src/com/babeldoc/jfreereports/pipeline/stage
Modified Files:
Tag: TEMP_MIKEA
JFRPipelineStage.java
Log Message:
Got the file loading right
Index: JFRPipelineStage.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/jfreereports/src/com/babeldoc/jfreereports/pipeline/stage/Attic/JFRPipelineStage.java,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -C2 -d -r1.1.2.5 -r1.1.2.6
*** JFRPipelineStage.java 26 Nov 2003 08:39:39 -0000 1.1.2.5
--- JFRPipelineStage.java 26 Nov 2003 13:24:30 -0000 1.1.2.6
***************
*** 83,86 ****
--- 83,87 ----
import com.babeldoc.utils.XMLTableModel;
+ import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.File;
***************
*** 236,241 ****
URL urlReportDefinitionUrl;
try {
! urlReportDefinitionUrl = new URL(strReportDefinitionUrl);
! xmlReportDefinition = (String) urlReportDefinitionUrl.getContent();
} catch (java.net.MalformedURLException e) {
throw new PipelineException(I18n.get("jfr.102"), e);
--- 237,247 ----
URL urlReportDefinitionUrl;
try {
! File file = new File(strReportDefinitionUrl);
! BufferedInputStream in = new BufferedInputStream(new FileInputStream(file));
! byte[] b = new byte[in.available()];
! in.read(b, 0, b.length);
! String s = new String(b, 0, b.length);
! in.close();
! xmlReportDefinition = s;
} catch (java.net.MalformedURLException e) {
throw new PipelineException(I18n.get("jfr.102"), e);
***************
*** 261,271 ****
URL urlReportDefinitionUrl;
try {
! urlReportDefinitionUrl = new URL(strReportDefinitionUrl);
! StringWriter sw = new StringWriter();
! FileInputStream fis = (FileInputStream) urlReportDefinitionUrl.getContent();
!
! xmlReportDefinition =
! log.logInfo(urlReportDefinitionUrl.getContent().getClass().getName());
! log.logDebug("Report definition URL found in stage options");
} catch (java.net.MalformedURLException e) {
throw new PipelineException(I18n.get("jfr.102"), e);
--- 267,277 ----
URL urlReportDefinitionUrl;
try {
! File file = new File(strReportDefinitionUrl);
! BufferedInputStream in = new BufferedInputStream(new FileInputStream(file));
! byte[] b = new byte[in.available()];
! in.read(b, 0, b.length);
! String s = new String(b, 0, b.length);
! in.close();
! xmlReportDefinition = s;
} catch (java.net.MalformedURLException e) {
throw new PipelineException(I18n.get("jfr.102"), e);
|
|
From: <mic...@us...> - 2003-11-26 08:39:42
|
Update of /cvsroot/babeldoc/babeldoc
In directory sc8-pr-cvs1:/tmp/cvs-serv13849
Modified Files:
Tag: TEMP_MIKEA
build.xml
Log Message:
Some jfreereports debugging...
Index: build.xml
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/build.xml,v
retrieving revision 1.16.2.2
retrieving revision 1.16.2.3
diff -C2 -d -r1.16.2.2 -r1.16.2.3
*** build.xml 21 Nov 2003 09:17:04 -0000 1.16.2.2
--- build.xml 26 Nov 2003 08:39:39 -0000 1.16.2.3
***************
*** 250,253 ****
--- 250,254 ----
<include name="babeldoc_crypto.jar"/>
<include name="babeldoc_init.jar"/>
+ <include name="babeldoc_jfreereports.jar"/>
<include name="babeldoc-scanner.jar"/>
<include name="babeldoc_sql.jar"/>
***************
*** 270,273 ****
--- 271,276 ----
<include name="csv19.jar"/>
<include name="dom4j-full.jar"/>
+ <include name="jcommon-0.8.5.jar"/>
+ <include name="jfreereport-0.8.4_4-all.jar"/>
<include name="poi.jar"/>
<include name="velocity.jar"/>
|
|
From: <mic...@us...> - 2003-11-26 08:39:42
|
Update of /cvsroot/babeldoc/babeldoc/modules/sql/src/com/babeldoc/sql/pipeline/stage
In directory sc8-pr-cvs1:/tmp/cvs-serv13849/modules/sql/src/com/babeldoc/sql/pipeline/stage
Modified Files:
Tag: TEMP_MIKEA
SqlQueryPipelineStage.java
Log Message:
Some jfreereports debugging...
Index: SqlQueryPipelineStage.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/sql/src/com/babeldoc/sql/pipeline/stage/SqlQueryPipelineStage.java,v
retrieving revision 1.6.2.2
retrieving revision 1.6.2.3
diff -C2 -d -r1.6.2.2 -r1.6.2.3
*** SqlQueryPipelineStage.java 24 Nov 2003 09:01:19 -0000 1.6.2.2
--- SqlQueryPipelineStage.java 26 Nov 2003 08:39:39 -0000 1.6.2.3
***************
*** 272,276 ****
}
}
- log.logInfo("Resultset size: " + rs.getRow());
}
--- 272,275 ----
|
|
From: <mic...@us...> - 2003-11-26 08:39:42
|
Update of /cvsroot/babeldoc/babeldoc/modules/jfreereports
In directory sc8-pr-cvs1:/tmp/cvs-serv13849/modules/jfreereports
Modified Files:
Tag: TEMP_MIKEA
build.xml
Log Message:
Some jfreereports debugging...
Index: build.xml
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/jfreereports/Attic/build.xml,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -d -r1.1.2.1 -r1.1.2.2
*** build.xml 12 Nov 2003 22:18:06 -0000 1.1.2.1
--- build.xml 26 Nov 2003 08:39:39 -0000 1.1.2.2
***************
*** 39,42 ****
--- 39,48 ----
</copy>
+ <!-- copy over the services file -->
+ <mkdir dir="${module_path}/META-INF/services"/>
+ <copy toDir="${module_path}/META-INF/services">
+ <fileset dir="services"/>
+ </copy>
+
<jar
jarfile="${base_dir}/build/lib/${Jarfile}"
|
|
From: <mic...@us...> - 2003-11-26 08:39:42
|
Update of /cvsroot/babeldoc/babeldoc/modules/sql
In directory sc8-pr-cvs1:/tmp/cvs-serv13849/modules/sql
Modified Files:
Tag: TEMP_MIKEA
build.xml
Log Message:
Some jfreereports debugging...
Index: build.xml
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/sql/build.xml,v
retrieving revision 1.8.2.1
retrieving revision 1.8.2.2
diff -C2 -d -r1.8.2.1 -r1.8.2.2
*** build.xml 12 Nov 2003 22:18:06 -0000 1.8.2.1
--- build.xml 26 Nov 2003 08:39:39 -0000 1.8.2.2
***************
*** 50,55 ****
<jar
jarfile="${base_dir}/build/lib/${Jarfile}"
! basedir="${module_path}"
! compress="false">
<manifest>
<attribute name="Built-By" value="${user.name}"/>
--- 50,54 ----
<jar
jarfile="${base_dir}/build/lib/${Jarfile}"
! basedir="${module_path}">
<manifest>
<attribute name="Built-By" value="${user.name}"/>
|
|
From: <mic...@us...> - 2003-11-26 08:39:42
|
Update of /cvsroot/babeldoc/babeldoc/modules/jfreereports/src/com/babeldoc/jfreereports/pipeline/stage
In directory sc8-pr-cvs1:/tmp/cvs-serv13849/modules/jfreereports/src/com/babeldoc/jfreereports/pipeline/stage
Modified Files:
Tag: TEMP_MIKEA
JFRPipelineStage.java
Log Message:
Some jfreereports debugging...
Index: JFRPipelineStage.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/jfreereports/src/com/babeldoc/jfreereports/pipeline/stage/Attic/JFRPipelineStage.java,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -C2 -d -r1.1.2.4 -r1.1.2.5
*** JFRPipelineStage.java 25 Nov 2003 17:44:37 -0000 1.1.2.4
--- JFRPipelineStage.java 26 Nov 2003 08:39:39 -0000 1.1.2.5
***************
*** 86,89 ****
--- 86,90 ----
import java.io.File;
import java.io.FileWriter;
+ import java.io.StringWriter;
import java.lang.reflect.Constructor;
import java.net.URL;
***************
*** 261,265 ****
try {
urlReportDefinitionUrl = new URL(strReportDefinitionUrl);
! xmlReportDefinition = (String) urlReportDefinitionUrl.getContent();
log.logDebug("Report definition URL found in stage options");
} catch (java.net.MalformedURLException e) {
--- 262,270 ----
try {
urlReportDefinitionUrl = new URL(strReportDefinitionUrl);
! StringWriter sw = new StringWriter();
! FileInputStream fis = (FileInputStream) urlReportDefinitionUrl.getContent();
!
! xmlReportDefinition =
! log.logInfo(urlReportDefinitionUrl.getContent().getClass().getName());
log.logDebug("Report definition URL found in stage options");
} catch (java.net.MalformedURLException e) {
|
|
From: <mic...@us...> - 2003-11-26 08:37:39
|
Update of /cvsroot/babeldoc/babeldoc/modules/jfreereports/config/service
In directory sc8-pr-cvs1:/tmp/cvs-serv13544/modules/jfreereports/config/service
Added Files:
Tag: TEMP_MIKEA
query.properties
Log Message:
Configuration info for the jfreereports module
--- NEW FILE: query.properties ---
PipelineStage.JFreeReport=com.babeldoc.jfreereports.pipeline.stage.JFRPipelineStage
|
|
From: <mic...@us...> - 2003-11-26 08:36:21
|
Update of /cvsroot/babeldoc/babeldoc/modules/jfreereports/config/service In directory sc8-pr-cvs1:/tmp/cvs-serv13352/modules/jfreereports/config/service Log Message: Directory /cvsroot/babeldoc/babeldoc/modules/jfreereports/config/service added to the repository --> Using per-directory sticky tag `TEMP_MIKEA' |
|
From: <mic...@us...> - 2003-11-25 17:44:40
|
Update of /cvsroot/babeldoc/babeldoc/modules/jfreereports/src/com/babeldoc/jfreereports/pipeline/stage
In directory sc8-pr-cvs1:/tmp/cvs-serv14655/modules/jfreereports/src/com/babeldoc/jfreereports/pipeline/stage
Modified Files:
Tag: TEMP_MIKEA
JFRPipelineStage.java
Log Message:
Added some logging
Index: JFRPipelineStage.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/jfreereports/src/com/babeldoc/jfreereports/pipeline/stage/Attic/JFRPipelineStage.java,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -C2 -d -r1.1.2.3 -r1.1.2.4
*** JFRPipelineStage.java 24 Nov 2003 09:01:19 -0000 1.1.2.3
--- JFRPipelineStage.java 25 Nov 2003 17:44:37 -0000 1.1.2.4
***************
*** 229,234 ****
--- 229,236 ----
// If unsuccessful, then try for a report definition URL from the document attributes
if (xmlReportDefinition == null) {
+ log.logDebug("No report definition document attribute, trying for URL document attribute");
strReportDefinitionUrl = (String) getDocument().get(REPORT_DEF_URL);
if (strReportDefinitionUrl != null) {
+ log.logDebug("Report definition URL found in document attribute");
URL urlReportDefinitionUrl;
try {
***************
*** 240,251 ****
--- 242,259 ----
throw new PipelineException(I18n.get("jfr.103"), e);
}
+ } else {
+ log.logDebug("Report definition URL not found in document attribute");
}
+ } else {
+ log.logDebug("Report definition found in document attribute");
}
// If still unsuccessful, then try the stage definition for a report definition
if (xmlReportDefinition == null) {
+ log.logDebug("Trying for report definition in stage option");
xmlReportDefinition = (String) this.getInfo().getOption(REPORT_DEF).getValue();
}
// Otherwise a report definition URL from the stage definition
if (xmlReportDefinition == null) {
+ log.logDebug("Try for report definition URL in stage options");
strReportDefinitionUrl = (String) this.getInfo().getOption(REPORT_DEF_URL).getValue();
if (strReportDefinitionUrl != null) {
***************
*** 254,257 ****
--- 262,266 ----
urlReportDefinitionUrl = new URL(strReportDefinitionUrl);
xmlReportDefinition = (String) urlReportDefinitionUrl.getContent();
+ log.logDebug("Report definition URL found in stage options");
} catch (java.net.MalformedURLException e) {
throw new PipelineException(I18n.get("jfr.102"), e);
***************
*** 260,263 ****
--- 269,274 ----
}
}
+ } else {
+ log.logDebug("Report definition found in stage options");
}
return (xmlReportDefinition);
|
|
From: <mic...@us...> - 2003-11-25 08:13:28
|
Update of /cvsroot/babeldoc/babeldoc/modules/jfreereports/src/com/babeldoc/utils
In directory sc8-pr-cvs1:/tmp/cvs-serv10917/modules/jfreereports/src/com/babeldoc/utils
Modified Files:
Tag: TEMP_MIKEA
XMLTableModel.java
Log Message:
Removed the gotXXXCount internal variables, now using -1 to indicate values not calculated yet.
Index: XMLTableModel.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/jfreereports/src/com/babeldoc/utils/Attic/XMLTableModel.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -d -r1.1.2.1 -r1.1.2.2
*** XMLTableModel.java 21 Nov 2003 09:17:04 -0000 1.1.2.1
--- XMLTableModel.java 25 Nov 2003 08:01:31 -0000 1.1.2.2
***************
*** 21,25 ****
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
- import org.w3c.dom.traversal.NodeIterator;
import org.dom4j.io.DOMWriter;
--- 21,24 ----
***************
*** 50,57 ****
private Document xmlData;
! private boolean gotColumnCount = false;
! private int columnCount;
! private boolean gotRowCount = false;
! private int rowCount;
public XMLTableModel() {
--- 49,54 ----
private Document xmlData;
! private int columnCount = -1;
! private int rowCount = -1;
public XMLTableModel() {
***************
*** 74,78 ****
if (xmlData == null) return (0);
! if (gotColumnCount) return (columnCount);
// This is the xpath for the count of columns in the first row
--- 71,75 ----
if (xmlData == null) return (0);
! if (columnCount >= 0) return (columnCount);
// This is the xpath for the count of columns in the first row
***************
*** 93,97 ****
// Get the result value from the node and cache
columnCount = new Integer(n.getNodeValue()).intValue();
- gotColumnCount = true;
return (columnCount);
--- 90,93 ----
***************
*** 105,109 ****
if (xmlData == null) return (0);
! if (gotRowCount) return (rowCount);
// This is the xpath for the count of columns in the first row
--- 101,105 ----
if (xmlData == null) return (0);
! if (rowCount >= 0) return (rowCount);
// This is the xpath for the count of columns in the first row
***************
*** 123,127 ****
// Get the result value from the node and cache
rowCount = new Integer(n.getNodeValue()).intValue();
- gotRowCount = true;
return (rowCount);
--- 119,122 ----
|
|
From: <mic...@us...> - 2003-11-24 09:01:23
|
Update of /cvsroot/babeldoc/babeldoc/modules/jfreereports/src/com/babeldoc/jfreereports/pipeline/stage
In directory sc8-pr-cvs1:/tmp/cvs-serv5852/modules/jfreereports/src/com/babeldoc/jfreereports/pipeline/stage
Modified Files:
Tag: TEMP_MIKEA
JFRPipelineStage.java
Log Message:
Added some debug logging to a few classes
Index: JFRPipelineStage.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/jfreereports/src/com/babeldoc/jfreereports/pipeline/stage/Attic/JFRPipelineStage.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -C2 -d -r1.1.2.2 -r1.1.2.3
*** JFRPipelineStage.java 21 Nov 2003 09:17:04 -0000 1.1.2.2
--- JFRPipelineStage.java 24 Nov 2003 09:01:19 -0000 1.1.2.3
***************
*** 92,95 ****
--- 92,98 ----
import java.util.Collection;
import java.util.Iterator;
+ import java.io.FileInputStream;
+ import java.io.InputStream;
+ import java.io.StringReader;
import javax.swing.table.DefaultTableModel;
***************
*** 107,110 ****
--- 110,115 ----
import org.jfree.report.modules.output.pageable.pdf.PDFReportUtil;
+ import org.xml.sax.InputSource;
+
/**
* @author mikea
***************
*** 159,195 ****
// Find the report definition
String xmlReportDefinition = getReportDefinition();
- File f = new File(System.getProperties().get("java.io.tmpdir") + "/tmprpt.xml");
- try {
- FileWriter writer = new FileWriter(f);
- writer.write(xmlReportDefinition);
- writer.flush();
- writer.close();
- } catch (java.io.IOException e) {
- log.logError(e);
- }
-
- // Set up the table model
- TableModel tm = null;
- try {
- tm = getTableModel();
- } catch (DocumentException e) {
- log.logError(e);
- }
- ReportGenerator gen = ReportGenerator.getInstance();
JFreeReport report = null;
try {
! report = gen.parseReport(f);
! } catch (java.io.IOException e) {
! log.logError(e);
} catch (org.jfree.xml.ElementDefinitionException e2) {
log.logError(e2);
}
! report.setData(tm);
!
! PDFReportUtil.createPDF(report, System.getProperties().get("java.io.tmpdir") + "/output.pdf");
!
! // TODO Auto-generated method stub
! return null;
}
--- 164,210 ----
// Find the report definition
String xmlReportDefinition = getReportDefinition();
JFreeReport report = null;
+ String outputFile = null;
try {
! // Set up the table model
! TableModel tm = getTableModel();
! // Create a report with the correct definition
! StringReader reader = new StringReader (xmlReportDefinition);
! URL contentBaseURL = new URL ("file:///");
! report = ReportGenerator.getInstance().parseReport(new InputSource(reader), contentBaseURL);
! // Put the data in
! report.setData(tm);
! // Generate the report output
! outputFile = getTempFilename() + ".pdf";
! PDFReportUtil.createPDF(report, outputFile);
! } catch (java.net.MalformedURLException e1) {
! // From new URL()
! log.logError(e1);
! throw new PipelineException(I18n.get("jfr.105"), e1);
} catch (org.jfree.xml.ElementDefinitionException e2) {
+ // From parseReport()
log.logError(e2);
+ throw new PipelineException(I18n.get("jfr.106"), e2);
+ } catch (DocumentException e3) {
+ // From getTableModel()
+ log.logError(e3);
+ throw new PipelineException(I18n.get("jfr.107"), e3);
}
!
! PipelineDocument newDocument = null;
! if (outputFile == null || outputFile.equals("")) {
! try {
! byte[] data = getBytesFromFile(new File(outputFile));
! newDocument = new PipelineDocument(this.getDocument(), data);
! newDocument.setBinary(true);
! newDocument.setMimeType("application/pdf");
! } catch (java.io.IOException e) {
! log.logError(e);
! throw new PipelineException(I18n.get("jfr.108"), e);
! }
!
! }
! return super.processHelper(newDocument);
}
***************
*** 262,265 ****
--- 277,318 ----
tm.setDocument(doc);
return (tm);
+ }
+ // Returns the contents of the file in a byte array.
+ public byte[] getBytesFromFile(File file) throws IOException {
+ InputStream is = new FileInputStream(file);
+
+ // Get the size of the file
+ long length = file.length();
+
+ // You cannot create an array using a long type.
+ // It needs to be an int type.
+ // Before converting to an int type, check
+ // to ensure that file is not larger than Integer.MAX_VALUE.
+ if (length > Integer.MAX_VALUE) {
+ // File is too large
+ }
+
+ // Create the byte array to hold the data
+ byte[] bytes = new byte[(int)length];
+
+ // Read in the bytes
+ int offset = 0;
+ int numRead = 0;
+ while (offset < bytes.length && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) {
+ offset += numRead;
+ }
+
+ // Ensure all the bytes have been read in
+ if (offset < bytes.length) {
+ throw new IOException("Could not completely read file "+file.getName());
+ }
+
+ // Close the input stream and return bytes
+ is.close();
+ return bytes;
+ }
+
+ private String getTempFilename() {
+ return ("tempfile");
}
}
|
|
From: <mic...@us...> - 2003-11-24 09:01:23
|
Update of /cvsroot/babeldoc/babeldoc/modules/sql/src/com/babeldoc/sql/pipeline/stage
In directory sc8-pr-cvs1:/tmp/cvs-serv5852/modules/sql/src/com/babeldoc/sql/pipeline/stage
Modified Files:
Tag: TEMP_MIKEA
SqlQueryPipelineStage.java
Log Message:
Added some debug logging to a few classes
Index: SqlQueryPipelineStage.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/sql/src/com/babeldoc/sql/pipeline/stage/SqlQueryPipelineStage.java,v
retrieving revision 1.6.2.1
retrieving revision 1.6.2.2
diff -C2 -d -r1.6.2.1 -r1.6.2.2
*** SqlQueryPipelineStage.java 12 Nov 2003 22:18:06 -0000 1.6.2.1
--- SqlQueryPipelineStage.java 24 Nov 2003 09:01:19 -0000 1.6.2.2
***************
*** 100,104 ****
public class SqlQueryPipelineStage
extends PipelineStage {
! /**
* constants
*/
--- 100,108 ----
public class SqlQueryPipelineStage
extends PipelineStage {
!
! private static LogService log =
! LogService.getInstance(SqlQueryPipelineStage.class.getName());
!
! /**
* constants
*/
***************
*** 187,206 ****
String sql = null;
try {
! conn = getConnection();
// Iterate through sqls
if ((queries != null) && (queries.length > 0)) {
for (int i = 0; i < queries.length; ++i) {
! Element queryElement = root.addElement(QUERY);
String queryName = queries[i].getName();
queryElement.addAttribute(QUERY_NAME, queryName);
queryElement.addAttribute(QUERY_NUMBER, Integer.toString(i));
sql = queries[i].getValue();
stmt = conn.createStatement();
! LogService.getInstance().logDebug("Executing " + sql);
rs = stmt.executeQuery(sql);
handleRows(rs, queryElement);
}
}
} catch (ResourceException e) {
--- 191,216 ----
String sql = null;
try {
! log.logDebug("Getting connection object");
! conn = getConnection();
// Iterate through sqls
if ((queries != null) && (queries.length > 0)) {
for (int i = 0; i < queries.length; ++i) {
! log.logDebug("Adding query root element");
! Element queryElement = root.addElement(QUERY);
String queryName = queries[i].getName();
+ log.logDebug("Adding query name");
queryElement.addAttribute(QUERY_NAME, queryName);
+ log.logDebug("Adding query number");
queryElement.addAttribute(QUERY_NUMBER, Integer.toString(i));
sql = queries[i].getValue();
stmt = conn.createStatement();
! log.logDebug("Executing " + sql);
rs = stmt.executeQuery(sql);
handleRows(rs, queryElement);
}
+ } else {
+ log.logWarn("No queries available for query pipeline stage");
}
} catch (ResourceException e) {
***************
*** 254,265 ****
columnElement.addAttribute(COLUMN_NAME, name);
columnElement.addAttribute(COLUMN_NUMBER, Integer.toString(j));
! columnElement.addAttribute(COLUMN_CLASS, metaData.getColumnClassName(j));
if(value!=null) {
! columnElement.setText(value.toString());
} else {
! columnElement.setText("");
}
}
}
}
--- 264,276 ----
columnElement.addAttribute(COLUMN_NAME, name);
columnElement.addAttribute(COLUMN_NUMBER, Integer.toString(j));
! columnElement.addAttribute(COLUMN_CLASS, metaData.getColumnClassName(j));
if(value!=null) {
! columnElement.setText(value.toString());
} else {
! columnElement.setText("");
}
}
}
+ log.logInfo("Resultset size: " + rs.getRow());
}
|
|
From: <mic...@us...> - 2003-11-24 09:01:22
|
Update of /cvsroot/babeldoc/babeldoc/modules/jfreereports/config/i18n
In directory sc8-pr-cvs1:/tmp/cvs-serv5852/modules/jfreereports/config/i18n
Modified Files:
Tag: TEMP_MIKEA
messages.properties
Log Message:
Added some debug logging to a few classes
Index: messages.properties
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/jfreereports/config/i18n/Attic/messages.properties,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -d -r1.1.2.1 -r1.1.2.2
*** messages.properties 12 Nov 2003 22:18:05 -0000 1.1.2.1
--- messages.properties 24 Nov 2003 09:01:18 -0000 1.1.2.2
***************
*** 8,10 ****
jfr.102=Invalid report definition URL
jfr.103=IO exception when retrieving report definition from URL
! jfr.104=Error loading data type {0}
\ No newline at end of file
--- 8,14 ----
jfr.102=Invalid report definition URL
jfr.103=IO exception when retrieving report definition from URL
! jfr.104=Error loading data type {0}
! jfr.105=Invalid content base URL
! jfr.106=Invalid report definition
! jfr.107=Invalid data document
! jfr.108=I/O error writing temp file
|
|
From: <mic...@us...> - 2003-11-21 09:17:08
|
Update of /cvsroot/babeldoc/babeldoc/modules/jfreereports/src/com/babeldoc/utils
In directory sc8-pr-cvs1:/tmp/cvs-serv16985/modules/jfreereports/src/com/babeldoc/utils
Added Files:
Tag: TEMP_MIKEA
XMLTableModel.java
Log Message:
New table model for XML files using XPath
--- NEW FILE: XMLTableModel.java ---
/*
* Created on 19-Nov-2003
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package com.babeldoc.utils;
import com.babeldoc.core.LogService;
import com.babeldoc.core.I18n;
import java.lang.reflect.Constructor;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableModel;
import javax.xml.transform.TransformerException;
import org.apache.xpath.XPathAPI;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.traversal.NodeIterator;
import org.dom4j.io.DOMWriter;
import org.dom4j.DocumentException;
/**
* @author mikea
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class XMLTableModel extends AbstractTableModel implements TableModel {
private static LogService log =
LogService.getInstance(XMLTableModel.class.getName());
public static final String XML_MIME_TYPE = "text/xml";
public static final String QUERY_RESULTS = "queryresults";
public static final String QUERY = "query";
public static final String QUERY_NAME = "query-name";
public static final String QUERY_NUMBER = "query-number";
public static final String ROW = "row";
public static final String ROW_NUMBER = "row-number";
public static final String COLUMN = "column";
public static final String COLUMN_NAME = "column-name";
public static final String COLUMN_NUMBER = "column-number";
public static final String COLUMN_CLASS = "column-class";
public static final String DEFAULT_CLASS = "java.lang.String";
private Document xmlData;
private boolean gotColumnCount = false;
private int columnCount;
private boolean gotRowCount = false;
private int rowCount;
public XMLTableModel() {
xmlData = null;
}
public XMLTableModel(org.dom4j.Document data) throws org.dom4j.DocumentException {
xmlData = transformToDOM(data);
}
public void setDocument(org.dom4j.Document doc) throws org.dom4j.DocumentException {
xmlData = transformToDOM(doc);
}
/* (non-Javadoc)
* @see javax.swing.table.TableModel#getColumnCount()
*/
public int getColumnCount() {
if (xmlData == null) return (0);
if (gotColumnCount) return (columnCount);
// This is the xpath for the count of columns in the first row
String xpath = "count(" +
QUERY_RESULTS + "/" +
ROW + "[1]/" +
COLUMN +
")";
Node n;
try {
n = XPathAPI.selectSingleNode(xmlData, xpath);
} catch (TransformerException e) {
log.logError(e);
return (-1);
}
// Get the result value from the node and cache
columnCount = new Integer(n.getNodeValue()).intValue();
gotColumnCount = true;
return (columnCount);
}
/* (non-Javadoc)
* @see javax.swing.table.TableModel#getRowCount()
*/
public int getRowCount() {
if (xmlData == null) return (0);
if (gotRowCount) return (rowCount);
// This is the xpath for the count of columns in the first row
String xpath = "count(" +
QUERY_RESULTS + "/" +
ROW +
")";
Node n;
try {
n = XPathAPI.selectSingleNode(xmlData, xpath);
} catch (TransformerException e) {
log.logError(e);
return (-1);
}
// Get the result value from the node and cache
rowCount = new Integer(n.getNodeValue()).intValue();
gotRowCount = true;
return (rowCount);
}
/* (non-Javadoc)
* @see javax.swing.table.TableModel#getValueAt(int, int)
*/
public Object getValueAt(int rowIndex, int columnIndex) {
if (xmlData == null) return (null);
// This is the xpath for a cell in an XML data document from the SqlQuery
// pipeline stage
String xpath = QUERY_RESULTS + "/" +
ROW + "[@" + ROW_NUMBER + "=" + rowIndex + "]/" +
COLUMN + "[@" + COLUMN_NUMBER + "=" + columnIndex + "]";
Node n;
try {
n = XPathAPI.selectSingleNode(xmlData, xpath);
} catch (TransformerException e) {
log.logError(e);
return null;
}
NamedNodeMap attrs = n.getAttributes();
String className = attrs.getNamedItem(COLUMN_CLASS).getNodeValue();
if (className == null || className.equals("")) {
className = DEFAULT_CLASS;
}
Object v;
try {
Class c = Class.forName(className).getClass();
Constructor cons = c.getConstructor(new Class[] {String.class});
v = cons.newInstance(new Object[] {n.getNodeValue()});
} catch (Exception e) {
log.logWarn(e.getMessage());
v = new String("[" + I18n.get("jfr.104", className) + "]");
}
return v;
}
private org.w3c.dom.Document transformToDOM(org.dom4j.Document doc) throws DocumentException {
DOMWriter writer = new DOMWriter();
return writer.write(doc);
}
}
|
|
From: <mic...@us...> - 2003-11-21 09:17:08
|
Update of /cvsroot/babeldoc/babeldoc
In directory sc8-pr-cvs1:/tmp/cvs-serv16985
Modified Files:
Tag: TEMP_MIKEA
build.xml
Log Message:
New table model for XML files using XPath
Index: build.xml
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/build.xml,v
retrieving revision 1.16.2.1
retrieving revision 1.16.2.2
diff -C2 -d -r1.16.2.1 -r1.16.2.2
*** build.xml 12 Nov 2003 22:18:06 -0000 1.16.2.1
--- build.xml 21 Nov 2003 09:17:04 -0000 1.16.2.2
***************
*** 269,272 ****
--- 269,273 ----
<include name="concurrent.jar"/>
<include name="csv19.jar"/>
+ <include name="dom4j-full.jar"/>
<include name="poi.jar"/>
<include name="velocity.jar"/>
|
|
From: <mic...@us...> - 2003-11-21 09:17:08
|
Update of /cvsroot/babeldoc/babeldoc/modules/jfreereports/src/com/babeldoc/jfreereports/pipeline/stage
In directory sc8-pr-cvs1:/tmp/cvs-serv16985/modules/jfreereports/src/com/babeldoc/jfreereports/pipeline/stage
Modified Files:
Tag: TEMP_MIKEA
JFRPipelineStage.java
Log Message:
New table model for XML files using XPath
Index: JFRPipelineStage.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/jfreereports/src/com/babeldoc/jfreereports/pipeline/stage/Attic/JFRPipelineStage.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -d -r1.1.2.1 -r1.1.2.2
*** JFRPipelineStage.java 12 Nov 2003 22:18:05 -0000 1.1.2.1
--- JFRPipelineStage.java 21 Nov 2003 09:17:04 -0000 1.1.2.2
***************
*** 81,84 ****
--- 81,85 ----
import com.babeldoc.core.resource.ResourceException;
import com.babeldoc.core.resource.ResourceFactory;
+ import com.babeldoc.utils.XMLTableModel;
import java.io.IOException;
***************
*** 100,103 ****
--- 101,105 ----
import org.dom4j.Element;
import org.dom4j.Node;
+ import org.dom4j.dom.DOMDocument;
import org.jfree.report.JFreeReport;
***************
*** 110,113 ****
--- 112,117 ----
*/
public class JFRPipelineStage extends PipelineStage {
+ private static LogService log =
+ LogService.getInstance(JFRPipelineStage.class.getName());
/**
***************
*** 162,170 ****
writer.close();
} catch (java.io.IOException e) {
! e.printStackTrace();
}
// Set up the table model
! TableModel tm = getTableModel();
ReportGenerator gen = ReportGenerator.getInstance();
--- 166,179 ----
writer.close();
} catch (java.io.IOException e) {
! log.logError(e);
}
// Set up the table model
! TableModel tm = null;
! try {
! tm = getTableModel();
! } catch (DocumentException e) {
! log.logError(e);
! }
ReportGenerator gen = ReportGenerator.getInstance();
***************
*** 173,179 ****
report = gen.parseReport(f);
} catch (java.io.IOException e) {
! e.printStackTrace();
} catch (org.jfree.xml.ElementDefinitionException e2) {
! e2.printStackTrace();
}
report.setData(tm);
--- 182,188 ----
report = gen.parseReport(f);
} catch (java.io.IOException e) {
! log.logError(e);
} catch (org.jfree.xml.ElementDefinitionException e2) {
! log.logError(e2);
}
report.setData(tm);
***************
*** 240,247 ****
}
! private TableModel getTableModel() {
- DefaultTableModel tm = new DefaultTableModel();
Document doc;
try {
doc = DocumentHelper.parseText(new String(getDocument().getBytes()));
--- 249,256 ----
}
! private TableModel getTableModel() throws DocumentException {
Document doc;
+ XMLTableModel tm = new XMLTableModel();
try {
doc = DocumentHelper.parseText(new String(getDocument().getBytes()));
***************
*** 251,287 ****
}
! Element queryResults = (Element) doc.selectSingleNode( "/queryresults/query" );
!
! // iterate through child elements of root with element name "foo"
! ArrayList rowData = new ArrayList();
! boolean needHeaders = true;
! for ( Iterator i = queryResults.elementIterator( "row" ); i.hasNext(); ) {
! Element row = (Element) i.next();
! int pos = 0;
! for ( Iterator j = queryResults.elementIterator( "column" ); j.hasNext(); ) {
! Element cell = (Element) j.next();
! // Add the column to the table model, if this is the first row being constructed
! if (needHeaders) {
! String columnName = cell.attribute("column-name").toString();
! if (tm.findColumn(columnName) == -1) {
! tm.addColumn(columnName);
! }
! }
! // Add the cell value to the rowData array
! Object v;
! try {
! Class c = Class.forName(cell.attribute("column-class").toString()).getClass();
! Constructor cons = c.getConstructor(new Class[] {String.class});
! v = cons.newInstance(new Object[] {cell.getText()});
! } catch (Exception e) {
! LogService.getInstance().logWarn(e.getMessage());
! v = new String("[" + I18n.get("jfr.104", cell.attribute("column-class").toString()) + "]");
! }
! rowData.add(pos, v);
! pos++;
! }
! needHeaders = false;
! tm.addRow(rowData.toArray());
! }
return (tm);
}
--- 260,264 ----
}
! tm.setDocument(doc);
return (tm);
}
|
|
From: <mic...@us...> - 2003-11-21 09:17:08
|
Update of /cvsroot/babeldoc/babeldoc/modules/scanner/src/com/babeldoc/scanner
In directory sc8-pr-cvs1:/tmp/cvs-serv16985/modules/scanner/src/com/babeldoc/scanner
Modified Files:
Tag: TEMP_MIKEA
ScannerFactory.java
Log Message:
New table model for XML files using XPath
Index: ScannerFactory.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/scanner/src/com/babeldoc/scanner/ScannerFactory.java,v
retrieving revision 1.11.2.1
retrieving revision 1.11.2.2
diff -C2 -d -r1.11.2.1 -r1.11.2.2
*** ScannerFactory.java 18 Nov 2003 01:29:28 -0000 1.11.2.1
--- ScannerFactory.java 21 Nov 2003 09:17:04 -0000 1.11.2.2
***************
*** 256,261 ****
public void flushConfig() {
! //factories.clear();
! Iterator i = factories.keySet().iterator();
while (i.hasNext()) {
String removal = (String) i.next();
--- 256,262 ----
public void flushConfig() {
! factories.clear();
! ConfigService.clearCache();
! /* Iterator i = factories.keySet().iterator();
while (i.hasNext()) {
String removal = (String) i.next();
***************
*** 264,268 ****
ConfigService.clearCache(removal);
}
! //factories.remove(configData.getName());
}
}
--- 265,269 ----
ConfigService.clearCache(removal);
}
! */
}
}
|
|
From: <mic...@us...> - 2003-11-21 09:16:58
|
Update of /cvsroot/babeldoc/babeldoc/modules/jfreereports/src/com/babeldoc/utils In directory sc8-pr-cvs1:/tmp/cvs-serv16942/modules/jfreereports/src/com/babeldoc/utils Log Message: Directory /cvsroot/babeldoc/babeldoc/modules/jfreereports/src/com/babeldoc/utils added to the repository --> Using per-directory sticky tag `TEMP_MIKEA' |