org.jooq.SelectQuery - java examples

Here are the examples of the java api org.jooq.SelectQuery taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

151 Examples 7

19 View Complete Implementation : RecordDao.java
Copyright MIT License
Author : openforis
public CollectRecord load(CollectSurvey survey, int id, Step step, boolean toBeUpdated) {
    SelectQuery query = selectRecordQuery(id, false, step, null);
    Record r = query.fetchOne();
    return r == null ? null : fromQueryResult(survey, r, toBeUpdated);
}

19 View Complete Implementation : RecordDao.java
Copyright MIT License
Author : openforis
public CollectRecord load(CollectSurvey survey, int id, int workflowSequenceNumber, boolean toBeUpdated) {
    SelectQuery query = selectRecordQuery(id, false, null, workflowSequenceNumber);
    Record r = query.fetchOne();
    return r == null ? null : fromQueryResult(survey, r, toBeUpdated);
}

19 View Complete Implementation : RecordDao.java
Copyright MIT License
Author : openforis
public int countRecords(RecordFilter filter) {
    SelectQuery<Record> q = dsl.selectQuery();
    q.addSelect(count());
    q.addFrom(OFC_RECORD);
    addRecordSummaryFilterConditions(q, filter);
    Record record = q.fetchOne();
    int result = record.getValue(count());
    return result;
}

19 View Complete Implementation : RecordDao.java
Copyright MIT License
Author : openforis
public byte[] loadBinaryData(CollectSurvey survey, int id, Step step) {
    SelectQuery query = selectRecordQuery(id, false, step, null);
    Record r = query.fetchOne();
    return r == null ? null : r.getValue(OFC_RECORD_DATA.DATA);
}

18 View Complete Implementation : RecordDao.java
Copyright MIT License
Author : openforis
public List<CollectRecordSummary> loadSummaries(RecordFilter filter, List<RecordSummarySortField> sortFields) {
    CollectSurvey survey = filter.getSurvey();
    SelectQuery<Record> q = createSelectSummariesQuery(filter, sortFields);
    Result<Record> result = q.fetch();
    return fromSummaryQueryResult(result, survey);
}

18 View Complete Implementation : MappingDSLContext.java
Copyright MIT License
Author : openforis
public <T> SelectQuery<?> selectByFieldQuery(TableField<?, T> field, T value) {
    SelectQuery<?> select = selectQuery(getTable());
    select.addConditions(field.eq(value));
    return select;
}

18 View Complete Implementation : Limit.java
Copyright MIT License
Author : chillenious
/**
 * Add the limit clause to the provided query.
 */
public void apply(SelectQuery query) {
    query.addLimit(offset, numberOfRows + (testForMore ? 1 : 0));
}

18 View Complete Implementation : RecordDao.java
Copyright MIT License
Author : openforis
public SelectQuery selectRecordQuery(int id, boolean onlySummary, Step step, Integer workflowSequenceNumber) {
    SelectQuery<Record> query = dsl.selectQuery();
    query.addSelect(RECORD_DATA_FULL_SUMMARY_FIELDS);
    if (!onlySummary) {
        query.addSelect(OFC_RECORD_DATA.DATA, OFC_RECORD_DATA.APP_VERSION);
    }
    query.addFrom(OFC_RECORD_DATA);
    if (workflowSequenceNumber == null) {
        workflowSequenceNumber = getLatestWorkflowSequenceNumber(id, step, true);
    }
    query.addJoin(OFC_RECORD, OFC_RECORD_DATA.RECORD_ID.eq(OFC_RECORD.ID).and(OFC_RECORD_DATA.SEQ_NUM.eq(workflowSequenceNumber)));
    query.addConditions(OFC_RECORD.ID.equal(id));
    return query;
}

18 View Complete Implementation : RecordDao.java
Copyright MIT License
Author : openforis
private void addFilterByFieldsConditions(SelectQuery q, TableField[] fields, boolean caseSensitiveValues, boolean isNullWhenNotSpecified, String... values) {
    if (values != null && values.length > 0) {
        for (int i = 0; i < values.length && i < fields.length; i++) {
            String value = values[i];
            @SuppressWarnings("unchecked")
            Field<String> field = (Field<String>) fields[i];
            if (isNotBlank(value)) {
                Condition condition;
                boolean likeSearchType = value.contains("*");
                if (likeSearchType) {
                    condition = field.like(value.replaceAll("\\*", "%"));
                } else if (caseSensitiveValues) {
                    condition = field.equal(value);
                } else {
                    condition = field.upper().equal(value.toUpperCase(Locale.ENGLISH));
                }
                q.addConditions(condition);
            } else if (isNullWhenNotSpecified) {
                q.addConditions(field.isNull());
            }
        }
    }
}

17 View Complete Implementation : MappingDSLContext.java
Copyright MIT License
Author : openforis
public SelectQuery<?> selectByIdQuery(I id) {
    SelectQuery<?> select = selectQuery(getTable());
    select.addConditions(idField.eq(id));
    return select;
}

17 View Complete Implementation : RecordDao.java
Copyright MIT License
Author : openforis
public Set<Integer> loadDistinctOwnerIds(RecordFilter filter) {
    SelectQuery<?> q = dsl().selectQuery();
    q.addSelect(OFC_RECORD.OWNER_ID);
    q.addFrom(OFC_RECORD);
    addRecordSummaryFilterConditions(q, filter);
    q.addConditions(OFC_RECORD.OWNER_ID.isNotNull());
    return q.fetchSet(OFC_RECORD.OWNER_ID);
}

17 View Complete Implementation : JdbcPaginator.java
Copyright Apache License 2.0
Author : ananas-analytics
public SelectQuery outputQuery(boolean isLimit) {
    Query inputQuery = DSL.using(this.jdbcConfig.sqlDialect.JOOQdialect).parser().parseQuery(this.jdbcConfig.sql);
    String outputSQL = DSL.using(this.jdbcConfig.driver.JOOQdialect).render(inputQuery);
    SelectQuery q = (SelectQuery) DSL.using(this.jdbcConfig.driver.JOOQdialect).parser().parseQuery(outputSQL);
    if (isLimit) {
        q.addLimit(DEFAULT_LIMIT);
    }
    return q;
}

17 View Complete Implementation : JdbcPaginator.java
Copyright Apache License 2.0
Author : ananas-analytics
@Override
public Schema autodetect() {
    SelectQuery q = outputQuery(true);
    return JdbcSchemaDetecter.autodetect(this.jdbcConfig.driver, this.jdbcConfig.url, this.jdbcConfig.username, this.jdbcConfig.preplacedword, q.toString());
}

17 View Complete Implementation : JdbcConnector.java
Copyright Apache License 2.0
Author : ananas-analytics
public SelectQuery outputQuery(boolean isLimit) {
    Query inputQuery = DSL.using(this.config.sqlDialect.JOOQdialect).parser().parseQuery(this.config.sql);
    String outputSQL = DSL.using(this.config.driver.JOOQdialect).render(inputQuery);
    SelectQuery q = (SelectQuery) DSL.using(this.config.driver.JOOQdialect).parser().parseQuery(outputSQL);
    if (isLimit) {
        q.addLimit(DEFAULT_LIMIT);
    }
    return q;
}

17 View Complete Implementation : ContestPhaseRibbonTypeDaoImpl.java
Copyright MIT License
Author : CCI-MIT
@Override
public List<IContestPhaseRibbonType> findByGiven() {
    final SelectQuery<Record> query = dslContext.select().from(CONTEST_PHASE_RIBBON_TYPE).getQuery();
    return query.fetchInto(ContestPhaseRibbonType.clreplaced);
}

17 View Complete Implementation : MappingDSLContext.java
Copyright MIT License
Author : openforis
public <T> SelectQuery<?> selectStartsWithQuery(TableField<?, String> field, String searchString) {
    if (searchString == null || searchString.isEmpty()) {
        throw new IllegalArgumentException("Search string required");
    }
    SelectQuery<?> select = selectQuery(getTable());
    searchString = searchString.toUpperCase(Locale.ENGLISH) + "%";
    select.addConditions(DSL.upper(field).like(searchString));
    return select;
}

17 View Complete Implementation : MappingDSLContext.java
Copyright MIT License
Author : openforis
public SelectQuery<?> selectCountQuery() {
    SelectQuery<?> select = selectQuery();
    select.addSelect(DSL.count());
    select.addFrom(getTable());
    return select;
}

17 View Complete Implementation : MappingDSLContext.java
Copyright MIT License
Author : openforis
public <T> SelectQuery<?> selectContainsQuery(TableField<?, String> field, String searchString) {
    if (searchString == null || searchString.isEmpty()) {
        throw new IllegalArgumentException("Search string required");
    }
    SelectQuery<?> select = selectQuery(getTable());
    searchString = "%" + searchString.toUpperCase(Locale.ENGLISH) + "%";
    select.addConditions(DSL.upper(field).like(searchString));
    return select;
}

16 View Complete Implementation : MappingJooqDaoSupport.java
Copyright MIT License
Author : openforis
public List<E> loadAll() {
    C dsl = dsl();
    SelectQuery<?> query = dsl.selectQuery(dsl.getTable());
    Result<?> result = query.fetch();
    List<E> enreplacedies = dsl.fromResult(result);
    return enreplacedies;
}

16 View Complete Implementation : RecordDao.java
Copyright MIT License
Author : openforis
private SelectQuery<Record> createSelectSummariesQuery(RecordFilter filter, List<RecordSummarySortField> sortFields) {
    SelectQuery<Record> q = dsl.selectQuery();
    q.addSelect(RECORD_FULL_SUMMARY_FIELDS);
    Field<String> ownerNameField = OFC_USER.USERNAME.as(RecordSummarySortField.Sortable.OWNER_NAME.name());
    q.addSelect(ownerNameField);
    q.addFrom(OFC_RECORD);
    // join with user table to get owner name
    q.addJoin(OFC_USER, JoinType.LEFT_OUTER_JOIN, OFC_RECORD.OWNER_ID.equal(OFC_USER.ID));
    addRecordSummaryFilterConditions(q, filter);
    // add limit
    if (filter.getOffset() != null && filter.getMaxNumberOfRecords() != null) {
        q.addLimit(filter.getOffset(), filter.getMaxNumberOfRecords());
    }
    // add ordering fields
    if (sortFields != null) {
        for (RecordSummarySortField sortField : sortFields) {
            addOrderBy(q, sortField, ownerNameField);
        }
    }
    // always order by ID to avoid pagination issues
    q.addOrderBy(OFC_RECORD.ID);
    return q;
}

16 View Complete Implementation : SamplingDesignDao.java
Copyright MIT License
Author : openforis
public List<SamplingDesignItem> loadItems(int surveyId, Integer upToLevel, int offset, int maxRecords) {
    SamplingDesignDSLContext dsl = dsl();
    SelectQuery<Record> q = createSelecreplacedemsQuery(dsl, surveyId, upToLevel);
    // add limit
    q.addLimit(offset, maxRecords);
    // fetch results
    Result<Record> result = q.fetch();
    return dsl.fromResult(result);
}

16 View Complete Implementation : RecordSummaryQueryBuilder.java
Copyright MIT License
Author : openforis
/**
 * @author S. Ricci
 */
public clreplaced RecordSummaryQueryBuilder {

    private final Log LOG = LogFactory.getLog(RecordSummaryQueryBuilder.clreplaced);

    private static final String USER_TABLE_CREATED_BY_ALIAS = "user_created_by";

    private static final String USER_TABLE_MODIFIED_BY_ALIAS = "user_modified_by";

    private static final String KEY_DATA_TABLE_ALIAS_PREFIX = "data_key_";

    private static final String COUNT_VIEW_ALIAS_PREFIX = "view_count_";

    private static final String COUNT_COLUMN_PREFIX = "count_";

    private static final String KEY_COLUMN_PREFIX = "key_";

    private static final String ORDER_BY_CREATED_BY_FIELD_NAME = "createdBy";

    private static final String ORDER_BY_MODIFIED_BY_FIELD_NAME = "createdBy";

    private static final String ORDER_BY_DATE_MODIFIED_FIELD_NAME = "modifiedDate";

    private static final String ORDER_BY_DATE_CREATED_FIELD_NAME = "creationDate";

    private static final String ORDER_BY_SKIPPED_FIELD_NAME = "skipped";

    private static final String ORDER_BY_MISSING_FIELD_NAME = "missing";

    private static final String ORDER_BY_ERRORS_FIELD_NAME = "errors";

    private static final String ORDER_BY_WARNINGS_FIELD_NAME = "warnings";

    private Factory jooqFactory;

    /**
     */
    private SelectQuery selectQuery;

    /**
     * the root enreplacedy used to filter the records
     */
    private EnreplacedyDefinition rootEnreplacedyDefinition;

    public RecordSummaryQueryBuilder(Factory jooqFactory) {
        super();
        this.jooqFactory = jooqFactory;
        init();
    }

    private void init() {
        // Aliases used in query
        private static final Record r = RECORD.as("r");
        private static final UserAccount u1 = USER_ACCOUNT.as("u1");
        private static final UserAccount u2 = USER_ACCOUNT.as("u2");
        // CREATE SELECT QUERY
        selectQuery = jooqFactory.selectQuery();
        // select
        selectQuery.addSelect(r.DATE_CREATED, r.DATE_MODIFIED, r.ERRORS, r.ID, r.LOCKED_BY_ID, r.MISSING, r.MODEL_VERSION, r.MODIFIED_BY_ID, r.ROOT_ENreplacedY_ID, r.SKIPPED, r.STATE, r.STEP, r.WARNINGS, u1.USERNAME, u2.USERNAME);
        // from
        selectQuery.addFrom(r);
        // add join with user table
        selectQuery.addJoin(u1, JoinType.LEFT_OUTER_JOIN, r.CREATED_BY_ID.equal(u1.ID));
        selectQuery.addJoin(u2, JoinType.LEFT_OUTER_JOIN, r.MODIFIED_BY_ID.equal(u2.ID));
    }

    /**
     * Build the select query to load record summaries.
     *
     * the projection will contain:
     * - key attribute columns
     * - count of enreplacedies annotated with countInRecordSummary
     * - record table fields
     * - user created by and modified by info
     */
    public SelectQuery toQuery() {
        // where conditions
        if (rootEnreplacedyDefinition != null) {
            selectQuery.addConditions(RECORD.ROOT_ENreplacedY_ID.equal(rootEnreplacedyDefinition.getId()));
        }
        // always order by id to avoid pagination problems
        selectQuery.addOrderBy(RECORD.ID);
        if (LOG.isDebugEnabled()) {
            String sql = selectQuery.toString();
            LOG.debug(sql);
        }
        return selectQuery;
    }

    public void setRootEnreplacedyDefinition(EnreplacedyDefinition rootEnreplacedyDefinition) {
        this.rootEnreplacedyDefinition = rootEnreplacedyDefinition;
    }

    public void addLimit(int offset, int maxNumberOfRecords) {
        selectQuery.addLimit(offset, maxNumberOfRecords);
    }

    /**
     * Adds count columns to the selection to get the count of enreplacedies annotated with counInSummaryList
     */
    public void addCountColumn(EnreplacedyDefinition enreplacedyDefinition) {
        String viewAliasName = COUNT_VIEW_ALIAS_PREFIX + enreplacedyDefinition.getName();
        // left join with ENreplacedY_COUNT_VIEW
        NodeCountView viewAlias = NODE_COUNT_VIEW.as(viewAliasName);
        selectQuery.addJoin(viewAlias, JoinType.LEFT_OUTER_JOIN, viewAlias.RECORD_ID.equal(RECORD.ID), viewAlias.DEFINITION_ID.equal(enreplacedyDefinition.getId()));
        String alias = COUNT_COLUMN_PREFIX + enreplacedyDefinition.getName();
        Field<?> countField = viewAlias.NODE_COUNT.as(alias);
        selectQuery.addSelect(countField);
    }

    /**
     * Adds joins with DATA table to get key attribute values
     */
    public void addKeyAttribute(AttributeDefinition keyAttributeDefinition) {
        // for each key attribute add a left join and a field in the projection
        String dataTableAliasName = KEY_DATA_TABLE_ALIAS_PREFIX + keyAttributeDefinition.getName();
        // left join with DATA table to get the key attribute
        Data dataTableAlias = DATA.as(dataTableAliasName);
        selectQuery.addJoin(dataTableAlias, JoinType.LEFT_OUTER_JOIN, dataTableAlias.RECORD_ID.equal(RECORD.ID), dataTableAlias.DEFINITION_ID.equal(keyAttributeDefinition.getId()));
        TableField<DataRecord, ?> dataField = getKeyValueField(dataTableAlias, keyAttributeDefinition);
        if (dataField != null) {
            // add key field to the projection fields
            Field<?> fieldAlias = dataField.as(KEY_COLUMN_PREFIX + keyAttributeDefinition.getName());
            selectQuery.addSelect(fieldAlias);
        }
    }

    /**
     * Adds order by condition to the select query
     */
    public void addOrderBy(String orderByFieldName) {
        Field<?> orderByField = null;
        if (orderByFieldName != null) {
            if (ORDER_BY_CREATED_BY_FIELD_NAME.equals(orderByFieldName)) {
                orderByField = USER_ACCOUNT.as(USER_TABLE_CREATED_BY_ALIAS).USERNAME;
            } else if (ORDER_BY_MODIFIED_BY_FIELD_NAME.equals(orderByFieldName)) {
                orderByField = USER_ACCOUNT.as(USER_TABLE_MODIFIED_BY_ALIAS).USERNAME;
            } else if (ORDER_BY_DATE_CREATED_FIELD_NAME.equals(orderByFieldName)) {
                orderByField = RECORD.DATE_CREATED;
            } else if (ORDER_BY_DATE_MODIFIED_FIELD_NAME.equals(orderByFieldName)) {
                orderByField = RECORD.DATE_MODIFIED;
            } else if (ORDER_BY_SKIPPED_FIELD_NAME.equals(orderByFieldName)) {
                orderByField = RECORD.SKIPPED;
            } else if (ORDER_BY_MISSING_FIELD_NAME.equals(orderByFieldName)) {
                orderByField = RECORD.MISSING;
            } else if (ORDER_BY_ERRORS_FIELD_NAME.equals(orderByFieldName)) {
                orderByField = RECORD.ERRORS;
            } else if (ORDER_BY_WARNINGS_FIELD_NAME.equals(orderByFieldName)) {
                orderByField = RECORD.WARNINGS;
            } else if (ORDER_BY_MODIFIED_BY_FIELD_NAME.equals(orderByFieldName)) {
                orderByField = USER_ACCOUNT.as(USER_TABLE_MODIFIED_BY_ALIAS).USERNAME;
            } else {
                List<Field<?>> selectFields = selectQuery.getSelect();
                for (Field<?> field : selectFields) {
                    if (orderByFieldName.equals(field.getName())) {
                        orderByField = field;
                        break;
                    }
                }
            }
        }
        if (orderByField != null) {
            selectQuery.addOrderBy(orderByField);
        }
    }

    private TableField<DataRecord, ?> getKeyValueField(Data dataTable, AttributeDefinition attributeDefinition) {
        TableField<DataRecord, ?> dataField = null;
        if (attributeDefinition instanceof CodeAttributeDefinition || attributeDefinition instanceof TextAttributeDefinition) {
            dataField = dataTable.TEXT1;
        } else if (attributeDefinition instanceof NumberAttributeDefinition) {
            dataField = dataTable.NUMBER1;
        }
        return dataField;
    }
}

