comparison flys-client/src/main/java/de/intevation/flys/client/server/DescribeCollectionServiceImpl.java @ 804:374712890b94

Facets read from Collection's DESCRIBE document keep all their attributes after the Collection's attribute has been modified. flys-client/trunk@2362 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 19 Jul 2011 16:32:52 +0000
parents cd8603aaa730
children e9337488bac3
comparison
equal deleted inserted replaced
803:653ae84533e7 804:374712890b94
7 7
8 import javax.xml.xpath.XPathConstants; 8 import javax.xml.xpath.XPathConstants;
9 9
10 import org.w3c.dom.Document; 10 import org.w3c.dom.Document;
11 import org.w3c.dom.Element; 11 import org.w3c.dom.Element;
12 import org.w3c.dom.NamedNodeMap;
13 import org.w3c.dom.Node;
12 import org.w3c.dom.NodeList; 14 import org.w3c.dom.NodeList;
13 15
14 import com.google.gwt.user.server.rpc.RemoteServiceServlet; 16 import com.google.gwt.user.server.rpc.RemoteServiceServlet;
15 17
16 import de.intevation.artifacts.common.ArtifactNamespaceContext; 18 import de.intevation.artifacts.common.ArtifactNamespaceContext;
21 import de.intevation.artifacts.httpclient.http.HttpClient; 23 import de.intevation.artifacts.httpclient.http.HttpClient;
22 import de.intevation.artifacts.httpclient.http.HttpClientImpl; 24 import de.intevation.artifacts.httpclient.http.HttpClientImpl;
23 import de.intevation.artifacts.httpclient.http.response.DocumentResponseHandler; 25 import de.intevation.artifacts.httpclient.http.response.DocumentResponseHandler;
24 26
25 import de.intevation.flys.client.shared.exceptions.ServerException; 27 import de.intevation.flys.client.shared.exceptions.ServerException;
28 import de.intevation.flys.client.shared.model.AttributedTheme;
26 import de.intevation.flys.client.shared.model.Collection; 29 import de.intevation.flys.client.shared.model.Collection;
27 import de.intevation.flys.client.shared.model.CollectionItem; 30 import de.intevation.flys.client.shared.model.CollectionItem;
28 import de.intevation.flys.client.shared.model.DefaultCollection; 31 import de.intevation.flys.client.shared.model.DefaultCollection;
29 import de.intevation.flys.client.shared.model.DefaultCollectionItem; 32 import de.intevation.flys.client.shared.model.DefaultCollectionItem;
30 import de.intevation.flys.client.shared.model.DefaultFacet; 33 import de.intevation.flys.client.shared.model.DefaultFacet;
204 protected ThemeList parseThemeList(Element node) { 207 protected ThemeList parseThemeList(Element node) {
205 System.out.println("DescribeCollectionServiceImpl.parseThemeList"); 208 System.out.println("DescribeCollectionServiceImpl.parseThemeList");
206 209
207 NodeList themes = node.getElementsByTagNameNS( 210 NodeList themes = node.getElementsByTagNameNS(
208 ArtifactNamespaceContext.NAMESPACE_URI, 211 ArtifactNamespaceContext.NAMESPACE_URI,
209 "theme"); 212 "facet");
210 213
211 int num = themes != null ? themes.getLength() : 0; 214 int num = themes != null ? themes.getLength() : 0;
212 215
213 List<Theme> themeList = new ArrayList<Theme>(num); 216 List<Theme> themeList = new ArrayList<Theme>(num);
214 217
227 protected Theme parseTheme(Element ele) { 230 protected Theme parseTheme(Element ele) {
228 System.out.println("DescribeCollectionServiceImpl.parseTheme"); 231 System.out.println("DescribeCollectionServiceImpl.parseTheme");
229 232
230 String uri = ArtifactNamespaceContext.NAMESPACE_URI; 233 String uri = ArtifactNamespaceContext.NAMESPACE_URI;
231 234
232 String strAct = ele.getAttributeNS(uri, "active"); 235 NamedNodeMap attrMap = ele.getAttributes();
233 String art = ele.getAttributeNS(uri, "artifact"); 236 int attrNum = attrMap != null ? attrMap.getLength() : 0;
234 String fac = ele.getAttributeNS(uri, "facet"); 237
235 String strPos = ele.getAttributeNS(uri, "pos"); 238 AttributedTheme t = new AttributedTheme();
236 String desc = ele.getAttributeNS(uri, "description"); 239
237 String strIdx = ele.getAttributeNS(uri, "index"); 240 for (int i = 0; i < attrNum; i++) {
238 241 Node attr = attrMap.item(i);
239 if (strAct.length() > 0 && art.length() > 0 && fac.length() > 0 242
240 && strPos.length() > 0 && strIdx.length() > 0) 243 String prefix = attr.getPrefix();
241 { 244 String name = attr.getNodeName().replace(prefix + ":", "");
242 try { 245 String value = attr.getNodeValue();
243 int pos = Integer.valueOf(strPos); 246
244 int active = Integer.valueOf(strAct); 247 t.addAttr(name, value);
245 int idx = Integer.valueOf(strIdx); 248 }
246 249
247 return new DefaultTheme(pos, idx, active > 0, art, fac, desc); 250 return t;
248 }
249 catch (NumberFormatException nfe) {
250 nfe.printStackTrace();
251 }
252 }
253
254 return null;
255 } 251 }
256 252
257 253
258 /** 254 /**
259 * This method extracts the CollectionItem from <i>node</i> with its output 255 * This method extracts the CollectionItem from <i>node</i> with its output

http://dive4elements.wald.intevation.org