Search in sources :

Example 11 with GlobalNotificationMessage

use of net.geoprism.registry.ws.GlobalNotificationMessage in project geoprism-registry by terraframe.

the class RegistryService method createGeoObjectType.

/**
 * Creates a {@link GeoObjectType} from the given JSON.
 *
 * @param sessionId
 * @param gtJSON
 *          JSON of the {@link GeoObjectType} to be created.
 * @return newly created {@link GeoObjectType}
 */
@Request(RequestType.SESSION)
public GeoObjectType createGeoObjectType(String sessionId, String gtJSON) {
    ServerGeoObjectType type = null;
    type = new ServerGeoObjectTypeConverter().create(gtJSON);
    ((Session) Session.getCurrentSession()).reloadPermissions();
    // If this did not error out then add to the cache
    ServiceFactory.getMetadataCache().addGeoObjectType(type);
    NotificationFacade.queue(new GlobalNotificationMessage(MessageType.TYPE_CACHE_CHANGE, null));
    return type.getType();
}
Also used : ServerGeoObjectTypeConverter(net.geoprism.registry.conversion.ServerGeoObjectTypeConverter) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) GlobalNotificationMessage(net.geoprism.registry.ws.GlobalNotificationMessage) Session(com.runwaysdk.session.Session) Request(com.runwaysdk.session.Request) OAuthClientRequest(org.apache.oltu.oauth2.client.request.OAuthClientRequest)

Example 12 with GlobalNotificationMessage

use of net.geoprism.registry.ws.GlobalNotificationMessage in project geoprism-registry by terraframe.

the class DataImportJob method createNewHistory.

@Override
public JobHistory createNewHistory() {
    ImportHistory history = new ImportHistory();
    history.setStartTime(new Date());
    history.addStatus(AllJobStatus.NEW);
    history.addStage(ImportStage.VALIDATE);
    history.setWorkProgress(0L);
    history.setImportedRecords(0L);
    history.apply();
    NotificationFacade.queue(new GlobalNotificationMessage(MessageType.IMPORT_JOB_CHANGE, null));
    return history;
}
Also used : GlobalNotificationMessage(net.geoprism.registry.ws.GlobalNotificationMessage) Date(java.util.Date)

Example 13 with GlobalNotificationMessage

use of net.geoprism.registry.ws.GlobalNotificationMessage in project geoprism-registry by terraframe.

the class DataImportJob method process.

// TODO : It might actually be faster to first convert into a shared temp
// table, assuming you're resolving the parent references into it.
private void process(ExecutionContext executionContext, ImportHistory history, ImportStage stage, ImportConfiguration config) throws MalformedURLException, InvocationTargetException {
    validate(config);
    // TODO : We should have a single transaction where we do all the history
    // configuration upfront, that way the job is either fully configured (and
    // resumable) or it isn't (no in-between)
    config.setHistoryId(history.getOid());
    config.setJobId(this.getOid());
    if (stage.equals(ImportStage.VALIDATE)) {
        // We can't do this because it prevents people from resuming the job where
        // it left off
        // history.appLock();
        // history.setWorkProgress(0L);
        // history.setImportedRecords(0L);
        // history.apply();
        ImportProgressListenerIF progressListener = runImport(history, stage, config);
        if (progressListener.hasValidationProblems()) {
            executionContext.setStatus(AllJobStatus.FEEDBACK);
            progressListener.applyValidationProblems();
            history.appLock();
            history.clearStage();
            history.addStage(ImportStage.VALIDATION_RESOLVE);
            history.setConfigJson(config.toJSON().toString());
            history.apply();
            NotificationFacade.queue(new GlobalNotificationMessage(MessageType.IMPORT_JOB_CHANGE, null));
        } else {
            history.appLock();
            history.clearStage();
            history.addStage(ImportStage.IMPORT);
            history.setConfigJson(config.toJSON().toString());
            history.setWorkProgress(0L);
            history.setImportedRecords(0L);
            history.apply();
            NotificationFacade.queue(new GlobalNotificationMessage(MessageType.IMPORT_JOB_CHANGE, null));
            this.process(executionContext, history, ImportStage.IMPORT, config);
        }
    } else if (stage.equals(ImportStage.IMPORT)) {
        deleteValidationProblems(history);
        // We can't do this because it prevents people from resuming the job where
        // it left off
        // history.appLock();
        // history.setWorkProgress(0L);
        // history.setImportedRecords(0L);
        // history.apply();
        runImport(history, stage, config);
        if (history.hasImportErrors()) {
            history.appLock();
            history.clearStage();
            history.addStage(ImportStage.IMPORT_RESOLVE);
            history.setConfigJson(config.toJSON().toString());
            history.apply();
            executionContext.setStatus(AllJobStatus.FEEDBACK);
        } else {
            history.appLock();
            history.clearStage();
            history.addStage(ImportStage.COMPLETE);
            history.setConfigJson(config.toJSON().toString());
            history.apply();
        }
        NotificationFacade.queue(new GlobalNotificationMessage(MessageType.IMPORT_JOB_CHANGE, null));
    } else if (// TODO : I'm not sure
    stage.equals(ImportStage.RESUME_IMPORT)) // this code block is ever
    // used
    {
        runImport(history, stage, config);
        if (history.hasImportErrors()) {
            history.appLock();
            history.clearStage();
            history.addStage(ImportStage.IMPORT_RESOLVE);
            history.setConfigJson(config.toJSON().toString());
            history.apply();
            executionContext.setStatus(AllJobStatus.FEEDBACK);
        } else {
            history.appLock();
            history.clearStage();
            history.addStage(ImportStage.COMPLETE);
            history.setConfigJson(config.toJSON().toString());
            history.apply();
        }
        NotificationFacade.queue(new GlobalNotificationMessage(MessageType.IMPORT_JOB_CHANGE, null));
    } else {
        String msg = "Invalid import stage [" + stage.getEnumName() + "].";
        logger.error(msg);
        throw new ProgrammingErrorException(msg);
    }
}
Also used : ImportProgressListenerIF(net.geoprism.registry.etl.upload.ImportProgressListenerIF) GlobalNotificationMessage(net.geoprism.registry.ws.GlobalNotificationMessage) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException)

