Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/shared/model/ToLoad.java @ 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 | 254e4e327274 |
children | 5e38e2924c07 |
comparison
equal
deleted
inserted
replaced
7174:87a7cdb6ee1e | 7175:b1f446f675b1 |
---|---|
19 | 19 |
20 public class ToLoad implements Serializable | 20 public class ToLoad implements Serializable |
21 { | 21 { |
22 | 22 |
23 /** Two strings. */ | 23 /** Two strings. */ |
24 public class StringPair { | 24 public static class StringTriple { |
25 public String first; | 25 public String first; |
26 public String second; | 26 public String second; |
27 public StringPair(String first, String second) { | 27 public String third; |
28 public StringTriple(String first, String second, String third) { | |
28 this.first = first; | 29 this.first = first; |
29 this.second = second; | 30 this.second = second; |
31 this.third = third; | |
30 } | 32 } |
33 @Override | |
31 public int hashCode() { | 34 public int hashCode() { |
32 return first.hashCode() + second.hashCode(); | 35 return first.hashCode() + second.hashCode() + third.hashCode(); |
33 } | 36 } |
34 public boolean equals(StringPair other) { | 37 @Override |
35 return (this.second.equals(other.second)) && (this.first.equals(other.first)); | 38 public boolean equals(Object o) { |
39 if (!(o instanceof StringTriple)) { | |
40 return false; | |
41 } | |
42 StringTriple other = (StringTriple) o; | |
43 return second.equals(other.second) && first.equals(other.first) && third.equals(other.third); | |
36 } | 44 } |
37 } | 45 } |
38 public static final String SYNTHETIC_KEY = "key-"; | 46 public static final String SYNTHETIC_KEY = "key-"; |
39 | 47 |
40 protected Map<String, Map<StringPair, ArtifactFilter>> artifacts; | 48 protected Map<String, Map<StringTriple, ArtifactFilter>> artifacts; |
41 | 49 |
42 public ToLoad() { | 50 public ToLoad() { |
43 artifacts = new HashMap<String, Map<StringPair, ArtifactFilter>>(); | 51 artifacts = new HashMap<String, Map<StringTriple, ArtifactFilter>>(); |
44 } | 52 } |
45 | 53 |
46 public static final String uniqueKey(Map<?, ?> map) { | 54 public static final String uniqueKey(Map<?, ?> map) { |
47 int idx = map.size(); | 55 int idx = map.size(); |
48 | 56 |
79 | 87 |
80 if (artifactName == null) { | 88 if (artifactName == null) { |
81 artifactName = uniqueKey(artifacts); | 89 artifactName = uniqueKey(artifacts); |
82 } | 90 } |
83 | 91 |
84 Map<StringPair, ArtifactFilter> artifact = artifacts.get(artifactName); | 92 Map<StringTriple, ArtifactFilter> artifact = artifacts.get(artifactName); |
85 | 93 |
86 if (artifact == null) { | 94 if (artifact == null) { |
87 artifact = new HashMap<StringPair, ArtifactFilter>(); | 95 artifact = new HashMap<StringTriple, ArtifactFilter>(); |
88 artifacts.put(artifactName, artifact); | 96 artifacts.put(artifactName, artifact); |
89 } | 97 } |
90 | 98 |
91 ArtifactFilter filter = artifact.get(factory); | 99 ArtifactFilter filter = artifact.get(factory); |
92 if (filter == null) { | 100 if (filter == null) { |
93 filter = new ArtifactFilter(factory); | 101 filter = new ArtifactFilter(factory); |
94 artifact.put(new StringPair(factory, displayName), filter); | 102 artifact.put(new StringTriple(factory, displayName, targetOut), filter); |
95 } | 103 } |
96 | 104 |
97 filter.add(out, name, ids); | 105 filter.add(out, name, ids); |
98 } | 106 } |
99 | 107 |
102 } | 110 } |
103 | 111 |
104 public List<Recommendation> toRecommendations() { | 112 public List<Recommendation> toRecommendations() { |
105 List<Recommendation> recommendations = new ArrayList<Recommendation>(); | 113 List<Recommendation> recommendations = new ArrayList<Recommendation>(); |
106 | 114 |
107 for (Map.Entry<String, Map<StringPair, ArtifactFilter>> all: | 115 for (Map.Entry<String, Map<StringTriple, ArtifactFilter>> all: |
108 artifacts.entrySet() | 116 artifacts.entrySet() |
109 ) { | 117 ) { |
110 String masterArtifact = all.getKey(); | 118 String masterArtifact = all.getKey(); |
111 | 119 |
112 if (masterArtifact.startsWith(SYNTHETIC_KEY)) { // system data | 120 if (masterArtifact.startsWith(SYNTHETIC_KEY)) { // system data |
113 masterArtifact = null; | 121 masterArtifact = null; |
114 } | 122 } |
115 | 123 |
116 for (Map.Entry<StringPair, ArtifactFilter> entry: | 124 for (Map.Entry<StringTriple, ArtifactFilter> entry: |
117 all.getValue().entrySet() | 125 all.getValue().entrySet() |
118 ) { | 126 ) { |
119 StringPair pair = entry.getKey(); | 127 StringTriple triple = entry.getKey(); |
120 String factory = pair.first; | 128 String factory = triple.first; |
129 String targetOut = triple.third; | |
121 ArtifactFilter artifactFilter = entry.getValue(); | 130 ArtifactFilter artifactFilter = entry.getValue(); |
122 | 131 |
123 String ids; | 132 String ids; |
124 Recommendation.Filter filter; | 133 Recommendation.Filter filter; |
125 | 134 |
131 ids = null; | 140 ids = null; |
132 filter = artifactFilter.toFilter(); | 141 filter = artifactFilter.toFilter(); |
133 } | 142 } |
134 | 143 |
135 Recommendation recommendation = new Recommendation( | 144 Recommendation recommendation = new Recommendation( |
136 factory, ids, masterArtifact, filter); | 145 factory, ids, masterArtifact, filter, targetOut); |
137 recommendation.setDisplayName(pair.second); | 146 recommendation.setDisplayName(triple.second); |
138 | 147 |
139 recommendations.add(recommendation); | 148 recommendations.add(recommendation); |
140 } | 149 } |
141 } | 150 } |
142 | 151 |