# HG changeset patch # User Felix Wolfsteller # Date 1323448748 0 # Node ID baefcfba97aa7bf45759c7c6045f1a060f8ebdea # Parent 18928f0f339b9432b89da698c08dd73cd206863a Add data items to StaticFLYSArtifacts description document. flys-artifacts/trunk@3381 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 18928f0f339b -r baefcfba97aa flys-artifacts/ChangeLog --- 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 + + * src/main/java/de/intevation/flys/artifacts/StaticFLYSArtifact.java: + (describe): Add data items to StaticFLYSArtifacts describe-doc. + 2011-12-09 Felix Wolfsteller * src/main/java/de/intevation/flys/artifacts/states/StaticState.java: diff -r 18928f0f339b -r baefcfba97aa flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticFLYSArtifact.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 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; }