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 |
| import org.w3c.dom.*; |
21 |
| import org.wsmo.common.*; |
22 |
| import org.wsmo.common.Entity; |
23 |
| import org.wsmo.common.exception.*; |
24 |
| |
25 |
| import com.ontotext.wsmo4j.serializer.xml.*; |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| |
31 |
| |
32 |
| |
33 |
| |
34 |
| |
35 |
| |
36 |
| public class NodeTopEntity { |
37 |
| |
38 |
0
| static void processTopEntityNode(TopEntity te, Node xmlNode, WsmlXmlParser parser)
|
39 |
| throws InvalidModelException { |
40 |
0
| if (te == null || xmlNode == null || parser == null
|
41 |
| || xmlNode.getNodeType() != Element.ELEMENT_NODE) { |
42 |
0
| throw new IllegalArgumentException();
|
43 |
| } |
44 |
| |
45 |
0
| NodeList nodes = xmlNode.getChildNodes();
|
46 |
0
| for (int i = 0; i < nodes.getLength(); i++) {
|
47 |
0
| Node node = nodes.item(i);
|
48 |
0
| if (node.getNodeName() == "importsOntology") {
|
49 |
0
| te.addOntology(parser.getFactory().createOntology(
|
50 |
| parser.getFactory().createIRI(WsmlXmlHelper.getElementText(node)))); |
51 |
| } |
52 |
0
| else if (node.getNodeName() == "usesMediator") {
|
53 |
0
| IRI iri = parser.getFactory().createIRI(WsmlXmlHelper.getElementText(node));
|
54 |
0
| te.addMediator(iri);
|
55 |
| } |
56 |
| } |
57 |
| } |
58 |
| |
59 |
0
| static void serializeTopEntity(Element parent, TopEntity te, WsmlXmlSerializer serializer) {
|
60 |
0
| if (!te.listOntologies().isEmpty()) {
|
61 |
0
| Object[] entities = te.listOntologies().toArray();
|
62 |
0
| for (int i = 0; i < entities.length; i++) {
|
63 |
0
| Element importOnto = serializer.createElement("importsOntology");
|
64 |
0
| parent.appendChild(importOnto);
|
65 |
0
| importOnto.appendChild(serializer.createTextNode(((Entity) entities[i])
|
66 |
| .getIdentifier().toString())); |
67 |
| } |
68 |
| } |
69 |
| |
70 |
0
| if (!te.listMediators().isEmpty()) {
|
71 |
0
| Object[] entities = te.listMediators().toArray();
|
72 |
0
| for (int i = 0; i < entities.length; i++) {
|
73 |
0
| Element useMediator = serializer.createElement("usesMediator");
|
74 |
0
| parent.appendChild(useMediator);
|
75 |
0
| useMediator.appendChild(serializer.createTextNode(((Identifier) entities[i])
|
76 |
| .toString())); |
77 |
| } |
78 |
| } |
79 |
| } |
80 |
| } |
81 |
| |
82 |
| |
83 |
| |
84 |
| |
85 |
| |
86 |
| |
87 |
| |
88 |
| |
89 |
| |
90 |
| |