/*
 * This file is generated by jOOQ.
 */
package ru.micord.webbpm.ervu.business_metrics.db_beans.init_registration_info.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.init_registration_info.InitRegistrationInfo;
import ru.micord.webbpm.ervu.business_metrics.db_beans.init_registration_info.tables.records.ViewIncidentsInfoRecord;


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

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of
     * <code>init_registration_info.view_incidents_info</code>
     */
    public static final ViewIncidentsInfo VIEW_INCIDENTS_INFO = new ViewIncidentsInfo();

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

    /**
     * The column
     * <code>init_registration_info.view_incidents_info.incidents_info_id</code>.
     */
    public final TableField<ViewIncidentsInfoRecord, Long> INCIDENTS_INFO_ID = createField(DSL.name("incidents_info_id"), SQLDataType.BIGINT, this, "");

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

    /**
     * The column
     * <code>init_registration_info.view_incidents_info.percent_without_id_ern</code>.
     */
    public final TableField<ViewIncidentsInfoRecord, BigDecimal> PERCENT_WITHOUT_ID_ERN = createField(DSL.name("percent_without_id_ern"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>init_registration_info.view_incidents_info.percent_discrepancy_epgu_info</code>.
     */
    public final TableField<ViewIncidentsInfoRecord, BigDecimal> PERCENT_DISCREPANCY_EPGU_INFO = createField(DSL.name("percent_discrepancy_epgu_info"), SQLDataType.NUMERIC, this, "");

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

    private ViewIncidentsInfo(Name alias, Table<ViewIncidentsInfoRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.view("""
        create view "view_incidents_info" as  SELECT incidents_info.incidents_info_id,
         (incidents_info.count_without_id_ern + incidents_info.count_discrepancy_epgu_info) AS count_all,
         COALESCE(round((((incidents_info.count_without_id_ern)::numeric * (100)::numeric) / NULLIF(((incidents_info.count_without_id_ern + incidents_info.count_discrepancy_epgu_info))::numeric, (0)::numeric))), (0)::numeric) AS percent_without_id_ern,
         COALESCE(round((((incidents_info.count_discrepancy_epgu_info)::numeric * (100)::numeric) / NULLIF(((incidents_info.count_without_id_ern + incidents_info.count_discrepancy_epgu_info))::numeric, (0)::numeric))), (0)::numeric) AS percent_discrepancy_epgu_info
        FROM init_registration_info.incidents_info;
        """), where);
    }

    /**
     * Create an aliased <code>init_registration_info.view_incidents_info</code>
     * table reference
     */
    public ViewIncidentsInfo(String alias) {
        this(DSL.name(alias), VIEW_INCIDENTS_INFO);
    }

    /**
     * Create an aliased <code>init_registration_info.view_incidents_info</code>
     * table reference
     */
    public ViewIncidentsInfo(Name alias) {
        this(alias, VIEW_INCIDENTS_INFO);
    }

    /**
     * Create a <code>init_registration_info.view_incidents_info</code> table
     * reference
     */
    public ViewIncidentsInfo() {
        this(DSL.name("view_incidents_info"), null);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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