comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/ManagedFacet.java @ 4256:9a1a3406deb5

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

http://dive4elements.wald.intevation.org