⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wfrunner.java

📁 OBPM是一个开源
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    if (js != null && js.trim().length() > 0) {
      try {
//        TestVO tv = new TestVO();
//        tv.setName("good morning!");
//
//        declareBean("$DOC", tv);
        System.out.println("js-->" + js);
        BSF_MANAGER.declareBean("$JSUTIL", util, util.getClass());
        result = BSF_MANAGER.eval("javascript", "tt", 0, 0, js);
        if (result instanceof Boolean) {
          istrue = ( (Boolean) result).booleanValue();
        }
      }
      catch (Exception em) {
        em.printStackTrace();
        System.out.println("mgr eval javascript error!");
      }
    }
    return istrue;
  }

  public String saveToXML() {
    return flowDiagram.toXML();
  }

//  public void testNextStep() { //测试流程下一步
//    Node cn = fd.getCurrentNode();
//    if (cn != null) {
//      System.out.println("CurrNode->" + cn.name);
//    }
//    else {
//      try {
//        fd.setFlowstatus(FlowType.FLOWSTATUS_OPEN_NOSTART);
//      }
//      catch (Exception ex) {
//        System.out.println("set FlowStatus error!");
//      }
//      cn = fd.getCurrentNode();
//      System.out.println("CurrNode->" + cn.name);
//    }
//    Vector v = fd.getNodeNextRelation(cn);
//    Iterator iter = v.iterator();
//    Relation item = null;
//    while (iter.hasNext()) {
//      Relation temp = (Relation) iter.next();
//      if (temp != null) {
//        System.out.println("condition-->" + temp.condition);
//        System.out.println("Relation->" + temp.name);
//        item = temp;
//        System.out.println("NextRelation-->" + item.name);
//      }
//    }
//    if (item != null) {
//      runJavascript(cn.afterscrpt); //流程转向下一步时执行afterscrpt
//      cn = fd.getNextNode(item);
//      if (cn != null) {
//        fd.setCurrentNode(cn);
//        runJavascript(cn.beforescrpt); //流程转入时执行beforescrpt
//      }
//    }
//    try {
//      fd.setFlowstatus(FlowType.FLOWSTATUS_OPEN_RUN_RUNNING);
//    }
//    catch (Exception ex) {
//      System.out.println("set Flow status error!");
//    }
//    saveXML(fd.toXML());
//
//  }
//
//  public void testNextStepByCndtn() { //测试流程下一步
//    Node cn = fd.getCurrentNode();
//    if (cn != null) {
//      System.out.println("CurrNode->" + cn.name);
//    }
//    else {
//      try {
//        fd.setFlowstatus(FlowType.FLOWSTATUS_OPEN_NOSTART);
//      }
//      catch (Exception ex) {
//        System.out.println("set FlowStatus error!");
//      }
//      cn = fd.getCurrentNode();
//      System.out.println("CurrNode->" + cn.name);
//    }
//    Vector v = fd.getNodeNextRelation(cn);
//
//    Iterator iter = v.iterator();
//    Relation item = null;
//    while (iter.hasNext()) {
//      Relation temp = (Relation) iter.next();
//      if (temp != null) {
//        System.out.println("Condition-->" + temp.condition);
//        if (isCondition(temp.condition)) {
//          System.out.println("Relation->" + temp.name);
//          item = temp;
//          System.out.println("NextRelation-->" + item.name);
//        }
//      }
//    }
//    if (item != null) {
//      runJavascript(cn.afterscrpt); //流程转向下一步时执行afterscrpt
//      cn = fd.getNextNode(item);
//      if (cn != null) {
//        fd.setCurrentNode(cn);
//        runJavascript(cn.beforescrpt); //流程转入时执行beforescrpt
//      }
//    }
//
//    try {
//      fd.setFlowstatus(FlowType.FLOWSTATUS_OPEN_RUN_RUNNING);
//    }
//    catch (Exception ex) {
//      System.out.println("set Flow status error!");
//    }
//    saveXML(fd.toXML());
//  }

  public void saveXML(String xml) {
    String f = "f:\\temp\\abdc2.xml";
    try {
      java.io.FileOutputStream os = new java.io.FileOutputStream(f);
      java.io.PrintStream osw = new java.io.PrintStream(os);
      osw.println(xml);
    }
    catch (Exception ex) {
      System.out.println("error!");
    }
  }

  /**
   * 获取指定结点前的所有结点
   *
   * @param
   */
  public Vector getAllBeforeNode(Node nd, boolean ispassed) {
      return flowDiagram.getAllBeforeNode(nd, ispassed);
  }
  
  /**
   * 获取指定结点前的所有当前结点
   */
  /*public Vector getAllCurrentNode(Node nd){
      return fd.getAllCurrentNode(nd);
  }*/
  
  public void toJpegImage(File file) throws Exception{
      flowDiagram.toJpegImage(file);
  }
  public static void main(String[] args) {
    File f = new File("d:\\temp\\asdn.xml");
    WFRunner wfr = new WFRunner(f);
    Node n = null;
    try{
//      wfr.setFlowstatus(WFRunner.FLOWSTATUS_OPEN_START);

//      wfr.setFlowstatus(WFRunner.FLOWSTATUS_OPEN_RUN_RUNNING);
//      n = (Node) wfr.getElementByID("1095848817968");
//      wfr.setCurrentNode(n);
//
//      wfr.setFlowstatus(WFRunner.FLOWSTATUS_OPEN_RUN_RUNNING);
//      n = (Node) wfr.getElementByID("1095848823562");
//      wfr.setCurrentNode(n);
//
//      wfr.setFlowstatus(WFRunner.FLOWSTATUS_OPEN_RUN_SUSPEND);
//      n = (Node) wfr.getElementByID("1095848823562");
//      wfr.setCurrentNode(n);
//
//      wfr.setFlowstatus(WFRunner.FLOWSTATUS_OPEN_RUN_RUNNING);
//      n = (Node) wfr.getElementByID("1095848829875");
//      wfr.setCurrentNode(n);
//
//      n = (Node) wfr.getElementByID("1111978952090");
//      wfr.setFlowpath(wfr.getCurrentNode().id + "," +
//                      WFRunner.RUNNING2RUNNING_BACK);
//      wfr.setCurrentNode(n);
////
//      Collection colls = wfr.getFlowpath();
//      Iterator paths = colls.iterator();
//      while (paths.hasNext()) {
//        String[] p = (String[]) paths.next();
//        if (p != null && p.length > 0) {
//          Node pathn = (Node) wfr.getElementByID(p[0]);
//          if (WFRunner.RUNNING2RUNNING_NEXT.equals(p[1])) {
//            System.out.println(pathn.name + "-->" + p[1]);
//          }
//        }
//      }

//      wfr.saveXML(wfr.saveToXML());
        
//      Vector allnode = wfr.getAllBeforeNode(n, false);
//      Enumeration enum = allnode.elements();
//      while (enum.hasMoreElements()) {
//        Object item = (Object) enum.nextElement();
//        if (item instanceof Node) {
//            Node nd = (Node)item;
//            System.out.println(nd.name);
//        }
//      }
      
//		    UserProxy userProxy = new UserProxy();
//		    UserVO userVO = userProxy.doView("U");
//		    WebUser user = new WebUser(userVO);
//		    n = wfr.getCurrentNode(user);
//		    Vector allCurr = wfr.getAllCurrentNode();
//		    Iterator iters = allCurr.iterator();
//		    while(iters.hasNext()){
//		        Node node = (Node)iters.next();
//		        System.out.println("node-->"+node.name);
//		        Vector all = wfr.getAllCurrentNode(node);
//		        System.out.println("all-->"+all);
//		    }
//		    System.out.println("allCurr-->"+allCurr);
//		    System.out.println("n-->"+n.name);
      
//        UserProxy userProxy = new UserProxy();
//		    UserVO userVO = userProxy.doView("U-05-07-012");
//		    WebUser user = new WebUser(userVO);
//		    n = wfr.getCurrentNode(user);
//        Vector allCurr = wfr.getNextNodeByCndtn(n);
//        Iterator iter = allCurr.iterator();
//			  while (iter.hasNext()) {
//			     Node nextNode = (Node)iter.next();
//			     System.out.println(nextNode.name);
//			  }
//        
//      File dir = new File(filepath);
//      if(!dir.exists()){
//          dir.mkdir();
//      }
      String filepath = "D:/jboss/server/CyberCMS/deploy/webroot.war/uploads/billflow/";
      File dir = new File(filepath);
      if(!dir.exists()){
          dir.mkdir();
      }
      filepath = filepath + "1000000000" + ".jpg";
      File file = new File(filepath);
      wfr.toJpegImage(file);
    }catch(Exception ex){
      ex.printStackTrace();
    }


//    Iterator iters = m.values().iterator() ;
//    while(iters.hasNext()){
//
//    }
//    wfr.setFlowDiagram(f);
//    wfr.testNextStepByCndtn();

//    Collection colls = wfr.getFlowpath();
//    Iterator iter = colls.iterator();
//    while (iter.hasNext()) {
//      String[] item = (String[]) iter.next();
//      if (item != null) {
//        Node n = (Node) wfr.getElementByID(item[0]);
//        System.out.println(n.name + "-->" + item[1]);
//      }
//    }

  }

public FlowDiagram getFlowDiagram() {
	return flowDiagram;
}

public void setFlowDiagram(FlowDiagram flowDiagram) {
	this.flowDiagram = flowDiagram;
}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -