1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| |
17 |
| |
18 |
| package com.ontotext.wsmo4j.parser.xml; |
19 |
| |
20 |
| |
21 |
| |
22 |
| |
23 |
| |
24 |
| |
25 |
| |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| import java.util.*; |
31 |
| |
32 |
| import org.w3c.dom.*; |
33 |
| import org.wsmo.common.*; |
34 |
| import org.wsmo.common.exception.*; |
35 |
| import org.wsmo.service.*; |
36 |
| import org.wsmo.wsml.*; |
37 |
| |
38 |
| import com.ontotext.wsmo4j.serializer.xml.*; |
39 |
| |
40 |
| |
41 |
| |
42 |
| |
43 |
| |
44 |
| |
45 |
| class NodeGoal { |
46 |
0
| static Goal deserialize(Node xmlNode, WsmlXmlParser parser) throws InvalidModelException,
|
47 |
| ParserException { |
48 |
0
| if (xmlNode == null || parser == null || xmlNode.getNodeName() != "goal"
|
49 |
| || xmlNode.getNodeType() != Element.ELEMENT_NODE) { |
50 |
0
| throw new IllegalArgumentException();
|
51 |
| } |
52 |
| |
53 |
0
| IRI goalIri = parser.getFactory().createIRI(WsmlXmlHelper.getAttrValue(xmlNode, "name"));
|
54 |
0
| Goal goal = parser.getFactory().createGoal(goalIri);
|
55 |
0
| NodeTopEntity.processTopEntityNode(goal, xmlNode, parser);
|
56 |
0
| NodeList nodes = xmlNode.getChildNodes();
|
57 |
| |
58 |
0
| for (int i = 0; i < nodes.getLength(); i++) {
|
59 |
0
| Node node = nodes.item(i);
|
60 |
0
| if (node.getNodeName() == "nonFunctionalProperties") {
|
61 |
0
| NodeNFP.deserialize(goal, node, parser);
|
62 |
| } |
63 |
0
| else if (node.getNodeName() == "capability") {
|
64 |
0
| goal.setCapability(NodeCapability.deserialize(node, parser));
|
65 |
| } |
66 |
0
| else if (node.getNodeName() == "interface") {
|
67 |
0
| goal.addInterface(NodeInterface.deserialize(node, parser));
|
68 |
| } |
69 |
| } |
70 |
| |
71 |
0
| return goal;
|
72 |
| } |
73 |
| |
74 |
0
| static Element serialize(Goal goal, WsmlXmlSerializer serializer) {
|
75 |
0
| Element goalElement = serializer.createElement("goal");
|
76 |
0
| goalElement.setAttribute("name", goal.getIdentifier().toString());
|
77 |
0
| NodeTopEntity.serializeTopEntity(goalElement, goal, serializer);
|
78 |
| |
79 |
0
| if (!goal.listNFPValues().isEmpty()) {
|
80 |
0
| NodeNFP.serialize(goalElement, goal, serializer);
|
81 |
| } |
82 |
| |
83 |
0
| goalElement.appendChild(NodeCapability.serialize(goal.getCapability(), serializer));
|
84 |
| |
85 |
0
| if (!goal.listInterfaces().isEmpty()) {
|
86 |
0
| for (Iterator i = goal.listInterfaces().iterator(); i.hasNext();) {
|
87 |
0
| Interface intrface = (Interface) i.next();
|
88 |
0
| goalElement.appendChild(NodeInterface.serialize(intrface, serializer));
|
89 |
| } |
90 |
| } |
91 |
| |
92 |
0
| return goalElement;
|
93 |
| } |
94 |
| } |
95 |
| |
96 |
| |
97 |
| |
98 |
| |
99 |
| |
100 |
| |
101 |
| |
102 |
| |
103 |
| |
104 |
| |
105 |
| |
106 |
| |
107 |
| |
108 |
| |
109 |
| |
110 |
| |
111 |
| |
112 |
| |
113 |
| |
114 |
| |