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.
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.
Additionally, this example uses the <default_filters>
element
to apply default filters to the report when opened in the Report Creator.
<?xml version="1.0" encoding="UTF-8"?> <catalog xmlns="http://www.pullreports.com/catalog-1.7.0" id="class" name="Class Reports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.pullreports.com/catalog-1.7.0 https://www.pullreports.com/docs/xsd/pullreports-catalog-1.7.0.xsd"> <report id="student-information" name="Student Information"> <export_config defaultSort="@name;@bdate desc" defaultColumns='id,name'> <default_filters> <default_filter>/student@name like 'Sam%'</default_filter> <default_filter>/student@bdate is null or /student@bdate > '2020-01-01'</default_filter> </default_filters> </export_config> <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>
The following example is an identical Catalog Configuration Java API configuration.
package com.pullreports.examples.exportconfig;
import com.pullreports.export.request.FilterValue;
import com.pullreports.export.request.Operator;
import com.pullreports.export.request.SortDirection;
import com.pullreports.model.*;
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.DefaultFilterTerm;
import com.pullreports.model.exportconfig.DefaultSortTerm;
import com.pullreports.model.exportconfig.ExportConfiguration;
import jakarta.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));
List<List<DefaultFilterTerm>> defaultFilters = Arrays.asList(
Collections.singletonList(
new DefaultFilterTerm(nameColumnConfiguration.getId(), Operator.LIKE, FilterValue.asList("Sam%")))
,Arrays.asList(
new DefaultFilterTerm(bdateColumnConfiguration.getId(), Operator.IS_NULL),
new DefaultFilterTerm(bdateColumnConfiguration.getId(),Operator.GREATER_THAN, FilterValue.asList("2020-01-01"))));
ReportConfiguration personReportConfiguration = new ReportConfiguration.Builder(
new ReportId("student-information"),"Student Information",studentTableConfiguration)
.setExportConfiguration(
new ExportConfiguration.Builder()
.setDefaultSortTerms(defaultSortTerms)
.setDefaultColumns(defaultColumns)
.setDefaultFilterTerms(defaultFilters)
.build()).build();
List<ReportConfiguration> reportConfigurations = Collections.singletonList(personReportConfiguration);
return new CatalogConfiguration(new CatalogId("class"),"Class Reports",reportConfigurations);
}
}
<kml> ? |
<geojson> ? |
<canned_queries> ? |
<default_filters> ? |
<report> |
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.
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.
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.