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


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

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of <code>journal_log.view_processed_records</code>
     */
    public static final ViewProcessedRecords VIEW_PROCESSED_RECORDS = new ViewProcessedRecords();

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

    /**
     * The column
     * <code>journal_log.view_processed_records.processed_records_id</code>.
     */
    public final TableField<ViewProcessedRecordsRecord, Long> PROCESSED_RECORDS_ID = createField(DSL.name("processed_records_id"), SQLDataType.BIGINT, this, "");

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

    /**
     * The column
     * <code>journal_log.view_processed_records.percent_flk_error</code>.
     */
    public final TableField<ViewProcessedRecordsRecord, BigDecimal> PERCENT_FLK_ERROR = createField(DSL.name("percent_flk_error"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>journal_log.view_processed_records.percent_time_error</code>.
     */
    public final TableField<ViewProcessedRecordsRecord, BigDecimal> PERCENT_TIME_ERROR = createField(DSL.name("percent_time_error"), SQLDataType.NUMERIC, this, "");

    /**
     * The column <code>journal_log.view_processed_records.percent_new</code>.
     */
    public final TableField<ViewProcessedRecordsRecord, BigDecimal> PERCENT_NEW = createField(DSL.name("percent_new"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>journal_log.view_processed_records.percent_actual</code>.
     */
    public final TableField<ViewProcessedRecordsRecord, BigDecimal> PERCENT_ACTUAL = createField(DSL.name("percent_actual"), SQLDataType.NUMERIC, this, "");

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

    private ViewProcessedRecords(Name alias, Table<ViewProcessedRecordsRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.view("""
        create view "view_processed_records" as  SELECT processed_records.processed_records_id,
         (((processed_records.count_flk_error + processed_records.count_time_error) + processed_records.count_new) + processed_records.count_actual) AS count_all,
         round((((processed_records.count_flk_error)::numeric * (100)::numeric) / ((((processed_records.count_flk_error + processed_records.count_time_error) + processed_records.count_new) + processed_records.count_actual))::numeric)) AS percent_flk_error,
         round((((processed_records.count_time_error)::numeric * (100)::numeric) / ((((processed_records.count_flk_error + processed_records.count_time_error) + processed_records.count_new) + processed_records.count_actual))::numeric)) AS percent_time_error,
         round((((processed_records.count_new)::numeric * (100)::numeric) / ((((processed_records.count_flk_error + processed_records.count_time_error) + processed_records.count_new) + processed_records.count_actual))::numeric)) AS percent_new,
         round((((processed_records.count_actual)::numeric * (100)::numeric) / ((((processed_records.count_flk_error + processed_records.count_time_error) + processed_records.count_new) + processed_records.count_actual))::numeric)) AS percent_actual
        FROM journal_log.processed_records;
        """), where);
    }

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

    /**
     * Create an aliased <code>journal_log.view_processed_records</code> table
     * reference
     */
    public ViewProcessedRecords(Name alias) {
        this(alias, VIEW_PROCESSED_RECORDS);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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