Search in sources :

Example 1 with SelectConditionStep

use of org.jooq.SelectConditionStep in project collect by openforis.

the class TaxonVernacularNameDao method findByVernacularName.

public List<TaxonVernacularName> findByVernacularName(int taxonomyId, String searchString, String[] qualifierValues, int maxResults) {
    TaxonVernacularNameDSLContext dsl = dsl();
    // find containing
    searchString = "%" + searchString.toLowerCase(Locale.ENGLISH) + "%";
    SelectConditionStep selectConditionStep = dsl.select(OFC_TAXON_VERNACULAR_NAME.fields()).from(OFC_TAXON_VERNACULAR_NAME).join(OFC_TAXON).on(OFC_TAXON.ID.equal(OFC_TAXON_VERNACULAR_NAME.TAXON_ID)).where(OFC_TAXON.TAXONOMY_ID.equal(taxonomyId).and(DSL.lower(OFC_TAXON_VERNACULAR_NAME.VERNACULAR_NAME).like(searchString)));
    if (qualifierValues != null) {
        for (int i = 0; i < qualifierValues.length; i++) {
            String value = qualifierValues[i];
            if (value != null) {
                TableField field = QUALIFIER_FIELDS[i];
                selectConditionStep.and(field.equal(value));
            }
        }
    }
    selectConditionStep.limit(maxResults);
    Result<?> result = selectConditionStep.fetch();
    List<TaxonVernacularName> entities = dsl.fromResult(result);
    return entities;
}
Also used : SelectConditionStep(org.jooq.SelectConditionStep) TaxonVernacularName(org.openforis.idm.model.species.TaxonVernacularName) TableField(org.jooq.TableField)

Example 2 with SelectConditionStep

use of org.jooq.SelectConditionStep in project collect by openforis.

the class TaxonVernacularNameDao method findByTaxon.

public List<TaxonVernacularName> findByTaxon(int taxonId) {
    TaxonVernacularNameDSLContext dsl = dsl();
    SelectConditionStep selectConditionStep = dsl.select(OFC_TAXON_VERNACULAR_NAME.fields()).from(OFC_TAXON_VERNACULAR_NAME).where(OFC_TAXON_VERNACULAR_NAME.TAXON_ID.equal(taxonId));
    Result<?> result = selectConditionStep.fetch();
    List<TaxonVernacularName> entities = dsl.fromResult(result);
    return entities;
}
Also used : SelectConditionStep(org.jooq.SelectConditionStep) TaxonVernacularName(org.openforis.idm.model.species.TaxonVernacularName)

Example 3 with SelectConditionStep

use of org.jooq.SelectConditionStep in project collect by openforis.

the class TaxonVernacularNameDao method deleteByTaxonomy.

public void deleteByTaxonomy(int taxonomyId) {
    TaxonVernacularNameDSLContext dsl = dsl();
    SelectConditionStep selectTaxonIds = dsl.select(OFC_TAXON.ID).from(OFC_TAXON).where(OFC_TAXON.TAXONOMY_ID.equal(taxonomyId));
    dsl.delete(OFC_TAXON_VERNACULAR_NAME).where(OFC_TAXON_VERNACULAR_NAME.TAXON_ID.in(selectTaxonIds)).execute();
}
Also used : SelectConditionStep(org.jooq.SelectConditionStep)

Aggregations

SelectConditionStep (org.jooq.SelectConditionStep)3 TaxonVernacularName (org.openforis.idm.model.species.TaxonVernacularName)2 TableField (org.jooq.TableField)1