<commit_before>package org.labkey.wnprc_compliance.schema.tables;

import org.jetbrains.annotations.Nullable;
import org.jooq.Select;
import org.labkey.api.data.*;
import org.labkey.api.query.ExprColumn;
import org.labkey.api.query.UserSchema;
import org.labkey.dbutils.jooq.jOOQConnection;
import org.labkey.wnprc_compliance.WNPRC_ComplianceSchema;

import static org.labkey.wnprc_compliance.model.jooq.Tables.PROTOCOLS;
import static org.labkey.wnprc_compliance.model.jooq.Tables.PROTOCOL_REVISIONS;

/**
 * Created by jon on 3/27/17.
 */
public class MostRecentProtocolRevision extends AbstractTableInfo {
    public static String NAME = "MostRecentProtocolRevision";
    private UserSchema schema;

    public MostRecentProtocolRevision(@Nullable UserSchema userSchema) {
        super(DbSchema.get(WNPRC_ComplianceSchema.NAME), NAME);
        schema = userSchema;

        this.addColumn(new ExprColumn(this, PROTOCOL_REVISIONS.PROTOCOL_ID.getName(), new SQLFragment(ExprColumn.STR_TABLE_ALIAS + "." + PROTOCOL_REVISIONS.PROTOCOL_ID.getName().toString()), JdbcType.VARCHAR));
        this.addColumn(new ExprColumn(this, PROTOCOL_REVISIONS.APPROVAL_DATE.getName(), new SQLFragment(ExprColumn.STR_TABLE_ALIAS + "." + PROTOCOL_REVISIONS.APPROVAL_DATE.getName().toString()), JdbcType.DATE));
    }


    @Override
    public SQLFragment getFromSQL() {
        SQLFragment sql = new SQLFragment();


        try (jOOQConnection jOOQConnection = new jOOQConnection(WNPRC_ComplianceSchema.NAME)) {
            String query = jOOQConnection.create().select(PROTOCOL_REVISIONS.PROTOCOL_ID, PROTOCOL_REVISIONS.APPROVAL_DATE)
                    .from(PROTOCOL_REVISIONS)
                    .getSQL();

            sql.append(query);
        }

        return sql;
    }

    @Nullable
    @Override
    public UserSchema getUserSchema() {
        return schema;
    }
}
<commit_msg>Rework table to use jOOQTableInfo from DBUtils.<commit_after>package org.labkey.wnprc_compliance.schema.tables;

import org.jetbrains.annotations.Nullable;
import org.jooq.*;
import org.labkey.api.query.UserSchema;
import org.labkey.dbutils.jooq.jOOQConnection;
import org.labkey.dbutils.jooq.jOOQTableInfo;
import org.labkey.wnprc_compliance.WNPRC_ComplianceSchema;

import static org.labkey.wnprc_compliance.model.jooq.Tables.PROTOCOLS;
import static org.labkey.wnprc_compliance.model.jooq.Tables.PROTOCOL_REVISIONS;

/**
 * Created by jon on 3/27/17.
 */
public class MostRecentProtocolRevision extends jOOQTableInfo {
    public static String NAME = "MostRecentProtocolRevision";

    public MostRecentProtocolRevision(@Nullable UserSchema userSchema) {
        super(NAME, WNPRC_ComplianceSchema.NAME, userSchema);
    }

    @Override
    public Table<? extends Record> getjOOQTable() {
        try (jOOQConnection jOOQConnection = new jOOQConnection(WNPRC_ComplianceSchema.NAME)) {
            return jOOQConnection.create().select(PROTOCOL_REVISIONS.PROTOCOL_ID, PROTOCOL_REVISIONS.APPROVAL_DATE, PROTOCOL_REVISIONS.HAS_PHYSICAL_HAZARDS)
                    .from(PROTOCOL_REVISIONS)
                    .asTable();
        }
    }
}

{'fraction_non_alphanumeric': 0.09583333333333334, 'fraction_numerical': 0.003205128205128205, 'mean_word_length': 4.0420032310177705, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7665152', 'n_tokens_mistral': 1059, 'n_tokens_neox': 1008, 'n_words': 156}