<export_config>

Abstract

Learn to configure the <export_config> element for Pull Reports™ Ad Hoc report and data service software.


Catalog Configuration Java API analog:  ExportConfiguration.Builder

Use <export_config> to configure capabilities of the Export Report REST API such as default export columns, default column sort, and spatial export.

See the <kml> and <geojson> documentation to configure the kml and geojson Export Report REST API export formats respectively.

Usage

Defining a default sort and columns

In the following example, the defaultSort attribute is used by the Export Report REST API to sort the export results in the absence of a sort parameter. The sort will be by the name column, ascending, and then by the bdate column, descending. Similarly, the defaultColumns attribute tells the Export Report REST API to return the id and name columns in the absence of a columns parameter.

This means that a Export Report REST API request to /[context]/pullreports/catalog/class/report/student-information/export without additional parameters results in SQL statement:

SELECT id, student_name FROM student_details 
ORDER BY student_name

In this example API request, the defaultSort's bdate sort configuration is ignored because the column is not present in the export results.

Example 1. Via an XML Catalog file
<?xml version="1.0" encoding="UTF-8"?>
<catalog xmlns="http://www.pullreports.com/catalog-1.6.1" id="class" name="Class Reports"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.pullreports.com/catalog-1.6.1
    https://www.pullreports.com/docs/xsd/pullreports-catalog-1.6.1.xsd">
    <report id="student-information" name="Student Information">
        <export_config defaultSort="@name;@bdate desc" defaultColumns='id,name'/> 
        <table id="student" displayName="Student Details" name="student_details"> 
            <column id="id" name="id" displayName="Student ID" paramType="java.lang.Integer"/>
            <column id="name" name="student_name" displayName="Student Name"/>
            <column id="bdate" name="birth_date" displayName="Birth Date" paramType="java.sql.Date"/>
        </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.exportconfig;

import com.pullreports.export.request.SortDirection;
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.ReportConfiguration;
import com.pullreports.model.config.TableConfiguration;
import com.pullreports.model.exportconfig.DefaultSortTerm;
import com.pullreports.model.exportconfig.ExportConfiguration;

import javax.servlet.ServletContext;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class ExportConfigExampleCatalogConfigurationFactory implements CatalogConfigurationFactory {

    @Override
    public CatalogConfiguration makeCatalog(ServletContext servletContext) {

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

        ColumnConfiguration nameColumnConfiguration = new ColumnConfiguration.Builder(
            new ColumnId("name"),"student_name")
            .setDisplayName("Student Name")
            .build();

        ColumnConfiguration bdateColumnConfiguration = new ColumnConfiguration.Builder(
            new ColumnId("bdate"),"birth_date")
            .setDisplayName("Birth Date")
            .setParamType(ParamType.DATE)
            .build();

        List<ColumnConfiguration> columnConfigurations = Arrays.asList(
                idColumnConfiguration
                ,nameColumnConfiguration
                ,bdateColumnConfiguration);

        TableConfiguration studentTableConfiguration = new TableConfiguration.Builder(
            new TableId("student"),"Student Details",columnConfigurations)
            .setName("student_details").build();

        List<ColumnId> defaultColumns = Arrays.asList(
            idColumnConfiguration.getId()
            ,nameColumnConfiguration.getId());

        List<DefaultSortTerm> defaultSortTerms = Arrays.asList(
            new DefaultSortTerm(nameColumnConfiguration.getId())
            ,new DefaultSortTerm(bdateColumnConfiguration.getId(),SortDirection.DESC));

        ReportConfiguration personReportConfiguration = new ReportConfiguration.Builder(
            new ReportId("student-information"),"Student Information",studentTableConfiguration)
            .setExportConfiguration(
                new ExportConfiguration.Builder()
                    .setDefaultSortTerms(defaultSortTerms)
                    .setDefaultColumns(defaultColumns)
                .build()).build();
        
        List<ReportConfiguration> reportConfigurations = Collections.singletonList(personReportConfiguration);

        return new CatalogConfiguration(new CatalogId("class"),"Class Reports",reportConfigurations);
    }
}
                

Children

<kml>?
<geojson>?
<canned_queries>?

Parents

<report>

Attributes

defaultColumns (Optional)

Comma separated list of one or more exportable, <column> ids from the <report>'s base table. "exportable" means that the <column> does not set export='false'.

The Export Report REST API will include these base table columns within the export result if no other base table columns are specified within the columns parameter.

defaultSort (Optional)

The default sort of this report for the Export Report REST API if the sort HTTP parameter is not provided. The format adheres to the rules of the Export Report sort parameter with the following exceptions:

  • <column> id references must reference a <column> on the base table of the <report>.

  • <column> id references must begin with an @ character and not contain the report's base table path.

Note

A single sort clause within the defaultSort list will only be applied to the export result if the sorted <column> is present within the export results.