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


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.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.Region.RegionPath;
import ru.micord.webbpm.ervu.business_metrics.db_beans.metrics.tables.records.RecruitmentRecord;


/**
 * Военный комиссариат
 */
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class Recruitment extends TableImpl<RecruitmentRecord> {

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of <code>metrics.recruitment</code>
     */
    public static final Recruitment RECRUITMENT = new Recruitment();

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

    /**
     * The column <code>metrics.recruitment.id</code>. Идентификатор ВК
     */
    public final TableField<RecruitmentRecord, String> ID = createField(DSL.name("id"), SQLDataType.VARCHAR(36).nullable(false).defaultValue(DSL.field(DSL.raw("uuid_generate_v4()"), SQLDataType.VARCHAR)), this, "Идентификатор ВК");

    /**
     * The column <code>metrics.recruitment.idm_id</code>. Идентификатор
     * организации
     */
    public final TableField<RecruitmentRecord, String> IDM_ID = createField(DSL.name("idm_id"), SQLDataType.VARCHAR(256), this, "Идентификатор организации");

    /**
     * The column <code>metrics.recruitment.parent_id</code>. Идентификатор
     * вышестоящей организации
     */
    public final TableField<RecruitmentRecord, String> PARENT_ID = createField(DSL.name("parent_id"), SQLDataType.VARCHAR, this, "Идентификатор вышестоящей организации");

    /**
     * The column <code>metrics.recruitment.version</code>. Версия записи
     */
    public final TableField<RecruitmentRecord, Integer> VERSION = createField(DSL.name("version"), SQLDataType.INTEGER, this, "Версия записи");

    /**
     * The column <code>metrics.recruitment.created_at</code>. Дата создания
     */
    public final TableField<RecruitmentRecord, Timestamp> CREATED_AT = createField(DSL.name("created_at"), SQLDataType.TIMESTAMP(0).nullable(false).defaultValue(DSL.field(DSL.raw("now()"), SQLDataType.TIMESTAMP)), this, "Дата создания");

    /**
     * The column <code>metrics.recruitment.updated_at</code>. Дата обновления
     */
    public final TableField<RecruitmentRecord, Timestamp> UPDATED_AT = createField(DSL.name("updated_at"), SQLDataType.TIMESTAMP(0).nullable(false).defaultValue(DSL.field(DSL.raw("now()"), SQLDataType.TIMESTAMP)), this, "Дата обновления");

    /**
     * The column <code>metrics.recruitment.schema</code>. Схема
     */
    public final TableField<RecruitmentRecord, String> SCHEMA = createField(DSL.name("schema"), SQLDataType.VARCHAR(64).nullable(false), this, "Схема");

    /**
     * The column <code>metrics.recruitment.military_code</code>. Код
     * организации
     */
    public final TableField<RecruitmentRecord, String> MILITARY_CODE = createField(DSL.name("military_code"), SQLDataType.VARCHAR(16), this, "Код организации");

    /**
     * The column <code>metrics.recruitment.shortname</code>. Укороченное
     * наименование организации
     */
    public final TableField<RecruitmentRecord, String> SHORTNAME = createField(DSL.name("shortname"), SQLDataType.VARCHAR.nullable(false), this, "Укороченное наименование организации");

    /**
     * The column <code>metrics.recruitment.fullname</code>. Полное наименование
     * организации
     */
    public final TableField<RecruitmentRecord, String> FULLNAME = createField(DSL.name("fullname"), SQLDataType.VARCHAR.nullable(false), this, "Полное наименование организации");

    /**
     * The column <code>metrics.recruitment.dns</code>. ДНС организации
     */
    public final TableField<RecruitmentRecord, String> DNS = createField(DSL.name("dns"), SQLDataType.VARCHAR(64), this, "ДНС организации");

    /**
     * The column <code>metrics.recruitment.email</code>. Е-mail организации
     */
    public final TableField<RecruitmentRecord, String> EMAIL = createField(DSL.name("email"), SQLDataType.VARCHAR(255), this, "Е-mail организации");

    /**
     * The column <code>metrics.recruitment.phone</code>. Телефон организации
     */
    public final TableField<RecruitmentRecord, String> PHONE = createField(DSL.name("phone"), SQLDataType.VARCHAR(24), this, "Телефон организации");

    /**
     * The column <code>metrics.recruitment.address</code>. Адрес организации
     */
    public final TableField<RecruitmentRecord, String> ADDRESS = createField(DSL.name("address"), SQLDataType.VARCHAR, this, "Адрес организации");

    /**
     * The column <code>metrics.recruitment.address_id</code>. Идентификатор
     * адреса организации
     */
    public final TableField<RecruitmentRecord, String> ADDRESS_ID = createField(DSL.name("address_id"), SQLDataType.VARCHAR, this, "Идентификатор адреса организации");

    /**
     * The column <code>metrics.recruitment.postal_address</code>. Почтовый
     * адрес организации
     */
    public final TableField<RecruitmentRecord, String> POSTAL_ADDRESS = createField(DSL.name("postal_address"), SQLDataType.VARCHAR, this, "Почтовый адрес организации");

    /**
     * The column <code>metrics.recruitment.postal_address_id</code>.
     * Идентификатор почтового адреса организации
     */
    public final TableField<RecruitmentRecord, String> POSTAL_ADDRESS_ID = createField(DSL.name("postal_address_id"), SQLDataType.VARCHAR, this, "Идентификатор почтового адреса организации");

    /**
     * The column <code>metrics.recruitment.nsi_department_id</code>.
     * Идентификатор департамента из НСИ
     */
    public final TableField<RecruitmentRecord, String> NSI_DEPARTMENT_ID = createField(DSL.name("nsi_department_id"), SQLDataType.VARCHAR, this, "Идентификатор департамента из НСИ");

    /**
     * The column <code>metrics.recruitment.nsi_organization_id</code>.
     * Идентификатор организации из НСИ
     */
    public final TableField<RecruitmentRecord, String> NSI_ORGANIZATION_ID = createField(DSL.name("nsi_organization_id"), SQLDataType.VARCHAR, this, "Идентификатор организации из НСИ");

    /**
     * The column <code>metrics.recruitment.oktmo</code>. ОКТМО
     */
    public final TableField<RecruitmentRecord, String> OKTMO = createField(DSL.name("oktmo"), SQLDataType.VARCHAR, this, "ОКТМО");

    /**
     * The column <code>metrics.recruitment.org_ogrn</code>. ОГРН организации
     */
    public final TableField<RecruitmentRecord, String> ORG_OGRN = createField(DSL.name("org_ogrn"), SQLDataType.VARCHAR, this, "ОГРН организации");

    /**
     * The column <code>metrics.recruitment.dep_ogrn</code>. ОГРН департамента
     */
    public final TableField<RecruitmentRecord, String> DEP_OGRN = createField(DSL.name("dep_ogrn"), SQLDataType.VARCHAR, this, "ОГРН департамента");

    /**
     * The column <code>metrics.recruitment.epgu_id</code>. Идентификатор ЕПГУ
     */
    public final TableField<RecruitmentRecord, String> EPGU_ID = createField(DSL.name("epgu_id"), SQLDataType.VARCHAR, this, "Идентификатор ЕПГУ");

    /**
     * The column <code>metrics.recruitment.kpp</code>. КПП
     */
    public final TableField<RecruitmentRecord, String> KPP = createField(DSL.name("kpp"), SQLDataType.VARCHAR(64), this, "КПП");

    /**
     * The column <code>metrics.recruitment.inn</code>. ИНН
     */
    public final TableField<RecruitmentRecord, String> INN = createField(DSL.name("inn"), SQLDataType.VARCHAR(64), this, "ИНН");

    /**
     * The column <code>metrics.recruitment.okato</code>. ОКАТО
     */
    public final TableField<RecruitmentRecord, String> OKATO = createField(DSL.name("okato"), SQLDataType.VARCHAR(64), this, "ОКАТО");

    /**
     * The column <code>metrics.recruitment.division_type</code>. Тип дивизиона
     */
    public final TableField<RecruitmentRecord, String> DIVISION_TYPE = createField(DSL.name("division_type"), SQLDataType.VARCHAR(64), this, "Тип дивизиона");

    /**
     * The column <code>metrics.recruitment.tns_department_id</code>.
     * Идентификатор департамента из ТНС
     */
    public final TableField<RecruitmentRecord, String> TNS_DEPARTMENT_ID = createField(DSL.name("tns_department_id"), SQLDataType.VARCHAR, this, "Идентификатор департамента из ТНС");

    /**
     * The column <code>metrics.recruitment.enabled</code>. Признак актуальности
     */
    public final TableField<RecruitmentRecord, Boolean> ENABLED = createField(DSL.name("enabled"), SQLDataType.BOOLEAN.nullable(false).defaultValue(DSL.field(DSL.raw("true"), SQLDataType.BOOLEAN)), this, "Признак актуальности");

    /**
     * The column <code>metrics.recruitment.timezone</code>. Часовой пояс
     */
    public final TableField<RecruitmentRecord, String> TIMEZONE = createField(DSL.name("timezone"), SQLDataType.VARCHAR(64), this, "Часовой пояс");

    /**
     * The column <code>metrics.recruitment.reports_enabled</code>. Признак
     * актуальности для отчета
     */
    public final TableField<RecruitmentRecord, Boolean> REPORTS_ENABLED = createField(DSL.name("reports_enabled"), SQLDataType.BOOLEAN, this, "Признак актуальности для отчета");

    /**
     * The column <code>metrics.recruitment.subpoena_series_code</code>. Серия
     */
    public final TableField<RecruitmentRecord, String> SUBPOENA_SERIES_CODE = createField(DSL.name("subpoena_series_code"), SQLDataType.VARCHAR(64), this, "Серия");

    /**
     * The column <code>metrics.recruitment.hidden</code>. Признак скрытого
     */
    public final TableField<RecruitmentRecord, Boolean> HIDDEN = createField(DSL.name("hidden"), SQLDataType.BOOLEAN.nullable(false).defaultValue(DSL.field(DSL.raw("false"), SQLDataType.BOOLEAN)), this, "Признак скрытого");

    /**
     * The column <code>metrics.recruitment.region_id</code>. Идентификатор
     * региона
     */
    public final TableField<RecruitmentRecord, Integer> REGION_ID = createField(DSL.name("region_id"), SQLDataType.INTEGER.nullable(false), this, "Идентификатор региона");

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

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

    private Recruitment(Name alias, Table<RecruitmentRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment("Военный комиссариат"), TableOptions.table(), where);
    }

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

    /**
     * Create an aliased <code>metrics.recruitment</code> table reference
     */
    public Recruitment(Name alias) {
        this(alias, RECRUITMENT);
    }

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

    public <O extends Record> Recruitment(Table<O> path, ForeignKey<O, RecruitmentRecord> childPath, InverseForeignKey<O, RecruitmentRecord> parentPath) {
        super(path, childPath, parentPath, RECRUITMENT);
    }

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

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

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

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

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

    @Override
    public UniqueKey<RecruitmentRecord> getPrimaryKey() {
        return Keys.RECRUITMENT_PKEY;
    }

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

    private transient RegionPath _region;

    /**
     * Get the implicit join path to the <code>metrics.region</code> table.
     */
    public RegionPath region() {
        if (_region == null)
            _region = new RegionPath(this, Keys.RECRUITMENT__FK_RECRUITMENT_REGION_ID, null);

        return _region;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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