use of com.runwaysdk.system.scheduler.JobHistoryQuery in project geoprism-registry by terraframe.
the class ListTypeTest method waitUntilPublished.
@Request
private void waitUntilPublished(String oid) {
List<? extends JobHistory> histories = null;
int waitTime = 0;
while (histories == null) {
if (waitTime > 10000) {
Assert.fail("Job was never scheduled. Unable to find any associated history.");
}
QueryFactory qf = new QueryFactory();
PublishListTypeVersionJobQuery jobQuery = new PublishListTypeVersionJobQuery(qf);
jobQuery.WHERE(jobQuery.getListType().EQ(oid));
JobHistoryQuery jhq = new JobHistoryQuery(qf);
jhq.WHERE(jhq.job(jobQuery));
List<? extends JobHistory> potentialHistories = jhq.getIterator().getAll();
if (potentialHistories.size() > 0) {
histories = potentialHistories;
} else {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
Assert.fail("Interrupted while waiting");
}
waitTime += 1000;
}
}
for (JobHistory history : histories) {
try {
SchedulerTestUtils.waitUntilStatus(history.getOid(), AllJobStatus.SUCCESS);
} catch (InterruptedException e) {
e.printStackTrace();
Assert.fail("Interrupted while waiting");
}
}
}
use of com.runwaysdk.system.scheduler.JobHistoryQuery in project geoprism-registry by terraframe.
the class ListTypeService method publishVersion.
@Request(RequestType.SESSION)
public JsonObject publishVersion(String sessionId, String oid) {
ListTypeVersion version = ListTypeVersion.get(oid);
// Only a working version can be republished.
if (!version.getWorking()) {
throw new UnsupportedOperationException();
}
this.enforceReadPermissions(version.getListType());
QueryFactory factory = new QueryFactory();
PublishListTypeVersionJobQuery query = new PublishListTypeVersionJobQuery(factory);
query.WHERE(query.getVersion().EQ(version));
JobHistoryQuery q = new JobHistoryQuery(factory);
q.WHERE(q.getStatus().containsAny(AllJobStatus.NEW, AllJobStatus.QUEUED, AllJobStatus.RUNNING));
q.AND(q.job(query));
if (q.getCount() > 0) {
throw new DuplicateJobException("This version has already been queued for publishing");
}
PublishListTypeVersionJob job = new PublishListTypeVersionJob();
job.setRunAsUserId(Session.getCurrentSession().getUser().getOid());
job.setVersion(version);
job.setListType(version.getListType());
job.apply();
NotificationFacade.queue(new GlobalNotificationMessage(MessageType.PUBLISH_JOB_CHANGE, null));
final JobHistory history = job.start();
JsonObject resp = new JsonObject();
resp.addProperty("jobOid", history.getOid());
return resp;
}
Aggregations