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


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

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of <code>journal_log.view_sign_journal</code>
     */
    public static final ViewSignJournal VIEW_SIGN_JOURNAL = new ViewSignJournal();

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

    /**
     * The column <code>journal_log.view_sign_journal.sign_journal_id</code>.
     */
    public final TableField<ViewSignJournalRecord, Long> SIGN_JOURNAL_ID = createField(DSL.name("sign_journal_id"), SQLDataType.BIGINT, this, "");

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

    /**
     * The column <code>journal_log.view_sign_journal.percent_sign</code>.
     */
    public final TableField<ViewSignJournalRecord, BigDecimal> PERCENT_SIGN = createField(DSL.name("percent_sign"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>journal_log.view_sign_journal.percent_cancel_sign</code>.
     */
    public final TableField<ViewSignJournalRecord, BigDecimal> PERCENT_CANCEL_SIGN = createField(DSL.name("percent_cancel_sign"), SQLDataType.NUMERIC, this, "");

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

    private ViewSignJournal(Name alias, Table<ViewSignJournalRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.view("""
        create view "view_sign_journal" as  SELECT sign_journal.sign_journal_id,
         (sign_journal.count_sign + sign_journal.count_cancel_sign) AS count_all,
         round((((sign_journal.count_sign)::numeric * (100)::numeric) / ((sign_journal.count_sign + sign_journal.count_cancel_sign))::numeric)) AS percent_sign,
         round((((sign_journal.count_cancel_sign)::numeric * (100)::numeric) / ((sign_journal.count_sign + sign_journal.count_cancel_sign))::numeric)) AS percent_cancel_sign
        FROM journal_log.sign_journal;
        """), where);
    }

    /**
     * Create an aliased <code>journal_log.view_sign_journal</code> table
     * reference
     */
    public ViewSignJournal(String alias) {
        this(DSL.name(alias), VIEW_SIGN_JOURNAL);
    }

    /**
     * Create an aliased <code>journal_log.view_sign_journal</code> table
     * reference
     */
    public ViewSignJournal(Name alias) {
        this(alias, VIEW_SIGN_JOURNAL);
    }

    /**
     * Create a <code>journal_log.view_sign_journal</code> table reference
     */
    public ViewSignJournal() {
        this(DSL.name("view_sign_journal"), null);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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