/*
 * 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.ActiveApplicationsRecord;


/**
 * Обжалования. Активные заявления в ГИС ЕРВУ
 */
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class ActiveApplications extends TableImpl<ActiveApplicationsRecord> {

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of <code>metrics.active_applications</code>
     */
    public static final ActiveApplications ACTIVE_APPLICATIONS = new ActiveApplications();

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

    /**
     * The column
     * <code>metrics.active_applications.active_applications_id</code>.
     */
    public final TableField<ActiveApplicationsRecord, Long> ACTIVE_APPLICATIONS_ID = createField(DSL.name("active_applications_id"), SQLDataType.BIGINT.nullable(false).identity(true), this, "");

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

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

    /**
     * The column
     * <code>metrics.active_applications.count_active_applications</code>.
     */
    public final TableField<ActiveApplicationsRecord, Long> COUNT_ACTIVE_APPLICATIONS = createField(DSL.name("count_active_applications"), SQLDataType.BIGINT.nullable(false).defaultValue(DSL.field(DSL.raw("0"), SQLDataType.BIGINT)), this, "");

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

    private ActiveApplications(Name alias, Table<ActiveApplicationsRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment("Обжалования. Активные заявления в ГИС ЕРВУ"), TableOptions.table(), where);
    }

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

    /**
     * Create an aliased <code>metrics.active_applications</code> table
     * reference
     */
    public ActiveApplications(Name alias) {
        this(alias, ACTIVE_APPLICATIONS);
    }

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

    public <O extends Record> ActiveApplications(Table<O> path, ForeignKey<O, ActiveApplicationsRecord> childPath, InverseForeignKey<O, ActiveApplicationsRecord> parentPath) {
        super(path, childPath, parentPath, ACTIVE_APPLICATIONS);
    }

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

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

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

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

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

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

    @Override
    public UniqueKey<ActiveApplicationsRecord> getPrimaryKey() {
        return Keys.ACTIVE_APPLICATIONS_PKEY;
    }

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

        return _recruitment;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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