comparison gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/fis/SelectProductArtifact.java @ 792:9b9bf42b7928

Added and repaired JavaDoc in artifacts package. gnv-artifacts/trunk@874 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 31 Mar 2010 10:52:34 +0000
parents c4156275c1e1
children feae2f9d6c6f
comparison
equal deleted inserted replaced
791:23877dd69444 792:9b9bf42b7928
37 import org.w3c.dom.Element; 37 import org.w3c.dom.Element;
38 import org.w3c.dom.Node; 38 import org.w3c.dom.Node;
39 import org.w3c.dom.NodeList; 39 import org.w3c.dom.NodeList;
40 40
41 /** 41 /**
42 * This artifact is used to handle to input/output at the beginning of a
43 * parameterization when no product has been selected so far. After the user
44 * having selected a product, this artifact is replaced by a concrete product
45 * artifact.
46 *
42 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> 47 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
43 */ 48 */
44 public class SelectProductArtifact extends GNVDefaultArtifact { 49 public class SelectProductArtifact extends GNVDefaultArtifact {
45 50
46 /** 51 /**
47 * THE UID of this Class. 52 * THE UID of this Class.
48 */ 53 */
49 private static final long serialVersionUID = -7952357683127758677L; 54 private static final long serialVersionUID = -7952357683127758677L;
50 55
56 /**
57 * Path to uuid.
58 */
51 public static final String XPATH_UUID = "art:action/art:uuid/@value"; 59 public static final String XPATH_UUID = "art:action/art:uuid/@value";
52 60
61 /**
62 * Path to hash.
63 */
53 public static final String XPATH_HASH = "art:action/art:hash/@value"; 64 public static final String XPATH_HASH = "art:action/art:hash/@value";
54 65
66 /**
67 * Path to selected product.
68 */
55 public static final String XPATH_INPUT_DATA_VALUE = 69 public static final String XPATH_INPUT_DATA_VALUE =
56 "art:action/art:data/art:input[@name='product']/@value"; 70 "art:action/art:data/art:input[@name='product']/@value";
57 71
72 /**
73 * Path to parameters required by the factory.
74 */
58 public static final String XPATH_SETUP_PARAMETER_NODES = 75 public static final String XPATH_SETUP_PARAMETER_NODES =
59 "/art:action/art:factory/art:parameter"; 76 "/art:action/art:factory/art:parameter";
60 77
78 /**
79 *
80 */
61 public static final String XFORM_URL = "http://www.w3.org/2002/xforms"; 81 public static final String XFORM_URL = "http://www.w3.org/2002/xforms";
82
83 /**
84 * Prefix used in the user interface description part of the describe
85 * document.
86 */
62 public static final String XFORM_PREFIX = "xform"; 87 public static final String XFORM_PREFIX = "xform";
63 88
64 private static Logger log = Logger.getLogger(SelectProductArtifact.class); 89 private static Logger log = Logger.getLogger(SelectProductArtifact.class);
65 90
66 private Map products; 91 private Map products;
68 private Artifact artifact; 93 private Artifact artifact;
69 private String name; 94 private String name;
70 95
71 private Map<String, InputData> preSettings = null; 96 private Map<String, InputData> preSettings = null;
72 97
98 /**
99 * Constructor.
100 */
73 public SelectProductArtifact() { 101 public SelectProductArtifact() {
74 super(); 102 super();
75 } 103 }
76 104
77 105
106 /**
107 * Initialize this artifact and parse all required information from <code>
108 * data</code> document.
109 *
110 * @param identifier
111 * @param factory
112 * @param context
113 * @param data
114 */
78 @Override 115 @Override
79 public void setup( 116 public void setup(
80 String identifier, 117 String identifier,
81 ArtifactFactory factory, 118 ArtifactFactory factory,
82 Object context, 119 Object context,
110 } 147 }
111 148
112 } 149 }
113 150
114 151
152 /**
153 *
154 * @param products
155 */
115 public void setProducts(Map products) { 156 public void setProducts(Map products) {
116 this.products = products; 157 this.products = products;
117 } 158 }
118 159
119 160
161 /**
162 * Search for a selected product and create a new concrecte product artifact
163 * with this information.
164 *
165 * @param target Document which contains the selected product.
166 * @param context CallContext.
167 * @return Error or success message.
168 */
120 @Override 169 @Override
121 public Document feed(Document target, CallContext context) { 170 public Document feed(Document target, CallContext context) {
122 log.debug("SelectProductArtifact.feed()"); 171 log.debug("SelectProductArtifact.feed()");
123 172
124 if (artifact == null) { 173 if (artifact == null) {
164 return artifact.feed(target, context); 213 return artifact.feed(target, context);
165 } 214 }
166 } 215 }
167 216
168 217
218 /**
219 * If {@link #feed(org.w3c.dom.Document, de.intevation.artifacts.CallContext)}
220 * was sucessfully called before, this artifact is replaced with a concrete
221 * product artifact.
222 *
223 * @param target
224 * @param context
225 * @return
226 */
169 @Override 227 @Override
170 public Document advance(Document target, CallContext context) { 228 public Document advance(Document target, CallContext context) {
171 log.debug("SelectProductArtifact.advance()"); 229 log.debug("SelectProductArtifact.advance()");
172 230
173 if (artifact != null) { 231 if (artifact != null) {
226 context.putContextValue(ProxyArtifact.REPLACE_PROXY, artifact); 284 context.putContextValue(ProxyArtifact.REPLACE_PROXY, artifact);
227 return result; 285 return result;
228 } 286 }
229 287
230 288
289 /**
290 * Create a describe document including the user interface description. The
291 * user gets the choice to select a product supported by the current fis.
292 *
293 * @param data
294 * @param context
295 * @return
296 */
231 @Override 297 @Override
232 public Document describe(Document data, CallContext context) { 298 public Document describe(Document data, CallContext context) {
233 log.debug("SelectProductArtifact.describe()"); 299 log.debug("SelectProductArtifact.describe()");
234 300
235 // create root node 301 // create root node
291 357
292 return document; 358 return document;
293 } 359 }
294 360
295 361
362 /**
363 *
364 * @param document
365 * @param out
366 * @param context
367 * @throws IOException
368 */
296 @Override 369 @Override
297 public void out(Document document, OutputStream out, CallContext context) 370 public void out(Document document, OutputStream out, CallContext context)
298 throws IOException 371 throws IOException
299 { 372 {
300 log.debug("SelectProductArtifact.out()"); 373 log.debug("SelectProductArtifact.out()");
302 artifact.out(document, out, context); 375 artifact.out(document, out, context);
303 } 376 }
304 } 377 }
305 378
306 379
380 /**
381 * Append products to the describe document.
382 *
383 * @param document
384 * @param parent
385 * @param context
386 */
307 protected void appendProducts( 387 protected void appendProducts(
308 Document document, 388 Document document,
309 Node parent, 389 Node parent,
310 Object context 390 Object context
311 ) { 391 ) {
327 parent.appendChild(current); 407 parent.appendChild(current);
328 } 408 }
329 } 409 }
330 410
331 411
412 /**
413 * Append the product select box to the user interface description of the
414 * describe document.
415 *
416 * @param document
417 * @param node
418 * @param callMeta
419 */
332 protected void appendSelectProducts( 420 protected void appendSelectProducts(
333 Document document, 421 Document document,
334 Node node, 422 Node node,
335 CallMeta callMeta 423 CallMeta callMeta
336 ) { 424 ) {
377 465
378 node.appendChild(selectNode); 466 node.appendChild(selectNode);
379 } 467 }
380 468
381 469
470 /**
471 * Create a feed document.
472 *
473 * @param uuid
474 * @param hash
475 * @return
476 */
382 protected Document feedDocument(String uuid, String hash) { 477 protected Document feedDocument(String uuid, String hash) {
383 Document document = XMLUtils.newDocument(); 478 Document document = XMLUtils.newDocument();
384 479
385 XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator( 480 XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator(
386 document, 481 document,
419 } 514 }
420 document.appendChild(rootNode); 515 document.appendChild(rootNode);
421 return document; 516 return document;
422 } 517 }
423 } 518 }
424 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: 519 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org