Mercurial > dive4elements > river
changeset 3466:8160e62bbb3a
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
line wrap: on
line diff
--- 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 <ingo@intevation.de> + + * 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 <felix.wolfsteller@intevation.de> * src/main/resources/messages.properties,
--- 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 @@ <facet name="longitudinal_section.q" description="facet.longitudinal_section.q"/> </facets> </outputmode> + <outputmode name="fix_vollmer_wq_curve" description="output.fix_vollmer_wq_curve" mine-type="image/png" type="chart"> + <facets> + <facet name="fix_wq_curve" description="WQ curve"/> + <facet name="fix_reference_events_wq" description="Raw event values used in the calculation"/> + <facet name="fix_outlier" description="The outliers"/> + </facets> + </outputmode> <outputmode name="fix_waterlevel_export" description="output.fix_waterlevel_export" mine-type="text/plain" type="export"> <facets> <facet name="csv" description="facet.waterlevel_export.csv" />
--- 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 @@ <output-generator name="fix_derivate_curve">de.intevation.flys.exports.fixings.FixDerivedCurveGenerator</output-generator> <output-generator name="fix_derivate_curve_chartinfo">de.intevation.flys.exports.fixings.FixDerivedCurveInfoGenerator</output-generator> <output-generator name="fix_waterlevel_export">de.intevation.flys.exports.WaterlevelExporter</output-generator> + <output-generator name="fix_vollmer_wq_curve">de.intevation.flys.exports.fixings.FixWQCurveGenerator</output-generator> + <output-generator name="fix_vollmer_wq_curve_chartinfo">de.intevation.flys.exports.fixings.FixWQCurveInfoGenerator</output-generator> <!-- Error report generators. --> <output-generator name="discharge_longitudinal_section_report">de.intevation.flys.exports.ReportGenerator</output-generator> <output-generator name="waterlevel_report">de.intevation.flys.exports.ReportGenerator</output-generator>
--- 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();
--- 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 + * <i>currentKm</i>. * - * @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<QW []> kmQWs = result.getOutliers(); + KMIndex<QW []> kmQWs = result.getOutliers(); + KMIndex.Entry<QW []> qwsEntry = kmQWs.binarySearch(currentKm); - KMIndex.Entry<QW []> 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; } }
--- 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();
--- 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();
--- 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 <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> */ @@ -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; } }
--- 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
--- 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}
--- 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}
--- 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}
--- 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}