@Test public void shouldExportAllInstancesAsCsv() { when(motechDataService.retrieveAll(any(QueryParams.class))).thenReturn(testInstances(IdMode.INCLUDE_ID)); StringWriter writer = new StringWriter(); long result = csvImporterExporter.exportCsv(ENTITY_ID, writer); assertEquals(INSTANCE_COUNT, result); assertEquals(getTestEntityRecordsAsCsv(IdMode.INCLUDE_ID), writer.toString()); }
@Transactional public long exportCsv(final long entityId, final Writer writer) { EntityInfo entityInfo = getEntity(entityId); try (CsvTableWriter tableWriter = new CsvTableWriter(writer)) { return exportData(entityInfo, tableWriter); } }
CsvImporterExporter extends AbstractMdsExporter { @Transactional public long exportCsv(final long entityId, final Writer writer) { EntityInfo entityInfo = getEntity(entityId); try (CsvTableWriter tableWriter = new CsvTableWriter(writer)) { return exportData(entityInfo, tableWriter); } } }
CsvImporterExporter extends AbstractMdsExporter { @Transactional public long exportCsv(final long entityId, final Writer writer) { EntityInfo entityInfo = getEntity(entityId); try (CsvTableWriter tableWriter = new CsvTableWriter(writer)) { return exportData(entityInfo, tableWriter); } }  }
CsvImporterExporter extends AbstractMdsExporter { @Transactional public long exportCsv(final long entityId, final Writer writer) { EntityInfo entityInfo = getEntity(entityId); try (CsvTableWriter tableWriter = new CsvTableWriter(writer)) { return exportData(entityInfo, tableWriter); } }  @Transactional CsvImportResults importCsv(final long entityId, final Reader reader, boolean continueOnError, boolean clearData); @Transactional CsvImportResults importCsv(final long entityId, final Reader reader, CsvImportCustomizer importCustomizer, boolean continueOnError, boolean clearData); @Transactional CsvImportResults importCsv(final String entityClassName, final Reader reader, boolean continueOnError); @Transactional long exportCsv(final long entityId, final Writer writer); @Transactional long exportCsv(final String entityClassName, final Writer writer); @Transactional long exportCsv(final long entityId, final Writer writer, final CsvExportCustomizer exportCustomizer); @Transactional long exportCsv(final String entityClassName, final Writer writer, final CsvExportCustomizer exportCustomizer); @Transactional long exportCsv(long entityId, Writer writer, String lookupName, QueryParams params, List<String> headers,
                          Map<String, Object> lookupFields); @Transactional long exportCsv(String entityClassName, Writer writer, String lookupName, QueryParams params, List<String> headers,
                          Map<String, Object> lookupFields); @Transactional long exportCsv(long entityId, Writer writer, String lookupName, QueryParams params, List<String> headers,
                          Map<String, Object> lookupFields, CsvExportCustomizer exportCustomizer); @Transactional long exportCsv(String entityClassName, Writer writer, String lookupName, QueryParams params, List<String> headers,
                          Map<String, Object> lookupFields, CsvExportCustomizer exportCustomizer); }
CsvImporterExporter extends AbstractMdsExporter { @Transactional public long exportCsv(final long entityId, final Writer writer) { EntityInfo entityInfo = getEntity(entityId); try (CsvTableWriter tableWriter = new CsvTableWriter(writer)) { return exportData(entityInfo, tableWriter); } }  @Transactional CsvImportResults importCsv(final long entityId, final Reader reader, boolean continueOnError, boolean clearData); @Transactional CsvImportResults importCsv(final long entityId, final Reader reader, CsvImportCustomizer importCustomizer, boolean continueOnError, boolean clearData); @Transactional CsvImportResults importCsv(final String entityClassName, final Reader reader, boolean continueOnError); @Transactional long exportCsv(final long entityId, final Writer writer); @Transactional long exportCsv(final String entityClassName, final Writer writer); @Transactional long exportCsv(final long entityId, final Writer writer, final CsvExportCustomizer exportCustomizer); @Transactional long exportCsv(final String entityClassName, final Writer writer, final CsvExportCustomizer exportCustomizer); @Transactional long exportCsv(long entityId, Writer writer, String lookupName, QueryParams params, List<String> headers,
                          Map<String, Object> lookupFields); @Transactional long exportCsv(String entityClassName, Writer writer, String lookupName, QueryParams params, List<String> headers,
                          Map<String, Object> lookupFields); @Transactional long exportCsv(long entityId, Writer writer, String lookupName, QueryParams params, List<String> headers,
                          Map<String, Object> lookupFields, CsvExportCustomizer exportCustomizer); @Transactional long exportCsv(String entityClassName, Writer writer, String lookupName, QueryParams params, List<String> headers,
                          Map<String, Object> lookupFields, CsvExportCustomizer exportCustomizer);  }