Package io.meeds.analytics.portlet
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
FieldsModifier and TypeFieldDescriptionprotected static final StringBoth exports write an OOXML workbook (XSSF, ".xlsx"). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddJSONParam(org.json.JSONObject jsonResponse, String paramName, Object paramValue) protected voidaddLanguageFilter(javax.portlet.ResourceRequest request, io.meeds.analytics.model.filter.AnalyticsFilter filter) protected voidaddLimitFilter(javax.portlet.ResourceRequest request, io.meeds.analytics.model.filter.AnalyticsFilter filter) protected voidaddPeriodFilter(javax.portlet.ResourceRequest request, io.meeds.analytics.model.filter.AnalyticsFilter filter) protected voidaddScopeFilter(javax.portlet.ResourceRequest request, io.meeds.analytics.model.filter.AnalyticsFilter filter) protected voidaddSortFilter(io.meeds.analytics.model.filter.AnalyticsFilter filter, String direction) protected voidaddTimeZoneFilter(javax.portlet.ResourceRequest request, io.meeds.analytics.model.filter.AbstractAnalyticsFilter filter) protected booleancanModifySettings(javax.portlet.PortletRequest request) voiddoView(javax.portlet.RenderRequest request, javax.portlet.RenderResponse response) protected voidexportExcel(javax.portlet.ResourceRequest request, javax.portlet.ResourceResponse response) protected io.meeds.analytics.api.service.AnalyticsServiceprotected TgetFilterFromPreferences(javax.portlet.ResourceRequest request) protected io.meeds.analytics.portlet.AbstractAnalyticsPortlet.SearchScopegetSearchScope(javax.portlet.PortletRequest request) protected org.exoplatform.social.core.space.spi.SpaceServiceprotected abstract StringvoidprocessAction(javax.portlet.ActionRequest request, javax.portlet.ActionResponse response) protected abstract voidreadData(javax.portlet.ResourceRequest request, javax.portlet.ResourceResponse response) protected voidreadSamples(javax.portlet.ResourceRequest request, javax.portlet.ResourceResponse response) protected abstract voidreadSettings(javax.portlet.ResourceRequest request, javax.portlet.ResourceResponse response) protected voidreadSettingsReadOnly(javax.portlet.ResourceRequest request, javax.portlet.ResourceResponse response) protected static StringresolveExportTitle(String title, Locale locale) Resolves a stored title for an export.protected static StringsafeSheetName(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 lettingWorkbook.createSheet(String)throw on them.final voidserveResource(javax.portlet.ResourceRequest request, javax.portlet.ResourceResponse response) protected booleanwriteDateCell(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 booleanwriteTimestampCell(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
-
Field Details
-
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:
doViewin classjavax.portlet.GenericPortlet- Throws:
IOExceptionjavax.portlet.PortletException
-
serveResource
public final void serveResource(javax.portlet.ResourceRequest request, javax.portlet.ResourceResponse response) throws javax.portlet.PortletException, IOException - Specified by:
serveResourcein interfacejavax.portlet.ResourceServingPortlet- Overrides:
serveResourcein classjavax.portlet.GenericPortlet- Throws:
javax.portlet.PortletExceptionIOException
-
processAction
public void processAction(javax.portlet.ActionRequest request, javax.portlet.ActionResponse response) throws IOException, javax.portlet.PortletException - Specified by:
processActionin interfacejavax.portlet.Portlet- Overrides:
processActionin classjavax.portlet.GenericPortlet- Throws:
IOExceptionjavax.portlet.PortletException
-
resolveExportTitle
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
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 lettingWorkbook.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.PortletExceptionIOException
-
getViewPagePath
-
getFilterClass
-
readSettings
protected abstract void readSettings(javax.portlet.ResourceRequest request, javax.portlet.ResourceResponse response) throws javax.portlet.PortletException, IOException - Throws:
javax.portlet.PortletExceptionIOException
-
readData
protected abstract void readData(javax.portlet.ResourceRequest request, javax.portlet.ResourceResponse response) throws javax.portlet.PortletException, IOException - Throws:
javax.portlet.PortletExceptionIOException
-
readSamples
protected void readSamples(javax.portlet.ResourceRequest request, javax.portlet.ResourceResponse response) throws javax.portlet.PortletException, IOException - Throws:
javax.portlet.PortletExceptionIOException
-
exportExcel
protected void exportExcel(javax.portlet.ResourceRequest request, javax.portlet.ResourceResponse response) throws javax.portlet.PortletException, IOException - Throws:
javax.portlet.PortletExceptionIOException
-
getFilterFromPreferences
-
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:
truewhen the cell was written as a date,falsewhen 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 writeaggregation- the aggregation the bucket belongs tokey- the raw bucket key, epoch milliseconds for a date histogramzoneId- time zone the buckets were aligned on, so the written wall-clock date is the one the chart showsstyles- 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:
truewhen the cell was written as a date,falsewhen this bucket has no faithful date representation and the caller should fall back to the textual label
-