|
44 | 44 | import de.symeda.sormas.api.importexport.DatabaseTable; |
45 | 45 | import de.symeda.sormas.backend.action.Action; |
46 | 46 | import de.symeda.sormas.backend.activityascase.ActivityAsCase; |
| 47 | +import de.symeda.sormas.backend.adverseeventsfollowingimmunization.entity.AdverseEvents; |
| 48 | +import de.symeda.sormas.backend.adverseeventsfollowingimmunization.entity.Aefi; |
| 49 | +import de.symeda.sormas.backend.adverseeventsfollowingimmunization.entity.AefiInvestigation; |
47 | 50 | import de.symeda.sormas.backend.campaign.Campaign; |
48 | 51 | import de.symeda.sormas.backend.campaign.data.CampaignFormData; |
49 | 52 | import de.symeda.sormas.backend.campaign.diagram.CampaignDiagramDefinition; |
|
120 | 123 |
|
121 | 124 | /** |
122 | 125 | * Exporting data directly from the PostgreSQL database with COPY commands as .csv files. |
123 | | - * |
| 126 | + * |
124 | 127 | * @author Stefan Kock |
125 | 128 | */ |
126 | 129 | @Stateless |
127 | 130 | @LocalBean |
128 | 131 | public class DatabaseExportService { |
129 | 132 |
|
130 | 133 | private static final String COPY_SINGLE_TABLE = "COPY (SELECT * FROM %s) TO STDOUT WITH (FORMAT CSV, DELIMITER '%s', HEADER)"; |
131 | | - public static final String COUNT_TABLE_COLUMNS = "SELECT COUNT(column_name) FROM information_schema.columns WHERE table_name=:tableName"; |
| 134 | + public static final String COUNT_TABLE_COLUMNS = |
| 135 | + "SELECT COUNT(column_name) FROM information_schema.columns WHERE table_name=CAST(:tableName AS text)"; |
132 | 136 |
|
133 | 137 | static final Map<DatabaseTable, String> EXPORT_CONFIGS = new LinkedHashMap<>(); |
134 | 138 |
|
@@ -160,6 +164,9 @@ public class DatabaseExportService { |
160 | 164 | EXPORT_CONFIGS.put(DatabaseTable.TRAVEL_ENTRIES, TravelEntry.TABLE_NAME); |
161 | 165 | EXPORT_CONFIGS.put(DatabaseTable.IMMUNIZATIONS, Immunization.TABLE_NAME); |
162 | 166 | EXPORT_CONFIGS.put(DatabaseTable.VACCINATIONS, Vaccination.TABLE_NAME); |
| 167 | + EXPORT_CONFIGS.put(DatabaseTable.ADVERSE_EVENTS_FOLLOWING_IMMUNIZATIONS, Aefi.TABLE_NAME); |
| 168 | + EXPORT_CONFIGS.put(DatabaseTable.ADVERSE_EVENTS_FOLLOWING_IMMUNIZATION_INVESTIGATIONS, AefiInvestigation.TABLE_NAME); |
| 169 | + EXPORT_CONFIGS.put(DatabaseTable.ADVERSE_EVENTS, AdverseEvents.TABLE_NAME); |
163 | 170 | EXPORT_CONFIGS.put(DatabaseTable.SAMPLES, Sample.TABLE_NAME); |
164 | 171 | EXPORT_CONFIGS.put(DatabaseTable.PATHOGEN_TESTS, PathogenTest.TABLE_NAME); |
165 | 172 | EXPORT_CONFIGS.put(DatabaseTable.ADDITIONAL_TESTS, AdditionalTest.TABLE_NAME); |
@@ -283,7 +290,7 @@ private void addDataRows(DatabaseTable databaseTable, String tableName, Writer w |
283 | 290 |
|
284 | 291 | /** |
285 | 292 | * Run an export command and write the result directly into a Writer |
286 | | - * |
| 293 | + * |
287 | 294 | * @param writer |
288 | 295 | * @param sql |
289 | 296 | * Actual native sql command to copy data to CSV. |
|
0 commit comments