Mercurial > dive4elements > river
changeset 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 (2011-12-09) |
parents | 18928f0f339b |
children | 368040e5c400 |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticFLYSArtifact.java |
diffstat | 2 files changed, 36 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Fri Dec 09 15:59:30 2011 +0000 +++ b/flys-artifacts/ChangeLog Fri Dec 09 16:39:08 2011 +0000 @@ -1,3 +1,8 @@ +2011-12-09 Felix Wolfsteller <felix.wolfsteller@intevation.de> + + * src/main/java/de/intevation/flys/artifacts/StaticFLYSArtifact.java: + (describe): Add data items to StaticFLYSArtifacts describe-doc. + 2011-12-09 Felix Wolfsteller <felix.wolfsteller@intevation.de> * src/main/java/de/intevation/flys/artifacts/states/StaticState.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticFLYSArtifact.java Fri Dec 09 15:59:30 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticFLYSArtifact.java Fri Dec 09 16:39:08 2011 +0000 @@ -1,5 +1,6 @@ package de.intevation.flys.artifacts; +import java.util.Collection; import java.util.List; import org.apache.log4j.Logger; @@ -10,6 +11,7 @@ import de.intevation.artifacts.ArtifactNamespaceContext; import de.intevation.artifacts.CallContext; +import de.intevation.artifactdatabase.data.StateData; import de.intevation.artifactdatabase.ProtocolUtils; import de.intevation.artifactdatabase.state.Facet; import de.intevation.artifactdatabase.state.Output; @@ -18,13 +20,19 @@ import de.intevation.artifacts.common.utils.XMLUtils; import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator; - +/** + * A basic FLYSArtifact. + */ public abstract class StaticFLYSArtifact extends FLYSArtifact { private static final Logger logger = Logger.getLogger(StaticFLYSArtifact.class); + /** + * Create description document which includes outputmodes. + * @param data ignored. + */ @Override public Document describe(Document data, CallContext cc) { logger.debug("Describe artifact: " + identifier()); @@ -42,6 +50,28 @@ ProtocolUtils.appendDescribeHeader(creator, root, identifier(), hash()); root.appendChild(createOutputModes(cc, desc, creator)); + // Add the data to an anonymous state. + Collection<StateData> datas = this.data.values(); + if (datas.size() > 0) { + Element ui = creator.create("ui"); + Element staticE = creator.create("static"); + Element state = creator.create("state"); + ui.appendChild(staticE); + staticE.appendChild(state); + root.appendChild(ui); + + for (StateData dataItem : datas) { + Element itemelent = creator.create("data"); + creator.addAttr(itemelent, "name", dataItem.getName(), true); + creator.addAttr(itemelent, "type", dataItem.getType(), true); + state.appendChild(itemelent); + Element valuement = creator.create("item"); + creator.addAttr(valuement, "label", dataItem.getDescription(), true); + creator.addAttr(valuement, "value", dataItem.getValue().toString(), true); + itemelent.appendChild(valuement); + } + } + return desc; }