use of com.runwaysdk.system.scheduler.JobHistoryRecordQuery in project geoprism-registry by terraframe.
the class SchedulerTestUtils method clearImportData.
@Request
public static void clearImportData() {
List<JobHistoryRecord> stoppedJobs = SchedulerManager.interruptAllRunningJobs();
if (stoppedJobs.size() > 0) {
try {
// Wait a few seconds for the job to stop
Thread.sleep(2000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
ValidationProblemQuery vpq = new ValidationProblemQuery(new QueryFactory());
OIterator<? extends ValidationProblem> vpit = vpq.getIterator();
while (vpit.hasNext()) {
ValidationProblem.lock(vpit.next().getOid()).delete();
}
ImportErrorQuery ieq = new ImportErrorQuery(new QueryFactory());
OIterator<? extends ImportError> ieit = ieq.getIterator();
while (ieit.hasNext()) {
ImportError.lock(ieit.next().getOid()).delete();
}
JobHistoryRecordQuery query = new JobHistoryRecordQuery(new QueryFactory());
OIterator<? extends JobHistoryRecord> jhrs = query.getIterator();
while (jhrs.hasNext()) {
JobHistoryRecord jhr = JobHistoryRecord.lock(jhrs.next().getOid());
jhr.appLock();
JobHistory hist = jhr.getChild();
if (hist instanceof ImportHistory) {
hist = ImportHistory.lock(hist.getOid());
hist.appLock();
ExecutableJob job = jhr.getParent();
job.appLock();
// If any tests are currently running, they will be errored out as a result of this.
if (hist.getStatus().get(0).equals(AllJobStatus.RUNNING) || hist.getStatus().get(0).equals(AllJobStatus.NEW) || hist.getStatus().get(0).equals(AllJobStatus.QUEUED)) {
logger.error("History with oid [" + hist.getOid() + "] currently has status [" + hist.getStatus().get(0).getEnumName() + "] which is concerning because it is about to be deleted. This will probably cause errors in the running job.");
}
// hist = ImportHistory.lock(hist.getOid());
// hist.appLock();
// hist = ImportHistory.lock(hist.getOid());
// VaultFile vf = ( (ImportHistory) hist ).getImportFile();
// hist.setValue(ImportHistory.IMPORTFILE, null);
// JobHistoryHistoryComment comment = hist.getHistoryComment();
// hist.setValue(JobHistory.HISTORYCOMMENT, null);
// JobHistoryHistoryInformation information = hist.getHistoryInformation();
// hist.setValue(JobHistory.HISTORYINFORMATION, null);
// hist.apply();
// vf.delete();
// comment.delete();
// information.delete();
// hist = ImportHistory.lock(hist.getOid());
// hist.appLock();
// hist = ImportHistory.lock(hist.getOid());
// hist.delete();
// This will also delete the history.
JobHistoryRecord.lock(jhr.getOid()).delete();
ExecutableJob.lock(job.getOid()).delete();
}
}
SynonymQuery sq = new SynonymQuery(new QueryFactory());
sq.WHERE(sq.getDisplayLabel().localize().EQ("00"));
OIterator<? extends Synonym> it = sq.getIterator();
while (it.hasNext()) {
Synonym.lock(it.next().getOid()).delete();
}
}
Aggregations