}
clean.cleanRepository();
}
public void cleanRepository() throws Exception {
WorkflowInstancePage page = wm != null ? wm.getFirstPage() : rep
.getFirstPage();
while (page != null && page.getPageWorkflows() != null
&& page.getPageWorkflows().size() > 0) {
LOG.log(Level.INFO,
"Cleaning workflow instances: page: [" + page.getPageNum() + "] of ["
+ page.getTotalPages() + "]: page size: [" + page.getPageSize()
+ "]");
for (WorkflowInstance inst : (List<WorkflowInstance>) page
.getPageWorkflows()) {
if (inst.getStatus().equals(WorkflowStatus.CREATED)
|| inst.getStatus().equals(WorkflowStatus.STARTED)
|| inst.getStatus().equals(WorkflowStatus.QUEUED)
|| inst.getStatus().equals(WorkflowStatus.RESMGR_SUBMIT)
|| inst.getStatus().equals(CONF_FILE_BUILD)
|| inst.getStatus().equals(CRAWLING)
|| inst.getStatus().equals(RUNNING_PGE)
|| inst.getStatus().equals(STAGING_INPUT)) {
String endDateTimeIsoStr = DateUtils.toString(Calendar.getInstance());
LOG.log(Level.INFO, "Updated workflow instance id: [" + inst.getId()
+ "]: setting end date time to: [" + endDateTimeIsoStr + "]");
LOG.log(Level.INFO, "Existing status: [" + inst.getStatus()
+ "]: setting to [" + WorkflowStatus.FINISHED + "]");
inst.setEndDateTimeIsoStr(endDateTimeIsoStr);
if (inst.getStartDateTimeIsoStr() == null
|| (inst.getStartDateTimeIsoStr() != null && inst
.getStartDateTimeIsoStr().equals(""))) {
inst.setStartDateTimeIsoStr(endDateTimeIsoStr);
}
inst.setStatus(WorkflowStatus.FINISHED);
if (wm != null) {
wm.updateWorkflowInstance(inst);
} else {
rep.updateWorkflowInstance(inst);
}
}
}
if (page.isLastPage()) {
LOG.log(Level.INFO, "Last set of workflow instances cleaned.");
break;
}
page = wm != null ? wm.getNextPage(page) : rep.getNextPage(page);