Class AbstractAnalyticsPortlet<T>

java.lang.Object
javax.portlet.GenericPortlet
io.meeds.analytics.portlet.AbstractAnalyticsPortlet<T>
All Implemented Interfaces:
javax.portlet.EventPortlet, javax.portlet.Portlet, javax.portlet.PortletConfig, javax.portlet.ResourceServingPortlet
Direct Known Subclasses:
AnalyticsPortlet, AnalyticsRatePortlet, AnalyticsTablePortlet

public abstract class AbstractAnalyticsPortlet<T> extends javax.portlet.GenericPortlet
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final String
    Both exports write an OOXML workbook (XSSF, ".xlsx").
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    addJSONParam(org.json.JSONObject jsonResponse, String paramName, Object paramValue)
     
    protected void
    addLanguageFilter(javax.portlet.ResourceRequest request, io.meeds.analytics.model.filter.AnalyticsFilter filter)
     
    protected void
    addLimitFilter(javax.portlet.ResourceRequest request, io.meeds.analytics.model.filter.AnalyticsFilter filter)
     
    protected void
    addPeriodFilter(javax.portlet.ResourceRequest request, io.meeds.analytics.model.filter.AnalyticsFilter filter)
     
    protected void
    addScopeFilter(javax.portlet.ResourceRequest request, io.meeds.analytics.model.filter.AnalyticsFilter filter)
     
    protected void
    addSortFilter(io.meeds.analytics.model.filter.AnalyticsFilter filter, String direction)
     
    protected void
    addTimeZoneFilter(javax.portlet.ResourceRequest request, io.meeds.analytics.model.filter.AbstractAnalyticsFilter filter)
     
    protected boolean
    canModifySettings(javax.portlet.PortletRequest request)
     
    void
    doView(javax.portlet.RenderRequest request, javax.portlet.RenderResponse response)
     
    protected void
    exportExcel(javax.portlet.ResourceRequest request, javax.portlet.ResourceResponse response)
     
    protected io.meeds.analytics.api.service.AnalyticsService
     
    protected abstract Class<T>
     
    protected T
    getFilterFromPreferences(javax.portlet.ResourceRequest request)
     
    protected io.meeds.analytics.portlet.AbstractAnalyticsPortlet.SearchScope
    getSearchScope(javax.portlet.PortletRequest request)
     
    protected org.exoplatform.social.core.space.spi.SpaceService
     
    protected abstract String
     
    void
    processAction(javax.portlet.ActionRequest request, javax.portlet.ActionResponse response)
     
    protected abstract void
    readData(javax.portlet.ResourceRequest request, javax.portlet.ResourceResponse response)
     
    protected void
    readSamples(javax.portlet.ResourceRequest request, javax.portlet.ResourceResponse response)
     
    protected abstract void
    readSettings(javax.portlet.ResourceRequest request, javax.portlet.ResourceResponse response)
     
    protected void
    readSettingsReadOnly(javax.portlet.ResourceRequest request, javax.portlet.ResourceResponse response)
     
    protected static String
    Resolves a stored title for an export.
    protected static String
    safeSheetName(String title, String fallback)
    Builds a sheet name POI accepts from a user-typed title: the characters a sheet name cannot contain (: / \ ? * [ ] and a leading or trailing quote) are replaced and the name is cut to 31 characters, instead of letting Workbook.createSheet(String) throw on them.
    final void
    serveResource(javax.portlet.ResourceRequest request, javax.portlet.ResourceResponse response)
     
    protected boolean
    writeDateCell(org.apache.poi.ss.usermodel.Cell cell, io.meeds.analytics.model.filter.aggregation.AnalyticsAggregation aggregation, String key, ZoneId zoneId, Map<String,org.apache.poi.ss.usermodel.CellStyle> styles)
    Writes a date bucket as a real date-typed cell instead of the localized label the chart displays.
    protected boolean
    writeTimestampCell(org.apache.poi.ss.usermodel.Cell cell, String value, ZoneId zoneId, Map<String,org.apache.poi.ss.usermodel.CellStyle> styles)
    Writes an epoch-milliseconds value as a real date-time cell.

    Methods inherited from class javax.portlet.GenericPortlet

    destroy, doDispatch, doEdit, doHeaders, doHelp, getContainerRuntimeOptions, getDefaultNamespace, getInitParameter, getInitParameterNames, getNextPossiblePortletModes, getPortletConfig, getPortletContext, getPortletName, getProcessingEventQNames, getPublicRenderParameterNames, getPublishingEventQNames, getResourceBundle, getSupportedLocales, getTitle, init, init, processEvent, render

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • XLSX_CONTENT_TYPE

      protected static final String XLSX_CONTENT_TYPE
      Both exports write an OOXML workbook (XSSF, ".xlsx"). Declaring the legacy "application/vnd.ms-excel" type of the binary ".xls" format makes Excel greet the download with a "the file format and the extension don't match" warning before opening it.
      See Also:
  • Constructor Details

    • AbstractAnalyticsPortlet

      public AbstractAnalyticsPortlet()
  • Method Details

    • doView

      public void doView(javax.portlet.RenderRequest request, javax.portlet.RenderResponse response) throws IOException, javax.portlet.PortletException
      Overrides:
      doView in class javax.portlet.GenericPortlet
      Throws:
      IOException
      javax.portlet.PortletException
    • serveResource

      public final void serveResource(javax.portlet.ResourceRequest request, javax.portlet.ResourceResponse response) throws javax.portlet.PortletException, IOException
      Specified by:
      serveResource in interface javax.portlet.ResourceServingPortlet
      Overrides:
      serveResource in class javax.portlet.GenericPortlet
      Throws:
      javax.portlet.PortletException
      IOException
    • processAction

      public void processAction(javax.portlet.ActionRequest request, javax.portlet.ActionResponse response) throws IOException, javax.portlet.PortletException
      Specified by:
      processAction in interface javax.portlet.Portlet
      Overrides:
      processAction in class javax.portlet.GenericPortlet
      Throws:
      IOException
      javax.portlet.PortletException
    • resolveExportTitle

      protected static String resolveExportTitle(String title, Locale locale)
      Resolves a stored title for an export. Since the chart settings drawer stores a multilingual title as a JSON object ({"en":"...","fr":"..."}), the raw value cannot be used as a sheet or file name: the text for the request locale is taken, then the English one, then the first non-blank translation. A plain title is returned unchanged.
    • safeSheetName

      protected static String safeSheetName(String title, String fallback)
      Builds a sheet name POI accepts from a user-typed title: the characters a sheet name cannot contain (: / \ ? * [ ] and a leading or trailing quote) are replaced and the name is cut to 31 characters, instead of letting Workbook.createSheet(String) throw on them.
    • readSettingsReadOnly

      protected void readSettingsReadOnly(javax.portlet.ResourceRequest request, javax.portlet.ResourceResponse response) throws javax.portlet.PortletException, IOException
      Throws:
      javax.portlet.PortletException
      IOException
    • getViewPagePath

      protected abstract String getViewPagePath()
    • getFilterClass

      protected abstract Class<T> getFilterClass()
    • readSettings

      protected abstract void readSettings(javax.portlet.ResourceRequest request, javax.portlet.ResourceResponse response) throws javax.portlet.PortletException, IOException
      Throws:
      javax.portlet.PortletException
      IOException
    • readData

      protected abstract void readData(javax.portlet.ResourceRequest request, javax.portlet.ResourceResponse response) throws javax.portlet.PortletException, IOException
      Throws:
      javax.portlet.PortletException
      IOException
    • readSamples

      protected void readSamples(javax.portlet.ResourceRequest request, javax.portlet.ResourceResponse response) throws javax.portlet.PortletException, IOException
      Throws:
      javax.portlet.PortletException
      IOException
    • exportExcel

      protected void exportExcel(javax.portlet.ResourceRequest request, javax.portlet.ResourceResponse response) throws javax.portlet.PortletException, IOException
      Throws:
      javax.portlet.PortletException
      IOException
    • getFilterFromPreferences

      protected T getFilterFromPreferences(javax.portlet.ResourceRequest request)
    • getSearchScope

      protected io.meeds.analytics.portlet.AbstractAnalyticsPortlet.SearchScope getSearchScope(javax.portlet.PortletRequest request)
    • canModifySettings

      protected boolean canModifySettings(javax.portlet.PortletRequest request)
    • addJSONParam

      protected void addJSONParam(org.json.JSONObject jsonResponse, String paramName, Object paramValue) throws javax.portlet.PortletException
      Throws:
      javax.portlet.PortletException
    • addTimeZoneFilter

      protected void addTimeZoneFilter(javax.portlet.ResourceRequest request, io.meeds.analytics.model.filter.AbstractAnalyticsFilter filter)
    • addLanguageFilter

      protected void addLanguageFilter(javax.portlet.ResourceRequest request, io.meeds.analytics.model.filter.AnalyticsFilter filter)
    • addSortFilter

      protected void addSortFilter(io.meeds.analytics.model.filter.AnalyticsFilter filter, String direction)
    • addLimitFilter

      protected void addLimitFilter(javax.portlet.ResourceRequest request, io.meeds.analytics.model.filter.AnalyticsFilter filter)
    • addPeriodFilter

      protected void addPeriodFilter(javax.portlet.ResourceRequest request, io.meeds.analytics.model.filter.AnalyticsFilter filter)
    • addScopeFilter

      protected void addScopeFilter(javax.portlet.ResourceRequest request, io.meeds.analytics.model.filter.AnalyticsFilter filter) throws javax.portlet.PortletException
      Throws:
      javax.portlet.PortletException
    • getAnalyticsService

      protected io.meeds.analytics.api.service.AnalyticsService getAnalyticsService()
    • getSpaceService

      protected org.exoplatform.social.core.space.spi.SpaceService getSpaceService()
    • writeTimestampCell

      protected boolean writeTimestampCell(org.apache.poi.ss.usermodel.Cell cell, String value, ZoneId zoneId, Map<String,org.apache.poi.ss.usermodel.CellStyle> styles)
      Writes an epoch-milliseconds value as a real date-time cell.

      Used for a column aggregating a date *field* (a MAX over a "last connection" field, say): the aggregation type is MAX, not DATE, so it is not a date histogram and has no interval — but its value is still an instant, and written as a plain number it reaches the reader as 1.75941E+12.

      Returns:
      true when the cell was written as a date, false when the value is not epoch millis and the caller should fall back
    • writeDateCell

      protected boolean writeDateCell(org.apache.poi.ss.usermodel.Cell cell, io.meeds.analytics.model.filter.aggregation.AnalyticsAggregation aggregation, String key, ZoneId zoneId, Map<String,org.apache.poi.ss.usermodel.CellStyle> styles)
      Writes a date bucket as a real date-typed cell instead of the localized label the chart displays.

      A label such as "1 sept. 2026" written as text is only a picture of a date to a spreadsheet: it cannot be sorted chronologically (it sorts lexicographically, so "10 août" lands before "1 sept."), filtered by period, or fed to a date formula, and no cell formatting recovers it because the underlying value is a string. A date-typed cell carries the instant itself and each reader's Excel renders it in their own locale.

      Parameters:
      cell - cell to write
      aggregation - the aggregation the bucket belongs to
      key - the raw bucket key, epoch milliseconds for a date histogram
      zoneId - time zone the buckets were aligned on, so the written wall-clock date is the one the chart shows
      styles - per-workbook cache of the created cell styles: a workbook holds a bounded number of them, so one per cell would both bloat the file and eventually hit that limit
      Returns:
      true when the cell was written as a date, false when this bucket has no faithful date representation and the caller should fall back to the textual label