use of io.github.jklingsporn.vertx.jooq.classic.reactivepg.ReactiveClassicGenericQueryExecutor in project mod-source-record-storage by folio-org.
the class DataImportConsumersVerticleTest method setUp.
@Before
public void setUp(TestContext context) throws IOException {
WireMock.stubFor(get(new UrlPathPattern(new RegexPattern(MAPPING_METADATA_URL + "/.*"), true)).willReturn(WireMock.ok().withBody(Json.encode(new MappingMetadataDto().withMappingParams(Json.encode(new MappingParameters()))))));
RawRecord rawRecord = new RawRecord().withId(recordId).withContent(new ObjectMapper().readValue(TestUtil.readFileFromPath(RAW_MARC_RECORD_CONTENT_SAMPLE_PATH), String.class));
ParsedRecord parsedRecord = new ParsedRecord().withId(recordId).withContent(PARSED_CONTENT);
Snapshot snapshot = new Snapshot().withJobExecutionId(snapshotId).withProcessingStartedDate(new Date()).withStatus(Snapshot.Status.COMMITTED);
record = new Record().withId(recordId).withSnapshotId(snapshot.getJobExecutionId()).withGeneration(0).withMatchedId(recordId).withRecordType(MARC_BIB).withRawRecord(rawRecord).withParsedRecord(parsedRecord).withExternalIdsHolder(new ExternalIdsHolder().withAuthorityId(UUID.randomUUID().toString()));
ReactiveClassicGenericQueryExecutor queryExecutor = postgresClientFactory.getQueryExecutor(TENANT_ID);
RecordDaoImpl recordDao = new RecordDaoImpl(postgresClientFactory);
SnapshotDaoUtil.save(queryExecutor, snapshot).compose(v -> recordDao.saveRecord(record, TENANT_ID)).onComplete(context.asyncAssertSuccess());
}
use of io.github.jklingsporn.vertx.jooq.classic.reactivepg.ReactiveClassicGenericQueryExecutor in project mod-source-record-storage by folio-org.
the class RecordCleanupServiceTest method after.
@After
public void after(TestContext testContext) throws InterruptedException {
Async async = testContext.async();
ReactiveClassicGenericQueryExecutor queryExecutor = postgresClientFactory.getQueryExecutor(TENANT_ID);
SnapshotDaoUtil.delete(queryExecutor, snapshot.getJobExecutionId()).compose(ar -> recordService.deleteRecordsBySnapshotId(snapshot.getJobExecutionId(), TENANT_ID)).onComplete(ar -> async.complete());
}
use of io.github.jklingsporn.vertx.jooq.classic.reactivepg.ReactiveClassicGenericQueryExecutor in project mod-source-record-storage by folio-org.
the class RecordCleanupServiceTest method verifyRecordIsPresent.
private Future<Void> verifyRecordIsPresent(String recordId, TestContext testContext) {
Promise<Void> promise = Promise.promise();
ReactiveClassicGenericQueryExecutor queryExecutor = postgresClientFactory.getQueryExecutor(TENANT_ID);
Future.succeededFuture().compose(ar -> RecordDaoUtil.findById(queryExecutor, recordId)).onSuccess(optionalRecord -> testContext.assertTrue(optionalRecord.isPresent())).compose(ar -> ParsedRecordDaoUtil.findById(queryExecutor, recordId, RecordType.MARC_BIB)).onSuccess(optionalParsedRecord -> testContext.assertTrue(optionalParsedRecord.isPresent())).compose(ar -> RawRecordDaoUtil.findById(queryExecutor, recordId)).onSuccess(optionalRawRecord -> testContext.assertTrue(optionalRawRecord.isPresent())).compose(ar -> ErrorRecordDaoUtil.findById(queryExecutor, recordId)).onSuccess(optionalErrorRecord -> testContext.assertTrue(optionalErrorRecord.isPresent())).onSuccess(ar -> promise.complete()).onFailure(ar -> promise.fail(ar));
return promise.future();
}
use of io.github.jklingsporn.vertx.jooq.classic.reactivepg.ReactiveClassicGenericQueryExecutor in project mod-source-record-storage by folio-org.
the class MarcAuthorityUpdateModifyEventHandlerTest method setUp.
@Before
public void setUp(TestContext context) {
WireMock.stubFor(get(new UrlPathPattern(new RegexPattern(MAPPING_METADATA__URL + "/.*"), true)).willReturn(WireMock.ok().withBody(Json.encode(new MappingMetadataDto().withMappingParams(Json.encode(new MappingParameters()))))));
recordDao = new RecordDaoImpl(postgresClientFactory);
recordService = new RecordServiceImpl(recordDao);
modifyRecordEventHandler = new MarcAuthorityUpdateModifyEventHandler(recordService, new MappingParametersSnapshotCache(vertx), vertx);
Snapshot snapshot = new Snapshot().withJobExecutionId(UUID.randomUUID().toString()).withProcessingStartedDate(new Date()).withStatus(Snapshot.Status.COMMITTED);
snapshotForRecordUpdate = new Snapshot().withJobExecutionId(UUID.randomUUID().toString()).withStatus(Snapshot.Status.PARSING_IN_PROGRESS);
record = new Record().withId(recordId).withSnapshotId(snapshot.getJobExecutionId()).withGeneration(0).withMatchedId(recordId).withRecordType(MARC_BIB).withRawRecord(rawRecord).withParsedRecord(parsedRecord);
ReactiveClassicGenericQueryExecutor queryExecutor = postgresClientFactory.getQueryExecutor(TENANT_ID);
SnapshotDaoUtil.save(queryExecutor, snapshot).compose(v -> recordService.saveRecord(record, TENANT_ID)).compose(v -> SnapshotDaoUtil.save(queryExecutor, snapshotForRecordUpdate)).onComplete(context.asyncAssertSuccess());
}
use of io.github.jklingsporn.vertx.jooq.classic.reactivepg.ReactiveClassicGenericQueryExecutor in project mod-source-record-storage by folio-org.
the class ParsedRecordDaoUtil method update.
/**
* Updates {@link ParsedRecord} to the db table defined by {@link RecordType} using
* {@link ReactiveClassicGenericQueryExecutor}
*
* @param queryExecutor query executor
* @param parsedRecord parsed record to update
* @param recordType record type to update
* @return future of updated ParsedRecord
*/
public static Future<ParsedRecord> update(ReactiveClassicGenericQueryExecutor queryExecutor, ParsedRecord parsedRecord, RecordType recordType) {
UUID id = UUID.fromString(parsedRecord.getId());
JsonObject content = normalize(parsedRecord.getContent());
return queryExecutor.executeAny(dsl -> dsl.update(table(name(recordType.getTableName()))).set(CONTENT_FIELD, content).where(ID_FIELD.eq(id))).map(update -> {
if (update.rowCount() > 0) {
return parsedRecord.withContent(content.getMap());
}
String message = format(PARSED_RECORD_NOT_FOUND_TEMPLATE, parsedRecord.getId());
throw new NotFoundException(message);
});
}
Aggregations