001: /*
002: * Copyright 2006-2007 Pentaho Corporation. All rights reserved.
003: * This software was developed by Pentaho Corporation and is provided under the terms
004: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
005: * this file except in compliance with the license. If you need a copy of the license,
006: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt.
007: *
008: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
009: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
010: * the license for the specific language governing your rights and limitations.
011: *
012: * Additional Contributor(s): Martin Schmid gridvision engineering GmbH
013: */
014: package org.pentaho.reportdesigner.crm.report.reportexporter;
015:
016: import org.jetbrains.annotations.NotNull;
017: import org.pentaho.reportdesigner.crm.report.model.Report;
018: import org.pentaho.reportdesigner.crm.report.model.ReportElement;
019: import org.pentaho.reportdesigner.crm.report.model.ResourceFieldReportElement;
020: import org.pentaho.reportdesigner.crm.report.model.ResourceLabelReportElement;
021: import org.pentaho.reportdesigner.crm.report.model.ResourceMessageReportElement;
022: import org.pentaho.reportdesigner.crm.report.model.StaticImageReportElement;
023: import org.pentaho.reportdesigner.crm.report.model.SubReportElement;
024:
025: import java.util.List;
026:
027: /**
028: * User: Martin
029: * Date: 28.10.2005
030: * Time: 08:38:04
031: */
032: public abstract class ReportExporter {
033: public abstract void exportReport(boolean isSubReport, @NotNull
034: Report report) throws Exception;
035:
036: public void getImageElements(@NotNull
037: ReportElement reportElement, @NotNull
038: List<StaticImageReportElement> imageElements) {
039: //noinspection ConstantConditions
040: if (reportElement == null) {
041: throw new IllegalArgumentException(
042: "reportElement must not be null");
043: }
044: //noinspection ConstantConditions
045: if (imageElements == null) {
046: throw new IllegalArgumentException(
047: "imageElements must not be null");
048: }
049:
050: List<ReportElement> children = reportElement.getChildren();
051: for (ReportElement child : children) {
052: getImageElements(child, imageElements);
053: if (child instanceof StaticImageReportElement) {
054: imageElements.add((StaticImageReportElement) child);
055: }
056: }
057: }
058:
059: public void getSubReportElements(@NotNull
060: ReportElement reportElement, @NotNull
061: List<SubReportElement> subReportElements) {
062: //noinspection ConstantConditions
063: if (reportElement == null) {
064: throw new IllegalArgumentException(
065: "reportElement must not be null");
066: }
067: //noinspection ConstantConditions
068: if (subReportElements == null) {
069: throw new IllegalArgumentException(
070: "subReportElements must not be null");
071: }
072:
073: List<ReportElement> children = reportElement.getChildren();
074: for (ReportElement child : children) {
075: getSubReportElements(child, subReportElements);
076: if (child instanceof SubReportElement) {
077: subReportElements.add((SubReportElement) child);
078: }
079: }
080: }
081:
082: public void getResourceElements(@NotNull
083: ReportElement reportElement, @NotNull
084: List<ReportElement> reportElements) {
085: //noinspection ConstantConditions
086: if (reportElement == null) {
087: throw new IllegalArgumentException(
088: "reportElement must not be null");
089: }
090: //noinspection ConstantConditions
091: if (reportElements == null) {
092: throw new IllegalArgumentException(
093: "reportElements must not be null");
094: }
095:
096: List<ReportElement> children = reportElement.getChildren();
097: for (ReportElement child : children) {
098: getResourceElements(child, reportElements);
099: if (child instanceof ResourceFieldReportElement) {
100: reportElements.add(child);
101: } else if (child instanceof ResourceMessageReportElement) {
102: reportElements.add(child);
103: } else if (child instanceof ResourceLabelReportElement) {
104: reportElements.add(child);
105: }
106: }
107: }
108: }
|