Package cn.com.manager.domains

Examples of cn.com.manager.domains.Task


            Process nodeProcess = ProcessFactory.getProcess(nodeName);
            if (!(nodeProcess instanceof InitiationProcess)) {
                throw new AppException("E1200000", nodeName);
            }
            // 创建任务
            Task task = ((InitiationProcess) nodeProcess).createTask();
            processData.setTask(task);
            //任务注册到缓存中
            TasksController.registTask(task);
            returnValue = nodeProcess.execute(processData);
        } catch (AppException ex) {
View Full Code Here


     * @param data 数据
     *
     * @return
     */
    public static <T> List<Result> approveProcess(String taskId, T data) {
        Task task = TasksController.getTask(taskId);
        ProcessNode node = task.getProcessNode();
        List<Result> rs = new ArrayList<Result>(3);
        String returnedValue = null;
        Throwable exception = null;
        ProcessData datas = new ProcessData(task, data);
        String nodeName = null;
        do {
            try {
                if (node != null) {
                    nodeName = node.getNodeName();
                    //节点处理类
                    Process nodeProcess = ProcessFactory.getProcess(nodeName);
                    returnedValue = nodeProcess.execute(datas);
                }
                node = task.getProcessNode();
            } catch (AppException ex) {
                exception = ex;
                node = null;
            }
            rs.add(new Result(returnedValue, nodeName, taskId, exception));
View Full Code Here

*/
public abstract class AbstractProcess implements Process {

    @Override
    public String execute(ProcessData datas) throws AppException {
        Task task = datas.getTask();
        String result = null;
        boolean capured = false;
        try {
            capured = task.tryLock();
            if (!capured) {
                throw new AppException("E1200001",task.getTaskid());
            }
            //业务处理
            result = this.process(datas.getData());
            //生成子任务
            if (this instanceof InitationSubProcess) {
                List<Task> subTasks = ((InitationSubProcess) this).createSubTask(task);
                for (Task sub : subTasks) {
                    TasksController.registTask(sub);
                }
            }
            //任务流转
            task.getStatemanager().change();
            //获取父任务的监听器
            if (task.getParentTask() != null) {
                if (!TaskStateManager._STATUS_END.equalsIgnoreCase(task.getParentTask().getStatus())) {
                    TaskListener listener = task.getParentTask().getListener();
                    if (listener != null) {
                        listener.listen(task.getParentTask());
                    }
                } else {
                    task.setParentTask(null);
                }
            }
            return result;
        } finally {
            if (capured) {
                task.unLock();
            }
        }

    }
View Full Code Here

    @Override
    public List<Task> createSubTask(Task parentTask) {
        //根据规则 产生子任务
        List<Task> subTasks = new ArrayList<Task>();
        Task task1 = new Task();
        Task task2 = new Task();
        task1.setTaskid("sub1");
        task1.setNode("sub");
        task1.setParentTask(parentTask);
        task2.setTaskid("sub2");
        task2.setNode("sub");
        task2.setParentTask(parentTask);
        subTasks.add(task1);
        subTasks.add(task2);
        //添加对子任务的监听
        TaskListener testTaskListener = new TestTaskListener(subTasks);
        parentTask.setListener(testTaskListener);
View Full Code Here

        InitiationTaskInfo.init();
//        Asn asn = OperatFactory.getServiceObject(ReceiptModules.class).queryAsn("123456");
            //初始化 收货
//            ProcessWrapper.InitProcess("receipt", asn);
            //得到任务
            Task task =TasksController.getTask("test data");
           
            //质检
//            ProcessWrapper.approveProcess(task.getTaskid(), asn);
           
//            System.out.println("=====:"+TasksController.getTask(task.getTaskid()).getStatus());
//            System.out.println(System.getProperty("file.encoding"));
            System.out.println("====================");
            Task sub1 = TasksController.getTask("sub1");
            Task sub2 = TasksController.getTask("sub2");
           
            ProcessWrapper.approveProcess(sub1.getTaskid(), null);
            ProcessWrapper.approveProcess(sub2.getTaskid(), null);
           
            System.out.println("=====:"+TasksController.getTask("sub1"));
    }
View Full Code Here

            LIElementTag liElement = null;
            LinkElementTag linkElement = null;
            String cssClass = _BLANK_CSS;
            AbstractHtmlElementTag childElement = null;
            int nodeCount = 0;
            Task lastNode = null;
            List<Task> nodeTasks = new ArrayList<Task>(3);
            for (Task m : tasks) {
                if (lastNode == null) {
                    lastNode = m;
                }

                if (!lastNode.getNode().equals(m.getNode())) {

                    liElement = new LIElementTag();
                    linkElement = new LinkElementTag();
                    linkElement.setHref(StringUtil.isEmpty(lastNode.getUrl()) ? _CURRENT_PAGE_HREF : lastNode.getUrl());

                    linkElement.setValue(lastNode.getDisplay() + _CONTENT_HINT_FONT + nodeCount + _CONTENT_HINT_FOOT);
                    linkElement.setCssClass(cssClass);
                    liElement.addChildrenTag(linkElement);
                    childElement = this.createTasksTag(nodeTasks);
                    if (childElement != null) {
                        liElement.addChildrenTag(childElement);
                    }

                    ulElement.addChildrenTag(liElement);
                    nodeCount = 0;
                    nodeTasks.clear();
                    lastNode = m;
                }
                nodeCount++;
                nodeTasks.add(m);

            }
            if (lastNode != null) {

                liElement = new LIElementTag();
                linkElement = new LinkElementTag();
                linkElement.setHref(StringUtil.isEmpty(lastNode.getUrl()) ? _CURRENT_PAGE_HREF : lastNode.getUrl());

                linkElement.setValue(lastNode.getDisplay() + _CONTENT_HINT_FONT + nodeCount + _CONTENT_HINT_FOOT);
                linkElement.setCssClass(cssClass);
                liElement.addChildrenTag(linkElement);
                childElement = this.createTasksTag(nodeTasks);
                if (childElement != null) {
                    liElement.addChildrenTag(childElement);
View Full Code Here

            LIElementTag liElement = null;
            LinkElementTag linkElement = null;
            String cssClass = _BLANK_CSS;
            AbstractHtmlElementTag childElement = null;
            int nodeCount = 0;
            Task lastNode = null;
            List<Task> nodeTasks = new ArrayList<Task>(3);
            for (Task m : tasks) {
                if (lastNode == null) {
                    lastNode = m;
                }

                if (!lastNode.getNode().equals(m.getNode())) {

                    liElement = new LIElementTag();
                    linkElement = new LinkElementTag();
                    linkElement.setHref(StringUtil.isEmpty(lastNode.getUrl()) ? _CURRENT_PAGE_HREF : lastNode.getUrl());

                    linkElement.setValue(lastNode.getDisplay() + _CONTENT_HINT_FONT + nodeCount + _CONTENT_HINT_FOOT);
                    linkElement.setCssClass(cssClass);
                    liElement.addChildrenTag(linkElement);
                    childElement = this.createTasksTag(nodeTasks);
                    if (childElement != null) {
                        liElement.addChildrenTag(childElement);
                    }

                    ulElement.addChildrenTag(liElement);
                    nodeCount = 0;
                    nodeTasks.clear();
                    lastNode = m;
                }
                nodeCount++;
                nodeTasks.add(m);

            }
            if (lastNode != null) {

                liElement = new LIElementTag();
                linkElement = new LinkElementTag();
                linkElement.setHref(StringUtil.isEmpty(lastNode.getUrl()) ? _CURRENT_PAGE_HREF : lastNode.getUrl());

                linkElement.setValue(lastNode.getDisplay() + _CONTENT_HINT_FONT + nodeCount + _CONTENT_HINT_FOOT);
                linkElement.setCssClass(cssClass);
                liElement.addChildrenTag(linkElement);
                childElement = this.createTasksTag(nodeTasks);
                if (childElement != null) {
                    liElement.addChildrenTag(childElement);
View Full Code Here

TOP

Related Classes of cn.com.manager.domains.Task

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.