annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/MetaDataService.java @ 4837:9e25c7523485

Fixed calculation of effective width in MINFO SQ relation. * Get all (including empty datasets) from db. * Filter empty datasets when processing data of the same date. * Added debug outputs.
author Raimund Renkert <rrenkert@intevation.de>
date Wed, 23 Jan 2013 11:14:41 +0100
parents afd817b006b7
children 9bddb6f5baa0
rev   line source
372
fc3cf0ef777e Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.services;
fc3cf0ef777e Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
2
fc3cf0ef777e Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
3 import org.w3c.dom.Document;
fc3cf0ef777e Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
4
fc3cf0ef777e Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
5 import org.apache.log4j.Logger;
fc3cf0ef777e Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
6
415
7c018f466d6d Datacage: Added river parameter to meta data services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 372
diff changeset
7 import java.util.Map;
7c018f466d6d Datacage: Added river parameter to meta data services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 372
diff changeset
8 import java.util.HashMap;
7c018f466d6d Datacage: Added river parameter to meta data services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 372
diff changeset
9
970
e456aca4eb7b meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 969
diff changeset
10 import de.intevation.artifacts.Artifact;
372
fc3cf0ef777e Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
11 import de.intevation.artifacts.CallMeta;
966
a63d79107289 Adjusted services to implement changed signature.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 950
diff changeset
12 import de.intevation.artifacts.GlobalContext;
970
e456aca4eb7b meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 969
diff changeset
13 import de.intevation.artifacts.ArtifactDatabase;
e456aca4eb7b meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 969
diff changeset
14 import de.intevation.artifacts.ArtifactDatabaseException;
372
fc3cf0ef777e Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
15
fc3cf0ef777e Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
16 import de.intevation.artifacts.common.utils.XMLUtils;
970
e456aca4eb7b meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 969
diff changeset
17 import de.intevation.artifacts.common.utils.StringUtils;
372
fc3cf0ef777e Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
18
421
24b53f9aa9dc MetaDataService: Make incoming XML symmetric to DistanceInfoService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 415
diff changeset
19 import de.intevation.artifacts.common.ArtifactNamespaceContext;
24b53f9aa9dc MetaDataService: Make incoming XML symmetric to DistanceInfoService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 415
diff changeset
20
1015
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
21 import de.intevation.flys.artifacts.datacage.Recommendations;
372
fc3cf0ef777e Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22
970
e456aca4eb7b meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 969
diff changeset
23 import de.intevation.flys.artifacts.FLYSArtifact;
e456aca4eb7b meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 969
diff changeset
24
4529
b70dedac4c7e MetaDataService: Added comment from ChangeLog.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
25
b70dedac4c7e MetaDataService: Added comment from ChangeLog.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
26 /**
b70dedac4c7e MetaDataService: Added comment from ChangeLog.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
27 * Following XPaths are evaluated on the incoming document.
b70dedac4c7e MetaDataService: Added comment from ChangeLog.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
28 *
b70dedac4c7e MetaDataService: Added comment from ChangeLog.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
29 * "/art:meta/art:artifact-id/@value" The UUID of the artifact. Optional.
b70dedac4c7e MetaDataService: Added comment from ChangeLog.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
30 * Used to fill the template enviroment.
b70dedac4c7e MetaDataService: Added comment from ChangeLog.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
31 * "/art:meta/art:user-id/@value" The UUID of the user. Optional.
b70dedac4c7e MetaDataService: Added comment from ChangeLog.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
32 * If given the user specific template is filled.
b70dedac4c7e MetaDataService: Added comment from ChangeLog.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
33 * "/art:meta/art:outs/@value" The list of outs used to recommend for the
b70dedac4c7e MetaDataService: Added comment from ChangeLog.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
34 * various outputs.
b70dedac4c7e MetaDataService: Added comment from ChangeLog.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
35 * "/art:meta/art:parameters/@value" A list of key/value pairs to inject more
b70dedac4c7e MetaDataService: Added comment from ChangeLog.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
36 * filters to the templating.
b70dedac4c7e MetaDataService: Added comment from ChangeLog.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
37 */
372
fc3cf0ef777e Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
38 public class MetaDataService
1633
f84ddc205c8b Made MetaDataService a subclass of FLYSService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1029
diff changeset
39 extends FLYSService
372
fc3cf0ef777e Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
40 {
fc3cf0ef777e Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
41 private static Logger log = Logger.getLogger(MetaDataService.class);
fc3cf0ef777e Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
42
1015
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
43 public static final String XPATH_ARTIFACT_ID = "/art:meta/art:artifact-id/@value";
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
44 public static final String XPATH_USER_ID = "/art:meta/art:user-id/@value";
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
45 public static final String XPATH_OUTS = "/art:meta/art:outs/@value";
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
46 public static final String XPATH_PARAMETERS = "/art:meta/art:parameters/@value";
970
e456aca4eb7b meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 969
diff changeset
47
1029
3f3988bb6284 Picky Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1016
diff changeset
48 /** The global context key of the artifact database. */
970
e456aca4eb7b meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 969
diff changeset
49 public static final String ARTIFACT_DATA_BASE_KEY =
e456aca4eb7b meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 969
diff changeset
50 "global.artifact.database";
969
2c8fc60125b9 Meta data template: Allow '-' in variable names.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 966
diff changeset
51
372
fc3cf0ef777e Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
52 public MetaDataService() {
fc3cf0ef777e Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
53 }
fc3cf0ef777e Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
54
1015
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
55 @Override
1633
f84ddc205c8b Made MetaDataService a subclass of FLYSService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1029
diff changeset
56 protected Document doProcess(
1015
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
57 Document data,
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
58 GlobalContext globalContext,
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
59 CallMeta callMeta
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
60 ) {
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
61 log.debug("MetaDataService.process");
415
7c018f466d6d Datacage: Added river parameter to meta data services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 372
diff changeset
62
1015
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
63 String artifactId = XMLUtils.xpathString(
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
64 data, XPATH_ARTIFACT_ID, ArtifactNamespaceContext.INSTANCE);
415
7c018f466d6d Datacage: Added river parameter to meta data services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 372
diff changeset
65
1016
ff7b81cf9999 Meta data service: Be a bit more tolerant about empty strings for UUIDs of artifact and user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1015
diff changeset
66 if (artifactId != null
ff7b81cf9999 Meta data service: Be a bit more tolerant about empty strings for UUIDs of artifact and user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1015
diff changeset
67 && (artifactId = artifactId.trim()).length() == 0) {
ff7b81cf9999 Meta data service: Be a bit more tolerant about empty strings for UUIDs of artifact and user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1015
diff changeset
68 artifactId = null;
ff7b81cf9999 Meta data service: Be a bit more tolerant about empty strings for UUIDs of artifact and user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1015
diff changeset
69 }
ff7b81cf9999 Meta data service: Be a bit more tolerant about empty strings for UUIDs of artifact and user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1015
diff changeset
70
1015
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
71 String userId = XMLUtils.xpathString(
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
72 data, XPATH_USER_ID, ArtifactNamespaceContext.INSTANCE);
415
7c018f466d6d Datacage: Added river parameter to meta data services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 372
diff changeset
73
1016
ff7b81cf9999 Meta data service: Be a bit more tolerant about empty strings for UUIDs of artifact and user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1015
diff changeset
74 if (userId != null
ff7b81cf9999 Meta data service: Be a bit more tolerant about empty strings for UUIDs of artifact and user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1015
diff changeset
75 && (userId = userId.trim()).length() == 0) {
ff7b81cf9999 Meta data service: Be a bit more tolerant about empty strings for UUIDs of artifact and user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1015
diff changeset
76 userId = null;
ff7b81cf9999 Meta data service: Be a bit more tolerant about empty strings for UUIDs of artifact and user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1015
diff changeset
77 }
ff7b81cf9999 Meta data service: Be a bit more tolerant about empty strings for UUIDs of artifact and user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1015
diff changeset
78
1015
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
79 String outs = XMLUtils.xpathString(
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
80 data, XPATH_OUTS, ArtifactNamespaceContext.INSTANCE);
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
81
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
82 String parameters = XMLUtils.xpathString(
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
83 data, XPATH_PARAMETERS, ArtifactNamespaceContext.INSTANCE);
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
84
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
85 return doService(
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
86 artifactId, userId, outs, parameters, globalContext);
415
7c018f466d6d Datacage: Added river parameter to meta data services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 372
diff changeset
87 }
7c018f466d6d Datacage: Added river parameter to meta data services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 372
diff changeset
88
1015
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
89 protected static Map<String, Object> splitParameters(
974
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
90 String parameters,
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
91 Map<String, Object> data
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
92 ) {
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
93 if (parameters != null) {
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
94 String [] parts = parameters.split("\\s*;\\s*");
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
95 for (String part: parts) {
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
96 String [] kv = part.split("\\s*:\\s*");
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
97 if (kv.length < 2 || (kv[0] = kv[0].trim()).length() == 0) {
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
98 continue;
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
99 }
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
100 String [] values = kv[1].split("\\s*,\\s*");
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
101 data.put(kv[0], values.length == 1 ? values[0] : values);
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
102 }
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
103 }
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
104 return data;
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
105 }
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
106
4589
afd817b006b7 Documentation added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4529
diff changeset
107 /** Return the document containing matched stuff from meta-data.xml. */
1015
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
108 protected Document doService(
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
109 String artifactId,
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
110 String userId,
970
e456aca4eb7b meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 969
diff changeset
111 String outsString,
974
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
112 String parameters,
970
e456aca4eb7b meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 969
diff changeset
113 GlobalContext globalContext
e456aca4eb7b meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 969
diff changeset
114 ) {
e456aca4eb7b meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 969
diff changeset
115 Document result = XMLUtils.newDocument();
e456aca4eb7b meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 969
diff changeset
116
974
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
117 FLYSArtifact flysArtifact;
970
e456aca4eb7b meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 969
diff changeset
118
975
a111f0984706 meta data service: Added 'if log.isDebugEnabled() {}'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 974
diff changeset
119 if (log.isDebugEnabled()) {
1015
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
120 log.debug("artifact : " + artifactId);
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
121 log.debug("user : " + userId);
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
122 log.debug("outs : " + outsString);
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
123 log.debug("parameters: " + parameters);
975
a111f0984706 meta data service: Added 'if log.isDebugEnabled() {}'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 974
diff changeset
124 }
970
e456aca4eb7b meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 969
diff changeset
125
1015
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
126 if (userId != null && !StringUtils.checkUUID(userId)) {
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
127 log.warn("'" + userId + "' is not a UUID");
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
128 return result;
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
129 }
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
130
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
131 if (artifactId != null) {
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
132 if (!StringUtils.checkUUID(artifactId)) {
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
133 log.warn("'" + artifactId + "' is not a UUID");
974
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
134 return result;
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
135 }
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
136
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
137 Object dbObject =
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
138 (ArtifactDatabase)globalContext.get(ARTIFACT_DATA_BASE_KEY);
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
139
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
140 if (!(dbObject instanceof ArtifactDatabase)) {
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
141 log.error("Cannot find artifact database");
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
142 return result;
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
143 }
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
144
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
145 ArtifactDatabase db = (ArtifactDatabase)dbObject;
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
146
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
147 Artifact artifact;
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
148
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
149 try {
1015
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
150 artifact = db.getRawArtifact(artifactId);
974
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
151 }
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
152 catch (ArtifactDatabaseException adbe) {
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
153 log.warn("fetching artifact failed", adbe);
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
154 return result;
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
155 }
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
156
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
157 if (!(artifact instanceof FLYSArtifact)) {
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
158 log.warn("artifact is not a FLYS artifact.");
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
159 return result;
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
160 }
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
161
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
162 flysArtifact = (FLYSArtifact)artifact;
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
163 }
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
164 else {
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
165 flysArtifact = null;
970
e456aca4eb7b meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 969
diff changeset
166 }
e456aca4eb7b meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 969
diff changeset
167
1015
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
168
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
169 Map<String, Object> data = splitParameters(
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
170 parameters, new HashMap<String, Object>());
970
e456aca4eb7b meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 969
diff changeset
171
1016
ff7b81cf9999 Meta data service: Be a bit more tolerant about empty strings for UUIDs of artifact and user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1015
diff changeset
172 String [] outs = outsString == null
ff7b81cf9999 Meta data service: Be a bit more tolerant about empty strings for UUIDs of artifact and user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1015
diff changeset
173 ? new String [0]
ff7b81cf9999 Meta data service: Be a bit more tolerant about empty strings for UUIDs of artifact and user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1015
diff changeset
174 : outsString.split("\\s*,\\s*");
3076
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1633
diff changeset
175
1015
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
176 Recommendations rec = Recommendations.getInstance();
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
177 rec.recommend(
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
178 flysArtifact, userId, outs, data, result);
970
e456aca4eb7b meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 969
diff changeset
179
e456aca4eb7b meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 969
diff changeset
180 return result;
e456aca4eb7b meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 969
diff changeset
181 }
372
fc3cf0ef777e Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
182 }
fc3cf0ef777e Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
183 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org