use of com.runwaysdk.dataaccess.ProgrammingErrorException in project geoprism-registry by terraframe.
the class FhirFactory method getPopulators.
public static List<FhirDataPopulator> getPopulators() {
List<FhirDataPopulator> configurations = new ArrayList<FhirDataPopulator>();
ServiceLoader<FhirDataPopulator> loader = ServiceLoader.load(FhirDataPopulator.class, Thread.currentThread().getContextClassLoader());
try {
Iterator<FhirDataPopulator> it = loader.iterator();
while (it.hasNext()) {
configurations.add(it.next());
}
} catch (ServiceConfigurationError serviceError) {
throw new ProgrammingErrorException(serviceError);
}
return configurations;
}
use of com.runwaysdk.dataaccess.ProgrammingErrorException in project geoprism-registry by terraframe.
the class FhirFactory method getProcessors.
public static List<FhirResourceProcessor> getProcessors() {
List<FhirResourceProcessor> configurations = new ArrayList<FhirResourceProcessor>();
ServiceLoader<FhirResourceProcessor> loader = ServiceLoader.load(FhirResourceProcessor.class, Thread.currentThread().getContextClassLoader());
try {
Iterator<FhirResourceProcessor> it = loader.iterator();
while (it.hasNext()) {
configurations.add(it.next());
}
} catch (ServiceConfigurationError serviceError) {
throw new ProgrammingErrorException(serviceError);
}
return configurations;
}
use of com.runwaysdk.dataaccess.ProgrammingErrorException in project geoprism-registry by terraframe.
the class FhirResourceImporter method recordExportError.
@Transaction
private void recordExportError(Exception ex, ExportHistory history, Resource resource) {
if (ex instanceof ProgrammingErrorException) {
logger.error("Unknown error while processing the FHIR resource [" + resource.getId() + "]", ex);
}
if (this.history != null) {
ExportError exportError = new ExportError();
exportError.setCode(resource.getId());
if (ex != null) {
exportError.setErrorJson(JobHistory.exceptionToJson(ex).toString());
}
// exportError.setRowIndex(ee.rowIndex);
exportError.setHistory(history);
exportError.apply();
}
}
use of com.runwaysdk.dataaccess.ProgrammingErrorException in project geoprism-registry by terraframe.
the class FhirResourceImporter method process.
private void process(Bundle bundle) {
FhirPathR4 path = new FhirPathR4(FhirContext.forR4());
List<Location> locations = path.evaluate(bundle, "Bundle.entry.resource.ofType(Location)", Location.class);
for (Location location : locations) {
try {
handleLocation(location);
if (this.history != null) {
this.history.appLock();
this.history.setWorkProgress(count++);
this.history.setExportedRecords(exportCount++);
this.history.apply();
}
} catch (Exception e) {
if (this.history != null) {
this.recordExportError(e, this.history, location);
this.history.appLock();
this.history.setWorkProgress(count++);
this.history.apply();
} else {
throw new ProgrammingErrorException(e);
}
}
}
List<Organization> organizations = path.evaluate(bundle, "Bundle.entry.resource.ofType(Organization)", Organization.class);
for (Organization organization : organizations) {
try {
handleOrganization(organization);
if (this.history != null) {
this.history.appLock();
this.history.setWorkProgress(count++);
this.history.setExportedRecords(exportCount++);
this.history.apply();
}
} catch (Exception e) {
if (this.history != null) {
this.recordExportError(e, this.history, organization);
this.history.appLock();
this.history.setWorkProgress(count++);
this.history.apply();
} else {
throw new ProgrammingErrorException(e);
}
}
}
}
use of com.runwaysdk.dataaccess.ProgrammingErrorException in project geoprism-registry by terraframe.
the class ExcelImporter method getExcelFileFromResource.
public static CloseableFile getExcelFileFromResource(ApplicationResource res) {
final String extension = "xlsx";
try {
if (res.getNameExtension().equals("zip")) {
try (InputStream is = res.openNewStream()) {
File dir = Files.createTempDirectory(res.getBaseName()).toFile();
extract(is, dir);
File[] files = dir.listFiles(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.endsWith("." + extension);
}
});
if (files.length > 0) {
return new CloseableDelegateFile(files[0], dir);
} else {
throw new ImportFileFormatException();
}
}
} else if (res.getNameExtension().equals(extension)) {
return res.openNewFile();
}
} catch (IOException e) {
throw new ProgrammingErrorException(e);
}
throw new ImportFileFormatException();
}
Aggregations