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


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

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of
     * <code>init_registration_info.view_decision_formation_status</code>
     */
    public static final ViewDecisionFormationStatus VIEW_DECISION_FORMATION_STATUS = new ViewDecisionFormationStatus();

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

    /**
     * The column
     * <code>init_registration_info.view_decision_formation_status.decision_formation_status_id</code>.
     */
    public final TableField<ViewDecisionFormationStatusRecord, Long> DECISION_FORMATION_STATUS_ID = createField(DSL.name("decision_formation_status_id"), SQLDataType.BIGINT, this, "");

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

    /**
     * The column
     * <code>init_registration_info.view_decision_formation_status.percent_signed</code>.
     */
    public final TableField<ViewDecisionFormationStatusRecord, BigDecimal> PERCENT_SIGNED = createField(DSL.name("percent_signed"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>init_registration_info.view_decision_formation_status.percent_suggested</code>.
     */
    public final TableField<ViewDecisionFormationStatusRecord, BigDecimal> PERCENT_SUGGESTED = createField(DSL.name("percent_suggested"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>init_registration_info.view_decision_formation_status.percent_waiting_sign</code>.
     */
    public final TableField<ViewDecisionFormationStatusRecord, BigDecimal> PERCENT_WAITING_SIGN = createField(DSL.name("percent_waiting_sign"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>init_registration_info.view_decision_formation_status.percent_refused</code>.
     */
    public final TableField<ViewDecisionFormationStatusRecord, BigDecimal> PERCENT_REFUSED = createField(DSL.name("percent_refused"), SQLDataType.NUMERIC, this, "");

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

    private ViewDecisionFormationStatus(Name alias, Table<ViewDecisionFormationStatusRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.view("""
        create view "view_decision_formation_status" as  SELECT decision_formation_status.decision_formation_status_id,
         (((decision_formation_status.count_signed + decision_formation_status.count_suggested) + decision_formation_status.count_waiting_sign) + decision_formation_status.count_refused) AS count_all,
         COALESCE(round((((decision_formation_status.count_signed)::numeric * (100)::numeric) / NULLIF(((((decision_formation_status.count_signed + decision_formation_status.count_suggested) + decision_formation_status.count_waiting_sign) + decision_formation_status.count_refused))::numeric, (0)::numeric))), (0)::numeric) AS percent_signed,
         COALESCE(round((((decision_formation_status.count_suggested)::numeric * (100)::numeric) / NULLIF(((((decision_formation_status.count_signed + decision_formation_status.count_suggested) + decision_formation_status.count_waiting_sign) + decision_formation_status.count_refused))::numeric, (0)::numeric))), (0)::numeric) AS percent_suggested,
         COALESCE(round((((decision_formation_status.count_waiting_sign)::numeric * (100)::numeric) / NULLIF(((((decision_formation_status.count_signed + decision_formation_status.count_suggested) + decision_formation_status.count_waiting_sign) + decision_formation_status.count_refused))::numeric, (0)::numeric))), (0)::numeric) AS percent_waiting_sign,
         COALESCE(round((((decision_formation_status.count_refused)::numeric * (100)::numeric) / NULLIF(((((decision_formation_status.count_signed + decision_formation_status.count_suggested) + decision_formation_status.count_waiting_sign) + decision_formation_status.count_refused))::numeric, (0)::numeric))), (0)::numeric) AS percent_refused
        FROM init_registration_info.decision_formation_status;
        """), where);
    }

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

    /**
     * Create an aliased
     * <code>init_registration_info.view_decision_formation_status</code> table
     * reference
     */
    public ViewDecisionFormationStatus(Name alias) {
        this(alias, VIEW_DECISION_FORMATION_STATUS);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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