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


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

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of
     * <code>deregistration.view_rejection_decisions</code>
     */
    public static final ViewRejectionDecisions VIEW_REJECTION_DECISIONS = new ViewRejectionDecisions();

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

    /**
     * The column
     * <code>deregistration.view_rejection_decisions.rejection_decisions_id</code>.
     */
    public final TableField<ViewRejectionDecisionsRecord, Long> REJECTION_DECISIONS_ID = createField(DSL.name("rejection_decisions_id"), SQLDataType.BIGINT, this, "");

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

    /**
     * The column
     * <code>deregistration.view_rejection_decisions.percent_for_sign</code>.
     */
    public final TableField<ViewRejectionDecisionsRecord, BigDecimal> PERCENT_FOR_SIGN = createField(DSL.name("percent_for_sign"), SQLDataType.NUMERIC, this, "");

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

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

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

    private ViewRejectionDecisions(Name alias, Table<ViewRejectionDecisionsRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.view("""
        create view "view_rejection_decisions" as  SELECT rejection_decisions.rejection_decisions_id,
         ((rejection_decisions.count_for_sign + rejection_decisions.count_signed) + rejection_decisions.count_refused) AS count_all,
         COALESCE(round((((rejection_decisions.count_for_sign)::numeric * (100)::numeric) / NULLIF((((rejection_decisions.count_for_sign + rejection_decisions.count_signed) + rejection_decisions.count_refused))::numeric, (0)::numeric))), (0)::numeric) AS percent_for_sign,
         COALESCE(round((((rejection_decisions.count_signed)::numeric * (100)::numeric) / NULLIF((((rejection_decisions.count_for_sign + rejection_decisions.count_signed) + rejection_decisions.count_refused))::numeric, (0)::numeric))), (0)::numeric) AS percent_signed,
         COALESCE(round((((rejection_decisions.count_refused)::numeric * (100)::numeric) / NULLIF((((rejection_decisions.count_for_sign + rejection_decisions.count_signed) + rejection_decisions.count_refused))::numeric, (0)::numeric))), (0)::numeric) AS percent_refused
        FROM deregistration.rejection_decisions;
        """), where);
    }

    /**
     * Create an aliased <code>deregistration.view_rejection_decisions</code>
     * table reference
     */
    public ViewRejectionDecisions(String alias) {
        this(DSL.name(alias), VIEW_REJECTION_DECISIONS);
    }

    /**
     * Create an aliased <code>deregistration.view_rejection_decisions</code>
     * table reference
     */
    public ViewRejectionDecisions(Name alias) {
        this(alias, VIEW_REJECTION_DECISIONS);
    }

    /**
     * Create a <code>deregistration.view_rejection_decisions</code> table
     * reference
     */
    public ViewRejectionDecisions() {
        this(DSL.name("view_rejection_decisions"), null);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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