@Test public void export() throws IOException { idolExportService.exportQueryResults(outputStream, queryRequest, ExportFormat.CSV, Collections.emptyList(), 10L); verify(aciService).executeAction(anySetOf(AciParameter.class), any()); }
@Override public void exportQueryResults(final OutputStream outputStream, final IdolQueryRequest queryRequest, final ExportFormat exportFormat, final Collection<String> selectedFieldIds, final long totalResults) throws AciErrorException, IOException { final PlatformDataExportStrategy exportStrategy = exportStrategies.get(exportFormat); final Collection<FieldInfo<?>> fieldNames = exportStrategy.getFieldNames(IdolMetadataNode.values(), selectedFieldIds); exportStrategy.writeHeader(outputStream, fieldNames); final Processor<Void> processor = new ExportQueryResponseProcessor(exportStrategy, outputStream, fieldNames, selectedFieldIds); for (int i = 0; i < totalResults; i += PAGINATION_SIZE) { final IdolQueryRequest paginatedQueryRequest = queryRequest.toBuilder() .start(i + 1) .maxResults(i + PAGINATION_SIZE) .build(); final AciParameters aciParameters = getAciParameters(paginatedQueryRequest); executeQueryDiscardingBlacklist( aciParameters, paginatedQueryRequest.getQueryType(), (params, queryType) -> aciServiceRetriever.getAciService(queryType).executeAction(params, processor) ); } }
IdolPlatformDataExportService implements PlatformDataExportService<IdolQueryRequest, AciErrorException> { @Override public void exportQueryResults(final OutputStream outputStream, final IdolQueryRequest queryRequest, final ExportFormat exportFormat, final Collection<String> selectedFieldIds, final long totalResults) throws AciErrorException, IOException { final PlatformDataExportStrategy exportStrategy = exportStrategies.get(exportFormat); final Collection<FieldInfo<?>> fieldNames = exportStrategy.getFieldNames(IdolMetadataNode.values(), selectedFieldIds); exportStrategy.writeHeader(outputStream, fieldNames); final Processor<Void> processor = new ExportQueryResponseProcessor(exportStrategy, outputStream, fieldNames, selectedFieldIds); for (int i = 0; i < totalResults; i += PAGINATION_SIZE) { final IdolQueryRequest paginatedQueryRequest = queryRequest.toBuilder() .start(i + 1) .maxResults(i + PAGINATION_SIZE) .build(); final AciParameters aciParameters = getAciParameters(paginatedQueryRequest); executeQueryDiscardingBlacklist( aciParameters, paginatedQueryRequest.getQueryType(), (params, queryType) -> aciServiceRetriever.getAciService(queryType).executeAction(params, processor) ); } } }
IdolPlatformDataExportService implements PlatformDataExportService<IdolQueryRequest, AciErrorException> { @Override public void exportQueryResults(final OutputStream outputStream, final IdolQueryRequest queryRequest, final ExportFormat exportFormat, final Collection<String> selectedFieldIds, final long totalResults) throws AciErrorException, IOException { final PlatformDataExportStrategy exportStrategy = exportStrategies.get(exportFormat); final Collection<FieldInfo<?>> fieldNames = exportStrategy.getFieldNames(IdolMetadataNode.values(), selectedFieldIds); exportStrategy.writeHeader(outputStream, fieldNames); final Processor<Void> processor = new ExportQueryResponseProcessor(exportStrategy, outputStream, fieldNames, selectedFieldIds); for (int i = 0; i < totalResults; i += PAGINATION_SIZE) { final IdolQueryRequest paginatedQueryRequest = queryRequest.toBuilder() .start(i + 1) .maxResults(i + PAGINATION_SIZE) .build(); final AciParameters aciParameters = getAciParameters(paginatedQueryRequest); executeQueryDiscardingBlacklist( aciParameters, paginatedQueryRequest.getQueryType(), (params, queryType) -> aciServiceRetriever.getAciService(queryType).executeAction(params, processor) ); } } @Autowired  IdolPlatformDataExportService(final HavenSearchAciParameterHandler parameterHandler,
                                         final AciServiceRetriever aciServiceRetriever,
                                         final PlatformDataExportStrategy[] exportStrategies); }
IdolPlatformDataExportService implements PlatformDataExportService<IdolQueryRequest, AciErrorException> { @Override public void exportQueryResults(final OutputStream outputStream, final IdolQueryRequest queryRequest, final ExportFormat exportFormat, final Collection<String> selectedFieldIds, final long totalResults) throws AciErrorException, IOException { final PlatformDataExportStrategy exportStrategy = exportStrategies.get(exportFormat); final Collection<FieldInfo<?>> fieldNames = exportStrategy.getFieldNames(IdolMetadataNode.values(), selectedFieldIds); exportStrategy.writeHeader(outputStream, fieldNames); final Processor<Void> processor = new ExportQueryResponseProcessor(exportStrategy, outputStream, fieldNames, selectedFieldIds); for (int i = 0; i < totalResults; i += PAGINATION_SIZE) { final IdolQueryRequest paginatedQueryRequest = queryRequest.toBuilder() .start(i + 1) .maxResults(i + PAGINATION_SIZE) .build(); final AciParameters aciParameters = getAciParameters(paginatedQueryRequest); executeQueryDiscardingBlacklist( aciParameters, paginatedQueryRequest.getQueryType(), (params, queryType) -> aciServiceRetriever.getAciService(queryType).executeAction(params, processor) ); } } @Autowired  IdolPlatformDataExportService(final HavenSearchAciParameterHandler parameterHandler,
                                         final AciServiceRetriever aciServiceRetriever,
                                         final PlatformDataExportStrategy[] exportStrategies); @Override void exportQueryResults(final OutputStream outputStream, final IdolQueryRequest queryRequest, final ExportFormat exportFormat, final Collection<String> selectedFieldIds, final long totalResults); @Override Collection<ExportFormat> handlesFormats(); }
IdolPlatformDataExportService implements PlatformDataExportService<IdolQueryRequest, AciErrorException> { @Override public void exportQueryResults(final OutputStream outputStream, final IdolQueryRequest queryRequest, final ExportFormat exportFormat, final Collection<String> selectedFieldIds, final long totalResults) throws AciErrorException, IOException { final PlatformDataExportStrategy exportStrategy = exportStrategies.get(exportFormat); final Collection<FieldInfo<?>> fieldNames = exportStrategy.getFieldNames(IdolMetadataNode.values(), selectedFieldIds); exportStrategy.writeHeader(outputStream, fieldNames); final Processor<Void> processor = new ExportQueryResponseProcessor(exportStrategy, outputStream, fieldNames, selectedFieldIds); for (int i = 0; i < totalResults; i += PAGINATION_SIZE) { final IdolQueryRequest paginatedQueryRequest = queryRequest.toBuilder() .start(i + 1) .maxResults(i + PAGINATION_SIZE) .build(); final AciParameters aciParameters = getAciParameters(paginatedQueryRequest); executeQueryDiscardingBlacklist( aciParameters, paginatedQueryRequest.getQueryType(), (params, queryType) -> aciServiceRetriever.getAciService(queryType).executeAction(params, processor) ); } } @Autowired  IdolPlatformDataExportService(final HavenSearchAciParameterHandler parameterHandler,
                                         final AciServiceRetriever aciServiceRetriever,
                                         final PlatformDataExportStrategy[] exportStrategies); @Override void exportQueryResults(final OutputStream outputStream, final IdolQueryRequest queryRequest, final ExportFormat exportFormat, final Collection<String> selectedFieldIds, final long totalResults); @Override Collection<ExportFormat> handlesFormats();  }