/*
 * This file is generated by jOOQ.
 */
package ru.micord.webbpm.ervu.business_metrics.db_beans.registration_change_address.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.metrics.tables.Recruitment.RecruitmentPath;
import ru.micord.webbpm.ervu.business_metrics.db_beans.registration_change_address.Keys;
import ru.micord.webbpm.ervu.business_metrics.db_beans.registration_change_address.RegistrationChangeAddress;
import ru.micord.webbpm.ervu.business_metrics.db_beans.registration_change_address.tables.records.SummonsesSignRecord;


/**
 * Постановка на воинский учет при смене адреса. Повестки, подписанные в первом
 * ВК
 */
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class SummonsesSign extends TableImpl<SummonsesSignRecord> {

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of
     * <code>registration_change_address.summonses_sign</code>
     */
    public static final SummonsesSign SUMMONSES_SIGN = new SummonsesSign();

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

    /**
     * The column
     * <code>registration_change_address.summonses_sign.summonses_sign_id</code>.
     */
    public final TableField<SummonsesSignRecord, Long> SUMMONSES_SIGN_ID = createField(DSL.name("summonses_sign_id"), SQLDataType.BIGINT.nullable(false).identity(true), this, "");

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

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

    /**
     * The column
     * <code>registration_change_address.summonses_sign.info_source</code>.
     * информация об источнике - PERSONAL_VISIT, GIR_VU, EPGU
     */
    public final TableField<SummonsesSignRecord, String> INFO_SOURCE = createField(DSL.name("info_source"), SQLDataType.VARCHAR.nullable(false), this, "информация об источнике - PERSONAL_VISIT, GIR_VU, EPGU");

    /**
     * The column
     * <code>registration_change_address.summonses_sign.count_refused_in_second</code>.
     * отмененные во 2 ВК
     */
    public final TableField<SummonsesSignRecord, Long> COUNT_REFUSED_IN_SECOND = createField(DSL.name("count_refused_in_second"), SQLDataType.BIGINT.nullable(false).defaultValue(DSL.field(DSL.raw("0"), SQLDataType.BIGINT)), this, "отмененные во 2 ВК");

    /**
     * The column
     * <code>registration_change_address.summonses_sign.count_accepted_in_second</code>.
     * подтвержденные во 2 ВК
     */
    public final TableField<SummonsesSignRecord, Long> COUNT_ACCEPTED_IN_SECOND = createField(DSL.name("count_accepted_in_second"), SQLDataType.BIGINT.nullable(false).defaultValue(DSL.field(DSL.raw("0"), SQLDataType.BIGINT)), this, "подтвержденные во 2 ВК");

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

    private SummonsesSign(Name alias, Table<SummonsesSignRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment("Постановка на воинский учет при смене адреса. Повестки, подписанные в первом ВК"), TableOptions.table(), where);
    }

    /**
     * Create an aliased <code>registration_change_address.summonses_sign</code>
     * table reference
     */
    public SummonsesSign(String alias) {
        this(DSL.name(alias), SUMMONSES_SIGN);
    }

    /**
     * Create an aliased <code>registration_change_address.summonses_sign</code>
     * table reference
     */
    public SummonsesSign(Name alias) {
        this(alias, SUMMONSES_SIGN);
    }

    /**
     * Create a <code>registration_change_address.summonses_sign</code> table
     * reference
     */
    public SummonsesSign() {
        this(DSL.name("summonses_sign"), null);
    }

    public <O extends Record> SummonsesSign(Table<O> path, ForeignKey<O, SummonsesSignRecord> childPath, InverseForeignKey<O, SummonsesSignRecord> parentPath) {
        super(path, childPath, parentPath, SUMMONSES_SIGN);
    }

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

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

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

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

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

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

    @Override
    public UniqueKey<SummonsesSignRecord> getPrimaryKey() {
        return Keys.SUMMONSES_SIGN_PKEY;
    }

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

        return _recruitment;
    }

    @Override
    public List<Check<SummonsesSignRecord>> getChecks() {
        return Arrays.asList(
            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 SummonsesSign as(String alias) {
        return new SummonsesSign(DSL.name(alias), this);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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