16 View Complete Implementation : ContestDaoImpl.java
Copyright MIT License
Author : CCI-MIT
@Override
public boolean isContestreplacedleYearUnique(String replacedle, Long year, Long currentContestId) {
    final SelectQuery<Record1<Integer>> query = dslContext.selectCount().from(CONTEST).getQuery();
    query.addConditions(CONTEST.replacedLE.eq(replacedle));
    query.addConditions(CONTEST.CONTEST_YEAR.eq(year));
    if (currentContestId != null) {
        query.addConditions(CONTEST.ID.notEqual(currentContestId));
    }
    return query.fetchOne().into(Integer.clreplaced) == 0;
}

16 View Complete Implementation : ContestDaoImpl.java
Copyright MIT License
Author : CCI-MIT
@Override
public int countByGiven(String contestUrlName, Long contestYear, Boolean active, Boolean featured, List<Long> contestTiers, List<Long> focusAreaIds, Long contestScheduleId, Long proposalTemplateId, List<Long> contestTypeIds, Boolean contestPrivate, String searchTerm) {
    final SelectQuery<Record1<Integer>> query = dslContext.selectCount().from(CONTEST).getQuery();
    addConditions(contestUrlName, contestYear, active, featured, contestTiers, focusAreaIds, contestScheduleId, proposalTemplateId, contestTypeIds, contestPrivate, searchTerm, query);
    return query.fetchOne().into(Integer.clreplaced);
}

16 View Complete Implementation : ContestDaoImpl.java
Copyright MIT License
Author : CCI-MIT
@Override
public List<Long> getContestYears() {
    // select ContestYear from xcolab_Contest group by ContestYear order by ContestYear desc;
    final SelectQuery<Record1<Long>> query = dslContext.select(CONTEST.CONTEST_YEAR).from(CONTEST).getQuery();
    query.addGroupBy(CONTEST.CONTEST_YEAR);
    query.addOrderBy(CONTEST.CONTEST_YEAR.desc());
    return query.fetchInto(Long.clreplaced);
}

16 View Complete Implementation : ContestDiscussionDaoImpl.java
Copyright MIT License
Author : CCI-MIT
@Override
public List<IContestDiscussion> findByGiven(PaginationHelper paginationHelper, Long contestId, String tab) {
    final SelectQuery<Record> query = dslContext.select().from(CONTEST_DISCUSSION).getQuery();
    return query.fetchInto(ContestDiscussion.clreplaced);
}

