Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/GNVDefaultArtifact.java @ 1119:7c4f81f74c47
merged gnv-artifacts
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:00 +0200 |
parents | dec4257ad570 |
children |
comparison
equal
deleted
inserted
replaced
1027:fca4b5eb8d2f | 1119:7c4f81f74c47 |
---|---|
1 /* | |
2 * Copyright (c) 2010 by Intevation GmbH | |
3 * | |
4 * This program is free software under the LGPL (>=v2.1) | |
5 * Read the file LGPL.txt coming with the software for details | |
6 * or visit http://www.gnu.org/licenses/ if it does not exist. | |
7 */ | |
8 | |
9 package de.intevation.gnv.artifacts; | |
10 | |
11 import de.intevation.artifactdatabase.DefaultArtifact; | |
12 import de.intevation.artifacts.common.utils.XMLUtils; | |
13 | |
14 import de.intevation.artifacts.ArtifactNamespaceContext; | |
15 import de.intevation.artifacts.CallContext; | |
16 import de.intevation.artifacts.CallMeta; | |
17 | |
18 import de.intevation.gnv.artifacts.ressource.RessourceFactory; | |
19 | |
20 import org.apache.log4j.Logger; | |
21 | |
22 import org.w3c.dom.Document; | |
23 import org.w3c.dom.Element; | |
24 | |
25 /** | |
26 * The default gnv artifact. The only thing defined here is a method to append | |
27 * the selected fis to the describe document. | |
28 * | |
29 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | |
30 */ | |
31 public class GNVDefaultArtifact extends DefaultArtifact { | |
32 | |
33 private static Logger logger = Logger.getLogger(GNVDefaultArtifact.class); | |
34 | |
35 /** | |
36 * | |
37 */ | |
38 public static final String EXCEPTION_NO_INPUT = "no.input.data"; | |
39 | |
40 | |
41 /** | |
42 * Constructor. | |
43 */ | |
44 public GNVDefaultArtifact() { | |
45 super(); | |
46 } | |
47 | |
48 | |
49 /** | |
50 * Append the selected fis to the describe document. | |
51 * | |
52 * @param document | |
53 * @param staticNode | |
54 * @param context | |
55 * @param fisName | |
56 */ | |
57 protected void appendFis( | |
58 Document document, | |
59 Element staticNode, | |
60 CallContext context, | |
61 String fisName | |
62 ) { | |
63 RessourceFactory resource = RessourceFactory.getInstance(); | |
64 CallMeta callMeta = (CallMeta) context.getMeta(); | |
65 | |
66 XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator( | |
67 document, | |
68 XMLUtils.XFORM_URL, | |
69 XMLUtils.XFORM_PREFIX | |
70 ); | |
71 | |
72 XMLUtils.ElementCreator artCreator = new XMLUtils.ElementCreator( | |
73 document, | |
74 ArtifactNamespaceContext.NAMESPACE_URI, | |
75 ArtifactNamespaceContext.NAMESPACE_PREFIX | |
76 ); | |
77 | |
78 Element selectNode = creator.create("select1"); | |
79 artCreator.addAttr(selectNode, "fis", "true", true); | |
80 | |
81 Element labelNode = creator.create("label"); | |
82 labelNode.setTextContent( | |
83 resource.getRessource(callMeta.getLanguages(), "fis", "fis") | |
84 ); | |
85 | |
86 Element choicesNode = creator.create("choices"); | |
87 | |
88 Element itemNode = creator.create("item"); | |
89 creator.addAttr(itemNode, "selected", "true"); | |
90 | |
91 Element choiceLabel = creator.create("label"); | |
92 choiceLabel.setTextContent(resource.getRessource( | |
93 callMeta.getLanguages(), | |
94 fisName, | |
95 fisName | |
96 )); | |
97 | |
98 Element choiceValue = creator.create("value"); | |
99 choiceValue.setTextContent(fisName); | |
100 | |
101 itemNode.appendChild(choiceLabel); | |
102 itemNode.appendChild(choiceValue); | |
103 choicesNode.appendChild(itemNode); | |
104 | |
105 selectNode.appendChild(labelNode); | |
106 selectNode.appendChild(choicesNode); | |
107 | |
108 staticNode.appendChild(selectNode); | |
109 } | |
110 } | |
111 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |