comparison flys-artifacts/src/main/java/org/dive4elements/river/artifacts/model/ManagedFacet.java @ 5831:bd047b71ab37

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

http://dive4elements.wald.intevation.org