# HG changeset patch # User Ingo Weinzierl # Date 1308233449 0 # Node ID 68c6c75a6f7cfca316c6a5512514b392c44e6add # Parent af393c5eb2c8ecacff5391fdb9f9875cc78dc982 Add index and description of facets to collections describe document. flys-artifacts/branches/facets-slt@2136 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r af393c5eb2c8 -r 68c6c75a6f7c flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/ManagedFacet.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/ManagedFacet.java Thu Jun 16 13:24:00 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/ManagedFacet.java Thu Jun 16 14:10:49 2011 +0000 @@ -8,6 +8,9 @@ /** The uuid of the owner artifact.*/ protected String uuid; + /** The index.*/ + protected int index; + /** A property that determines the position of this facet.*/ protected int position; @@ -17,12 +20,13 @@ public ManagedFacet( String name, + int index, String desc, String uuid, int pos, int active) { - super(name, desc); + super(index, name, desc); this.uuid = uuid; this.position = pos; diff -r af393c5eb2c8 -r 68c6c75a6f7c flys-artifacts/src/main/java/de/intevation/flys/collections/AttributeParser.java --- a/flys-artifacts/src/main/java/de/intevation/flys/collections/AttributeParser.java Thu Jun 16 13:24:00 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/collections/AttributeParser.java Thu Jun 16 14:10:49 2011 +0000 @@ -8,6 +8,7 @@ import org.apache.log4j.Logger; import org.w3c.dom.Document; +import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; @@ -99,39 +100,40 @@ logger.debug("Output has " + num + " themes."); - for (int i = 0; i < num; i++) { - Node theme = themes.item(i); + String uri = ArtifactNamespaceContext.NAMESPACE_URI; - String name = XMLUtils.xpathString( - theme, "@art:facet", ArtifactNamespaceContext.INSTANCE); + for (int i = 0; i < num; i++) { + Element theme = (Element) themes.item(i); + String name = theme.getAttributeNS(uri, "facet"); if (name == null || name.length() == 0) { continue; } - String uuid = XMLUtils.xpathString( - theme, "@art:artifact", ArtifactNamespaceContext.INSTANCE); - + String uuid = theme.getAttributeNS(uri, "artifact"); if (uuid == null || uuid.length() == 0) { continue; } - String pos = XMLUtils.xpathString( - theme, "@art:pos", ArtifactNamespaceContext.INSTANCE); - + String pos = theme.getAttributeNS(uri, "pos"); if (pos == null || pos.length() == 0) { continue; } - String active = XMLUtils.xpathString( - theme, "@art:active", ArtifactNamespaceContext.INSTANCE); + String index = theme.getAttributeNS(uri, "index"); + if (index == null || index.length() == 0) { + continue; + } + String active = theme.getAttributeNS(uri, "active"); if (active == null || active.length() == 0) { continue; } + String description = theme.getAttributeNS(uri, "description"); + ManagedFacet item = new ManagedFacet( - name, "", uuid, + name, Integer.parseInt(index), description, uuid, Integer.parseInt(pos), Integer.parseInt(active)); diff -r af393c5eb2c8 -r 68c6c75a6f7c flys-artifacts/src/main/java/de/intevation/flys/collections/AttributeWriter.java --- a/flys-artifacts/src/main/java/de/intevation/flys/collections/AttributeWriter.java Thu Jun 16 13:24:00 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/collections/AttributeWriter.java Thu Jun 16 14:10:49 2011 +0000 @@ -116,7 +116,7 @@ ManagedFacet a, List list) { - String name = a.getName(); + String name = a.getName() + a.getIndex(); if (list == null) { logger.debug("No old facets found."); @@ -124,7 +124,7 @@ } for (Facet facet: list) { - if (name.equals(facet.getName())) { + if (name.equals(facet.getName() + facet.getIndex())) { writeFacet(doc, cr, output, (ManagedFacet) facet); return true; } @@ -145,6 +145,8 @@ cr.addAttr(theme, "facet", f.getName(), true); cr.addAttr(theme, "pos", Integer.toString(f.getPosition()), true); cr.addAttr(theme, "active", Integer.toString(f.getActive()), true); + cr.addAttr(theme, "index", Integer.toString(f.getIndex()), true); + cr.addAttr(theme, "description", f.getDescription(), true); output.appendChild(theme); } diff -r af393c5eb2c8 -r 68c6c75a6f7c flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java --- a/flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java Thu Jun 16 13:24:00 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java Thu Jun 16 14:10:49 2011 +0000 @@ -719,30 +719,29 @@ return; } - for (int i = 0; i < num; i++) { - Node theme = themes.item(i); - - String name = XMLUtils.xpathString( - theme, "@art:facet", ArtifactNamespaceContext.INSTANCE); + String uri = ArtifactNamespaceContext.NAMESPACE_URI; - String uuid = XMLUtils.xpathString( - theme, "@art:artifact", ArtifactNamespaceContext.INSTANCE); + for (int i = 0; i < num; i++) { + Element theme = (Element) themes.item(i); - String pos = XMLUtils.xpathString( - theme, "@art:pos", ArtifactNamespaceContext.INSTANCE); + String name = theme.getAttributeNS(uri, "facet"); + String uuid = theme.getAttributeNS(uri, "artifact"); + String pos = theme.getAttributeNS(uri, "pos"); + String active = theme.getAttributeNS(uri, "active"); + String idx = theme.getAttributeNS(uri, "index"); + String desc = theme.getAttributeNS(uri, "description"); - String active = XMLUtils.xpathString( - theme, "@art:active", ArtifactNamespaceContext.INSTANCE); - - addTheme(uuid, name, pos, active); + addTheme(uuid, name, idx, pos, active, desc); } } protected void addTheme( String uuid, String name, + String index, String position, - String active) + String active, + String description) { if (logger.isDebugEnabled()) { logger.debug("Add theme: "); @@ -755,10 +754,11 @@ try { int pos = Integer.parseInt(position); int act = Integer.parseInt(active); + int idx = Integer.parseInt(index); themes.put( new Integer(pos-1), - new ManagedFacet(name, null, uuid, pos, act)); + new ManagedFacet(name, idx, description, uuid, pos, act)); } catch (NumberFormatException nfe) { logger.warn(nfe, nfe); diff -r af393c5eb2c8 -r 68c6c75a6f7c flys-artifacts/src/main/java/de/intevation/flys/collections/OutputParser.java --- a/flys-artifacts/src/main/java/de/intevation/flys/collections/OutputParser.java Thu Jun 16 13:24:00 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/collections/OutputParser.java Thu Jun 16 14:10:49 2011 +0000 @@ -8,6 +8,7 @@ import org.apache.log4j.Logger; import org.w3c.dom.Document; +import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; @@ -124,15 +125,19 @@ int num = facets != null ? facets.getLength() : 0; + String uri = ArtifactNamespaceContext.NAMESPACE_URI; + logger.debug("Output has " + num + " facets."); for (int i = 0; i < num; i++) { - Node facet = facets.item(i); + Element facet = (Element) facets.item(i); - String name = XMLUtils.xpathString( - facet, "@art:name", ArtifactNamespaceContext.INSTANCE); + String name = facet.getAttributeNS(uri, "name"); + String desc = facet.getAttributeNS(uri, "description"); + String index = facet.getAttributeNS(uri, "index"); - ManagedFacet item = new ManagedFacet(name, null, uuid, 1, 1); + ManagedFacet item = new ManagedFacet( + name, Integer.parseInt(index), desc, uuid, 1, 1); addItem(outname, item); }