}
private static Reporting createReportingEngine(PropertiesLoader propertiesLoader) throws IOException {
DefaultFormatterFactory formatterFactory = new DefaultFormatterFactory();
Reporting reporting = new Reporting();
Properties properties = propertiesLoader.load();
String openOfficePath = properties.getProperty(PropertiesLoader.CUBA_REPORTING_OPENOFFICE_PATH);
String openOfficePorts = properties.getProperty(PropertiesLoader.CUBA_REPORTING_OPENOFFICE_PORTS);
if (StringUtils.isNotBlank(openOfficePath) && StringUtils.isNotBlank(openOfficePorts)) {
String[] portsStr = openOfficePorts.split("[,|]");
Integer[] ports = new Integer[portsStr.length];
for (int i = 0, portsStrLength = portsStr.length; i < portsStrLength; i++) {
String str = portsStr[i];
ports[i] = Integer.valueOf(str);
}
OfficeIntegration officeIntegration = new OfficeIntegration(openOfficePath, ports);
formatterFactory.setOfficeIntegration(officeIntegration);
String openOfficeTimeout = properties.getProperty(PropertiesLoader.CUBA_REPORTING_OPENOFFICE_TIMEOUT);
if (StringUtils.isNotBlank(openOfficeTimeout)) {
officeIntegration.setTimeoutInSeconds(Integer.valueOf(openOfficeTimeout));
}
String displayDeviceAvailable = properties.getProperty(PropertiesLoader.CUBA_REPORTING_OPENOFFICE_DISPLAY_DEVICE_AVAILABLE);
if (StringUtils.isNotBlank(displayDeviceAvailable)) {
officeIntegration.setDisplayDeviceAvailable(Boolean.valueOf(displayDeviceAvailable));
}
}
reporting.setFormatterFactory(formatterFactory);
reporting.setLoaderFactory(
new DefaultLoaderFactory()
.setSqlDataLoader(new PropertiesSqlLoaderFactory(propertiesLoader).create())
.setGroovyDataLoader(new GroovyDataLoader(new DefaultScriptingImpl()))
.setJsonDataLoader(new JsonDataLoader()));
return reporting;