Mercurial > dive4elements > river
view flys-artifacts/src/main/java/de/intevation/flys/artifacts/FixationArtifactAccess.java @ 2783:cbb513a8f548
FixA: km indexed datastructure for delta w/t results.
flys-artifacts/trunk@4522 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 25 May 2012 13:49:27 +0000 |
parents | f53173a8736b |
children | 3dd1c320cf81 |
line wrap: on
line source
package de.intevation.flys.artifacts; import java.util.Arrays; import de.intevation.artifactdatabase.data.StateData; import gnu.trove.TDoubleArrayList; import de.intevation.flys.utils.FLYSUtils; import org.apache.log4j.Logger; public class FixationArtifactAccess { private static Logger log = Logger.getLogger(FixationArtifactAccess.class); protected FLYSArtifact artifact; protected String river; protected String calculationMode; protected Double from; protected Double to; protected Double step; protected Long start; protected Long end; protected Integer qSectorStart; protected Integer qSectorEnd; protected Long referenceStart; protected Long referenceEnd; protected long [][] analysisPeriods; protected int [] events; protected Boolean preprocessing; protected String function; protected double [] qs; public FixationArtifactAccess() { } public FixationArtifactAccess(FLYSArtifact artifact) { this.artifact = artifact; } public FLYSArtifact getArtifact() { return artifact; } public String getRiver() { if (river == null) { StateData sd = artifact.getData("river"); if (sd == null) { log.warn("missing 'river' value"); return null; } river = (String)sd.getValue(); } if (log.isDebugEnabled()) { log.debug("river: '" + river + "'"); } return river; } public String getCalculationMode() { if (calculationMode == null) { StateData sd = artifact.getData("calculation.mode"); if (sd == null) { log.warn("missing 'calculation.mode' value"); return null; } calculationMode = (String)sd.getValue(); } if (log.isDebugEnabled()) { log.debug("calculationMode: '" + calculationMode + "'"); } return calculationMode; } public Double getFrom() { if (from == null) { StateData sd = artifact.getData("from"); if (sd == null) { log.warn("missing 'from' value"); return null; } try { from = Double.valueOf((String)sd.getValue()); } catch (NumberFormatException nfe) { log.warn("from '" + sd.getValue() + "' is not numeric."); } } if (log.isDebugEnabled()) { log.debug("from: '" + from + "'"); } return from; } public Double getTo() { if (to == null) { StateData sd = artifact.getData("to"); if (sd == null) { log.warn("missing 'to' value"); return null; } try { to = Double.valueOf((String)sd.getValue()); } catch (NumberFormatException nfe) { log.warn("to '" + sd.getValue() + "' is not numeric."); } } if (log.isDebugEnabled()) { log.debug("to: '" + to + "'"); } return to; } public Double getStep() { if (step == null) { StateData sd = artifact.getData("step"); if (sd == null) { log.warn("missing 'step' value"); return null; } try { step = Double.valueOf((String)sd.getValue()); } catch (NumberFormatException nfe) { log.warn("step '" + sd.getValue() + "' is not numeric."); } } if (log.isDebugEnabled()) { log.debug("step: '" + step + "'"); } return step; } public Long getStart() { if (start == null) { StateData sd = artifact.getData("start"); if (sd == null) { log.warn("missing 'start' value"); return null; } try { start = Long.valueOf((String)sd.getValue()); } catch (NumberFormatException nfe) { log.warn("start '" + sd.getValue() + "' is not an integer."); } } if (log.isDebugEnabled()) { log.debug("start: '" + start + "'"); } return start; } public Long getEnd() { if (end == null) { StateData sd = artifact.getData("end"); if (sd == null) { log.warn("missing 'end' value"); return null; } try { end = Long.valueOf((String)sd.getValue()); } catch (NumberFormatException nfe) { log.warn("end '" + sd.getValue() + "' is not an integer."); } } if (log.isDebugEnabled()) { log.debug("end: '" + end + "'"); } return end; } public Integer getQSectorStart() { if (qSectorStart == null) { StateData sd = artifact.getData("q1"); if (sd == null) { log.warn("missing 'q1' value"); return null; } try { qSectorStart = Integer.valueOf((String)sd.getValue()); } catch (NumberFormatException nfe) { log.warn("q1 '" + sd.getValue() + "' is not an integer."); } } return qSectorStart; } public Integer getQSectorEnd() { if (qSectorEnd == null) { StateData sd = artifact.getData("q2"); if (sd == null) { log.warn("missing 'q2' value"); return null; } try { qSectorEnd = Integer.valueOf((String)sd.getValue()); } catch (NumberFormatException nfe) { log.warn("q2 '" + sd.getValue() + "' is not an integer."); } } return qSectorEnd; } public int [] getEvents() { if (events == null) { StateData sd = artifact.getData("events"); if (sd == null) { log.warn("missing 'events' value"); return null; } events = FLYSUtils.intArrayFromString((String)sd.getValue()); } return events; } public Long getReferenceStart() { if (referenceStart == null) { StateData sd = artifact.getData("ref_start"); if (sd == null) { log.warn("missing 'ref_start' value"); return null; } try { referenceStart = Long.valueOf((String)sd.getValue()); } catch (NumberFormatException nfe) { log.warn("ref_start '" + sd.getValue() + "' is not an integer."); } } if (log.isDebugEnabled()) { log.debug("referenceStart: '" + referenceStart + "'"); } return referenceStart; } public Long getReferenceEnd() { if (referenceEnd == null) { StateData sd = artifact.getData("ref_end"); if (sd == null) { log.warn("missing 'ref_end' value"); return null; } try { referenceEnd = Long.valueOf((String)sd.getValue()); } catch (NumberFormatException nfe) { log.warn("ref_end '" + sd.getValue() + "' is not an integer."); } } if (log.isDebugEnabled()) { log.debug("referenceEnd: '" + referenceEnd + "'"); } return referenceEnd; } public long [][] getAnalysisPeriods() { if (analysisPeriods == null) { /** TODO: Use real arrays here! */ StateData sdStart = artifact.getData("ana_start"); StateData sdEnd = artifact.getData("ana_end"); if (sdStart == null || sdEnd == null) { log.warn("missing 'ana_start' or 'ana_end'"); return null; } try { analysisPeriods = new long [][] { { Long.parseLong((String)sdStart.getValue()), Long.parseLong((String)sdEnd.getValue()) } }; } catch (NumberFormatException nfe) { log.warn("'ana_start' or 'ana_end' is not an integer."); return null; } } if (log.isDebugEnabled()) { for (int i = 0; i < analysisPeriods.length; ++i) { long [] ap = analysisPeriods[i]; log.debug("analysis period " + ap[0] + " - " + ap[1]); } } return analysisPeriods; } public Boolean getPreprocessing() { if (preprocessing == null) { StateData sd = artifact.getData("preprocessing"); if (sd == null) { log.warn("missing 'preprocessing'"); return null; } preprocessing = Boolean.valueOf((String)sd.getValue()); } return preprocessing; } public String getFunction() { if (function == null) { StateData sd = artifact.getData("function"); if (sd == null) { log.warn("missing 'function'"); return null; } function = (String)sd.getValue(); } if (log.isDebugEnabled()) { log.debug("function: " + function); } return function; } public double [] getQs() { if (qs == null) { StateData sd = artifact.getData("qs"); if (sd == null) { log.warn("missing 'qs'"); return null; } String [] parts = ((String)sd.getValue()).split("[\\s;]"); TDoubleArrayList list = new TDoubleArrayList(parts.length); for (String part: parts) { try { list.add(Double.parseDouble(part)); } catch (NumberFormatException nfe) { log.warn("'" + part + "' is not numeric."); } } qs = list.toNativeArray(); } if (log.isDebugEnabled()) { log.debug("qs: " + Arrays.toString(qs)); } return qs; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :