Search in sources :

Example 1 with AV_CLOB

use of usace.cwms.db.jooq.codegen.tables.AV_CLOB in project cwms-radar-api by USACE.

the class ClobDao method getAll.

// Yikes, I hate this method - it retrieves all the clobs?  That could be gigabytes of data.
// Not returning Value or Desc fields until a useful way of working with this method is figured out.
@Override
public List<Clob> getAll(Optional<String> limitToOffice) {
    AV_CLOB ac = AV_CLOB.AV_CLOB;
    AV_OFFICE ao = AV_OFFICE.AV_OFFICE;
    SelectJoinStep<Record2<String, String>> joinStep = dsl.select(ac.ID, ao.OFFICE_ID).from(ac.join(ao).on(ac.OFFICE_CODE.eq(ao.OFFICE_CODE)));
    Select<Record2<String, String>> select = joinStep;
    if (limitToOffice.isPresent()) {
        String office = limitToOffice.get();
        if (office != null && !office.isEmpty()) {
            SelectConditionStep<Record2<String, String>> conditionStep = joinStep.where(ao.OFFICE_ID.eq(office));
            select = conditionStep;
        }
    }
    RecordMapper<Record2<String, String>, Clob> mapper = joinRecord -> new Clob(joinRecord.get(ao.OFFICE_ID), joinRecord.get(ac.ID), null, null);
    return select.fetch(mapper);
}
Also used : SelectJoinStep(org.jooq.SelectJoinStep) Clob(cwms.radar.data.dto.Clob) DSL(org.jooq.impl.DSL) RecordMapper(org.jooq.RecordMapper) DSL.count(org.jooq.impl.DSL.count) Table(org.jooq.Table) Clobs(cwms.radar.data.dto.Clobs) ParamType(org.jooq.conf.ParamType) Condition(org.jooq.Condition) SelectLimitPercentStep(org.jooq.SelectLimitPercentStep) Record4(org.jooq.Record4) SelectConditionStep(org.jooq.SelectConditionStep) Record2(org.jooq.Record2) AV_OFFICE(usace.cwms.db.jooq.codegen.tables.AV_OFFICE) Record1(org.jooq.Record1) DSLContext(org.jooq.DSLContext) Select(org.jooq.Select) AV_CLOB(usace.cwms.db.jooq.codegen.tables.AV_CLOB) DSL.inline(org.jooq.impl.DSL.inline) Record(org.jooq.Record) DSL.asterisk(org.jooq.impl.DSL.asterisk) Logger(java.util.logging.Logger) List(java.util.List) Catalog(cwms.radar.data.dto.Catalog) TableField(org.jooq.TableField) SQLDataType(org.jooq.impl.SQLDataType) Optional(java.util.Optional) Office(cwms.radar.data.dto.Office) AV_CLOB(usace.cwms.db.jooq.codegen.tables.AV_CLOB) AV_OFFICE(usace.cwms.db.jooq.codegen.tables.AV_OFFICE) Clob(cwms.radar.data.dto.Clob) Record2(org.jooq.Record2)

Example 2 with AV_CLOB

use of usace.cwms.db.jooq.codegen.tables.AV_CLOB in project cwms-radar-api by USACE.

the class ClobDao method getClobValue.

public String getClobValue(String office, String id) {
    AV_CLOB ac = AV_CLOB.AV_CLOB;
    AV_OFFICE ao = AV_OFFICE.AV_OFFICE;
    Condition cond = ac.ID.eq(id).and(ao.OFFICE_ID.eq(office));
    Record1<String> clobRecord = dsl.select(ac.VALUE).from(ac.join(ao).on(ac.OFFICE_CODE.eq(ao.OFFICE_CODE))).where(cond).fetchOne();
    return clobRecord.value1();
}
Also used : Condition(org.jooq.Condition) AV_CLOB(usace.cwms.db.jooq.codegen.tables.AV_CLOB) AV_OFFICE(usace.cwms.db.jooq.codegen.tables.AV_OFFICE)

Example 3 with AV_CLOB

use of usace.cwms.db.jooq.codegen.tables.AV_CLOB in project cwms-radar-api by USACE.

the class ClobDao method getByUniqueName.

@Override
public Optional<Clob> getByUniqueName(String uniqueName, Optional<String> limitToOffice) {
    AV_CLOB ac = AV_CLOB.AV_CLOB;
    AV_OFFICE ao = AV_OFFICE.AV_OFFICE;
    Condition cond = ac.ID.eq(uniqueName);
    if (limitToOffice.isPresent()) {
        String office = limitToOffice.get();
        if (office != null && !office.isEmpty()) {
            cond = cond.and(ao.OFFICE_ID.eq(office));
        }
    }
    RecordMapper<Record, Clob> mapper = joinRecord -> new Clob(joinRecord.getValue(ao.OFFICE_ID), joinRecord.getValue(ac.ID), joinRecord.getValue(ac.DESCRIPTION), joinRecord.getValue(ac.VALUE));
    Clob avClob = dsl.select(ao.OFFICE_ID, ac.asterisk()).from(ac.join(ao).on(ac.OFFICE_CODE.eq(ao.OFFICE_CODE))).where(cond).fetchOne(mapper);
    return Optional.ofNullable(avClob);
}
Also used : Condition(org.jooq.Condition) SelectJoinStep(org.jooq.SelectJoinStep) Clob(cwms.radar.data.dto.Clob) DSL(org.jooq.impl.DSL) RecordMapper(org.jooq.RecordMapper) DSL.count(org.jooq.impl.DSL.count) Table(org.jooq.Table) Clobs(cwms.radar.data.dto.Clobs) ParamType(org.jooq.conf.ParamType) Condition(org.jooq.Condition) SelectLimitPercentStep(org.jooq.SelectLimitPercentStep) Record4(org.jooq.Record4) SelectConditionStep(org.jooq.SelectConditionStep) Record2(org.jooq.Record2) AV_OFFICE(usace.cwms.db.jooq.codegen.tables.AV_OFFICE) Record1(org.jooq.Record1) DSLContext(org.jooq.DSLContext) Select(org.jooq.Select) AV_CLOB(usace.cwms.db.jooq.codegen.tables.AV_CLOB) DSL.inline(org.jooq.impl.DSL.inline) Record(org.jooq.Record) DSL.asterisk(org.jooq.impl.DSL.asterisk) Logger(java.util.logging.Logger) List(java.util.List) Catalog(cwms.radar.data.dto.Catalog) TableField(org.jooq.TableField) SQLDataType(org.jooq.impl.SQLDataType) Optional(java.util.Optional) Office(cwms.radar.data.dto.Office) AV_CLOB(usace.cwms.db.jooq.codegen.tables.AV_CLOB) AV_OFFICE(usace.cwms.db.jooq.codegen.tables.AV_OFFICE) Record(org.jooq.Record) Clob(cwms.radar.data.dto.Clob)

Example 4 with AV_CLOB

use of usace.cwms.db.jooq.codegen.tables.AV_CLOB in project cwms-radar-api by USACE.

the class ClobDao method getClobs.

public Clobs getClobs(String cursor, int pageSize, Optional<String> office, boolean includeValues, String like) {
    int total = 0;
    String clobCursor = "*";
    AV_CLOB v_clob = AV_CLOB.AV_CLOB;
    AV_OFFICE v_office = AV_OFFICE.AV_OFFICE;
    if (cursor == null || cursor.isEmpty()) {
        SelectConditionStep<Record1<Integer>> count = dsl.select(count(asterisk())).from(v_clob).join(v_office).on(v_clob.OFFICE_CODE.eq(v_office.OFFICE_CODE)).where(v_clob.ID.upper().likeRegex(like.toUpperCase())).and(v_office.OFFICE_ID.upper().like(office.isPresent() ? office.get().toUpperCase() : "%"));
        total = count.fetchOne().value1().intValue();
    } else {
        String[] parts = Catalog.decodeCursor(cursor, "||");
        logger.fine("decoded cursor: " + String.join("||", parts));
        for (String p : parts) {
            logger.finest(p);
        }
        if (parts.length > 1) {
            clobCursor = parts[0].split(";")[0];
            // ditch the officeId that's embedded in
            clobCursor = clobCursor.substring(clobCursor.indexOf("/") + 1);
            total = Integer.parseInt(parts[1]);
            pageSize = Integer.parseInt(parts[2]);
        }
    }
    /*
		Table<?> forLimit = dsl.select(v_clob.ID,v_office.OFFICE_ID)
							   .from(v_clob)
							   .join(v_office).on(v_clob.OFFICE_CODE.eq(v_office.OFFICE_CODE))
							   .where(v_clob.ID.likeRegex(like))
							   .and(v_office.OFFICE_ID.like( office.isPresent() ? office.get() : "%"))
							   .and(v_clob.ID.upper().greaterThan(clobCursor))
							   .orderBy(v_clob.ID).limit(pageSize).asTable();*/
    SelectLimitPercentStep<Record4<String, String, String, String>> query = dsl.select(v_office.OFFICE_ID, v_clob.ID, v_clob.DESCRIPTION, includeValues == true ? v_clob.VALUE : DSL.inline("").as(v_clob.VALUE)).from(v_clob).join(v_office).on(v_clob.OFFICE_CODE.eq(v_office.OFFICE_CODE)).where(v_clob.ID.upper().likeRegex(like.toUpperCase())).and(v_clob.ID.upper().greaterThan(clobCursor)).orderBy(v_clob.ID).limit(pageSize);
    ;
    Clobs.Builder builder = new Clobs.Builder(clobCursor, pageSize, total);
    logger.finest(() -> {
        return query.getSQL(ParamType.INLINED);
    });
    query.fetch().forEach(row -> {
        usace.cwms.db.jooq.codegen.tables.records.AV_CLOB clob = row.into(v_clob);
        usace.cwms.db.jooq.codegen.tables.records.AV_OFFICE clobOffice = row.into(v_office);
        builder.addClob(new Clob(clobOffice.getOFFICE_ID(), clob.getID(), clob.getDESCRIPTION(), clob.getVALUE()));
    });
    return builder.build();
}
Also used : Clobs(cwms.radar.data.dto.Clobs) AV_CLOB(usace.cwms.db.jooq.codegen.tables.AV_CLOB) AV_OFFICE(usace.cwms.db.jooq.codegen.tables.AV_OFFICE) Record4(org.jooq.Record4) Clob(cwms.radar.data.dto.Clob) Record1(org.jooq.Record1)

Example 5 with AV_CLOB

use of usace.cwms.db.jooq.codegen.tables.AV_CLOB in project cwms-radar-api by USACE.

the class ClobDao method getClobsLike.

public List<Clob> getClobsLike(String office, String idLike) {
    AV_CLOB ac = AV_CLOB.AV_CLOB;
    AV_OFFICE ao = AV_OFFICE.AV_OFFICE;
    Condition cond = ac.ID.upper().like(idLike.toUpperCase());
    if (office != null && !office.isEmpty()) {
        cond = cond.and(ao.OFFICE_ID.upper().eq(office.toUpperCase()));
    }
    RecordMapper<Record, Clob> mapper = joinRecord -> new Clob(joinRecord.get(ao.OFFICE_ID), joinRecord.get(ac.ID), joinRecord.get(ac.DESCRIPTION), joinRecord.get(ac.VALUE));
    return dsl.select(ac.asterisk(), ao.OFFICE_ID).from(ac.join(ao).on(ac.OFFICE_CODE.eq(ao.OFFICE_CODE))).where(cond).fetch(mapper);
}
Also used : Condition(org.jooq.Condition) SelectJoinStep(org.jooq.SelectJoinStep) Clob(cwms.radar.data.dto.Clob) DSL(org.jooq.impl.DSL) RecordMapper(org.jooq.RecordMapper) DSL.count(org.jooq.impl.DSL.count) Table(org.jooq.Table) Clobs(cwms.radar.data.dto.Clobs) ParamType(org.jooq.conf.ParamType) Condition(org.jooq.Condition) SelectLimitPercentStep(org.jooq.SelectLimitPercentStep) Record4(org.jooq.Record4) SelectConditionStep(org.jooq.SelectConditionStep) Record2(org.jooq.Record2) AV_OFFICE(usace.cwms.db.jooq.codegen.tables.AV_OFFICE) Record1(org.jooq.Record1) DSLContext(org.jooq.DSLContext) Select(org.jooq.Select) AV_CLOB(usace.cwms.db.jooq.codegen.tables.AV_CLOB) DSL.inline(org.jooq.impl.DSL.inline) Record(org.jooq.Record) DSL.asterisk(org.jooq.impl.DSL.asterisk) Logger(java.util.logging.Logger) List(java.util.List) Catalog(cwms.radar.data.dto.Catalog) TableField(org.jooq.TableField) SQLDataType(org.jooq.impl.SQLDataType) Optional(java.util.Optional) Office(cwms.radar.data.dto.Office) AV_CLOB(usace.cwms.db.jooq.codegen.tables.AV_CLOB) AV_OFFICE(usace.cwms.db.jooq.codegen.tables.AV_OFFICE) Record(org.jooq.Record) Clob(cwms.radar.data.dto.Clob)

Aggregations

AV_CLOB (usace.cwms.db.jooq.codegen.tables.AV_CLOB)5 AV_OFFICE (usace.cwms.db.jooq.codegen.tables.AV_OFFICE)5 Clob (cwms.radar.data.dto.Clob)4 Clobs (cwms.radar.data.dto.Clobs)4 Condition (org.jooq.Condition)4 Record1 (org.jooq.Record1)4 Record4 (org.jooq.Record4)4 Catalog (cwms.radar.data.dto.Catalog)3 Office (cwms.radar.data.dto.Office)3 List (java.util.List)3 Optional (java.util.Optional)3 Logger (java.util.logging.Logger)3 DSLContext (org.jooq.DSLContext)3 Record (org.jooq.Record)3 Record2 (org.jooq.Record2)3 RecordMapper (org.jooq.RecordMapper)3 Select (org.jooq.Select)3 SelectConditionStep (org.jooq.SelectConditionStep)3 SelectJoinStep (org.jooq.SelectJoinStep)3 SelectLimitPercentStep (org.jooq.SelectLimitPercentStep)3