Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/utils/MetaWriter.java @ 806:2cea76f1112e
Added Javadoc in utils package.
gnv-artifacts/trunk@888 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 08 Apr 2010 13:10:39 +0000 |
parents | c4156275c1e1 |
children | a645bd23c1c8 |
comparison
equal
deleted
inserted
replaced
805:bb7afd783321 | 806:2cea76f1112e |
---|---|
21 | 21 |
22 import org.w3c.dom.Document; | 22 import org.w3c.dom.Document; |
23 import org.w3c.dom.Element; | 23 import org.w3c.dom.Element; |
24 | 24 |
25 /** | 25 /** |
26 * This class provides some methods to create files storing meta information | |
27 * about wms layers and a map service which serves these layers. | |
28 * | |
26 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | 29 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
27 */ | 30 */ |
28 public class MetaWriter { | 31 public class MetaWriter { |
29 | 32 |
30 private static Logger logger = Logger.getLogger(MetaWriter.class); | 33 private static Logger logger = Logger.getLogger(MetaWriter.class); |
39 public static final String POLYGON_NAME = "polygons.shp"; | 42 public static final String POLYGON_NAME = "polygons.shp"; |
40 public static final String LAYER_DATA_NAME = "data.shp"; | 43 public static final String LAYER_DATA_NAME = "data.shp"; |
41 | 44 |
42 public static final String CONTEXT_LAYER_TITLE = "wms.title"; | 45 public static final String CONTEXT_LAYER_TITLE = "wms.title"; |
43 | 46 |
47 /** | |
48 * Constructor. | |
49 */ | |
44 private MetaWriter() { | 50 private MetaWriter() { |
45 } | 51 } |
46 | 52 |
53 /** | |
54 * Writes a meta information file for product type 'Layer'. | |
55 * | |
56 * @param context CallContext object. | |
57 * @param uuid The UUID of the current artifact. | |
58 * @param path The destination of the meta file. | |
59 * @param paramType The parameter type. | |
60 * @param layerType The layer type. | |
61 * @return the meta document. | |
62 */ | |
47 public static Document writeLayerMeta(CallContext context, | 63 public static Document writeLayerMeta(CallContext context, |
48 String uuid, | 64 String uuid, |
49 String path, | 65 String path, |
50 String paramType, | 66 String paramType, |
51 String layerType){ | 67 String layerType){ |
66 }else{ | 82 }else{ |
67 return null; | 83 return null; |
68 } | 84 } |
69 } | 85 } |
70 | 86 |
87 | |
88 /** | |
89 * Writes a meta information file for product type 'Horizontalschnitt'. | |
90 * | |
91 * @param context The CallContext object. | |
92 * @param uuid The UUID of the current artifact. | |
93 * @param path The destination of the meta file. | |
94 * @param paramType The parameter type. | |
95 * @return the meta document. | |
96 */ | |
71 public static Document writeHorizontalcrosssectionMeta( | 97 public static Document writeHorizontalcrosssectionMeta( |
72 CallContext context, | 98 CallContext context, |
73 String uuid, | 99 String uuid, |
74 String path, | 100 String path, |
75 String paramType) | 101 String paramType) |
82 | 108 |
83 Element root = creator.create("meta"); | 109 Element root = creator.create("meta"); |
84 meta.appendChild(root); | 110 meta.appendChild(root); |
85 | 111 |
86 writeAbstractMeta(context, meta, root); | 112 writeAbstractMeta(context, meta, root); |
87 writePolygonMeta(context, meta, root, uuid, path, paramType); | 113 writePolygonMeta(context, meta, root, uuid, paramType); |
88 writeIsolineMeta(context, meta, root, uuid, path, paramType); | 114 writeIsolineMeta(context, meta, root, uuid, paramType); |
89 | 115 |
90 boolean success = writeMetaFile(path, meta); | 116 boolean success = writeMetaFile(path, meta); |
91 | 117 |
92 if (success){ | 118 if (success){ |
93 return meta; | 119 return meta; |
95 return null; | 121 return null; |
96 } | 122 } |
97 } | 123 } |
98 | 124 |
99 /** | 125 /** |
100 * @param path | 126 * Method to write the <i>meta</i> document down to a file. |
101 * @param meta | 127 * |
128 * @param path The destination of the file. | |
129 * @param meta The xml document storing the meta information. | |
102 */ | 130 */ |
103 private static boolean writeMetaFile(String path, Document meta) { | 131 private static boolean writeMetaFile(String path, Document meta) { |
104 try { | 132 try { |
105 File metaFile = new File(path, META_FILE_NAME); | 133 File metaFile = new File(path, META_FILE_NAME); |
106 | 134 |
142 return false; | 170 return false; |
143 } | 171 } |
144 } | 172 } |
145 | 173 |
146 | 174 |
175 /** | |
176 * Append meta information about the mapservice itself. | |
177 * | |
178 * @param callContext The CallContext object. | |
179 * @param document The meta information document. | |
180 * @param meta The element where the new information need to be appended to. | |
181 */ | |
147 public static void writeAbstractMeta( | 182 public static void writeAbstractMeta( |
148 CallContext callContext, | 183 CallContext callContext, |
149 Document document, | 184 Document document, |
150 Element meta | 185 Element meta |
151 ) { | 186 ) { |
178 mapserver.appendChild(serverPath); | 213 mapserver.appendChild(serverPath); |
179 mapserver.appendChild(mapPath); | 214 mapserver.appendChild(mapPath); |
180 meta.appendChild(mapserver); | 215 meta.appendChild(mapserver); |
181 } | 216 } |
182 | 217 |
218 /** | |
219 * Append layer information to the meta document. | |
220 * | |
221 * @param callContext The CallContext object. | |
222 * @param document The meta document. | |
223 * @param meta The element where the new information need to be appended to. | |
224 * @param uuid The UUID of the current artifact. | |
225 * @param paramType The parameter type (e.g. salinity). | |
226 * @param layerType The layer type. | |
227 */ | |
183 protected static void writeLayerMeta( | 228 protected static void writeLayerMeta( |
184 CallContext callContext, | 229 CallContext callContext, |
185 Document document, | 230 Document document, |
186 Element meta, | 231 Element meta, |
187 String uuid, | 232 String uuid, |
223 | 268 |
224 meta.appendChild(layer); | 269 meta.appendChild(layer); |
225 } | 270 } |
226 | 271 |
227 | 272 |
273 /** | |
274 * Append polygon layer information to meta document. | |
275 * | |
276 * @param context | |
277 * @param document The meta document. | |
278 * @param meta The element where the new information need to be appended to. | |
279 * @param uuid The UUID of the current artifact. | |
280 * @param paramType The parameter type (e.g. salinity). | |
281 */ | |
228 public static void writePolygonMeta( | 282 public static void writePolygonMeta( |
229 CallContext context, | 283 CallContext context, |
230 Document document, | 284 Document document, |
231 Element meta, | 285 Element meta, |
232 String uuid, | 286 String uuid, |
233 String path, | |
234 String paramType | 287 String paramType |
235 ) { | 288 ) { |
236 XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator( | 289 XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator( |
237 document, | 290 document, |
238 ArtifactNamespaceContext.NAMESPACE_URI, | 291 ArtifactNamespaceContext.NAMESPACE_URI, |
272 | 325 |
273 meta.appendChild(layer); | 326 meta.appendChild(layer); |
274 } | 327 } |
275 | 328 |
276 | 329 |
330 /** | |
331 * Append isoline layer information to meta document. | |
332 * | |
333 * @param context | |
334 * @param document The meta document. | |
335 * @param meta The element where the new information need to be appended to. | |
336 * @param uuid The UUID of the current artifact. | |
337 * @param paramType The parameter type (e.g. salinity). | |
338 */ | |
277 public static void writeIsolineMeta( | 339 public static void writeIsolineMeta( |
278 CallContext context, | 340 CallContext context, |
279 Document document, | 341 Document document, |
280 Element meta, | 342 Element meta, |
281 String uuid, | 343 String uuid, |
282 String path, | |
283 String paramType | 344 String paramType |
284 ) { | 345 ) { |
285 XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator( | 346 XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator( |
286 document, | 347 document, |
287 ArtifactNamespaceContext.NAMESPACE_URI, | 348 ArtifactNamespaceContext.NAMESPACE_URI, |