view flys-aft/src/main/java/de/intevation/aft/DischargeTable.java @ 4091:a91c7e982c32

Make W/Q values from AFT and FLYS loadable. flys-aft/trunk@3601 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 05 Jan 2012 16:41:26 +0000
parents d556e29592f5
children b3fc044f75ba
line wrap: on
line source
package de.intevation.aft;

import java.util.List;
import java.util.ArrayList;

import java.sql.SQLException;
import java.sql.ResultSet;

import de.intevation.db.SymbolicStatement;

public class DischargeTable
{
    protected int          id;
    protected int          gaugeId;
    protected TimeInterval timeInterval;
    protected String       description;
    protected List<WQ>     values;

    public DischargeTable() {
    }

    public DischargeTable(
        int          gaugeId, 
        TimeInterval timeInterval, 
        String       description
    ) {
        this.gaugeId      = gaugeId;
        this.timeInterval = timeInterval;
        this.description  = description;
        values = new ArrayList<WQ>();
    }

    public DischargeTable(
        int          id, 
        int          gaugeId, 
        TimeInterval timeInterval, 
        String       description
    ) {
        this(gaugeId, timeInterval, description);
        this.id = id;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getGaugeId() {
        return gaugeId;
    }

    public void setGaugeId(int gaugeId) {
        this.gaugeId = gaugeId;
    }

    public TimeInterval getTimeInterval() {
        return timeInterval;
    }

    public void setTimeInterval(TimeInterval timeInterval) {
        this.timeInterval = timeInterval;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    protected void loadValues(SymbolicStatement.Instance query) 
    throws SQLException
    {
        ResultSet rs = query.executeQuery();
        while (rs.next()) {
            int    id = rs.getInt("id");
            double w  = rs.getDouble("w");
            double q  = rs.getDouble("q");
            values.add(new WQ(id, w, q));
        }
        rs.close();
    }

    public void loadAftValues(SyncContext context) throws SQLException {
        loadValues(context.getAftStatements()
            .getStatement("select.tafelwert")
            .clearParameters()
            .setInt("number", getId()));
    }

    public void loadFlysValues(SyncContext context) throws SQLException {
        loadValues(context.getFlysStatements()
            .getStatement("select.discharge.table.values")
            .clearParameters()
            .setInt("table_id", getId()));
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org