Mercurial > dive4elements > framework
comparison artifact-database/src/main/java/de/intevation/artifactdatabase/state/AbstractState.java @ 468:402cd5464723 3.0.0
${help.url} in states helpText attributes now evaluates to /artifact-database/help-url/text() from configuration.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Mon, 15 Apr 2013 12:30:38 +0200 |
parents | ad74e1ba88ba |
children |
comparison
equal
deleted
inserted
replaced
467:2d828a605669 | 468:402cd5464723 |
---|---|
24 import de.intevation.artifacts.Artifact; | 24 import de.intevation.artifacts.Artifact; |
25 import de.intevation.artifacts.ArtifactNamespaceContext; | 25 import de.intevation.artifacts.ArtifactNamespaceContext; |
26 import de.intevation.artifacts.CallContext; | 26 import de.intevation.artifacts.CallContext; |
27 import de.intevation.artifacts.CallMeta; | 27 import de.intevation.artifacts.CallMeta; |
28 | 28 |
29 import de.intevation.artifacts.common.utils.Config; | |
29 import de.intevation.artifacts.common.utils.XMLUtils; | 30 import de.intevation.artifacts.common.utils.XMLUtils; |
30 | 31 |
31 import de.intevation.artifactdatabase.data.StateData; | 32 import de.intevation.artifactdatabase.data.StateData; |
32 | 33 |
33 | 34 |
55 | 56 |
56 /** The XPath to the list of facets relative to the output mode it belongs | 57 /** The XPath to the list of facets relative to the output mode it belongs |
57 * to. */ | 58 * to. */ |
58 public static final String XPATH_FACETS = "facets/facet"; | 59 public static final String XPATH_FACETS = "facets/facet"; |
59 | 60 |
61 public static final String XPATH_HELP_URL = "/artifact-database/help-url/text()"; | |
62 | |
63 public static final String HELP_URL = "${help.url}"; | |
64 | |
60 | 65 |
61 /** The logger that is used in this class. */ | 66 /** The logger that is used in this class. */ |
62 private static Logger logger = Logger.getLogger(AbstractState.class); | 67 private static Logger logger = Logger.getLogger(AbstractState.class); |
63 | 68 |
64 | 69 |
75 protected Map<String, StateData> data; | 80 protected Map<String, StateData> data; |
76 | 81 |
77 /** A list of output modes which are available for this state. */ | 82 /** A list of output modes which are available for this state. */ |
78 protected List<Output> outputs; | 83 protected List<Output> outputs; |
79 | 84 |
85 private static String helpUrl; | |
86 | |
80 | 87 |
81 public AbstractState() { | 88 public AbstractState() { |
82 outputs = new ArrayList<Output>(); | 89 outputs = new ArrayList<Output>(); |
83 } | 90 } |
84 | 91 |
92 public static synchronized final String getHelpUrl() { | |
93 if (helpUrl == null) { | |
94 helpUrl = Config.getStringXPath(XPATH_HELP_URL, HELP_URL); | |
95 } | |
96 return helpUrl; | |
97 } | |
98 | |
99 public static String replaceHelpUrl(String string) { | |
100 return string.replace(HELP_URL, getHelpUrl()); | |
101 } | |
102 | |
85 | 103 |
86 /** | 104 /** |
87 * The default constructor. | 105 * The default constructor. |
88 * | 106 * |
89 * @param id The ID of the state. | 107 * @param id The ID of the state. |
97 } | 115 } |
98 | 116 |
99 | 117 |
100 public AbstractState(String id, String description, String helpText) { | 118 public AbstractState(String id, String description, String helpText) { |
101 this(id, description); | 119 this(id, description); |
102 this.helpText = helpText; | 120 this.helpText = replaceHelpUrl(helpText); |
103 } | 121 } |
104 | 122 |
105 | 123 |
106 /** | 124 /** |
107 * Returns the ID of the state. | 125 * Returns the ID of the state. |
157 * Set the help text for this state. | 175 * Set the help text for this state. |
158 * | 176 * |
159 * @param helpText The help text. | 177 * @param helpText The help text. |
160 */ | 178 */ |
161 public void setHelpText(String helpText) { | 179 public void setHelpText(String helpText) { |
162 this.helpText = helpText; | 180 this.helpText = replaceHelpUrl(helpText); |
163 } | 181 } |
164 | 182 |
165 | 183 |
166 /** | 184 /** |
167 * Returns the data of the state. | 185 * Returns the data of the state. |
229 description = (String) XMLUtils.xpath( | 247 description = (String) XMLUtils.xpath( |
230 config, XPATH_DESCRIPTION, XPathConstants.STRING); | 248 config, XPATH_DESCRIPTION, XPathConstants.STRING); |
231 | 249 |
232 helpText = (String) XMLUtils.xpath( | 250 helpText = (String) XMLUtils.xpath( |
233 config, XPATH_HELP_TEXT, XPathConstants.STRING); | 251 config, XPATH_HELP_TEXT, XPathConstants.STRING); |
252 | |
253 if (helpUrl != null) { | |
254 helpUrl = replaceHelpUrl(helpUrl); | |
255 } | |
234 | 256 |
235 setupOutputs(config); | 257 setupOutputs(config); |
236 } | 258 } |
237 | 259 |
238 | 260 |