本文整理匯總了Java中me.kafeitu.activiti.chapter7.entity.Leave類的典型用法代碼示例。如果您正苦於以下問題:Java Leave類的具體用法?Java Leave怎麽用?Java Leave使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Leave類屬於me.kafeitu.activiti.chapter7.entity包,在下文中一共展示了Leave類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: startWorkflow
import me.kafeitu.activiti.chapter7.entity.Leave; //導入依賴的package包/類
/**
* 保存請假實體並啟動流程
*/
public ProcessInstance startWorkflow(Leave entity, String userId, Map<String, Object> variables) {
if (entity.getId() == null) {
entity.setApplyTime(new Date());
entity.setUserId(userId);
}
leaveManager.save(entity);
String businessKey = entity.getId().toString();
// 用來設置啟動流程的人員ID,引擎會自動把用戶ID保存到activiti:initiator中
identityService.setAuthenticatedUserId(userId);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("leave", businessKey, variables);
String processInstanceId = processInstance.getId();
entity.setProcessInstanceId(processInstanceId);
logger.debug("start process of {key={}, bkey={}, pid={}, variables={}}", new Object[]{"leave", businessKey, processInstanceId, variables});
leaveManager.save(entity);
return processInstance;
}
示例2: taskList
import me.kafeitu.activiti.chapter7.entity.Leave; //導入依賴的package包/類
/**
* 任務列表
*
* @param leave
*/
@RequestMapping(value = "task/list")
public ModelAndView taskList(HttpSession session) {
ModelAndView mav = new ModelAndView("/chapter7/leave/leave-task-list");
String userId = UserUtil.getUserFromSession(session).getId();
List<Leave> results = leaveService.findTodoTasks(userId);
mav.addObject("records", results);
return mav;
}
示例3: findTodoTasks
import me.kafeitu.activiti.chapter7.entity.Leave; //導入依賴的package包/類
/**
* 查詢待辦任務
*/
@Transactional(readOnly = true)
public List<Leave> findTodoTasks(String userId) {
List<Leave> results = new ArrayList<Leave>();
List<Task> tasks = new ArrayList<Task>();
// 根據當前人的ID查詢
List<Task> todoList = taskService.createTaskQuery().processDefinitionKey("leave").taskAssignee(userId).active().list();
// 根據當前人未簽收的任務
List<Task> unsignedTasks = taskService.createTaskQuery().processDefinitionKey("leave").taskCandidateUser(userId).active().list();
// 合並
tasks.addAll(todoList);
tasks.addAll(unsignedTasks);
// 根據流程的業務ID查詢實體並關聯
for (Task task : tasks) {
String processInstanceId = task.getProcessInstanceId();
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
String businessKey = processInstance.getBusinessKey();
Leave leave = leaveManager.get(new Long(businessKey));
leave.setTask(task);
leave.setProcessInstance(processInstance);
String processDefinitionId = processInstance.getProcessDefinitionId();
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionId).singleResult();
leave.setProcessDefinition(processDefinition);
results.add(leave);
}
return results;
}
示例4: findTodoTasks
import me.kafeitu.activiti.chapter7.entity.Leave; //導入依賴的package包/類
/**
* 查詢待辦任務
*/
@Transactional(readOnly = true)
public List<Leave> findTodoTasks(String userId) {
List<Leave> results = new ArrayList<Leave>();
List<Task> tasks = new ArrayList<Task>();
// 根據當前人的ID查詢
List<Task> todoList = taskService.createTaskQuery().processDefinitionKey("leave").taskAssignee(userId).list();
// 根據當前人未簽收的任務
List<Task> unsignedTasks = taskService.createTaskQuery().processDefinitionKey("leave").taskCandidateUser(userId).list();
// 合並
tasks.addAll(todoList);
tasks.addAll(unsignedTasks);
// 根據流程的業務ID查詢實體並關聯
for (Task task : tasks) {
String processInstanceId = task.getProcessInstanceId();
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
String businessKey = processInstance.getBusinessKey();
Leave leave = leaveManager.get(new Long(businessKey));
leave.setTask(task);
leave.setProcessInstance(processInstance);
String processDefinitionId = processInstance.getProcessDefinitionId();
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionId).singleResult();
leave.setProcessDefinition(processDefinition);
results.add(leave);
}
return results;
}
示例5: showTaskView
import me.kafeitu.activiti.chapter7.entity.Leave; //導入依賴的package包/類
/**
* 任務列表
*
* @param leave
*/
@RequestMapping(value = "task/view/{taskId}")
public ModelAndView showTaskView(@PathVariable("taskId") String taskId) {
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
String processInstanceId = task.getProcessInstanceId();
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
Leave leave = leaveManager.get(new Long(processInstance.getBusinessKey()));
ModelAndView mav = new ModelAndView("/chapter7/leave/task-" + task.getTaskDefinitionKey());
mav.addObject("leave", leave);
mav.addObject("task", task);
return mav;
}
示例6: notify
import me.kafeitu.activiti.chapter7.entity.Leave; //導入依賴的package包/類
public void notify(DelegateTask delegateTask) {
Leave leave = leaveManager.get(new Long(delegateTask.getExecution().getProcessBusinessKey()));
Object realityStartTime = delegateTask.getVariable("realityStartTime");
leave.setRealityStartTime((Date) realityStartTime);
Object realityEndTime = delegateTask.getVariable("realityEndTime");
leave.setRealityEndTime((Date) realityEndTime);
leaveManager.save(leave);
}
示例7: getLeave
import me.kafeitu.activiti.chapter7.entity.Leave; //導入依賴的package包/類
/**
* 自動綁定頁麵字段
*/
@ModelAttribute("preloadLeave")
public Leave getLeave(@RequestParam(value = "id", required = false) Long id, HttpSession session) {
if (id != null) {
return leaveManager.get(id);
}
return new Leave();
}