16 View Complete Implementation : ContestPhaseTypeDaoImpl.java
Copyright MIT License
Author : CCI-MIT
@Override
public List<IContestPhaseType> findByGiven() {
    final SelectQuery<Record> query = dslContext.select().from(CONTEST_PHASE_TYPE).getQuery();
    return query.fetchInto(ContestPhaseType.clreplaced);
}

16 View Complete Implementation : CodeListItemDao.java
Copyright MIT License
Author : openforis
protected static SelectQuery<Record> createSelectChildItemsQuery(JooqDSLContext jf, CodeList codeList, Long parenreplacedemId, boolean addOrderByClause) {
    SelectQuery<Record> q = createSelectFromCodeListQuery(jf, codeList);
    addFilterByParenreplacedemConditions(q, codeList, parenreplacedemId);
    if (addOrderByClause) {
        q.addOrderBy(OFC_CODE_LIST.SORT_ORDER);
    }
    return q;
}

16 View Complete Implementation : ContestScheduleDaoImpl.java
Copyright MIT License
Author : CCI-MIT
@Override
public List<IContestSchedule> findByGiven() {
    final SelectQuery<Record> query = dslContext.select().from(CONTEST_SCHEDULE).getQuery();
    return query.fetchInto(ContestSchedule.clreplaced);
}

16 View Complete Implementation : FocusAreaDaoImpl.java
Copyright MIT License
Author : CCI-MIT
@Override
public List<FocusAreaWrapper> findByGiven() {
    final SelectQuery<Record> query = dslContext.select().from(FOCUS_AREA).getQuery();
    return query.fetchInto(FocusAreaWrapper.clreplaced);
}

16 View Complete Implementation : ImpactTemplateMaxFocusAreaDaoImpl.java
Copyright MIT License
Author : CCI-MIT
@Override
public List<IImpactTemplateMaxFocusArea> findByGiven(Long focusAreaListId) {
    final SelectQuery<Record> query = dslContext.select().from(IMPACT_TEMPLATE_MAX_FOCUS_AREA).getQuery();
    if (focusAreaListId != null) {
        query.addConditions(IMPACT_TEMPLATE_MAX_FOCUS_AREA.FOCUS_AREA_LIST_ID.eq(focusAreaListId));
    }
    return query.fetchInto(ImpactTemplateMaxFocusArea.clreplaced);
}

16 View Complete Implementation : OntologySpaceDaoImpl.java
Copyright MIT License
Author : CCI-MIT
@Override
public List<OntologySpaceWrapper> findByGiven() {
    final SelectQuery<Record> query = dslContext.select().from(ONTOLOGY_SPACE).getQuery();
    return query.fetchInto(OntologySpaceWrapper.clreplaced);
}

16 View Complete Implementation : ProposalTemplateDaoImpl.java
Copyright MIT License
Author : CCI-MIT
@Override
public List<IProposalTemplate> findByGiven() {
    final SelectQuery<Record> query = dslContext.select().from(PROPOSAL_TEMPLATE).getQuery();
    return query.fetchInto(ProposalTemplate.clreplaced);
}

16 View Complete Implementation : ProposalRatingValueDaoImpl.java
Copyright MIT License
Author : CCI-MIT
@Override
public List<IProposalRatingValue> findByGiven(Long ratingTypeId) {
    final SelectQuery<Record> query = dslContext.select().from(PROPOSAL_RATING_VALUE).getQuery();
    if (ratingTypeId != null) {
        query.addConditions(PROPOSAL_RATING_VALUE.RATING_TYPE_ID.eq(ratingTypeId));
    }
    return query.fetchInto(ProposalRatingValue.clreplaced);
}

16 View Complete Implementation : SearchDaoImpl.java
Copyright MIT License
Author : CCI-MIT
private Integer getTotalForCount(String query, TableImpl table, Collection<? extends Condition> conditions, Field... fields) {
    SelectQuery<Record1<Integer>> rec = getQueryForCount(query, table, fields);
    rec.addConditions(conditions);
    Integer ret = rec.fetchOne().into(Integer.clreplaced);
    if (ret == null) {
        return 0;
    } else {
        return ret;
    }
}

16 View Complete Implementation : UserDaoImpl.java
Copyright MIT License
Author : CCI-MIT
@Override
public List<UserWrapper> findByIp(String ip) {
    final SelectQuery<Record> query = dslContext.selectDistinct(USER.fields()).from(USER).join(LOGIN_LOG).on(LOGIN_LOG.USER_ID.equal(USER.ID)).where(LOGIN_LOG.IP_ADDRESS.eq(ip)).getQuery();
    return query.fetchInto(UserWrapper.clreplaced);
}

