use of org.folio.rest.jaxrs.model.Record.RecordType.MARC_BIB 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 org.folio.rest.jaxrs.model.Record.RecordType.MARC_BIB 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 org.folio.rest.jaxrs.model.Record.RecordType.MARC_BIB in project mod-source-record-manager by folio-org.
the class ChangeEngineServiceImpl method ensureMappingMetaDataSnapshot.
private Future<Boolean> ensureMappingMetaDataSnapshot(String jobExecutionId, List<Record> recordsList, OkapiConnectionParams okapiParams) {
if (CollectionUtils.isEmpty(recordsList)) {
return Future.succeededFuture(false);
}
Promise<Boolean> promise = Promise.promise();
mappingMetadataService.getMappingMetadataDto(jobExecutionId, okapiParams).onSuccess(v -> promise.complete(false)).onFailure(e -> {
if (e instanceof NotFoundException) {
RecordType recordType = recordsList.get(0).getRecordType();
recordType = Objects.isNull(recordType) || recordType == RecordType.EDIFACT ? MARC_BIB : recordType;
mappingMetadataService.saveMappingRulesSnapshot(jobExecutionId, recordType.toString(), okapiParams.getTenantId()).compose(arMappingRules -> mappingMetadataService.saveMappingParametersSnapshot(jobExecutionId, okapiParams)).onSuccess(ar -> promise.complete(true)).onFailure(promise::fail);
return;
}
promise.fail(e);
});
return promise.future();
}
use of org.folio.rest.jaxrs.model.Record.RecordType.MARC_BIB in project mod-source-record-storage by folio-org.
the class MarcBibUpdateModifyEventHandlerTest 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 MarcBibUpdateModifyEventHandler(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 org.folio.rest.jaxrs.model.Record.RecordType.MARC_BIB in project mod-source-record-storage by folio-org.
the class QuickMarcKafkaHandlerTest method setUp.
@Before
public void setUp(TestContext context) {
MockitoAnnotations.initMocks(this);
recordDao = new RecordDaoImpl(postgresClientFactory);
recordService = new RecordServiceImpl(recordDao);
Async async = context.async();
Snapshot snapshot = new Snapshot().withJobExecutionId(UUID.randomUUID().toString()).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);
SnapshotDaoUtil.save(postgresClientFactory.getQueryExecutor(TENANT_ID), snapshot).compose(savedSnapshot -> recordService.saveRecord(record, TENANT_ID)).onSuccess(ar -> async.complete()).onFailure(context::fail);
}
Aggregations