/*
 * 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.ViewIncidentsChangeDataFromGirVuRecord;


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

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of
     * <code>metrics.view_incidents_change_data_from_gir_vu</code>
     */
    public static final ViewIncidentsChangeDataFromGirVu VIEW_INCIDENTS_CHANGE_DATA_FROM_GIR_VU = new ViewIncidentsChangeDataFromGirVu();

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

    /**
     * The column
     * <code>metrics.view_incidents_change_data_from_gir_vu.incidents_change_data_from_gir_vu_id</code>.
     */
    public final TableField<ViewIncidentsChangeDataFromGirVuRecord, Long> INCIDENTS_CHANGE_DATA_FROM_GIR_VU_ID = createField(DSL.name("incidents_change_data_from_gir_vu_id"), SQLDataType.BIGINT, this, "");

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

    /**
     * The column
     * <code>metrics.view_incidents_change_data_from_gir_vu.percent_epgu_citizen_appeal</code>.
     */
    public final TableField<ViewIncidentsChangeDataFromGirVuRecord, BigDecimal> PERCENT_EPGU_CITIZEN_APPEAL = createField(DSL.name("percent_epgu_citizen_appeal"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>metrics.view_incidents_change_data_from_gir_vu.percent_manual</code>.
     */
    public final TableField<ViewIncidentsChangeDataFromGirVuRecord, BigDecimal> PERCENT_MANUAL = createField(DSL.name("percent_manual"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>metrics.view_incidents_change_data_from_gir_vu.percent_send_to_gir_vu</code>.
     */
    public final TableField<ViewIncidentsChangeDataFromGirVuRecord, BigDecimal> PERCENT_SEND_TO_GIR_VU = createField(DSL.name("percent_send_to_gir_vu"), SQLDataType.NUMERIC, this, "");

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

    private ViewIncidentsChangeDataFromGirVu(Name alias, Table<ViewIncidentsChangeDataFromGirVuRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.view("""
        create view "view_incidents_change_data_from_gir_vu" as  SELECT incidents_change_data_from_gir_vu.incidents_change_data_from_gir_vu_id,
         ((incidents_change_data_from_gir_vu.count_epgu_citizen_appeal + incidents_change_data_from_gir_vu.count_manual) + incidents_change_data_from_gir_vu.count_send_to_gir_vu) AS count_all,
         COALESCE(round((((incidents_change_data_from_gir_vu.count_epgu_citizen_appeal)::numeric * (100)::numeric) / NULLIF((((incidents_change_data_from_gir_vu.count_epgu_citizen_appeal + incidents_change_data_from_gir_vu.count_manual) + incidents_change_data_from_gir_vu.count_send_to_gir_vu))::numeric, (0)::numeric))), (0)::numeric) AS percent_epgu_citizen_appeal,
         COALESCE(round((((incidents_change_data_from_gir_vu.count_manual)::numeric * (100)::numeric) / NULLIF((((incidents_change_data_from_gir_vu.count_epgu_citizen_appeal + incidents_change_data_from_gir_vu.count_manual) + incidents_change_data_from_gir_vu.count_send_to_gir_vu))::numeric, (0)::numeric))), (0)::numeric) AS percent_manual,
         COALESCE(round((((incidents_change_data_from_gir_vu.count_send_to_gir_vu)::numeric * (100)::numeric) / NULLIF((((incidents_change_data_from_gir_vu.count_epgu_citizen_appeal + incidents_change_data_from_gir_vu.count_manual) + incidents_change_data_from_gir_vu.count_send_to_gir_vu))::numeric, (0)::numeric))), (0)::numeric) AS percent_send_to_gir_vu
        FROM metrics.incidents_change_data_from_gir_vu;
        """), where);
    }

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

    /**
     * Create an aliased
     * <code>metrics.view_incidents_change_data_from_gir_vu</code> table
     * reference
     */
    public ViewIncidentsChangeDataFromGirVu(Name alias) {
        this(alias, VIEW_INCIDENTS_CHANGE_DATA_FROM_GIR_VU);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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