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


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

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of <code>deregistration.view_solutions</code>
     */
    public static final ViewSolutions VIEW_SOLUTIONS = new ViewSolutions();

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

    /**
     * The column <code>deregistration.view_solutions.solutions_id</code>.
     */
    public final TableField<ViewSolutionsRecord, Long> SOLUTIONS_ID = createField(DSL.name("solutions_id"), SQLDataType.BIGINT, this, "");

    /**
     * The column <code>deregistration.view_solutions.count_accepted_all</code>.
     */
    public final TableField<ViewSolutionsRecord, Long> COUNT_ACCEPTED_ALL = createField(DSL.name("count_accepted_all"), SQLDataType.BIGINT, this, "");

    /**
     * The column
     * <code>deregistration.view_solutions.percent_accepted_for_sign</code>.
     */
    public final TableField<ViewSolutionsRecord, BigDecimal> PERCENT_ACCEPTED_FOR_SIGN = createField(DSL.name("percent_accepted_for_sign"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>deregistration.view_solutions.percent_accepted_signed</code>.
     */
    public final TableField<ViewSolutionsRecord, BigDecimal> PERCENT_ACCEPTED_SIGNED = createField(DSL.name("percent_accepted_signed"), SQLDataType.NUMERIC, this, "");

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

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

    private ViewSolutions(Name alias, Table<ViewSolutionsRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.view("""
        create view "view_solutions" as  SELECT solutions.solutions_id,
         ((solutions.count_accepted_signed + solutions.count_accepted_for_sign) + solutions.count_refused) AS count_accepted_all,
         COALESCE(round((((solutions.count_accepted_signed)::numeric * (100)::numeric) / NULLIF((((solutions.count_accepted_signed + solutions.count_accepted_for_sign) + solutions.count_refused))::numeric, (0)::numeric))), (0)::numeric) AS percent_accepted_for_sign,
         COALESCE(round((((solutions.count_accepted_for_sign)::numeric * (100)::numeric) / NULLIF((((solutions.count_accepted_signed + solutions.count_accepted_for_sign) + solutions.count_refused))::numeric, (0)::numeric))), (0)::numeric) AS percent_accepted_signed,
         COALESCE(round((((solutions.count_refused)::numeric * (100)::numeric) / NULLIF((((solutions.count_accepted_signed + solutions.count_accepted_for_sign) + solutions.count_refused))::numeric, (0)::numeric))), (0)::numeric) AS percent_refused
        FROM deregistration.solutions;
        """), where);
    }

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

    /**
     * Create an aliased <code>deregistration.view_solutions</code> table
     * reference
     */
    public ViewSolutions(Name alias) {
        this(alias, VIEW_SOLUTIONS);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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