Search in sources :

Example 11 with ProgrammingErrorException

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;
}
Also used : ArrayList(java.util.ArrayList) ServiceConfigurationError(java.util.ServiceConfigurationError) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException)

Example 12 with ProgrammingErrorException

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;
}
Also used : ArrayList(java.util.ArrayList) ServiceConfigurationError(java.util.ServiceConfigurationError) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException)

Example 13 with ProgrammingErrorException

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();
    }
}
Also used : ExportError(net.geoprism.registry.etl.export.ExportError) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 14 with ProgrammingErrorException

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);
            }
        }
    }
}
Also used : Organization(org.hl7.fhir.r4.model.Organization) FhirPathR4(org.hl7.fhir.r4.hapi.fluentpath.FhirPathR4) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException) Location(org.hl7.fhir.r4.model.Location)

Example 15 with ProgrammingErrorException

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();
}
Also used : FilenameFilter(java.io.FilenameFilter) CloseableDelegateFile(net.geoprism.registry.etl.CloseableDelegateFile) ZipInputStream(java.util.zip.ZipInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException) CloseableFile(com.runwaysdk.resource.CloseableFile) File(java.io.File) CloseableDelegateFile(net.geoprism.registry.etl.CloseableDelegateFile) ImportFileFormatException(net.geoprism.registry.etl.ImportFileFormatException) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException)

Aggregations

ProgrammingErrorException (com.runwaysdk.dataaccess.ProgrammingErrorException)67 IOException (java.io.IOException)34 SimpleDateFormat (java.text.SimpleDateFormat)21 JsonObject (com.google.gson.JsonObject)18 File (java.io.File)16 ParseException (java.text.ParseException)16 InputStream (java.io.InputStream)13 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)13 MdAttributeConcreteDAOIF (com.runwaysdk.dataaccess.MdAttributeConcreteDAOIF)12 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)12 MdBusinessDAOIF (com.runwaysdk.dataaccess.MdBusinessDAOIF)11 JSONException (org.json.JSONException)11 JsonArray (com.google.gson.JsonArray)10 List (java.util.List)10 MdBusinessDAO (com.runwaysdk.dataaccess.metadata.MdBusinessDAO)9 ArrayList (java.util.ArrayList)9 Date (java.util.Date)9 HashMap (java.util.HashMap)8 Collectors (java.util.stream.Collectors)8 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)8