Mercurial > dive4elements > framework
comparison artifact-database/src/main/java/de/intevation/artifactdatabase/ProtocolUtils.java @ 295:e5bc48dc3ec3
Facets can write its internal representation to XML using a toXML() method now.
artifacts/trunk@2352 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 18 Jul 2011 15:05:20 +0000 |
parents | 995fa6994480 |
children | f367be55dd35 |
comparison
equal
deleted
inserted
replaced
294:b530e83acf2e | 295:e5bc48dc3ec3 |
---|---|
7 */ | 7 */ |
8 package de.intevation.artifactdatabase; | 8 package de.intevation.artifactdatabase; |
9 | 9 |
10 import java.util.List; | 10 import java.util.List; |
11 | 11 |
12 import org.w3c.dom.Document; | |
12 import org.w3c.dom.Element; | 13 import org.w3c.dom.Element; |
14 import org.w3c.dom.Node; | |
15 | |
16 import de.intevation.artifacts.ArtifactNamespaceContext; | |
13 | 17 |
14 import de.intevation.artifacts.common.utils.XMLUtils; | 18 import de.intevation.artifacts.common.utils.XMLUtils; |
19 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator; | |
15 | 20 |
16 import de.intevation.artifactdatabase.state.Facet; | 21 import de.intevation.artifactdatabase.state.Facet; |
17 import de.intevation.artifactdatabase.state.Output; | 22 import de.intevation.artifactdatabase.state.Output; |
18 import de.intevation.artifactdatabase.state.State; | 23 import de.intevation.artifactdatabase.state.State; |
19 | 24 |
155 * @param creator The ElementCreator used to create new elements. | 160 * @param creator The ElementCreator used to create new elements. |
156 * @param out The parent node for new elements. | 161 * @param out The parent node for new elements. |
157 * @param outputs The list of reachable outputs. | 162 * @param outputs The list of reachable outputs. |
158 */ | 163 */ |
159 public static void appendOutputModes( | 164 public static void appendOutputModes( |
160 XMLUtils.ElementCreator creator, | 165 Document doc, |
161 Element out, | 166 Element out, |
162 List<Output> outputs) | 167 List<Output> outputs) |
163 { | 168 { |
169 ElementCreator creator = new ElementCreator( | |
170 doc, | |
171 ArtifactNamespaceContext.NAMESPACE_URI, | |
172 ArtifactNamespaceContext.NAMESPACE_PREFIX); | |
173 | |
164 for (Output o: outputs) { | 174 for (Output o: outputs) { |
165 Element newOut = createArtNode( | 175 Element newOut = createArtNode( |
166 creator, | 176 creator, |
167 "output", | 177 "output", |
168 new String[] {"name", "description", "mime-type", "type"}, | 178 new String[] {"name", "description", "mime-type", "type"}, |
171 o.getDescription(), | 181 o.getDescription(), |
172 o.getMimeType(), | 182 o.getMimeType(), |
173 o.getType() }); | 183 o.getType() }); |
174 | 184 |
175 Element facets = createArtNode(creator, "facets", null, null); | 185 Element facets = createArtNode(creator, "facets", null, null); |
176 appendFacets(creator, facets, o.getFacets()); | 186 appendFacets(doc, facets, o.getFacets()); |
177 | 187 |
178 newOut.appendChild(facets); | 188 newOut.appendChild(facets); |
179 out.appendChild(newOut); | 189 out.appendChild(newOut); |
180 } | 190 } |
181 } | 191 } |
188 * @param creator The ElementCreator used to create new elements. | 198 * @param creator The ElementCreator used to create new elements. |
189 * @param facet The root node for new elements. | 199 * @param facet The root node for new elements. |
190 * @param facets The list of facets. | 200 * @param facets The list of facets. |
191 */ | 201 */ |
192 public static void appendFacets( | 202 public static void appendFacets( |
193 XMLUtils.ElementCreator creator, | 203 Document doc, |
194 Element facet, | 204 Element facet, |
195 List<Facet> facets) | 205 List<Facet> facets) |
196 { | 206 { |
197 if (facets == null || facets.size() == 0) { | 207 if (facets == null || facets.size() == 0) { |
198 return; | 208 return; |
199 } | 209 } |
200 | 210 |
211 ElementCreator creator = new ElementCreator( | |
212 doc, | |
213 ArtifactNamespaceContext.NAMESPACE_URI, | |
214 ArtifactNamespaceContext.NAMESPACE_PREFIX); | |
215 | |
201 for (Facet f: facets) { | 216 for (Facet f: facets) { |
202 Element newFacet = createArtNode( | 217 Node node = f.toXML(doc); |
203 creator, | 218 |
204 "facet", | 219 if (node != null) { |
205 new String[] { "index", "name", "description" }, | 220 facet.appendChild(node); |
206 new String[] { | 221 } |
207 String.valueOf(f.getIndex()), | |
208 f.getName(), | |
209 f.getDescription() | |
210 }); | |
211 | |
212 facet.appendChild(newFacet); | |
213 } | 222 } |
214 } | 223 } |
215 } | 224 } |
216 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: | 225 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: |