📄 jaxp_fpdl_parser.java.svn-base
字号:
task.setDescription(Util4JAXPParser.elementAsString(taskElement, DESCRIPTION)); task.setType(taskElement.getAttribute(TYPE)); String sPriority = taskElement.getAttribute(PRIORITY); int priority = 0; if (sPriority != null) { try { priority = Integer.parseInt(sPriority); } catch (Exception e) { } } task.setPriority(priority); task.setAssignmentStrategy(taskElement.getAttribute(COMPLETION_STRATEGY)); task.setDefaultView(taskElement.getAttribute(DEFAULT_VIEW));// task.setStartMode(taskElement.getAttribute(START_MODE)); task.setPerformer(createPerformer(Util4JAXPParser.child(taskElement, PERFORMER))); task.setApplication(createApplication(Util4JAXPParser.child(taskElement, APPLICATION))); task.setEditForm(createForm(Util4JAXPParser.child(taskElement, EDIT_FORM))); task.setViewForm(createForm(Util4JAXPParser.child(taskElement, VIEW_FORM))); task.setListForm(createForm(Util4JAXPParser.child(taskElement, LIST_FORM))); task.setDuration(createDuration(Util4JAXPParser.child(taskElement, DURATION))); task.setSubWorkflowProcess(createSubWorkflowProcess(Util4JAXPParser.child(taskElement, SUB_WORKFLOW_PROCESS))); loadEventListeners(task.getEventListeners(), Util4JAXPParser.child(taskElement, EVENT_LISTENERS)); loadExtendedAttributes(task.getExtendedAttributes(), Util4JAXPParser.child(taskElement, EXTENDED_ATTRIBUTES)); return task; } protected Participant createPerformer(Element performerElement) { if (performerElement == null) { return null; } Participant part = new Participant(performerElement.getAttribute(NAME)); part.setDisplayName(performerElement.getAttribute(DISPLAY_NAME)); part.setDescription(Util4JAXPParser.elementAsString(performerElement, DESCRIPTION)); part.setAssignmentHandler(Util4JAXPParser.elementAsString(performerElement, ASSIGNMENT_HANDLER)); return part; } protected SubWorkflowProcess createSubWorkflowProcess(Element subFlowElement) { if (subFlowElement == null) { return null; } SubWorkflowProcess subFlow = new SubWorkflowProcess(subFlowElement.getAttribute(NAME)); subFlow.setDisplayName(subFlowElement.getAttribute(DISPLAY_NAME)); subFlow.setDescription(Util4JAXPParser.elementAsString(subFlowElement, DESCRIPTION)); subFlow.setWorkflowProcessId(Util4JAXPParser.elementAsString(subFlowElement, WORKFLOW_PROCESS_ID)); return subFlow; } protected Application createApplication(Element applicationElement) { if (applicationElement == null) { return null; } Application app = new Application(applicationElement.getAttribute(NAME)); app.setDisplayName(applicationElement.getAttribute(DISPLAY_NAME)); app.setDescription(Util4JAXPParser.elementAsString(applicationElement, DESCRIPTION)); app.setHandler(Util4JAXPParser.elementAsString(applicationElement, HANDLER)); return app; } protected Form createForm(Element formElement) { if (formElement == null) { return null; } Form form = new Form(formElement.getAttribute(NAME)); form.setDisplayName(formElement.getAttribute(DISPLAY_NAME)); form.setDescription(Util4JAXPParser.elementAsString(formElement, DESCRIPTION)); form.setUri(Util4JAXPParser.elementAsString(formElement, URI)); return form; } protected Duration createDuration(Element durationElement) { if (durationElement == null) { return null; } String sValue = durationElement.getAttribute(VALUE); String sIsBusTime = durationElement.getAttribute(IS_BUSINESS_TIME); boolean isBusinessTime = true; int value = 1; if (sValue != null) { try { value = Integer.parseInt(sValue); isBusinessTime = Boolean.parseBoolean(sIsBusTime); } catch (Exception ex) { return null; } } Duration duration = new Duration(value, durationElement.getAttribute(UNIT)); duration.setBusinessTime(isBusinessTime); return duration; } protected void loadTransitions(WorkflowProcess wp, Element element) throws FPDLParserException { if (element == null) { return; } loadTransitions(wp, Util4JAXPParser.children(element, TRANSITION)); } protected void loadTransitions(WorkflowProcess wp, List<Element> elements) throws FPDLParserException { List<Transition> transitions = wp.getTransitions(); HashMap<String, IWFElement> nodeMap = new HashMap<String, IWFElement>(); if (wp.getStartNode() != null) { nodeMap.put(wp.getStartNode().getId(), wp.getStartNode()); } List activityList = wp.getActivities(); for (int i = 0; i < activityList.size(); i++) { Activity activity = (Activity) activityList.get(i); nodeMap.put(activity.getId(), activity); } List synchronizerList = wp.getSynchronizers(); for (int i = 0; i < synchronizerList.size(); i++) { Synchronizer syn = (Synchronizer) synchronizerList.get(i); nodeMap.put(syn.getId(), syn); } List endNodeList = wp.getEndNodes(); for (int i = 0; i < endNodeList.size(); i++) { EndNode endNode = (EndNode) endNodeList.get(i); nodeMap.put(endNode.getId(), endNode); } transitions.clear(); Iterator iter = elements.iterator(); while (iter.hasNext()) { Element transitionElement = (Element) iter.next(); Transition transition = createTransition(wp, transitionElement, nodeMap); transitions.add(transition); Node fromNode = transition.getFromNode(); Node toNode = transition.getToNode(); if (fromNode != null && (fromNode instanceof Activity)) { ((Activity) fromNode).setLeavingTransition(transition); } else if (fromNode != null && (fromNode instanceof Synchronizer)) { ((Synchronizer) fromNode).getLeavingTransitions().add( transition); } if (toNode != null && (toNode instanceof Activity)) { ((Activity) toNode).setEnteringTransition(transition); } else if (toNode != null && (toNode instanceof Synchronizer)) { ((Synchronizer) toNode).getEnteringTransitions().add(transition); } } } protected Transition createTransition(WorkflowProcess wp, Element element, Map nodeMap) throws FPDLParserException { String fromNodeId = element.getAttribute(FROM); String toNodeId = element.getAttribute(TO); Node fromNode = (Node) nodeMap.get(fromNodeId); Node toNode = (Node) nodeMap.get(toNodeId); Transition transition = new Transition(wp, element.getAttribute(NAME), fromNode, toNode); transition.setSn(UUID.randomUUID().toString()); transition.setDisplayName(element.getAttribute(DISPLAY_NAME)); transition.setDescription(Util4JAXPParser.elementAsString(element, DESCRIPTION)); Element conditionElement = Util4JAXPParser.child(element, CONDITION); transition.setCondition(conditionElement == null ? "" : conditionElement.getTextContent()); // load extended attributes Map<String, String> extAttrs = transition.getExtendedAttributes(); loadExtendedAttributes(extAttrs, Util4JAXPParser.child(element, EXTENDED_ATTRIBUTES)); return transition; } protected void loadDataFields(WorkflowProcess wp, List<DataField> dataFields, Element element) throws FPDLParserException { if (element == null) { return; } List datafieldsElement = Util4JAXPParser.children(element, DATA_FIELD); dataFields.clear(); Iterator iter = datafieldsElement.iterator(); while (iter.hasNext()) { Element dataFieldElement = (Element) iter.next(); dataFields.add(createDataField(wp, dataFieldElement)); } } 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; } protected void loadExtendedAttributes(Map<String, String> extendedAttributes, Element element) throws FPDLParserException { if (element == null) { return; } extendedAttributes.clear(); List extendAttributeElementsList = Util4JAXPParser.children(element, EXTENDED_ATTRIBUTE); Iterator iter = extendAttributeElementsList.iterator(); while (iter.hasNext()) { Element extAttrElement = (Element) iter.next(); String name = extAttrElement.getAttribute(NAME); String value = extAttrElement.getAttribute(VALUE); extendedAttributes.put(name, value); } } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -