Package org.uengine.kernel

Examples of org.uengine.kernel.ProcessDefinition


 
  public static void main(String args[]) throws Exception{
   
    ProcessInstance.USE_CLASS = DefaultProcessInstance.class;

    ProcessDefinition pd = (ProcessDefinition) GlobalContext.deserialize(new FileInputStream(args[0]), ProcessDefinition.class);
   
    ProcessInstance pi = pd.createInstance();
   
    pi.set("", "fieldName", "1");
   
    try{
      pi.execute();
View Full Code Here


      now = Calendar.getInstance().getTimeInMillis();
      System.out.println("thread: " + threadId + ";  initialize time: " + (now-thatTime) + "  instanceId: " + instanceId);
      thatTime = now;
   
      //dynamic change
      ProcessDefinition def = pm.getProcessDefinitionWithInstanceId(instanceId);
      String changedName = "name is changed to def of " + instanceId;
      def.setName(changedName);
      pm.changeProcessDefinition(instanceId, def);
     
      ProcessDefinition def2 = pm.getProcessDefinitionWithInstanceId(instanceId);
     
      if(!def.getName().equals(def2.getName()))
        System.err.println("something wrong with dynamic change!");

      now = Calendar.getInstance().getTimeInMillis();
      System.out.println("thread: " + threadId + ";  dynamic change time: " + (now-thatTime));
      thatTime = now;
View Full Code Here

   
    assertTrue(prevActs.size() == 2);
  }
 
  public ProcessDefinition createProcessDefinition(){
    ProcessDefinition def = new ProcessDefinition();{
      ComplexActivity all1 = new AllActivity();{
        SequenceActivity seq11 = new SequenceActivity();{
          DefaultActivity act111 = new DefaultActivity("111");
          seq11.setChildActivities(new Activity[]{act111});
        }   

        AllActivity all12 = new AllActivity();{
          SequenceActivity seq12 = new SequenceActivity();{
            DefaultActivity act111 = new DefaultActivity("1211");
            seq12.setChildActivities(new Activity[]{act111});
          }
          SequenceActivity seq122 = new SequenceActivity();/*{
            DefaultActivity act111 = new DefaultActivity("1212");
            DefaultActivity act112 = new DefaultActivity("1213");
            seq122.setChildActivities(new Activity[]{act111, act112});
          }*/
          all12.setChildActivities(new Activity[]{seq12, seq122});
        }       
       
        all1.setChildActivities(new Activity[]{seq11, all12});
      }
     
      DefaultActivity act2 = new DefaultActivity("2");
     
      def.setChildActivities(new Activity[]{all1, act2});
     
      currActivity = act2;
    }
   
    return def;
View Full Code Here

public class ProcessMonitoringToolkit {
 
  public static String createFlowChart(InputStream inputStream,MonitoringOption options) throws Exception{

   
    final ProcessDefinition definition = (ProcessDefinition) GlobalContext.deserialize(
        inputStream, ProcessDefinition.class);
   
    final HashMap statusCode = options.getStatusCode();
   
    ProcessInstance instance = new DefaultProcessInstance(){

      public String getStatus(String scope) throws Exception {
        Activity act =  definition.getActivity(scope);
       
        if(act instanceof ProcessDefinition) return Activity.STATUS_RUNNING;
       
        return statusCode.containsKey(act.getStatusCode()) ? Activity.STATUS_RUNNING : Activity.STATUS_READY;
      }
View Full Code Here

              connectedFromMain = !(processDefinitionDesignerFrom.getParentDesigner().getActivity().getProcessDefinition() == processDefinition);
            }catch(Exception ex){
            }
           
            SubProcessActivity subProcAct = null;
            ProcessDefinition mainProcessDefinition, subProcessDefinition;
            Role subRole, mainRole;
            if(connectedFromMain){
              subProcAct = (SubProcessActivity) getSubProcessDesigner(getProcessDefinitionDesigner()).getActivity();
              subProcessDefinition = (ProcessDefinition) getProcessDefinitionDesigner().getActivity();
              subRole = (Role)value;
View Full Code Here

    String docFileURL = (UEngineUtil.isNotEmpty(getPath()) ? getPath() : defaultValue.getTemplateFilePath());

    if(docFileURL==null)
      throw new UEngineException(" document file is empty.");
   
    ProcessDefinition definition = (instance !=null ? instance.getProcessDefinition() : new ProcessDefinition(){

      public StringBuffer evaluateContent(ProcessInstance instance, String expression) {
        return new StringBuffer("");
      }
     
    });

    docFileURL = (instance != null ? definition.evaluateContent(instance, docFileURL).toString() : docFileURL);
   
    InputStream is = new URL(docFileURL).openStream();
    Workbook workbook = Workbook.getWorkbook(is);

    String tempFName = defaultValue.getSavingFileName(instance);
    WritableWorkbook copy = Workbook.createWorkbook(new File(tempFName), workbook);
 
    WritableSheet sheets[] = copy.getSheets();
//System.out.println("  ExcelSheetActivity:getWIHAddress: start parsing file");

    for(int i=0; i<sheets.length; i++){
      WritableSheet sheet = sheets[i];
       
      for(int row = 0; row < sheet.getRows(); row++){
        boolean newRowInserted=false;
       
        for(int col = 0; col < sheet.getColumns(); col++){           
          WritableCell cell = sheet.getWritableCell(col,row);
         
          if (cell.getType() == CellType.LABEL)
          {
            Label l = (Label) cell;       
            String expression = l.getString();
           
            if(expression.startsWith("<%=+")){
//System.out.println("expression:"+expression);
             
              if(!newRowInserted){
                newRowInserted = true;
                sheet.insertRow(row);
              }
              //l.setString(expression);
/*
                WritableCell existingCell = sheet.getWritableCell(col,row);
                Label ecl = (Label) existingCell;
                ecl.setString(               
                  EMailActivity.parseContent(expression, this, instance).toString()
                );*/
             
              jxl.format.CellFormat style = l.getCellFormat();
              WritableCell label = new Label(col,row, definition.evaluateContent(instance, expression).toString(), style);
              sheet.addCell(label);
             
            }else
            if(expression.indexOf("<%=") > -1 || expression.indexOf("<%=*") > -1){ //if the expression contains any value need to evaluate.
//System.out.println("expression:"+expression);
              l.setString(
                definition.evaluateContent( instance, expression).toString()
              );
//System.out.println("evaluated:"+l.getString());
            }else
            if(expression.startsWith("<%->")){
              l.setString("");
            }else
            if(expression.startsWith("<%<-")){
              WritableCell leftCell = sheet.getWritableCell(col-1,row);
              Label lcl = (Label) leftCell;         
              lcl.setString(
                definition.evaluateContent(instance, expression).toString()
              );
             
              l.setString("");
              }
            }                                   
View Full Code Here

    ProcessVariable theVariable = instance.getProcessDefinition().getProcessVariable(variableKey);
    FileContext defaultValue = (FileContext)theVariable.getDefaultValue();
   
    if(defaultValue.getTemplateFilePath()!=null && defaultValue.getTemplateFilePath().endsWith(".xls")){
      //parse the completed xsl file and reflect the changes to the corresponding process variables.//
      ProcessDefinition definition = instance.getProcessDefinition();
     
      String tempFName = defaultValue.getSavingFileName(instance);
     
      //template xls file
      String urlStr = definition.evaluateContent(instance, defaultValue.getTemplateFilePath()).toString();
      InputStream tis = new URL(urlStr).openStream();
      String targetUrlStr = defaultValue.getFullSavingFTPURL(instance);
     
      try{
        InputStream is = new URL(targetUrlStr).openStream();
       
        Workbook workbook = Workbook.getWorkbook(tis);
        Workbook resultWorkbook = Workbook.getWorkbook(is);   
       
        Sheet resultSheets[] = resultWorkbook.getSheets();
        Sheet sheets[] = workbook.getSheets();
       
        for(int i=0; i<sheets.length; i++){
          Sheet sheet = sheets[i];
          Sheet resultSheet = resultSheets[i];
         
          for(int col = 0; col < sheet.getColumns(); col++){
            for(int row = 0; row < sheet.getRows(); row++){
              try{
                Cell cell = sheet.getCell(col,row);       
       
                String expression = cell.getContents();
  //  System.out.println("ExcelActivity:: onComplete: expression:"+expression);
                if(expression.startsWith("<%=*")){ //if the expression contains any value need to evaluate.
                  String k = expression.substring(4, expression.indexOf("%>"));
  //  System.out.println("ExcelActivity:: key:"+k);
                  Cell resultCell = resultSheet.getCell(col, row);
                  String val = resultCell.getContents();
  //  System.out.println("ExcelActivity:: val:"+val);
                  definition.getProcessVariable(k).set(instance, "", val);
                }else
                if(expression.startsWith("<%->")){ //if the expression contains any value need to evaluate.
                  String k = expression.substring(4, expression.indexOf("%>"));
                  Cell resultCell = resultSheet.getCell(col-1, row);
                  String val = resultCell.getContents();
                  definition.getProcessVariable(k).set(instance, "", val);
                }
              }catch(Exception e){
  //  System.out.println("ExcelActivity:: error in setting value");
                e.printStackTrace();
              }
View Full Code Here

      }else{
      }
//    }
   
    if(subProcDef==null){
      subProcDef = new ProcessDefinition();
      subProcDef.setName(subProcAct.getName());
     
      ProcessDefinition mainProcDef = subProcAct.getProcessDefinition();
     
      Role[] subProcRoles = new Role[mainProcDef.getRoles().length];
      for(int i=0; i<mainProcDef.getRoles().length; i++){
        subProcRoles[i] = (Role) mainProcDef.getRoles()[i].clone();
      }
      subProcDef.setRoles(subProcRoles);
      /*
      ProcessVariable[] subProcVariables = new ProcessVariable[mainProcDef.getProcessVariables().length];
      for(int i=0; i<mainProcDef.getProcessVariables().length; i++){
View Full Code Here

        if(ProcessDesigner.getInstance().saveDesignToServer(false, subProcDef)){
          if(subProcDef.getBelongingDefinitionId()!=null)
            subProcessAct.setDefinitionId("["+subProcDef.getAlias()+"]");
        }
      }else{
        ProcessDefinition def = subProcDef;

        String definitionName = def.getName().getText();
        String alias = def.getAlias();
        int version=def.getVersion();

        SaveDialogInfo saveInfo = new SaveDialogInfo();
        saveInfo.setName(definitionName);
        saveInfo.setAlias(alias);
        saveInfo.setVersion(version+1);
View Full Code Here

    Graphics2D g2 = (Graphics2D) g;
    BasicStroke stroke = new BasicStroke(2, 1, 1, 1, new float[]{4f,4f}, 3);
    g2.setStroke(stroke);
    g2.setColor(new Color(100, 100, 100));
   
    ProcessDefinition processDefinition = (ProcessDefinition)getActivity();
   
   
   
    Vector selectedActivityComponents = ActivityDesignerListener.getSelectedComponents();
    for(int i=0; i<selectedActivityComponents.size(); i++){
      ActivityDesigner activityDesigner = (ActivityDesigner)selectedActivityComponents.get(i);
      if(activityDesigner instanceof ArrowTargetSource){
        ArrowTargetSource arrowTargetSource = ((ArrowTargetSource)activityDesigner);
       
        ProcessVariable variables[] = processDefinition.getProcessVariables();
        if(variables !=null)
        for(int j=0; j<variables.length; j++){
          java.util.List links = arrowTargetSource.getArrowLinkingInfo(variables[j]);

          if(links!=null)
          for(int k=0; k<links.size(); k++){
            ArrowLinkingInfo ali = (ArrowLinkingInfo)links.get(k);
            Point pointToLink = ali.getLinkPoint();
           
            Point relativeLocationOfActivityDesigner = UEngineUtil.getRelativeLocation(this, activityDesigner.getComponent());
            Point relativeLinkPointToActivityDesigner = new Point(relativeLocationOfActivityDesigner.x + pointToLink.x, relativeLocationOfActivityDesigner.y + pointToLink.y);
            Point relativeLinkPointFrom = UEngineUtil.getRelativeLocation(this, processVariableInformationPanel.getJLabel(variables[j]));
           
            g2.drawLine(relativeLinkPointFrom.x, relativeLinkPointFrom.y, relativeLinkPointToActivityDesigner.x, relativeLinkPointToActivityDesigner.y);
           
            if(ali.isTarget())
              g2.drawArc(relativeLinkPointToActivityDesigner.x, relativeLinkPointToActivityDesigner.y, 2, 2, 0, 0);
            if(ali.isSource())
              g2.drawArc(relativeLinkPointFrom.x, relativeLinkPointFrom.y, 2, 2, 0, 0);
          }
        }
       
        Role roles[] = processDefinition.getRoles();
        if(roles !=null)
        for(int j=0; j<roles.length; j++){
          java.util.List links = arrowTargetSource.getArrowLinkingInfo(roles[j]);

          if(links!=null)
View Full Code Here

TOP

Related Classes of org.uengine.kernel.ProcessDefinition

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.