Package de.danet.an.workflow.api

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


    }

    private WfProcess createProcess
  (String pkgId, String prcId, WfRequester req)
        throws Exception {
  ProcessDefinitionDirectory pdd = null;
  try {
      pdd = workflowService().processDefinitionDirectory ();
      WfProcessMgr pmgr = pdd.processMgr(pkgId, prcId);
      return pmgr.createProcess (req);
  } finally {
      workflowService().release (pdd);
  }
    }
View Full Code Here


 
    /**
     * Create a new process and then remove its process definition.
     */
    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("/parent/firstChild");
    String value2 = xpath.stringValueOf(returnResult);
    assertTrue(value2.equals("I'm number one"));


    XPath xpath2 = new DOMXPath("/parent/thirdChild");
    Element child = (Element)xpath2.selectSingleNode(returnResult);
    System.out.println("child = " + child.getClass());
     org.jdom.Element child2 = new org.jdom.input.DOMBuilder().build(child);
     org.jdom.output.XMLOutputter output= new org.jdom.output.XMLOutputter();
     java.io.StringWriter sw = new java.io.StringWriter();
     output.output(child2, sw);
     System.out.println(sw.toString());
      }

      // 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");
      assertTrue(pd!=null);
  } finally {
      workflowService().release (pdd);
  }
    }
View Full Code Here

   // Create process definition directory bean
  ProcessDefinitionDirectoryHome pddh
      = (ProcessDefinitionDirectoryHome)EJBUtil.lookupEJBHome
      (ProcessDefinitionDirectoryHome.class,
       "ejb/de.danet.an.wfdemo.ProcessDefinitionDirectory");
  ProcessDefinitionDirectory pdd = pddh.create();
  InputStream is = JSTest.class.getResourceAsStream(filename);
  assertTrue (is != null);
  BufferedReader br = new BufferedReader
      (new InputStreamReader(is, "ISO-8859-1"));
  StringBuffer sb = new StringBuffer();
  String st;
  while ((st = br.readLine()) != null) {
      sb.append(st + "\n");
  }
  pdd.importProcessDefinitions(sb.toString());
  Collection processDefinitions = pdd.processDefinitions();
  assertTrue (processDefinitions.size() > 0);
    }
View Full Code Here

     * Import the process definitions from a XPDL file
     * unsing the ProcessDefinitionDirectory bean.
     */
    public void importProcessDefinitions() throws Exception {
  // Create process definition directory bean
  ProcessDefinitionDirectory pdd
      = workflowService.processDefinitionDirectory();

  InputStream is = getClass()
      .getResourceAsStream("/tools/simpleApplDirTest.xml");
  assertTrue (is != null);
  BufferedReader br = new BufferedReader
      (new InputStreamReader(is, "ISO-8859-1"));
  StringBuffer sb = new StringBuffer();
  String st;
  while ((st = br.readLine()) != null) {
      sb.append(st + "\n");
  }
  pdd.importProcessDefinitions(sb.toString());
  Collection processDefinitions = pdd.processDefinitions();
  assertTrue (processDefinitions.size() > 0);
    }
View Full Code Here

    /**
     * Test.
     */
    public void findByKey () throws Exception {
  ProcessDefinitionDirectory procDefDir = null;
  ProcessDirectory procDir = null;
  try {
            SimpleApplicationDirectory ad
                = (SimpleApplicationDirectory)workflowService
                .executeBatch(new SimpleApplicationDirectoryLookup());
            assertTrue (ad.infosByKey
                        ("unittests.Test1", "ToolTest").size() == 0);
      procDefDir = workflowService.processDefinitionDirectory();
      procDir = workflowService.processDirectory();
      ProcessMgr pmgr = procDefDir
    .processMgr ("simpleApplDirTests", "test1");
      WfProcess process
    = pmgr.createProcess(new DefaultRequester (workflowService));
      process.start();
            WfActivity act = null;
View Full Code Here

  }
    }

    private WfProcess createProcess(String pkgId, String prcId, WfRequester req)
            throws Exception {
        ProcessDefinitionDirectory procDir = null;
        try {
            procDir = workflowService.processDefinitionDirectory();
            ProcessMgr pmgr = procDir.processMgr(pkgId, prcId);
            return pmgr.createProcess(req);
        } finally {
            workflowService.release(procDir);
        }
    }
View Full Code Here

    /**
     * Returns a list of all defined process definitions
     * from the ProcessDefinitionDirectory bean.
     */
    public void listProcessDefinitions() throws Exception {
        ProcessDefinitionDirectory pdd
            = WorkflowServiceFactory.newInstance()
            .newWorkflowService().processDefinitionDirectory();

  Collection processDefinitions = pdd.processDefinitions();
  assertTrue (processDefinitions.size() > 0);
  Collection ids = new ArrayList();
  Collection names = new ArrayList();
  for (Iterator pdi = processDefinitions.iterator(); pdi.hasNext();) {
      ProcessDefinition pd = (ProcessDefinition)pdi.next();
View Full Code Here

    /**
     * Disable/Enable ProcessDefinitionDirectory.
     */
    public void disableProcessDefinition() throws Exception {
        ProcessDefinitionDirectory pdd
            = WorkflowServiceFactory.newInstance()
            .newWorkflowService().processDefinitionDirectory();

  Collection processDefinitions = pdd.processDefinitions();
  assertTrue (processDefinitions.size() > 0);
  ProcessDefinition pd
      = (ProcessDefinition)(processDefinitions.iterator().next());
  assertTrue (pdd.isEnabled(pd.packageId(), pd.processId()));
  pdd.setEnabled (pd.packageId(), pd.processId(), false);
  assertTrue (!pdd.isEnabled(pd.packageId(), pd.processId()));
  pdd.setEnabled (pd.packageId(), pd.processId(), true);
  assertTrue (pdd.isEnabled(pd.packageId(), pd.processId()));
    }
View Full Code Here

    /**
     * Removes a given process definition using the ProcessDirectory bean.
     */
    public void  removeProcessDefinition() throws Exception {
        ProcessDefinitionDirectory pdd
            = WorkflowServiceFactory.newInstance()
            .newWorkflowService().processDefinitionDirectory();

  ProcessDefinition pd
      = pdd.lookupProcessDefinition("ut-procdef", "jut1");
  assertTrue(pd!=null);
  pdd.removeProcessDefinition("ut-procdef", "jut1");
  boolean gotEx = false;
  try {
      pd = pdd.lookupProcessDefinition("ut-procdef", "jut1");
  } catch (Exception ex) {
      gotEx = true;
  }
  assertTrue(gotEx);
    }
View Full Code Here

    /**
     * Returns a process definition
     * from the ProcessDefinitionDirectory bean.
     */
    public ProcessDefinition getProcessDefinition() throws Exception {
        ProcessDefinitionDirectory pdd
            = WorkflowServiceFactory.newInstance()
            .newWorkflowService().processDefinitionDirectory();
 
  ProcessDefinition pd
      = pdd.lookupProcessDefinition("ut-procdef", "jut2");
  assertTrue (pd!=null);
  boolean gotEx = false;
  try {
      pd = pdd.lookupProcessDefinition("ut-procdef", "doesn't exist");
  } catch (Exception ex) {
      gotEx = true;
  }
  assertTrue(gotEx);
  return pd;
View Full Code Here

TOP

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

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.