1
2
3
4
5
6
7
8 package net.kwfgrid.gworkflowdl.structure;
9
10 import org.apache.log4j.Logger;
11 import org.jdom.Element;
12
13 /***
14 * hans
15 * Date: 02.05.2006
16 * Time: 11:41:43
17 */
18 public class JDOMOperation implements Operation {
19
20 static Logger logger = Logger.getLogger(JDOMOperation.class);
21 private Object obj;
22
23 public JDOMOperation() {
24 obj = Operation.DEFAULT_OBJECT;
25 }
26
27 /***
28 * get operation object. Can be of class <code>Element</code> or <code>OperationClass</code>.
29 */
30 public Object get() {
31 return obj;
32 }
33
34 /***
35 * set operation object.
36 */
37 public void set(Object object) {
38 this.obj = object;
39 }
40
41 /***
42 * set operation object.
43 */
44 public void set(OperationClass operationClass) {
45 this.obj = operationClass;
46 }
47
48 public final int getAbstractionLevel() {
49 if (obj != DEFAULT_OBJECT) {
50 if (obj instanceof OperationClass) return ((OperationClass) obj).getAbstractionLevel();
51 else return GREEN;
52 } else {
53 return RED;
54 }
55 }
56
57 public String toXML() {
58 String ret = "";
59 if (obj != null && obj instanceof Element) {
60 Element element = (Element) obj;
61 element.addNamespaceDeclaration(JdomString.NAMESPACE_XSD);
62 element.addNamespaceDeclaration(JdomString.NAMESPACE_XSI);
63 element.addNamespaceDeclaration(JdomString.NAMESPACE_SOAPENC);
64
65 try {
66 ret = JdomString.element2stringNoHeader(element);
67 } catch (java.io.IOException ex) {
68 logger.error("IOException during toXML()", ex);
69 }
70 } else {
71 logger.error("Object has wrong type: "+obj);
72 }
73
74 return ret;
75 }
76
77 public void fromXML(final String s) throws WorkflowFormatException {
78 obj = JdomString.string2element(s);
79 }
80
81 }