[PATCH 1 of 4] Save target_out in the recommendation to ensure it is sent to the server

Wald Commits scm-commit at wald.intevation.org
Thu Sep 26 19:15:44 CEST 2013


# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1380214956 -7200
# Node ID b1f446f675b1c3b450fb1d1f234db5fa9cb94f65
# Parent  87a7cdb6ee1eac8440fe9ee9b4cdaf01df3ddeca
Save target_out in the recommendation to ensure it is sent to the server

diff -r 87a7cdb6ee1e -r b1f446f675b1 gwt-client/src/main/java/org/dive4elements/river/client/shared/model/ToLoad.java
--- 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);
             }


More information about the Dive4elements-commits mailing list