001: /*
002: * Created on May 25, 2004
003: *
004: * TODO To change the template for this generated file go to
005: * Window - Preferences - Java - Code Style - Code Templates
006: */
007: package org.xdev.base.xssl.manage;
008:
009: import java.util.ArrayList;
010: import java.util.HashMap;
011: import java.util.List;
012: import org.jdom.Element;
013:
014: import org.jaxen.XPath;
015:
016: import org.xdev.base.xssl.XSSLAction;
017: import org.xdev.base.xssl.XSSLReturn;
018:
019: /**
020: * @author AYegorov
021: *
022: * TODO To change the template for this generated type comment go to
023: * Window - Preferences - Java - Code Style - Code Templates
024: */
025: public class TransactionGoto extends XSSLReturn {
026:
027: private Object returnValue = null;
028:
029: /**
030: * @param id
031: * @param properties
032: */
033: public TransactionGoto(String id) {
034: super (id);
035: // TODO Auto-generated constructor stub
036: }
037:
038: /**
039: * @param id
040: * @param properties
041: */
042: public TransactionGoto(String id, HashMap properties) {
043: super (id, properties);
044: // TODO Auto-generated constructor stub
045: }
046:
047: protected void set() throws Exception {
048: XPath xpath = this .getXPathProperty("path");
049:
050: List actions = xpath.selectNodes(this );
051:
052: int size = actions.size();
053:
054: Object action = null;
055:
056: List returnValues = new ArrayList();
057:
058: XSSLAction sourceParent = null;
059: XSSLAction targetParent = (XSSLAction) this
060: .getParentComponent();
061:
062: List children = targetParent.getChildren();
063:
064: List newChildren = new ArrayList();
065:
066: List sourceChildren = null;
067:
068: int sz = children.size();
069:
070: for (int j = 0; j < sz; j++) {
071: newChildren.add(((Element) children.get(0)).detach());
072: }
073:
074: for (int i = 0; i < size; i++) {
075: if ((action = actions.get(i)) instanceof XSSLAction) {
076: sourceParent = (XSSLAction) ((XSSLAction) action)
077: .getParentComponent();
078:
079: newChildren.add(newChildren.indexOf(this ) + 1,
080: ((XSSLAction) ((XSSLAction) action)
081: .newInstance(this .getRoot(),
082: targetParent)));
083:
084: if (!this .hasProperty("break")
085: || this .getBooleanProperty("break")) {
086: ((XSSLAction) action).breakExecution();
087: }
088:
089: }
090: }
091:
092: targetParent.setContent(newChildren);
093:
094: /*if (returnValues.size() == 0) {
095: this.returnValue = "";
096: }
097: else if (returnValues.size() == 1){
098: this.returnValue = returnValues.get(0);
099: }
100: else {
101: this.returnValue = returnValues;
102: }*/
103: }
104:
105: /* (non-Javadoc)
106: * @see org.xdev.base.xssl.XSSLReturn#getValue()
107: */
108: public Object getObjectValue() {
109: return this.returnValue;
110: }
111: }
|