changeset 7175:b1f446f675b1

Save target_out in the recommendation to ensure it is sent to the server
author Andre Heinecke <aheinecke@intevation.de>
date Thu, 26 Sep 2013 19:02:36 +0200
parents 87a7cdb6ee1e
children 1a938a5a7e21
files gwt-client/src/main/java/org/dive4elements/river/client/shared/model/ToLoad.java
diffstat 1 files changed, 25 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/gwt-client/src/main/java/org/dive4elements/river/client/shared/model/ToLoad.java	Thu Sep 26 17:31:25 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/shared/model/ToLoad.java	Thu Sep 26 19:02:36 2013 +0200
@@ -21,26 +21,34 @@
 {
 
     /** Two strings. */
-    public class StringPair {
+    public static class StringTriple {
         public String first;
         public String second;
-        public StringPair(String first, String second) {
+        public String third;
+        public StringTriple(String first, String second, String third) {
             this.first = first;
             this.second = second;
+            this.third = third;
         }
+        @Override
         public int hashCode() {
-            return first.hashCode() + second.hashCode();
+            return first.hashCode() + second.hashCode() + third.hashCode();
         }
-        public boolean equals(StringPair other) {
-            return (this.second.equals(other.second)) && (this.first.equals(other.first));
+        @Override
+        public boolean equals(Object o) {
+            if (!(o instanceof StringTriple)) {
+                return false;
+            }
+            StringTriple other = (StringTriple) o;
+            return second.equals(other.second) && first.equals(other.first) && third.equals(other.third);
         }
     }
     public static final String SYNTHETIC_KEY = "key-";
 
-    protected Map<String, Map<StringPair, ArtifactFilter>> artifacts;
+    protected Map<String, Map<StringTriple, ArtifactFilter>> artifacts;
 
     public ToLoad() {
-        artifacts = new HashMap<String, Map<StringPair, ArtifactFilter>>();
+        artifacts = new HashMap<String, Map<StringTriple, ArtifactFilter>>();
     }
 
     public static final String uniqueKey(Map<?, ?> map) {
@@ -81,17 +89,17 @@
             artifactName = uniqueKey(artifacts);
         }
 
-        Map<StringPair, ArtifactFilter> artifact = artifacts.get(artifactName);
+        Map<StringTriple, ArtifactFilter> artifact = artifacts.get(artifactName);
 
         if (artifact == null) {
-            artifact = new HashMap<StringPair, ArtifactFilter>();
+            artifact = new HashMap<StringTriple, ArtifactFilter>();
             artifacts.put(artifactName, artifact);
         }
 
         ArtifactFilter filter = artifact.get(factory);
         if (filter == null) {
             filter = new ArtifactFilter(factory);
-            artifact.put(new StringPair(factory, displayName), filter);
+            artifact.put(new StringTriple(factory, displayName, targetOut), filter);
         }
 
         filter.add(out, name, ids);
@@ -104,7 +112,7 @@
     public List<Recommendation> toRecommendations() {
         List<Recommendation> recommendations = new ArrayList<Recommendation>();
 
-        for (Map.Entry<String, Map<StringPair, ArtifactFilter>> all:
+        for (Map.Entry<String, Map<StringTriple, ArtifactFilter>> all:
             artifacts.entrySet()
         ) {
             String masterArtifact = all.getKey();
@@ -113,11 +121,12 @@
                 masterArtifact = null;
             }
 
-            for (Map.Entry<StringPair, ArtifactFilter> entry:
+            for (Map.Entry<StringTriple, ArtifactFilter> entry:
                 all.getValue().entrySet()
             ) {
-                StringPair pair = entry.getKey();
-                String factory = pair.first;
+                StringTriple triple = entry.getKey();
+                String factory = triple.first;
+                String targetOut = triple.third;
                 ArtifactFilter artifactFilter = entry.getValue();
 
                 String                ids;
@@ -133,8 +142,8 @@
                 }
 
                 Recommendation recommendation = new Recommendation(
-                    factory, ids, masterArtifact, filter);
-                recommendation.setDisplayName(pair.second);
+                    factory, ids, masterArtifact, filter, targetOut);
+                recommendation.setDisplayName(triple.second);
 
                 recommendations.add(recommendation);
             }

http://dive4elements.wald.intevation.org