package cz.utb.tadis.charts.model;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;

@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum ChartAxis {

    CITY("Město", ChartAxisType.TEXT_VALUE, "a.city", "Attack a", "a.city is not null"),
    COUNTRY("Stát", ChartAxisType.TEXT_VALUE, "a.country", "Attack a", "a.country is not null"),
    TERROR("Teror", ChartAxisType.TEXT_VALUE, "a.terror", "Attack a", "a.terror is not null"),
    EPICENTER("Epicentrum", ChartAxisType.TEXT_VALUE, "a.epicenter", "Attack a", "a.epicenter is not null"),
    MODUS_OPERANDI("Modus Operandi", ChartAxisType.TEXT_VALUE, "a.modusOperandi", "Attack a", "a.modusOperandi is not null"),
    ENTRANCE_SECURITY("Ochranka u vstupu", ChartAxisType.TEXT_VALUE, "a.entranceSecurity", "Attack a", "a.entranceSecurity is not null"),
    TERRORIST_ORGANIZATION("K útoku se přihlásili", ChartAxisType.TEXT_VALUE, "a.terroristOrganization", "Attack a", "a.terroristOrganization is not null"),

    COUNT("Počet útoků", ChartAxisType.COUNT, "count(a)", "Attack a", "a.id is not null"),

    YEAR("Rok", ChartAxisType.NUMERIC_VALUE, "year(a.date)", "Attack a", "a.date is not null"),
    DEATHS("Počet smrtí", ChartAxisType.NUMERIC_VALUE, "a.deaths", "Attack a", "a.deaths is not null"),
    INJURED("Počet zraněných", ChartAxisType.NUMERIC_VALUE, "a.injured", "Attack a", "a.injured is not null"),
    ATTACKERS("Počet útočníků", ChartAxisType.NUMERIC_VALUE, "a.attackersCount", "Attack a", "a.attackersCount is not null"),

    AVG_DEATHS("Průměrný počet smrtí", ChartAxisType.AVG, "avg(a.deaths)", "Attack a", "a.deaths is not null"),
    SUM_DEATHS("Celkový počet smrtí", ChartAxisType.SUM, "sum(a.deaths)", "Attack a", "a.deaths is not null"),
    AVG_INJURED("Průměrný počet zraněných", ChartAxisType.AVG, "avg(a.injured)", "Attack a", "a.injured is not null"),
    SUM_INJURED("Celkový počet zraněných", ChartAxisType.SUM, "sum(a.injured)", "Attack a", "a.injured is not null"),
    AVG_ATTACKERS("Průměrný počet útočníků", ChartAxisType.AVG, "avg(a.attackersCount)", "Attack a", "a.attackersCount is not null"),
    SUM_ATTACKERS("Celkový počet útočníků", ChartAxisType.SUM, "sum(a.attackersCount)", "Attack a", "a.attackersCount is not null");

    private String label;
    private ChartAxisType type;

    @JsonIgnore
    private String column;

    @JsonIgnore
    private String sourceTables;

    @JsonIgnore
    private String constraint;

    ChartAxis() {
    }

    ChartAxis(String label, ChartAxisType type, String column, String sourceTables, String constraint) {
        this.label = label;
        this.type = type;
        this.column = column;
        this.sourceTables = sourceTables;
        this.constraint = constraint;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public ChartAxisType getType() {
        return type;
    }

    public void setType(ChartAxisType type) {
        this.type = type;
    }

    public String getColumn() {
        return column;
    }

    public void setColumn(String column) {
        this.column = column;
    }

    public String getSourceTables() {
        return sourceTables;
    }

    public void setSourceTables(String sourceTables) {
        this.sourceTables = sourceTables;
    }

    public String getConstraint() {
        return constraint;
    }

    public void setConstraint(String constraint) {
        this.constraint = constraint;
    }

    @JsonProperty
    public String getName() {
        return name();
    }

}
