use of org.folio.rest.jaxrs.model.Record.RecordType 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 in project mod-source-record-storage by folio-org.
the class SourceStorageStreamApiTest method shouldReturnAllMarcRecordsWithNotEmptyStateOnGetWhenNoQueryIsSpecified.
private void shouldReturnAllMarcRecordsWithNotEmptyStateOnGetWhenNoQueryIsSpecified(TestContext testContext, RecordType recordType, Record marc_auth_record_1) {
postSnapshots(testContext, snapshot_1, snapshot_2, snapshot_3);
Record record_4 = new Record().withId(FOURTH_UUID).withSnapshotId(snapshot_3.getJobExecutionId()).withRecordType(recordType).withRawRecord(rawRecord).withParsedRecord(marcRecord).withMatchedId(FOURTH_UUID).withOrder(1).withState(Record.State.OLD);
postRecords(testContext, marc_bib_record_1, marc_bib_record_2, marc_bib_record_3, record_4, marc_auth_record_1);
final Async async = testContext.async();
InputStream response = RestAssured.given().spec(spec).when().get(SOURCE_STORAGE_STREAM_RECORDS_PATH + "?recordType=" + recordType).then().statusCode(HttpStatus.SC_OK).extract().response().asInputStream();
List<Record> actual = new ArrayList<>();
flowableInputStreamScanner(response).map(r -> Json.decodeValue(r, Record.class)).doFinally(() -> {
testContext.assertEquals(2, actual.size());
async.complete();
}).collect(() -> actual, (a, r) -> a.add(r)).subscribe();
}
use of org.folio.rest.jaxrs.model.Record.RecordType in project mod-source-record-storage by folio-org.
the class SourceStorageStreamApiTest method shouldReturnMarcRecordsOnGetBySpecifiedSnapshotId.
private void shouldReturnMarcRecordsOnGetBySpecifiedSnapshotId(TestContext testContext, RecordType marcHolding, Record marc_holdings_record_1) {
postSnapshots(testContext, snapshot_1, snapshot_2, snapshot_3);
Record recordWithOldStatus = new Record().withId(FOURTH_UUID).withSnapshotId(snapshot_3.getJobExecutionId()).withRecordType(marcHolding).withRawRecord(rawRecord).withParsedRecord(marcRecord).withMatchedId(FOURTH_UUID).withOrder(1).withState(Record.State.OLD);
postRecords(testContext, marc_bib_record_1, marc_bib_record_2, marc_bib_record_3, marc_holdings_record_1, recordWithOldStatus);
final Async async = testContext.async();
InputStream response = RestAssured.given().spec(spec).when().get(SOURCE_STORAGE_STREAM_RECORDS_PATH + "?recordType=" + marcHolding + "&state=ACTUAL&snapshotId=" + marc_holdings_record_1.getSnapshotId()).then().statusCode(HttpStatus.SC_OK).extract().response().asInputStream();
List<Record> actual = new ArrayList<>();
flowableInputStreamScanner(response).map(r -> Json.decodeValue(r, Record.class)).doFinally(() -> {
testContext.assertEquals(1, actual.size());
testContext.assertEquals(marc_holdings_record_1.getSnapshotId(), actual.get(0).getSnapshotId());
testContext.assertEquals(false, actual.get(0).getAdditionalInfo().getSuppressDiscovery());
async.complete();
}).collect(() -> actual, (a, r) -> a.add(r)).subscribe();
}
use of org.folio.rest.jaxrs.model.Record.RecordType in project mod-source-record-storage by folio-org.
the class SourceStorageStreamApiTest method shouldReturnSortedSourceRecordsOnGetWhenSortByIsSpecified.
@Test
public void shouldReturnSortedSourceRecordsOnGetWhenSortByIsSpecified(TestContext testContext) {
postSnapshots(testContext, snapshot_1, snapshot_2);
String firstMatchedId = UUID.randomUUID().toString();
Record record_4_tmp = new Record().withId(firstMatchedId).withSnapshotId(snapshot_1.getJobExecutionId()).withRecordType(Record.RecordType.MARC_BIB).withRawRecord(rawRecord).withParsedRecord(marcRecord).withMatchedId(firstMatchedId).withOrder(1).withState(Record.State.ACTUAL);
String secondMathcedId = UUID.randomUUID().toString();
Record record_2_tmp = new Record().withId(secondMathcedId).withSnapshotId(snapshot_2.getJobExecutionId()).withRecordType(Record.RecordType.MARC_BIB).withRawRecord(rawRecord).withParsedRecord(marcRecord).withMatchedId(secondMathcedId).withOrder(11).withState(Record.State.ACTUAL);
postRecords(testContext, marc_bib_record_2, record_2_tmp, marc_bib_record_4, record_4_tmp);
final Async async = testContext.async();
InputStream response = RestAssured.given().spec(spec).when().get(SOURCE_STORAGE_STREAM_SOURCE_RECORDS_PATH + "?recordType=MARC_BIB&orderBy=createdDate,DESC").then().statusCode(HttpStatus.SC_OK).extract().response().asInputStream();
List<SourceRecord> actual = new ArrayList<>();
flowableInputStreamScanner(response).map(r -> Json.decodeValue(r, SourceRecord.class)).doFinally(() -> {
testContext.assertEquals(4, actual.size());
testContext.assertTrue(Objects.nonNull(actual.get(0).getParsedRecord()));
testContext.assertTrue(Objects.nonNull(actual.get(1).getParsedRecord()));
testContext.assertTrue(Objects.nonNull(actual.get(2).getParsedRecord()));
testContext.assertTrue(Objects.nonNull(actual.get(3).getParsedRecord()));
testContext.assertEquals(false, actual.get(0).getDeleted());
testContext.assertEquals(false, actual.get(1).getDeleted());
testContext.assertEquals(false, actual.get(2).getDeleted());
testContext.assertEquals(false, actual.get(3).getDeleted());
testContext.assertTrue(actual.get(0).getMetadata().getCreatedDate().after(actual.get(1).getMetadata().getCreatedDate()));
testContext.assertTrue(actual.get(1).getMetadata().getCreatedDate().after(actual.get(2).getMetadata().getCreatedDate()));
testContext.assertTrue(actual.get(2).getMetadata().getCreatedDate().after(actual.get(3).getMetadata().getCreatedDate()));
async.complete();
}).collect(() -> actual, (a, r) -> a.add(r)).subscribe();
}
Aggregations