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