use of org.folio.rest.jooq.tables.RequestMetadataLb.REQUEST_METADATA_LB in project mod-oai-pmh by folio-org.
the class InstancesDaoImpl method updateRequestUpdatedDate.
@Override
public Future<RequestMetadataLb> updateRequestUpdatedDate(String requestId, OffsetDateTime lastUpdatedDate, String tenantId) {
RequestMetadataLb requestMetadataLb = new RequestMetadataLb();
requestMetadataLb.setRequestId(UUID.fromString(requestId)).setLastUpdatedDate(lastUpdatedDate);
return getQueryExecutor(tenantId).transaction(queryExecutor -> queryExecutor.executeAny(dslContext -> dslContext.update(REQUEST_METADATA_LB).set(REQUEST_METADATA_LB.LAST_UPDATED_DATE, lastUpdatedDate).where(REQUEST_METADATA_LB.REQUEST_ID.eq(UUID.fromString(requestId))).returning()).map(this::toOptionalRequestMetadata).map(optional -> {
if (optional.isPresent()) {
return optional.get();
}
throw new NotFoundException(String.format(REQUEST_METADATA_WITH_ID_DOES_NOT_EXIST, requestId));
}));
}
use of org.folio.rest.jooq.tables.RequestMetadataLb.REQUEST_METADATA_LB in project mod-oai-pmh by folio-org.
the class InstancesDaoImpl method saveRequestMetadata.
@Override
public Future<RequestMetadataLb> saveRequestMetadata(RequestMetadataLb requestMetadata, String tenantId) {
UUID uuid = requestMetadata.getRequestId();
requestMetadata.setStreamEnded(false);
if (Objects.isNull(uuid) || StringUtils.isEmpty(uuid.toString())) {
return Future.failedFuture(new IllegalStateException("Cannot save request metadata, request metadata entity must contain requestId"));
}
return getQueryExecutor(tenantId).transaction(queryExecutor -> queryExecutor.executeAny(dslContext -> dslContext.insertInto(REQUEST_METADATA_LB).set(toDatabaseRecord(requestMetadata))).map(raw -> requestMetadata));
}
Aggregations