Package org.fireflow.model

Examples of org.fireflow.model.DataField


    // 初始化流程变量
    processInstance.setProcessInstanceVariables(new HashMap<String, Object>());
   
    List<DataField> datafields = wfProcess.getDataFields();
    for (int i = 0; datafields != null && i < datafields.size(); i++) {
      DataField df =  datafields.get(i);
      if (df.getDataType().equals(DataField.STRING)) {
        if (df.getInitialValue() != null) {
          processInstance.setProcessInstanceVariable(df
              .getName(), df.getInitialValue());
        } else {
          processInstance.setProcessInstanceVariable(df
              .getName(), "");
        }
      } else if (df.getDataType().equals(DataField.INTEGER)) {
        if (df.getInitialValue() != null) {
          try {
            Integer intValue = new Integer(df
                .getInitialValue());
            processInstance.setProcessInstanceVariable(df
                .getName(), intValue);
          } catch (Exception e) {
          }
        } else {
          processInstance.setProcessInstanceVariable(df
              .getName(), new Integer(0));
        }
      } else if (df.getDataType().equals(DataField.LONG)) {
        if (df.getInitialValue() != null) {
          try {
            Long longValue = new Long(df.getInitialValue());
            processInstance.setProcessInstanceVariable(df
                .getName(), longValue);
          } catch (Exception e) {
          }
        } else {
          processInstance.setProcessInstanceVariable(df
              .getName(), new Long(0));
        }
      } else if (df.getDataType().equals(DataField.FLOAT)) {
        if (df.getInitialValue() != null) {
          Float floatValue = new Float(df.getInitialValue());
          processInstance.setProcessInstanceVariable(df
              .getName(), floatValue);
        } else {
          processInstance.setProcessInstanceVariable(df
              .getName(), new Float(0));
        }
      } else if (df.getDataType().equals(DataField.DOUBLE)) {
        if (df.getInitialValue() != null) {
          Double doubleValue = new Double(df
              .getInitialValue());
          processInstance.setProcessInstanceVariable(df
              .getName(), doubleValue);
        } else {
          processInstance.setProcessInstanceVariable(df
              .getName(), new Double(0));
        }
      } else if (df.getDataType().equals(DataField.BOOLEAN)) {
        if (df.getInitialValue() != null) {
          Boolean booleanValue = new Boolean(df
              .getInitialValue());
          processInstance.setProcessInstanceVariable(df
              .getName(), booleanValue);
        } else {
          processInstance.setProcessInstanceVariable(df
              .getName(), Boolean.FALSE);
        }
      } else if (df.getDataType().equals(DataField.DATETIME)) {
        // TODO 需要完善一下
        if (df.getInitialValue() != null
            && df.getDataPattern() != null) {
          try {
            SimpleDateFormat dFormat = new SimpleDateFormat(
                df.getDataPattern());
            Date dateTmp = dFormat.parse(df
                .getInitialValue());
            processInstance.setProcessInstanceVariable(df
                .getName(), dateTmp);
          } catch (Exception e) {
            processInstance.setProcessInstanceVariable(df
                .getName(), null);
            e.printStackTrace();
          }
        } else {
          processInstance.setProcessInstanceVariable(df
              .getName(), null);
        }
      }
    }
    return processInstance;
View Full Code Here


        //初始化流程变量,从父实例获得初始值
        Map<String ,Object> processVars = ((TaskInstance) taskInstance).getAliveProcessInstance().getProcessInstanceVariables();
        List<DataField> datafields = subWorkflowProcess.getDataFields();
        for (int i = 0; datafields != null && i < datafields.size(); i++) {
            DataField df = datafields.get(i);
            //TODO wmj2003 疑问,这里的逻辑都不对吧? 直接 subProcessInstance.setProcessInstanceVariable(df.getName(), processVars.get(df.getName()));
            //还需要判断什么类型啊?反正value是Object
            if (df.getDataType().equals(DataField.STRING)) {
                if (processVars.get(df.getName()) != null && (processVars.get(df.getName()) instanceof String)) {
                    subProcessInstance.setProcessInstanceVariable(df.getName(), processVars.get(df.getName()));
                } else if (df.getInitialValue() != null) {
                    subProcessInstance.setProcessInstanceVariable(df.getName(), df.getInitialValue());
                } else {
                    subProcessInstance.setProcessInstanceVariable(df.getName(), "");
                }
            } else if (df.getDataType().equals(DataField.INTEGER)) {
                if (processVars.get(df.getName()) != null && (processVars.get(df.getName()) instanceof Integer)) {
                    subProcessInstance.setProcessInstanceVariable(df.getName(), processVars.get(df.getName()));
                } else if (df.getInitialValue() != null) {
                    try {
                        Integer intValue = new Integer(df.getInitialValue());
                        subProcessInstance.setProcessInstanceVariable(df.getName(), intValue);
                    } catch (Exception e) {
                    }
                } else {
                    subProcessInstance.setProcessInstanceVariable(df.getName(), new Integer(0));
                }
            } else if (df.getDataType().equals(DataField.FLOAT)) {
                if (processVars.get(df.getName()) != null && (processVars.get(df.getName()) instanceof Float)) {
                    subProcessInstance.setProcessInstanceVariable(df.getName(), processVars.get(df.getName()));
                } else if (df.getInitialValue() != null) {
                    Float floatValue = new Float(df.getInitialValue());
                    subProcessInstance.setProcessInstanceVariable(df.getName(), floatValue);
                } else {
                    subProcessInstance.setProcessInstanceVariable(df.getName(), new Float(0));
                }
            } else if (df.getDataType().equals(DataField.BOOLEAN)) {
                if (processVars.get(df.getName()) != null && (processVars.get(df.getName()) instanceof Boolean)) {
                    subProcessInstance.setProcessInstanceVariable(df.getName(), processVars.get(df.getName()));
                } else if (df.getInitialValue() != null) {
                    Boolean booleanValue = new Boolean(df.getInitialValue());
                    subProcessInstance.setProcessInstanceVariable(df.getName(), booleanValue);
                } else {
                    subProcessInstance.setProcessInstanceVariable(df.getName(), Boolean.FALSE);
                }
            } else if (df.getDataType().equals(DataField.DATETIME)) {
                //TODO 需要完善一下 ( 父子流程数据传递——时间类型的数据还未做传递-不知道为什么?)
              //wmj2003 20090925 补充上了
                if (processVars.get(df.getName()) != null && (processVars.get(df.getName()) instanceof Date)) {
                    subProcessInstance.setProcessInstanceVariable(df.getName(), processVars.get(df.getName()));
                } else if (df.getInitialValue() != null) {
          try {
                    SimpleDateFormat dFormat = new SimpleDateFormat(df.getDataPattern());
            Date dateTmp = dFormat.parse(df.getInitialValue());
            subProcessInstance.setProcessInstanceVariable(df.getName(), dateTmp);
          } catch (ParseException e) {
            subProcessInstance.setProcessInstanceVariable(df.getName(), null);
            e.printStackTrace();
          }
                  
                } else {
                    subProcessInstance.setProcessInstanceVariable(df.getName(), null);
                }
            }
        }
        //TODO 应将下面这句删除!这里还需要吗?应该直接subProcessInstance.run()就可以了。
        runtimeContext.getPersistenceService().saveOrUpdateProcessInstance(subProcessInstance);
