[Dive4elements-commits] [PATCH 2 of 2] Merged

Wald Commits scm-commit at wald.intevation.org
Thu Oct 25 14:02:54 CEST 2012


# HG changeset patch
# User Ingo Weinzierl <weinzierl.ingo at googlemail.com>
# Date 1351166559 -7200
# Node ID 9a1a3406deb5c2b8d4fe1fbac3e537f49bfc01ba
# Parent  33b15ac17fd1f52a061d6f3d585346d071beea0e
# Parent  670e98f5a44114cb2a6b3bf319a50e781c62d613
Merged.

diff -r 33b15ac17fd1 -r 9a1a3406deb5 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 Oct 25 13:58:53 2012 +0200
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/ManagedFacet.java	Thu Oct 25 14:02:39 2012 +0200
@@ -4,19 +4,17 @@
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 
-import de.intevation.artifacts.ArtifactNamespaceContext;
-
-import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator;
-
 import de.intevation.artifactdatabase.state.DefaultFacet;
 import de.intevation.artifactdatabase.state.Facet;
+import de.intevation.artifacts.ArtifactNamespaceContext;
+import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator;
 
 
 /**
  * Facet with user-supplied theme-control-information (pos in list,
  * active/disabled etc) attached.
  */
-public class ManagedFacet extends DefaultFacet {
+public class ManagedFacet extends DefaultFacet implements Comparable {
 
     /** The uuid of the owner artifact. */
     protected String uuid;
@@ -30,28 +28,19 @@
     /** A property that determines if this facet is visible or not. */
     protected int visible;
 
-
     public ManagedFacet() {
     }
 
-    public ManagedFacet(
-        String  name,
-        int     index,
-        String  desc,
-        String  uuid,
-        int     pos,
-        int     active,
-        int     visible)
-    {
+    public ManagedFacet(String name, int index, String desc, String uuid,
+        int pos, int active, int visible) {
         super(index, name, desc);
 
-        this.uuid     = uuid;
+        this.uuid = uuid;
         this.position = pos;
-        this.active   = active;
-        this.visible  = visible;
+        this.active = active;
+        this.visible = visible;
     }
 
-
     /**
      * Sets position (will be merged to position in ThemeList).
      */
@@ -59,44 +48,37 @@
         this.position = pos;
     }
 
-
     public int getPosition() {
         return position;
     }
 
-
     public void setActive(int active) {
         this.active = active;
     }
 
-
     public int getActive() {
         return active;
     }
 
-
     public void setVisible(int visible) {
         this.visible = visible;
     }
 
-
     public int getVisible() {
         return visible;
     }
 
-
     /**
      * Get uuid of related artifact.
+     * 
      * @return uuid of related artifact.
      */
     public String getArtifact() {
         return uuid;
     }
 
-
     public Node toXML(Document doc) {
-        ElementCreator ec = new ElementCreator(
-            doc,
+        ElementCreator ec = new ElementCreator(doc,
             ArtifactNamespaceContext.NAMESPACE_URI,
             ArtifactNamespaceContext.NAMESPACE_PREFIX);
 
@@ -113,17 +95,36 @@
     }
 
     public void set(ManagedFacet other) {
-        uuid     = other.uuid;
+        uuid = other.uuid;
         position = other.position;
-        active   = other.active;
+        active = other.active;
     }
 
     @Override
     public Facet deepCopy() {
         ManagedFacet copy = new ManagedFacet();
-        copy.set((DefaultFacet)this);
-        copy.set((ManagedFacet)this);
+        copy.set((DefaultFacet) this);
+        copy.set((ManagedFacet) this);
         return copy;
     }
+
+    @Override
+    public int compareTo(Object o) {
+        if (!(o instanceof ManagedFacet)) {
+            return -1;
+        }
+
+        ManagedFacet other = (ManagedFacet) o;
+
+        if (position < other.position) {
+            return -1;
+        }
+        else if (position > other.position) {
+            return 1;
+        }
+        else {
+            return 0;
+        }
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r 33b15ac17fd1 -r 9a1a3406deb5 flys-artifacts/src/main/java/de/intevation/flys/exports/OutputHelper.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/OutputHelper.java	Thu Oct 25 13:58:53 2012 +0200
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/OutputHelper.java	Thu Oct 25 14:02:39 2012 +0200
@@ -2,6 +2,7 @@
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -470,10 +471,10 @@
      */
     private static class ThemeList {
         private Logger logger = Logger.getLogger(ThemeList.class);
-        protected Map<Integer, ManagedFacet> themes;
+        protected List<ManagedFacet> themes;
 
         public ThemeList(Document output) {
-            themes = new HashMap<Integer, ManagedFacet>();
+            themes = new ArrayList<ManagedFacet>();
             parse(output);
         }
 
@@ -496,12 +497,14 @@
                 Element theme = (Element) themeList.item(i);
 
                 ManagedDomFacet facet = new ManagedDomFacet(theme);
-                themes.put(Integer.valueOf(facet.getPosition()-1), facet);
+                themes.add(facet);
             }
+
+            Collections.sort(themes);
         }
 
         public ManagedFacet get(int idx) {
-            return themes.get(Integer.valueOf(idx));
+            return themes.get(idx);
         }
 
         public int size() {


More information about the Dive4elements-commits mailing list