# HG changeset patch # User Sascha L. Teichmann # Date 1313763018 0 # Node ID eccf966fb6777a18d4736e3af66b5d621aeac985 # Parent 433559e25b50a56ee8b2411b05a2914bae060804 State engine: Removed CallContext from state validation. flys-artifacts/trunk@2512 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 433559e25b50 -r eccf966fb677 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Fri Aug 19 11:46:40 2011 +0000 +++ b/flys-artifacts/ChangeLog Fri Aug 19 14:10:18 2011 +0000 @@ -1,3 +1,33 @@ +2011-08-19 Sascha L. Teichmann + + * src/main/java/de/intevation/flys/artifacts/states/DefaultState.java: + Removed CallContext from state validation. It is not needed and hindered + the extraction of all out of an artifact if you don't have a + call context (like initial scan of datacage database). + + * src/main/java/de/intevation/flys/artifacts/datacage/Datacage.java: + Extract all outs now. + + * src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java, + src/main/java/de/intevation/flys/artifacts/datacage/Datacage.java, + src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java, + src/main/java/de/intevation/flys/artifacts/states/FloodplainChoice.java, + src/main/java/de/intevation/flys/artifacts/states/ScenarioSelect.java, + src/main/java/de/intevation/flys/artifacts/states/DGMSelect.java, + src/main/java/de/intevation/flys/artifacts/states/LocationSelect.java, + src/main/java/de/intevation/flys/artifacts/states/WQAdapted.java, + src/main/java/de/intevation/flys/artifacts/states/ProfileDistanceSelect.java, + src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java, + src/main/java/de/intevation/flys/artifacts/states/LocationDistanceSelect.java, + src/main/java/de/intevation/flys/artifacts/states/DefaultState.java, + src/main/java/de/intevation/flys/artifacts/states/WQSelect.java, + src/main/java/de/intevation/flys/artifacts/states/RiverSelect.java, + src/main/java/de/intevation/flys/artifacts/states/RangeState.java, + src/main/java/de/intevation/flys/artifacts/states/CalculationSelect.java, + src/main/java/de/intevation/flys/artifacts/AnnotationArtifact.java, + src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java: + Adjusted calls. + 2011-08-19 Felix Wolfsteller * src/main/resources/messages.properties, diff -r 433559e25b50 -r eccf966fb677 flys-artifacts/src/main/java/de/intevation/flys/artifacts/AnnotationArtifact.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/AnnotationArtifact.java Fri Aug 19 11:46:40 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/AnnotationArtifact.java Fri Aug 19 14:10:18 2011 +0000 @@ -194,7 +194,7 @@ try { DefaultState cur = (DefaultState) getCurrentState(context); - if (cur.validate(this, context)) { + if (cur.validate(this)) { List list = cur.getOutputs(); if (list != null && list.size() > 0) { logger.debug( diff -r 433559e25b50 -r eccf966fb677 flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java Fri Aug 19 11:46:40 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java Fri Aug 19 14:10:18 2011 +0000 @@ -471,7 +471,7 @@ } DefaultState current = (DefaultState) getCurrentState(context); - current.validate(this, context); + current.validate(this); } @@ -1121,7 +1121,7 @@ } - public List getOutputs(CallContext context) { + public List getOutputs(Object context) { List stateIds = getPreviousStateIds(); List generated = new ArrayList(); @@ -1140,11 +1140,11 @@ } - public List getCurrentOutputs(CallContext context) { + public List getCurrentOutputs(Object context) { DefaultState cur = (DefaultState) getCurrentState(context); try { - if (cur.validate(this, context)) { + if (cur.validate(this)) { return getOutputForState(cur); } } @@ -1153,10 +1153,6 @@ return new ArrayList(); } - public List getCurrentOutputs(Object context) { - return getOutputForState((DefaultState)getCurrentState(context)); - } - protected List getOutputForState(DefaultState state) { List list = state.getOutputs(); if (list == null || list.size() == 0) { diff -r 433559e25b50 -r eccf966fb677 flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java Fri Aug 19 11:46:40 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java Fri Aug 19 14:10:18 2011 +0000 @@ -153,7 +153,7 @@ try { DefaultState cur = (DefaultState) getCurrentState(context); - if (cur.validate(this, context)) { + if (cur.validate(this)) { List list = cur.getOutputs(); if (list != null && list.size() > 0) { logger.debug( diff -r 433559e25b50 -r eccf966fb677 flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Fri Aug 19 11:46:40 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Fri Aug 19 14:10:18 2011 +0000 @@ -199,7 +199,7 @@ try { DefaultState cur = (DefaultState) getCurrentState(context); - if (cur.validate(this, context)) { + if (cur.validate(this)) { List list = cur.getOutputs(); if (list != null && list.size() > 0) { logger.debug( diff -r 433559e25b50 -r eccf966fb677 flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/Datacage.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/Datacage.java Fri Aug 19 11:46:40 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/Datacage.java Fri Aug 19 14:10:18 2011 +0000 @@ -929,7 +929,7 @@ final FLYSArtifact artifact, GlobalContext context ) { - final List outs = artifact.getCurrentOutputs(context); + final List outs = artifact.getOutputs(context); if (outs.isEmpty()) { return; diff -r 433559e25b50 -r eccf966fb677 flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/CalculationSelect.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/CalculationSelect.java Fri Aug 19 11:46:40 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/CalculationSelect.java Fri Aug 19 14:10:18 2011 +0000 @@ -113,7 +113,7 @@ @Override - public boolean validate(Artifact artifact, CallContext context) + public boolean validate(Artifact artifact) throws IllegalArgumentException { logger.debug("CalculationSelect.validate"); diff -r 433559e25b50 -r eccf966fb677 flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DGMSelect.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DGMSelect.java Fri Aug 19 11:46:40 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DGMSelect.java Fri Aug 19 14:10:18 2011 +0000 @@ -13,14 +13,5 @@ protected String getUIProvider() { return "datacage_panel"; } - - - @Override - public boolean validate(Artifact artifact, CallContext context) - throws IllegalArgumentException - { - // TODO We have to check the user data if there is a real input! - return true; - } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : diff -r 433559e25b50 -r eccf966fb677 flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DefaultState.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DefaultState.java Fri Aug 19 11:46:40 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DefaultState.java Fri Aug 19 14:10:18 2011 +0000 @@ -249,11 +249,10 @@ * was correct, otherwise an exception is thrown. * * @param artifact A reference to the owner artifact. - * @param context The CallContext object. * * @return true, if everything was fine. */ - public boolean validate(Artifact artifact, CallContext context) + public boolean validate(Artifact artifact) throws IllegalArgumentException { return true; diff -r 433559e25b50 -r eccf966fb677 flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodplainChoice.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodplainChoice.java Fri Aug 19 11:46:40 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodplainChoice.java Fri Aug 19 14:10:18 2011 +0000 @@ -59,14 +59,5 @@ return item; } - - - @Override - public boolean validate(Artifact artifact, CallContext context) - throws IllegalArgumentException - { - // TODO We have to check the user data if there is a real input! - return true; - } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : diff -r 433559e25b50 -r eccf966fb677 flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/LocationDistanceSelect.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/LocationDistanceSelect.java Fri Aug 19 11:46:40 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/LocationDistanceSelect.java Fri Aug 19 14:10:18 2011 +0000 @@ -44,7 +44,7 @@ @Override - public boolean validate(Artifact artifact, CallContext context) + public boolean validate(Artifact artifact) throws IllegalArgumentException { logger.debug("LocationDistanceSelect.validate"); @@ -52,15 +52,15 @@ FLYSArtifact flys = (FLYSArtifact) artifact; if (flys.isRange()) { - return super.validate(flys, context); + return super.validate(flys); } else { - return validateLocations(flys, context); + return validateLocations(flys); } } - protected boolean validateLocations(FLYSArtifact flys, CallContext context) + protected boolean validateLocations(FLYSArtifact flys) throws IllegalArgumentException { StateData dValues = getData(flys, LOCATIONS); diff -r 433559e25b50 -r eccf966fb677 flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/LocationSelect.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/LocationSelect.java Fri Aug 19 11:46:40 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/LocationSelect.java Fri Aug 19 14:10:18 2011 +0000 @@ -80,7 +80,7 @@ @Override - public boolean validate(Artifact artifact, CallContext context) + public boolean validate(Artifact artifact) throws IllegalArgumentException { logger.debug("LocationSelect.validate"); diff -r 433559e25b50 -r eccf966fb677 flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ProfileDistanceSelect.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ProfileDistanceSelect.java Fri Aug 19 11:46:40 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ProfileDistanceSelect.java Fri Aug 19 14:10:18 2011 +0000 @@ -13,14 +13,5 @@ protected String getUIProvider() { return "auto_integer"; } - - - @Override - public boolean validate(Artifact artifact, CallContext context) - throws IllegalArgumentException - { - // TODO We have to check the user data if there is a real input! - return true; - } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : diff -r 433559e25b50 -r eccf966fb677 flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/RangeState.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/RangeState.java Fri Aug 19 11:46:40 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/RangeState.java Fri Aug 19 14:10:18 2011 +0000 @@ -63,7 +63,7 @@ @Override - public boolean validate(Artifact artifact, CallContext context) + public boolean validate(Artifact artifact) throws IllegalArgumentException { FLYSArtifact flys = (FLYSArtifact) artifact; diff -r 433559e25b50 -r eccf966fb677 flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/RiverSelect.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/RiverSelect.java Fri Aug 19 11:46:40 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/RiverSelect.java Fri Aug 19 14:10:18 2011 +0000 @@ -132,7 +132,7 @@ @Override - public boolean validate(Artifact artifact, CallContext context) + public boolean validate(Artifact artifact) throws IllegalArgumentException { logger.debug("RiverSelect.validate"); diff -r 433559e25b50 -r eccf966fb677 flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ScenarioSelect.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ScenarioSelect.java Fri Aug 19 11:46:40 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ScenarioSelect.java Fri Aug 19 14:10:18 2011 +0000 @@ -74,15 +74,5 @@ return item; } - - - @Override - public boolean validate(Artifact artifact, CallContext context) - throws IllegalArgumentException - { - // TODO - - return true; - } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : diff -r 433559e25b50 -r eccf966fb677 flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQAdapted.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQAdapted.java Fri Aug 19 11:46:40 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQAdapted.java Fri Aug 19 14:10:18 2011 +0000 @@ -271,7 +271,7 @@ @Override - public boolean validate(Artifact artifact, CallContext context) + public boolean validate(Artifact artifact) throws IllegalArgumentException { logger.debug("WQAdapted.validate"); @@ -282,10 +282,10 @@ String mode = data != null ? (String) data.getValue() : null; if (mode != null && mode.equals("W")) { - return validateW(artifact, context); + return validateW(artifact); } else if (mode != null && mode.equals("Q")) { - return validateQ(artifact, context); + return validateQ(artifact); } else { throw new IllegalArgumentException("error_feed_no_wq_mode_selected"); @@ -293,7 +293,7 @@ } - protected boolean validateW(Artifact artifact, CallContext context) + protected boolean validateW(Artifact artifact) throws IllegalArgumentException { logger.debug("WQAdapted.validateW"); @@ -323,7 +323,7 @@ } - protected boolean validateQ(Artifact artifact, CallContext context) + protected boolean validateQ(Artifact artifact) throws IllegalArgumentException { logger.debug("WQAdapted.validateQ"); diff -r 433559e25b50 -r eccf966fb677 flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQSelect.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQSelect.java Fri Aug 19 11:46:40 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQSelect.java Fri Aug 19 14:10:18 2011 +0000 @@ -200,7 +200,7 @@ @Override - public boolean validate(Artifact artifact, CallContext context) + public boolean validate(Artifact artifact) throws IllegalArgumentException { logger.debug("WQSelect.validate"); @@ -211,10 +211,10 @@ String selectionMode = data != null ? (String) data.getValue() : null; if (selectionMode == null || selectionMode.equals("single")) { - return validateSingle(artifact, context); + return validateSingle(artifact); } else { - return validateRange(artifact, context); + return validateRange(artifact); } } @@ -241,7 +241,7 @@ } - protected boolean validateSingle(Artifact artifact, CallContext context) + protected boolean validateSingle(Artifact artifact) throws IllegalArgumentException { logger.debug("WQSelect.validateSingle"); @@ -293,7 +293,7 @@ } - protected boolean validateRange(Artifact artifact, CallContext context) + protected boolean validateRange(Artifact artifact) throws IllegalArgumentException { logger.debug("WQSelect.validateRange"); @@ -325,10 +325,10 @@ double step = Double.parseDouble(stepStr); if (mode != null && mode.trim().toLowerCase().equals("w")) { - return validateW(artifact, context, from, to, step); + return validateW(artifact, from, to, step); } else if (mode != null && mode.trim().toLowerCase().equals("q")) { - return validateQ(artifact, context, from, to, step); + return validateQ(artifact, from, to, step); } else { throw new IllegalArgumentException( @@ -345,7 +345,6 @@ * Validates the inserted W values. * * @param artifact The owner artifact. - * @param context The CallContext * @param from The lower value of the W range. * @param to The upper value of the W range. * @param step The step width. @@ -354,7 +353,6 @@ */ protected boolean validateW( Artifact artifact, - CallContext context, double from, double to, double step) @@ -372,7 +370,6 @@ * Validates the inserted Q values. * * @param artifact The owner artifact. - * @param context The CallContext * @param from The lower value of the Q range. * @param to The upper value of the Q range. * @param step The step width. @@ -381,7 +378,6 @@ */ protected boolean validateQ( Artifact artifact, - CallContext context, double from, double to, double step) diff -r 433559e25b50 -r eccf966fb677 flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java Fri Aug 19 11:46:40 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java Fri Aug 19 14:10:18 2011 +0000 @@ -34,22 +34,6 @@ } - /** - * This method returns always true, because there is no data to validate. - * - * @param artifact The Artifact. - * @param context The CallContext. - * - * @return always true. - */ - @Override - public boolean validate(Artifact artifact, CallContext context) - throws IllegalArgumentException - { - return true; - } - - @Override public Object computeAdvance( FLYSArtifact artifact,