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 org.omwg.ontology.*; |
31 |
| import org.w3c.dom.*; |
32 |
| import org.wsmo.common.*; |
33 |
| import org.wsmo.common.exception.*; |
34 |
| import org.wsmo.mediator.*; |
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 |
| public class NodeWsml { |
46 |
| |
47 |
0
| static TopEntity deserialzieTopEntity(Node xmlNode, WsmlXmlParser parser)
|
48 |
| throws InvalidModelException, ParserException { |
49 |
0
| if (xmlNode == null || xmlNode.getNodeName() != "wsml") {
|
50 |
0
| throw new IllegalArgumentException();
|
51 |
| } |
52 |
| |
53 |
| |
54 |
| |
55 |
0
| NodeList nodes = xmlNode.getChildNodes();
|
56 |
0
| for (int i = 0; i < nodes.getLength(); i++) {
|
57 |
0
| Node node = nodes.item(i);
|
58 |
0
| if (node.getNodeName() == "ontology" && node.getNodeType() == Node.ELEMENT_NODE) {
|
59 |
0
| return NodeOntology.deserialize(node, parser);
|
60 |
| } |
61 |
0
| else if (node.getNodeName().endsWith("Mediator")
|
62 |
| && node.getNodeType() == Node.ELEMENT_NODE) { |
63 |
0
| return NodeMediator.processMediatorNode(node, parser);
|
64 |
| } |
65 |
0
| else if (node.getNodeName() == "goal" && node.getNodeType() == Node.ELEMENT_NODE) {
|
66 |
0
| return NodeGoal.deserialize(node, parser);
|
67 |
| } |
68 |
0
| else if (node.getNodeName() == "webService" && node.getNodeType() == Node.ELEMENT_NODE) {
|
69 |
0
| return NodeWebService.deserialize(node, parser);
|
70 |
| } |
71 |
| } |
72 |
| |
73 |
0
| return null;
|
74 |
| } |
75 |
| |
76 |
0
| public static Element serializeTopEntity(TopEntity[] entities, WsmlXmlSerializer serializer) {
|
77 |
0
| Element wsmlElement = serializer.createElement("wsml");
|
78 |
0
| for (int i = 0; i < entities.length; i++) {
|
79 |
0
| if (entities[i] instanceof Ontology) {
|
80 |
0
| wsmlElement.appendChild(NodeOntology.serialize((Ontology) entities[i], serializer));
|
81 |
| } |
82 |
0
| else if (entities[i] instanceof Mediator) {
|
83 |
0
| NodeMediator.serializeMediator(wsmlElement, (Mediator) entities[i], serializer);
|
84 |
| } |
85 |
0
| else if (entities[i] instanceof Goal) {
|
86 |
0
| wsmlElement.appendChild(NodeGoal.serialize((Goal) entities[i], serializer));
|
87 |
| } |
88 |
0
| else if (entities[i] instanceof WebService) {
|
89 |
0
| wsmlElement.appendChild(NodeWebService.serialize((WebService) entities[i], serializer));
|
90 |
| } |
91 |
| } |
92 |
| |
93 |
0
| return wsmlElement;
|
94 |
| } |
95 |
| } |
96 |
| |
97 |
| |
98 |
| |
99 |
| |
100 |
| |
101 |
| |
102 |
| |
103 |
| |
104 |
| |
105 |
| |
106 |
| |
107 |
| |
108 |
| |
109 |
| |
110 |
| |
111 |
| |