Example 14 with GlobalNotificationMessage

use of net.geoprism.registry.ws.GlobalNotificationMessage in project geoprism-registry by terraframe.

the class DataImportJob method resumeInTrans.

@Transaction
private void resumeInTrans(JobHistoryRecord jhr) {
    ImportHistory hist = (ImportHistory) jhr.getChild();
    ImportStage stage = hist.getStage().get(0);
    if (hist.getStatus().get(0).equals(AllJobStatus.RUNNING)) {
    // This code block happens when the server restarts after a job was
    // running when it died.
    // Do nothing. Allow the job to resume as normal.
    } else {
        if (stage.equals(ImportStage.VALIDATION_RESOLVE)) {
            DataImportJob.deleteValidationProblems(hist);
            hist.appLock();
            hist.clearStage();
            hist.addStage(ImportStage.VALIDATE);
            hist.setWorkProgress(0L);
            hist.setImportedRecords(0L);
            hist.apply();
        } else // else if (stage.equals(ImportStage.IMPORT_RESOLVE))
        // {
        // hist.appLock();
        // hist.clearStage();
        // hist.setWorkProgress(0);
        // hist.addStage(ImportStage.RESUME_IMPORT);
        // hist.apply();
        // }
        {
            logger.error("Resuming job with unexpected initial stage [" + stage + "].");
            hist.appLock();
            hist.clearStage();
            hist.addStage(ImportStage.VALIDATE);
            hist.apply();
        }
    }
    NotificationFacade.queue(new GlobalNotificationMessage(MessageType.IMPORT_JOB_CHANGE, null));
}
Also used : GlobalNotificationMessage(net.geoprism.registry.ws.GlobalNotificationMessage) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 15 with GlobalNotificationMessage

use of net.geoprism.registry.ws.GlobalNotificationMessage in project geoprism-registry by terraframe.

the class FhirExportJob method afterJobExecute.

@Override
public void afterJobExecute(JobHistory history) {
    super.afterJobExecute(history);
    NotificationFacade.queue(new GlobalNotificationMessage(MessageType.PUBLISH_JOB_CHANGE, null));
}
Also used : GlobalNotificationMessage(net.geoprism.registry.ws.GlobalNotificationMessage)

Aggregations

GlobalNotificationMessage (net.geoprism.registry.ws.GlobalNotificationMessage)25 Date (java.util.Date)5 ProgrammingErrorException (com.runwaysdk.dataaccess.ProgrammingErrorException)4 Request (com.runwaysdk.session.Request)4 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)4 JsonObject (com.google.gson.JsonObject)3 Session (com.runwaysdk.session.Session)3 HttpError (net.geoprism.registry.etl.export.HttpError)3 FhirExternalSystem (net.geoprism.registry.graph.FhirExternalSystem)3 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)2 ListTypeVersion (net.geoprism.registry.ListTypeVersion)2 OAuthClientRequest (org.apache.oltu.oauth2.client.request.OAuthClientRequest)2 DataFormatException (ca.uhn.fhir.parser.DataFormatException)1 GsonBuilder (com.google.gson.GsonBuilder)1 JsonArray (com.google.gson.JsonArray)1 Business (com.runwaysdk.business.Business)1 BusinessQuery (com.runwaysdk.business.BusinessQuery)1 QueryFactory (com.runwaysdk.query.QueryFactory)1 JobHistory (com.runwaysdk.system.scheduler.JobHistory)1 JobHistoryQuery (com.runwaysdk.system.scheduler.JobHistoryQuery)1