Mercurial > dive4elements > river
changeset 834:77469d7f3c93
Generate unique keys for anonymous artifacts (aka static data).
flys-client/trunk@2547 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 24 Aug 2011 09:06:35 +0000 |
parents | dcecdd9693a8 |
children | c89a42950d11 |
files | flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/shared/model/ArtifactFilter.java flys-client/src/main/java/de/intevation/flys/client/shared/model/ToLoad.java |
diffstat | 3 files changed, 24 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/ChangeLog Wed Aug 24 08:36:51 2011 +0000 +++ b/flys-client/ChangeLog Wed Aug 24 09:06:35 2011 +0000 @@ -1,3 +1,9 @@ +2011-08-24 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/client/shared/model/ArtifactFilter.java, + src/main/java/de/intevation/flys/client/shared/model/ToLoad.java: + Generate unique keys for anonymous artifacts (aka static data). + 2011-08-24 Ingo Weinzierl <ingo@intevation.de> * src/main/java/de/intevation/flys/client/client/ui/DigitizePanel.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/ArtifactFilter.java Wed Aug 24 08:36:51 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/ArtifactFilter.java Wed Aug 24 09:06:35 2011 +0000 @@ -29,6 +29,11 @@ } public void add(String out, String name, String num) { + + if (out == null) { + out = ToLoad.uniqueKey(outFilters); + } + OutFilter outFilter = outFilters.get(out); if (outFilter == null) {
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/ToLoad.java Wed Aug 24 08:36:51 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/ToLoad.java Wed Aug 24 09:06:35 2011 +0000 @@ -13,6 +13,16 @@ artifacts = new HashMap<String, Map<String, ArtifactFilter>>(); } + public static final String uniqueKey(Map<?, ?> map) { + int idx = map.size(); + + String key = "key-" + idx; + while (map.containsKey(key)) { + key = "key-" + ++idx; + } + return key; + } + public void add( String artifactName, String factory, @@ -20,8 +30,9 @@ String name, String num ) { - if (artifactName == null) artifactName = ""; - if (out == null) out = ""; + if (artifactName == null) { + artifactName = uniqueKey(artifacts); + } Map<String, ArtifactFilter> artifact = artifacts.get(artifactName);