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


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

import org.jooq.Check;
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.Internal;
import org.jooq.impl.SQLDataType;
import org.jooq.impl.TableImpl;

import ru.micord.webbpm.ervu.business_metrics.db_beans.init_registration_info.InitRegistrationInfo;
import ru.micord.webbpm.ervu.business_metrics.db_beans.init_registration_info.Keys;
import ru.micord.webbpm.ervu.business_metrics.db_beans.init_registration_info.tables.records.RecordsInfoIdUkIdErnRecord;
import ru.micord.webbpm.ervu.business_metrics.db_beans.metrics.tables.Recruitment.RecruitmentPath;


/**
 * Первоначальная постановка на учет. Информация о налиции ИД ЕРН и ИД УК
 */
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class RecordsInfoIdUkIdErn extends TableImpl<RecordsInfoIdUkIdErnRecord> {

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of
     * <code>init_registration_info.records_info_id_uk_id_ern</code>
     */
    public static final RecordsInfoIdUkIdErn RECORDS_INFO_ID_UK_ID_ERN = new RecordsInfoIdUkIdErn();

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

    /**
     * The column
     * <code>init_registration_info.records_info_id_uk_id_ern.records_info_id_uk_id_ern_id</code>.
     */
    public final TableField<RecordsInfoIdUkIdErnRecord, Long> RECORDS_INFO_ID_UK_ID_ERN_ID = createField(DSL.name("records_info_id_uk_id_ern_id"), SQLDataType.BIGINT.nullable(false).identity(true), this, "");

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

    /**
     * The column
     * <code>init_registration_info.records_info_id_uk_id_ern.update_date</code>.
     */
    public final TableField<RecordsInfoIdUkIdErnRecord, 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>init_registration_info.records_info_id_uk_id_ern.info_date</code>.
     */
    public final TableField<RecordsInfoIdUkIdErnRecord, Date> INFO_DATE = createField(DSL.name("info_date"), SQLDataType.DATE.nullable(false), this, "");

    /**
     * The column
     * <code>init_registration_info.records_info_id_uk_id_ern.info_source</code>.
     * Источник - PERSONAL_VISIT, GIR_VU, EPGU
     */
    public final TableField<RecordsInfoIdUkIdErnRecord, String> INFO_SOURCE = createField(DSL.name("info_source"), SQLDataType.VARCHAR.nullable(false), this, "Источник - PERSONAL_VISIT, GIR_VU, EPGU");

    /**
     * The column
     * <code>init_registration_info.records_info_id_uk_id_ern.info_age</code>.
     * Информациия о каком возрасте 17_YEARS, 18_YEARS
     */
    public final TableField<RecordsInfoIdUkIdErnRecord, String> INFO_AGE = createField(DSL.name("info_age"), SQLDataType.VARCHAR.nullable(false), this, "Информациия о каком возрасте 17_YEARS, 18_YEARS");

    /**
     * The column
     * <code>init_registration_info.records_info_id_uk_id_ern.records_with_id_uk</code>.
     */
    public final TableField<RecordsInfoIdUkIdErnRecord, Long> RECORDS_WITH_ID_UK = createField(DSL.name("records_with_id_uk"), SQLDataType.BIGINT.nullable(false).defaultValue(DSL.field(DSL.raw("0"), SQLDataType.BIGINT)), this, "");

    /**
     * The column
     * <code>init_registration_info.records_info_id_uk_id_ern.records_without_id_uk</code>.
     */
    public final TableField<RecordsInfoIdUkIdErnRecord, Long> RECORDS_WITHOUT_ID_UK = createField(DSL.name("records_without_id_uk"), SQLDataType.BIGINT.nullable(false).defaultValue(DSL.field(DSL.raw("0"), SQLDataType.BIGINT)), this, "");

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

    private RecordsInfoIdUkIdErn(Name alias, Table<RecordsInfoIdUkIdErnRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment("Первоначальная постановка на учет. Информация о налиции ИД ЕРН и ИД УК"), TableOptions.table(), where);
    }

    /**
     * Create an aliased
     * <code>init_registration_info.records_info_id_uk_id_ern</code> table
     * reference
     */
    public RecordsInfoIdUkIdErn(String alias) {
        this(DSL.name(alias), RECORDS_INFO_ID_UK_ID_ERN);
    }

    /**
     * Create an aliased
     * <code>init_registration_info.records_info_id_uk_id_ern</code> table
     * reference
     */
    public RecordsInfoIdUkIdErn(Name alias) {
        this(alias, RECORDS_INFO_ID_UK_ID_ERN);
    }

    /**
     * Create a <code>init_registration_info.records_info_id_uk_id_ern</code>
     * table reference
     */
    public RecordsInfoIdUkIdErn() {
        this(DSL.name("records_info_id_uk_id_ern"), null);
    }

    public <O extends Record> RecordsInfoIdUkIdErn(Table<O> path, ForeignKey<O, RecordsInfoIdUkIdErnRecord> childPath, InverseForeignKey<O, RecordsInfoIdUkIdErnRecord> parentPath) {
        super(path, childPath, parentPath, RECORDS_INFO_ID_UK_ID_ERN);
    }

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

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

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

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

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

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

    @Override
    public UniqueKey<RecordsInfoIdUkIdErnRecord> getPrimaryKey() {
        return Keys.RECORDS_INFO_ID_UK_ID_ERN_PKEY;
    }

    @Override
    public List<ForeignKey<RecordsInfoIdUkIdErnRecord, ?>> getReferences() {
        return Arrays.asList(Keys.RECORDS_INFO_ID_UK_ID_ERN__FK_CONV_INFO_RECORDS_FROM_EASU_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.RECORDS_INFO_ID_UK_ID_ERN__FK_CONV_INFO_RECORDS_FROM_EASU_RECRUITMENT_ID, null);

        return _recruitment;
    }

    @Override
    public List<Check<RecordsInfoIdUkIdErnRecord>> getChecks() {
        return Arrays.asList(
            Internal.createCheck(this, DSL.name("chk_info_age"), "(((info_age)::text = ANY (ARRAY[('17_YEARS'::character varying)::text, ('18_YEARS'::character varying)::text, ('EPGU'::character varying)::text])))", true),
            Internal.createCheck(this, DSL.name("chk_info_source"), "(((info_source)::text = ANY (ARRAY[('PERSONAL_VISIT'::character varying)::text, ('GIR_VU'::character varying)::text, ('EPGU'::character varying)::text])))", true)
        );
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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