use of io.github.jklingsporn.vertx.jooq.shared.internal.QueryResult in project mod-source-record-storage by folio-org.
the class RecordDaoImpl method toMarcBibCollection.
private MarcBibCollection toMarcBibCollection(QueryResult result) {
MarcBibCollection marcBibCollection = new MarcBibCollection();
List<String> ids = new ArrayList<>();
result.stream().map(res -> asRow(res.unwrap())).forEach(row -> ids.add(row.getString(HRID)));
if (!ids.isEmpty()) {
marcBibCollection.withInvalidMarcBibIds(ids);
}
return marcBibCollection;
}
use of io.github.jklingsporn.vertx.jooq.shared.internal.QueryResult in project mod-source-record-storage by folio-org.
the class RecordDaoImpl method getRecords.
@Override
public Future<RecordCollection> getRecords(Condition condition, RecordType recordType, Collection<OrderField<?>> orderFields, int offset, int limit, String tenantId) {
Name cte = name(CTE);
Name prt = name(recordType.getTableName());
return getQueryExecutor(tenantId).transaction(txQE -> txQE.query(dsl -> dsl.with(cte.as(dsl.selectCount().from(RECORDS_LB).where(condition.and(recordType.getRecordImplicitCondition())))).select(getAllRecordFieldsWithCount(prt)).from(RECORDS_LB).leftJoin(table(prt)).on(RECORDS_LB.ID.eq(field(TABLE_FIELD_TEMPLATE, UUID.class, prt, name(ID)))).leftJoin(RAW_RECORDS_LB).on(RECORDS_LB.ID.eq(RAW_RECORDS_LB.ID)).leftJoin(ERROR_RECORDS_LB).on(RECORDS_LB.ID.eq(ERROR_RECORDS_LB.ID)).rightJoin(dsl.select().from(table(cte))).on(trueCondition()).where(condition.and(recordType.getRecordImplicitCondition())).orderBy(orderFields).offset(offset).limit(limit > 0 ? limit : DEFAULT_LIMIT_FOR_GET_RECORDS))).map(queryResult -> toRecordCollectionWithLimitCheck(queryResult, limit));
}
use of io.github.jklingsporn.vertx.jooq.shared.internal.QueryResult in project mod-source-record-storage by folio-org.
the class RecordDaoImpl method toSourceRecordCollection.
private SourceRecordCollection toSourceRecordCollection(QueryResult result) {
SourceRecordCollection sourceRecordCollection = new SourceRecordCollection().withTotalRecords(0);
List<SourceRecord> sourceRecords = result.stream().map(res -> asRow(res.unwrap())).map(row -> {
sourceRecordCollection.setTotalRecords(row.getInteger(COUNT));
return RecordDaoUtil.toSourceRecord(RecordDaoUtil.toRecord(row)).withParsedRecord(ParsedRecordDaoUtil.toParsedRecord(row));
}).collect(Collectors.toList());
if (!sourceRecords.isEmpty() && Objects.nonNull(sourceRecords.get(0).getRecordId())) {
sourceRecordCollection.withSourceRecords(sourceRecords);
}
return sourceRecordCollection;
}
use of io.github.jklingsporn.vertx.jooq.shared.internal.QueryResult in project mod-source-record-storage by folio-org.
the class RecordDaoImpl method toRecordCollection.
private RecordCollection toRecordCollection(QueryResult result) {
RecordCollection recordCollection = new RecordCollection().withTotalRecords(0);
List<Record> records = result.stream().map(res -> asRow(res.unwrap())).map(row -> {
recordCollection.setTotalRecords(row.getInteger(COUNT));
return toRecord(row);
}).collect(Collectors.toList());
if (!records.isEmpty() && Objects.nonNull(records.get(0).getId())) {
recordCollection.withRecords(records);
}
return recordCollection;
}
use of io.github.jklingsporn.vertx.jooq.shared.internal.QueryResult in project mod-source-record-storage by folio-org.
the class RecordDaoImpl method getMatchedRecords.
public Future<List<Record>> getMatchedRecords(MatchField matchedField, TypeConnection typeConnection, int offset, int limit, String tenantId) {
Name prt = name(typeConnection.getDbType().getTableName());
Table marcIndexersPartitionTable = table(name("marc_indexers_" + matchedField.getTag()));
return getQueryExecutor(tenantId).transaction(txQE -> txQE.query(dsl -> dsl.select(getAllRecordFields(prt)).from(RECORDS_LB).leftJoin(table(prt)).on(RECORDS_LB.ID.eq(field(TABLE_FIELD_TEMPLATE, UUID.class, prt, name(ID)))).leftJoin(RAW_RECORDS_LB).on(RECORDS_LB.ID.eq(RAW_RECORDS_LB.ID)).leftJoin(ERROR_RECORDS_LB).on(RECORDS_LB.ID.eq(ERROR_RECORDS_LB.ID)).innerJoin(marcIndexersPartitionTable).on(RECORDS_LB.ID.eq(field(TABLE_FIELD_TEMPLATE, UUID.class, marcIndexersPartitionTable, name(MARC_ID)))).where(filterRecordByType(typeConnection.getRecordType().value()).and(filterRecordByState(Record.State.ACTUAL.value())).and(getMatchedFieldCondition(matchedField, marcIndexersPartitionTable.getName()))).offset(offset).limit(limit > 0 ? limit : DEFAULT_LIMIT_FOR_GET_RECORDS))).map(queryResult -> queryResult.stream().map(res -> asRow(res.unwrap())).map(this::toRecord).collect(Collectors.toList()));
}
Aggregations