comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/ManagedDomFacet.java @ 945:59ae2a823e73

Use the Facet.toXML() method to write facet elements into the DESCRIBE document of the Collection. flys-artifacts/trunk@2360 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 19 Jul 2011 10:37:57 +0000
parents
children c2edf0032cf8
comparison
equal deleted inserted replaced
944:c256061287d7 945:59ae2a823e73
1 package de.intevation.flys.artifacts.model;
2
3 import org.w3c.dom.Document;
4 import org.w3c.dom.Element;
5 import org.w3c.dom.Node;
6
7 import de.intevation.artifacts.ArtifactNamespaceContext;
8
9
10 public class ManagedDomFacet extends ManagedFacet {
11
12 protected Element facet;
13
14
15 public ManagedDomFacet(Element facet) {
16 super(null, -1, null, null, -1, -1);
17
18 this.facet = facet;
19 }
20
21
22 @Override
23 public int getIndex() {
24 if (this.index < 0) {
25 String index = facet.getAttributeNS(
26 ArtifactNamespaceContext.NAMESPACE_URI, "index");
27
28 if (index != null && index.length() > 0) {
29 this.index = Integer.parseInt(index);
30 }
31 }
32
33 return this.index;
34 }
35
36
37 @Override
38 public String getName() {
39 if (this.name == null || this.name.length() == 0) {
40 String name = facet.getAttributeNS(
41 ArtifactNamespaceContext.NAMESPACE_URI, "facet");
42
43 this.name = name;
44 }
45
46 return this.name;
47 }
48
49
50 @Override
51 public String getDescription() {
52 if (this.description == null || this.description.length() == 0) {
53 String description = facet.getAttributeNS(
54 ArtifactNamespaceContext.NAMESPACE_URI, "description");
55
56 this.description = description;
57 }
58
59 return this.description;
60 }
61
62
63 @Override
64 public int getPosition() {
65 if (this.position < 0) {
66 String position = facet.getAttributeNS(
67 ArtifactNamespaceContext.NAMESPACE_URI, "pos");
68
69 if (position != null && position.length() > 0) {
70 this.position = Integer.parseInt(position);
71 }
72 }
73
74 return this.position;
75 }
76
77
78 @Override
79 public void setPosition(int position) {
80 this.position = position;
81
82 facet.setAttributeNS(
83 ArtifactNamespaceContext.NAMESPACE_URI,
84 "pos",
85 String.valueOf(position));
86 }
87
88
89 @Override
90 public int getActive() {
91 if (this.active < 0) {
92 String active = facet.getAttributeNS(
93 ArtifactNamespaceContext.NAMESPACE_URI, "active");
94
95 if (active != null && active.length() > 0) {
96 this.active = Integer.parseInt(active);
97 }
98 }
99
100 return this.active;
101 }
102
103
104 @Override
105 public void setActive(int active) {
106 this.active = active;
107
108 facet.setAttributeNS(
109 ArtifactNamespaceContext.NAMESPACE_URI,
110 "active",
111 String.valueOf(active));
112 }
113
114
115 @Override
116 public String getArtifact() {
117 if (this.uuid == null || this.uuid.length() == 0) {
118 String uuid = facet.getAttributeNS(
119 ArtifactNamespaceContext.NAMESPACE_URI, "artifact");
120
121 this.uuid = uuid;
122 }
123
124 return this.uuid;
125 }
126
127
128 @Override
129 public Node toXML(Document doc) {
130 return doc.importNode(facet, true);
131 }
132 }
133 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org