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


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

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of
     * <code>metrics.view_incidents_files_requests</code>
     */
    public static final ViewIncidentsFilesRequests VIEW_INCIDENTS_FILES_REQUESTS = new ViewIncidentsFilesRequests();

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

    /**
     * The column
     * <code>metrics.view_incidents_files_requests.incidents_files_requests_id</code>.
     */
    public final TableField<ViewIncidentsFilesRequestsRecord, Long> INCIDENTS_FILES_REQUESTS_ID = createField(DSL.name("incidents_files_requests_id"), SQLDataType.BIGINT, this, "");

    /**
     * The column
     * <code>metrics.view_incidents_files_requests.percent_requisites_entered</code>.
     */
    public final TableField<ViewIncidentsFilesRequestsRecord, BigDecimal> PERCENT_REQUISITES_ENTERED = createField(DSL.name("percent_requisites_entered"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>metrics.view_incidents_files_requests.percent_results_entered</code>.
     */
    public final TableField<ViewIncidentsFilesRequestsRecord, BigDecimal> PERCENT_RESULTS_ENTERED = createField(DSL.name("percent_results_entered"), SQLDataType.NUMERIC, this, "");

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

    private ViewIncidentsFilesRequests(Name alias, Table<ViewIncidentsFilesRequestsRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.view("""
        create view "view_incidents_files_requests" as  SELECT incidents_files_requests.incidents_files_requests_id,
         COALESCE(round((((incidents_files_requests.count_requisites_entered)::numeric * (100)::numeric) / NULLIF((incidents_files_requests.count_requisites_entered)::numeric, (0)::numeric))), (0)::numeric) AS percent_requisites_entered,
         COALESCE(round((((incidents_files_requests.count_results_entered)::numeric * (100)::numeric) / NULLIF((incidents_files_requests.count_requisites_entered)::numeric, (0)::numeric))), (0)::numeric) AS percent_results_entered
        FROM metrics.incidents_files_requests;
        """), where);
    }

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

    /**
     * Create an aliased <code>metrics.view_incidents_files_requests</code>
     * table reference
     */
    public ViewIncidentsFilesRequests(Name alias) {
        this(alias, VIEW_INCIDENTS_FILES_REQUESTS);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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