<report>


Catalog Configuration Java API analog:  ReportConfigurationBuilder

The <report> element configures one Pull Report endpoint within the Pull Reports REST API.

A report consists of a exactly one <table> or <table_ref> element which is the base table of the report. The base table is always included within the Export Report REST API SQL from statement. Additionally, at least one base table <column> is always returned from the Export Report REST API endpoint. The report's base table may contain one or more nested <relationship> elements representing additional tables within the report's join tree.

A <report> element is always within one <catalog>. The report and catalog id attributes form the base URL path to all Pull Reports REST API endpoints like so:

/[context]/pullreports/catalog/[catalog id]/report/[report id]/[endpoint]

For this reason, choose report and catalog ids carefully since they are part of the semantic REST structure and will cause REST clients to break if changed.

Configure capabilities of the report's Export Report REST API endpoint such as the default base table columns or sorting behavior and availability of the report's kml and geojson formats with a child <export_config> element.

Configure report access control to all Pull Reports REST API endpoints with a child <access_control_voter> element.

Usage

Catalog with single <report>

The following example uses the real estate data model from the <relationship> documentation to demonstrate a minimal <report> configuration. In this example, the Export Report REST API will return only one database column, realestate.home.id.

Example 1. Via an XML Catalog file
<?xml version="1.0" encoding="UTF-8"?>
<catalog xmlns="http://www.pullreports.com/catalog-1.5.0" id="realestate" name="Realestate Reports">
    <report id="home" name="Home Report">
        <table id="home" name="realestate.home" displayName="Home"> 
            <column id="id" name="id" paramType="java.lang.Integer"/>
        </table>
    </report>
</catalog>

Example 2. Via the Catalog Configuration Java API

The following example is an identical Catalog Configuration Java API configuration.

package com.pullreports.examples.report;

import java.util.Arrays;
import java.util.List;

import javax.servlet.ServletContext;

import com.pullreports.model.CatalogId;
import com.pullreports.model.ColumnId;
import com.pullreports.model.ParamType;
import com.pullreports.model.ReportId;
import com.pullreports.model.TableId;
import com.pullreports.model.config.CatalogConfiguration;
import com.pullreports.model.config.CatalogConfigurationFactory;
import com.pullreports.model.config.ColumnConfiguration;
import com.pullreports.model.config.ColumnConfiguration.ColumnConfigurationBuilder;
import com.pullreports.model.config.ReportConfiguration;
import com.pullreports.model.config.ReportConfiguration.ReportConfigurationBuilder;
import com.pullreports.model.config.TableConfiguration;
import com.pullreports.model.config.TableConfiguration.TableConfigurationBuilder;

public class OneReportCatalogConfigurationFactory implements CatalogConfigurationFactory {

    @Override
    public CatalogConfiguration makeCatalog(ServletContext servletContext) {

        ColumnConfiguration idColumnConfiguration = new ColumnConfigurationBuilder(
            new ColumnId("id"),"id")
            .setParamType(ParamType.INTEGER).build();

        List<ColumnConfiguration> columnConfigurations = Arrays.asList(
            new ColumnConfiguration[]{
                idColumnConfiguration});

        TableConfiguration homeTableConfiguration = new TableConfigurationBuilder(
            new TableId("home"),"Home",columnConfigurations)
            .setName("realestate.home").build();

        ReportConfiguration homeReportConfiguration = new ReportConfigurationBuilder(
            new ReportId("home"),"Home Report",homeTableConfiguration).build();
        
        List<ReportConfiguration> reportConfigurations = Arrays.asList(
            new ReportConfiguration[]{homeReportConfiguration});

        return new CatalogConfiguration(new CatalogId("realestate"),"Realestate Reports",reportConfigurations);
    }
}
                

Catalog with multiple <report>s

A <catalog> may contain many reports up to the limit of the Pull Reportslicense. Reports within a catalog may share the same global <table>, <global_label_value_list>, and <column_group> configuration.

The following example demonstrates the configuration of two reports within one catalog using the real estate data model from the <relationship> documentation.

Example 3. Via an XML Catalog file
<?xml version="1.0" encoding="UTF-8"?>
<catalog xmlns="http://www.pullreports.com/catalog-1.5.0" id="realestate" name="Realestate Reports">
    <report id="home" name="Home Report">
        <table id="home" name="realestate.home" displayName="Home"> 
            <column id="id" name="id" paramType="java.lang.Integer"/>
        </table>
    </report>
    <report id="owner" name="Owner Report">
        <table id="owner" name="realestate.owner" displayName="Owner"> 
            <column id="first_name" name="first_name"/>
            <column id="last_name" name="last_name"/>
        </table>
    </report>
</catalog>

Example 4. Via the Catalog Configuration Java API

The following example is an identical Catalog Configuration Java API configuration.

package com.pullreports.examples.report;

import java.util.Arrays;
import java.util.List;

import javax.servlet.ServletContext;

