comparison gwt-client/src/main/java/org/dive4elements/river/client/shared/model/SINFOArtifact.java @ 9263:abf14917be32

Moved stepping behaviour of NaviOutputChart into an exchangeable strategy. Allows for distinct values stepping of sinfo flood duration.
author gernotbelger
date Tue, 17 Jul 2018 19:48:18 +0200
parents 7bbfb24e6eec
children 9826b465b751
comparison
equal deleted inserted replaced
9262:fee5fa18361c 9263:abf14917be32
6 * documentation coming with Dive4Elements River for details. 6 * documentation coming with Dive4Elements River for details.
7 */ 7 */
8 8
9 package org.dive4elements.river.client.shared.model; 9 package org.dive4elements.river.client.shared.model;
10 10
11 import java.util.Collections;
12 import java.util.HashSet;
11 import java.util.List; 13 import java.util.List;
12 14 import java.util.Set;
13 15
14 /** 16 /**
15 * The SINFO implementation of an Artifact. 17 * The SINFO implementation of an Artifact.
16 * 18 *
17 * @author Gernot Belger 19 * @author Gernot Belger
18 */ 20 */
19 public class SINFOArtifact extends DefaultArtifact { 21 public class SINFOArtifact extends DefaultArtifact {
20 22
21 /** The name of this artifact: 'sinfo'.*/ 23 /** The name of this artifact: 'sinfo'. */
22 private static final String NAME = "sinfo"; 24 private static final String NAME = "sinfo";
23 25
24 /** Necessary for serialization */ 26 /** Necessary for serialization */
25 public SINFOArtifact() { 27 public SINFOArtifact() {
26 } 28 }
27 29
28 // public SINFOArtifact(String uuid, String hash) { 30 public SINFOArtifact(final String uuid, final String hash, final boolean inBackground, final List<CalculationMessage> messages) {
29 // super(uuid, hash);
30 // }
31
32 public SINFOArtifact(
33 String uuid,
34 String hash,
35 boolean inBackground,
36 List<CalculationMessage> messages
37 ) {
38 super(uuid, hash, inBackground, messages); 31 super(uuid, hash, inBackground, messages);
39 } 32 }
40 33
41 34 @Override
42 public String getName() { 35 public String getName() {
43 return NAME; 36 return NAME;
44 } 37 }
38
39 public Set<Double> getValidDurationChartKms(final CollectionItem item) {
40
41 final String validKmsText = item.getData().get("validStations");
42 if (validKmsText == null || validKmsText.trim().isEmpty())
43 return Collections.emptySet();
44
45 final String[] split = validKmsText.split(",");
46
47 final Set<Double> validKms = new HashSet<Double>(split.length);
48
49 for (final String stationText : split) {
50
51 try {
52 final double station = Double.parseDouble(stationText);
53 validKms.add(station);
54 }
55 catch (final NumberFormatException e) {
56 e.printStackTrace();
57 }
58 }
59
60 return validKms;
61 }
45 } 62 }
46 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org