Unresolved
Pinned fields
Click on the next to a field label to start pinning.
Details
Assignee
Szymon Radziszewski
Szymon Radziszewski(Deactivated)Reporter
Nikola Laskowska
Nikola Laskowska(Deactivated)Labels
Original estimate
1w
Time tracking
Priority
Time Assistant
Created October 27, 2022 at 5:40 AM
Updated March 1, 2023 at 1:35 PM
In referencedata service generate the .csv file with structure:
productCode
name
description
packRoundingThreshold
packSize
roundToZero
dispensable
VC003000
Bacillus Calmette Guerin
Bacillus Calmette Guerin
1
20
FALSE
dispensingUnit:dose
VC003001
Bivalent Oral Polio Vaccine (1+3)
Bivalent Oral Polio Vaccine (1+3)
1
10
FALSE
dispensingUnit:dose
VC003002
COVID-19 Vaccine AstraZeneca
COVID-19 Vaccine AstraZeneca
1
10
FALSE
dispensingUnit:dose
Mapping:
productCode -> referencedata.orderables.code
name -> referencedata.orderables.fullProductName
description -> referencedata.orderables.description
packRoundingThreshold -> referencedata.orderables.packroundingthreshold
packSize -> referencedata.orderables.netcontent
roundToZero -> referencedata.orderables.roundtozero
dispensable -> referencedata.dispensable_attributes
Export
Create a service class containing a methods that
- creates a csv file(s) with specific name(s).
- creates a zip archive containing csv files.
The csv generating method returns an ByteArrayOutputStream with processed data.
The method retrieves the Orderable data from the database and, using specific formatter implementation, processes them to bytes
- create an additional method that returns a Map where the keys are filenames and the values are the corresponding byte data
The zip generating method returns array of bytes and uses java.util.zip library to create archive.
Formatting
The data will be processed into the csv format using the solutions already available on the service. The writer implementation uses a super-csv lib.
This solution was introduced for exporting IdealStockAmount objects data to csv format. Check the ticket.
create base interface for formatters (DataFormatterService) with process method
create implementation of the base interface (CsvFormatterService) that uses already implemented writer
In case of need to extend the functionality of data export to other formats, it will only be necessary to add a new implementation without modifying the code.
Appropriate formatter implementations will be set dynamically using the BeanFactory.
DataFormatterService formatter = beanFactory.getBean(format + FORMATTER_SERVICE_NAME_SUFFIX, DataFormatterService.class);
Retrieving data
Generated files will not always be just entities, so another layer of data retrieval is needed.
create base interface to find data to be exported (ExportableDataService) with findAll method
OrderableService should implement that interface
Appropriate repository implementations will be set dynamically using the BeanFactory.
ExportableDataService service = beanFactory.getBean(filename + SERVICE_NAME_SUFFIX, ExportableDataService.class);
Knowledge base:
http://super-csv.github.io/super-csv/index.html
https://openlmis.atlassian.net/browse/OLMIS-3227