Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/ChartArtifact.java @ 7471:fff862f4ef76
Experimental caching of datacage recommendations. The respective hook is called a lot and running the datacage over and over again when loading data can be expensive. So the generated recommendations are cached for some time.
Hopefully this improves the overall speed of loading data from the datacage.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Wed, 30 Oct 2013 15:26:21 +0100 |
parents | af13ceeba52a |
children | 8d5ca5175038 |
rev | line source |
---|---|
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
2 * Software engineering by Intevation GmbH |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
3 * |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5867
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5867
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
7 */ |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
8 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4497
diff
changeset
|
9 package org.dive4elements.river.artifacts; |
2113
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
10 |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
11 import org.apache.log4j.Logger; |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
12 |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
13 import java.util.List; |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
14 |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
15 import org.w3c.dom.Document; |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
16 import org.w3c.dom.Element; |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
17 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4497
diff
changeset
|
18 import org.dive4elements.artifacts.Artifact; |
2113
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
19 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4497
diff
changeset
|
20 import org.dive4elements.artifacts.ArtifactFactory; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4497
diff
changeset
|
21 import org.dive4elements.artifacts.CallMeta; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4497
diff
changeset
|
22 import org.dive4elements.artifacts.CallContext; |
2113
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
23 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4497
diff
changeset
|
24 import org.dive4elements.artifacts.common.utils.XMLUtils; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4497
diff
changeset
|
25 import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator; |
2113
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
26 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4497
diff
changeset
|
27 import org.dive4elements.artifactdatabase.ProtocolUtils; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4497
diff
changeset
|
28 import org.dive4elements.artifactdatabase.state.Facet; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4497
diff
changeset
|
29 import org.dive4elements.artifactdatabase.state.State; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4497
diff
changeset
|
30 import org.dive4elements.artifactdatabase.state.StateEngine; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4497
diff
changeset
|
31 import org.dive4elements.artifactdatabase.state.Output; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4497
diff
changeset
|
32 |
5865
73da40528cf2
River artifacts: Renamed FLYSUtils to RiverUtils.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
33 import org.dive4elements.river.utils.RiverUtils; |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4497
diff
changeset
|
34 |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4497
diff
changeset
|
35 import org.dive4elements.river.artifacts.states.DefaultState; |
5866
9a6741ccf6d4
FLYS artifacts: Renamed FLYSContext(Factory) to RiverContext(Factory).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5865
diff
changeset
|
36 import org.dive4elements.river.artifacts.context.RiverContext; |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4497
diff
changeset
|
37 import org.dive4elements.river.artifacts.resources.Resources; |
2113
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
38 |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
39 |
3650
cbe2febe30cc
Merged revisions 5391-5392 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3555
diff
changeset
|
40 /** Artifact, open to generate any (?) out. */ |
5867
59ff03ff48f1
River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5866
diff
changeset
|
41 public class ChartArtifact extends D4EArtifact { |
2113
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
42 |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
43 private static final Logger logger = |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
44 Logger.getLogger(ChartArtifact.class); |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
45 |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
46 @Override |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
47 public void setup( |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
48 String identifier, |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
49 ArtifactFactory factory, |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
50 Object context, |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
51 CallMeta callmeta, |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
52 Document data) |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
53 { |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
54 logger.debug("ChartArtifact.setup"); |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
55 this.identifier = identifier; |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
56 name = "new_chart"; |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
57 |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
58 List<State> states = getStates(context); |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
59 |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
60 setCurrentState(states.get(0)); |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
61 } |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
62 |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
63 @Override |
3193
2f922be407ea
Moved common code of the *Artifacts into FLYSArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3083
diff
changeset
|
64 protected void appendBackgroundActivity( |
2113
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
65 ElementCreator cr, |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
66 Element root, |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
67 CallContext context |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
68 ) { |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
69 Element inBackground = cr.create("background-processing"); |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
70 root.appendChild(inBackground); |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
71 |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
72 cr.addAttr( |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
73 inBackground, |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
74 "value", |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
75 String.valueOf(context.isInBackground()), |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
76 true); |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
77 } |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
78 |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
79 |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
80 /** |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
81 * Append output mode nodes to a document. |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
82 */ |
3193
2f922be407ea
Moved common code of the *Artifacts into FLYSArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3083
diff
changeset
|
83 @Override |
2113
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
84 protected void appendOutputModes( |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
85 Document doc, |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
86 Element outs, |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
87 CallContext context, |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
88 String uuid) |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
89 { |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
90 List<String> stateIds = getPreviousStateIds(); |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
91 |
5866
9a6741ccf6d4
FLYS artifacts: Renamed FLYSContext(Factory) to RiverContext(Factory).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5865
diff
changeset
|
92 RiverContext flysContext = RiverUtils.getFlysContext(context); |
2113
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
93 StateEngine engine = (StateEngine) flysContext.get( |
5866
9a6741ccf6d4
FLYS artifacts: Renamed FLYSContext(Factory) to RiverContext(Factory).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5865
diff
changeset
|
94 RiverContext.STATE_ENGINE_KEY); |
2113
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
95 |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
96 for (String stateId: stateIds) { |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
97 logger.debug("Append output modes for state: " + stateId); |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
98 DefaultState state = (DefaultState) engine.getState(stateId); |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
99 |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
100 List<Output> list = state.getOutputs(); |
3555
b1912514e0f5
s/container.size() == 0/container.isEmpty()/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3193
diff
changeset
|
101 if (list == null || list.isEmpty()) { |
2113
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
102 logger.debug("-> No output modes for this state."); |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
103 continue; |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
104 } |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
105 |
4497
a2735a4bf75e
Change facets member variable to private
Björn Ricks <bjoern.ricks@intevation.de>
parents:
4049
diff
changeset
|
106 List<Facet> fs = getFacets(stateId); |
2113
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
107 |
3555
b1912514e0f5
s/container.size() == 0/container.isEmpty()/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3193
diff
changeset
|
108 if (fs == null || fs.isEmpty()) { |
2113
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
109 logger.debug("No facets for previous state found."); |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
110 continue; |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
111 } |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
112 |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
113 logger.debug("Found " + fs.size() + " facets in previous states."); |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
114 |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
115 List<Output> generated = generateOutputs(list, fs); |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
116 |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
117 ProtocolUtils.appendOutputModes(doc, outs, generated); |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
118 } |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
119 |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
120 try { |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
121 DefaultState cur = (DefaultState) getCurrentState(context); |
2158
1ea555bf3c6b
Removed state validation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2153
diff
changeset
|
122 List<Output> list = cur.getOutputs(); |
1ea555bf3c6b
Removed state validation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2153
diff
changeset
|
123 if (list != null && list.size() > 0) { |
1ea555bf3c6b
Removed state validation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2153
diff
changeset
|
124 logger.debug( |
1ea555bf3c6b
Removed state validation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2153
diff
changeset
|
125 "Append output modes for current state: " + cur.getID()); |
2113
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
126 |
4497
a2735a4bf75e
Change facets member variable to private
Björn Ricks <bjoern.ricks@intevation.de>
parents:
4049
diff
changeset
|
127 List<Facet> fs = getFacets(cur.getID()); |
2113
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
128 |
2158
1ea555bf3c6b
Removed state validation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2153
diff
changeset
|
129 if (fs != null && fs.size() > 0) { |
1ea555bf3c6b
Removed state validation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2153
diff
changeset
|
130 List<Output> generated = generateOutputs(list, fs); |
1ea555bf3c6b
Removed state validation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2153
diff
changeset
|
131 |
1ea555bf3c6b
Removed state validation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2153
diff
changeset
|
132 logger.debug("Found " + fs.size() + " current facets."); |
1ea555bf3c6b
Removed state validation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2153
diff
changeset
|
133 if (!generated.isEmpty()) { |
1ea555bf3c6b
Removed state validation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2153
diff
changeset
|
134 ProtocolUtils.appendOutputModes( |
1ea555bf3c6b
Removed state validation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2153
diff
changeset
|
135 doc, outs, generated); |
2113
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
136 } |
2158
1ea555bf3c6b
Removed state validation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2153
diff
changeset
|
137 } |
1ea555bf3c6b
Removed state validation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2153
diff
changeset
|
138 else { |
1ea555bf3c6b
Removed state validation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2153
diff
changeset
|
139 logger.debug("No facets found for the current state."); |
2113
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
140 } |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
141 } |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
142 } |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
143 catch (IllegalArgumentException iae) { |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
144 // state is not valid, so we do not append its outputs. |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
145 } |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
146 } |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
147 |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
148 public static class ChartState extends DefaultState { |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
149 |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
150 public static final String FIELD_MODE = "chart_type"; |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
151 |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
152 public static final String DURATION_CURVE = |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
153 "chart.new.durationcurve"; |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
154 |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
155 public static final String COMPUTED_DISCHARGE_CURVE = |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
156 "chart.new.computeddischargecurve"; |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
157 |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
158 public static final String DISCHARGE_LONGITUDINAL_CURVE = |
2153
734d5f5e55c0
'New chart' for cross sections.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2120
diff
changeset
|
159 "chart.new.longitudinal_section"; |
2113
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
160 |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
161 public static final String W_DIFFERENCES = |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
162 "chart.new.w_differences"; |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
163 |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
164 public static final String WATERLEVEL = |
2153
734d5f5e55c0
'New chart' for cross sections.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2120
diff
changeset
|
165 "chart.new.crosssection"; |
2113
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
166 |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
167 public static final String[] CHARTS = { |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
168 COMPUTED_DISCHARGE_CURVE, |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
169 DURATION_CURVE, |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
170 DISCHARGE_LONGITUDINAL_CURVE, |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
171 W_DIFFERENCES, |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
172 WATERLEVEL }; |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
173 |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
174 |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
175 |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
176 @Override |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
177 public Object computeAdvance( |
5867
59ff03ff48f1
River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5866
diff
changeset
|
178 D4EArtifact artifact, |
2113
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
179 String hash, |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
180 CallContext context, |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
181 List<Facet> facets, |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
182 Object old) |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
183 { |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
184 logger.debug("ChartState.computeAdvance"); |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
185 |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
186 |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
187 return null; |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
188 } |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
189 |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
190 |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
191 @Override |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
192 protected Element[] createItems( |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
193 XMLUtils.ElementCreator cr, |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
194 Artifact artifact, |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
195 String name, |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
196 CallContext context) |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
197 { |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
198 CallMeta meta = context.getMeta(); |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
199 Element[] charts = new Element[CHARTS.length]; |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
200 |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
201 int i = 0; |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
202 |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
203 for (String chart: CHARTS) { |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
204 charts[i++] = createItem( |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
205 cr, new String[] { |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
206 Resources.getMsg(meta, chart, chart), |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
207 chart |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
208 }); |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
209 } |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
210 |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
211 return charts; |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
212 } |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
213 } |
d109e7702995
Initial implementation for module 'new chart'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
214 } |
3083
4bd3d8bbb60c
Added missing vim lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2158
diff
changeset
|
215 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |