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


/**
 * Журналирование. Журналы входящих, исходящих, сформированных сообщений
 */
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class MessageJournal extends TableImpl<MessageJournalRecord> {

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of <code>journal_log.message_journal</code>
     */
    public static final MessageJournal MESSAGE_JOURNAL = new MessageJournal();

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

    /**
     * The column <code>journal_log.message_journal.message_journal_id</code>.
     */
    public final TableField<MessageJournalRecord, Long> MESSAGE_JOURNAL_ID = createField(DSL.name("message_journal_id"), SQLDataType.BIGINT.nullable(false).identity(true), this, "");

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

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

    /**
     * The column <code>journal_log.message_journal.info_source</code>. тип
     * сообщений IN - входящие, OUT - исходящие, FORMED - сформированные,
     * IN_ERROR - входящие с ошибками
     */
    public final TableField<MessageJournalRecord, String> INFO_SOURCE = createField(DSL.name("info_source"), SQLDataType.VARCHAR.nullable(false), this, "тип сообщений IN - входящие, OUT - исходящие, FORMED - сформированные, IN_ERROR - входящие с ошибками");

    /**
     * The column <code>journal_log.message_journal.org_source</code>. тип
     * организаций MVD - МДВ, FBI - ФБР, FNS - ФНС, MEASURES_RELEASE - Реализ.
     * мер, MIN_DIGIT - минцифры, RUS_REESTR - Росреестр
     */
    public final TableField<MessageJournalRecord, String> ORG_SOURCE = createField(DSL.name("org_source"), SQLDataType.VARCHAR.nullable(false), this, "тип организаций MVD - МДВ, FBI - ФБР, FNS - ФНС, MEASURES_RELEASE - Реализ. мер, MIN_DIGIT - минцифры, RUS_REESTR - Росреестр");

    /**
     * The column <code>journal_log.message_journal.count_subpoena</code>.
     * реестр повесток
     */
    public final TableField<MessageJournalRecord, Long> COUNT_SUBPOENA = createField(DSL.name("count_subpoena"), SQLDataType.BIGINT.nullable(false).defaultValue(DSL.field(DSL.raw("0"), SQLDataType.BIGINT)), this, "реестр повесток");

    /**
     * The column <code>journal_log.message_journal.count_ern</code>. сведения
     * об ерн
     */
    public final TableField<MessageJournalRecord, Long> COUNT_ERN = createField(DSL.name("count_ern"), SQLDataType.BIGINT.nullable(false).defaultValue(DSL.field(DSL.raw("0"), SQLDataType.BIGINT)), this, "сведения об ерн");

    /**
     * The column <code>journal_log.message_journal.count_app_epgu</code>. прием
     * заявлений с епгу
     */
    public final TableField<MessageJournalRecord, Long> COUNT_APP_EPGU = createField(DSL.name("count_app_epgu"), SQLDataType.BIGINT.nullable(false).defaultValue(DSL.field(DSL.raw("0"), SQLDataType.BIGINT)), this, "прием заявлений с епгу");

    /**
     * The column <code>journal_log.message_journal.count_tmp_measures</code>.
     * введение временных мер
     */
    public final TableField<MessageJournalRecord, Long> COUNT_TMP_MEASURES = createField(DSL.name("count_tmp_measures"), SQLDataType.BIGINT.nullable(false).defaultValue(DSL.field(DSL.raw("0"), SQLDataType.BIGINT)), this, "введение временных мер");

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

    private MessageJournal(Name alias, Table<MessageJournalRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment("Журналирование. Журналы входящих, исходящих, сформированных сообщений"), TableOptions.table(), where);
    }

    /**
     * Create an aliased <code>journal_log.message_journal</code> table
     * reference
     */
    public MessageJournal(String alias) {
        this(DSL.name(alias), MESSAGE_JOURNAL);
    }

    /**
     * Create an aliased <code>journal_log.message_journal</code> table
     * reference
     */
    public MessageJournal(Name alias) {
        this(alias, MESSAGE_JOURNAL);
    }

    /**
     * Create a <code>journal_log.message_journal</code> table reference
     */
    public MessageJournal() {
        this(DSL.name("message_journal"), null);
    }

    public <O extends Record> MessageJournal(Table<O> path, ForeignKey<O, MessageJournalRecord> childPath, InverseForeignKey<O, MessageJournalRecord> parentPath) {
        super(path, childPath, parentPath, MESSAGE_JOURNAL);
    }

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

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

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

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

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

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

    @Override
    public UniqueKey<MessageJournalRecord> getPrimaryKey() {
        return Keys.MESSAGE_JOURNAL_PKEY;
    }

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

        return _recruitment;
    }

    @Override
    public List<Check<MessageJournalRecord>> getChecks() {
        return Arrays.asList(
            Internal.createCheck(this, DSL.name("chk_info_source"), "(((info_source)::text = ANY (ARRAY[('IN'::character varying)::text, ('OUT'::character varying)::text, ('FORMED'::character varying)::text, ('IN_ERROR'::character varying)::text])))", true),
            Internal.createCheck(this, DSL.name("chk_org_source"), "(((org_source)::text = ANY (ARRAY[('MVD'::character varying)::text, ('FBI'::character varying)::text, ('FNS'::character varying)::text, ('MEASURES_RELEASE'::character varying)::text, ('MIN_DIGIT'::character varying)::text, ('RUS_REESTR'::character varying)::text])))", true)
        );
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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