comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WMSLayerFacet.java @ 1190:f514894ec2fd

merged flys-artifacts/2.5
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:14:17 +0200
parents 1ea7eb72aaa6
children 092e1e5020bc
comparison
equal deleted inserted replaced
917:b48c36076e17 1190:f514894ec2fd
1 package de.intevation.flys.artifacts.model;
2
3 import java.util.ArrayList;
4 import java.util.List;
5
6 import org.apache.log4j.Logger;
7
8 import org.w3c.dom.Document;
9 import org.w3c.dom.Element;
10 import org.w3c.dom.Node;
11
12 import de.intevation.artifacts.Artifact;
13 import de.intevation.artifacts.ArtifactNamespaceContext;
14 import de.intevation.artifacts.CallContext;
15
16 import de.intevation.artifacts.common.utils.XMLUtils;
17 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator;
18
19 import de.intevation.artifactdatabase.state.DefaultFacet;
20 import de.intevation.artifactdatabase.state.Facet;
21
22 import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
23
24
25 public class WMSLayerFacet
26 extends DefaultFacet
27 {
28 protected ComputeType type;
29 protected List<String> layers;
30 protected String stateId;
31 protected String hash;
32 protected String url;
33 protected String extent;
34 protected String srid;
35
36
37 private static final Logger logger = Logger.getLogger(WMSLayerFacet.class);
38
39 public WMSLayerFacet() {
40 }
41
42
43 public WMSLayerFacet(int index, String name, String description) {
44 this(index, name, description, ComputeType.FEED, null, null);
45 }
46
47
48 public WMSLayerFacet(
49 int index,
50 String name,
51 String description,
52 ComputeType type,
53 String stateId,
54 String hash
55
56 ) {
57 super(index, name, description);
58 this.layers = new ArrayList<String>();
59 this.type = type;
60 this.stateId = stateId;
61 this.hash = hash;
62 }
63
64
65 public WMSLayerFacet(
66 int index,
67 String name,
68 String description,
69 ComputeType type,
70 String stateId,
71 String hash,
72 String url
73 ) {
74 this(index, name, description, type, stateId, hash);
75 this.url = url;
76 }
77
78
79 public void addLayer(String name) {
80 if (name != null && name.length() > 0) {
81 layers.add(name);
82 }
83 }
84
85
86 public void setExtent(String extent) {
87 if (extent != null) {
88 this.extent = extent;
89 }
90 }
91
92
93 public void setSrid(String srid) {
94 if (srid != null) {
95 this.srid = srid;
96 }
97 }
98
99
100 public Object getData(Artifact artifact, CallContext context) {
101 return null;
102 }
103
104
105 @Override
106 public Node toXML(Document doc) {
107 ElementCreator ec = new ElementCreator(
108 doc,
109 ArtifactNamespaceContext.NAMESPACE_URI,
110 ArtifactNamespaceContext.NAMESPACE_PREFIX);
111
112 Element facet = ec.create("facet");
113 ec.addAttr(facet, "description", description, true);
114 ec.addAttr(facet, "index", String.valueOf(index), true);
115 ec.addAttr(facet, "name", name, true);
116 ec.addAttr(facet, "url", url, true);
117 ec.addAttr(facet, "layers", layers.get(0), true);
118 ec.addAttr(facet, "extent", extent != null ? extent : "", true);
119 ec.addAttr(facet, "srid", srid != null ? srid : "", true);
120
121 return facet;
122 }
123
124 @Override
125 public Facet deepCopy() {
126 WMSLayerFacet copy = new WMSLayerFacet();
127 copy.set(this);
128
129 copy.type = type;
130 copy.layers = new ArrayList<String>(layers);
131 copy.stateId = stateId;
132 copy.hash = hash;
133 copy.url = url;
134 copy.extent = extent;
135 copy.srid = srid;
136
137 return copy;
138 }
139 }
140 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org