KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > pentaho > plugin > jfreereport > outputs > JFreeReportAllContentComponent


1 /*
2  * Copyright 2006 Pentaho Corporation. All rights reserved.
3  * This software was developed by Pentaho Corporation and is provided under the terms
4  * of the Mozilla Public License, Version 1.1, or any later version. You may not use
5  * this file except in compliance with the license. If you need a copy of the license,
6  * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
7  * BI Platform. The Initial Developer is Pentaho Corporation.
8  *
9  * Software distributed under the Mozilla Public License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
11  * the license for the specific language governing your rights and limitations.
12  */

13 package org.pentaho.plugin.jfreereport.outputs;
14
15 import org.apache.commons.logging.Log;
16 import org.apache.commons.logging.LogFactory;
17 import org.jfree.report.JFreeReport;
18 import org.pentaho.core.component.IComponent;
19 import org.pentaho.core.runtime.IRuntimeContext;
20 import org.pentaho.messages.Messages;
21 import org.pentaho.plugin.core.StandardSettings;
22 import org.pentaho.plugin.jfreereport.AbstractJFreeReportComponent;
23
24 /**
25  * Creation-Date: 07.07.2006, 21:01:58
26  *
27  * @author Thomas Morgner
28  */

29 public class JFreeReportAllContentComponent extends
30     AbstractJFreeReportComponent {
31   private static final long serialVersionUID = -8233725514054165666L;
32
33   private AbstractGenerateContentComponent component;
34
35   public JFreeReportAllContentComponent() {
36   }
37
38   public Log getLogger() {
39     return LogFactory.getLog(getClass());
40   }
41
42   protected boolean executeAction() throws Throwable JavaDoc {
43     if (component != null) {
44       debug(Messages.getString("JFreeReportAllContentComponent.DEBUG_EXECUTING_COMPONENT", component.toString())); //$NON-NLS-1$
45
return (component.execute() == IRuntimeContext.RUNTIME_STATUS_SUCCESS);
46     }
47
48     debug(Messages.getString("JFreeReportAllContentComponent.DEBUG_NO_COMPONENT")); //$NON-NLS-1$
49
return false;
50   }
51
52   public boolean init() {
53     if (component != null) {
54       return component.init();
55     }
56     return true;
57   }
58
59   public void done() {
60     if (component != null) {
61       component.done();
62     }
63   }
64
65   protected boolean validateSystemSettings() {
66     return true;
67   }
68
69   protected boolean initAndValidate(IComponent componentToValidate) {
70     componentToValidate.setInstanceId(getInstanceId());
71     componentToValidate.setActionName(getActionName());
72     componentToValidate.setProcessId(getProcessId());
73     componentToValidate.setComponentDefinition(getComponentDefinition());
74     componentToValidate.setSession(getSession());
75     componentToValidate.setRuntimeContext(getRuntimeContext());
76     componentToValidate.setLoggingLevel(getLoggingLevel());
77     componentToValidate.setMessages(getMessages());
78     return (componentToValidate.validate() == IRuntimeContext.RUNTIME_CONTEXT_VALIDATE_OK);
79   }
80
81   protected boolean validateAction() {
82
83     if (isDefinedInput(StandardSettings.PRINTER_NAME)) {
84       component = new JFreeReportPrintComponent();
85       return initAndValidate(component);
86     }
87
88     if (isDefinedInput(REPORTALLCONTENT_OUTPUTTYPE)) {
89
90       String JavaDoc reportOutputType = getInputStringValue(REPORTALLCONTENT_OUTPUTTYPE);
91       if (getLogger().isDebugEnabled()) {
92         debug(Messages.getString(
93             "JFreeReport.DEBUG_OUTPUT_TYPE", reportOutputType)); //$NON-NLS-1$
94
}
95       if (REPORTALLCONTENT_OUTPUTTYPE_HTML.equals(reportOutputType)) {
96         component = new JFreeReportHtmlComponent();
97         return initAndValidate(component);
98       } else if (REPORTALLCONTENT_OUTPUTTYPE_PDF.equals(reportOutputType)) {
99         component = new JFreeReportPdfComponent();
100         return initAndValidate(component);
101       } else if (REPORTALLCONTENT_OUTPUTTYPE_XLS.equals(reportOutputType)) {
102         component = new JFreeReportExcelComponent();
103         return initAndValidate(component);
104       } else if (REPORTALLCONTENT_OUTPUTTYPE_CSV.equals(reportOutputType)) {
105         component = new JFreeReportCSVComponent();
106         return initAndValidate(component);
107       } else if (REPORTALLCONTENT_OUTPUTTYPE_RTF.equals(reportOutputType)) {
108         component = new JFreeReportRTFComponent();
109         return initAndValidate(component);
110       } else if (REPORTALLCONTENT_OUTPUTTYPE_XML.equals(reportOutputType)) {
111         component = new JFreeReportXmlComponent();
112         return initAndValidate(component);
113       } else {
114         return false;
115       }
116     }
117     warn(Messages.getString("JFreeReportAllContentComponent.WARN_NO_PRINTER_GIVEN")); //$NON-NLS-1$
118
return false;
119   }
120
121   protected boolean performExport(final JFreeReport report) {
122     return false;
123   }
124 }
125
Popular Tags