Class TableProcessor

    • Constructor Detail

      • TableProcessor

        protected TableProcessor()
        Constructor.
    • Method Detail

      • setJasperTemplate

        public void setJasperTemplate​(java.lang.String jasperTemplate)
        The path to the JasperReports template that contains the template for the sub-report. If dynamic is false then the template will be used without any changes. It will simply be compiled and used as is.

        If dynamic is true then the template will be used to obtain the column styles and the size of the subreport and to get the position of the first header and field element. The actual field and column definitions will be dynamically generated from the table data that is provided. This may be null if dynamic is false. If it is null then the main template will likely use the generated table datasource directly as its datasource for use in its detail section and the table will be directly in the main template's detail section. Or a later processor may use the table's datasource in someway.

        Parameters:
        jasperTemplate - the template to use for rendering the table.
      • setDynamic

        public void setDynamic​(boolean dynamic)
        If true then the JasperReport template will be generated dynamically based on the columns in the table attribute.

        Default: false

        Parameters:
        dynamic - indicate if the template should be dynamically generated for each print request.
      • setReportWidth

        public void setReportWidth​(java.lang.Integer reportWidth)
        If dynamic is true, the page width of the table report can be adjusted with this property.
        Parameters:
        reportWidth - The report width to use.
      • setColumns

        public void setColumns​(java.util.Map<java.lang.String,​TableColumnConverter<?>> columnConverters)
        Set strategies for converting the textual representation of each column to some other object (image, other text, etc...).

        Note: The type returned by the column converter must match the type in the jasper template.

        Parameters:
        columnConverters - Map from column name -> TableColumnConverter
      • setConverters

        public void setConverters​(java.util.List<TableColumnConverter<?>> converters)
        Set strategies for converting the textual representation of each cell to some other object (image, other text, etc...).

        This is similar to the converters specified for a particular column. The difference is that these converters are applied to every cell of the table (except for the cells of those columns that are assigned a specific converter).

        Parameters:
        converters - A list of TableColumnConverters.
      • setFirstHeaderStyle

        public void setFirstHeaderStyle​(java.lang.String firstHeaderStyle)
        The id of the style to apply to the first column in the table header. This is optional.

        The style must be a style element in the jasperTemplate.

        Parameters:
        firstHeaderStyle - a ref to a style in the japserTemplate
      • setLastHeaderStyle

        public void setLastHeaderStyle​(java.lang.String lastHeaderStyle)
        The id of the style to apply to the last column in the table header. This is optional.

        The style must be a style element in the jasperTemplate.

        Parameters:
        lastHeaderStyle - a ref to a style in the japserTemplate
      • setHeaderStyle

        public void setHeaderStyle​(java.lang.String headerStyle)
        The id of the style to apply to the all columns in the table header except first and last columns. This value is will be used as a default if either firstHeaderStyle or lastHeaderStyle is not defined. This is required if dynamic is true and is not permitted if dynamic is false.

        The style must be a style element in the jasperTemplate.

        Parameters:
        headerStyle - a ref to a style in the japserTemplate
      • setFirstDetailStyle

        public void setFirstDetailStyle​(java.lang.String firstDetailStyle)
        The id of the style to apply to the first column in the table detail section. This is optional.

        The style must be a style element in the jasperTemplate.

        Parameters:
        firstDetailStyle - a ref to a style in the jasperTemplate
      • setLastDetailStyle

        public void setLastDetailStyle​(java.lang.String lastDetailStyle)
        The id of the style to apply to the last column in the table detail section. This is optional.

        The style must be a style element in the jasperTemplate.

        Parameters:
        lastDetailStyle - a ref to a style in the jasperTemplate
      • setDetailStyle

        public void setDetailStyle​(java.lang.String detailStyle)
        The id of the style to apply to the all columns in the table detail section except first and last columns. This value is will be used as a default if either firstDetailStyle or lastDetailStyle is not defined. This is required if dynamic is true and is not permitted if dynamic is false.

        The style must be a style element in the jasperTemplate.

        Parameters:
        detailStyle - a ref to a style in the japserTemplate
      • setMaxColumns

        public void setMaxColumns​(int maxColumns)
        The maximum number of columns to allow.
        Parameters:
        maxColumns - maximum number of columns to allow.
      • setExcludeColumns

        public void setExcludeColumns​(java.util.Set<java.lang.String> excludeColumns)
        A set of column names to exclude from the table.
        Parameters:
        excludeColumns - a set of names of the columns to exclude from the table.
      • createInputParameter

        public TableProcessor.Input createInputParameter()
        Description copied from interface: Processor
        Returns a new/clean instance of a parameter object. This instance's will be inspected using reflection to find its public fields and the properties will be set from the Values object.

        The way the properties will be looked up is to

        1. take the bean property name
        2. map it using the input mapper, (if the input mapper does not have a mapping for the property then the unmapped property name is used)
        3. Look up the property value in the Values object using the mapped property name
        4. set the value on the instance created by this method. If the value is null an exception will be thrown UNLESS the HasDefaultValue annotation is on the field for the property.
        The populated instance will be passed to the execute method. It is imperative that a new instance is created each time because they will be used in a multi-threaded environment and thus the same processor instance may be ran in multiple threads with different instances of the parameter object.

        It is important to realize that super classes will also be analyzed, so care must be had with inheritance.

      • execute

        public TableProcessor.Output execute​(TableProcessor.Input values,
                                             Processor.ExecutionContext context)
                                      throws java.lang.Exception
        Description copied from interface: Processor
        Perform the process on the input attributes.
        Parameters:
        values - A Java object whose public fields are populated from the Values object (which is used for transferring properties between processors).
        context - The execution context for a print task.
        Returns:
        A Java object whose public fields will be put into the Values object. The key in the Values object is the name of the field or if there is a mapping in the Processor.getOutputMapperBiMap() map, the mapped name. The key is determined in a similar way as for the input object.
        Throws:
        java.lang.Exception