comparison flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java @ 1717:755a890ecf0e

FLYSArtifactCollection.ThemeList makes now use of ManagedDomFacet to read all attributes of a Facet. flys-artifacts/trunk@2995 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 17 Oct 2011 15:53:59 +0000
parents a70e0cbc5e02
children defe2cfeefa5
comparison
equal deleted inserted replaced
1716:3ca999f507b7 1717:755a890ecf0e
31 import de.intevation.artifactdatabase.Backend.PersistentArtifact; 31 import de.intevation.artifactdatabase.Backend.PersistentArtifact;
32 import de.intevation.artifactdatabase.DefaultArtifactCollection; 32 import de.intevation.artifactdatabase.DefaultArtifactCollection;
33 33
34 import de.intevation.flys.artifacts.context.FLYSContext; 34 import de.intevation.flys.artifacts.context.FLYSContext;
35 import de.intevation.flys.artifacts.model.ManagedFacet; 35 import de.intevation.flys.artifacts.model.ManagedFacet;
36 import de.intevation.flys.artifacts.model.ManagedDomFacet;
36 import de.intevation.flys.exports.OutGenerator; 37 import de.intevation.flys.exports.OutGenerator;
37 import de.intevation.flys.themes.Theme; 38 import de.intevation.flys.themes.Theme;
38 import de.intevation.flys.themes.ThemeFactory; 39 import de.intevation.flys.themes.ThemeFactory;
39 40
40 41
773 themes = new HashMap<Integer, ManagedFacet>(); 774 themes = new HashMap<Integer, ManagedFacet>();
774 parse(output); 775 parse(output);
775 } 776 }
776 777
777 protected void parse(Document output) { 778 protected void parse(Document output) {
778 NodeList themes = (NodeList) XMLUtils.xpath( 779 NodeList themeList = (NodeList) XMLUtils.xpath(
779 output, 780 output,
780 "art:output/art:facet", 781 "art:output/art:facet",
781 XPathConstants.NODESET, 782 XPathConstants.NODESET,
782 ArtifactNamespaceContext.INSTANCE); 783 ArtifactNamespaceContext.INSTANCE);
783 784
784 int num = themes != null ? themes.getLength() : 0; 785 int num = themeList != null ? themeList.getLength() : 0;
785 786
786 logger.debug("Output has " + num + " elements."); 787 logger.debug("Output has " + num + " elements.");
787 788
788 if (num == 0) { 789 if (num == 0) {
789 return; 790 return;
790 } 791 }
791 792
792 String uri = ArtifactNamespaceContext.NAMESPACE_URI; 793 String uri = ArtifactNamespaceContext.NAMESPACE_URI;
793 794
794 for (int i = 0; i < num; i++) { 795 for (int i = 0; i < num; i++) {
795 Element theme = (Element) themes.item(i); 796 Element theme = (Element) themeList.item(i);
796 797
797 String name = theme.getAttributeNS(uri, "facet"); 798 ManagedDomFacet facet = new ManagedDomFacet(theme);
798 String uuid = theme.getAttributeNS(uri, "artifact"); 799 themes.put(new Integer(facet.getPosition()-1), facet);
799 String pos = theme.getAttributeNS(uri, "pos");
800 String active = theme.getAttributeNS(uri, "active");
801 String idx = theme.getAttributeNS(uri, "index");
802 String desc = theme.getAttributeNS(uri, "description");
803 String visible = theme.getAttributeNS(uri, "visible");
804
805 addTheme(uuid, name, idx, pos, active, desc, visible);
806 }
807 }
808
809 protected void addTheme(
810 String uuid,
811 String name,
812 String index,
813 String position,
814 String active,
815 String desc,
816 String visible)
817 {
818 if (logger.isDebugEnabled()) {
819 logger.debug("Add theme: ");
820 logger.debug(".. name: " + name);
821 logger.debug(".. uuid: " + uuid);
822 logger.debug(".. position: " + position);
823 logger.debug(".. active: " + active);
824 logger.debug(".. visible: " + visible);
825 }
826
827 try {
828 int pos = Integer.parseInt(position);
829 int act = Integer.parseInt(active);
830 int idx = Integer.parseInt(index);
831 int vis = Integer.parseInt(visible);
832
833 themes.put(
834 new Integer(pos-1),
835 new ManagedFacet(name, idx, desc, uuid, pos, act, vis));
836 }
837 catch (NumberFormatException nfe) {
838 logger.warn(nfe, nfe);
839 } 800 }
840 } 801 }
841 802
842 public ManagedFacet get(int idx) { 803 public ManagedFacet get(int idx) {
843 return themes.get(new Integer(idx)); 804 return themes.get(new Integer(idx));

http://dive4elements.wald.intevation.org