package app.GUI;

import app.PREPROCESSING.PrepConf;
import app.PREPROCESSING.Preprocesor;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.inject.Named;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Petr Flégl on 5.3.2017.
 */
@Named
@ManagedBean
@ViewScoped
public class OilTable {
    private List<String> columns = new ArrayList<String>();
   private double[][] values;
    private List<PrepConf> sloupce = new ArrayList<>();

    public OilTable() {
        populateColumns();

        Preprocesor p = new Preprocesor(sloupce);
        values =  p.getData();//preprocesor .getdata
              if(values.length>0){
        }

    }

    @PostConstruct
    public void init(){



    }

    public void populateColumns() {

        sloupce.add(new PrepConf("table9:datumOdberu", "Odběr", "datumOdberu", 1420066800, 1451516400, 0, 35, 0, 35));
        sloupce.add(new PrepConf("table9:datumRozboru", "Výsledek", "datumRozboru", 1420066800, 1451516400, 38, 48, 38, 48));
        sloupce.add(new PrepConf("table9:dobaOleje", "MTh oleje", "datumOdberu", 1420066800, 1451516400, 45, 58, 45, 58));
        sloupce.add(new PrepConf("table9:dobaProvozu", "MTh celkem", "datumOdberu", 1420066800, 1451516400, 0, 50, 0, 50));
        sloupce.add(new PrepConf("table9:obsahVody", "Obsah vody", "datumOdberu", 1420066800, 1451516400, 0, 50, 0, 50));
        sloupce.add(new PrepConf("table9:obsahGlykolu", "Obsah glyk.", "datumOdberu", 1420066800, 1451516400, 0, 50, 0, 50));
        sloupce.add(new PrepConf("table9:nitrace", "Nitrace", "datumOdberu", 1420066800, 1451516400, 0, 50, 0, 50));
        sloupce.add(new PrepConf("table9:sulfatace", "Sulfatace", "datumOdberu", 1420066800, 1451516400, 0, 50, 0, 50));
        sloupce.add(new PrepConf("table9:oxidace", "Oxidace", "datumOdberu", 1420066800, 1451516400, 0, 50, 0, 50));
        sloupce.add(new PrepConf("table9:tBN", "TBN", "datumOdberu", 1420066800, 1451516400, 0, 50, 0, 50));
        sloupce.add(new PrepConf("table9:aN", "AN", "datumOdberu", 1420066800, 1451516400, 0, 50, 0, 50));
        sloupce.add(new PrepConf("table9:iPH", "IPH", "datumOdberu", 1420066800, 1451516400, 0, 50, 0, 50));
        sloupce.add(new PrepConf("table9:med", "Obsah mědi", "datumOdberu", 1420066800, 1451516400, 0, 50, 0, 50));
        sloupce.add(new PrepConf("table9:zelezo", "Obsah železa", "datumOdberu", 1420066800, 1451516400, 0, 50, 0, 50));

        for (int c = 0; c < sloupce.size(); c++) {
            columns.add(sloupce.get(c).getDesctription().toUpperCase());
        }

    }


    public List<String> getColumns() {
        return columns;
    }

    public void setColumns(List<String> columns) {
        this.columns = columns;
    }

    public double[][] getValues() {
        return values;
    }

    public void setValues(double[][] values) {
        this.values = values;
    }

    public List<PrepConf> getSloupce() {
        return sloupce;
    }

    public void setSloupce(List<PrepConf> sloupce) {
        this.sloupce = sloupce;
    }

    public int getColCount() {
        return columns.size();
    }

    public int getRowCount(){
        if(values.length>0)
            return values[0].length;
        else
            return 0;
    }
}
