Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/context/FLYSContext.java @ 3426:e7a67407dea1
Limited the input of time periods in SQ relation calculation to 1.
flys-artifacts/trunk@5082 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 20 Jul 2012 09:34:47 +0000 |
parents | 4fc442f1b4f6 |
children | 28be160b5870 |
rev | line source |
---|---|
106
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.context; |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
3295
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
3 import java.util.Map; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
4 |
106
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 import org.apache.log4j.Logger; |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 import org.w3c.dom.Document; |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 import de.intevation.artifactdatabase.DefaultArtifactContext; |
3295
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
10 import de.intevation.artifacts.CallContext; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
11 import de.intevation.flys.exports.OutGenerator; |
106
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 /** |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 * This class is used to store application wide information in a global context. |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 * |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 */ |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 public class FLYSContext extends DefaultArtifactContext { |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 |
1821
e55f1a851923
Added ARTIFACT key to FLYSContextm, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
958
diff
changeset
|
21 /** The logger used in this class. */ |
106
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 private static Logger logger = Logger.getLogger(FLYSContext.class); |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 |
1821
e55f1a851923
Added ARTIFACT key to FLYSContextm, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
958
diff
changeset
|
24 /** The key that is used to store the StateEngine in the context. */ |
e55f1a851923
Added ARTIFACT key to FLYSContextm, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
958
diff
changeset
|
25 public static final String ARTIFACT_KEY = |
e55f1a851923
Added ARTIFACT key to FLYSContextm, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
958
diff
changeset
|
26 "artifact"; |
e55f1a851923
Added ARTIFACT key to FLYSContextm, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
958
diff
changeset
|
27 |
e55f1a851923
Added ARTIFACT key to FLYSContextm, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
958
diff
changeset
|
28 /** The key that is used to store the TransitionEngine in the context. */ |
106
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 public static final String TRANSITION_ENGINE_KEY = |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 "artifact.transition.engine"; |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 |
1821
e55f1a851923
Added ARTIFACT key to FLYSContextm, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
958
diff
changeset
|
32 /** The key that is used to store the StateEngine in the context. */ |
107
a228b39494a9
Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
106
diff
changeset
|
33 public static final String STATE_ENGINE_KEY = |
a228b39494a9
Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
106
diff
changeset
|
34 "artifact.state.engine"; |
a228b39494a9
Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
106
diff
changeset
|
35 |
295
53c155bfde07
Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
107
diff
changeset
|
36 /** The key that is used to store the Map of OutGenerator classes in the |
1821
e55f1a851923
Added ARTIFACT key to FLYSContextm, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
958
diff
changeset
|
37 * context. */ |
295
53c155bfde07
Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
107
diff
changeset
|
38 public static final String OUTGENERATORS_KEY = |
53c155bfde07
Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
107
diff
changeset
|
39 "flys.export.outgenerators"; |
53c155bfde07
Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
107
diff
changeset
|
40 |
1821
e55f1a851923
Added ARTIFACT key to FLYSContextm, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
958
diff
changeset
|
41 /** The key that is used to store the map of themes in the context. */ |
341
eca7892bf8ff
Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
295
diff
changeset
|
42 public static final String THEMES = |
eca7892bf8ff
Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
295
diff
changeset
|
43 "flys.themes.map"; |
eca7892bf8ff
Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
295
diff
changeset
|
44 |
1821
e55f1a851923
Added ARTIFACT key to FLYSContextm, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
958
diff
changeset
|
45 /** The key that is used to store a map of theme mappings in the context. */ |
345
88a669785863
Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
341
diff
changeset
|
46 public static final String THEME_MAPPING = |
88a669785863
Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
341
diff
changeset
|
47 "flys.themes.mapping.map"; |
88a669785863
Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
341
diff
changeset
|
48 |
1821
e55f1a851923
Added ARTIFACT key to FLYSContextm, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
958
diff
changeset
|
49 /** The key that is used to store a map of WMS urls for each river. */ |
958
ae198bef4ba0
Added configurations for river WMSe (currently for Saar, Mosel, Elbe).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
345
diff
changeset
|
50 public static final String RIVER_WMS = |
ae198bef4ba0
Added configurations for river WMSe (currently for Saar, Mosel, Elbe).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
345
diff
changeset
|
51 "flys.floodmap.river.wms"; |
ae198bef4ba0
Added configurations for river WMSe (currently for Saar, Mosel, Elbe).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
345
diff
changeset
|
52 |
1970
368040e5c400
Improved the Scheduler to be able to cancel running WSPLGEN jobs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1821
diff
changeset
|
53 /** The key that is used to store an instance of Scheduler in the context.*/ |
368040e5c400
Improved the Scheduler to be able to cancel running WSPLGEN jobs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1821
diff
changeset
|
54 public static final String SCHEDULER = |
368040e5c400
Improved the Scheduler to be able to cancel running WSPLGEN jobs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1821
diff
changeset
|
55 "flys.wsplgen.scheduler"; |
368040e5c400
Improved the Scheduler to be able to cancel running WSPLGEN jobs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1821
diff
changeset
|
56 |
106
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 /** |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
59 * The default constructor. |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 */ |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 public FLYSContext() { |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 super(); |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 } |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
65 |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
66 /** |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
67 * A constructor with a config document. |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 */ |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
69 public FLYSContext(Document config) { |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
70 super(config); |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
71 } |
3295
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
72 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
73 /** |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
74 * Returns the OutGenerator for a specified <i>type</i>. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
75 * |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
76 * @param name The name of the output type. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
77 * @param type Defines the type of the desired OutGenerator. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
78 * |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
79 * @return Instance of an OutGenerator for specified <i>type</i>. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
80 */ |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
81 public static OutGenerator getOutGenerator( |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
82 CallContext context, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
83 String name, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
84 String type) |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
85 { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
86 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
87 FLYSContext flysContext = context instanceof FLYSContext |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
88 ? (FLYSContext) context |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
89 : (FLYSContext) context.globalContext(); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
90 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
91 Map<String, Class> generators = (Map<String, Class>) |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
92 flysContext.get(FLYSContext.OUTGENERATORS_KEY); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
93 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
94 if (generators == null) { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
95 return null; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
96 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
97 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
98 Class clazz = generators.get(name); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
99 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
100 try { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
101 return clazz != null ? (OutGenerator) clazz.newInstance() : null; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
102 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
103 catch (InstantiationException ie) { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
104 logger.error(ie, ie); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
105 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
106 catch (IllegalAccessException iae) { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
107 logger.error(iae, iae); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
108 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
109 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
110 return null; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1970
diff
changeset
|
111 } |
106
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
112 } |
5864c41219db
Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
113 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |