Package org.apache.oodt.cas.workflow.structs

Examples of org.apache.oodt.cas.workflow.structs.WorkflowInstance


        argList.add(wInstId);

        try {
            Hashtable workflowInstance = (Hashtable) client.execute(
                    "workflowmgr.getWorkflowInstanceById", argList);
            WorkflowInstance wInst = XmlRpcStructFactory
                    .getWorkflowInstanceFromXmlRpc(workflowInstance);
            return wInst;
        } catch (XmlRpcException e) {
            e.printStackTrace();
            throw new Exception(e.getMessage());
View Full Code Here


                    "workflowmgr.getWorkflowInstancesByStatus", argList);
            if (insts != null) {
                instsUnpacked = new Vector(insts.size());
                for (Iterator i = insts.iterator(); i.hasNext();) {
                    Hashtable hWinst = (Hashtable) i.next();
                    WorkflowInstance inst = XmlRpcStructFactory
                            .getWorkflowInstanceFromXmlRpc(hWinst);
                    instsUnpacked.add(inst);
                }
                return instsUnpacked;
            } else
View Full Code Here

                    argList);
            if (insts != null) {
                instsUnpacked = new Vector(insts.size());
                for (Iterator i = insts.iterator(); i.hasNext();) {
                    Hashtable hWinst = (Hashtable) i.next();
                    WorkflowInstance inst = XmlRpcStructFactory
                            .getWorkflowInstanceFromXmlRpc(hWinst);
                    instsUnpacked.add(inst);
                }
                return instsUnpacked;
            } else
View Full Code Here

            try {
                insts = client.getWorkflowInstances();

                if (insts != null) {
                    for (Iterator i = insts.iterator(); i.hasNext();) {
                        WorkflowInstance inst = (WorkflowInstance) i.next();
                        System.out
                                .println("Instance: [id="
                                        + inst.getId()
                                        + ", status="
                                        + inst.getStatus()
                                        + ", currentTask="
                                        + inst.getCurrentTaskId()
                                        + ", workflow="
                                        + inst.getWorkflow().getName()
                                        + ",wallClockTime="
                                        + client
                                                .getWorkflowWallClockMinutes(inst
                                                        .getId())
                                        + ",currentTaskWallClockTime="
                                        + client
                                                .getWorkflowCurrentTaskWallClockMinutes(inst
                                                        .getId()) + "]");
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
                throw new RuntimeException(e);
            }
        } else if (operation.equals("--stopWorkflowInst")) {
            XmlRpcWorkflowManagerClient client = new XmlRpcWorkflowManagerClient(
                    new URL(url));

            String workflowInstId = null;

            for (int i = 4; i < args.length; i++) {
                if (args[i].equals("--id")) {
                    workflowInstId = args[++i];
                }
            }

            try {
                boolean stopped = client.stopWorkflowInstance(workflowInstId);
                if (stopped) {
                    System.out.println("Successfully stopped workflow: ["
                            + workflowInstId + "]");
                }
            } catch (Exception e) {
                throw new RuntimeException(e.getMessage());
            }

        } else if (operation.equals("--pauseWorkflowInst")) {
            XmlRpcWorkflowManagerClient client = new XmlRpcWorkflowManagerClient(
                    new URL(url));

            String workflowInstId = null;

            for (int i = 4; i < args.length; i++) {
                if (args[i].equals("--id")) {
                    workflowInstId = args[++i];
                }
            }

            try {
                boolean paused = client.pauseWorkflowInstance(workflowInstId);
                if (paused) {
                    System.out.println("Successfully paused workflow: ["
                            + workflowInstId + "]");
                }
            } catch (Exception e) {
                throw new RuntimeException(e.getMessage());
            }

        } else if (operation.equals("--resumeWorkflowInst")) {
            XmlRpcWorkflowManagerClient client = new XmlRpcWorkflowManagerClient(
                    new URL(url));

            String workflowInstId = null;

            for (int i = 4; i < args.length; i++) {
                if (args[i].equals("--id")) {
                    workflowInstId = args[++i];
                }
            }

            try {
                boolean resumed = client.resumeWorkflowInstance(workflowInstId);
                if (resumed) {
                    System.out.println("Successfully resumed workflow: ["
                            + workflowInstId + "]");
                }
            } catch (Exception e) {
                throw new RuntimeException(e.getMessage());
            }

        }

        else if (operation.equals("--getTaskWallClockTime")) {
            XmlRpcWorkflowManagerClient client = new XmlRpcWorkflowManagerClient(
                    new URL(url));

            String workflowInstId = null;

            for (int i = 4; i < args.length; i++) {
                if (args[i].equals("--id")) {
                    workflowInstId = args[++i];
                }
            }

            try {
                double wallClockTime = client
                        .getWorkflowCurrentTaskWallClockMinutes(workflowInstId);
                System.out.println(wallClockTime + " minutes");
            } catch (Exception e) {
                throw new RuntimeException(e.getMessage());
            }

        } else if (operation.equals("--getWallClockTime")) {
            XmlRpcWorkflowManagerClient client = new XmlRpcWorkflowManagerClient(
                    new URL(url));

            String workflowInstId = null;

            for (int i = 4; i < args.length; i++) {
                if (args[i].equals("--id")) {
                    workflowInstId = args[++i];
                }
            }

            try {
                double wallClockTime = client
                        .getWorkflowWallClockMinutes(workflowInstId);
                System.out.println(wallClockTime + " minutes");
            } catch (Exception e) {
                throw new RuntimeException(e.getMessage());
            }

        }

        else if (operation.equals("--getFirstPage")) {
            XmlRpcWorkflowManagerClient client = new XmlRpcWorkflowManagerClient(
                    new URL(url));

            WorkflowInstancePage page = null;
            String status = null;

            for (int i = 4; i < args.length; i++) {
                if (args[i].equals("--status")) {
                    status = args[++i];
                }
            }

            try {
                if (status != null && !status.equals("")) {
                    page = client.paginateWorkflowInstances(1, status);
                } else {
                    page = client.getFirstPage();
                }

                System.out.println("Page: [num=" + page.getPageNum() + ","
                        + "pageSize=" + page.getPageSize() + ",totalPages="
                        + page.getTotalPages() + "]");
                if (page.getPageWorkflows() != null
                        && page.getPageWorkflows().size() > 0) {
                    for (Iterator i = page.getPageWorkflows().iterator(); i
                            .hasNext();) {
                        WorkflowInstance inst = (WorkflowInstance) i.next();
                        System.out
                                .println("Instance: [id="
                                        + inst.getId()
                                        + ", status="
                                        + inst.getStatus()
                                        + ", currentTask="
                                        + inst.getCurrentTaskId()
                                        + ", workflow="
                                        + inst.getWorkflow().getName()
                                        + ",wallClockTime="
                                        + client
                                                .getWorkflowWallClockMinutes(inst
                                                        .getId())
                                        + ",currentTaskWallClockTime="
                                        + client
                                                .getWorkflowCurrentTaskWallClockMinutes(inst
                                                        .getId()) + "]");
                    }
                }

            } catch (Exception e) {
                throw new RuntimeException(e);
            }

        } else if (operation.equals("--getLastPage")) {
            XmlRpcWorkflowManagerClient client = new XmlRpcWorkflowManagerClient(
                    new URL(url));

            WorkflowInstancePage page = null;
            String status = null;

            for (int i = 4; i < args.length; i++) {
                if (args[i].equals("--status")) {
                    status = args[++i];
                }
            }

            try {
                if (status != null && !status.equals("")) {
                    WorkflowInstancePage firstPage = client
                            .paginateWorkflowInstances(1, status);
                    page = client.paginateWorkflowInstances(firstPage
                            .getTotalPages(), status);
                } else {
                    page = client.getLastPage();
                }

                System.out.println("Page: [num=" + page.getPageNum() + ","
                        + "pageSize=" + page.getPageSize() + ",totalPages="
                        + page.getTotalPages() + "]");
                if (page.getPageWorkflows() != null
                        && page.getPageWorkflows().size() > 0) {
                    for (Iterator i = page.getPageWorkflows().iterator(); i
                            .hasNext();) {
                        WorkflowInstance inst = (WorkflowInstance) i.next();
                        System.out
                                .println("Instance: [id="
                                        + inst.getId()
                                        + ", status="
                                        + inst.getStatus()
                                        + ", currentTask="
                                        + inst.getCurrentTaskId()
                                        + ", workflow="
                                        + inst.getWorkflow().getName()
                                        + ",wallClockTime="
                                        + client
                                                .getWorkflowWallClockMinutes(inst
                                                        .getId())
                                        + ",currentTaskWallClockTime="
                                        + client
                                                .getWorkflowCurrentTaskWallClockMinutes(inst
                                                        .getId()) + "]");
                    }
                }

            } catch (Exception e) {
                throw new RuntimeException(e);
            }

        } else if (operation.equals("--getNextPage")) {
            XmlRpcWorkflowManagerClient client = new XmlRpcWorkflowManagerClient(
                    new URL(url));

            WorkflowInstancePage page = null;
            String status = null;
            int pageNum = -1;

            for (int i = 4; i < args.length; i++) {
                if (args[i].equals("--status")) {
                    status = args[++i];
                } else if (args[i].equals("--pageNum")) {
                    pageNum = Integer.parseInt(args[++i]);
                }
            }

            if (pageNum == -1) {
                System.err.println(getNextPageOperation);
                System.exit(1);
            }

            try {
                if (status != null && !status.equals("")) {
                    page = client
                            .paginateWorkflowInstances(pageNum + 1, status);
                } else {
                    page = client.paginateWorkflowInstances(pageNum + 1);
                }

                System.out.println("Page: [num=" + page.getPageNum() + ","
                        + "pageSize=" + page.getPageSize() + ",totalPages="
                        + page.getTotalPages() + "]");
                if (page.getPageWorkflows() != null
                        && page.getPageWorkflows().size() > 0) {
                    for (Iterator i = page.getPageWorkflows().iterator(); i
                            .hasNext();) {
                        WorkflowInstance inst = (WorkflowInstance) i.next();
                        System.out
                                .println("Instance: [id="
                                        + inst.getId()
                                        + ", status="
                                        + inst.getStatus()
                                        + ", currentTask="
                                        + inst.getCurrentTaskId()
                                        + ", workflow="
                                        + inst.getWorkflow().getName()
                                        + ",wallClockTime="
                                        + client
                                                .getWorkflowWallClockMinutes(inst
                                                        .getId())
                                        + ",currentTaskWallClockTime="
                                        + client
                                                .getWorkflowCurrentTaskWallClockMinutes(inst
                                                        .getId()) + "]");
                    }
                }

            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        } else if (operation.equals("--getPrevPage")) {
            XmlRpcWorkflowManagerClient client = new XmlRpcWorkflowManagerClient(
                    new URL(url));

            WorkflowInstancePage page = null;
            String status = null;
            int pageNum = -1;

            for (int i = 4; i < args.length; i++) {
                if (args[i].equals("--status")) {
                    status = args[++i];
                } else if (args[i].equals("--pageNum")) {
                    pageNum = Integer.parseInt(args[++i]);
                }
            }

            if (pageNum == -1) {
                System.err.println(getPrevPageOperation);
                System.exit(1);
            }

            try {
                if (status != null && !status.equals("")) {
                    page = client
                            .paginateWorkflowInstances(pageNum - 1, status);
                } else {
                    page = client.paginateWorkflowInstances(pageNum - 1);
                }

                System.out.println("Page: [num=" + page.getPageNum() + ","
                        + "pageSize=" + page.getPageSize() + ",totalPages="
                        + page.getTotalPages() + "]");
                if (page.getPageWorkflows() != null
                        && page.getPageWorkflows().size() > 0) {
                    for (Iterator i = page.getPageWorkflows().iterator(); i
                            .hasNext();) {
                        WorkflowInstance inst = (WorkflowInstance) i.next();
                        System.out
                                .println("Instance: [id="
                                        + inst.getId()
                                        + ", status="
                                        + inst.getStatus()
                                        + ", currentTask="
                                        + inst.getCurrentTaskId()
                                        + ", workflow="
                                        + inst.getWorkflow().getName()
                                        + ",wallClockTime="
                                        + client
                                                .getWorkflowWallClockMinutes(inst
                                                        .getId())
                                        + ",currentTaskWallClockTime="
                                        + client
                                                .getWorkflowCurrentTaskWallClockMinutes(inst
                                                        .getId()) + "]");
                    }
                }

            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }

        else if (operation.equals("--getWorkflowInst")) {
            XmlRpcWorkflowManagerClient client = new XmlRpcWorkflowManagerClient(
                    new URL(url));

            WorkflowInstance inst = null;

            String wInstId = null;

            for (int i = 4; i < args.length; i++) {
                if (args[i].equals("--id")) {
                    wInstId = args[++i];
                }
            }

            try {
                inst = client.getWorkflowInstanceById(wInstId);
                if (inst != null) {
                    System.out
                            .println("Instance: [id="
                                    + inst.getId()
                                    + ", status="
                                    + inst.getStatus()
                                    + ", currentTask="
                                    + inst.getCurrentTaskId()
                                    + ", workflow="
                                    + inst.getWorkflow().getName()
                                    + ",wallClockTime="
                                    + client.getWorkflowWallClockMinutes(inst
                                            .getId())
                                    + ",currentTaskWallClockTime="
                                    + client
                                            .getWorkflowCurrentTaskWallClockMinutes(inst
                                                    .getId()) + "]");
                }
            } catch (Exception e) {
                e.printStackTrace();
                throw new RuntimeException(e.getMessage());
View Full Code Here

            return false;
    }

    public Hashtable getWorkflowInstanceById(String wInstId)
            throws EngineException {
        WorkflowInstance inst = null;

        try {
            inst = engine.getInstanceRepository().getWorkflowInstanceById(
                    wInstId);
        } catch (Exception e) {
            e.printStackTrace();
            LOG.log(Level.WARNING,
                    "Error obtaining workflow instance with ID: [" + wInstId
                            + "]: Message: " + e.getMessage());
            inst = new WorkflowInstance();
        }

        return XmlRpcStructFactory.getXmlRpcWorkflowInstance(inst);

    }
View Full Code Here

                    "Getting workflow instances by status: retrieved: "
                            + workflowInsts.size() + " instances");

            try {
                for (Iterator i = workflowInsts.iterator(); i.hasNext();) {
                    WorkflowInstance wInst = (WorkflowInstance) i.next();
                    // pick up the description of the workflow
                    Workflow wDesc = repo.getWorkflowById(wInst.getWorkflow()
                            .getId());
                    // TODO: hack for now, fix this, we shouldn't have to cast
                    // here, bad
                    // design
                    wInst.setWorkflow(wDesc);
                    Hashtable workflowInstance = XmlRpcStructFactory
                            .getXmlRpcWorkflowInstance(wInst);
                    workflowInstances.add(workflowInstance);
                }
            } catch (Exception e) {
View Full Code Here

            LOG.log(Level.INFO, "Getting workflow instances: retrieved: "
                    + workflowInsts.size() + " instances");

            try {
                for (Iterator i = workflowInsts.iterator(); i.hasNext();) {
                    WorkflowInstance wInst = (WorkflowInstance) i.next();
                    // pick up the description of the workflow
                    Workflow wDesc = repo.getWorkflowById(wInst.getWorkflow()
                            .getId());
                    // TODO: hack for now, fix this, we shouldn't have to cast
                    // here, bad
                    // design
                    wInst.setWorkflow(wDesc);
                    Hashtable workflowInstance = XmlRpcStructFactory
                            .getXmlRpcWorkflowInstance(wInst);
                    workflowInstances.add(workflowInstance);
                }
                return workflowInstances;
View Full Code Here

        LogManager.getLogManager().getLogger("").setLevel(Level.SEVERE);
    }

    public void testCurrentTaskWallClockTime() {
        // at first, there is no start date time
        WorkflowInstance inst = new WorkflowInstance();
        assertEquals(Double.valueOf(0.0), Double
                .valueOf(ThreadPoolWorkflowEngine
                        .getCurrentTaskWallClockMinutes(inst)));

        // now set start date time, and assert that wall clock minutes > 0
        inst.setCurrentTaskStartDateTimeIsoStr(DateConvert
                .isoFormat(new Date()));
        assertTrue(ThreadPoolWorkflowEngine
                .getCurrentTaskWallClockMinutes(inst) > 0.0);

        // set end date time to "" and make sure wall clock mins still greater
        // than 0
        inst.setCurrentTaskEndDateTimeIsoStr("");
        assertTrue(ThreadPoolWorkflowEngine
                .getCurrentTaskWallClockMinutes(inst) > 0.0);

        // set the end date time, compute it, and make sure it stays the same
        String endDateTimeIsoStr = DateConvert.isoFormat(new Date());
        inst.setCurrentTaskEndDateTimeIsoStr(endDateTimeIsoStr);
        double wallClockMins = ThreadPoolWorkflowEngine
                .getCurrentTaskWallClockMinutes(inst);
        assertEquals(Double.valueOf(wallClockMins), Double
                .valueOf(ThreadPoolWorkflowEngine
                        .getCurrentTaskWallClockMinutes(inst)));
        assertEquals(Double.valueOf(wallClockMins), Double
                .valueOf(ThreadPoolWorkflowEngine
                        .getCurrentTaskWallClockMinutes(inst)));

        // set the start date time after the end date time
        // make sure that the wall cock time is 0.0
        inst.setCurrentTaskStartDateTimeIsoStr(DateConvert
                .isoFormat(new Date()));
        assertEquals(Double.valueOf(0.0), Double
                .valueOf(ThreadPoolWorkflowEngine
                        .getCurrentTaskWallClockMinutes(inst)));
View Full Code Here

        met.addMetadata(metadata);
        return this.engine.updateMetadata(workflowInstId, met);
    }

    public synchronized boolean updateWorkflowInstance(Hashtable workflowInst) {
        WorkflowInstance wInst = XmlRpcStructFactory
                .getWorkflowInstanceFromXmlRpc(workflowInst);
        return doUpdateWorkflowInstance(wInst);

    }
View Full Code Here

    }

    public synchronized boolean setWorkflowInstanceCurrentTaskStartDateTime(
            String wInstId, String startDateTimeIsoStr) {
        WorkflowInstance wInst = null;
        try {
            wInst = this.engine.getInstanceRepository()
                    .getWorkflowInstanceById(wInstId);
        } catch (InstanceRepositoryException e) {
            e.printStackTrace();
            return false;
        }
        wInst.setCurrentTaskStartDateTimeIsoStr(startDateTimeIsoStr);
        return doUpdateWorkflowInstance(wInst);
    }
View Full Code Here

TOP

Related Classes of org.apache.oodt.cas.workflow.structs.WorkflowInstance

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.