# HG changeset patch # User Felix Wolfsteller # Date 1314608500 0 # Node ID af73f196eccc5b3030ab5fc20a5c02998dafadcb # Parent 1ea7eb72aaa6319d82fe88610de66137425ef7d0 Refactored to use new FLYSUtils, moved getRiver-functionality inside. flys-artifacts/trunk@2602 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 1ea7eb72aaa6 -r af73f196eccc flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Mon Aug 29 08:58:03 2011 +0000 +++ b/flys-artifacts/ChangeLog Mon Aug 29 09:01:40 2011 +0000 @@ -1,3 +1,16 @@ +2011-08-29 Felix Wolfsteller + + Refactored to use new Helper class FLYSUtils, moved getRiver-functionality + in there. + + * src/main/java/de/intevation/flys/utils/FLYSUtils.java (getRiver): + New function to retrieve river of an artifact, slightly modified from + WINFOArtifact. + + * src/main/java/de/intevation/flys/artifacts/AnnotationArtifact.java, + src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java: + Removed implementations of getRiver, update calls to use FLYSUtils. + 2011-08-29 Felix Wolfsteller Minor cosmetics. diff -r 1ea7eb72aaa6 -r af73f196eccc flys-artifacts/src/main/java/de/intevation/flys/artifacts/AnnotationArtifact.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/AnnotationArtifact.java Mon Aug 29 08:58:03 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/AnnotationArtifact.java Mon Aug 29 09:01:40 2011 +0000 @@ -28,18 +28,17 @@ import de.intevation.artifacts.common.utils.XMLUtils; import de.intevation.flys.artifacts.states.DefaultState; +import de.intevation.flys.artifacts.cache.CacheFactory; import de.intevation.flys.artifacts.context.FLYSContext; +import de.intevation.flys.artifacts.model.AnnotationsFactory; +import de.intevation.flys.artifacts.model.RiverFactory; import de.intevation.flys.backend.SessionHolder; -import de.intevation.flys.artifacts.cache.CacheFactory; - import de.intevation.flys.model.Annotation; -import de.intevation.flys.artifacts.model.AnnotationsFactory; - import de.intevation.flys.model.River; -import de.intevation.flys.artifacts.model.RiverFactory; +import de.intevation.flys.utils.FLYSUtils; /** * Artifact to access names of Points Of Interest along a segment of a river. @@ -232,13 +231,6 @@ } } - public River getRiver() { - StateData dRiver = getData("river"); - - return dRiver != null - ? RiverFactory.getRiver((String) dRiver.getValue()) - : null; - } /** * Get Annotations for Points (opposed to segments) in river in range. @@ -246,7 +238,7 @@ * @return list of Annotations. */ public List getAnnotations() { - String river = getRiver().getName(); + String river = FLYSUtils.getRiver(this).getName(); logger.debug("Search annotations for river: " /*+ river*/); //Cache cache = CacheFactory.getCache(CACHE_NAME); diff -r 1ea7eb72aaa6 -r af73f196eccc flys-artifacts/src/main/java/de/intevation/flys/utils/FLYSUtils.java --- a/flys-artifacts/src/main/java/de/intevation/flys/utils/FLYSUtils.java Mon Aug 29 08:58:03 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/FLYSUtils.java Mon Aug 29 09:01:40 2011 +0000 @@ -3,7 +3,8 @@ import gnu.trove.TDoubleArrayList; import de.intevation.flys.artifacts.FLYSArtifact; - +import de.intevation.flys.artifacts.model.RiverFactory; +import de.intevation.flys.model.River; public class FLYSUtils { @@ -15,7 +16,7 @@ public static KM_MODE getKmRangeMode(FLYSArtifact flys) { - String mode = flys.getDataAsString("ld_mode"); + String mode = flys.getDataAsString("ld_mode"); if (mode == null || mode.length() == 0) { return KM_MODE.NONE; @@ -99,4 +100,19 @@ return locations.toNativeArray(); } + + + /** + * Returns the selected River object based on the 'river' data that might + * have been inserted by the user. + * + * @return the selected River or null if no river has been chosen yet. + */ + public static River getRiver(FLYSArtifact flys) { + String sRiver = flys.getDataAsString("river"); + + return (sRiver != null) + ? RiverFactory.getRiver(sRiver) + : null; + } }