public String value() { return name(); }
public static ReportDefinitionReportType fromValue(String v) { return valueOf(v); }
@Override public ReportQuery.Builder from(String reportType) { return from(ReportDefinitionReportType.fromValue(reportType)); }
CsvReport csvReport = reportBeanClass.getAnnotation(CsvReport.class); if (csvReport.value().equals(ReportDefinitionReportType.UNKNOWN)) { experimentalReportsDefinitionMap.put(csvReport.fileOnlyReportType(), reportBeanClass); } else {
/** * Instantiates the report definition, setting all the correct formats. * * @param reportDefinitionReportType the report definition type. * @param dateRangeType the date range type. * @param selector the selector containing the report properties. * @return the {@code ReportDefinition} */ protected ReportDefinition instantiateReportDefinition( ReportDefinitionReportType reportDefinitionReportType, ReportDefinitionDateRangeType dateRangeType, Selector selector) { // Create the Report Definition ReportDefinition reportDefinition = new ReportDefinition(); reportDefinition.setReportName( REPORT_PREFIX + reportDefinitionReportType.value() + " " + System.currentTimeMillis()); reportDefinition.setDateRangeType(dateRangeType); reportDefinition.setReportType(reportDefinitionReportType); reportDefinition.setDownloadFormat(DownloadFormat.GZIPPED_CSV); reportDefinition.setSelector(selector); return reportDefinition; }
@Override public ReportQuery.Builder from(String reportType) { return from(ReportDefinitionReportType.fromValue(reportType)); }
public String value() { return name(); }
public static ReportDefinitionReportType fromValue(String v) { return valueOf(v); }
/** * Deletes the local files used as temporary containers. * * @param localFiles the list of local unzipped files. * @param reportType the report type. */ private void deleteTemporaryFiles( Collection<File> localFiles, ReportDefinitionReportType reportType) { // Delete temporary report files logger.info("\n Deleting temporary report files after Parsing..."); for (File file : localFiles) { file.delete(); logger.trace("."); } logger.info("\n ** Finished: " + reportType.name() + " **"); }
/** * Extracts the report type name from the given key name. * * @param keyName the name of the key in the properties file. * @return the report type name, without the "$" symbol, so it can be used to download the report * type. */ private ReportDefinitionReportType extractReportTypeFromKey(String keyName) { int indexOfDollar = keyName.indexOf(REPORT_KEY_SEPARATOR); if (indexOfDollar > 0) { keyName = keyName.substring(0, indexOfDollar); } try { return ReportDefinitionReportType.valueOf(keyName); } catch (IllegalArgumentException e) { return null; } }
/** * Downloads all the files from the API and process all the rows, saving the data to the * configured database. * * @param topCustomerId the top customer account id. * @param reportType the report type. * @param dateRangeAndType the date range and type. * @param accountIdList the account IDs. * @param properties the properties resource. * @throws ReportProcessingException */ @Override protected void downloadAndProcess( String topCustomerId, ReportDefinitionReportType reportType, DateRangeAndType dateRangeAndType, Set<Long> accountIdList, String reportDefinitionKey, Properties properties) throws ReportProcessingException { // Download Reports to local files and Generate Report objects logger.info("\n\n ** Generating: " + reportType.name() + " **"); logger.info(" Processing reports..."); ReportDefinition reportDefinition = getReportDefinition(reportType, dateRangeAndType, reportDefinitionKey, properties); Class<? extends Report> reportBeanClass = this.csvReportEntitiesMapping.getReportBeanClass(reportType); downloadAndProcessReports( topCustomerId, reportBeanClass, accountIdList, reportDefinition, dateRangeAndType); }
/** * Process the input files delegating the call to the concrete implementation. * * @param topCustomerId the top customer account id. * @param reportTypeName the report type name as String. * @param localFiles the local files. * @param dateRangeAndType the date range and type. * @throws ReportProcessingException */ public void processInputFiles( String topCustomerId, String reportTypeName, Collection<File> localFiles, DateRangeAndType dateRangeAndType) throws ReportProcessingException { Class<? extends Report> reportBeanClass; try { ReportDefinitionReportType reportType = ReportDefinitionReportType.valueOf(reportTypeName); reportBeanClass = csvReportEntitiesMapping.getReportBeanClass(reportType); } catch (IllegalArgumentException e) { reportBeanClass = csvReportEntitiesMapping.getExperimentalReportBeanClass(reportTypeName); } if (reportBeanClass == null) { throw new IllegalArgumentException("Report type not found: " + reportTypeName); } processFiles(topCustomerId, reportBeanClass, localFiles, false, dateRangeAndType); }
logger.info("\n\n ** Generating: " + reportType.name() + " **"); logger.info(" Downloading reports..."); Collection<File> localFiles = Lists.newArrayList();