Examples of WorkflowInstance


Examples of eu.planets_project.ifr.core.wee.api.workflow.WorkflowInstance

     
      //1) get the WEEManager instance - required in the same JVM
        WeeManager weeManager = WeeManagerImpl.getWeeManagerInstance();
       
      //2) extract the Message's payload 
      WorkflowInstance wf = null;
      UUID uuid = null;
      try {
        TextMessage msg = null;
          if (m instanceof TextMessage) {
              msg = (TextMessage) m;
              log.debug("WorkflowExecutionEngine: received ObjectMessage at timestamp: " + msg.getJMSTimestamp());
          }
          // for ObjectMessages: uuid = UUID.fromString(msg.getStringProperty("UUID"));
          uuid = UUID.fromString(msg.getText());
          /*
           *  WorkflowInstance object cannot be Serialized due to the org.jboss.ws.core.jaxws.client.ClientProxy
           *  it contains that cannot be serialized. Therefore a callback to the weeManager for fetching this object
           *  is performed.
           *  Not possible:  wf = (WorkflowInstance)msg.getObject();
           */
          wf = ((WeeManagerImpl)weeManager).getWorkflowInstance(uuid);
          //for testing poolsize 1
          //Thread.currentThread().sleep(30000);

      } catch (Exception e) {
          log.error("WorkflowExecutionEngine: error receiving message workflow payload or UUID",e);
          if(uuid!=null){
            weeManager.notify(uuid,WorkflowExecutionStatus.FAILED);
          }
          return;
      }
               
       
        //set status for the workflow inISRUNNING
      weeManager.notify(uuid,WorkflowExecutionStatus.RUNNING);

        //3) executeWorkflow and get WF Result
      WorkflowResult ret = wf.initializeExecution();
      try {
        log.debug("WorkflowExecutionEngine: start executing wf ID: " + wf.getWorkflowID());
       
        //EXECUTES THE WF INSTANCE
      List<DigitalObject> payload = wf.getData();
      int count = 1;
      for(DigitalObject digo : payload){
        //process the payload item by item - workflowResult appends individual log items
        ret = wf.execute(digo);
        count+=1;
        int progress = (100/payload.size())*count;
        weeManager.notify(uuid, ret, WorkflowExecutionStatus.RUNNING, progress);
      }
      ret = wf.finalizeExecution();
     
     
      log.debug("WorkflowExecutionEngine: completed executing wf ID: " + wf.getWorkflowID());
    } catch (Exception e) {
      log.error("WorkflowExecutionEngine: error running Workflow.execute()",e);
      //set WeeManagerstatus 'failed'
      weeManager.notify(uuid, WorkflowExecutionStatus.FAILED);
      return;
View Full Code Here

Examples of org.apache.airavata.registry.api.workflow.WorkflowInstance

  }

  @Override
  public boolean saveWorkflowExecutionStatus(String experimentId,
      ExecutionStatus status) throws RegistryException {
    this.status.put(experimentId, new WorkflowInstanceStatus(new WorkflowInstance(experimentId,experimentId),status));
    return true;
  }
View Full Code Here

Examples of org.apache.lenya.workflow.WorkflowInstance

            PageEnvelope envelope = PageEnvelopeFactory.getInstance().getPageEnvelope(objectModel);
            Document document = envelope.getDocument();

            WorkflowFactory factory = WorkflowFactory.newInstance();
            if (factory.hasWorkflow(document)) {
                WorkflowInstance instance = factory.buildInstance(document);
                if (name.equals(STATE)) {
                    value = instance.getCurrentState().toString();
                }
                else if (name.startsWith(VARIABLE_PREFIX)) {
                    String variableName = name.substring(VARIABLE_PREFIX.length());
                    String[] variableNames = instance.getWorkflow().getVariableNames();
                    if (Arrays.asList(variableNames).contains(variableName)) {
                        value = Boolean.valueOf(instance.getValue(variableName));
                    }
                }
                else if (name.equals(HISTORY_PATH)) {
                    value = ((CMSHistory) WorkflowFactory.getHistory(document)).getHistoryPath();
                }
View Full Code Here

Examples of org.apache.lenya.workflow.WorkflowInstance

        Situation situation = factory.buildSituation(emptyRoles, "test", "127.0.0.1");

        WorkflowFactory.initHistory(document, workflowId, situation);

        for (int situationIndex = 0; situationIndex < situations.length; situationIndex++) {
            WorkflowInstance instance = null;
            instance = factory.buildInstance(document);
            assertNotNull(instance);

            System.out.println("Current state: " + instance.getCurrentState());

            Identity identity = new Identity();
            User user =
                getAccreditableManager().getUserManager().getUser(
                    situations[situationIndex].getUser());
            identity.addIdentifiable(user);

            Role[] roles = policy.getRoles(identity);
            System.out.print("Roles:");

            for (int roleIndex = 0; roleIndex < roles.length; roleIndex++) {
                System.out.print(" " + roles[roleIndex]);
            }

            System.out.println();

            situation = null;

            try {
                situation = factory.buildSituation(roles, identity);
            } catch (WorkflowException e1) {
                e1.printStackTrace(System.err);
            }

            Event[] events = instance.getExecutableEvents(situation);

            Event event = null;
            System.out.print("Events:");

            for (int eventIndex = 0; eventIndex < events.length; eventIndex++) {
                System.out.print(" " + events[eventIndex]);

                if (events[eventIndex].getName().equals(situations[situationIndex].getEvent())) {
                    event = events[eventIndex];
                }
            }

            assertNotNull(event);
            System.out.println();

            System.out.println("Executing event: " + event);
            instance.invoke(situation, event);

            assertTrue(instance.getValue(variableName) == situations[situationIndex].getValue());

            System.out.println(
                "Variable: " + variableName + " = " + instance.getValue(variableName));
            System.out.println("------------------------------------------------------");
        }

        System.out.println("Test completed.");
    }
View Full Code Here

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

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

                    "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

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

                    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

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

            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

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

            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

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

                    "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
TOP
Copyright © 2018 www.massapi.com. 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.