use of com.qlangtech.tis.workflow.dao.IWorkFlowBuildHistoryDAO in project tis by qlangtech.
the class CoreAction method doGetFullBuildHistory.
/**
* 构建全量索引歷史記錄
*
* @param context
* @throws Exception
*/
public void doGetFullBuildHistory(Context context) throws Exception {
Integer wfid = this.getInt("wfid", -1);
boolean getwf = this.getBoolean("getwf");
WorkFlow workFlow = new WorkFlow();
WorkFlowBuildHistoryCriteria query = new WorkFlowBuildHistoryCriteria();
WorkFlowBuildHistoryCriteria.Criteria criteria = query.createCriteria();
if (isCollectionAware()) {
criteria.andAppIdEqualTo(this.getAppDomain().getAppid());
} else {
if (wfid < 0) {
throw new IllegalArgumentException("param wfid can not small than 0");
}
criteria.andWorkFlowIdEqualTo(wfid);
workFlow = new WorkFlow();
if (getwf) {
workFlow = this.getWorkflowDAOFacade().getWorkFlowDAO().selectByPrimaryKey(wfid);
if (workFlow == null) {
throw new IllegalStateException("can not find workflow in db ,wfid:" + wfid);
}
}
}
query.setOrderByClause("id desc");
IWorkFlowBuildHistoryDAO historyDAO = this.getWorkflowDAOFacade().getWorkFlowBuildHistoryDAO();
Pager pager = this.createPager();
pager.setTotalCount(historyDAO.countByExample(query));
this.setBizResult(context, new PaginationResult(pager, adapterBuildHistory(historyDAO.selectByExample(query, pager.getCurPage(), pager.getRowsPerPage())), workFlow.getName()));
}
use of com.qlangtech.tis.workflow.dao.IWorkFlowBuildHistoryDAO in project tis by qlangtech.
the class CoreAction method doCancelTask.
/**
* 终止正在执行的任务
*
* @param context
* @throws Exception
*/
@Func(value = PermissionConstant.APP_UPDATE)
public void doCancelTask(Context context) throws Exception {
Integer taskId = this.getInt(IExecChainContext.KEY_TASK_ID);
IWorkFlowBuildHistoryDAO workFlowBuildDAO = this.getWorkflowDAOFacade().getWorkFlowBuildHistoryDAO();
WorkFlowBuildHistory buildHistory = workFlowBuildDAO.loadFromWriteDB(taskId);
ExecResult processState = ExecResult.parse(buildHistory.getState());
if (!processState.isProcessing()) {
this.addErrorMessage(context, "当前任务状态为已终止,不能执行终止操作");
return;
}
List<ConfigFileContext.Header> headers = Lists.newArrayList();
headers.add(new ConfigFileContext.Header(IExecChainContext.KEY_TASK_ID, String.valueOf(taskId)));
headers.add(new ConfigFileContext.Header(IParamContext.KEY_ASYN_JOB_NAME, String.valueOf(processState == ExecResult.ASYN_DOING)));
headers.add(new ConfigFileContext.Header(IFullBuildContext.KEY_APP_NAME, IAppSourcePipelineController.DATAX_FULL_PIPELINE + buildHistory.getAppName()));
TriggerBuildResult triggerResult = CoreAction.triggerBuild(this, context, ConfigFileContext.HTTPMethod.DELETE, Collections.emptyList(), headers);
if (!triggerResult.success) {
return;
}
WorkFlowBuildHistory record = new WorkFlowBuildHistory();
record.setState((byte) ExecResult.CANCEL.getValue());
WorkFlowBuildHistoryCriteria criteria = new WorkFlowBuildHistoryCriteria();
criteria.createCriteria().andIdEqualTo(triggerResult.getTaskid());
workFlowBuildDAO.updateByExampleSelective(record, criteria);
this.addActionMessage(context, "已经成功终止当前任务");
this.setBizResult(context, new ExtendWorkFlowBuildHistory(this.getWorkflowDAOFacade().getWorkFlowBuildHistoryDAO().loadFromWriteDB(triggerResult.getTaskid())));
}
Aggregations