}
Properties properties = initApplicationContextAndProperties(propertiesPath);
LOGGER.debug("Creating ReportProcessor bean...");
ReportProcessor processor = createReportProcessor();
LOGGER.debug("... success.");
String mccAccountId = properties.getProperty("mccAccountId").replaceAll("-", "");;
if (cmdLine.hasOption("generatePdf")) {
LOGGER.debug("GeneratePDF option detected.");
// Get HTML template and output directory
String[] pdfFiles = cmdLine.getOptionValues("generatePdf");
File htmlTemplateFile = new File(pdfFiles[0]);
File outputDirectory = new File(pdfFiles[1]);
boolean sumAdExtensions = false;
if (cmdLine.hasOption("sumAdExtensions")) {
LOGGER.debug("sumAdExtensions option detected.");
sumAdExtensions = true;
}
LOGGER.debug("Html template file to be used: " + htmlTemplateFile);
LOGGER.debug("Output directory for PDF: " + outputDirectory);
// Export Reports
ReportExporterLocal reportExporter = createReportExporter();
reportExporter.exportReports(
createAuthenticator().getOAuth2Credential(null, mccAccountId, false),
mccAccountId, cmdLine.getOptionValue("startDate"),
cmdLine.getOptionValue("endDate"),
processor.retrieveAccountIds(null, mccAccountId),
properties, htmlTemplateFile,
outputDirectory, sumAdExtensions);
} else if (cmdLine.hasOption("startDate") && cmdLine.hasOption("endDate")) {
// Generate Reports
String dateStart = cmdLine.getOptionValue("startDate");
String dateEnd = cmdLine.getOptionValue("endDate");
LOGGER.info(
"Starting report download for dateStart: " + dateStart + " and dateEnd: " + dateEnd);
processor.generateReportsForMCC(null, mccAccountId, ReportDefinitionDateRangeType.CUSTOM_DATE, dateStart,
dateEnd, accountIdsSet, properties, null, null);
} else if (cmdLine.hasOption("dateRange")) {
ReportDefinitionDateRangeType dateRangeType =
ReportDefinitionDateRangeType.fromValue(cmdLine.getOptionValue("dateRange"));
LOGGER.info("Starting report download for dateRange: " + dateRangeType.name());
processor.generateReportsForMCC(null, mccAccountId, dateRangeType, null, null, accountIdsSet, properties, null, null);
} else {
errors = true;
LOGGER.error("Configuration incomplete. Missing options for command line.");
}