/*
 * This file is generated by jOOQ.
 */
package ru.micord.webbpm.ervu.business_metrics.db_beans.metrics.tables;


import java.sql.Date;
import java.sql.Timestamp;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;

import org.jooq.Condition;
import org.jooq.Field;
import org.jooq.ForeignKey;
import org.jooq.Identity;
import org.jooq.InverseForeignKey;
import org.jooq.Name;
import org.jooq.Path;
import org.jooq.PlainSQL;
import org.jooq.QueryPart;
import org.jooq.Record;
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.UniqueKey;
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.Keys;
import ru.micord.webbpm.ervu.business_metrics.db_beans.metrics.Metrics;
import ru.micord.webbpm.ervu.business_metrics.db_beans.metrics.tables.Recruitment.RecruitmentPath;
import ru.micord.webbpm.ervu.business_metrics.db_beans.metrics.tables.records.CitizenAppealsRecord;


/**
 * Обжалования. Обжалования граждан
 */
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class CitizenAppeals extends TableImpl<CitizenAppealsRecord> {

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of <code>metrics.citizen_appeals</code>
     */
    public static final CitizenAppeals CITIZEN_APPEALS = new CitizenAppeals();

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

    /**
     * The column <code>metrics.citizen_appeals.citizen_appeals_id</code>.
     */
    public final TableField<CitizenAppealsRecord, Long> CITIZEN_APPEALS_ID = createField(DSL.name("citizen_appeals_id"), SQLDataType.BIGINT.nullable(false).identity(true), this, "");

    /**
     * The column <code>metrics.citizen_appeals.recruitment_id</code>.
     */
    public final TableField<CitizenAppealsRecord, String> RECRUITMENT_ID = createField(DSL.name("recruitment_id"), SQLDataType.VARCHAR(36).nullable(false), this, "");

    /**
     * The column <code>metrics.citizen_appeals.update_date</code>.
     */
    public final TableField<CitizenAppealsRecord, Timestamp> UPDATE_DATE = createField(DSL.name("update_date"), SQLDataType.TIMESTAMP(0).nullable(false).defaultValue(DSL.field(DSL.raw("now()"), SQLDataType.TIMESTAMP)), this, "");

    /**
     * The column <code>metrics.citizen_appeals.info_date</code>.
     */
    public final TableField<CitizenAppealsRecord, Date> INFO_DATE = createField(DSL.name("info_date"), SQLDataType.DATE.nullable(false), this, "");

    /**
     * The column <code>metrics.citizen_appeals.count_submitted</code>. Подано
     * обращений
     */
    public final TableField<CitizenAppealsRecord, Long> COUNT_SUBMITTED = createField(DSL.name("count_submitted"), SQLDataType.BIGINT.nullable(false).defaultValue(DSL.field(DSL.raw("0"), SQLDataType.BIGINT)), this, "Подано обращений");

    /**
     * The column <code>metrics.citizen_appeals.count_satisfided</code>.
     * Удовлетворенных
     */
    public final TableField<CitizenAppealsRecord, Long> COUNT_SATISFIDED = createField(DSL.name("count_satisfided"), SQLDataType.BIGINT.nullable(false).defaultValue(DSL.field(DSL.raw("0"), SQLDataType.BIGINT)), this, "Удовлетворенных");

    /**
     * The column <code>metrics.citizen_appeals.count_not_satisfided</code>. Не
     * удовлетворенных
     */
    public final TableField<CitizenAppealsRecord, Long> COUNT_NOT_SATISFIDED = createField(DSL.name("count_not_satisfided"), SQLDataType.BIGINT.nullable(false).defaultValue(DSL.field(DSL.raw("0"), SQLDataType.BIGINT)), this, "Не удовлетворенных");

    /**
     * The column <code>metrics.citizen_appeals.count_accepted_expired</code>.
     * Просроченных
     */
    public final TableField<CitizenAppealsRecord, Long> COUNT_ACCEPTED_EXPIRED = createField(DSL.name("count_accepted_expired"), SQLDataType.BIGINT.nullable(false).defaultValue(DSL.field(DSL.raw("0"), SQLDataType.BIGINT)), this, "Просроченных");

    /**
     * The column <code>metrics.citizen_appeals.count_accepted_on_time</code>.
     * Принято в срок
     */
    public final TableField<CitizenAppealsRecord, Long> COUNT_ACCEPTED_ON_TIME = createField(DSL.name("count_accepted_on_time"), SQLDataType.BIGINT.nullable(false).defaultValue(DSL.field(DSL.raw("0"), SQLDataType.BIGINT)), this, "Принято в срок");

    /**
     * The column <code>metrics.citizen_appeals.average_response_time</code>.
     * Средний срок ответа
     */
    public final TableField<CitizenAppealsRecord, Long> AVERAGE_RESPONSE_TIME = createField(DSL.name("average_response_time"), SQLDataType.BIGINT.nullable(false).defaultValue(DSL.field(DSL.raw("0"), SQLDataType.BIGINT)), this, "Средний срок ответа");

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

    private CitizenAppeals(Name alias, Table<CitizenAppealsRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment("Обжалования. Обжалования граждан"), TableOptions.table(), where);
    }

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

    /**
     * Create an aliased <code>metrics.citizen_appeals</code> table reference
     */
    public CitizenAppeals(Name alias) {
        this(alias, CITIZEN_APPEALS);
    }

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

    public <O extends Record> CitizenAppeals(Table<O> path, ForeignKey<O, CitizenAppealsRecord> childPath, InverseForeignKey<O, CitizenAppealsRecord> parentPath) {
        super(path, childPath, parentPath, CITIZEN_APPEALS);
    }

    /**
     * A subtype implementing {@link Path} for simplified path-based joins.
     */
    public static class CitizenAppealsPath extends CitizenAppeals implements Path<CitizenAppealsRecord> {
        public <O extends Record> CitizenAppealsPath(Table<O> path, ForeignKey<O, CitizenAppealsRecord> childPath, InverseForeignKey<O, CitizenAppealsRecord> parentPath) {
            super(path, childPath, parentPath);
        }
        private CitizenAppealsPath(Name alias, Table<CitizenAppealsRecord> aliased) {
            super(alias, aliased);
        }

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

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

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

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

    @Override
    public Identity<CitizenAppealsRecord, Long> getIdentity() {
        return (Identity<CitizenAppealsRecord, Long>) super.getIdentity();
    }

    @Override
    public UniqueKey<CitizenAppealsRecord> getPrimaryKey() {
        return Keys.CITIZEN_APPEALS_PKEY;
    }

    @Override
    public List<ForeignKey<CitizenAppealsRecord, ?>> getReferences() {
        return Arrays.asList(Keys.CITIZEN_APPEALS__FK_CRIMINAL_ADMINISTRATIVE_LIABILITY_RECRUITMENT_ID);
    }

    private transient RecruitmentPath _recruitment;

    /**
     * Get the implicit join path to the <code>metrics.recruitment</code> table.
     */
    public RecruitmentPath recruitment() {
        if (_recruitment == null)
            _recruitment = new RecruitmentPath(this, Keys.CITIZEN_APPEALS__FK_CRIMINAL_ADMINISTRATIVE_LIABILITY_RECRUITMENT_ID, null);

        return _recruitment;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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