org.pentaho.reporting.engine.classic.core
Class SubReport

java.lang.Object
  extended by org.pentaho.reporting.engine.classic.core.Element
      extended by org.pentaho.reporting.engine.classic.core.Section
          extended by org.pentaho.reporting.engine.classic.core.AbstractReportDefinition
              extended by org.pentaho.reporting.engine.classic.core.SubReport
All Implemented Interfaces:
Serializable, Cloneable, DataTarget, ReportDefinition, ReportElement

public class SubReport
extends AbstractReportDefinition

A subreport element. A subreport can be attached to a root-level band and will be printed afterwards. Subreports have their own tablemodel (queried with the sub-reports's defined query and the master report's data-factory).

A sub-report that has been added to a root-level band will always be printed below the root-level band.

Sub-reports can have import and export parameters. The parameter mapping can be defined freely, so a subreport is not required to use the same column names as the parent report.

If a global import or export is defined (by adding the parameter mapping "*" => "*") the other defined parameter mappings will be ignored.

Author:
Thomas Morgner
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.pentaho.reporting.engine.classic.core.Element
ANONYMOUS_ELEMENT_PREFIX
 
Constructor Summary
SubReport()
          Creates a new subreport instance.
SubReport(InstanceID id)
           
 
Method Summary
 void addExportParameter(String outerName, String sourceColumn)
          Adds an export-parameter mapping to the subreport.
 void addInputParameter(String outerName, String sourceColumn)
          Adds an input-parameter mapping to the subreport.
 void clearExportParameters()
           
 void clearInputParameters()
           
 Object clone()
          Clones the report.
 Element derive(boolean preserveElementInstanceIds)
          Clones the report.
 Expression getActivationExpression()
           
 DataFactory getDataFactory()
          Returns the data factory that has been assigned to this report.
 ParameterMapping[] getExportMappings()
          Returns the parameter mappings for the subreport.
 ParameterMapping[] getInputMappings()
          Returns the input mappings defined for this subreport.
 PageDefinition getPageDefinition()
          Returns the page definition assigned to the report definition.
 org.pentaho.reporting.libraries.resourceloader.ResourceManager getResourceManager()
           
 boolean isGlobalExport()
          Checks whether a global export is defined.
 boolean isGlobalImport()
          Checks whether a global import is defined.
 void removeExportParameter(String outerName)
          Removes the export parameter from the mapping.
 void removeInputParameter(String sourceColumn)
          Removes the input parameter from the parameter mapping.
 void setActivationExpression(Expression activationExpression)
           
 void setDataFactory(DataFactory dataFactory)
          The (optional) data-factory for the subreport.
 void setExportMappings(ParameterMapping[] mappings)
           
 void setInputMappings(ParameterMapping[] mappings)
           
 
Methods inherited from class org.pentaho.reporting.engine.classic.core.AbstractReportDefinition
addExpression, addGroup, addGroup, addPreProcessor, addReportModelListener, addStructureFunction, fireModelLayoutChanged, getContentBase, getDataRow, getDataSchemaDefinition, getDatasourceChangeTracker, getDefinitionSource, getDetailsFooter, getDetailsHeader, getElement, getElementCount, getExpressions, getGroup, getGroupByName, getGroupCount, getItemBand, getNoDataBand, getNonVisualsChangeTracker, getPageFooter, getPageHeader, getPreProcessor, getPreProcessorCount, getPreProcessors, getProperties, getProperty, getQuery, getQueryLimit, getQueryTimeout, getReportDefinition, getReportFooter, getReportHeader, getResourceBundleFactory, getRootGroup, getStructureFunction, getStructureFunctionCount, getStructureFunctions, getStyleSheetCollection, getWatermark, removeExpression, removeGroup, removeGroup, removePreProcessor, removeReportModelListener, removeStructureFunction, setContentBase, setDataSchemaDefinition, setDefinitionSource, setDetailsFooter, setDetailsHeader, setElementAt, setExpressions, setGroups, setItemBand, setNoDataBand, setPageFooter, setPageHeader, setProperty, setQuery, setQueryLimit, setQueryTimeout, setReportFooter, setReportHeader, setResourceBundleFactory, setRootGroup, setWatermark
 
Methods inherited from class org.pentaho.reporting.engine.classic.core.Element
derive, getAttribute, getAttributeExpression, getAttributeExpressionNames, getAttributeExpressionNamespaces, getAttributeNames, getAttributeNamespaces, getAttributes, getChangeTracker, getDataSource, getElementType, getElementTypeName, getHRefTarget, getId, getMetaData, getName, getObjectID, getParent, getParentSection, getStyle, getStyleExpression, getStyleExpressions, getTreeLock, getValue, isDynamicContent, isVisible, notifyNodeChildAdded, notifyNodeChildRemoved, notifyNodePropertiesChanged, notifyNodePropertiesChanged, notifyNodeStructureChanged, setAttribute, setAttribute, setAttributeExpression, setDataSource, setDynamicContent, setElementType, setHRefTarget, setId, setName, setStyleExpression, setVisible, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.pentaho.reporting.engine.classic.core.ReportElement
getAttribute, getAttributeExpression, getAttributeExpressionNames, getAttributeExpressionNamespaces, getAttributeNames, getAttributeNamespaces, getAttributes, getId, getMetaData, getName, getObjectID, getParentSection, getStyle, getStyleExpression, getStyleExpressions, getTreeLock, setAttribute, setAttributeExpression, setStyleExpression
 

Constructor Detail

SubReport

public SubReport()
Creates a new subreport instance.


SubReport

public SubReport(InstanceID id)
Method Detail

getPageDefinition

public PageDefinition getPageDefinition()
Returns the page definition assigned to the report definition. The page definition defines the report area and how the report is subdivided by the child pages.

Returns:
null, as subreports have no page-definition at all.

derive

public Element derive(boolean preserveElementInstanceIds)
               throws CloneNotSupportedException
Clones the report.

Overrides:
derive in class AbstractReportDefinition
Parameters:
preserveElementInstanceIds - defines whether this call generates new instance-ids for the derived elements. Instance-IDs are used by the report processor to recognize reoccurring elements and must not changed within the report run. Outside of the report processors new instance ids should be generated at all times to separate instances and to make them uniquely identifiable.
Returns:
the clone.
Throws:
CloneNotSupportedException - this should never happen.

clone

public Object clone()
             throws CloneNotSupportedException
Clones the report.

Specified by:
clone in interface DataTarget
Overrides:
clone in class AbstractReportDefinition
Returns:
the clone.
Throws:
CloneNotSupportedException - this should never happen.

addExportParameter

public void addExportParameter(String outerName,
                               String sourceColumn)
Adds an export-parameter mapping to the subreport. The parameter specified by 'sourceColumn' will be made available with the name 'outerName' in the parent report.

Parameters:
outerName - the name the parameter will get in the master report.
sourceColumn - the source-column in the sub-report.

removeExportParameter

public void removeExportParameter(String outerName)
Removes the export parameter from the mapping.

Parameters:
outerName - the name of the parameter as it is known in the master report.

getExportMappings

public ParameterMapping[] getExportMappings()
Returns the parameter mappings for the subreport. The parameter mappings define how columns of the sub-report get mapped into the master report.

Returns:
the parameter mappings array.

setExportMappings

public void setExportMappings(ParameterMapping[] mappings)

addInputParameter

public void addInputParameter(String outerName,
                              String sourceColumn)
Adds an input-parameter mapping to the subreport. Input parameters define how columns that exist in the parent report get mapped into the subreport.

Input parameter mapping happens only once, so after the report has been started, changes to the parameters will not pass through to the subreport.

Parameters:
outerName - the name of the parent report's column that provides the data.
sourceColumn - the name under which the parameter will be available in the subreport.

removeInputParameter

public void removeInputParameter(String sourceColumn)
Removes the input parameter from the parameter mapping.

Parameters:
sourceColumn - the name of the column of the subreport report that acts as source for the input parameter.

clearInputParameters

public void clearInputParameters()

clearExportParameters

public void clearExportParameters()

getInputMappings

public ParameterMapping[] getInputMappings()
Returns the input mappings defined for this subreport.

Returns:
the input mappings, never null.

setInputMappings

public void setInputMappings(ParameterMapping[] mappings)

isGlobalImport

public boolean isGlobalImport()
Checks whether a global import is defined. A global import effectly overrides all other imports.

Returns:
true, if there is a global import defined, false otherwise.

isGlobalExport

public boolean isGlobalExport()
Checks whether a global export is defined. A global export effectly overrides all other export mappings.

Returns:
true, if there is a global export defined, false otherwise.

getDataFactory

public DataFactory getDataFactory()
Description copied from class: AbstractReportDefinition
Returns the data factory that has been assigned to this report. The data factory will never be null.

Specified by:
getDataFactory in class AbstractReportDefinition
Returns:
the data factory.

setDataFactory

public void setDataFactory(DataFactory dataFactory)
The (optional) data-factory for the subreport. If no datafactory is defined here, the subreport will use the master report's data-factory.

Specified by:
setDataFactory in class AbstractReportDefinition
Parameters:
dataFactory -

getActivationExpression

public Expression getActivationExpression()

setActivationExpression

public void setActivationExpression(Expression activationExpression)

getResourceManager

public org.pentaho.reporting.libraries.resourceloader.ResourceManager getResourceManager()
Specified by:
getResourceManager in class AbstractReportDefinition