comparison artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/BedQualityPeriodsSelect.java @ 8856:5e38e2924c07 3.2.x

Fix code style.
author Tom Gottfried <tom@intevation.de>
date Thu, 18 Jan 2018 20:12:01 +0100
parents 8dbb969091c5
children 0a5239a1e46e
comparison
equal deleted inserted replaced
8855:d7c005e12af0 8856:5e38e2924c07
38 38
39 39
40 public class BedQualityPeriodsSelect extends DefaultState { 40 public class BedQualityPeriodsSelect extends DefaultState {
41 41
42 /** The log used in this class. */ 42 /** The log used in this class. */
43 private static Logger log = Logger.getLogger(BedQualityPeriodsSelect.class); 43 private static Logger log = Logger.getLogger(
44 BedQualityPeriodsSelect.class);
44 45
45 private static final String I18N_NO_DATA = 46 private static final String I18N_NO_DATA =
46 "state.minfo.bed.error.no_data"; 47 "state.minfo.bed.error.no_data";
47 48
48 private static final String I18N_NO_DATA_FOR_PERIOD = 49 private static final String I18N_NO_DATA_FOR_PERIOD =
52 * The default constructor that initializes an empty State object. 53 * The default constructor that initializes an empty State object.
53 */ 54 */
54 public BedQualityPeriodsSelect() { 55 public BedQualityPeriodsSelect() {
55 } 56 }
56 57
57 /** Get either the start and end date of the data at the current position. */ 58 /** Get the start and end date of the data at the current position. */
58 protected Long[] getDataMinMaxDate(Artifact artifact) { 59 protected Long[] getDataMinMaxDate(Artifact artifact) {
59 D4EArtifact arti = (D4EArtifact) artifact; 60 D4EArtifact arti = (D4EArtifact) artifact;
60 RangeAccess access = new RangeAccess(arti); 61 RangeAccess access = new RangeAccess(arti);
61 double a = access.getFrom(true); 62 double a = access.getFrom(true);
62 double b = access.getTo(true); 63 double b = access.getTo(true);
63 64
64 BedOverview overview = BedOverviewFactory.getOverview(access.getRiverName()); 65 BedOverview overview = BedOverviewFactory.getOverview(
65 BedloadOverview overview2 = BedloadOverviewFactory.getOverview(access.getRiverName()); 66 access.getRiverName());
67 BedloadOverview overview2 = BedloadOverviewFactory.getOverview(
68 access.getRiverName());
66 69
67 /* Filter is not implemented and only checks if a complete 70 /* Filter is not implemented and only checks if a complete
68 * KMIndex list is acceptable or not. So KMFiltering wont work */ 71 * KMIndex list is acceptable or not. So KMFiltering wont work */
69 KMIndex<List<Date>> entries = overview.filter(BedOverview.ACCEPT); 72 KMIndex<List<Date>> entries = overview.filter(BedOverview.ACCEPT);
70 KMIndex<List<Date>> loads = overview2.filter(BedloadOverview.ACCEPT); 73 KMIndex<List<Date>> loads = overview2.filter(BedloadOverview.ACCEPT);
102 if (values == null) { 105 if (values == null) {
103 return null; 106 return null;
104 } 107 }
105 Element def = createItem( 108 Element def = createItem(
106 cr, 109 cr,
107 new String[] {"default", values[0].toString() + "," + values[1].toString()}); 110 new String[] {"default",
111 values[0].toString() + "," + values[1].toString()}
112 );
108 113
109 return new Element[] { def }; 114 return new Element[] { def };
110 } 115 }
111 116
112 @Override 117 @Override
115 D4EArtifact arti = (D4EArtifact) artifact; 120 D4EArtifact arti = (D4EArtifact) artifact;
116 BedQualityAccess access = new BedQualityAccess(arti, context); 121 BedQualityAccess access = new BedQualityAccess(arti, context);
117 122
118 Long[] minMax = getDataMinMaxDate(artifact); 123 Long[] minMax = getDataMinMaxDate(artifact);
119 if (minMax == null) { 124 if (minMax == null) {
120 throw new IllegalArgumentException(Resources.getMsg(context.getMeta(), 125 throw new IllegalArgumentException(Resources.getMsg(
121 I18N_NO_DATA, 126 context.getMeta(),
122 I18N_NO_DATA)); 127 I18N_NO_DATA,
128 I18N_NO_DATA));
123 } 129 }
124 130
125 long min = minMax[0]; 131 long min = minMax[0];
126 long max = minMax[1]; 132 long max = minMax[1];
127 for (DateRange range: access.getDateRanges()) { 133 for (DateRange range: access.getDateRanges()) {
128 long a = range.getFrom().getTime(); 134 long a = range.getFrom().getTime();
129 long b = range.getTo().getTime(); 135 long b = range.getTo().getTime();
130 log.debug("min max a b " + min + " " + max + " " + a + " " + b); 136 log.debug("min max a b " + min + " " + max + " " + a + " " + b);
131 if (b < min || a > max || a > b) { 137 if (b < min || a > max || a > b) {
132 DateFormat df = Formatter.getDateFormatter(context.getMeta(), "dd.MM.yyyy"); 138 DateFormat df = Formatter.getDateFormatter(
133 throw new IllegalArgumentException(Resources.getMsg(context.getMeta(), 139 context.getMeta(), "dd.MM.yyyy");
134 I18N_NO_DATA_FOR_PERIOD, 140 throw new IllegalArgumentException(Resources.getMsg(
135 I18N_NO_DATA_FOR_PERIOD, 141 context.getMeta(),
136 new Object[] {df.format(range.getFrom()), 142 I18N_NO_DATA_FOR_PERIOD,
137 df.format(range.getTo())})); 143 I18N_NO_DATA_FOR_PERIOD,
144 new Object[] {df.format(range.getFrom()),
145 df.format(range.getTo())}));
138 } 146 }
139 } 147 }
140 } 148 }
141 149
142 @Override 150 @Override

http://dive4elements.wald.intevation.org