Mercurial > dive4elements > river
annotate flys-client/src/main/java/de/intevation/flys/client/server/CollectionItemAttributeServiceImpl.java @ 4925:57609ffb3843
AttributeWriter: Use new CollectionAttribute.hasOutput .
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Thu, 31 Jan 2013 09:29:24 +0100 |
parents | 7a94d5e7fc3d |
children | b296d435fc69 |
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 |
1367
ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1329
diff
changeset
|
7 import org.apache.log4j.Logger; |
ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1329
diff
changeset
|
8 |
1285
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
9 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
|
10 |
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.exceptions.ConnectionException; |
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.HttpClient; |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
13 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
|
14 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
|
15 |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
16 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
|
17 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
|
18 |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
19 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
|
20 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
|
21 |
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.Collection; |
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.CollectionItemAttribute; |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
24 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
|
25 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
|
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 /** |
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 * @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
|
31 */ |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
32 public class CollectionItemAttributeServiceImpl |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
33 extends RemoteServiceServlet |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
34 implements CollectionItemAttributeService |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
35 { |
1367
ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1329
diff
changeset
|
36 private static final Logger logger = |
ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1329
diff
changeset
|
37 Logger.getLogger(CollectionItemAttributeServiceImpl.class); |
ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1329
diff
changeset
|
38 |
ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1329
diff
changeset
|
39 |
1285
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
40 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
|
41 |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
42 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
|
43 |
1310
c4c957a9c092
Improved exception handling while fetching theme styles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1295
diff
changeset
|
44 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
|
45 "error_no_theme_styles_found"; |
c4c957a9c092
Improved exception handling while fetching theme styles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1295
diff
changeset
|
46 |
1285
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
47 |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
48 public CollectionItemAttribute getCollectionItemAttribute( |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
49 Collection collection, |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
50 String artifact, |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
51 String locale) |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
52 throws ServerException |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
53 { |
1367
ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1329
diff
changeset
|
54 logger.info( |
1292
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
55 "CollectionItemAttributeServiceImpl.getCollectionItemAttribute"); |
1285
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
56 |
1425
bc06a671ef60
Removed the URL parameter from service calls. The service
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1367
diff
changeset
|
57 String url = getServletContext().getInitParameter("server-url"); |
bc06a671ef60
Removed the URL parameter from service calls. The service
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1367
diff
changeset
|
58 |
1285
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
59 Document requestDoc = XMLUtils.newDocument(); |
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 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator( |
1442
4a6814be92ba
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1425
diff
changeset
|
62 requestDoc, |
4a6814be92ba
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1425
diff
changeset
|
63 ArtifactNamespaceContext.NAMESPACE_URI, |
4a6814be92ba
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1425
diff
changeset
|
64 ArtifactNamespaceContext.NAMESPACE_PREFIX); |
1285
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
65 |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
66 Element action = ec.create("action"); |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
67 |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
68 Element type = ec.create("type"); |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
69 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
|
70 |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
71 Element art = ec.create("artifact"); |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
72 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
|
73 |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
74 type.appendChild(art); |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
75 action.appendChild(type); |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
76 requestDoc.appendChild (action); |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
77 |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
78 try { |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
79 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
|
80 Document res = (Document) client.doCollectionAction( |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
81 requestDoc, |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
82 collection.identifier(), |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
83 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
|
84 return readXML (res, artifact); |
1285
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
85 } |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
86 catch (ConnectionException ce) { |
1367
ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1329
diff
changeset
|
87 logger.error(ce, ce); |
1285
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
88 } |
1310
c4c957a9c092
Improved exception handling while fetching theme styles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1295
diff
changeset
|
89 |
c4c957a9c092
Improved exception handling while fetching theme styles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1295
diff
changeset
|
90 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
|
91 } |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
92 |
1292
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
93 |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
94 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
|
95 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
|
96 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
|
97 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
|
98 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
|
99 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
|
100 { |
1367
ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1329
diff
changeset
|
101 logger.info( |
1292
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
102 "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
|
103 |
1425
bc06a671ef60
Removed the URL parameter from service calls. The service
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1367
diff
changeset
|
104 String url = getServletContext().getInitParameter("server-url"); |
bc06a671ef60
Removed the URL parameter from service calls. The service
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1367
diff
changeset
|
105 |
1292
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
106 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
|
107 |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
108 try { |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
109 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
|
110 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
|
111 doc, |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
112 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
|
113 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
|
114 |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
115 return; |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
116 } |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
117 catch (ConnectionException ce) { |
1367
ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1329
diff
changeset
|
118 logger.error(ce, ce); |
ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1329
diff
changeset
|
119 throw new ServerException(ce.getLocalizedMessage()); |
1292
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
120 } |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
121 } |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
122 |
1310
c4c957a9c092
Improved exception handling while fetching theme styles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1295
diff
changeset
|
123 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
|
124 throws ServerException |
c4c957a9c092
Improved exception handling while fetching theme styles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1295
diff
changeset
|
125 { |
1285
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
126 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
|
127 cia.setArtifact(artifact); |
1285
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
128 |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
129 Element root = doc.getDocumentElement(); |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
130 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
|
131 |
1310
c4c957a9c092
Improved exception handling while fetching theme styles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1295
diff
changeset
|
132 if (themes == null || themes.getLength() == 0) { |
c4c957a9c092
Improved exception handling while fetching theme styles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1295
diff
changeset
|
133 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
|
134 } |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
135 |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
136 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
|
137 NodeList items = e.getElementsByTagName("theme"); |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
138 |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
139 for (int i = 0; i < items.getLength(); i++) { |
2908
cd068ff7966d
Show only style attributes in StyleEditorWindow that are not 'hidden'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1442
diff
changeset
|
140 Style s = StyleHelper.getStyle ((Element) items.item(i)); |
1326
974c6b3700de
Use the theme index to identify the correct style.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1310
diff
changeset
|
141 if(s == null) { |
974c6b3700de
Use the theme index to identify the correct style.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1310
diff
changeset
|
142 throw new ServerException(ERROR_NO_STYLES_FOUND); |
974c6b3700de
Use the theme index to identify the correct style.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1310
diff
changeset
|
143 } |
974c6b3700de
Use the theme index to identify the correct style.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1310
diff
changeset
|
144 else { |
974c6b3700de
Use the theme index to identify the correct style.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1310
diff
changeset
|
145 cia.appendStyle(s); |
974c6b3700de
Use the theme index to identify the correct style.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1310
diff
changeset
|
146 } |
1285
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
147 } |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
148 |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
149 return cia; |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
150 } |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
151 |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
152 |
1292
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
153 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
|
154 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
|
155 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
|
156 { |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
157 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
|
158 |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
159 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
|
160 styles, |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
161 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
|
162 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
|
163 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
|
164 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
|
165 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
|
166 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
|
167 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
|
168 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
|
169 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
|
170 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
|
171 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
|
172 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
|
173 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
|
174 |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
175 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
|
176 styles, |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
177 "", |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
178 ""); |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
179 |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
180 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
|
181 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
|
182 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
|
183 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
|
184 theme.setAttribute("facet", s.getFacet()); |
1329
b18b32269a3f
Set the correct index when saving changed attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1326
diff
changeset
|
185 theme.setAttribute("index", String.valueOf(s.getIndex())); |
1292
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
186 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
|
187 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
|
188 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
|
189 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
|
190 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
|
191 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
|
192 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
|
193 field.setAttribute("type", set.getType()); |
4284
7a94d5e7fc3d
Write the "hidden" attribute of a style into the collection's attribute when using the theme editor.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2908
diff
changeset
|
194 field.setAttribute("hidden", String.valueOf(set.isHidden())); |
1292
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
195 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
|
196 } |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
197 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
|
198 } |
bdc270ea6195
Edited item attributes are saved and send to the server on accept.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1285
diff
changeset
|
199 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
|
200 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
|
201 } |
1285
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
202 } |
0f3b19df1880
Added new service and model for collection item attributes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
203 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |