Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/LocationDistanceSelect.java @ 624:929137ee8154
ISSUE-62 (part I/II) States are no longer filled with data - if a state needs user input, it needs to query the owner artifact.
flys-artifacts/trunk@1982 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 23 May 2011 15:11:55 +0000 |
parents | c21fb8de54f8 |
children | 833290f16f09 |
comparison
equal
deleted
inserted
replaced
623:aa64fe4df8ab | 624:929137ee8154 |
---|---|
1 package de.intevation.flys.artifacts.states; | 1 package de.intevation.flys.artifacts.states; |
2 | |
3 import java.util.Map; | |
4 | 2 |
5 import org.apache.log4j.Logger; | 3 import org.apache.log4j.Logger; |
6 | 4 |
7 import org.w3c.dom.Element; | 5 import org.w3c.dom.Element; |
8 | 6 |
138 } | 136 } |
139 | 137 |
140 | 138 |
141 protected double[] getMinMaxDistance(Artifact artifact) { | 139 protected double[] getMinMaxDistance(Artifact artifact) { |
142 FLYSArtifact flysArtifact = (FLYSArtifact) artifact; | 140 FLYSArtifact flysArtifact = (FLYSArtifact) artifact; |
143 StateData data = flysArtifact.getData("river"); | 141 StateData data = getData(flysArtifact, "river"); |
144 | 142 |
145 String name = (String) data.getValue(); | 143 String name = data != null ? (String) data.getValue() : ""; |
146 | 144 |
147 logger.debug("Search for the min/max distances of '" + name + "'"); | 145 logger.debug("Search for the min/max distances of '" + name + "'"); |
148 | 146 |
149 River river = RiverFactory.getRiver(name); | 147 River river = RiverFactory.getRiver(name); |
150 | 148 |
156 public boolean validate(Artifact artifact, CallContext context) | 154 public boolean validate(Artifact artifact, CallContext context) |
157 throws IllegalArgumentException | 155 throws IllegalArgumentException |
158 { | 156 { |
159 logger.debug("LocationDistanceSelect.validate"); | 157 logger.debug("LocationDistanceSelect.validate"); |
160 | 158 |
161 Map<String, StateData> data = getData(); | 159 FLYSArtifact flys = (FLYSArtifact) artifact; |
162 | 160 |
163 String fromStr = (String) data.get(FROM).getValue(); | 161 StateData dFrom = getData(flys, FROM); |
164 String toStr = (String) data.get(TO).getValue(); | 162 StateData dTo = getData(flys, TO); |
165 String stepStr = (String) data.get(STEP).getValue(); | 163 StateData dStep = getData(flys, STEP); |
164 | |
165 String fromStr = dFrom != null ? (String) dFrom.getValue() : null; | |
166 String toStr = dTo != null ? (String) dTo.getValue() : null; | |
167 String stepStr = dStep != null ? (String) dStep.getValue() : null; | |
166 | 168 |
167 if (fromStr == null || toStr == null || stepStr == null) { | 169 if (fromStr == null || toStr == null || stepStr == null) { |
168 throw new IllegalArgumentException("error_empty_state"); | 170 throw new IllegalArgumentException("error_empty_state"); |
169 } | 171 } |
170 | 172 |