/*
 * This file is generated by jOOQ.
 */
package ru.micord.webbpm.ervu.business_metrics.db_beans.metrics.tables;


import java.math.BigDecimal;
import java.util.Collection;

import org.jooq.Condition;
import org.jooq.Field;
import org.jooq.Name;
import org.jooq.PlainSQL;
import org.jooq.QueryPart;
import org.jooq.SQL;
import org.jooq.Schema;
import org.jooq.Select;
import org.jooq.Stringly;
import org.jooq.Table;
import org.jooq.TableField;
import org.jooq.TableOptions;
import org.jooq.impl.DSL;
import org.jooq.impl.SQLDataType;
import org.jooq.impl.TableImpl;

import ru.micord.webbpm.ervu.business_metrics.db_beans.metrics.Metrics;
import ru.micord.webbpm.ervu.business_metrics.db_beans.metrics.tables.records.ViewIncidentsRecievedByDataFromGirVuRecord;


/**
 * This class is generated by jOOQ.
 */
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class ViewIncidentsRecievedByDataFromGirVu extends TableImpl<ViewIncidentsRecievedByDataFromGirVuRecord> {

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of
     * <code>metrics.view_incidents_recieved_by_data_from_gir_vu</code>
     */
    public static final ViewIncidentsRecievedByDataFromGirVu VIEW_INCIDENTS_RECIEVED_BY_DATA_FROM_GIR_VU = new ViewIncidentsRecievedByDataFromGirVu();

    /**
     * The class holding records for this type
     */
    @Override
    public Class<ViewIncidentsRecievedByDataFromGirVuRecord> getRecordType() {
        return ViewIncidentsRecievedByDataFromGirVuRecord.class;
    }

    /**
     * The column
     * <code>metrics.view_incidents_recieved_by_data_from_gir_vu.incidents_recieved_by_data_from_gir_vu_id</code>.
     */
    public final TableField<ViewIncidentsRecievedByDataFromGirVuRecord, Long> INCIDENTS_RECIEVED_BY_DATA_FROM_GIR_VU_ID = createField(DSL.name("incidents_recieved_by_data_from_gir_vu_id"), SQLDataType.BIGINT, this, "");

    /**
     * The column
     * <code>metrics.view_incidents_recieved_by_data_from_gir_vu.count_all</code>.
     */
    public final TableField<ViewIncidentsRecievedByDataFromGirVuRecord, Long> COUNT_ALL = createField(DSL.name("count_all"), SQLDataType.BIGINT, this, "");

    /**
     * The column
     * <code>metrics.view_incidents_recieved_by_data_from_gir_vu.percent_confirmed</code>.
     */
    public final TableField<ViewIncidentsRecievedByDataFromGirVuRecord, BigDecimal> PERCENT_CONFIRMED = createField(DSL.name("percent_confirmed"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>metrics.view_incidents_recieved_by_data_from_gir_vu.percent_not_confirmed</code>.
     */
    public final TableField<ViewIncidentsRecievedByDataFromGirVuRecord, BigDecimal> PERCENT_NOT_CONFIRMED = createField(DSL.name("percent_not_confirmed"), SQLDataType.NUMERIC, this, "");

    private ViewIncidentsRecievedByDataFromGirVu(Name alias, Table<ViewIncidentsRecievedByDataFromGirVuRecord> aliased) {
        this(alias, aliased, (Field<?>[]) null, null);
    }

    private ViewIncidentsRecievedByDataFromGirVu(Name alias, Table<ViewIncidentsRecievedByDataFromGirVuRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.view("""
        create view "view_incidents_recieved_by_data_from_gir_vu" as  SELECT incidents_recieved_by_data_from_gir_vu.incidents_recieved_by_data_from_gir_vu_id,
         (incidents_recieved_by_data_from_gir_vu.count_confirmed + incidents_recieved_by_data_from_gir_vu.count_not_confirmed) AS count_all,
         COALESCE(round((((incidents_recieved_by_data_from_gir_vu.count_confirmed)::numeric * (100)::numeric) / NULLIF(((incidents_recieved_by_data_from_gir_vu.count_confirmed + incidents_recieved_by_data_from_gir_vu.count_not_confirmed))::numeric, (0)::numeric))), (0)::numeric) AS percent_confirmed,
         COALESCE(round((((incidents_recieved_by_data_from_gir_vu.count_not_confirmed)::numeric * (100)::numeric) / NULLIF(((incidents_recieved_by_data_from_gir_vu.count_confirmed + incidents_recieved_by_data_from_gir_vu.count_not_confirmed))::numeric, (0)::numeric))), (0)::numeric) AS percent_not_confirmed
        FROM metrics.incidents_recieved_by_data_from_gir_vu;
        """), where);
    }

    /**
     * Create an aliased
     * <code>metrics.view_incidents_recieved_by_data_from_gir_vu</code> table
     * reference
     */
    public ViewIncidentsRecievedByDataFromGirVu(String alias) {
        this(DSL.name(alias), VIEW_INCIDENTS_RECIEVED_BY_DATA_FROM_GIR_VU);
    }

    /**
     * Create an aliased
     * <code>metrics.view_incidents_recieved_by_data_from_gir_vu</code> table
     * reference
     */
    public ViewIncidentsRecievedByDataFromGirVu(Name alias) {
        this(alias, VIEW_INCIDENTS_RECIEVED_BY_DATA_FROM_GIR_VU);
    }

    /**
     * Create a <code>metrics.view_incidents_recieved_by_data_from_gir_vu</code>
     * table reference
     */
    public ViewIncidentsRecievedByDataFromGirVu() {
        this(DSL.name("view_incidents_recieved_by_data_from_gir_vu"), null);
    }

    @Override
    public Schema getSchema() {
        return aliased() ? null : Metrics.METRICS;
    }

    @Override
    public ViewIncidentsRecievedByDataFromGirVu as(String alias) {
        return new ViewIncidentsRecievedByDataFromGirVu(DSL.name(alias), this);
    }

    @Override
    public ViewIncidentsRecievedByDataFromGirVu as(Name alias) {
        return new ViewIncidentsRecievedByDataFromGirVu(alias, this);
    }

    @Override
    public ViewIncidentsRecievedByDataFromGirVu as(Table<?> alias) {
        return new ViewIncidentsRecievedByDataFromGirVu(alias.getQualifiedName(), this);
    }

    /**
     * Rename this table
     */
    @Override
    public ViewIncidentsRecievedByDataFromGirVu rename(String name) {
        return new ViewIncidentsRecievedByDataFromGirVu(DSL.name(name), null);
    }

    /**
     * Rename this table
     */
    @Override
    public ViewIncidentsRecievedByDataFromGirVu rename(Name name) {
        return new ViewIncidentsRecievedByDataFromGirVu(name, null);
    }

    /**
     * Rename this table
     */
    @Override
    public ViewIncidentsRecievedByDataFromGirVu rename(Table<?> name) {
        return new ViewIncidentsRecievedByDataFromGirVu(name.getQualifiedName(), null);
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public ViewIncidentsRecievedByDataFromGirVu where(Condition condition) {
        return new ViewIncidentsRecievedByDataFromGirVu(getQualifiedName(), aliased() ? this : null, null, condition);
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public ViewIncidentsRecievedByDataFromGirVu where(Collection<? extends Condition> conditions) {
        return where(DSL.and(conditions));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public ViewIncidentsRecievedByDataFromGirVu where(Condition... conditions) {
        return where(DSL.and(conditions));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public ViewIncidentsRecievedByDataFromGirVu where(Field<Boolean> condition) {
        return where(DSL.condition(condition));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    @PlainSQL
    public ViewIncidentsRecievedByDataFromGirVu where(SQL condition) {
        return where(DSL.condition(condition));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    @PlainSQL
    public ViewIncidentsRecievedByDataFromGirVu where(@Stringly.SQL String condition) {
        return where(DSL.condition(condition));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    @PlainSQL
    public ViewIncidentsRecievedByDataFromGirVu where(@Stringly.SQL String condition, Object... binds) {
        return where(DSL.condition(condition, binds));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    @PlainSQL
    public ViewIncidentsRecievedByDataFromGirVu where(@Stringly.SQL String condition, QueryPart... parts) {
        return where(DSL.condition(condition, parts));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public ViewIncidentsRecievedByDataFromGirVu whereExists(Select<?> select) {
        return where(DSL.exists(select));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public ViewIncidentsRecievedByDataFromGirVu whereNotExists(Select<?> select) {
        return where(DSL.notExists(select));
    }
}
