Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WMSLayerFacet.java @ 3812:f788d2d901d6
merged flys-artifacts/pre2.6-2011-12-05
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:53 +0200 |
parents | a80d33a3bcca |
children | 8cb679d4ec49 |
comparison
equal
deleted
inserted
replaced
3808:5fab0fe3c445 | 3812:f788d2d901d6 |
---|---|
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 com.vividsolutions.jts.geom.Envelope; | |
13 | |
14 import de.intevation.artifacts.Artifact; | |
15 import de.intevation.artifacts.ArtifactNamespaceContext; | |
16 import de.intevation.artifacts.CallContext; | |
17 | |
18 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator; | |
19 | |
20 import de.intevation.artifactdatabase.state.DefaultFacet; | |
21 import de.intevation.artifactdatabase.state.Facet; | |
22 | |
23 import de.intevation.flys.artifacts.states.DefaultState.ComputeType; | |
24 import de.intevation.flys.utils.GeometryUtils; | |
25 | |
26 | |
27 public class WMSLayerFacet | |
28 extends DefaultFacet | |
29 { | |
30 protected ComputeType type; | |
31 protected List<String> layers; | |
32 protected String stateId; | |
33 protected String hash; | |
34 protected String url; | |
35 protected Envelope extent; | |
36 protected String srid; | |
37 | |
38 | |
39 private static final Logger logger = Logger.getLogger(WMSLayerFacet.class); | |
40 | |
41 public WMSLayerFacet() { | |
42 } | |
43 | |
44 | |
45 public WMSLayerFacet(int index, String name, String description) { | |
46 this(index, name, description, ComputeType.FEED, null, null); | |
47 } | |
48 | |
49 | |
50 public WMSLayerFacet( | |
51 int index, | |
52 String name, | |
53 String description, | |
54 ComputeType type, | |
55 String stateId, | |
56 String hash | |
57 | |
58 ) { | |
59 super(index, name, description); | |
60 this.layers = new ArrayList<String>(); | |
61 this.type = type; | |
62 this.stateId = stateId; | |
63 this.hash = hash; | |
64 } | |
65 | |
66 | |
67 public WMSLayerFacet( | |
68 int index, | |
69 String name, | |
70 String description, | |
71 ComputeType type, | |
72 String stateId, | |
73 String hash, | |
74 String url | |
75 ) { | |
76 this(index, name, description, type, stateId, hash); | |
77 this.url = url; | |
78 } | |
79 | |
80 | |
81 public void addLayer(String name) { | |
82 if (name != null && name.length() > 0) { | |
83 layers.add(name); | |
84 } | |
85 } | |
86 | |
87 | |
88 public void setExtent(Envelope extent) { | |
89 if (extent != null) { | |
90 this.extent = extent; | |
91 } | |
92 } | |
93 | |
94 | |
95 public Envelope getExtent() { | |
96 return extent; | |
97 } | |
98 | |
99 | |
100 public void setSrid(String srid) { | |
101 if (srid != null) { | |
102 this.srid = srid; | |
103 } | |
104 } | |
105 | |
106 | |
107 public String getSrid() { | |
108 return srid; | |
109 } | |
110 | |
111 | |
112 public Object getData(Artifact artifact, CallContext context) { | |
113 return null; | |
114 } | |
115 | |
116 | |
117 @Override | |
118 public Node toXML(Document doc) { | |
119 ElementCreator ec = new ElementCreator( | |
120 doc, | |
121 ArtifactNamespaceContext.NAMESPACE_URI, | |
122 ArtifactNamespaceContext.NAMESPACE_PREFIX); | |
123 | |
124 Element facet = ec.create("facet"); | |
125 ec.addAttr(facet, "description", description, true); | |
126 ec.addAttr(facet, "index", String.valueOf(index), true); | |
127 ec.addAttr(facet, "name", name, true); | |
128 ec.addAttr(facet, "url", url, true); | |
129 ec.addAttr(facet, "layers", layers.get(0), true); | |
130 ec.addAttr(facet, "srid", srid != null ? srid : "", true); | |
131 ec.addAttr(facet, "extent", extent != null | |
132 ? GeometryUtils.jtsBoundsToOLBounds(extent) | |
133 : "", true); | |
134 ec.addAttr(facet, "queryable", String.valueOf(isQueryable()), true); | |
135 | |
136 return facet; | |
137 } | |
138 | |
139 | |
140 public boolean isQueryable() { | |
141 return false; | |
142 } | |
143 | |
144 | |
145 @Override | |
146 public Facet deepCopy() { | |
147 WMSLayerFacet copy = new WMSLayerFacet(); | |
148 copy.set(this); | |
149 | |
150 copy.type = type; | |
151 copy.layers = new ArrayList<String>(layers); | |
152 copy.stateId = stateId; | |
153 copy.hash = hash; | |
154 copy.url = url; | |
155 copy.extent = extent; | |
156 copy.srid = srid; | |
157 | |
158 return copy; | |
159 } | |
160 } | |
161 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |