CsvImporterExporter

public class CsvImporterExporter extends AbstractMdsExporter

Component used for importing CSV records to the database. The reason for separating import logic is keeping the db transaction and sending the MOTECH event at completion separate. This bean lives in the context of the generated MDS entities bundle.

Methods

exportCsv

public long exportCsv(long entityId, Writer writer)

Exports entity instances to a CSV file.

Parameters:
  • entityId – id of the entity for which the instances will be exported
  • writer – the writer that will be used for output
Returns:

number of exported instances

exportCsv

public long exportCsv(String entityClassName, Writer writer)

Exports entity instances to a CSV file.

Parameters:
  • entityClassName – the class name of the entity for which instances will be exported
  • writer – the writer that will be used for output
Returns:

number of exported instances

exportCsv

public long exportCsv(long entityId, Writer writer, CsvExportCustomizer exportCustomizer)

Exports entity instances to a CSV file.

Parameters:
  • entityId – id of the entity for which the instances will be exported
  • writer – the writer that will be used for output
  • exportCustomizer – the customizer that will be used during export
Returns:

number of exported instances

exportCsv

public long exportCsv(String entityClassName, Writer writer, CsvExportCustomizer exportCustomizer)

Exports entity instances to a CSV file.

Parameters:
  • entityClassName – the class name of the entity for which instances will be exported
  • writer – the writer that will be used for output
  • exportCustomizer – the customizer that will be used during export
Returns:

number of exported instances

exportCsv

public long exportCsv(long entityId, Writer writer, String lookupName, QueryParams params, List<String> headers, Map<String, Object> lookupFields)

Exports entity instances to a CSV file.

Parameters:
  • entityId – id of the entity for which the instances will be exported
  • writer – the writer that will be used for output
  • lookupName – the name of lookup
  • params – query parameters to be used retrieving instances
  • headers – the headers of exported file
  • lookupFields – the lookupFields used in the lookup
Returns:

number of exported instances

exportCsv

public long exportCsv(String entityClassName, Writer writer, String lookupName, QueryParams params, List<String> headers, Map<String, Object> lookupFields)

Exports entity instances to a CSV file.

Parameters:
  • entityClassName – the class name of the entity for which instances will be exported
  • writer – the writer that will be used for output
  • lookupName – the name of lookup
  • params – query parameters to be used retrieving instances
  • headers – the headers of exported file
  • lookupFields – the lookupFields used in the lookup
Returns:

number of exported instances

exportCsv

public long exportCsv(long entityId, Writer writer, String lookupName, QueryParams params, List<String> headers, Map<String, Object> lookupFields, CsvExportCustomizer exportCustomizer)

Exports entity instances to a CSV file.

Parameters:
  • entityId – id of the entity for which the instances will be exported
  • writer – the writer that will be used for output
  • lookupName – the name of lookup
  • params – query parameters to be used retrieving instances
  • headers – the headers of exported file
  • lookupFields – the lookupFields used in the lookup
  • exportCustomizer – the customizer that will be used during export
Returns:

number of exported instances

exportCsv

public long exportCsv(String entityClassName, Writer writer, String lookupName, QueryParams params, List<String> headers, Map<String, Object> lookupFields, CsvExportCustomizer exportCustomizer)

Exports entity instances to a CSV file.

Parameters:
  • entityClassName – the class name of the entity for which instances will be exported
  • writer – the writer that will be used for output
  • lookupName – the name of lookup
  • params – query parameters to be used retrieving instances
  • headers – the headers of exported file
  • lookupFields – the lookupFields used in the lookup
  • exportCustomizer – the customizer that will be used during export
Returns:

number of exported instances

importCsv

public CsvImportResults importCsv(long entityId, Reader reader, boolean continueOnError, boolean clearData)

Imports instances of the given entity to the database.

Parameters:
  • entityId – the ID of the entity for which instances will be imported
  • reader – reader from which the csv file will be read
  • continueOnError – if true, import will continue with next row if exception was encountered, if false, import process will stop and rethrow the exception
Returns:

IDs of instances updated/added during import

importCsv

public CsvImportResults importCsv(long entityId, Reader reader, CsvImportCustomizer importCustomizer, boolean continueOnError, boolean clearData)

Imports instances of the given entity to the database.

Parameters:
  • entityId – the ID of the entity for which instances will be imported
  • reader – reader from which the csv file will be read
  • importCustomizer – the customizer that will be used during instance import from rows
  • continueOnError – if true, import will continue with next row if exception was encountered, if false, import process will stop and rethrow the exception
  • clearData – if true, import will clear instances from table
Returns:

IDs of instances updated/added during import

importCsv

public CsvImportResults importCsv(String entityClassName, Reader reader, boolean continueOnError)

Imports instances of the given entity to the database.

Parameters:
  • entityClassName – the class name of the entity for which instances will be imported
  • reader – reader from which the csv file will be read
  • continueOnError – if true, import will continue with next row if exception was encountered, if false, import process will stop and rethrow the exception
Returns:

IDs of instances updated/added during import