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


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

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of
     * <code>metrics.view_convert_info_loaded_records</code>
     */
    public static final ViewConvertInfoLoadedRecords VIEW_CONVERT_INFO_LOADED_RECORDS = new ViewConvertInfoLoadedRecords();

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

    /**
     * The column
     * <code>metrics.view_convert_info_loaded_records.convert_info_loaded_records_id</code>.
     */
    public final TableField<ViewConvertInfoLoadedRecordsRecord, Long> CONVERT_INFO_LOADED_RECORDS_ID = createField(DSL.name("convert_info_loaded_records_id"), SQLDataType.BIGINT, this, "");

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

    /**
     * The column
     * <code>metrics.view_convert_info_loaded_records.percent_error</code>.
     */
    public final TableField<ViewConvertInfoLoadedRecordsRecord, BigDecimal> PERCENT_ERROR = createField(DSL.name("percent_error"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>metrics.view_convert_info_loaded_records.percent_success</code>.
     */
    public final TableField<ViewConvertInfoLoadedRecordsRecord, BigDecimal> PERCENT_SUCCESS = createField(DSL.name("percent_success"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>metrics.view_convert_info_loaded_records.percent_not_success</code>.
     */
    public final TableField<ViewConvertInfoLoadedRecordsRecord, BigDecimal> PERCENT_NOT_SUCCESS = createField(DSL.name("percent_not_success"), SQLDataType.NUMERIC, this, "");

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

    private ViewConvertInfoLoadedRecords(Name alias, Table<ViewConvertInfoLoadedRecordsRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.view("""
        create view "view_convert_info_loaded_records" as  SELECT convert_info_loaded_records.convert_info_loaded_records_id,
         ((convert_info_loaded_records.count_success + convert_info_loaded_records.count_error) + convert_info_loaded_records.count_not_success) AS count_all,
         COALESCE(round((((convert_info_loaded_records.count_error)::numeric * (100)::numeric) / NULLIF((((convert_info_loaded_records.count_success + convert_info_loaded_records.count_error) + convert_info_loaded_records.count_not_success))::numeric, (0)::numeric))), (0)::numeric) AS percent_error,
         COALESCE(round((((convert_info_loaded_records.count_success)::numeric * (100)::numeric) / NULLIF((((convert_info_loaded_records.count_success + convert_info_loaded_records.count_error) + convert_info_loaded_records.count_not_success))::numeric, (0)::numeric))), (0)::numeric) AS percent_success,
         COALESCE(round((((convert_info_loaded_records.count_not_success)::numeric * (100)::numeric) / NULLIF((((convert_info_loaded_records.count_success + convert_info_loaded_records.count_error) + convert_info_loaded_records.count_not_success))::numeric, (0)::numeric))), (0)::numeric) AS percent_not_success
        FROM metrics.convert_info_loaded_records;
        """), where);
    }

    /**
     * Create an aliased <code>metrics.view_convert_info_loaded_records</code>
     * table reference
     */
    public ViewConvertInfoLoadedRecords(String alias) {
        this(DSL.name(alias), VIEW_CONVERT_INFO_LOADED_RECORDS);
    }

    /**
     * Create an aliased <code>metrics.view_convert_info_loaded_records</code>
     * table reference
     */
    public ViewConvertInfoLoadedRecords(Name alias) {
        this(alias, VIEW_CONVERT_INFO_LOADED_RECORDS);
    }

    /**
     * Create a <code>metrics.view_convert_info_loaded_records</code> table
     * reference
     */
    public ViewConvertInfoLoadedRecords() {
        this(DSL.name("view_convert_info_loaded_records"), null);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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