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


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

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of
     * <code>init_registration_info.view_init_registration_from_gir_vu</code>
     */
    public static final ViewInitRegistrationFromGirVu VIEW_INIT_REGISTRATION_FROM_GIR_VU = new ViewInitRegistrationFromGirVu();

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

    /**
     * The column
     * <code>init_registration_info.view_init_registration_from_gir_vu.init_registration_from_gir_vu_id</code>.
     */
    public final TableField<ViewInitRegistrationFromGirVuRecord, Long> INIT_REGISTRATION_FROM_GIR_VU_ID = createField(DSL.name("init_registration_from_gir_vu_id"), SQLDataType.BIGINT, this, "");

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

    /**
     * The column
     * <code>init_registration_info.view_init_registration_from_gir_vu.percent_womens</code>.
     */
    public final TableField<ViewInitRegistrationFromGirVuRecord, BigDecimal> PERCENT_WOMENS = createField(DSL.name("percent_womens"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>init_registration_info.view_init_registration_from_gir_vu.percent_received_citizenship</code>.
     */
    public final TableField<ViewInitRegistrationFromGirVuRecord, BigDecimal> PERCENT_RECEIVED_CITIZENSHIP = createField(DSL.name("percent_received_citizenship"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>init_registration_info.view_init_registration_from_gir_vu.percent_serving_sentence</code>.
     */
    public final TableField<ViewInitRegistrationFromGirVuRecord, BigDecimal> PERCENT_SERVING_SENTENCE = createField(DSL.name("percent_serving_sentence"), SQLDataType.NUMERIC, this, "");

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

    private ViewInitRegistrationFromGirVu(Name alias, Table<ViewInitRegistrationFromGirVuRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.view("""
        create view "view_init_registration_from_gir_vu" as  SELECT init_registration_from_gir_vu.init_registration_from_gir_vu_id,
         ((init_registration_from_gir_vu.count_womens + init_registration_from_gir_vu.count_received_citizenship) + init_registration_from_gir_vu.count_serving_sentence) AS count_all,
         COALESCE(round((((init_registration_from_gir_vu.count_womens)::numeric * (100)::numeric) / NULLIF((((init_registration_from_gir_vu.count_womens + init_registration_from_gir_vu.count_received_citizenship) + init_registration_from_gir_vu.count_serving_sentence))::numeric, (0)::numeric))), (0)::numeric) AS percent_womens,
         COALESCE(round((((init_registration_from_gir_vu.count_received_citizenship)::numeric * (100)::numeric) / NULLIF((((init_registration_from_gir_vu.count_womens + init_registration_from_gir_vu.count_received_citizenship) + init_registration_from_gir_vu.count_serving_sentence))::numeric, (0)::numeric))), (0)::numeric) AS percent_received_citizenship,
         COALESCE(round((((init_registration_from_gir_vu.count_serving_sentence)::numeric * (100)::numeric) / NULLIF((((init_registration_from_gir_vu.count_womens + init_registration_from_gir_vu.count_received_citizenship) + init_registration_from_gir_vu.count_serving_sentence))::numeric, (0)::numeric))), (0)::numeric) AS percent_serving_sentence
        FROM init_registration_info.init_registration_from_gir_vu;
        """), where);
    }

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

    /**
     * Create an aliased
     * <code>init_registration_info.view_init_registration_from_gir_vu</code>
     * table reference
     */
    public ViewInitRegistrationFromGirVu(Name alias) {
        this(alias, VIEW_INIT_REGISTRATION_FROM_GIR_VU);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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