comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/ManagedFacet.java @ 3318:dbe2f85bf160

merged flys-artifacts/2.8
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:14:35 +0200
parents 5642a83420f2
children 8e66293c5369
comparison
equal deleted inserted replaced
2987:98c7a46ec5ae 3318:dbe2f85bf160
1 package de.intevation.flys.artifacts.model;
2
3 import org.apache.log4j.Logger;
4
5 import org.w3c.dom.Document;
6 import org.w3c.dom.Element;
7 import org.w3c.dom.Node;
8
9 import de.intevation.artifacts.ArtifactNamespaceContext;
10
11 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator;
12
13 import de.intevation.artifactdatabase.state.DefaultFacet;
14 import de.intevation.artifactdatabase.state.Facet;
15
16
17 /**
18 * Facet with user-supplied theme-control-information (pos in list,
19 * active/disabled etc) attached.
20 */
21 public class ManagedFacet extends DefaultFacet {
22
23 /** The uuid of the owner artifact. */
24 protected String uuid;
25
26 /** A property that determines the position of this facet. */
27 protected int position;
28
29 /** A property that determines if this facet is active or not. */
30 protected int active;
31
32 /** The logger that is used in this class. */
33 private static Logger logger = Logger.getLogger(ManagedFacet.class);
34
35 /** A property that determines if this facet is visible or not. */
36 protected int visible;
37
38
39 public ManagedFacet() {
40 }
41
42 public ManagedFacet(
43 String name,
44 int index,
45 String desc,
46 String uuid,
47 int pos,
48 int active,
49 int visible)
50 {
51 super(index, name, desc);
52
53 this.uuid = uuid;
54 this.position = pos;
55 this.active = active;
56 this.visible = visible;
57 }
58
59
60 /**
61 * Sets position (will be merged to position in ThemeList).
62 */
63 public void setPosition(int pos) {
64 this.position = pos;
65 }
66
67
68 public int getPosition() {
69 return position;
70 }
71
72
73 public void setActive(int active) {
74 this.active = active;
75 }
76
77
78 public int getActive() {
79 return active;
80 }
81
82
83 public void setVisible(int visible) {
84 this.visible = visible;
85 }
86
87
88 public int getVisible() {
89 return visible;
90 }
91
92
93 /**
94 * Get uuid of related artifact.
95 * @return uuid of related artifact.
96 */
97 public String getArtifact() {
98 return uuid;
99 }
100
101
102 public Node toXML(Document doc) {
103 ElementCreator ec = new ElementCreator(
104 doc,
105 ArtifactNamespaceContext.NAMESPACE_URI,
106 ArtifactNamespaceContext.NAMESPACE_PREFIX);
107
108 Element facet = ec.create("theme");
109 ec.addAttr(facet, "artifact", getArtifact(), true);
110 ec.addAttr(facet, "facet", getName(), true);
111 ec.addAttr(facet, "pos", String.valueOf(getPosition()), true);
112 ec.addAttr(facet, "active", String.valueOf(getActive()), true);
113 ec.addAttr(facet, "index", String.valueOf(getIndex()), true);
114 ec.addAttr(facet, "description", getDescription(), true);
115 ec.addAttr(facet, "visible", String.valueOf(getVisible()), true);
116
117 return facet;
118 }
119
120 public void set(ManagedFacet other) {
121 uuid = other.uuid;
122 position = other.position;
123 active = other.active;
124 }
125
126 @Override
127 public Facet deepCopy() {
128 ManagedFacet copy = new ManagedFacet();
129 copy.set((DefaultFacet)this);
130 copy.set((ManagedFacet)this);
131 return copy;
132 }
133 }
134 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org