Mercurial > dive4elements > river
annotate flys-client/src/main/java/de/intevation/flys/client/server/CollectionItemAttributeServiceImpl.java @ 1325:2f5fbfeda1d4
Introduced i18n for datacage
flys-client/trunk@2967 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 13 Oct 2011 16:30:55 +0000 |
parents | c4c957a9c092 |
children | 974c6b3700de |
rev | line source |
---|---|
1285
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.client.server; |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
2 |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
3 import org.w3c.dom.Document; |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
4 import org.w3c.dom.Element; |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
5 import org.w3c.dom.NodeList; |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
6 |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
7 import com.google.gwt.user.server.rpc.RemoteServiceServlet; |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
8 |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
9 import de.intevation.artifacts.httpclient.exceptions.ConnectionException; |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
10 import de.intevation.artifacts.httpclient.http.HttpClient; |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
11 import de.intevation.artifacts.httpclient.http.HttpClientImpl; |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
12 import de.intevation.artifacts.httpclient.http.response.DocumentResponseHandler; |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
13 |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
14 import de.intevation.artifacts.common.ArtifactNamespaceContext; |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
15 import de.intevation.artifacts.common.utils.XMLUtils; |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
16 |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
17 import de.intevation.flys.client.shared.exceptions.ServerException; |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
18 import de.intevation.flys.client.client.services.CollectionItemAttributeService; |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
19 |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
20 import de.intevation.flys.client.shared.model.Collection; |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
21 import de.intevation.flys.client.shared.model.CollectionItemAttribute; |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
22 import de.intevation.flys.client.shared.model.Style; |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
23 import de.intevation.flys.client.shared.model.StyleSetting; |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
24 |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
25 |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
26 /** |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
27 * |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
28 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
29 */ |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
30 public class CollectionItemAttributeServiceImpl |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
31 extends RemoteServiceServlet |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
32 implements CollectionItemAttributeService |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
33 { |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
34 public static final String XPATH_RESULT = "/art:result/text()"; |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
35 |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
36 public static final String OPERATION_FAILURE = "FAILED"; |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
37 |
1310
c4c957a9c092
Improved exception handling while fetching theme styles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1295
diff
changeset
|
38 public static final String ERROR_NO_STYLES_FOUND = |
c4c957a9c092
Improved exception handling while fetching theme styles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1295
diff
changeset
|
39 "error_no_theme_styles_found"; |
c4c957a9c092
Improved exception handling while fetching theme styles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1295
diff
changeset
|
40 |
1285
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
41 |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
42 public CollectionItemAttribute getCollectionItemAttribute( |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
43 Collection collection, |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
44 String artifact, |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
45 String url, |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
46 String locale) |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
47 throws ServerException |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
48 { |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
49 System.out.println( |
1292
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
50 "CollectionItemAttributeServiceImpl.getCollectionItemAttribute"); |
1285
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
51 |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
52 Document requestDoc = XMLUtils.newDocument(); |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
53 |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
54 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator( |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
55 requestDoc, |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
56 ArtifactNamespaceContext.NAMESPACE_URI, |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
57 ArtifactNamespaceContext.NAMESPACE_PREFIX); |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
58 |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
59 Element action = ec.create("action"); |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
60 |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
61 Element type = ec.create("type"); |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
62 ec.addAttr(type, "name", "getitemattribute", false); |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
63 |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
64 Element art = ec.create("artifact"); |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
65 ec.addAttr(art, "uuid", artifact, false); |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
66 |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
67 type.appendChild(art); |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
68 action.appendChild(type); |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
69 requestDoc.appendChild (action); |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
70 |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
71 try { |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
72 HttpClient client = new HttpClientImpl(url, locale); |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
73 Document res = (Document) client.doCollectionAction( |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
74 requestDoc, |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
75 collection.identifier(), |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
76 new DocumentResponseHandler()); |
1292
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
77 return readXML (res, artifact); |
1285
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
78 } |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
79 catch (ConnectionException ce) { |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
80 System.err.println(ce.getLocalizedMessage()); |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
81 } |
1310
c4c957a9c092
Improved exception handling while fetching theme styles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1295
diff
changeset
|
82 |
c4c957a9c092
Improved exception handling while fetching theme styles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1295
diff
changeset
|
83 throw new ServerException(ERROR_NO_STYLES_FOUND); |
1285
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
84 } |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
85 |
1292
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
86 |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
87 public void setCollectionItemAttribute( |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
88 Collection collection, |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
89 String artifact, |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
90 String url, |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
91 String locale, |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
92 CollectionItemAttribute attributes) |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
93 throws ServerException |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
94 { |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
95 System.out.println( |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
96 "CollectionItemAttributeServiceImpl.setCollectionItemAttribute"); |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
97 |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
98 Document doc = writeXML(attributes, artifact); |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
99 |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
100 try { |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
101 HttpClient client = new HttpClientImpl(url, locale); |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
102 Document res = (Document) client.doCollectionAction( |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
103 doc, |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
104 collection.identifier(), |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
105 new DocumentResponseHandler()); |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
106 |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
107 return; |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
108 } |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
109 catch (ConnectionException ce) { |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
110 System.err.println(ce.getLocalizedMessage()); |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
111 } |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
112 throw new ServerException(""); |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
113 } |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
114 |
1310
c4c957a9c092
Improved exception handling while fetching theme styles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1295
diff
changeset
|
115 protected CollectionItemAttribute readXML(Document doc, String artifact) |
c4c957a9c092
Improved exception handling while fetching theme styles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1295
diff
changeset
|
116 throws ServerException |
c4c957a9c092
Improved exception handling while fetching theme styles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1295
diff
changeset
|
117 { |
1285
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
118 CollectionItemAttribute cia = new CollectionItemAttribute(); |
1292
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
119 cia.setArtifact(artifact); |
1285
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
120 |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
121 Element root = doc.getDocumentElement(); |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
122 NodeList themes = root.getElementsByTagName("art:themes"); |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
123 |
1310
c4c957a9c092
Improved exception handling while fetching theme styles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1295
diff
changeset
|
124 if (themes == null || themes.getLength() == 0) { |
c4c957a9c092
Improved exception handling while fetching theme styles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1295
diff
changeset
|
125 throw new ServerException(ERROR_NO_STYLES_FOUND); |
1285
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
126 } |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
127 |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
128 Element e = (Element) themes.item(0); |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
129 NodeList items = e.getElementsByTagName("theme"); |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
130 |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
131 for (int i = 0; i < items.getLength(); i++) { |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
132 cia.appendStyle(getStyle ((Element) items.item(i))); |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
133 } |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
134 |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
135 return cia; |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
136 } |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
137 |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
138 |
1292
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
139 protected Document writeXML ( |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
140 CollectionItemAttribute attributes, |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
141 String artifact) |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
142 { |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
143 Document styles = XMLUtils.newDocument(); |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
144 |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
145 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator( |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
146 styles, |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
147 ArtifactNamespaceContext.NAMESPACE_URI, |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
148 ArtifactNamespaceContext.NAMESPACE_PREFIX); |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
149 Element action = ec.create("action"); |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
150 Element type = ec.create("type"); |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
151 type.setAttribute("name", "setitemattribute"); |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
152 Element art = ec.create("artifact"); |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
153 art.setAttribute("uuid", artifact); |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
154 Element attr = ec.create("attribute"); |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
155 Element themes = ec.create("themes"); |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
156 action.appendChild(type); |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
157 type.appendChild(art); |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
158 art.appendChild(attr); |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
159 attr.appendChild(themes); |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
160 |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
161 XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator( |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
162 styles, |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
163 "", |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
164 ""); |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
165 |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
166 for (int i = 0; i < attributes.getNumStyles(); i++) { |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
167 Style s = attributes.getStyle(i); |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
168 Element theme = creator.create("theme"); |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
169 theme.setAttribute("name", s.getName()); |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
170 theme.setAttribute("facet", s.getFacet()); |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
171 theme.setAttribute("index", String.valueOf(i)); |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
172 for (int j = 0; j < s.getNumSettings(); j++) { |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
173 StyleSetting set = s.getSetting(j); |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
174 Element field = creator.create("field"); |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
175 field.setAttribute("name", set.getName()); |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
176 field.setAttribute("display", set.getDisplayName()); |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
177 field.setAttribute("default", set.getDefaultValue()); |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
178 field.setAttribute("hints", set.getHints()); |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
179 field.setAttribute("type", set.getType()); |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
180 theme.appendChild(field); |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
181 } |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
182 themes.appendChild(theme); |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
183 } |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
184 styles.appendChild(action); |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
185 return styles; |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
186 } |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
187 |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
188 |
1285
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
189 protected Style getStyle (Element element) { |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
190 |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
191 if (!element.getTagName().equals("theme")) { |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
192 return null; |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
193 } |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
194 |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
195 NodeList list = element.getElementsByTagName("field"); |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
196 Style style = new Style(); |
1292
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
197 |
1285
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
198 style.setName (element.getAttribute("name")); |
1292
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
199 style.setFacet (element.getAttribute("facet")); |
1285
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
200 for(int i = 0; i < list.getLength(); i++) { |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
201 Element e = (Element) list.item(i); |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
202 StyleSetting set = new StyleSetting ( |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
203 e.getAttribute("name"), |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
204 e.getAttribute("default"), |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
205 e.getAttribute("display"), |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
206 e.getAttribute("hints"), |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
207 e.getAttribute("type")); |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
208 style.appendStyleSetting(set); |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
209 } |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
210 return style; |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
211 } |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
212 } |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
213 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |