bjoern@3739: package de.intevation.flys.artifacts.services; bjoern@3739: bjoern@3739: import java.math.BigDecimal; bjoern@3739: import java.util.List; bjoern@3739: bjoern@3739: import org.apache.log4j.Logger; bjoern@3739: bjoern@3739: import org.w3c.dom.Document; bjoern@3739: import org.w3c.dom.Element; bjoern@3739: bjoern@3739: import de.intevation.artifacts.CallMeta; bjoern@3739: import de.intevation.artifacts.GlobalContext; bjoern@3739: import de.intevation.artifacts.common.ArtifactNamespaceContext; bjoern@3739: import de.intevation.artifacts.common.utils.XMLUtils; bjoern@3739: bjoern@3739: import de.intevation.flys.artifacts.model.RiverFactory; bjoern@3739: import de.intevation.flys.model.Gauge; bjoern@3739: import de.intevation.flys.model.MinMaxWQ; bjoern@3739: import de.intevation.flys.model.Range; bjoern@3739: import de.intevation.flys.model.River; bjoern@3739: bjoern@3739: /** bjoern@3739: * @author Björn Ricks bjoern@3739: */ bjoern@4247: public class GaugeOverviewInfoService extends RiverInfoService { bjoern@3739: bjoern@3739: private static final Logger logger = Logger.getLogger( bjoern@3739: GaugeOverviewInfoService.class); bjoern@3739: bjoern@3739: @Override bjoern@3739: public Document doProcess( bjoern@3739: Document data, bjoern@3739: GlobalContext globalContext, bjoern@3739: CallMeta callMeta bjoern@3739: ) { bjoern@4247: Document result = super.doProcess(data, globalContext, callMeta); bjoern@3739: bjoern@4247: logger.debug("GaugeOverviewInfoService.process"); bjoern@3739: bjoern@3739: Element egs = ec.create("gauges"); bjoern@3739: bjoern@3739: List gauges = river.getGauges(); sascha@3748: sascha@3748: if (logger.isDebugEnabled()) { sascha@3748: logger.debug("Loaded gauges: " + gauges); sascha@3748: } sascha@3748: bjoern@3739: for (Gauge gauge: river.getGauges()) { bjoern@3739: Element eg = ec.create("gauge"); sascha@3748: bjoern@3739: String name = gauge.getName(); bjoern@3739: if (name != null) { bjoern@3739: ec.addAttr(eg, "name", gauge.getName(), true); bjoern@3739: } bjoern@3739: bjoern@4247: String aeo = getStringValue(gauge.getAeo()); sascha@3748: if (aeo != null) { sascha@3748: ec.addAttr(eg, "aeo", aeo, true); sascha@3748: } sascha@3748: bjoern@4247: String datum = getStringValue(gauge.getDatum()); sascha@3748: if (datum != null) { sascha@3748: ec.addAttr(eg, "datum", datum, true); sascha@3748: } sascha@3748: bjoern@3739: Range range = gauge.getRange(); bjoern@3739: if (range != null) { bjoern@3753: BigDecimal a = range.getA(); bjoern@3753: if (a != null) { bjoern@3753: double min = a.doubleValue(); bjoern@3753: ec.addAttr(eg, "start", Double.toString(min), true); bjoern@3753: } bjoern@3739: bjoern@3739: BigDecimal b = range.getB(); bjoern@3739: if (b != null) { bjoern@3739: double max = range.getB().doubleValue(); bjoern@3739: ec.addAttr(eg, "end", Double.toString(max), true); bjoern@3739: } bjoern@3739: } bjoern@3739: MinMaxWQ minmaxwq = gauge.fetchMaxMinWQ(); bjoern@4247: String minw = getStringValue(minmaxwq.getMinW()); bjoern@4247: String maxw = getStringValue(minmaxwq.getMaxW()); bjoern@4247: String minq = getStringValue(minmaxwq.getMinQ()); bjoern@4247: String maxq = getStringValue(minmaxwq.getMaxQ()); bjoern@3739: bjoern@3739: if (minw != null) { bjoern@3739: ec.addAttr(eg, "minw", minw, true); bjoern@3739: } bjoern@3739: if (maxw != null) { bjoern@3739: ec.addAttr(eg, "maxw", maxw, true); bjoern@3739: } bjoern@3739: if (minq != null) { bjoern@3739: ec.addAttr(eg, "minq", minq, true); bjoern@3739: } bjoern@3739: if (maxq != null) { bjoern@3739: ec.addAttr(eg, "maxq", maxq, true); bjoern@3739: } bjoern@3739: bjoern@4247: String station = getStringValue(gauge.getStation()); ingo@3785: if (station != null) { ingo@3785: ec.addAttr(eg, "station", station, true); ingo@3785: } ingo@3785: bjoern@3896: Long official = gauge.getOfficialNumber(); bjoern@3896: if (official != null) { bjoern@3896: ec.addAttr(eg, "official", official.toString(), true); bjoern@3896: } bjoern@3896: bjoern@3739: egs.appendChild(eg); bjoern@3739: } bjoern@3739: bjoern@4247: riverele.appendChild(egs); bjoern@3739: bjoern@3739: return result; bjoern@3739: } bjoern@3739: }