bjoern@4246: package de.intevation.flys.artifacts.services; bjoern@4246: bjoern@4246: import java.math.BigDecimal; bjoern@4246: import java.util.List; bjoern@4246: bjoern@4246: import org.apache.log4j.Logger; bjoern@4246: bjoern@4246: import org.w3c.dom.Document; bjoern@4246: import org.w3c.dom.Element; bjoern@4246: bjoern@4246: import de.intevation.artifacts.CallMeta; bjoern@4246: import de.intevation.artifacts.GlobalContext; bjoern@4246: import de.intevation.artifacts.common.ArtifactNamespaceContext; bjoern@4246: import de.intevation.artifacts.common.utils.XMLUtils; bjoern@4246: bjoern@4246: import de.intevation.flys.artifacts.model.RiverFactory; bjoern@4246: import de.intevation.flys.model.MeasurementStation; bjoern@4246: import de.intevation.flys.model.Range; bjoern@4246: import de.intevation.flys.model.River; bjoern@4246: bjoern@4246: /** bjoern@4246: * @author Björn Ricks bjoern@4246: */ bjoern@4247: public class MeasurementStationInfoService extends RiverInfoService { bjoern@4246: bjoern@4246: private static final Logger logger = Logger.getLogger( bjoern@4264: MeasurementStationInfoService.class); bjoern@4246: bjoern@4246: @Override bjoern@4246: public Document doProcess( bjoern@4246: Document data, bjoern@4246: GlobalContext globalContext, bjoern@4246: CallMeta callMeta bjoern@4246: ) { bjoern@4247: Document result = super.doProcess(data, globalContext, callMeta); bjoern@4246: bjoern@4246: Element egs = ec.create("measurement-stations"); bjoern@4246: bjoern@4246: List mstations = river.getMeasurementStations(); bjoern@4246: bjoern@4246: if (logger.isDebugEnabled()) { bjoern@4246: logger.debug("Loaded stations: " + mstations); bjoern@4246: } bjoern@4246: bjoern@4246: for (MeasurementStation mstation: mstations) { bjoern@4246: Element eg = ec.create("measurement-station"); bjoern@4246: bjoern@4246: String name = mstation.getName(); bjoern@4246: if (name != null) { bjoern@4246: ec.addAttr(eg, "name", name, true); bjoern@4246: } bjoern@4246: bjoern@4263: Integer id = mstation.getId(); bjoern@4263: if (id != null) { bjoern@4263: ec.addAttr(eg, "id", Integer.toString(id), true); bjoern@4263: } bjoern@4263: bjoern@4246: String type = mstation.getMeasurementType(); bjoern@4246: if (type != null) { bjoern@4246: ec.addAttr(eg, "type", type, true); bjoern@4246: } bjoern@4246: bjoern@4246: String riverside = mstation.getRiverside(); bjoern@4246: if (riverside != null) { bjoern@4246: ec.addAttr(eg, "riverside", riverside, true); bjoern@4246: } bjoern@4246: bjoern@4246: Double station = mstation.getStation(); bjoern@4246: if (station != null) { bjoern@4246: ec.addAttr(eg, "station", Double.toString(station), true); bjoern@4246: } bjoern@4246: bjoern@4246: Range range = mstation.getRange(); bjoern@4246: if (range != null) { bjoern@4246: BigDecimal a = range.getA(); bjoern@4246: if (a != null) { bjoern@4246: ec.addAttr(eg, "start", getStringValue(a), true); bjoern@4246: } bjoern@4246: bjoern@4246: BigDecimal b = range.getB(); bjoern@4246: if (b != null) { bjoern@4246: ec.addAttr(eg, "end", getStringValue(b), true); bjoern@4246: } bjoern@4246: } bjoern@4246: bjoern@4263: String moperator = mstation.getOperator(); bjoern@4263: if (moperator != null) { bjoern@4263: ec.addAttr(eg, "operator", moperator, true); bjoern@4263: } bjoern@4263: bjoern@4246: egs.appendChild(eg); bjoern@4246: } bjoern@4246: bjoern@4247: this.riverele.appendChild(egs); bjoern@4246: bjoern@4246: return result; bjoern@4246: } bjoern@4246: bjoern@4246: }