15 View Complete Implementation : ImpactDefaultSeriesDataDaoImpl.java
Copyright MIT License
Author : CCI-MIT
@Override
public List<IImpactDefaultSeriesData> findByGiven(Long seriesId, Integer year) {
    final SelectQuery<Record> query = dslContext.select().from(IMPACT_DEFAULT_SERIES_DATA).getQuery();
    if (seriesId != null) {
        query.addConditions(IMPACT_DEFAULT_SERIES_DATA.SERIES_ID.eq(seriesId));
    }
    if (seriesId != null) {
        query.addConditions(IMPACT_DEFAULT_SERIES_DATA.YEAR.eq(year));
    }
    return query.fetchInto(ImpactDefaultSeriesData.clreplaced);
}

15 View Complete Implementation : ImpactIterationDaoImpl.java
Copyright MIT License
Author : CCI-MIT
@Override
public List<IImpacreplacederation> findByGiven(Long iterationId) {
    final SelectQuery<Record> query = dslContext.select().from(IMPACT_ITERATION).getQuery();
    if (iterationId != null) {
        query.addConditions(IMPACT_ITERATION.ITERATION_ID.eq(iterationId));
    }
    return query.fetchInto(Impacreplacederation.clreplaced);
}

15 View Complete Implementation : ProposalVersionDaoImpl.java
Copyright MIT License
Author : CCI-MIT
@Override
public int countByGiven(Long proposalId) {
    final SelectQuery<Record1<Integer>> query = dslContext.selectCount().from(PROPOSAL_VERSION).where(PROPOSAL_VERSION.PROPOSAL_ID.eq(proposalId)).getQuery();
    return query.fetchOne().into(Integer.clreplaced);
}

15 View Complete Implementation : UserDaoImpl.java
Copyright MIT License
Author : CCI-MIT
@Override
public List<UserWrapper> findByScreenNameName(String name) {
    final SelectQuery<Record> query = dslContext.select().from(USER).where(USER.SCREEN_NAME.like("%" + name + "%")).or(USER.FIRST_NAME.like("%" + name + "%")).and(USER.STATUS.eq(0)).orderBy(USER.SCREEN_NAME).getQuery();
    return query.fetchInto(UserWrapper.clreplaced);
}

15 View Complete Implementation : MappingJooqDaoSupport.java
Copyright MIT License
Author : openforis
public List<E> findContaining(TableField<?, String> field, String searchString, int maxResults) {
    C dsl = dsl();
    SelectQuery<?> query = dsl.selectContainsQuery(field, searchString);
    query.addLimit(maxResults);
    query.execute();
    Result<?> result = query.getResult();
    List<E> enreplacedies = dsl.fromResult(result);
    return enreplacedies;
}

15 View Complete Implementation : MappingJooqDaoSupport.java
Copyright MIT License
Author : openforis
public List<E> findStartingWith(TableField<?, String> field, String searchString, int maxResults) {
    C dsl = dsl();
    SelectQuery<?> query = dsl.selectStartsWithQuery(field, searchString);
    query.addLimit(maxResults);
    query.execute();
    Result<?> result = query.getResult();
    List<E> enreplacedies = dsl.fromResult(result);
    return enreplacedies;
}

15 View Complete Implementation : RecordDao.java
Copyright MIT License
Author : openforis
public void visitSummaries(RecordFilter filter, List<RecordSummarySortField> sortFields, Visitor<CollectRecordSummary> visitor, boolean includeStepDetails, Predicate<CollectRecordSummary> stopWhenPredicate) {
    SelectQuery<Record> q = createSelectSummariesQuery(filter, sortFields);
    Cursor<Record> cursor = null;
    try {
        cursor = q.fetchLazy();
        while (cursor.hasNext()) {
            Record r = cursor.fetchOne();
            CollectRecordSummary s = fromSummaryQueryRecord(filter.getSurvey(), r);
            if (includeStepDetails) {
                s.clearStepSummaries();
                Map<Step, StepSummary> summaryByStep = loadLatestStepSummaries(filter.getSurvey(), s.getId());
                for (Step step : Step.values()) {
                    StepSummary stepSummary = summaryByStep.get(step);
                    if (stepSummary != null) {
                        s.addStepSummary(stepSummary);
                    }
                }
            }
            visitor.visit(s);
            if (stopWhenPredicate != null && stopWhenPredicate.evaluate(s)) {
                break;
            }
        }
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }
}

