comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageTwinPanel.java @ 1304:18b0414bde44

Allow reparameterization of W-Diffs. flys-client/trunk@2938 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 11 Oct 2011 11:59:57 +0000
parents b0ed67cb5197
children 014fc183c640
comparison
equal deleted inserted replaced
1303:84c50f1d939b 1304:18b0414bde44
128 for (int i = 0; i < recs.length; i+=2) { 128 for (int i = 0; i < recs.length; i+=2) {
129 Recommendation minuend = createRecommendationFromString(recs[i+0]); 129 Recommendation minuend = createRecommendationFromString(recs[i+0]);
130 Recommendation subtrahend = createRecommendationFromString(recs[i+1]); 130 Recommendation subtrahend = createRecommendationFromString(recs[i+1]);
131 RecommendationPairRecord pr = new RecommendationPairRecord( 131 RecommendationPairRecord pr = new RecommendationPairRecord(
132 "A", minuend, "B", subtrahend); 132 "A", minuend, "B", subtrahend);
133 // This Recommendation Pair comes from the data string and was thus
134 // already cloned.
135 pr.setIsAlreadyLoaded(true);
133 this.differencesList.addData(pr); 136 this.differencesList.addData(pr);
134 } 137 }
135 } 138 }
136 139
137 140
225 * */ 228 * */
226 GWT.log("DatacageTwinPanel.onClick"); 229 GWT.log("DatacageTwinPanel.onClick");
227 Config config = Config.getInstance(); 230 Config config = Config.getInstance();
228 ListGridRecord[] records = differencesList.getRecords(); 231 ListGridRecord[] records = differencesList.getRecords();
229 232
230 Set<Recommendation> ar = new HashSet<Recommendation>(); 233 Set<Recommendation> ar = new HashSet<Recommendation>();
234 Set<Recommendation> all = new HashSet<Recommendation>();
231 for (ListGridRecord record : records) { 235 for (ListGridRecord record : records) {
232 RecommendationPairRecord r = 236 RecommendationPairRecord r =
233 (RecommendationPairRecord) record; 237 (RecommendationPairRecord) record;
234 ar.add(r.getFirst()); 238 // Do not add "old" recommendations.
235 ar.add(r.getSecond()); 239 if (!r.isAlreadyLoaded()) {
236 } 240 GWT.log("One not yet loaded.");
237 241 ar.add(r.getFirst());
238 final Recommendation[] rs = ar.toArray(new Recommendation[ar.size()]); 242 ar.add(r.getSecond());
243 }
244 else {
245 GWT.log("One already loaded.");
246 all.add(r.getFirst());
247 all.add(r.getSecond());
248 }
249 }
250
251 final Recommendation[] toClone = ar.toArray(new Recommendation[ar.size()]);
252 final Recommendation[] toUse = all.toArray(new Recommendation[all.size()]);
239 loadArtifactService.loadMany( 253 loadArtifactService.loadMany(
240 this.collection, 254 this.collection,
241 rs, 255 toClone,
242 "waterlevel", 256 "waterlevel",
243 config.getServerUrl(), 257 config.getServerUrl(),
244 config.getLocale(), 258 config.getLocale(),
245 new AsyncCallback<Artifact[]>() { 259 new AsyncCallback<Artifact[]>() {
246 public void onFailure(Throwable caught) { 260 public void onFailure(Throwable caught) {
247 GWT.log("Failure of cloning with waterlevelfactory!"); 261 GWT.log("Failure of cloning with waterlevelfactory!");
248 } 262 }
249 public void onSuccess(Artifact[] artifacts) { 263 public void onSuccess(Artifact[] artifacts) {
250 GWT.log("Success in cloning with watelevelfactory!"); 264 GWT.log("Success in cloning ("+toClone.length+") with watelevelfactory!");
251 265
252 fireStepForwardEvent(new StepForwardEvent( 266 fireStepForwardEvent(new StepForwardEvent(
253 getData(rs, artifacts))); 267 getData(toClone, artifacts, toUse)));
254 } 268 }
255 } ); 269 } );
256 } 270 }
257 271
258 272
259 protected Data[] getData(Recommendation[] rs, Artifact[] newArtifacts) { 273 protected Data[] getData(
274 Recommendation[] newRecommendations,
275 Artifact[] newArtifacts,
276 Recommendation[] oldRecommendations)
277 {
260 // Construct string with info about selections. 278 // Construct string with info about selections.
261 String dataItemString = ""; 279 String dataItemString = "";
262 for (int i = 0; i < rs.length; i++) { 280 for (int i = 0; i < newRecommendations.length; i++) {
263 Recommendation r = rs[i]; 281 Recommendation r = newRecommendations[i];
264 Artifact newArtifact = newArtifacts[i]; 282 Artifact newArtifact = newArtifacts[i];
265 String uuid = newArtifact.getUuid(); 283 String uuid = newArtifact.getUuid();
266 r.setMasterArtifact(uuid); 284 r.setMasterArtifact(uuid);
267 if (i>0) dataItemString += "#"; 285 if (i>0) dataItemString += "#";
268 286
269 dataItemString += createDataString(uuid, r.getFilter()); 287 dataItemString += createDataString(uuid, r.getFilter());
270 } 288 }
289
290 for (int i = 0; i < oldRecommendations.length; i++) {
291 Recommendation r = oldRecommendations[i];
292 String uuid = r.getIDs();
293 if (dataItemString.length() > 0) dataItemString += "#";
294
295 dataItemString += createDataString(uuid, r.getFilter());
296 }
297
271 DataItem item = new DefaultDataItem(dataName, dataName, dataItemString); 298 DataItem item = new DefaultDataItem(dataName, dataName, dataItemString);
272 return new Data[] { new DefaultData( 299 return new Data[] { new DefaultData(
273 dataName, null, null, new DataItem[] {item}) }; 300 dataName, null, null, new DataItem[] {item}) };
274 } 301 }
275 302

http://dive4elements.wald.intevation.org