Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticFLYSArtifact.java @ 1969:baefcfba97aa
Add data items to StaticFLYSArtifacts description document.
flys-artifacts/trunk@3381 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Fri, 09 Dec 2011 16:39:08 +0000 |
parents | c62ff9e72cea |
children | 64dc2997b2dd |
comparison
equal
deleted
inserted
replaced
1968:18928f0f339b | 1969:baefcfba97aa |
---|---|
1 package de.intevation.flys.artifacts; | 1 package de.intevation.flys.artifacts; |
2 | 2 |
3 import java.util.Collection; | |
3 import java.util.List; | 4 import java.util.List; |
4 | 5 |
5 import org.apache.log4j.Logger; | 6 import org.apache.log4j.Logger; |
6 | 7 |
7 import org.w3c.dom.Document; | 8 import org.w3c.dom.Document; |
8 import org.w3c.dom.Element; | 9 import org.w3c.dom.Element; |
9 | 10 |
10 import de.intevation.artifacts.ArtifactNamespaceContext; | 11 import de.intevation.artifacts.ArtifactNamespaceContext; |
11 import de.intevation.artifacts.CallContext; | 12 import de.intevation.artifacts.CallContext; |
12 | 13 |
14 import de.intevation.artifactdatabase.data.StateData; | |
13 import de.intevation.artifactdatabase.ProtocolUtils; | 15 import de.intevation.artifactdatabase.ProtocolUtils; |
14 import de.intevation.artifactdatabase.state.Facet; | 16 import de.intevation.artifactdatabase.state.Facet; |
15 import de.intevation.artifactdatabase.state.Output; | 17 import de.intevation.artifactdatabase.state.Output; |
16 import de.intevation.artifactdatabase.state.State; | 18 import de.intevation.artifactdatabase.state.State; |
17 | 19 |
18 import de.intevation.artifacts.common.utils.XMLUtils; | 20 import de.intevation.artifacts.common.utils.XMLUtils; |
19 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator; | 21 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator; |
20 | 22 |
21 | 23 /** |
24 * A basic FLYSArtifact. | |
25 */ | |
22 public abstract class StaticFLYSArtifact extends FLYSArtifact { | 26 public abstract class StaticFLYSArtifact extends FLYSArtifact { |
23 | 27 |
24 private static final Logger logger = | 28 private static final Logger logger = |
25 Logger.getLogger(StaticFLYSArtifact.class); | 29 Logger.getLogger(StaticFLYSArtifact.class); |
26 | 30 |
27 | 31 |
32 /** | |
33 * Create description document which includes outputmodes. | |
34 * @param data ignored. | |
35 */ | |
28 @Override | 36 @Override |
29 public Document describe(Document data, CallContext cc) { | 37 public Document describe(Document data, CallContext cc) { |
30 logger.debug("Describe artifact: " + identifier()); | 38 logger.debug("Describe artifact: " + identifier()); |
31 | 39 |
32 Document desc = XMLUtils.newDocument(); | 40 Document desc = XMLUtils.newDocument(); |
39 Element root = ProtocolUtils.createRootNode(creator); | 47 Element root = ProtocolUtils.createRootNode(creator); |
40 desc.appendChild(root); | 48 desc.appendChild(root); |
41 | 49 |
42 ProtocolUtils.appendDescribeHeader(creator, root, identifier(), hash()); | 50 ProtocolUtils.appendDescribeHeader(creator, root, identifier(), hash()); |
43 root.appendChild(createOutputModes(cc, desc, creator)); | 51 root.appendChild(createOutputModes(cc, desc, creator)); |
52 | |
53 // Add the data to an anonymous state. | |
54 Collection<StateData> datas = this.data.values(); | |
55 if (datas.size() > 0) { | |
56 Element ui = creator.create("ui"); | |
57 Element staticE = creator.create("static"); | |
58 Element state = creator.create("state"); | |
59 ui.appendChild(staticE); | |
60 staticE.appendChild(state); | |
61 root.appendChild(ui); | |
62 | |
63 for (StateData dataItem : datas) { | |
64 Element itemelent = creator.create("data"); | |
65 creator.addAttr(itemelent, "name", dataItem.getName(), true); | |
66 creator.addAttr(itemelent, "type", dataItem.getType(), true); | |
67 state.appendChild(itemelent); | |
68 Element valuement = creator.create("item"); | |
69 creator.addAttr(valuement, "label", dataItem.getDescription(), true); | |
70 creator.addAttr(valuement, "value", dataItem.getValue().toString(), true); | |
71 itemelent.appendChild(valuement); | |
72 } | |
73 } | |
44 | 74 |
45 return desc; | 75 return desc; |
46 } | 76 } |
47 | 77 |
48 | 78 |