fontPaths = Arrays.asList(propertyReportFonts.split(","));
}
LOGGER.debug("Generating in Memory HTML for account: " + accountId);
// Writing HTML to Memory
MemoryReportWriter mrwHtml = MemoryReportWriter.newMemoryReportWriter();
HTMLExporter.exportHtml(reportDataMap, template, mrwHtml);
if (propertyReportWriterType != null &&
propertyReportWriterType.equals(ReportWriterType.GoogleDriveWriter.name())) {
// One folder per account
Boolean perAccountFolder = false;
if (properties.getProperty("aw.report.exporter.reportwritertype.drive.peraccountfolder") != null) {
perAccountFolder = Boolean.valueOf(properties.getProperty("aw.report.exporter.writeDriveDoc"));
}
// Writing HTML to GoogleDrive
if (writeHtml) {
LOGGER.debug("Writing (to GoogleDrive) HTML for account: " + accountId);
GoogleDriveReportWriter gdrwHtml = new GoogleDriveReportWriter.GoogleDriveReportWriterBuilder(
accountId, dateStart, dateEnd, mccAccountId, credential, ReportFileType.HTML,
templateName)
.withFolderPerAccount(perAccountFolder)
.build();
gdrwHtml.write(mrwHtml.getAsSource());
}
// Writing PDF to GoogleDrive
if (writePdf) {
LOGGER.debug("Writing (to GoogleDrive) PDF for account: " + accountId);
GoogleDriveReportWriter gdrwPdf = new GoogleDriveReportWriter.GoogleDriveReportWriterBuilder(
accountId, dateStart, dateEnd, mccAccountId, credential, ReportFileType.PDF,
templateName)
.withFolderPerAccount(perAccountFolder)
.build();
HTMLExporter.exportHtmlToPdf(mrwHtml.getAsSource(), gdrwPdf, fontPaths);
}
// Writing Drive Doc to GoogleDrive
if (writeDriveDoc) {
LOGGER.debug("Writing GoogleDrive Doc for account: " + accountId);
GoogleDriveReportWriter gdrwDriveDoc = new GoogleDriveReportWriter.GoogleDriveReportWriterBuilder(
accountId, dateStart, dateEnd, mccAccountId, credential, ReportFileType.DRIVE_DOC,
templateName)
.withFolderPerAccount(perAccountFolder)
.build();
gdrwDriveDoc.write(mrwHtml.getAsSource());
}
} else {
// Writing HTML to Disk
if (writeHtml) {
LOGGER.debug("Writing (to FileSystem) HTML for account: " + accountId);
FileSystemReportWriter fsrwHtml = FileSystemReportWriter.newFileSystemReportWriter(
templateName, dateStart, dateEnd, accountId, outputDirectory, ReportFileType.HTML);
fsrwHtml.write(mrwHtml.getAsSource());
}
// Writing PDF to Disk
if (writePdf) {
LOGGER.debug("Writing (to FileSystem) PDF for account: " + accountId);
FileSystemReportWriter fsrwPdf = FileSystemReportWriter.newFileSystemReportWriter(
templateName, dateStart, dateEnd, accountId, outputDirectory, ReportFileType.PDF);
HTMLExporter.exportHtmlToPdf(mrwHtml.getAsSource(), fsrwPdf, fontPaths);
}
}
} else {
LOGGER.info("No data found for account " + accountId);
}