Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/client/ui/RecommandationUtils.java @ 9027:274ddafb719b
S-Info-Proof-Init
Testing
author | gernotbelger |
---|---|
date | Thu, 26 Apr 2018 10:46:12 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
9026:679b1442c886 | 9027:274ddafb719b |
---|---|
1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde | |
2 * Software engineering by | |
3 * Björnsen Beratende Ingenieure GmbH | |
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt | |
5 * | |
6 * This file is Free Software under the GNU AGPL (>=v3) | |
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
8 * documentation coming with Dive4Elements River for details. | |
9 */ | |
10 package org.dive4elements.river.client.client.ui; | |
11 | |
12 import java.util.List; | |
13 import java.util.Map; | |
14 import java.util.Set; | |
15 | |
16 import org.dive4elements.river.client.client.ui.AbstractPairRecommendationPanel.IRecommendationInfo; | |
17 import org.dive4elements.river.client.shared.model.Recommendation; | |
18 import org.dive4elements.river.client.shared.model.Recommendation.Facet; | |
19 import org.dive4elements.river.client.shared.model.Recommendation.Filter; | |
20 | |
21 /** | |
22 * @author Domenico Nardi Tironi | |
23 * | |
24 */ | |
25 public class RecommandationUtils { | |
26 /** | |
27 * Creates part of the String that encodes minuend or subtrahend. | |
28 * | |
29 * @param recommendation | |
30 * Recommendation to wrap in string. | |
31 * @param info | |
32 * Provides the factory to encode. | |
33 */ | |
34 public static final String createDataString(final String artifactUuid, final Recommendation recommendation, final IRecommendationInfo info) { | |
35 final String factory = info.getDataStringFactory(recommendation); | |
36 | |
37 final Filter filter = recommendation.getFilter(); | |
38 Facet f = null; | |
39 | |
40 if (filter != null) { | |
41 final Map<String, List<Facet>> outs = filter.getOuts(); | |
42 final Set<Map.Entry<String, List<Facet>>> entries = outs.entrySet(); | |
43 | |
44 for (final Map.Entry<String, List<Facet>> entry : entries) { | |
45 final List<Facet> fs = entry.getValue(); | |
46 | |
47 f = fs.get(0); | |
48 if (f != null) { | |
49 break; | |
50 } | |
51 } | |
52 | |
53 return "[" + artifactUuid + ";" + f.getName() + ";" + f.getIndex() + ";" + recommendation.getDisplayName() + "]"; | |
54 } | |
55 | |
56 return "[" + artifactUuid + ";" + factory + ";0;" + recommendation.getDisplayName() + "]"; | |
57 } | |
58 } |