cn.schoolwow.workflow.service.execute.WorkFlowInstanceServiceImpl Maven / Gradle / Ivy
package cn.schoolwow.workflow.service.execute;
import cn.schoolwow.quickdao.domain.external.PageVo;
import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.workflow.composite.instance.action.RevokeWorkFlowInstanceCompositeBusiness;
import cn.schoolwow.workflow.composite.instance.action.StartWorkFlowCompositeBusiness;
import cn.schoolwow.workflow.composite.instance.query.GetInstanceContextDataFlow;
import cn.schoolwow.workflow.composite.instance.query.GetWorkFlowInstancePagingListFlow;
import cn.schoolwow.workflow.domain.QuickWorkFlowConfig;
import cn.schoolwow.workflow.domain.request.ContextDataRequest;
import cn.schoolwow.workflow.domain.request.StartWorkFlowRequest;
import cn.schoolwow.workflow.domain.request.WorkFlowInstanceQuery;
import cn.schoolwow.workflow.entity.WorkFlowInstance;
import com.alibaba.fastjson.JSONObject;
public class WorkFlowInstanceServiceImpl implements WorkFlowInstanceService {
private QuickWorkFlowConfig quickWorkFlowConfig;
public WorkFlowInstanceServiceImpl(QuickWorkFlowConfig quickWorkFlowConfig) {
this.quickWorkFlowConfig = quickWorkFlowConfig;
}
@Override
public WorkFlowInstance getWorkFlowInstance(WorkFlowInstanceQuery workFlowInstanceQuery) {
PageVo pageVo = getWorkFlowInstancePagingList(workFlowInstanceQuery,1,10);
if(!pageVo.getList().isEmpty()){
return pageVo.getList().get(0);
}
return null;
}
@Override
public PageVo getWorkFlowInstancePagingList(WorkFlowInstanceQuery workFlowInstanceQuery, int pageNumber, int pageSize) {
FlowContext flowContext = quickWorkFlowConfig.workflow.startFlow(new GetWorkFlowInstancePagingListFlow())
.putCurrentCompositeFlowData("workFlowInstanceQuery", workFlowInstanceQuery)
.putCurrentCompositeFlowData("pageNumber", pageNumber)
.putCurrentCompositeFlowData("pageSize", pageSize)
.execute();
PageVo pageVo = (PageVo) flowContext.checkData("pageVo");
return pageVo;
}
@Override
public JSONObject getWorkFlowInstanceContextData(ContextDataRequest contextDataRequest){
FlowContext flowContext = quickWorkFlowConfig.workflow.startFlow(new GetInstanceContextDataFlow())
.putCurrentCompositeFlowData("contextDataRequest", contextDataRequest)
.execute();
JSONObject contextData = (JSONObject) flowContext.getData("contextData");
return contextData;
}
@Override
public WorkFlowInstance startWorkFlow(String name){
StartWorkFlowRequest startWorkFlowRequest = new StartWorkFlowRequest();
startWorkFlowRequest.name = name;
return startWorkFlow(startWorkFlowRequest);
}
@Override
public WorkFlowInstance startWorkFlow(StartWorkFlowRequest startWorkFlowRequest) {
FlowContext flowContext = quickWorkFlowConfig.workflow.startFlow(new StartWorkFlowCompositeBusiness())
.putCurrentCompositeFlowData("startWorkFlowRequest", startWorkFlowRequest)
.execute();
WorkFlowInstance workFlowInstance = (WorkFlowInstance) flowContext.checkData("workFlowInstance");
return workFlowInstance;
}
@Override
public void revokeWorkFlowInstance(long workFlowInstanceId) {
quickWorkFlowConfig.workflow.startFlow(new RevokeWorkFlowInstanceCompositeBusiness())
.putCurrentCompositeFlowData("workFlowInstanceId", workFlowInstanceId)
.execute();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy