當前位置: 首頁>>代碼示例>>Java>>正文


Java UserUtil.getUserFromSession方法代碼示例

本文整理匯總了Java中me.kafeitu.activiti.chapter6.util.UserUtil.getUserFromSession方法的典型用法代碼示例。如果您正苦於以下問題:Java UserUtil.getUserFromSession方法的具體用法?Java UserUtil.getUserFromSession怎麽用?Java UserUtil.getUserFromSession使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在me.kafeitu.activiti.chapter6.util.UserUtil的用法示例。


在下文中一共展示了UserUtil.getUserFromSession方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: todoTasks

import me.kafeitu.activiti.chapter6.util.UserUtil; //導入方法依賴的package包/類
/**
 * 讀取啟動流程的表單字段
 */
@RequestMapping(value = "task/list")
public ModelAndView todoTasks(HttpSession session) throws Exception {
    String viewName = "chapter6/task-list";
    ModelAndView mav = new ModelAndView(viewName);
    User user = UserUtil.getUserFromSession(session);

    /*// 讀取直接分配給當前人或者已經簽收的任務
    List<Task> doingTasks = taskService.createTaskQuery().taskAssignee(user.getId()).list();

    // 等待簽收的任務
    List<Task> waitingClaimTasks = taskService.createTaskQuery().taskCandidateUser(user.getId()).list();

    // 合並兩種任務
    List<Task> allTasks = new ArrayList<Task>();
    allTasks.addAll(doingTasks);
    allTasks.addAll(waitingClaimTasks);*/

    // 5.16版本可以使用一下代碼待辦查詢
    List<Task> allTasks = taskService.createTaskQuery().taskCandidateOrAssigned(user.getId()).list();

    mav.addObject("tasks", allTasks);
    return mav;
}
 
開發者ID:shawn-gogh,項目名稱:myjavacode,代碼行數:27,代碼來源:TaskController.java

示例2: todoTasks

import me.kafeitu.activiti.chapter6.util.UserUtil; //導入方法依賴的package包/類
/**
 * 讀取啟動流程的表單字段
 */
@RequestMapping(value = "task/list")
public ModelAndView todoTasks(HttpSession session) throws Exception {
    String viewName = "chapter6/task-list";
    ModelAndView mav = new ModelAndView(viewName);
    User user = UserUtil.getUserFromSession(session);

    /*// 讀取直接分配給當前人或者已經簽收的任務
    List<Task> doingTasks = taskService.createTaskQuery().taskAssignee(user.getId()).list();

    // 等待簽收的任務
    List<Task> waitingClaimTasks = taskService.createTaskQuery().taskCandidateUser(user.getId()).list();

    // 合並兩種任務
    List<Task> allTasks = new ArrayList<Task>();
    allTasks.addAll(doingTasks);
    allTasks.addAll(waitingClaimTasks);*/

    // 5.16版本可以使用一下代碼待辦查詢
    List<Task> tasks = taskService.createTaskQuery().taskCandidateOrAssigned(user.getId()).list();

    mav.addObject("tasks", tasks);
    return mav;
}
 
開發者ID:shawn-gogh,項目名稱:myjavacode,代碼行數:27,代碼來源:TaskController.java

示例3: todoTasks

import me.kafeitu.activiti.chapter6.util.UserUtil; //導入方法依賴的package包/類
/**
 * 讀取啟動流程的表單字段
 */
@RequestMapping(value = "task/list")
public ModelAndView todoTasks(HttpServletRequest request, @RequestParam(value = "taskName", required = false) String taskName) throws Exception {
    String viewName = "chapter6/task-list";
    ModelAndView mav = new ModelAndView(viewName);

    User user = UserUtil.getUserFromSession(request.getSession());
    Page<Task> page = new Page<Task>(PageUtil.PAGE_SIZE);
    int[] pageParams = PageUtil.init(page, request);

    NativeTaskQuery nativeTaskQuery = taskService.createNativeTaskQuery();

    LeaveJpaEntity leave = leaveEntityManager.getLeave(1l);
    System.out.println(leave);

/*
過濾條件
 */
    String filters = "";
    if (StringUtils.isNotBlank(taskName)) {
        filters += " and RES.NAME_ like #{taskName}";
        nativeTaskQuery.parameter("taskName", "%" + taskName + "%");
        mav.addObject("taskName", taskName);
    }

    // 當前人在候選人或者候選組範圍之內
    String sql = "select distinct RES.* from ACT_RU_TASK RES left join ACT_RU_IDENTITYLINK I on I.TASK_ID_ = RES.ID_ WHERE SUSPENSION_STATE_ = '1' and " +
            " ( RES.ASSIGNEE_ = #{userId}" +
            " or (RES.ASSIGNEE_ is null  and ( I.USER_ID_ = #{userId} or I.GROUP_ID_ IN (select G.GROUP_ID_ from ACT_ID_MEMBERSHIP G where G.USER_ID_ = #{userId} ) )" +
            ") )" + filters + " order by RES.CREATE_TIME_ desc";

    nativeTaskQuery.sql(sql).parameter("userId", user.getId());
    List<Task> tasks = nativeTaskQuery.listPage(pageParams[0], pageParams[1]);

    page.setResult(tasks);
    page.setTotalCount(nativeTaskQuery.sql("select count(*) from (" + sql + ")").count());

    // 從5.16版本開始可以使用以下方式
    /*TaskQuery taskQuery = taskService.createTaskQuery().taskCandidateOrAssigned(user.getId());
    page.setTotalCount(taskQuery.count());
    page.setResult(taskQuery.list());
    mav.addObject("tasks", tasks);*/

    mav.addObject("page", page);

    return mav;
}
 
開發者ID:barudisshu,項目名稱:activiti-in-action-codes,代碼行數:50,代碼來源:TaskController.java

示例4: readStartForm

import me.kafeitu.activiti.chapter6.util.UserUtil; //導入方法依賴的package包/類
/**
 * 讀取啟動流程的表單字段
 */
@RequestMapping(value = "getform/start/{processDefinitionId}")
public ModelAndView readStartForm(@PathVariable("processDefinitionId") String processDefinitionId,
                                  HttpServletRequest request, RedirectAttributes redirectAttributes) throws Exception {
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
            .processDefinitionId(processDefinitionId).singleResult();

    User user = UserUtil.getUserFromSession(request.getSession());
    List<Group> groupList = (List<Group>) request.getSession().getAttribute("groups");

    // 權限攔截
    boolean startable = false;
    List<IdentityLink> identityLinks = repositoryService.getIdentityLinksForProcessDefinition(processDefinition.getId());
    if (identityLinks == null || identityLinks.isEmpty()) {
        startable = true;
    } else {
        for (IdentityLink identityLink : identityLinks) {
            if (StringUtils.isNotBlank(identityLink.getUserId()) && identityLink.getUserId().equals(user.getId())) {
                startable = true;
                break;
            }

            if (StringUtils.isNotBlank(identityLink.getGroupId())) {
                for (Group group : groupList) {
                    if (group.getName().equals(identityLink.getGroupId())) {
                        startable = true;
                        break;
                    }
                }
            }
        }
    }

    if (!startable) {
        redirectAttributes.addFlashAttribute("error", "您無權啟動【" + processDefinition.getName() + "】流程!");
        return new ModelAndView("redirect:/chapter5/process-list-view");
    }

    boolean hasStartFormKey = processDefinition.hasStartFormKey();

    // 根據是否有formkey屬性判斷使用哪個展示層
    String viewName = "chapter6/start-process-form";
    ModelAndView mav = new ModelAndView(viewName);

    // 判斷是否有formkey屬性
    if (hasStartFormKey) {
        Object renderedStartForm = formService.getRenderedStartForm(processDefinitionId);
        mav.addObject("startFormData", renderedStartForm);
        mav.addObject("processDefinition", processDefinition);
    } else { // 動態表單字段
        StartFormData startFormData = formService.getStartFormData(processDefinitionId);
        mav.addObject("startFormData", startFormData);
    }
    mav.addObject("hasStartFormKey", hasStartFormKey);
    mav.addObject("processDefinitionId", processDefinitionId);
    return mav;
}
 
開發者ID:barudisshu,項目名稱:activiti-in-action-codes,代碼行數:60,代碼來源:ProcessDefinitionController.java

示例5: list

import me.kafeitu.activiti.chapter6.util.UserUtil; //導入方法依賴的package包/類
/**
 * 用戶參與過的流程
 *
 * @return
 */
@RequestMapping("execution/list")
public ModelAndView list(HttpServletRequest request) {
    ModelAndView mav = new ModelAndView("chapter13/execution-list");
/* 標準查詢
List<ProcessInstance> processInstanceList = runtimeService.createProcessInstanceQuery().list();
List<Execution> list = runtimeService.createExecutionQuery().list();
mav.addObject("list", list);
*/

    User user = UserUtil.getUserFromSession(request.getSession());
    Page<Execution> page = new Page<Execution>(PageUtil.PAGE_SIZE);
    int[] pageParams = PageUtil.init(page, request);
    NativeExecutionQuery nativeExecutionQuery = runtimeService.createNativeExecutionQuery();

    // native query
    String sql = "select RES.* from ACT_RU_EXECUTION RES left join ACT_HI_TASKINST ART on ART.PROC_INST_ID_ = RES.PROC_INST_ID_ "
            + " where SUSPENSION_STATE_ = '1' and ART.ASSIGNEE_ = #{userId} and ACT_ID_ is not null and IS_ACTIVE_ = 'TRUE' order by START_TIME_ desc";

    nativeExecutionQuery.parameter("userId", user.getId());

    List<Execution> executionList = nativeExecutionQuery.sql(sql).listPage(pageParams[0], pageParams[1]);

    // 查詢流程定義對象
    Map<String, ProcessDefinition> definitionMap = new HashMap<String, ProcessDefinition>();

    // 任務的英文-中文對照
    Map<String, Task> taskMap = new HashMap<String, Task>();

    // 每個Execution的當前活動ID,可能為多個
    Map<String, List<String>> currentActivityMap = new HashMap<String, List<String>>();

    // 設置每個Execution對象的當前活動節點
    for (Execution execution : executionList) {
        ExecutionEntity executionEntity = (ExecutionEntity) execution;
        String processInstanceId = executionEntity.getProcessInstanceId();
        String processDefinitionId = executionEntity.getProcessDefinitionId();

        // 緩存ProcessDefinition對象到Map集合
        definitionCache(definitionMap, processDefinitionId);

        // 查詢當前流程的所有處於活動狀態的活動ID,如果並行的活動則會有多個
        List<String> activeActivityIds = runtimeService.getActiveActivityIds(execution.getId());
        currentActivityMap.put(execution.getId(), activeActivityIds);

        for (String activityId : activeActivityIds) {

            // 查詢處於活動狀態的任務
            Task task = taskService.createTaskQuery().taskDefinitionKey(activityId).executionId(execution.getId()).singleResult();

            // 調用活動
            if (task == null) {
                ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
                        .superProcessInstanceId(processInstanceId).singleResult();
                if (processInstance != null) {
                    task = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).singleResult();
                    definitionCache(definitionMap, processInstance.getProcessDefinitionId());
                }
            }
            taskMap.put(activityId, task);
        }
    }

    mav.addObject("taskMap", taskMap);
    mav.addObject("definitions", definitionMap);
    mav.addObject("currentActivityMap", currentActivityMap);

    page.setResult(executionList);
    page.setTotalCount(nativeExecutionQuery.sql("select count(*) from (" + sql + ")").count());
    mav.addObject("page", page);

    return mav;
}
 
開發者ID:barudisshu,項目名稱:activiti-in-action-codes,代碼行數:78,代碼來源:ExecutionController.java

示例6: list

import me.kafeitu.activiti.chapter6.util.UserUtil; //導入方法依賴的package包/類
/**
 * 用戶參與過的流程
 *
 * @return
 */
@RequestMapping("execution/list")
public ModelAndView list(HttpServletRequest request) {
    ModelAndView mav = new ModelAndView("chapter13/execution-list");
/* 標準查詢
List<ProcessInstance> processInstanceList = runtimeService.createProcessInstanceQuery().list();
List<Execution> list = runtimeService.createExecutionQuery().list();
mav.addObject("list", list);
*/

    User user = UserUtil.getUserFromSession(request.getSession());
    Page<Execution> page = new Page<Execution>(PageUtil.PAGE_SIZE);
    int[] pageParams = PageUtil.init(page, request);
    NativeExecutionQuery nativeExecutionQuery = runtimeService.createNativeExecutionQuery();

    // native query
    String sql = "select distinct * from (select RES.* from ACT_RU_EXECUTION RES left join ACT_HI_TASKINST ART on ART.PROC_INST_ID_ = RES.PROC_INST_ID_ "
            + " left join ACT_HI_PROCINST AHP on AHP.PROC_INST_ID_ = RES.PROC_INST_ID_ "
            + " where SUSPENSION_STATE_ = '1' and (ART.ASSIGNEE_ = #{userId} or AHP.START_USER_ID_ = #{userId}) "
            + " and ACT_ID_ is not null and IS_ACTIVE_ = 'TRUE' order by ART.START_TIME_ desc)";

    nativeExecutionQuery.parameter("userId", user.getId());

    List<Execution> executionList = nativeExecutionQuery.sql(sql).listPage(pageParams[0], pageParams[1]);

    // 查詢流程定義對象
    Map<String, ProcessDefinition> definitionMap = new HashMap<String, ProcessDefinition>();

    // 任務的英文-中文對照
    Map<String, Task> taskMap = new HashMap<String, Task>();

    // 每個Execution的當前活動ID,可能為多個
    Map<String, List<String>> currentActivityMap = new HashMap<String, List<String>>();

    // 設置每個Execution對象的當前活動節點
    for (Execution execution : executionList) {
        ExecutionEntity executionEntity = (ExecutionEntity) execution;
        String processInstanceId = executionEntity.getProcessInstanceId();
        String processDefinitionId = executionEntity.getProcessDefinitionId();

        // 緩存ProcessDefinition對象到Map集合
        definitionCache(definitionMap, processDefinitionId);

        // 查詢當前流程的所有處於活動狀態的活動ID,如果並行的活動則會有多個
        List<String> activeActivityIds = runtimeService.getActiveActivityIds(execution.getId());
        currentActivityMap.put(execution.getId(), activeActivityIds);

        for (String activityId : activeActivityIds) {

            // 查詢處於活動狀態的任務
            Task task = taskService.createTaskQuery().taskDefinitionKey(activityId).executionId(execution.getId()).singleResult();

            // 調用活動
            if (task == null) {
                ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
                        .superProcessInstanceId(processInstanceId).singleResult();
                if (processInstance != null) {
                    task = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).singleResult();
                    definitionCache(definitionMap, processInstance.getProcessDefinitionId());
                }
            }
            taskMap.put(activityId, task);
        }
    }

    mav.addObject("taskMap", taskMap);
    mav.addObject("definitions", definitionMap);
    mav.addObject("currentActivityMap", currentActivityMap);

    page.setResult(executionList);
    page.setTotalCount(nativeExecutionQuery.sql("select count(*) from (" + sql + ")").count());
    mav.addObject("page", page);

    return mav;
}
 
開發者ID:barudisshu,項目名稱:activiti-in-action-codes,代碼行數:80,代碼來源:ExecutionController.java

示例7: todoTasks

import me.kafeitu.activiti.chapter6.util.UserUtil; //導入方法依賴的package包/類
/**
 * 讀取啟動流程的表單字段
 */
@RequestMapping(value = "task/list")
public ModelAndView todoTasks(HttpServletRequest request, @RequestParam(value = "taskName", required = false) String taskName) throws Exception {
    String viewName = "chapter6/task-list";
    ModelAndView mav = new ModelAndView(viewName);

    User user = UserUtil.getUserFromSession(request.getSession());
    Page<Task> page = new Page<Task>(PageUtil.PAGE_SIZE);
    int[] pageParams = PageUtil.init(page, request);

    NativeTaskQuery nativeTaskQuery = taskService.createNativeTaskQuery();

/*
過濾條件
 */
    String filters = "";
    if (StringUtils.isNotBlank(taskName)) {
        filters += " and RES.NAME_ like #{taskName}";
        nativeTaskQuery.parameter("taskName", "%" + taskName + "%");
        mav.addObject("taskName", taskName);
    }

    // 當前人在候選人或者候選組範圍之內
    String sql = "select distinct RES.* from ACT_RU_TASK RES left join ACT_RU_IDENTITYLINK I on I.TASK_ID_ = RES.ID_ WHERE SUSPENSION_STATE_ = '1' and " +
            " ( RES.ASSIGNEE_ = #{userId}" +
            " or (RES.ASSIGNEE_ is null  and ( I.USER_ID_ = #{userId} or I.GROUP_ID_ IN (select G.GROUP_ID_ from ACT_ID_MEMBERSHIP G where G.USER_ID_ = #{userId} ) )" +
            ") )" + filters + " order by RES.CREATE_TIME_ desc";

    nativeTaskQuery.sql(sql).parameter("userId", user.getId());
    List<Task> tasks = nativeTaskQuery.listPage(pageParams[0], pageParams[1]);

    page.setResult(tasks);
    page.setTotalCount(nativeTaskQuery.sql("select count(*) from (" + sql + ")").count());

    // 從5.16版本開始可以使用以下方式
    /*TaskQuery taskQuery = taskService.createTaskQuery().taskCandidateOrAssigned(user.getId());
    page.setTotalCount(taskQuery.count());
    page.setResult(taskQuery.list());
    mav.addObject("tasks", tasks);*/

    mav.addObject("page", page);

    return mav;
}
 
開發者ID:shawn-gogh,項目名稱:myjavacode,代碼行數:47,代碼來源:TaskController.java

示例8: list

import me.kafeitu.activiti.chapter6.util.UserUtil; //導入方法依賴的package包/類
/**
 * 用戶參與過的流程
 *
 * @return
 */
@RequestMapping("execution/list")
public ModelAndView list(HttpServletRequest request) {
    ModelAndView mav = new ModelAndView("chapter13/execution-list");
/* 標準查詢
List<ProcessInstance> processInstanceList = runtimeService.createProcessInstanceQuery().list();
List<Execution> list = runtimeService.createExecutionQuery().list();
mav.addObject("list", list);
*/

    User user = UserUtil.getUserFromSession(request.getSession());
    Page<Execution> page = new Page<Execution>(PageUtil.PAGE_SIZE);
    int[] pageParams = PageUtil.init(page, request);
    NativeExecutionQuery nativeExecutionQuery = runtimeService.createNativeExecutionQuery();

    // native query
    String sql = "select RES.* from ACT_RU_EXECUTION RES left join ACT_HI_TASKINST ART on ART.PROC_INST_ID_ = RES.PROC_INST_ID_ "
            + " where ART.ASSIGNEE_ = #{userId} and ACT_ID_ is not null and IS_ACTIVE_ = 'TRUE' order by START_TIME_ desc";

    nativeExecutionQuery.parameter("userId", user.getId());

    List<Execution> executionList = nativeExecutionQuery.sql(sql).listPage(pageParams[0], pageParams[1]);

    // 查詢流程定義對象
    Map<String, ProcessDefinition> definitionMap = new HashMap<String, ProcessDefinition>();

    // 任務的英文-中文對照
    Map<String, Task> taskMap = new HashMap<String, Task>();

    // 每個Execution的當前活動ID,可能為多個
    Map<String, List<String>> currentActivityMap = new HashMap<String, List<String>>();

    // 設置每個Execution對象的當前活動節點
    for (Execution execution : executionList) {
        ExecutionEntity executionEntity = (ExecutionEntity) execution;
        String processInstanceId = executionEntity.getProcessInstanceId();
        String processDefinitionId = executionEntity.getProcessDefinitionId();

        // 緩存ProcessDefinition對象到Map集合
        definitionCache(definitionMap, processDefinitionId);

        // 查詢當前流程的所有處於活動狀態的活動ID,如果並行的活動則會有多個
        List<String> activeActivityIds = runtimeService.getActiveActivityIds(execution.getId());
        currentActivityMap.put(execution.getId(), activeActivityIds);

        for (String activityId : activeActivityIds) {

            // 查詢處於活動狀態的任務
            Task task = taskService.createTaskQuery().taskDefinitionKey(activityId).executionId(execution.getId()).singleResult();

            // 調用活動
            if (task == null) {
                ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
                        .superProcessInstanceId(processInstanceId).singleResult();
                task = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).singleResult();
                definitionCache(definitionMap, processInstance.getProcessDefinitionId());
            }
            taskMap.put(activityId, task);
        }
    }

    mav.addObject("taskMap", taskMap);
    mav.addObject("definitions", definitionMap);
    mav.addObject("currentActivityMap", currentActivityMap);

    page.setResult(executionList);
    page.setTotalCount(nativeExecutionQuery.sql("select count(*) from (" + sql + ")").count());
    mav.addObject("page", page);

    return mav;
}
 
開發者ID:barudisshu,項目名稱:activiti-in-action-codes,代碼行數:76,代碼來源:ExecutionController.java


注:本文中的me.kafeitu.activiti.chapter6.util.UserUtil.getUserFromSession方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。