comparison gnv-artifacts/src/main/java/de/intevation/gnv/utils/MetaWriter.java @ 859:3fbabd4803d7

ISSUE252 Make it possible to export more than one Layer gnv-artifacts/trunk@983 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Mon, 26 Apr 2010 09:09:20 +0000
parents 164d102b0af5
children dfd02f8d3602
comparison
equal deleted inserted replaced
858:ec2265bb85a1 859:3fbabd4803d7
8 import java.util.Date; 8 import java.util.Date;
9 9
10 import org.apache.log4j.Logger; 10 import org.apache.log4j.Logger;
11 import org.w3c.dom.Document; 11 import org.w3c.dom.Document;
12 import org.w3c.dom.Element; 12 import org.w3c.dom.Element;
13 import org.w3c.dom.Node;
13 14
14 import de.intevation.artifactdatabase.XMLUtils; 15 import de.intevation.artifactdatabase.XMLUtils;
15 import de.intevation.artifacts.ArtifactNamespaceContext; 16 import de.intevation.artifacts.ArtifactNamespaceContext;
16 import de.intevation.artifacts.CallContext; 17 import de.intevation.artifacts.CallContext;
17 import de.intevation.gnv.artifacts.context.GNVArtifactContext; 18 import de.intevation.gnv.artifacts.context.GNVArtifactContext;
47 48
48 /** 49 /**
49 * Writes a meta information file for product type 'Layer'. 50 * Writes a meta information file for product type 'Layer'.
50 * 51 *
51 * @param context CallContext object. 52 * @param context CallContext object.
52 * @param uuid The UUID of the current artifact. 53 * @param meta the document where the information should be placed in.
53 * @param path The destination of the meta file.
54 * @param paramType The parameter type.
55 * @param layerType The layer type.
56 * @return the meta document. 54 * @return the meta document.
57 */ 55 */
58 public static Document writeLayerMeta(CallContext context, 56 public static Node writeLayerMeta(CallContext context, Document meta){
59 String uuid,
60 String path,
61 String paramType,
62 String layerType,
63 String shapefileName,
64 String title){
65 Document meta = XMLUtils.newDocument();
66 XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator( 57 XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator(
67 meta, 58 meta,
68 ArtifactNamespaceContext.NAMESPACE_URI, 59 ArtifactNamespaceContext.NAMESPACE_URI,
69 ArtifactNamespaceContext.NAMESPACE_PREFIX); 60 ArtifactNamespaceContext.NAMESPACE_PREFIX);
70 Element root = creator.create("meta"); 61 Element root = creator.create("meta");
71 meta.appendChild(root); 62 meta.appendChild(root);
72 63
73 writeAbstractMeta(context, meta, root); 64 writeAbstractMeta(context, meta, root);
74 writeLayerMeta(context, meta, root, uuid, paramType,layerType,shapefileName,title); 65 return root;
75 boolean success = writeMetaFile(path, meta);
76
77 if (success){
78 return meta;
79 }else{
80 return null;
81 }
82 } 66 }
83 67
84 68
85 /** 69 /**
86 * Writes a meta information file for product type 'Horizontalschnitt'. 70 * Writes a meta information file for product type 'Horizontalschnitt'.
123 * Method to write the <i>meta</i> document down to a file. 107 * Method to write the <i>meta</i> document down to a file.
124 * 108 *
125 * @param path The destination of the file. 109 * @param path The destination of the file.
126 * @param meta The xml document storing the meta information. 110 * @param meta The xml document storing the meta information.
127 */ 111 */
128 private static boolean writeMetaFile(String path, Document meta) { 112 public static boolean writeMetaFile(String path, Document meta) {
129 try { 113 try {
130 File metaFile = new File(path, META_FILE_NAME); 114 File metaFile = new File(path, META_FILE_NAME);
131 115
132 if (metaFile.exists()) { 116 if (metaFile.exists()) {
133 logger.info("Delete old meta information file."); 117 logger.info("Delete old meta information file.");
215 /** 199 /**
216 * Append layer information to the meta document. 200 * Append layer information to the meta document.
217 * 201 *
218 * @param callContext The CallContext object. 202 * @param callContext The CallContext object.
219 * @param document The meta document. 203 * @param document The meta document.
220 * @param meta The element where the new information need to be appended to. 204 * @param root The element where the new information need to be appended to.
221 * @param uuid The UUID of the current artifact. 205 * @param uuid The UUID of the current artifact.
222 * @param paramType The parameter type (e.g. salinity). 206 * @param paramType The parameter type (e.g. salinity).
223 * @param layerType The layer type. 207 * @param layerType The layer type.
224 */ 208 * @param shapefileName the name of the Shapefile
225 protected static void writeLayerMeta( 209 * @param shapefileName the Title of the Layer
210 */
211 public static void writeLayerMeta(
226 CallContext callContext, 212 CallContext callContext,
227 Document document, 213 Document document,
228 Element meta, 214 Node root,
229 String uuid, 215 String uuid,
230 String paramType, 216 String paramType,
231 String layerType, 217 String layerType,
232 String shapefileName, 218 String shapefileName,
233 String layerTitle 219 String layerTitle
267 layer.appendChild(type); 253 layer.appendChild(type);
268 layer.appendChild(status); 254 layer.appendChild(status);
269 layer.appendChild(data); 255 layer.appendChild(data);
270 layer.appendChild(timeToLive); 256 layer.appendChild(timeToLive);
271 257
272 meta.appendChild(layer); 258 root.appendChild(layer);
273 } 259 }
274 260
275 261
276 /** 262 /**
277 * Append polygon layer information to meta document. 263 * Append polygon layer information to meta document.

http://dive4elements.wald.intevation.org