Mercurial > dive4elements > river
changeset 660:627be3ca1ab6
code clean up in states
flys-artifacts/trunk@2068 c6561f87-3c4e-4783-a992-168aeb5c3f6f
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Tue Jun 07 13:15:02 2011 +0000 +++ b/flys-artifacts/ChangeLog Tue Jun 07 14:28:44 2011 +0000 @@ -1,9 +1,25 @@ +2011-06-07 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + + * src/main/java/de/intevation/flys/artifacts/states/DefaultState.java: + createItem() is not abstract any longer to avoid code repetitionin sub classes. + + * src/main/java/de/intevation/flys/artifacts/states/ComputedDischargeCurveState.java, + src/main/java/de/intevation/flys/artifacts/states/LocationDistanceSelect.java, + src/main/java/de/intevation/flys/artifacts/states/RiverSelect.java, + src/main/java/de/intevation/flys/artifacts/states/WQSelect.java, + src/main/java/de/intevation/flys/artifacts/states/DischargeLongitudinalSection.java, + src/main/java/de/intevation/flys/artifacts/states/WQAdapted.java, + src/main/java/de/intevation/flys/artifacts/states/DurationCurveState.java, + src/main/java/de/intevation/flys/artifacts/states/CalculationSelect.java: + Removed duplicated code, inserted default constructors and Override annotations. + 2011-06-07 Ingo Weinzierl <ingo@intevation.de> * src/main/java/de/intevation/flys/exports/InfoGeneratorHelper.java: Append axes range information to the info document. -2011-06-08 Sascha L. Teichmann <sascha.teichmann@intevation.de> +2011-06-07 Sascha L. Teichmann <sascha.teichmann@intevation.de> * src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java: If feed() fails do not store invalid values in database.
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/CalculationSelect.java Tue Jun 07 13:15:02 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/CalculationSelect.java Tue Jun 07 14:28:44 2011 +0000 @@ -66,7 +66,12 @@ public static final String ERROR_INVALID_CALCULATION_MODE = "error_feed_invalid_calculation_mode"; + + public CalculationSelect() { + } + + @Override protected Element[] createItems( XMLUtils.ElementCreator cr, Artifact artifact,
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ComputedDischargeCurveState.java Tue Jun 07 13:15:02 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ComputedDischargeCurveState.java Tue Jun 07 14:28:44 2011 +0000 @@ -22,15 +22,7 @@ private static Logger logger = Logger.getLogger(ComputedDischargeCurveState.class); - - protected Element[] createItems( - XMLUtils.ElementCreator cr, - Artifact artifact, - String name, - CallContext context) - { - logger.debug("ComputedDischargeCurveState.createItems"); - return null; + public ComputedDischargeCurveState() { } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DefaultState.java Tue Jun 07 13:15:02 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DefaultState.java Tue Jun 07 14:28:44 2011 +0000 @@ -213,11 +213,14 @@ * * @return a list of items. */ - protected abstract Element[] createItems( + protected Element[] createItems( XMLUtils.ElementCreator cr, Artifact artifact, String name, - CallContext context); + CallContext context + ) { + return null; + } /**
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DischargeLongitudinalSection.java Tue Jun 07 13:15:02 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DischargeLongitudinalSection.java Tue Jun 07 14:28:44 2011 +0000 @@ -12,19 +12,7 @@ public class DischargeLongitudinalSection extends DefaultState { - /** The logger that is used in this state.*/ private static Logger logger = Logger.getLogger(DischargeLongitudinalSection.class); - - - protected Element[] createItems( - XMLUtils.ElementCreator cr, - Artifact artifact, - String name, - CallContext context) - { - logger.debug("DischargeLongitudinalSection.createItems"); - return null; - } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DurationCurveState.java Tue Jun 07 13:15:02 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DurationCurveState.java Tue Jun 07 14:28:44 2011 +0000 @@ -21,15 +21,7 @@ /** The logger that is used in this state.*/ private static Logger logger = Logger.getLogger(DurationCurveState.class); - - protected Element[] createItems( - XMLUtils.ElementCreator cr, - Artifact artifact, - String name, - CallContext context) - { - logger.debug("DurationCurveState.createItems"); - return null; + public DurationCurveState() { } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/LocationDistanceSelect.java Tue Jun 07 13:15:02 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/LocationDistanceSelect.java Tue Jun 07 14:28:44 2011 +0000 @@ -81,6 +81,7 @@ } + @Override protected Element[] createItems( XMLUtils.ElementCreator cr, Artifact artifact, @@ -139,6 +140,7 @@ } + @Override protected String getUIProvider() { return "location_distance_panel"; }
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/RiverSelect.java Tue Jun 07 13:15:02 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/RiverSelect.java Tue Jun 07 14:28:44 2011 +0000 @@ -88,6 +88,7 @@ } + @Override protected Element[] createItems( XMLUtils.ElementCreator cr, Artifact artifact,
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQAdapted.java Tue Jun 07 13:15:02 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQAdapted.java Tue Jun 07 14:28:44 2011 +0000 @@ -55,6 +55,9 @@ public static final GaugeOrder GAUGE_UP = new GaugeOrder(true); public static final GaugeOrder GAUGE_DOWN = new GaugeOrder(false); + public WQAdapted() { + } + /** * This method creates one element for each gauge of the selected river that * is intersected by the given kilometer range. Each element is a tuple of @@ -70,6 +73,7 @@ * @return a list of elements that consist of tuples of the intersected * gauges of the selected river. */ + @Override protected Element[] createItems( XMLUtils.ElementCreator cr, Artifact artifact, @@ -191,6 +195,7 @@ } + @Override public boolean validate(Artifact artifact, CallContext context) throws IllegalArgumentException {
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQSelect.java Tue Jun 07 13:15:02 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQSelect.java Tue Jun 07 14:28:44 2011 +0000 @@ -90,6 +90,7 @@ } + @Override protected Element[] createItems( XMLUtils.ElementCreator cr, Artifact artifact, @@ -115,8 +116,10 @@ return new Element[] { maxW, maxQ }; } else { - Element stepW = createItem(cr, new String[] {"stepW", DEFAULT_STEP_W}); - Element stepQ = createItem(cr, new String[] {"stepQ", DEFAULT_STEP_Q}); + Element stepW = createItem( + cr, new String[] {"stepW", DEFAULT_STEP_W}); + Element stepQ = createItem( + cr, new String[] {"stepQ", DEFAULT_STEP_Q}); return new Element[] { stepW, stepQ }; } } @@ -139,6 +142,7 @@ } + @Override protected String getUIProvider() { return "wq_panel"; } @@ -305,7 +309,8 @@ return validateQ(artifact, context, from, to, step); } else { - throw new IllegalArgumentException("error_feed_invalid_wq_mode"); + throw new IllegalArgumentException( + "error_feed_invalid_wq_mode"); } } catch (NumberFormatException nfe) {