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


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

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of <code>journal_log.view_dictionary_update</code>
     */
    public static final ViewDictionaryUpdate VIEW_DICTIONARY_UPDATE = new ViewDictionaryUpdate();

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

    /**
     * The column
     * <code>journal_log.view_dictionary_update.dictionary_update_id</code>.
     */
    public final TableField<ViewDictionaryUpdateRecord, Long> DICTIONARY_UPDATE_ID = createField(DSL.name("dictionary_update_id"), SQLDataType.BIGINT, this, "");

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

    /**
     * The column
     * <code>journal_log.view_dictionary_update.count_without_1</code>.
     */
    public final TableField<ViewDictionaryUpdateRecord, Long> COUNT_WITHOUT_1 = createField(DSL.name("count_without_1"), SQLDataType.BIGINT, this, "");

    /**
     * The column
     * <code>journal_log.view_dictionary_update.count_without_2</code>.
     */
    public final TableField<ViewDictionaryUpdateRecord, Long> COUNT_WITHOUT_2 = createField(DSL.name("count_without_2"), SQLDataType.BIGINT, this, "");

    /**
     * The column
     * <code>journal_log.view_dictionary_update.count_without_3</code>.
     */
    public final TableField<ViewDictionaryUpdateRecord, Long> COUNT_WITHOUT_3 = createField(DSL.name("count_without_3"), SQLDataType.BIGINT, this, "");

    /**
     * The column
     * <code>journal_log.view_dictionary_update.count_without_4</code>.
     */
    public final TableField<ViewDictionaryUpdateRecord, Long> COUNT_WITHOUT_4 = createField(DSL.name("count_without_4"), SQLDataType.BIGINT, this, "");

    /**
     * The column
     * <code>journal_log.view_dictionary_update.percent_dictionary_1</code>.
     */
    public final TableField<ViewDictionaryUpdateRecord, BigDecimal> PERCENT_DICTIONARY_1 = createField(DSL.name("percent_dictionary_1"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>journal_log.view_dictionary_update.percent_dictionary_2</code>.
     */
    public final TableField<ViewDictionaryUpdateRecord, BigDecimal> PERCENT_DICTIONARY_2 = createField(DSL.name("percent_dictionary_2"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>journal_log.view_dictionary_update.percent_dictionary_3</code>.
     */
    public final TableField<ViewDictionaryUpdateRecord, BigDecimal> PERCENT_DICTIONARY_3 = createField(DSL.name("percent_dictionary_3"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>journal_log.view_dictionary_update.percent_dictionary_4</code>.
     */
    public final TableField<ViewDictionaryUpdateRecord, BigDecimal> PERCENT_DICTIONARY_4 = createField(DSL.name("percent_dictionary_4"), SQLDataType.NUMERIC, this, "");

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

    private ViewDictionaryUpdate(Name alias, Table<ViewDictionaryUpdateRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.view("""
        create view "view_dictionary_update" as  SELECT t.dictionary_update_id,
         t.count_all,
         (t.count_all - t.count_dictionary_1) AS count_without_1,
         (t.count_all - t.count_dictionary_2) AS count_without_2,
         (t.count_all - t.count_dictionary_3) AS count_without_3,
         (t.count_all - t.count_dictionary_4) AS count_without_4,
         round((((t.count_dictionary_1)::numeric * (100)::numeric) / (t.count_all)::numeric)) AS percent_dictionary_1,
         round((((t.count_dictionary_2)::numeric * (100)::numeric) / (t.count_all)::numeric)) AS percent_dictionary_2,
         round((((t.count_dictionary_3)::numeric * (100)::numeric) / (t.count_all)::numeric)) AS percent_dictionary_3,
         round((((t.count_dictionary_4)::numeric * (100)::numeric) / (t.count_all)::numeric)) AS percent_dictionary_4
        FROM ( SELECT (((dictionary_update.count_dictionary_1 + dictionary_update.count_dictionary_2) + dictionary_update.count_dictionary_3) + dictionary_update.count_dictionary_4) AS count_all,
                 dictionary_update.dictionary_update_id,
                 dictionary_update.recruitment_id,
                 dictionary_update.update_date,
                 dictionary_update.info_date,
                 dictionary_update.count_dictionary_1,
                 dictionary_update.count_dictionary_2,
                 dictionary_update.count_dictionary_3,
                 dictionary_update.count_dictionary_4,
                 dictionary_update.name_dictionary_1,
                 dictionary_update.name_dictionary_2,
                 dictionary_update.name_dictionary_3,
                 dictionary_update.name_dictionary_4
                FROM journal_log.dictionary_update) t;
        """), where);
    }

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

    /**
     * Create an aliased <code>journal_log.view_dictionary_update</code> table
     * reference
     */
    public ViewDictionaryUpdate(Name alias) {
        this(alias, VIEW_DICTIONARY_UPDATE);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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