Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/org/dive4elements/river/artifacts/access/BedQualityAccess.java @ 5831:bd047b71ab37
Repaired internal references
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 12:06:39 +0200 |
parents | flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/BedQualityAccess.java@37112235a946 |
children |
comparison
equal
deleted
inserted
replaced
5830:160f53ee0870 | 5831:bd047b71ab37 |
---|---|
1 package org.dive4elements.river.artifacts.access; | |
2 | |
3 import java.util.Date; | |
4 import java.util.LinkedList; | |
5 import java.util.List; | |
6 | |
7 import org.apache.log4j.Logger; | |
8 | |
9 import org.dive4elements.artifacts.CallContext; | |
10 | |
11 import org.dive4elements.river.artifacts.FLYSArtifact; | |
12 import org.dive4elements.river.artifacts.model.DateRange; | |
13 | |
14 | |
15 /** Access data of artifact used in BedQuality calculations. */ | |
16 public class BedQualityAccess | |
17 extends RangeAccess { | |
18 | |
19 private static final Logger logger = Logger | |
20 .getLogger(BedQualityAccess.class); | |
21 | |
22 private List<String> bedDiameter; | |
23 private List<String> bedloadDiameter; | |
24 private List<DateRange> ranges; | |
25 | |
26 | |
27 public BedQualityAccess(FLYSArtifact artifact, CallContext context) { | |
28 super(artifact, context); | |
29 } | |
30 | |
31 public List<DateRange> getDateRanges() { | |
32 if (ranges == null) { | |
33 ranges = extractRanges(getString("periods")); | |
34 } | |
35 return ranges; | |
36 } | |
37 | |
38 public List<String> getBedDiameter() { | |
39 String value = getString("bed_diameter"); | |
40 if (bedDiameter == null && value != null) { | |
41 bedDiameter = extractDiameter(value); | |
42 } | |
43 return bedDiameter; | |
44 } | |
45 | |
46 public List<String> getBedloadDiameter() { | |
47 String value = getString("load_diameter"); | |
48 if (bedloadDiameter == null && value != null) { | |
49 bedloadDiameter = extractDiameter(value); | |
50 } | |
51 return bedloadDiameter; | |
52 } | |
53 | |
54 private List<DateRange> extractRanges(String dateString) { | |
55 List<DateRange> list = new LinkedList<DateRange>(); | |
56 String[] dates = dateString.split(";"); | |
57 for (String s : dates) { | |
58 String[] pair = s.split(","); | |
59 try { | |
60 long l1 = Long.parseLong(pair[0]); | |
61 long l2 = Long.parseLong(pair[1]); | |
62 Date first = new Date(l1); | |
63 Date second = new Date(l2); | |
64 DateRange dr = new DateRange(first, second); | |
65 list.add(dr); | |
66 } | |
67 catch (NumberFormatException nfe) { | |
68 continue; | |
69 } | |
70 } | |
71 return list; | |
72 } | |
73 | |
74 private List<String> extractDiameter(String value) { | |
75 List<String> result = new LinkedList<String>(); | |
76 String[] diameter = value.split(";"); | |
77 for (String v : diameter) { | |
78 logger.debug("diameter: " + v); | |
79 String[] parts = v.split("\\."); | |
80 result.add(parts[parts.length - 1]); | |
81 logger.debug(parts[parts.length-1]); | |
82 } | |
83 return result; | |
84 } | |
85 } | |
86 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |