Search in sources :

Example 1 with ExportContext

use of org.motechproject.mds.json.ExportContext in project motech by motech.

the class ImportExportServiceImpl method exportEntities.

@Override
@Transactional
public void exportEntities(ImportExportBlueprint blueprint, Writer writer) {
    try (JsonWriter jsonWriter = new JsonWriter(writer)) {
        jsonWriter.setIndent("  ");
        ExportContext exportContext = new ExportContext(sortBlueprintRecords(blueprint), bundleContext, allEntities);
        ExportWriter exportWriter = new ExportWriter(jsonWriter, exportContext);
        exportWriter.export();
    } catch (IOException e) {
        throw new ImportExportException("An IO error occurred during export.", e);
    }
}
Also used : ExportContext(org.motechproject.mds.json.ExportContext) ImportExportException(org.motechproject.mds.exception.importexport.ImportExportException) IOException(java.io.IOException) JsonWriter(com.google.gson.stream.JsonWriter) ExportWriter(org.motechproject.mds.json.ExportWriter) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

JsonWriter (com.google.gson.stream.JsonWriter)1 IOException (java.io.IOException)1 ImportExportException (org.motechproject.mds.exception.importexport.ImportExportException)1 ExportContext (org.motechproject.mds.json.ExportContext)1 ExportWriter (org.motechproject.mds.json.ExportWriter)1 Transactional (org.springframework.transaction.annotation.Transactional)1