Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticFLYSArtifact.java @ 3812:f788d2d901d6
merged flys-artifacts/pre2.6-2011-12-05
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:53 +0200 |
parents | c62ff9e72cea |
children | baefcfba97aa |
comparison
equal
deleted
inserted
replaced
3808:5fab0fe3c445 | 3812:f788d2d901d6 |
---|---|
1 package de.intevation.flys.artifacts; | |
2 | |
3 import java.util.List; | |
4 | |
5 import org.apache.log4j.Logger; | |
6 | |
7 import org.w3c.dom.Document; | |
8 import org.w3c.dom.Element; | |
9 | |
10 import de.intevation.artifacts.ArtifactNamespaceContext; | |
11 import de.intevation.artifacts.CallContext; | |
12 | |
13 import de.intevation.artifactdatabase.ProtocolUtils; | |
14 import de.intevation.artifactdatabase.state.Facet; | |
15 import de.intevation.artifactdatabase.state.Output; | |
16 import de.intevation.artifactdatabase.state.State; | |
17 | |
18 import de.intevation.artifacts.common.utils.XMLUtils; | |
19 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator; | |
20 | |
21 | |
22 public abstract class StaticFLYSArtifact extends FLYSArtifact { | |
23 | |
24 private static final Logger logger = | |
25 Logger.getLogger(StaticFLYSArtifact.class); | |
26 | |
27 | |
28 @Override | |
29 public Document describe(Document data, CallContext cc) { | |
30 logger.debug("Describe artifact: " + identifier()); | |
31 | |
32 Document desc = XMLUtils.newDocument(); | |
33 | |
34 ElementCreator creator = new ElementCreator( | |
35 desc, | |
36 ArtifactNamespaceContext.NAMESPACE_URI, | |
37 ArtifactNamespaceContext.NAMESPACE_PREFIX); | |
38 | |
39 Element root = ProtocolUtils.createRootNode(creator); | |
40 desc.appendChild(root); | |
41 | |
42 ProtocolUtils.appendDescribeHeader(creator, root, identifier(), hash()); | |
43 root.appendChild(createOutputModes(cc, desc, creator)); | |
44 | |
45 return desc; | |
46 } | |
47 | |
48 | |
49 protected Element createOutputModes( | |
50 CallContext cc, | |
51 Document doc, | |
52 ElementCreator creator) | |
53 { | |
54 Element outs = ProtocolUtils.createArtNode( | |
55 creator, "outputmodes", null, null); | |
56 | |
57 State state = getCurrentState(cc); | |
58 List<Output> list = state.getOutputs(); | |
59 | |
60 if (list != null && list.size() > 0) { | |
61 List<Facet> fs = facets.get(state.getID()); | |
62 if (fs != null && fs.size() > 0) { | |
63 List<Output> generated = generateOutputs(list, fs); | |
64 | |
65 logger.debug("Found " + fs.size() + " current facets."); | |
66 if (!generated.isEmpty()) { | |
67 ProtocolUtils.appendOutputModes( | |
68 doc, outs, generated); | |
69 } | |
70 } | |
71 else { | |
72 logger.debug("No facets found for the current state."); | |
73 } | |
74 } | |
75 | |
76 return outs; | |
77 } | |
78 } | |
79 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |