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();
}
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;
}
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);
}
}
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));
}
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));
}
Aggregations