View Full Code Here

        Element dataFieldsElement = Util4Serializer.addElement(parent,
                DATA_FIELDS);
        Iterator<DataField> iter = dataFields.iterator();
        while (iter.hasNext()) {
            DataField dataField = iter.next();
            Element dataFieldElement = Util4Serializer.addElement(
                    dataFieldsElement, DATA_FIELD);

            dataFieldElement.addAttribute(ID, dataField.getId());
            dataFieldElement.addAttribute(NAME, dataField.getName());
            dataFieldElement.addAttribute(DISPLAY_NAME, dataField.getDisplayName());
            dataFieldElement.addAttribute(DATA_TYPE, dataField.getDataType());

            dataFieldElement.addAttribute(INITIAL_VALUE,
                    dataField.getInitialValue());

            Util4Serializer.addElement(dataFieldElement, DESCRIPTION, dataField.getDescription());

            writeExtendedAttributes(dataField.getExtendedAttributes(),
                    dataFieldElement);
        }
    }
View Full Code Here

        String dataType = element.attributeValue(DATA_TYPE);
        if (dataType == null) {
            dataType = DataField.STRING;
        }

        DataField dataField = new DataField(wp, element.attributeValue(NAME),
                dataType);
        dataField.setSn(UUID.randomUUID().toString());

        dataField.setDisplayName(element.attributeValue(DISPLAY_NAME));
        dataField.setInitialValue(element.attributeValue(INITIAL_VALUE));
        dataField.setDescription(Util4Parser.elementAsString(element,
                DESCRIPTION));

        loadExtendedAttributes(dataField.getExtendedAttributes(), Util4Parser.child(element, EXTENDED_ATTRIBUTES));

        return dataField;
    }
View Full Code Here

        Element dataFieldsElement = Util4JAXPSerializer.addElement(document, parent,
                DATA_FIELDS);
        Iterator<DataField> iter = dataFields.iterator();
        while (iter.hasNext()) {
            DataField dataField = iter.next();
            Element dataFieldElement = Util4JAXPSerializer.addElement(document,
                    dataFieldsElement, DATA_FIELD);

            dataFieldElement.setAttribute(ID, dataField.getId());
            dataFieldElement.setAttribute(NAME, dataField.getName());
            dataFieldElement.setAttribute(DISPLAY_NAME, dataField.getDisplayName());
            dataFieldElement.setAttribute(DATA_TYPE, dataField.getDataType());

            dataFieldElement.setAttribute(INITIAL_VALUE,
                    dataField.getInitialValue());

            Util4JAXPSerializer.addElement(document, dataFieldElement, DESCRIPTION, dataField.getDescription());

            writeExtendedAttributes(dataField.getExtendedAttributes(),
                    dataFieldElement, document);
        }
    }
View Full Code Here

    protected DataField createDataField(WorkflowProcess wp, Element element)
            throws FPDLParserException {
        if (element == null) {
            return null;
        }
        DataField dataField = new DataField(wp, element.getAttribute(NAME),
                element.getAttribute(DATA_TYPE));
        dataField.setSn(UUID.randomUUID().toString());

        dataField.setDisplayName(element.getAttribute(DISPLAY_NAME));
        dataField.setInitialValue(element.getAttribute(INITIAL_VALUE));
        dataField.setDescription(Util4JAXPParser.elementAsString(element,
                DESCRIPTION));

        loadExtendedAttributes(dataField.getExtendedAttributes(), Util4JAXPParser.child(element, EXTENDED_ATTRIBUTES));

        return dataField;
    }
View Full Code Here

TOP

Related Classes of org.fireflow.model.DataField

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.