1 package org.jbpm.bpel.xml; 2 3 import java.util.Iterator ; 4 5 import org.w3c.dom.Element ; 6 7 import org.jbpm.bpel.data.def.Snippet; 8 import org.jbpm.bpel.def.Activity; 9 import org.jbpm.bpel.def.CompositeActivity; 10 import org.jbpm.bpel.def.Switch; 11 import org.jbpm.bpel.xml.util.NodeUtil; 12 13 19 public class SwitchReader extends ActivityReader { 20 21 protected Activity createActivity() { 22 return new Switch(); 23 } 24 25 protected void readActivity(Activity activity, Element switchElem) { 26 Switch switchBlock = (Switch)activity; 27 CompositeActivity parent = switchBlock.getCompositeActivity(); 28 29 Iterator caseElemIt = NodeUtil.getElements(switchElem, BpelConstants.NS_BPWS, BpelConstants.ELEM_CASE); 30 while (caseElemIt.hasNext()) { 32 Element caseElem = (Element ) caseElemIt.next(); 33 Element activityElement = bpelReader.getActivityElement(caseElem); 35 Activity child = bpelReader.readActivity(activityElement, switchBlock); 36 37 Element conditionElement = 39 NodeUtil.getElement(caseElem, BpelConstants.NS_BPWS, BpelConstants.ELEM_CONDITION); 40 41 Snippet condition = bpelReader.readExpression(conditionElement, parent); 42 switchBlock.setCondition(child, condition); 43 } 44 45 Element otherwiseElem = NodeUtil.getElement(switchElem, BpelConstants.NS_BPWS, BpelConstants.ELEM_OTHERWISE); 47 48 if (otherwiseElem != null) { 49 Element childElement = bpelReader.getActivityElement(otherwiseElem); 50 Activity otherwise = bpelReader.readActivity(childElement, switchBlock); 51 switchBlock.setOtherwise(otherwise); 52 } 53 } 54 } 55 | Popular Tags |