Brightspot CMS Developer Guide

Editorial content report APIs


While the editorial content reports feature can be utilized without any additional development, the following APIs can be leveraged in order to further customize how reports are generated, stored, and/or presented.


The ContentReportDataProvider class is used for generating the output of a report. This class is customizable, allowing users to define the expected output (T) of the report. The return type is open-ended, allowing reports to be grouped as any type of output.

public abstract class ContentReportDataProvider<T> extends Record {

    public abstract T run();
}
  • Returns the result of the generated report

Usage Example

public class DataSupplierDataProvider extends ContentReportDataProvider<DataTable> {

    @Required
    private DataSupplier dataSupplier;

    @Override
    public DataTable run() {
        if (dataSupplier != null) {
            return dataSupplier.get();
        }
        return new DataTable();
    }

}
  • Using the dataSupplier field, the #run method is able to return the proper DataTable output type


The ReportStorage class represents how the output of the report is stored. It provides a method to create an HTML access link for users to access the report from the CMS however they prefer.

public abstract class ReportStorage extends Record {

    public abstract String createAccessLink(String presentationName);

}

Usage Example
In this implementation of ReportStorage, the report data is stored within a StorageItem

public class StorageItemReportStorage extends ReportStorage {

    private StorageItem storageItem;

    public StorageItem getStorageItem() {
        return storageItem;
    }

    public void setStorageItem(StorageItem storageItem) {
        this.storageItem = storageItem;
    }

    public String createAccessLink(String presentationName) {
        return BUTTON.with("Download " + presentationName).toString()
            + INPUT.typeHidden().name("storageItemReportStorageId").value(getId().toString()).toString();
    }
}
  • This storage data can be accessed through the button's hidden input value


The ReportPresentation class represents different formats in which data can be presented. Sub-classes must specify the input type (D) and the storage type (S).

public abstract class ReportPresentation<D, S extends ReportStorage> {

    public abstract S generate(D data);

    public abstract String getDisplayName();

}
  • Generates the storage object from the data
  • Returns the display name of the presentation

Usage Example
The following implementation generates the report presentation in CSV format:

class CsvPresentation extends ReportPresentation<DataTable, StorageItemReportStorage> {

    @Override
    public String getDisplayName() {
        return "CSV";
    }

    @Override
    public StorageItemReportStorage generate(DataTable data) {
        StorageItem storageItem = StorageItem.Static.create();
        storageItem.setContentType("text/csv");
        storageItem.setPath(new RandomUuidStorageItemPathGenerator()
            .createPath("report.csv"));
        /* Handle construction of the report text in CSV format using the DataTable data value, and then set the CSV file contents to the storageItem field here... */   
        StorageItemReportStorage storageItemReportStorage = new StorageItemReportStorage();
        storageItemReportStorage.setStorageItem(storageItem);
        return storageItemReportStorage;
    }
}

Previous Topic
Using the GraphQL explorer
Next Topic
Controlling revision access
Was this topic helpful?
Thanks for your feedback.
Our robust, flexible Design System provides hundreds of pre-built components you can use to build the presentation layer of your dreams.

Asset types
Module types
Page types
Brightspot is packaged with content types that get you up and running in a matter of days, including assets, modules and landing pages.

Content types
Modules
Landing pages
Everything you need to know when creating, managing, and administering content within Brightspot CMS.

Dashboards
Publishing
Workflows
Admin configurations
A guide for installing, supporting, extending, modifying and administering code on the Brightspot platform.

Field types
Content modeling
Rich-text elements
Images
A guide to configuring Brightspot's library of integrations, including pre-built options and developer-configured extensions.

Google Analytics
Shopify
Apple News