|
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);
}
}
|