Skip to content

Instantly share code, notes, and snippets.

@floverfelt
Created February 14, 2021 02:05
Show Gist options
  • Save floverfelt/0b723b203aa8cea1796859fa60c339e6 to your computer and use it in GitHub Desktop.
Save floverfelt/0b723b203aa8cea1796859fa60c339e6 to your computer and use it in GitHub Desktop.
Create report from cube
WebReportSource reportSource = adminSession.getFactory().getReportSource();
WebReportExecutionSettings webReportExecutionSettings = reportSource.newExecutionSettings();
webReportExecutionSettings.setSource("your-cube-id",
EnumWebReportSourceType.WebReportSourceTypeCube);
WebReportInstance webReportInstance = reportSource.getNewInstance(webReportExecutionSettings);
webReportInstance.setExecutionMode(EnumWebReportExecutionModes.REPORT_MODE_PLAIN_TEXT);
webReportInstance.getExportSettings().setMode(EnumDSSXMLExportFormat.DssXmlExportJSON);
WebWorkingSet webWorkingSet = webReportInstance.getWorkingSet();
WebFolder webFolder = webWorkingSet.getWorkingSetObjects();
for (int i=0; i<webFolder.size(); i++){
WebObjectInfo webObjectInfo = webFolder.get(i);
if (webObjectInfo.getType() == EnumDSSXMLObjectTypes.DssXmlTypeAttribute) {
webReportInstance.getTemplate().add(webObjectInfo, 1, webReportInstance.getTemplate().getRows().getIndex());
}
}
webReportInstance.getTemplate().addMetrics(1, webReportInstance.getTemplate().getColumns().getIndex());
webReportInstance.setAsync(false);
webReportInstance.pollStatus();
System.out.println(webReportInstance.getResultsAsJSON());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment