Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/shared/model/ToLoad.java @ 1352:01b18db3b288
In WDiff datacage input make names survive backjumps.
flys-client/trunk@3027 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 19 Oct 2011 11:08:03 +0000 |
parents | e47ef0ca8f33 |
children |
comparison
equal
deleted
inserted
replaced
1351:19f621663b7a | 1352:01b18db3b288 |
---|---|
7 | 7 |
8 import java.io.Serializable; | 8 import java.io.Serializable; |
9 | 9 |
10 public class ToLoad implements Serializable | 10 public class ToLoad implements Serializable |
11 { | 11 { |
12 | |
13 public class StringPair { | |
14 public String first; | |
15 public String second; | |
16 public StringPair(String first, String second) { | |
17 this.first = first; | |
18 this.second = second; | |
19 } | |
20 public int hashCode() { | |
21 return first.hashCode() + second.hashCode(); | |
22 } | |
23 public boolean equals(StringPair other) { | |
24 return (this.second.equals(other.second)) && (this.first.equals(other.first)); | |
25 } | |
26 } | |
12 public static final String SYNTHETIC_KEY = "key-"; | 27 public static final String SYNTHETIC_KEY = "key-"; |
13 | 28 |
14 protected Map<String, Map<String, ArtifactFilter>> artifacts; | 29 protected Map<String, Map<StringPair, ArtifactFilter>> artifacts; |
15 | 30 |
16 public ToLoad() { | 31 public ToLoad() { |
17 artifacts = new HashMap<String, Map<String, ArtifactFilter>>(); | 32 artifacts = new HashMap<String, Map<StringPair, ArtifactFilter>>(); |
18 } | 33 } |
19 | 34 |
20 public static final String uniqueKey(Map<?, ?> map) { | 35 public static final String uniqueKey(Map<?, ?> map) { |
21 int idx = map.size(); | 36 int idx = map.size(); |
22 | 37 |
30 public void add( | 45 public void add( |
31 String artifactName, | 46 String artifactName, |
32 String factory, | 47 String factory, |
33 String out, | 48 String out, |
34 String name, | 49 String name, |
35 String ids | 50 String ids, |
51 String displayName | |
36 ) { | 52 ) { |
37 if (artifactName == null) { | 53 if (artifactName == null) { |
38 artifactName = uniqueKey(artifacts); | 54 artifactName = uniqueKey(artifacts); |
39 } | 55 } |
40 | 56 |
41 Map<String, ArtifactFilter> artifact = artifacts.get(artifactName); | 57 Map<StringPair, ArtifactFilter> artifact = artifacts.get(artifactName); |
42 | 58 |
43 if (artifact == null) { | 59 if (artifact == null) { |
44 artifact = new HashMap<String, ArtifactFilter>(); | 60 artifact = new HashMap<StringPair, ArtifactFilter>(); |
45 artifacts.put(artifactName, artifact); | 61 artifacts.put(artifactName, artifact); |
46 } | 62 } |
47 | 63 |
48 ArtifactFilter filter = artifact.get(factory); | 64 ArtifactFilter filter = artifact.get(factory); |
49 if (filter == null) { | 65 if (filter == null) { |
50 filter = new ArtifactFilter(factory); | 66 filter = new ArtifactFilter(factory); |
51 artifact.put(factory, filter); | 67 artifact.put(new StringPair(factory, displayName), filter); |
52 } | 68 } |
53 | 69 |
54 filter.add(out, name, ids); | 70 filter.add(out, name, ids); |
55 } | 71 } |
56 | 72 |
59 } | 75 } |
60 | 76 |
61 public List<Recommendation> toRecommendations() { | 77 public List<Recommendation> toRecommendations() { |
62 List<Recommendation> recommendations = new ArrayList<Recommendation>(); | 78 List<Recommendation> recommendations = new ArrayList<Recommendation>(); |
63 | 79 |
64 for (Map.Entry<String, Map<String, ArtifactFilter>> all: | 80 for (Map.Entry<String, Map<StringPair, ArtifactFilter>> all: |
65 artifacts.entrySet() | 81 artifacts.entrySet() |
66 ) { | 82 ) { |
67 String masterArtifact = all.getKey(); | 83 String masterArtifact = all.getKey(); |
68 | 84 |
69 if (masterArtifact.startsWith(SYNTHETIC_KEY)) { // system data | 85 if (masterArtifact.startsWith(SYNTHETIC_KEY)) { // system data |
70 masterArtifact = null; | 86 masterArtifact = null; |
71 } | 87 } |
72 | 88 |
73 for (Map.Entry<String, ArtifactFilter> entry: | 89 for (Map.Entry<StringPair, ArtifactFilter> entry: |
74 all.getValue().entrySet() | 90 all.getValue().entrySet() |
75 ) { | 91 ) { |
76 String factory = entry.getKey(); | 92 StringPair pair = entry.getKey(); |
93 String factory = pair.first; | |
77 ArtifactFilter artifactFilter = entry.getValue(); | 94 ArtifactFilter artifactFilter = entry.getValue(); |
78 | 95 |
79 String ids; | 96 String ids; |
80 Recommendation.Filter filter; | 97 Recommendation.Filter filter; |
81 | 98 |
88 filter = artifactFilter.toFilter(); | 105 filter = artifactFilter.toFilter(); |
89 } | 106 } |
90 | 107 |
91 Recommendation recommendation = new Recommendation( | 108 Recommendation recommendation = new Recommendation( |
92 factory, ids, masterArtifact, filter); | 109 factory, ids, masterArtifact, filter); |
110 recommendation.setDisplayName(pair.second); | |
93 | 111 |
94 recommendations.add(recommendation); | 112 recommendations.add(recommendation); |
95 } | 113 } |
96 } | 114 } |
97 | 115 |