comparison flys-artifacts/src/main/java/org/dive4elements/river/exports/ReportGenerator.java @ 5831:bd047b71ab37

Repaired internal references
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 12:06:39 +0200
parents flys-artifacts/src/main/java/de/intevation/flys/exports/ReportGenerator.java@118fe1cc8cc8
children
comparison
equal deleted inserted replaced
5830:160f53ee0870 5831:bd047b71ab37
1 package org.dive4elements.river.exports;
2
3 import java.io.IOException;
4 import java.io.OutputStream;
5
6 import org.apache.log4j.Logger;
7
8 import org.dive4elements.artifacts.Artifact;
9 import org.dive4elements.artifacts.CallContext;
10
11 import org.dive4elements.artifacts.common.utils.XMLUtils;
12
13 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
14 import org.dive4elements.artifactdatabase.state.Facet;
15 import org.dive4elements.artifactdatabase.state.Settings;
16
17 import org.dive4elements.river.artifacts.model.Calculation;
18 import org.dive4elements.river.collections.FLYSArtifactCollection;
19
20 import org.w3c.dom.Document;
21
22 public class ReportGenerator
23 implements OutGenerator
24 {
25 private static Logger logger = Logger.getLogger(ReportGenerator.class);
26
27 protected Document result;
28 protected OutputStream out;
29 protected CallContext context;
30
31 public ReportGenerator() {
32 }
33
34 @Override
35 public void init(Document request, OutputStream out, CallContext context) {
36 logger.debug("init");
37 this.out = out;
38 this.context = context;
39 result = null;
40 }
41
42 @Override
43 public void setMasterArtifact(Artifact master) {
44 // not needed
45 }
46
47 @Override
48 public void setCollection(FLYSArtifactCollection collection) {
49 // not needed
50 }
51
52 @Override
53 public void doOut(
54 ArtifactAndFacet artifactFacet,
55 Document attr,
56 boolean visible
57 ) {
58 logger.debug("doOut");
59 Facet facet = artifactFacet.getFacet();
60 if (facet != null) {
61 Calculation report = (Calculation) artifactFacet.getData(context);
62 if (result == null) {
63 result = XMLUtils.newDocument();
64 report.toXML(result, context.getMeta());
65 }
66 }
67 }
68
69 @Override
70 public void generate() throws IOException {
71 logger.debug("generate");
72 XMLUtils.toStream(result != null
73 ? result
74 : XMLUtils.newDocument(), out);
75 }
76
77
78 /**
79 * Returns an instance of <i>EmptySettings</i> currently!
80 *
81 * @return an instance of <i>EmptySettings</i>.
82 */
83 public Settings getSettings() {
84 return new EmptySettings();
85 }
86
87
88 /**
89 * This method is not implemented. Override it in subclasses if those need a
90 * <i>Settings</i> object.
91 */
92 public void setSettings(Settings settings) {
93 // do nothing
94 }
95 }
96 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org