import com.pullreports.model.CatalogId;
import com.pullreports.model.ColumnId;
import com.pullreports.model.ParamType;
import com.pullreports.model.ReportId;
import com.pullreports.model.TableId;
import com.pullreports.model.config.CatalogConfiguration;
import com.pullreports.model.config.CatalogConfigurationFactory;
import com.pullreports.model.config.ColumnConfiguration;
import com.pullreports.model.config.ColumnConfiguration.ColumnConfigurationBuilder;
import com.pullreports.model.config.ReportConfiguration;
import com.pullreports.model.config.ReportConfiguration.ReportConfigurationBuilder;
import com.pullreports.model.config.TableConfiguration;
import com.pullreports.model.config.TableConfiguration.TableConfigurationBuilder;

public class TwoReportCatalogConfigurationFactory implements CatalogConfigurationFactory {

    @Override
    public CatalogConfiguration makeCatalog(ServletContext servletContext) {

        List<ReportConfiguration> reportConfigurations = Arrays.asList(
            new ReportConfiguration[]{makeHomeReportConfiguration()
                ,makeOwnerReportConfiguration()});

        return new CatalogConfiguration(new CatalogId("realestate"),"Realestate Reports",reportConfigurations);
    }

    private ReportConfiguration makeHomeReportConfiguration() {

        ColumnConfiguration idColumnConfiguration = new ColumnConfigurationBuilder(
            new ColumnId("id"),"id")
            .setParamType(ParamType.INTEGER).build();

        List<ColumnConfiguration> columnConfigurations = Arrays.asList(
            new ColumnConfiguration[]{
                idColumnConfiguration});

        TableConfiguration homeTableConfiguration = new TableConfigurationBuilder(
            new TableId("home"),"Home",columnConfigurations)
            .setName("realestate.home").build();

        return new ReportConfigurationBuilder(
            new ReportId("home"),"Home Report",homeTableConfiguration).build();
    }

    private ReportConfiguration makeOwnerReportConfiguration() {

        ColumnConfiguration firstNameColumnConfiguration = new ColumnConfigurationBuilder(
            new ColumnId("first_name"),"first_name").build();

        ColumnConfiguration lastNameColumnConfiguration = new ColumnConfigurationBuilder(
            new ColumnId("last_name"),"last_name").build();

        List<ColumnConfiguration> columnConfigurations = Arrays.asList(
            new ColumnConfiguration[]{
                firstNameColumnConfiguration
                ,lastNameColumnConfiguration});

        TableConfiguration ownerTableConfiguration = new TableConfigurationBuilder(
            new TableId("owner"),"Owner",columnConfigurations)
            .setName("realestate.owner").build();

        return new ReportConfigurationBuilder(
            new ReportId("owner"),"Owner Report",ownerTableConfiguration).build();
    }
}
                

Catalog with multiple <report>s using <table_ref>

The following example demonstrates the usage of global <table>s and <table_ref>s to reuse table configuration between <report>s and <relationship>s. The example extends the join trees of both report configurations from the previous example with child <relationship> elements.

Example 5. Via an XML Catalog file
<?xml version="1.0" encoding="UTF-8"?>
<catalog xmlns="http://www.pullreports.com/catalog-1.5.0" id="realestate" name="Realestate Reports">
    <report id="home" name="Home Report">
        <table_ref ref="home" id="home">
            <relationship>
                <join_table name="realestate.home_owner">
                    <join_columns>
                        <join_column columnName="home_id" referencedColumnName="id" />
                    </join_columns>
                    <inverse_join_columns>
                        <join_column columnName="owner_id" referencedColumnName="id" />
                   </inverse_join_columns>
                </join_table>
                <table_ref id="owner" ref="owner"/>
            </relationship>
        </table_ref>
    </report>
    <report id="owner" name="Owner Report">
        <table_ref id="owner" ref="owner">
            <relationship>
                <join_table name="realestate.home_owner">
                    <join_columns>
                        <join_column columnName="owner_id" referencedColumnName="id" />
                    </join_columns>
                    <inverse_join_columns>
                        <join_column columnName="home_id" referencedColumnName="id" />
                   </inverse_join_columns>
                </join_table>
                <table_ref id="home" ref="home"/>
            </relationship>
        </table_ref>
    </report>
    <table id="home" name="realestate.home" displayName="Home"> 
        <column id="id" name="id" paramType="java.lang.Integer"/>
    </table>
    <table id="owner" name="realestate.owner" displayName="Owner"> 
        <column id="first_name" name="first_name"/>
        <column id="last_name" name="last_name"/>
    </table>
</catalog>

Children

<description>?
<export_config>?
<table> | <table_ref>

Parents

<catalog>

Attributes

id

The unique id of the report within the parent <catalog> This id forms part of all Pull Reports REST API endpoints. For example, the following id configuration:

<report id="salary_summary" ...>

creates REST endpoints:

/[context]/pullreports/catalog/[catalog id]/report/salary_summary/[endpoint]

Report id's may be composed of alphabetical characters, digits, or the - and _ characters.

name

The human readable name of the report.

The name value is reflected within the Pull Reports™ Ad Hoc Report Creator, header component.

Additionally, the name forms the downloadable file name of the Export Report REST API kml and csv export formats.