Mercurial > dive4elements > river
diff 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 |
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/server/DescribeCollectionServiceImpl.java Mon Jul 18 09:52:16 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/DescribeCollectionServiceImpl.java Tue Jul 19 16:32:52 2011 +0000 @@ -9,6 +9,8 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; import org.w3c.dom.NodeList; import com.google.gwt.user.server.rpc.RemoteServiceServlet; @@ -23,6 +25,7 @@ import de.intevation.artifacts.httpclient.http.response.DocumentResponseHandler; import de.intevation.flys.client.shared.exceptions.ServerException; +import de.intevation.flys.client.shared.model.AttributedTheme; import de.intevation.flys.client.shared.model.Collection; import de.intevation.flys.client.shared.model.CollectionItem; import de.intevation.flys.client.shared.model.DefaultCollection; @@ -206,7 +209,7 @@ NodeList themes = node.getElementsByTagNameNS( ArtifactNamespaceContext.NAMESPACE_URI, - "theme"); + "facet"); int num = themes != null ? themes.getLength() : 0; @@ -229,29 +232,22 @@ String uri = ArtifactNamespaceContext.NAMESPACE_URI; - String strAct = ele.getAttributeNS(uri, "active"); - String art = ele.getAttributeNS(uri, "artifact"); - String fac = ele.getAttributeNS(uri, "facet"); - String strPos = ele.getAttributeNS(uri, "pos"); - String desc = ele.getAttributeNS(uri, "description"); - String strIdx = ele.getAttributeNS(uri, "index"); + NamedNodeMap attrMap = ele.getAttributes(); + int attrNum = attrMap != null ? attrMap.getLength() : 0; - if (strAct.length() > 0 && art.length() > 0 && fac.length() > 0 - && strPos.length() > 0 && strIdx.length() > 0) - { - try { - int pos = Integer.valueOf(strPos); - int active = Integer.valueOf(strAct); - int idx = Integer.valueOf(strIdx); + AttributedTheme t = new AttributedTheme(); - return new DefaultTheme(pos, idx, active > 0, art, fac, desc); - } - catch (NumberFormatException nfe) { - nfe.printStackTrace(); - } + for (int i = 0; i < attrNum; i++) { + Node attr = attrMap.item(i); + + String prefix = attr.getPrefix(); + String name = attr.getNodeName().replace(prefix + ":", ""); + String value = attr.getNodeValue(); + + t.addAttr(name, value); } - return null; + return t; }