comparison artifact-database/src/main/java/de/intevation/artifactdatabase/ProtocolUtils.java @ 227:4bb6bfaca393

The output nodes written into the DESCRIBE document by ProtocolUtils have nodes for each facet supported by an output. artifacts/trunk@1627 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 30 Mar 2011 15:19:08 +0000
parents 435631e07da2
children 5ed1afd81569
comparison
equal deleted inserted replaced
226:41404961c804 227:4bb6bfaca393
11 11
12 import org.w3c.dom.Element; 12 import org.w3c.dom.Element;
13 13
14 import de.intevation.artifacts.common.utils.XMLUtils; 14 import de.intevation.artifacts.common.utils.XMLUtils;
15 15
16 import de.intevation.artifactdatabase.state.Facet;
16 import de.intevation.artifactdatabase.state.Output; 17 import de.intevation.artifactdatabase.state.Output;
17 import de.intevation.artifactdatabase.state.State; 18 import de.intevation.artifactdatabase.state.State;
18 19
19 20
20 /** 21 /**
145 146
146 root.appendChild(reachable); 147 root.appendChild(reachable);
147 } 148 }
148 149
149 150
151 /**
152 * This method appends a node for each Output in the <i>outputs</i> list to
153 * <i>out</i>. Note: an output node includes its provided facets!
154 *
155 * @param creator The ElementCreator used to create new elements.
156 * @param out The parent node for new elements.
157 * @param outputs The list of reachable outputs.
158 */
150 public static void appendOutputModes( 159 public static void appendOutputModes(
151 XMLUtils.ElementCreator creator, 160 XMLUtils.ElementCreator creator,
152 Element out, 161 Element out,
153 List<Output> outputs) 162 List<Output> outputs)
154 { 163 {
155 for (Output o: outputs) { 164 for (Output o: outputs) {
156 out.appendChild(createArtNode( 165 Element newOut = createArtNode(
157 creator, 166 creator,
158 "output", 167 "output",
159 new String[] {"name", "description", "mime-type"}, 168 new String[] {"name", "description", "mime-type"},
160 new String[] {o.getName(),o.getDescription(),o.getMimeType()})); 169 new String[] {o.getName(),o.getDescription(),o.getMimeType()});
170
171 Element facets = createArtNode(creator, "facets", null, null);
172 appendFacets(creator, facets, o.getFacets());
173
174 newOut.appendChild(facets);
175 out.appendChild(newOut);
176 }
177 }
178
179
180 /**
181 * This method appends a node for each Facet in the <i>facets</i> list to
182 * <i>facet</i>.
183 *
184 * @param creator The ElementCreator used to create new elements.
185 * @param facet The root node for new elements.
186 * @param facets The list of facets.
187 */
188 public static void appendFacets(
189 XMLUtils.ElementCreator creator,
190 Element facet,
191 List<Facet> facets)
192 {
193 if (facets == null || facets.size() == 0) {
194 return;
195 }
196
197 for (Facet f: facets) {
198 Element newFacet = createArtNode(
199 creator,
200 "facet",
201 new String[] { "name", "description" },
202 new String[] { f.getName(), f.getDescription() });
203
204 facet.appendChild(newFacet);
161 } 205 }
162 } 206 }
163 } 207 }
164 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: 208 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:

http://dive4elements.wald.intevation.org