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


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

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of <code>summonses_list.view_all_summonses</code>
     */
    public static final ViewAllSummonses VIEW_ALL_SUMMONSES = new ViewAllSummonses();

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

    /**
     * The column
     * <code>summonses_list.view_all_summonses.all_summonses_id</code>.
     */
    public final TableField<ViewAllSummonsesRecord, Long> ALL_SUMMONSES_ID = createField(DSL.name("all_summonses_id"), SQLDataType.BIGINT, this, "");

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

    /**
     * The column
     * <code>summonses_list.view_all_summonses.percent_init_registration</code>.
     */
    public final TableField<ViewAllSummonsesRecord, BigDecimal> PERCENT_INIT_REGISTRATION = createField(DSL.name("percent_init_registration"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>summonses_list.view_all_summonses.percent_draft_company</code>.
     */
    public final TableField<ViewAllSummonsesRecord, BigDecimal> PERCENT_DRAFT_COMPANY = createField(DSL.name("percent_draft_company"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>summonses_list.view_all_summonses.percent_management_military_registration</code>.
     */
    public final TableField<ViewAllSummonsesRecord, BigDecimal> PERCENT_MANAGEMENT_MILITARY_REGISTRATION = createField(DSL.name("percent_management_military_registration"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>summonses_list.view_all_summonses.percent_mobilization</code>.
     */
    public final TableField<ViewAllSummonsesRecord, BigDecimal> PERCENT_MOBILIZATION = createField(DSL.name("percent_mobilization"), SQLDataType.NUMERIC, this, "");

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

    private ViewAllSummonses(Name alias, Table<ViewAllSummonsesRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.view("""
        create view "view_all_summonses" as  SELECT all_summonses.all_summonses_id,
         (((all_summonses.count_init_registration + all_summonses.count_draft_company) + all_summonses.count_management_military_registration) + all_summonses.count_mobilization) AS count_all,
         COALESCE(round((((all_summonses.count_init_registration)::numeric * (100)::numeric) / NULLIF(((((all_summonses.count_init_registration + all_summonses.count_draft_company) + all_summonses.count_management_military_registration) + all_summonses.count_mobilization))::numeric, (0)::numeric))), (0)::numeric) AS percent_init_registration,
         COALESCE(round((((all_summonses.count_draft_company)::numeric * (100)::numeric) / NULLIF(((((all_summonses.count_init_registration + all_summonses.count_draft_company) + all_summonses.count_management_military_registration) + all_summonses.count_mobilization))::numeric, (0)::numeric))), (0)::numeric) AS percent_draft_company,
         COALESCE(round((((all_summonses.count_management_military_registration)::numeric * (100)::numeric) / NULLIF(((((all_summonses.count_init_registration + all_summonses.count_draft_company) + all_summonses.count_management_military_registration) + all_summonses.count_mobilization))::numeric, (0)::numeric))), (0)::numeric) AS percent_management_military_registration,
         COALESCE(round((((all_summonses.count_mobilization)::numeric * (100)::numeric) / NULLIF(((((all_summonses.count_init_registration + all_summonses.count_draft_company) + all_summonses.count_management_military_registration) + all_summonses.count_mobilization))::numeric, (0)::numeric))), (0)::numeric) AS percent_mobilization
        FROM summonses_list.all_summonses;
        """), where);
    }

    /**
     * Create an aliased <code>summonses_list.view_all_summonses</code> table
     * reference
     */
    public ViewAllSummonses(String alias) {
        this(DSL.name(alias), VIEW_ALL_SUMMONSES);
    }

    /**
     * Create an aliased <code>summonses_list.view_all_summonses</code> table
     * reference
     */
    public ViewAllSummonses(Name alias) {
        this(alias, VIEW_ALL_SUMMONSES);
    }

    /**
     * Create a <code>summonses_list.view_all_summonses</code> table reference
     */
    public ViewAllSummonses() {
        this(DSL.name("view_all_summonses"), null);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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