Search in sources :

Example 1 with ExportError

use of net.geoprism.registry.etl.export.ExportError in project geoprism-registry by terraframe.

the class DHIS2SynchronizationManager method recordExportError.

private void recordExportError(DHIS2SyncError ee, ExportHistory history) {
    DHIS2ImportResponse resp = ee.response;
    Throwable ex = ee.error;
    String geoObjectCode = ee.geoObjectCode;
    ExportError exportError = new ExportError();
    if (ee.submittedJson != null) {
        exportError.setSubmittedJson(ee.submittedJson);
    }
    if (resp != null) {
        if (resp.getResponse() != null && resp.getResponse().length() > 0) {
            exportError.setResponseJson(resp.getResponse());
            if (resp.hasErrorReports()) {
                List<ErrorReport> reports = resp.getErrorReports();
                ErrorReport report = reports.get(0);
                exportError.setErrorMessage(report.getMessage());
            }
        }
        exportError.setErrorCode(resp.getStatusCode());
    }
    exportError.setCode(geoObjectCode);
    if (ex != null) {
        exportError.setErrorJson(JobHistory.exceptionToJson(ex).toString());
    }
    exportError.setRowIndex(ee.rowIndex);
    exportError.setHistory(history);
    exportError.apply();
}
Also used : ErrorReport(net.geoprism.dhis2.dhis2adapter.response.model.ErrorReport) ExportError(net.geoprism.registry.etl.export.ExportError) DHIS2ImportResponse(net.geoprism.dhis2.dhis2adapter.response.DHIS2ImportResponse)

Example 2 with ExportError

use of net.geoprism.registry.etl.export.ExportError 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 3 with ExportError

use of net.geoprism.registry.etl.export.ExportError in project geoprism-registry by terraframe.

the class ETLService method getExportErrors.

@Request(RequestType.SESSION)
public JsonObject getExportErrors(String sessionId, String historyId, int pageSize, int pageNumber) {
    JsonArray ja = new JsonArray();
    ExportErrorQuery query = new ExportErrorQuery(new QueryFactory());
    query.WHERE(query.getHistory().EQ(historyId));
    query.ORDER_BY(query.getRowIndex(), SortOrder.ASC);
    query.restrictRows(pageSize, pageNumber);
    try (OIterator<? extends ExportError> it = query.getIterator()) {
        List<ExportError> results = new LinkedList<>(it.getAll());
        return new Page<ExportError>(query.getCount(), query.getPageNumber(), query.getPageSize(), results).toJSON();
    }
}
Also used : JsonArray(com.google.gson.JsonArray) QueryFactory(com.runwaysdk.query.QueryFactory) ExportErrorQuery(net.geoprism.registry.etl.export.ExportErrorQuery) ExportError(net.geoprism.registry.etl.export.ExportError) LinkedList(java.util.LinkedList) Request(com.runwaysdk.session.Request)

Aggregations

ExportError (net.geoprism.registry.etl.export.ExportError)3 JsonArray (com.google.gson.JsonArray)1 ProgrammingErrorException (com.runwaysdk.dataaccess.ProgrammingErrorException)1 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)1 QueryFactory (com.runwaysdk.query.QueryFactory)1 Request (com.runwaysdk.session.Request)1 LinkedList (java.util.LinkedList)1 DHIS2ImportResponse (net.geoprism.dhis2.dhis2adapter.response.DHIS2ImportResponse)1 ErrorReport (net.geoprism.dhis2.dhis2adapter.response.model.ErrorReport)1 ExportErrorQuery (net.geoprism.registry.etl.export.ExportErrorQuery)1