use of org.motechproject.mds.exception.importexport.ImportExportException in project motech by motech.
the class ImportExportServiceImpl method importSchema.
private void importSchema(final ImportContext importContext, final JsonReader jsonReader) {
LOGGER.debug("Importing schema...");
doInTransaction(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
try {
ImportReader importReader = new ImportReader(jsonReader, importContext);
importReader.importSchema();
} catch (IOException e) {
throw new ImportExportException("An error occurred during importing schema", e);
}
}
});
if (importContext.hasUnresolvedEntities()) {
LOGGER.warn("Unresolved relationships found. Skipping. ({})", importContext.getUnresolvedEntities());
}
LOGGER.debug("Schema imported.");
LOGGER.debug("Regenerating MDS bundle and refreshing affected bundles: {}", importContext.getAffectedModules());
mdsBundleRegenerationService.regenerateMdsDataBundleAfterDdeEnhancement(importContext.getAffectedModulesArray());
LOGGER.debug("Bundles regenerated/refreshed");
}
use of org.motechproject.mds.exception.importexport.ImportExportException 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);
}
}
use of org.motechproject.mds.exception.importexport.ImportExportException in project motech by motech.
the class ImportExportServiceImpl method importInstances.
private void importInstances(final ImportContext importContext, final JsonReader jsonReader) {
LOGGER.debug("Importing instances...");
doInTransaction(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
try {
importContext.removeExistingInstances();
ImportReader importReader = new ImportReader(jsonReader, importContext);
importReader.importInstances();
} catch (IOException e) {
throw new ImportExportException("An error occurred during importing schema", e);
}
}
});
LOGGER.debug("Instances imported.");
}
use of org.motechproject.mds.exception.importexport.ImportExportException in project motech by motech.
the class ImportExportServiceImpl method saveImportFileAndExtractManifest.
@Override
@Transactional
public ImportManifest saveImportFileAndExtractManifest(byte[] bytes) {
try {
ImportManifest manifest = extractManifest(bytes);
File file = createImportFile();
FileUtils.writeByteArrayToFile(file, bytes);
manifest.setImportId(getImportId(file));
return manifest;
} catch (IOException e) {
throw new ImportExportException("Cannot save import file", e);
}
}
Aggregations