package de.jeyp91.tippliga;


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

public class TLWMatchday {

    final Integer STATUS_NOTSTARTED = 0;
    final Integer STATUS_STARTED = 1;
    final Integer STATUS_PROVISIONAL_RESULT_AVAILABLE = 2;
    final Integer STATUS_FINISHED = 3;

    private Integer season = null;
    private Integer league = null;
    private Integer matchday = null;
    private Integer status = null;
    private String deliveryDate = null;
    private String deliveryDate2 = null;
    private String deliveryDate3 = null;
    private String matchdayName = null;
    private Integer matches = null;

    public TLWMatchday(ResultSet rset) {

        final int SEASON = 1;
        final int LEAGUE = 2;
        final int MATCHDAY = 3;
        final int STATUS = 4;
        final int DELIVERY_DATE = 5;
        final int DELIVERY_DATE_2 = 6;
        final int DELIVERY_DATE_3 = 7;
        final int MATCHDAY_NAME = 8;
        final int MATCHES = 9;

        try {
            this.season = Integer.parseInt(rset.getString(SEASON));
            this.league = Integer.parseInt(rset.getString(LEAGUE));
            this.matchday = Integer.parseInt(rset.getString(MATCHDAY));
            this.status = Integer.parseInt(rset.getString(STATUS));
            this.deliveryDate = rset.getString(DELIVERY_DATE);
            this.deliveryDate2 = rset.getString(DELIVERY_DATE_2);
            this.deliveryDate3 = rset.getString(DELIVERY_DATE_3);
            this.matchdayName = rset.getString(MATCHDAY_NAME);
            this.matches = Integer.parseInt(rset.getString(MATCHES));
        } catch (SQLException e) {
            /* TODO */
            e.printStackTrace();
        }
    }

    public TLWMatchday(int season, int league, int matchday, int status, String deliveryDate1, String deliveryDate2, String deliveryDate3, String matchdayName, int numberOfMatches) {
        this.season = season;
        this.league = league;
        this.matchday = matchday;
        this.status = status;
        this.deliveryDate = deliveryDate1;
        this.deliveryDate2 = deliveryDate2;
        this.deliveryDate3 = deliveryDate3;
        this.matchdayName = matchdayName;
        this.matches = numberOfMatches;
    }

    public Integer getSeason() {
        return this.season;
    }

    public Integer getLeague() {
        return this.league;
    }

    public Integer getMatchday() {
        return this.matchday;
    }

    public Integer getStatus() {
        return this.status;
    }

    public String getDeliveryDate() {
        return this.deliveryDate == null ? "" : this.deliveryDate;
    }

    public String getDeliveryDate2() {
        return this.deliveryDate2 == null ? "" : this.deliveryDate2;
    }

    public String getDeliveryDate3() {
        return this.deliveryDate3 == null ? "" : this.deliveryDate3;
    }

    public String getMatchdayName() {
        return this.matchdayName;
    }

    public Integer getMatches() {
        return this.matches;
    }
}
