Mercurial > dive4elements > river
changeset 1307:489e6a82fe84
Partial fix for flys/issue304 (Erweiterte Funktionen W-Differenzen).
flys-client/trunk@2941 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 12 Oct 2011 06:59:42 +0000 |
parents | 2e57776f77b5 |
children | d194bee456d3 |
files | flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageTwinPanel.java flys-client/src/main/java/de/intevation/flys/client/server/LoadArtifactServiceImpl.java |
diffstat | 3 files changed, 60 insertions(+), 36 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/ChangeLog Tue Oct 11 13:25:18 2011 +0000 +++ b/flys-client/ChangeLog Wed Oct 12 06:59:42 2011 +0000 @@ -1,3 +1,18 @@ +2011-10-12 Felix Wolfsteller <felix.wolfsteller@intevation.de> + + Partial fix for flys/issue304 [1] (Erweiterte Funktionen W-Differenzen), + enable multiple clones of same recommendation, but be 'sparse'. + + * src/main/java/de/intevation/flys/client/server/LoadArtifactServiceImpl.java + (loadMany): While iterating over recommendations and creating + clones, keep track of results, do not clone a second time if same + recommendation is present multiple times in list, use "old" clone + instead. Throw excpetion in fail-case. + + * src/main/java/de/intevation/flys/client/client/ui/DatacageTwinPanel.java: + Use list instead of set, 'sparseness' is now achieved by + LoadArtifactService. Docs, removed junk. + 2011-10-11 Ingo Weinzierl <ingo@intevation.de> flys/issue300 (ÜSK: Reihenfolge der Ebenen findet keine Berücksichtigung)
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageTwinPanel.java Tue Oct 11 13:25:18 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageTwinPanel.java Wed Oct 12 06:59:42 2011 +0000 @@ -1,7 +1,6 @@ package de.intevation.flys.client.client.ui; import java.util.ArrayList; -import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -188,6 +187,7 @@ // TODO i18n of error message. (MSG.no_waterlevel_pair_selected()) errors.add("No pair of waterlevel items selected"); } + // Check whether minuend and subtrahend are equal. return errors; } @@ -230,9 +230,12 @@ Config config = Config.getInstance(); ListGridRecord[] records = differencesList.getRecords(); - // Use LinkedHashSet to keep the order. - Set<Recommendation> ar = new LinkedHashSet<Recommendation>(); - Set<Recommendation> all = new LinkedHashSet<Recommendation>(); + // TODO Problem when same facet participates in two diffs. + // + // Resolve whether "new" ones were already cloned. + + List<Recommendation> ar = new ArrayList<Recommendation>(); + List<Recommendation> all = new ArrayList<Recommendation>(); for (ListGridRecord record : records) { RecommendationPairRecord r = (RecommendationPairRecord) record; @@ -301,6 +304,9 @@ } + /** + * Creates part of the String that encodes minuend or subtrahend. + */ protected String createDataString(String artifact, Filter filter) { Facet f = null; @@ -318,19 +324,5 @@ return "[" + artifact + ";" + f.getName() + ";" + f.getIndex() + "]"; } - - /*@Override - protected Data[] getData() { - // TODO ToLoadRecord ! - String value = "TODO:FIND VALUE"; - if (toLoad1 != null) { - List<Recommendation> recommendations = toLoad1.toRecommendations(); - value = recommendations.get(0).getIDs(); - } - DataItem item1 = new DefaultDataItem(dataName, dataName, value); - DataItem item2 = new DefaultDataItem(dataName, dataName, value); - return new Data[] { new DefaultData( - dataName, null, null, new DataItem[] { item1, item2}) }; - }*/ } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/server/LoadArtifactServiceImpl.java Tue Oct 11 13:25:18 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/LoadArtifactServiceImpl.java Wed Oct 12 06:59:42 2011 +0000 @@ -1,6 +1,7 @@ package de.intevation.flys.client.server; import java.util.ArrayList; +import java.util.HashMap; import de.intevation.flys.client.shared.exceptions.ServerException; import de.intevation.flys.client.shared.model.Artifact; @@ -53,11 +54,13 @@ /** - * Clone one or more artifacts and add it to a collection. + * Clone one or more artifacts and add it to a collection, avoid duplicates. * * @param parent Collection where clones will be added to. * @param recommendations definitions of source of clone. * @param factory name of factory to use when cloning artifacts. + * @return cloned artifacts (same artifact might be contained multiple + * times). */ public Artifact[] loadMany( Collection parent, @@ -67,32 +70,46 @@ String locale ) throws ServerException { - System.out.println("LoadArtifactServiceImpl.loadMany: " - + recoms[0].getMasterArtifact()); + System.out.println("LoadArtifactServiceImpl.loadMany"); ArrayList<Artifact> artifacts = new ArrayList<Artifact>(); + HashMap<Recommendation, Artifact> cloneMap = + new HashMap<Recommendation, Artifact>(); // TODO Respect the index of what to clone. - // 1) Clone the Artifacts specified in >>recom<< + // 1) Clone the Artifacts specified in >>recoms<< for (Recommendation recom : recoms) { - Artifact clone = ArtifactHelper.createArtifact( - url, locale, factory, recom); - - if (clone != null) { - System.out.println("Successfully create Artifact Clone. Add now!"); - Collection c = CollectionHelper.addArtifact( - parent, clone, url, locale); - - if (c != null) { - System.out.println("Successfully added Clone to Collection."); - - artifacts.add(clone); + // Do not do two clones of two identical recommendations. + Artifact prevClone = cloneMap.get(recom); + if (prevClone != null) { + // Already cloned a recommendation like this. + System.out.println("LoadArtifactServiceImpl: Avoid reclones, " + + "clone already exists."); + artifacts.add(prevClone); + } + else { + // Not already cloned. + Artifact clone = ArtifactHelper.createArtifact( + url, locale, factory, recom); + + if (clone != null) { + System.out.println("LoadArtifactServiceImple: Successfully " + + "loaded Artifact Clone."); + Collection c = CollectionHelper.addArtifact( + parent, clone, url, locale); + + if (c != null) { + artifacts.add(clone); + // Remember we cloned a recommendation like this. + cloneMap.put(recom, clone); + } + else { + throw new ServerException(ERROR_LOAD_ARTIFACT); + } } } } return artifacts.toArray(new Artifact[artifacts.size()]); - - //throw new ServerException(ERROR_LOAD_ARTIFACT); } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :