📄 dom4jfpdlparser.java.svn-base
字号:
activities.add(activity);
}
}
protected void loadTasks(Activity activity, List<Task> tasks, Element element)
throws FPDLParserException {
tasks.clear();
if (element == null) {
return;
}
List tasksElms = Util4Parser.children(element, TASK);
Iterator iter = tasksElms.iterator();
while (iter.hasNext()) {
Element elm = (Element) iter.next();
tasks.add(createTask(activity, elm));
}
}
protected Task createTask(Activity activity, Element taskElement)
throws FPDLParserException {
Task task = new Task(activity, taskElement.attributeValue(NAME));
task.setSn(UUID.randomUUID().toString());
task.setDisplayName(taskElement.attributeValue(DISPLAY_NAME));
task.setDescription(Util4Parser.elementAsString(taskElement, DESCRIPTION));
task.setType(taskElement.attributeValue(TYPE));
String sPriority = taskElement.attributeValue(PRIORITY);
int priority = 0;
if (sPriority != null) {
try {
priority = Integer.parseInt(sPriority);
} catch (Exception e) {
}
}
task.setPriority(priority);
task.setAssignmentStrategy(taskElement.attributeValue(COMPLETION_STRATEGY));
task.setDefaultView(taskElement.attributeValue(DEFAULT_VIEW));
// task.setStartMode(taskElement.attributeValue(START_MODE));
task.setPerformer(createPerformer(Util4Parser.child(taskElement,
PERFORMER)));
task.setApplication(createApplication(Util4Parser.child(taskElement,
APPLICATION)));
task.setEditForm(createForm(Util4Parser.child(taskElement, EDIT_FORM)));
task.setViewForm(createForm(Util4Parser.child(taskElement, VIEW_FORM)));
task.setListForm(createForm(Util4Parser.child(taskElement, LIST_FORM)));
task.setDuration(createDuration(Util4Parser.child(taskElement, DURATION)));
task.setSubWorkflowProcess(createSubWorkflowProcess(Util4Parser.child(taskElement, SUB_WORKFLOW_PROCESS)));
loadEventListeners(task.getEventListeners(), Util4Parser.child(taskElement, EVENT_LISTENERS));
loadExtendedAttributes(task.getExtendedAttributes(),
Util4Parser.child(taskElement, EXTENDED_ATTRIBUTES));
return task;
}
protected Participant createPerformer(Element performerElement) {
if (performerElement == null) {
return null;
}
Participant part = new Participant(performerElement.attributeValue(NAME));
part.setDisplayName(performerElement.attributeValue(DISPLAY_NAME));
part.setDescription(Util4Parser.elementAsString(performerElement,
DESCRIPTION));
part.setAssignmentHandler(Util4Parser.elementAsString(performerElement,
this.ASSIGNMENT_HANDLER));
return part;
}
protected SubWorkflowProcess createSubWorkflowProcess(Element subFlowElement) {
if (subFlowElement == null) {
return null;
}
SubWorkflowProcess subFlow = new SubWorkflowProcess(subFlowElement.attributeValue(NAME));
subFlow.setDisplayName(subFlowElement.attributeValue(DISPLAY_NAME));
subFlow.setDescription(Util4Parser.elementAsString(subFlowElement,
DESCRIPTION));
subFlow.setWorkflowProcessId(Util4Parser.elementAsString(subFlowElement,
this.WORKFLOW_PROCESS_ID));
return subFlow;
}
protected Application createApplication(Element applicationElement) {
if (applicationElement == null) {
return null;
}
Application app = new Application(applicationElement.attributeValue(APPLICATION));
app.setDisplayName(applicationElement.attributeValue(DISPLAY_NAME));
app.setDescription(Util4Parser.elementAsString(applicationElement,
DESCRIPTION));
app.setHandler(Util4Parser.elementAsString(applicationElement,
HANDLER));
return app;
}
protected Form createForm(Element formElement) {
if (formElement == null) {
return null;
}
Form form = new Form(formElement.attributeValue(NAME));
form.setDisplayName(formElement.attributeValue(DISPLAY_NAME));
form.setDescription(Util4Parser.elementAsString(formElement,
DESCRIPTION));
form.setUri(Util4Parser.elementAsString(formElement, URI));
return form;
}
protected Duration createDuration(Element durationElement) {
if (durationElement == null) {
return null;
}
String sValue = durationElement.attributeValue(VALUE);
String sIsBusTime = durationElement.attributeValue(this.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.attributeValue(UNIT));
duration.setBusinessTime(isBusinessTime);
return duration;
}
protected void loadTransitions(WorkflowProcess wp, Element element)
throws FPDLParserException {
if (element == null) {
return;
}
loadTransitions(wp, Util4Parser.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.attributeValue(FROM);
String toNodeId = element.attributeValue(TO);
Node fromNode = (Node) nodeMap.get(fromNodeId);
Node toNode = (Node) nodeMap.get(toNodeId);
Transition transition = new Transition(wp,
element.attributeValue(NAME), fromNode,
toNode);
transition.setSn(UUID.randomUUID().toString());
transition.setDisplayName(element.attributeValue(DISPLAY_NAME));
transition.setDescription(Util4Parser.elementAsString(element,
DESCRIPTION));
Element conditionElement = Util4Parser.child(element, CONDITION);
transition.setCondition(conditionElement == null ? ""
: conditionElement.getStringValue());
// load extended attributes
Map<String, String> extAttrs = transition.getExtendedAttributes();
loadExtendedAttributes(extAttrs, Util4Parser.child(element,
EXTENDED_ATTRIBUTES));
return transition;
}
protected void loadDataFields(WorkflowProcess wp, List<DataField> dataFields,
Element element) throws FPDLParserException {
if (element == null) {
return;
}
List datafieldsElement = Util4Parser.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;
}
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;
}
protected void loadExtendedAttributes(Map<String, String> extendedAttributes,
Element element) throws FPDLParserException {
if (element == null) {
return;
}
extendedAttributes.clear();
List extendAttributeElementsList = Util4Parser.children(element,
EXTENDED_ATTRIBUTE);
Iterator iter = extendAttributeElementsList.iterator();
while (iter.hasNext()) {
Element extAttrElement = (Element) iter.next();
String name = extAttrElement.attributeValue(NAME);
String value = extAttrElement.attributeValue(VALUE);
extendedAttributes.put(name, value);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -