Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/MetaDataService.java @ 971:d0c9a5f32c30
Prepared the FLYSArtifactCollection to support the storage of already loaded recommendations.
flys-artifacts/trunk@2396 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 22 Jul 2011 11:18:00 +0000 |
parents | e456aca4eb7b |
children | 30c85cb33a50 |
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 java.sql.Connection; |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 import java.sql.SQLException; |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 import org.w3c.dom.Document; |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 import org.apache.log4j.Logger; |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 |
415
7c018f466d6d
Datacage: Added river parameter to meta data services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
372
diff
changeset
|
10 import java.util.Map; |
7c018f466d6d
Datacage: Added river parameter to meta data services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
372
diff
changeset
|
11 import java.util.HashMap; |
7c018f466d6d
Datacage: Added river parameter to meta data services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
372
diff
changeset
|
12 |
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.Artifact; |
372
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 import de.intevation.artifacts.CallMeta; |
966
a63d79107289
Adjusted services to implement changed signature.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
950
diff
changeset
|
15 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
|
16 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
|
17 import de.intevation.artifacts.ArtifactDatabaseException; |
372
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 import de.intevation.artifactdatabase.DefaultService; |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 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
|
22 import de.intevation.artifacts.common.utils.StringUtils; |
372
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 |
421
24b53f9aa9dc
MetaDataService: Make incoming XML symmetric to DistanceInfoService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
415
diff
changeset
|
24 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
|
25 |
372
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 import de.intevation.flys.artifacts.services.meta.Builder; |
950
22bc87a42a0d
First step to factor out the "Datenkorb" logic into a service independent singleton.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
948
diff
changeset
|
27 import de.intevation.flys.artifacts.services.meta.DataCage; |
372
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 |
970
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
29 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
|
30 |
372
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 import de.intevation.flys.backend.SessionHolder; |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 import org.hibernate.Session; |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
34 |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 import org.hibernate.jdbc.Work; |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 public class MetaDataService |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 extends DefaultService |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 { |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 private static Logger log = Logger.getLogger(MetaDataService.class); |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 |
969
2c8fc60125b9
Meta data template: Allow '-' in variable names.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
966
diff
changeset
|
42 // old service. To be removed |
421
24b53f9aa9dc
MetaDataService: Make incoming XML symmetric to DistanceInfoService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
415
diff
changeset
|
43 public static final String XPATH_RIVER = "/art:river/text()"; |
415
7c018f466d6d
Datacage: Added river parameter to meta data services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
372
diff
changeset
|
44 |
970
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
45 public static final String XPATH_UUID = "/art:uuid/@value"; |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
46 public static final String XPATH_OUTS = "/art:outs/@value"; |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
47 public static final String XPATH_FILTERS = "/art:filters/@value"; |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
48 |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
49 /** The global context key of the artifact database */ |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
50 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
|
51 "global.artifact.database"; |
969
2c8fc60125b9
Meta data template: Allow '-' in variable names.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
966
diff
changeset
|
52 |
372
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
53 public MetaDataService() { |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
54 } |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
55 |
415
7c018f466d6d
Datacage: Added river parameter to meta data services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
372
diff
changeset
|
56 protected static Map<String, Object> extractParameters(Document data) { |
7c018f466d6d
Datacage: Added river parameter to meta data services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
372
diff
changeset
|
57 HashMap<String, Object> parameters = new HashMap<String, Object>(); |
7c018f466d6d
Datacage: Added river parameter to meta data services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
372
diff
changeset
|
58 |
421
24b53f9aa9dc
MetaDataService: Make incoming XML symmetric to DistanceInfoService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
415
diff
changeset
|
59 String river = XMLUtils.xpathString( |
24b53f9aa9dc
MetaDataService: Make incoming XML symmetric to DistanceInfoService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
415
diff
changeset
|
60 data, XPATH_RIVER, ArtifactNamespaceContext.INSTANCE); |
415
7c018f466d6d
Datacage: Added river parameter to meta data services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
372
diff
changeset
|
61 |
7c018f466d6d
Datacage: Added river parameter to meta data services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
372
diff
changeset
|
62 if (river == null || (river = river.trim()).length() == 0) { |
7c018f466d6d
Datacage: Added river parameter to meta data services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
372
diff
changeset
|
63 river = "%"; // matches all rivers |
7c018f466d6d
Datacage: Added river parameter to meta data services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
372
diff
changeset
|
64 } |
7c018f466d6d
Datacage: Added river parameter to meta data services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
372
diff
changeset
|
65 |
7c018f466d6d
Datacage: Added river parameter to meta data services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
372
diff
changeset
|
66 parameters.put("river", river); |
7c018f466d6d
Datacage: Added river parameter to meta data services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
372
diff
changeset
|
67 |
7c018f466d6d
Datacage: Added river parameter to meta data services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
372
diff
changeset
|
68 return parameters; |
7c018f466d6d
Datacage: Added river parameter to meta data services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
372
diff
changeset
|
69 } |
7c018f466d6d
Datacage: Added river parameter to meta data services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
372
diff
changeset
|
70 |
970
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
71 /** The old service. To be removed. */ |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
72 protected Document oldService(Document data) { |
372
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
73 |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
74 final Document result = XMLUtils.newDocument(); |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
75 |
950
22bc87a42a0d
First step to factor out the "Datenkorb" logic into a service independent singleton.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
948
diff
changeset
|
76 final Builder builder = DataCage.getInstance().getBuilder(); |
22bc87a42a0d
First step to factor out the "Datenkorb" logic into a service independent singleton.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
948
diff
changeset
|
77 |
372
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
78 if (builder == null) { |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
79 log.error("MetaDataService is not setup properly."); |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
80 return result; |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
81 } |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
82 |
415
7c018f466d6d
Datacage: Added river parameter to meta data services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
372
diff
changeset
|
83 final Map<String, Object> parameters = extractParameters(data); |
7c018f466d6d
Datacage: Added river parameter to meta data services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
372
diff
changeset
|
84 |
372
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
85 Session session = SessionHolder.acquire(); |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
86 try { |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
87 session.doWork(new Work() { |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
88 @Override |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
89 public void execute(Connection connection) |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
90 throws SQLException |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
91 { |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
92 log.debug("MetaDataService.execute"); |
415
7c018f466d6d
Datacage: Added river parameter to meta data services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
372
diff
changeset
|
93 builder.build(connection, result, parameters); |
372
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
94 } |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
95 }); |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
96 } |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
97 finally { |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
98 session.close(); |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
99 SessionHolder.release(); |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
100 } |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
101 |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
102 return result; |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
103 } |
970
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
104 |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
105 protected Document newService( |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
106 String uuid, |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
107 String outsString, |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
108 String filters, |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
109 GlobalContext globalContext |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
110 ) { |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
111 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
|
112 |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
113 if (!StringUtils.checkUUID(uuid)) { |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
114 log.warn("'" + uuid + "' is not a UUID"); |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
115 return result; |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
116 } |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
117 |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
118 Object dbObject = |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
119 (ArtifactDatabase)globalContext.get(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
|
120 |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
121 if (!(dbObject instanceof ArtifactDatabase)) { |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
122 log.error("Cannot find artifact database"); |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
123 return result; |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
124 } |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
125 |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
126 ArtifactDatabase db = (ArtifactDatabase)dbObject; |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
127 |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
128 Artifact artifact; |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
129 |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
130 try { |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
131 artifact = db.getRawArtifact(uuid); |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
132 } |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
133 catch (ArtifactDatabaseException adbe) { |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
134 log.warn("fetching artifact failed", adbe); |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
135 return result; |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
136 } |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
137 |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
138 if (!(artifact instanceof FLYSArtifact)) { |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
139 log.warn("artifact is not a FLYS artifact."); |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
140 return result; |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
141 } |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
142 |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
143 FLYSArtifact flysArtifact = (FLYSArtifact)artifact; |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
144 |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
145 String [] outs = outsString.split("\\s*,\\s*"); |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
146 |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
147 Map<String, Object> extras; |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
148 |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
149 if (filters != null) { |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
150 extras = new HashMap<String, Object>(); |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
151 for (String filter: filters.split("\\s*,\\*s")) { |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
152 extras.put(filter, "true"); |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
153 } |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
154 } |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
155 else { |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
156 extras = null; |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
157 } |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
158 |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
159 DataCage dc = DataCage.getInstance(); |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
160 |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
161 dc.recommend(flysArtifact, outs, extras, result); |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
162 |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
163 return result; |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
164 } |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
165 |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
166 @Override |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
167 public Document process( |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
168 Document data, |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
169 GlobalContext globalContext, |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
170 CallMeta callMeta |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
171 ) { |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
172 log.debug("MetaDataService.process"); |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
173 |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
174 String uuid = XMLUtils.xpathString( |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
175 data, XPATH_UUID, ArtifactNamespaceContext.INSTANCE); |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
176 |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
177 String outs = XMLUtils.xpathString( |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
178 data, XPATH_OUTS, ArtifactNamespaceContext.INSTANCE); |
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 String filters = XMLUtils.xpathString( |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
181 data, XPATH_FILTERS, ArtifactNamespaceContext.INSTANCE); |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
182 |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
183 return uuid != null && outs != null |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
184 ? newService(uuid, outs, filters, globalContext) |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
185 : oldService(data); |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
186 } |
372
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
187 } |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
188 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |