Package de.danet.an.workflow.api

Examples of de.danet.an.workflow.api.Process


     */
    public void cleanup () throws Exception {
 
  ProcessDirectory pd = workflowService().processDirectory ();
  for (Iterator i = pd.processes().iterator (); i.hasNext ();) {
      Process proc = (Process)i.next ();
      boolean done = false;
      for (int count = 5; count > 0; count--) {
    try {
        handleProcess (pd, proc);
        done = true;
View Full Code Here


     * Remove selected processes.
     */
    public String removeSelected () throws RemoteException {
        ProcessDirectory procDir = wsc.getWorkflowService().processDirectory();
        for (Iterator i = selectedProcesses.iterator(); i.hasNext();) {
            Process process = (Process)i.next();
            try {
                procDir.removeProcess(process);
            } catch (CannotRemoveException e) {
                // Probably removed by other user
                logger.debug(e.getMessage(), e);
View Full Code Here

     */
    public void createProcess1AndRemoveProcessDef() throws Exception
  ProcessDefinitionDirectory pdd = null;
  try {
      WfRequester cont = new DefaultRequester(workflowService());
      Process process = (Process)createProcess("ut-process", "jut1", cont);
      assertTrue(process.state().startsWith("open.not_running.not_started"));
      process.start();
      assertTrue(process.state().startsWith("open.running"));
      // remove its process definition
      pdd = workflowService().processDefinitionDirectory ();
      ProcessDefinition pd
    = pdd.lookupProcessDefinition("ut-process", "jut1");
      assertTrue(pd!=null);
      pdd.removeProcessDefinition("ut-process", "jut1");
      boolean gotEx = false;
      try {
    pd = pdd.lookupProcessDefinition("ut-process", "jut1");
      } catch (Exception ex) {
    gotEx = true;
      }
      assertTrue(gotEx);
      // check the process definition of the process
      ProcessDefinition procDef = process.processDefinition();
      assertTrue(procDef.packageId().equals("ut-process"));
      assertTrue(procDef.processId().equals("jut1"));
      // import the process definition again.
      importProcessDefinitions();
      pd = pdd.lookupProcessDefinition("ut-process", "jut1");
View Full Code Here

        break;
    }
      }
      Iterator subs = act.performers().iterator ();
      assertTrue (subs.hasNext ());
      Process sub = (Process)subs.next ();
       procDir.removeProcess(sub);
       procDir.removeProcess(process);
  } finally {
            workflowService.release(chan);
      workflowService.release (procDefDir);
View Full Code Here

    /**
     * Create a new process for the given type.
     */
    public void checkFormalParams() throws Exception {
  WfRequester cont = new DefaultRequester(workflowService());
  Process process = (Process)createProcess
      ("subflowtest", "called1", cont);
  FormalParameter[] fps = process.processDefinition().formalParameters();
  assertTrue(fps.length == 2);
  assertTrue(fps[0].id().equals ("testData"));
  assertTrue(fps[1].id().equals ("status"));
    }
View Full Code Here

     */
    public void createProcess1AndRemoveProcessDef() throws Exception
  ProcessDefinitionDirectory pdd = null;
  try {
      WfRequester cont = new DefaultRequester(workflowService());
      Process process = (Process)createProcess("ut-process", "jut1", cont);
      assertTrue(process.state().startsWith("open.not_running.not_started"));
      process.start();
      assertTrue(process.state().startsWith("open.running"));
      // remove its process definition
      pdd = workflowService().processDefinitionDirectory ();
      ProcessDefinition pd
    = pdd.lookupProcessDefinition("ut-process", "jut1");
      assertTrue(pd!=null);
      pdd.removeProcessDefinition("ut-process", "jut1");
      boolean gotEx = false;
      try {
    pd = pdd.lookupProcessDefinition("ut-process", "jut1");
      } catch (Exception ex) {
    gotEx = true;
      }
      assertTrue(gotEx);
      // check the process definition of the process
      ProcessDefinition procDef = process.processDefinition();
      assertTrue(procDef.packageId().equals("ut-process"));
      assertTrue(procDef.processId().equals("jut1"));
      // import the process definition again.
      importProcessDefinitions();
      pd = pdd.lookupProcessDefinition("ut-process", "jut1");
View Full Code Here

     */
    public void createProcessAndRemoveProcessDef() throws Exception
  ProcessDefinitionDirectory pdd = null;
  try {
      WfRequester cont = new DefaultRequester(workflowService());
      Process process = (Process)createProcess("N1", "N2", cont);
      process.start();
      Thread.sleep(5000);

      // get processdata
      ProcessData data = process.processContext();
      Object value = data.get("result");
      if (value != null) {
    SAXEventBufferImpl myBuffer
        = (SAXEventBufferImpl)value;
    TransformerFactory tf
        = TransformerFactory.newInstance();
    SAXTransformerFactory saxTransFact = null;
    if (tf.getFeature(SAXTransformerFactory.FEATURE)) {
        saxTransFact = (SAXTransformerFactory)tf;
    }
    TransformerHandler transHand = null;
      transHand = saxTransFact.newTransformerHandler();
      StreamResult streamResult = new StreamResult
          (new java.io.ByteArrayOutputStream());
      transHand.setResult(streamResult);
      myBuffer.emit(transHand);
     System.out.println(streamResult.getOutputStream().toString());

    DOMResult domResult = new DOMResult();
    transHand = saxTransFact.newTransformerHandler();
    transHand.setResult(domResult);
    myBuffer.emit(transHand);
    Element returnResult = ((Document)domResult.getNode())
        .getDocumentElement();

    XPath xpath = new DOMXPath("/BLUB/root/element1");
    Element element1
        = (Element)xpath.selectSingleNode(returnResult);
    String value1 = element1.getAttribute("attr1");
    // check testXSLT.xml for the expected result
    assertTrue(value1.equals("42"));

    xpath = new DOMXPath("/BLUB/root/element2");
    Element element2
        = (Element)xpath.selectSingleNode(returnResult);
    String value2 = element2.getAttribute("attr2");
    // check testXSLT.xml for the expected result
    assertTrue(value2.equals("66"));

      }

      // remove its process definition
      pdd = workflowService().processDefinitionDirectory ();
      ProcessDefinition pd
    = pdd.lookupProcessDefinition("N1", "N2");
      assertTrue(pd!=null);
      pdd.removeProcessDefinition("N1", "N2");
      boolean gotEx = false;
      try {
    pd = pdd.lookupProcessDefinition("N1", "N2");
      } catch (Exception ex) {
    gotEx = true;
      }
      assertTrue(gotEx);
      // check the process definition of the process
      ProcessDefinition procDef = process.processDefinition();
      assertTrue(procDef.packageId().equals("N1"));
      assertTrue(procDef.processId().equals("N2"));
      // import the process definition again.
      importProcessDefinitions();
      pd = pdd.lookupProcessDefinition("N1", "N2");
View Full Code Here

        throws RemoteException, InvalidKeyException {
        ProcessDefinitionDirectory pdd = null;
        try {
            pdd = wsc.getWorkflowService().processDefinitionDirectory();
            ProcessMgr pmgr = pdd.processMgr(packageId, processId);
            Process p = (Process)pmgr.createProcess
                (new DefaultRequester(wsc.getWorkflowService()));
            if (isStartInDebugMode()) {
                p.setDebugEnabled (true);
            }
            p.start ();
            setStartInDebugMode(false);
        } catch (InvalidStateException e) {
            // shouldn't happen
            logger.error (e.getMessage (), e);
        } catch (RequesterRequiredException e) {
View Full Code Here

     */
    public void testAssoc() throws Exception {
  EventLogger evtlog1 = new EventLogger();
  WfRequester cont1
      = new DefaultRequester(workflowService(), evtlog1);
  Process proc1a = (Process)createProcess("ut-process", "jut1", cont1);
  assertTrue (proc1a.requester().equals (cont1));
  Process proc1b = (Process)createProcess("ut-process", "jut1", cont1);
  assertTrue (proc1b.requester().equals (cont1));
  EventLogger evtlog2 = new EventLogger();
  WfRequester cont2 = new DefaultRequester(workflowService(), evtlog2);
  assertTrue (!cont2.equals (cont1));
  Process proc2 = (Process)createProcess("ut-process", "jut1", cont2);
  assertTrue (proc2.requester().equals (cont2));
  Collection c1 = cont1.performers();
  assertTrue (c1.size() == 2);
  boolean foundA = false
  boolean foundB = false;
  for (Iterator i = c1.iterator(); i.hasNext();) {
      Process p = (Process)i.next();
      if (p.key().equals (proc1a.key())) {
    foundA = true;
      }
      if (p.key().equals (proc1b.key())) {
    foundB = true;
      }
  }
  assertTrue (foundA && foundB);
  Thread.sleep (2000);
View Full Code Here

     * finish mode of the corresponding activities.
     */
    public void removejut1() throws Exception {
  WfRequester req = new DefaultRequester(workflowService);
  // create the process
  Process process = (Process)(createProcess("ut-process", "jut1", req));
  assertTrue(process.state().equals("open.not_running.not_started"));
  // start the process
  process.start();
  assertTrue(process.state().startsWith("open.running"));
  Thread.sleep (1000);
  // start the first two activities and stop it.
  Collection c = process.steps();
  for (int i = 1; i <= 2; i++) {
      WfActivity a = null;
      for (Iterator it = c.iterator(); it.hasNext();) {
    a = (WfActivity)it.next();
    if (a.name().equals ("A1" + i)) {
        break;
    }
      }
      if (a.name().equals("A12")) {
    Thread.sleep (1000);
    a.resume();
      }
      Thread.sleep (1000);
      assertTrue(a.name() + " not closed.completed: " + a.state(),
           a.state().startsWith("closed.completed"));
  }
  assertTrue(!process.state().equals("closed.completed"));

  // try to remove the process (should result into an exception)
  boolean removeExceptionCaught = false;
  try {
      //Process p = processDirectory().lookupProcess(null, process.key());
      processDirectory().removeProcess(process);
      assertTrue(false);
  } catch (CannotRemoveException cre) {
      removeExceptionCaught = true;
  } catch (Exception e) {
      e.printStackTrace();
      assertTrue("Unexpected exception caugth", false);
  }
  assertTrue("did not receive CannotRemoveException for a process "
       + "that has not been terminated",
       removeExceptionCaught);
 
  // start the last activity and stop it.
  for (int i = 3; i <= 3; i++) {
      WfActivity a = null;
      for (Iterator it = c.iterator(); it.hasNext();) {
    a = (WfActivity)it.next();
    if (a.name().equals ("A1" + i)) {
        break;
    }
      }
      assertTrue(a.state() != null);
      boolean exceptionCaught = false;
      assertTrue
        (a.name() + " not open.not_running.suspended: " + a.state(),
       a.state().startsWith("open.not_running.suspended"));
      a.resume();
      Thread.sleep (1000);
      a.resume();
      Thread.sleep (1000);
      assertTrue(a.name() + " not closed.completed: " + a.state(),
             a.state().startsWith("closed.completed"));
  }
  assertTrue(process + " not closed.completed: " + process.state(),
       process.state().startsWith("closed.completed"));
 
  // finally remove the process and retry to access it
  boolean exceptionCaught = false;
  Process p = processDirectory().lookupProcess(null, process.key());
  processDirectory().removeProcess(process);
  try {
      process.start();
  } catch (Exception e) {
      //e.printStackTrace();
View Full Code Here

TOP

Related Classes of de.danet.an.workflow.api.Process

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.