15 View Complete Implementation : SamplingDesignDao.java
Copyright MIT License
Author : openforis
private SelectQuery<Record> createSelecreplacedemsQuery(SamplingDesignDSLContext dsl, int surveyId, Integer upToLevel) {
    SelectQuery<Record> q = dsl.selectQuery();
    q.addFrom(OFC_SAMPLING_DESIGN);
    q.addConditions(OFC_SAMPLING_DESIGN.SURVEY_ID.equal(surveyId));
    addLevelKeyNullConditions(q, upToLevel);
    q.addOrderBy(OFC_SAMPLING_DESIGN.ID);
    return q;
}

15 View Complete Implementation : SamplingDesignDao.java
Copyright MIT License
Author : openforis
public SamplingDesignItem loadItem(int surveyId, String... parentKeys) {
    SamplingDesignDSLContext dsl = dsl();
    SelectQuery<Record> q = dsl.selectQuery();
    q.addFrom(OFC_SAMPLING_DESIGN);
    q.addConditions(OFC_SAMPLING_DESIGN.SURVEY_ID.equal(surveyId));
    addParentKeysConditions(q, parentKeys);
    int nextLevelIndex = parentKeys == null ? 0 : parentKeys.length;
    addLevelKeyNullConditions(q, nextLevelIndex);
    Record r = q.fetchAny();
    return r == null ? null : dsl.fromRecord(r);
}

15 View Complete Implementation : SamplingDesignDao.java
Copyright MIT License
Author : openforis
public int countBySurvey(int surveyId) {
    SelectQuery<?> q = dsl().selectCountQuery();
    q.addConditions(OFC_SAMPLING_DESIGN.SURVEY_ID.equal(surveyId));
    Record r = q.fetchOne();
    return (Integer) r.getValue(0);
}

14 View Complete Implementation : ContentPageDaoImpl.java
Copyright MIT License
Author : CCI-MIT
@Override
public List<IContentPage> list(String replacedle) {
    final SelectQuery<Record> query = dslContext.select().from(CONTENT_PAGE).getQuery();
    if (replacedle != null && !replacedle.isEmpty()) {
        query.addConditions(CONTENT_PAGE.replacedLE.eq(replacedle));
    }
    return query.fetch().into(ContentPage.clreplaced);
}

14 View Complete Implementation : FocusAreaOntologyTermDaoImpl.java
Copyright MIT License
Author : CCI-MIT
@Override
public List<IFocusAreaOntologyTerm> findByOntologyTermIds(List<Long> ontologyTermId) {
    final SelectQuery<Record> query = dslContext.select().from(FOCUS_AREA_ONTOLOGY_TERM).getQuery();
    if (ontologyTermId != null) {
        query.addConditions(FOCUS_AREA_ONTOLOGY_TERM.ONTOLOGY_TERM_ID.in(ontologyTermId));
    }
    return query.fetchInto(FocusAreaOntologyTerm.clreplaced);
}

14 View Complete Implementation : ImpactDefaultSeriesDaoImpl.java
Copyright MIT License
Author : CCI-MIT
@Override
public List<IImpactDefaultSeries> findByGiven(Long focusAreaId, String name) {
    final SelectQuery<Record> query = dslContext.select().from(IMPACT_DEFAULT_SERIES).getQuery();
    if (focusAreaId != null) {
        query.addConditions(IMPACT_DEFAULT_SERIES.FOCUS_AREA_ID.eq(focusAreaId));
    }
    if (name != null) {
        query.addConditions(IMPACT_DEFAULT_SERIES.NAME.eq(name));
    }
    return query.fetchInto(ImpactDefaultSeries.clreplaced);
}

14 View Complete Implementation : ProposalDaoImpl.java
Copyright MIT License
Author : CCI-MIT
@Override
public List<ProposalWrapper> filterByGiven(Collection<Long> proposalIds, Boolean visible, Boolean contestPrivate) {
    final SelectQuery<Record> query = dslContext.selectDistinct(PROPOSAL.fields()).from(PROPOSAL).where(PROPOSAL.ID.in(proposalIds)).getQuery();
    final boolean requiresContest = contestPrivate != null;
    final boolean requiresPhase = visible != null;
    addJoins(query, requiresContest, requiresPhase);
    addVisibilityConditions(visible, contestPrivate, query);
    return query.fetchInto(ProposalWrapper.clreplaced);
}