# HG changeset patch # User Ingo Weinzierl # Date 1343303224 0 # Node ID 8160e62bbb3af492c4cf309e4e497b9f803d5f3d # Parent 7d0ebde8c3e36a70fb4d6e1034aaea5138e792b4 Registered new output 'fix_vollmer_wq_curve' for the vollmer path of fixings analysis module; create required Facets for it after calculation. flys-artifacts/trunk@5137 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 7d0ebde8c3e3 -r 8160e62bbb3a flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Thu Jul 26 10:09:06 2012 +0000 +++ b/flys-artifacts/ChangeLog Thu Jul 26 11:47:04 2012 +0000 @@ -1,3 +1,34 @@ +2012-07-26 Ingo Weinzierl + + * doc/conf/artifacts/fixanalysis.xml: Registered new Output + 'fix_vollmer_wq_curve'. + + * doc/conf/conf.xml: Registered new FixWQCurveGenerator for + 'fix_vollmer_wq_curve'. + + * src/main/resources/messages.properties, + src/main/resources/messages_de_DE.properties, + src/main/resources/messages_en.properties, + src/main/resources/messages_de.properties: Added new names for Facets + used in 'fix_vollmer_wq_curve' Output. + + * src/main/java/de/intevation/flys/artifacts/model/fixings/FixWQCurveFacet.java, + src/main/java/de/intevation/flys/artifacts/model/fixings/FixReferenceEventsFacet.java, + src/main/java/de/intevation/flys/artifacts/model/fixings/FixOutlierFacet.java: + Make use of FitResult (parent of FixAnalysisResult) which is enough for + these Facets instead of casting the calculation result to + FixAnalysisResult. + + * src/main/java/de/intevation/flys/artifacts/access/FixAnalysisAccess.java: + Fixed potential NullpointerException. + + * src/main/java/de/intevation/flys/artifacts/states/fixation/FixRealizingCompute.java: + Create new Facets for WQ curve, fix events and outliers. + + * src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java: + Add subtitles only if the required data (date period and referenence + period) are existing. Otherwise do not add a subtitle. + 2012-07-26 Felix Wolfsteller * src/main/resources/messages.properties, diff -r 7d0ebde8c3e3 -r 8160e62bbb3a flys-artifacts/doc/conf/artifacts/fixanalysis.xml --- a/flys-artifacts/doc/conf/artifacts/fixanalysis.xml Thu Jul 26 10:09:06 2012 +0000 +++ b/flys-artifacts/doc/conf/artifacts/fixanalysis.xml Thu Jul 26 11:47:04 2012 +0000 @@ -230,6 +230,13 @@ + + + + + + + diff -r 7d0ebde8c3e3 -r 8160e62bbb3a flys-artifacts/doc/conf/conf.xml --- a/flys-artifacts/doc/conf/conf.xml Thu Jul 26 10:09:06 2012 +0000 +++ b/flys-artifacts/doc/conf/conf.xml Thu Jul 26 11:47:04 2012 +0000 @@ -279,6 +279,8 @@ de.intevation.flys.exports.fixings.FixDerivedCurveGenerator de.intevation.flys.exports.fixings.FixDerivedCurveInfoGenerator de.intevation.flys.exports.WaterlevelExporter + de.intevation.flys.exports.fixings.FixWQCurveGenerator + de.intevation.flys.exports.fixings.FixWQCurveInfoGenerator de.intevation.flys.exports.ReportGenerator de.intevation.flys.exports.ReportGenerator diff -r 7d0ebde8c3e3 -r 8160e62bbb3a flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/FixAnalysisAccess.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/FixAnalysisAccess.java Thu Jul 26 10:09:06 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/FixAnalysisAccess.java Thu Jul 26 11:47:04 2012 +0000 @@ -71,6 +71,10 @@ public DateRange getDateRange() { DateRange refP = getReferencePeriod(); + if (refP == null) { + return null; + } + Date from = refP.getFrom(); Date to = refP.getTo(); diff -r 7d0ebde8c3e3 -r 8160e62bbb3a flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixOutlierFacet.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixOutlierFacet.java Thu Jul 26 10:09:06 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixOutlierFacet.java Thu Jul 26 11:47:04 2012 +0000 @@ -1,22 +1,16 @@ package de.intevation.flys.artifacts.model.fixings; +import org.apache.log4j.Logger; + import de.intevation.artifacts.Artifact; import de.intevation.artifacts.CallContext; - import de.intevation.flys.artifacts.FLYSArtifact; - -import de.intevation.flys.artifacts.access.FixAnalysisAccess; - import de.intevation.flys.artifacts.model.CalculationResult; import de.intevation.flys.artifacts.model.DataFacet; import de.intevation.flys.artifacts.model.FacetTypes; - import de.intevation.flys.artifacts.states.DefaultState.ComputeType; - import de.intevation.flys.utils.KMIndex; -import org.apache.log4j.Logger; - /** * Facet to show the outliers in a fix calculation. * @@ -49,10 +43,11 @@ /** * Returns the data this facet requires. * - * @param artifact the owner artifact. - * @param context the CallContext (ignored). + * @param artifact the owner artifact; needs to be a FLYSArtifact. + * @param context the CallContext; required to retrieve the value of + * currentKm. * - * @return the data. + * @return an array of QW objects or null. */ @Override public Object getData(Artifact artifact, CallContext context) { @@ -60,28 +55,34 @@ if (artifact instanceof FLYSArtifact) { FLYSArtifact flys = (FLYSArtifact)artifact; - FixAnalysisAccess access = new FixAnalysisAccess(flys); CalculationResult res = (CalculationResult) flys.compute(context, ComputeType.ADVANCE, false); - FixAnalysisResult result = (FixAnalysisResult) res.getData(); + FixResult result = (FixResult) res.getData(); double currentKm = ((Double)context.getContextValue("currentKm")).doubleValue(); - KMIndex kmQWs = result.getOutliers(); + KMIndex kmQWs = result.getOutliers(); + KMIndex.Entry qwsEntry = kmQWs.binarySearch(currentKm); - KMIndex.Entry qwsEntry = kmQWs.binarySearch(currentKm); QW[] qws = null; if(qwsEntry != null) { qws = qwsEntry.getValue(); + + logger.debug("Found " + (qws != null ? qws.length : 0) + + " KMIndex.Entry for km " + currentKm); } + else { + logger.debug("Found no KMIndex.Entry for km " + currentKm); + } + return qws; } else { - logger.debug("Not an instance of FixationArtifact."); + logger.warn("Not an instance of FLYSArtifact."); return null; } } diff -r 7d0ebde8c3e3 -r 8160e62bbb3a flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixReferenceEventsFacet.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixReferenceEventsFacet.java Thu Jul 26 10:09:06 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixReferenceEventsFacet.java Thu Jul 26 11:47:04 2012 +0000 @@ -1,22 +1,16 @@ package de.intevation.flys.artifacts.model.fixings; +import org.apache.log4j.Logger; + import de.intevation.artifacts.Artifact; import de.intevation.artifacts.CallContext; - import de.intevation.flys.artifacts.FLYSArtifact; - -import de.intevation.flys.artifacts.access.FixAnalysisAccess; - import de.intevation.flys.artifacts.model.CalculationResult; import de.intevation.flys.artifacts.model.DataFacet; import de.intevation.flys.artifacts.model.FacetTypes; - import de.intevation.flys.artifacts.states.DefaultState.ComputeType; - import de.intevation.flys.utils.KMIndex; -import org.apache.log4j.Logger; - /** * Facet to show W values for Q values at km for a date. @@ -62,14 +56,13 @@ if (artifact instanceof FLYSArtifact) { FLYSArtifact flys = (FLYSArtifact)artifact; - FixAnalysisAccess access = new FixAnalysisAccess(flys); CalculationResult res = (CalculationResult) flys.compute(context, ComputeType.ADVANCE, false); - FixAnalysisResult result = (FixAnalysisResult) res.getData(); + FixResult result = (FixResult) res.getData(); double currentKm = ((Double)context.getContextValue("currentKm")).doubleValue(); diff -r 7d0ebde8c3e3 -r 8160e62bbb3a flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixWQCurveFacet.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixWQCurveFacet.java Thu Jul 26 10:09:06 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixWQCurveFacet.java Thu Jul 26 11:47:04 2012 +0000 @@ -68,7 +68,7 @@ ComputeType.ADVANCE, false); - FixAnalysisResult result = (FixAnalysisResult) res.getData(); + FixResult result = (FixResult) res.getData(); double currentKm = ((Double)context.getContextValue("currentKm")).doubleValue(); diff -r 7d0ebde8c3e3 -r 8160e62bbb3a flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/fixation/FixRealizingCompute.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/fixation/FixRealizingCompute.java Thu Jul 26 10:09:06 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/fixation/FixRealizingCompute.java Thu Jul 26 11:47:04 2012 +0000 @@ -1,30 +1,29 @@ package de.intevation.flys.artifacts.states.fixation; +import java.util.List; + +import org.apache.log4j.Logger; + import de.intevation.artifactdatabase.state.Facet; - import de.intevation.artifacts.CallContext; - +import de.intevation.artifacts.CallMeta; import de.intevation.flys.artifacts.FLYSArtifact; - import de.intevation.flys.artifacts.access.FixRealizingAccess; - import de.intevation.flys.artifacts.model.CalculationResult; import de.intevation.flys.artifacts.model.DataFacet; import de.intevation.flys.artifacts.model.FacetTypes; import de.intevation.flys.artifacts.model.ReportFacet; import de.intevation.flys.artifacts.model.WQCKms; import de.intevation.flys.artifacts.model.WQKms; - +import de.intevation.flys.artifacts.model.fixings.FixOutlierFacet; import de.intevation.flys.artifacts.model.fixings.FixRealizingCalculation; import de.intevation.flys.artifacts.model.fixings.FixRealizingResult; +import de.intevation.flys.artifacts.model.fixings.FixReferenceEventsFacet; +import de.intevation.flys.artifacts.model.fixings.FixWQCurveFacet; import de.intevation.flys.artifacts.model.fixings.FixWaterlevelFacet; - +import de.intevation.flys.artifacts.resources.Resources; import de.intevation.flys.artifacts.states.DefaultState; -import java.util.List; - -import org.apache.log4j.Logger; - /** * @author Raimund Renkert */ @@ -33,6 +32,15 @@ /** The logger used in this class. */ private static Logger logger = Logger.getLogger(FixRealizingCompute.class); + + public static final String I18N_WQ_CURVE = "fix.vollmer.wq.curve"; + + public static final String I18N_WQ_OUTLIER = "fix.vollmer.wq.outliers"; + + public static final String I18N_WQ_EVENTS = "fix.vollmer.wq.events"; + + + /** * The default constructor that initializes an empty State object. */ @@ -49,7 +57,8 @@ ) { logger.debug("FixRealizingCompute.computeAdvance"); - String id = getID(); + String id = getID(); + CallMeta meta = context.getMeta(); CalculationResult res; @@ -110,11 +119,29 @@ } if (wqkms.length > 0) { - facets.add(new DataFacet(CSV, "CSV data", ComputeType.ADVANCE, hash, id)); - facets.add(new DataFacet(WST, "WST data", ComputeType.ADVANCE, hash, id)); - facets.add(new DataFacet(PDF, "PDF data", ComputeType.ADVANCE, hash, id)); + facets.add( + new DataFacet(CSV, "CSV data", ComputeType.ADVANCE, hash, id)); + + facets.add( + new DataFacet(WST, "WST data", ComputeType.ADVANCE, hash, id)); + + facets.add( + new DataFacet(PDF, "PDF data", ComputeType.ADVANCE, hash, id)); } + facets.add(new FixWQCurveFacet( + 0, Resources.getMsg(meta, I18N_WQ_CURVE, I18N_WQ_CURVE))); + + facets.add(new FixReferenceEventsFacet( + 0, + FIX_REFERENCE_EVENTS_WQ, + Resources.getMsg(meta, I18N_WQ_EVENTS, I18N_WQ_EVENTS))); + + facets.add(new FixOutlierFacet( + 0, + FIX_OUTLIER, + Resources.getMsg(meta, I18N_WQ_OUTLIER, I18N_WQ_OUTLIER))); + return res; } } diff -r 7d0ebde8c3e3 -r 8160e62bbb3a flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java Thu Jul 26 10:09:06 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java Thu Jul 26 11:47:04 2012 +0000 @@ -221,20 +221,32 @@ FixAnalysisAccess access = new FixAnalysisAccess(artifact); DateRange dateRange = access.getDateRange(); DateRange refRange = access.getReferencePeriod(); - return Resources.format( - context.getMeta(), - I18N_CHART_SUBTITLE, - "", - access.getRiver(), - dateRange.getFrom(), - dateRange.getTo(), - refRange.getFrom(), - refRange.getTo()); + + if (dateRange != null && refRange != null) { + return Resources.format( + context.getMeta(), + I18N_CHART_SUBTITLE, + "", + access.getRiver(), + dateRange.getFrom(), + dateRange.getTo(), + refRange.getFrom(), + refRange.getTo()); + } + + return null; } @Override protected void addSubtitles(JFreeChart chart) { - chart.addSubtitle(new TextTitle(getDefaultChartSubtitle())); + String defaultSubtitle = getDefaultChartSubtitle(); + + if (defaultSubtitle == null || defaultSubtitle.length() == 0) { + return; + } + + chart.addSubtitle(new TextTitle(defaultSubtitle)); + StringBuilder buf = new StringBuilder(); // Add analysis periods as additional subtitle diff -r 7d0ebde8c3e3 -r 8160e62bbb3a flys-artifacts/src/main/resources/messages.properties --- a/flys-artifacts/src/main/resources/messages.properties Thu Jul 26 10:09:06 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages.properties Thu Jul 26 11:47:04 2012 +0000 @@ -347,6 +347,9 @@ fix.analysis=Analysis fix.deviation=Standard deviation fix.reference.deviation=Reference deviation +fix.vollmer.wq.curve=W/Q +fix.vollmer.wq.outliers=Outliers +fix.vollmer.wq.events=Events chart.fix.deltawt.title=Difference from compensating curve at kilometer {0} chart.fix.deltawt.subtitle=Water: {0}; Period: {1,date,short} to {2,date,short}; Reference period: {3,date,short} bis {4,date,short} diff -r 7d0ebde8c3e3 -r 8160e62bbb3a flys-artifacts/src/main/resources/messages_de.properties --- a/flys-artifacts/src/main/resources/messages_de.properties Thu Jul 26 10:09:06 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages_de.properties Thu Jul 26 11:47:04 2012 +0000 @@ -349,6 +349,9 @@ fix.analysis=Analyse fix.deviation=Standardabweichung fix.reference.deviation=Abweichung im Bezugszeitraum +fix.vollmer.wq.curve=W/Q +fix.vollmer.wq.outliers=Ausrei\u00dfer +fix.vollmer.wq.events=Ereignisse chart.fix.deltawt.title=Abweichungen von der Ausgleichskurve an Kilometer {0} chart.fix.deltawt.subtitle=Gew\u00e4sser: {0}; Darstellungszeitraum: {1,date,short} bis {2,date,short}; Bezugszeitraum: {3,date,short} bis {4,date,short} diff -r 7d0ebde8c3e3 -r 8160e62bbb3a flys-artifacts/src/main/resources/messages_de_DE.properties --- a/flys-artifacts/src/main/resources/messages_de_DE.properties Thu Jul 26 10:09:06 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages_de_DE.properties Thu Jul 26 11:47:04 2012 +0000 @@ -346,6 +346,9 @@ fix.analysis=Analyse fix.deviation=Standardabweichung fix.reference.deviation=Abweichung im Bezugszeitraum +fix.vollmer.wq.curve=W/Q +fix.vollmer.wq.outliers=Ausrei\u00dfer +fix.vollmer.wq.events=Ereignisse chart.fix.deltawt.title=Abweichungen von der Ausgleichskurve an Kilometer {0} chart.fix.deltawt.subtitle=Gew\u00e4sser: {0}; Darstellungszeitraum: {1,date,short} bis {2,date,short}; Bezugszeitraum: {3,date,short} bis {4,date,short} diff -r 7d0ebde8c3e3 -r 8160e62bbb3a flys-artifacts/src/main/resources/messages_en.properties --- a/flys-artifacts/src/main/resources/messages_en.properties Thu Jul 26 10:09:06 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages_en.properties Thu Jul 26 11:47:04 2012 +0000 @@ -350,6 +350,9 @@ fix.analysis=Analysis fix.deviation=Standard deviation fix.reference.deviation=Reference deviation +fix.vollmer.wq.curve=W/Q +fix.vollmer.wq.outliers=Outliers +fix.vollmer.wq.events=Events chart.fix.deltawt.title=Difference from compensating curve at kilometer {0} chart.fix.deltawt.subtitle=Water: {0}; Period: {1,date,short} to {2,date,short}; Reference period: {3,date,short} bis {4,date,short}