Skip to content

Commit

Permalink
MODSOURCE-773: Remove default searching via "deleted"="false". (#626)
Browse files Browse the repository at this point in the history
* MODSOURCE-773: MARC Search omits suppressed from discovery records in default search.

* MODSOURCE-773: Useless condition removed.

* MODSOURCE-773: NEWS updated.

* MODSOURCE-773: TEMPORARY SCHEMA CHANGE. REMOVE AFTER TESTING ON RANCHER!

* MODSOURCE-773: REVERTING CHANGE.

* MODSOURCE-773: Updating raml-storage.

* MODSOURCE-773: Updating raml-storage.

* MODSOURCE-773: Compilation errors due to schema profile wrappers changes - fixed.

* MODSOURCE-773: Compilation errors due to schema profile wrappers changes in tests - fixed .

* MODSOURCE-773: Schema updated.

* MODSOURCE-773: Deleted-parameter searching mechanism changed.

* MODSOURCE-773: Schema updated.

* MODSOURCE-773: Condition improved.
  • Loading branch information
VRohach authored Jun 5, 2024
1 parent 31a805e commit 755b9cf
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,10 @@ public static Condition filterRecordByUpdatedDateRange(Date updatedAfter, Date u
*/
public static Condition filterRecordByDeleted(Boolean deleted) {
Condition condition = filterRecordByState(RecordState.ACTUAL.name());
if (deleted == null) {
condition = condition.or(filterRecordByState(RecordState.DELETED.name()))
.or(filterRecordByState(RecordState.ACTUAL.name()));
}
if (Boolean.TRUE.equals(deleted)) {
condition = condition.or(filterRecordByState(RecordState.DELETED.name()))
.or(filterRecordByState(RecordState.ACTUAL.name()).and(filterRecordByLeaderRecordStatus(DELETED_LEADER_RECORD_STATUS)));
Expand All @@ -618,7 +622,7 @@ public static Condition filterRecordByExternalIdNonNull() {

/**
* Convert {@link List} of {@link String} to {@link List} or {@link OrderField}
*
* <p>
* Relies on strong convention between dto property name and database column name.
* Property name being lower camel case and column name being lower snake case of the property name.
*
Expand All @@ -629,7 +633,7 @@ public static Condition filterRecordByExternalIdNonNull() {
@SuppressWarnings("squid:S1452")
public static List<OrderField<?>> toRecordOrderFields(List<String> orderBy, Boolean forOffset) {
if (forOffset && orderBy.isEmpty()) {
return Arrays.asList(new OrderField<?>[] {RECORDS_LB.ID.asc()});
return Arrays.asList(new OrderField<?>[]{RECORDS_LB.ID.asc()});
}
return orderBy.stream()
.map(order -> order.split(COMMA))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class RecordSearchParameters {
private String leaderSearchExpression;
private String fieldsSearchExpression;
private Record.RecordType recordType;
private boolean deleted;
private Boolean deleted;
private Boolean suppressedFromDiscovery;
private Integer limit;
private Integer offset;
Expand Down Expand Up @@ -57,11 +57,11 @@ public void setRecordType(Record.RecordType recordType) {
this.recordType = recordType;
}

public boolean isDeleted() {
public Boolean isDeleted() {
return deleted;
}

public void setDeleted(boolean deleted) {
public void setDeleted(Boolean deleted) {
this.deleted = deleted;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1195,6 +1195,45 @@ public void shouldReturnRecordOnSearchMarcRecordWhenRecordWasNotSuppressedAndSet
async.complete();
}


@Test
public void shouldReturnRecordOnSearchMarcRecordWhenRecordWasDeletedAndDeletedNotSetInRequest(TestContext testContext) {
// given
postSnapshots(testContext, snapshot_2);
Response createParsed = RestAssured.given()
.spec(spec)
.body(marc_bib_record_2)
.when()
.post(SOURCE_STORAGE_RECORDS_PATH);
assertThat(createParsed.statusCode(), is(HttpStatus.SC_CREATED));
Record parsed = createParsed.body().as(Record.class);
Async async = testContext.async();
RestAssured.given()
.spec(spec)
.when()
.delete(SOURCE_STORAGE_RECORDS_PATH + "/" + parsed.getId())
.then()
.statusCode(HttpStatus.SC_NO_CONTENT);
async.complete();
MarcRecordSearchRequest searchRequest = new MarcRecordSearchRequest();
searchRequest.setLeaderSearchExpression("p_05 = 'd'");
// when
async = testContext.async();
ExtractableResponse<Response> response = RestAssured.given()
.spec(spec)
.body(searchRequest)
.when()
.post("/source-storage/stream/marc-record-identifiers")
.then()
.extract();
JsonObject responseBody = new JsonObject(response.body().asString());
// then
assertEquals(HttpStatus.SC_OK, response.statusCode());
assertEquals(1, responseBody.getJsonArray("records").size());
assertEquals(1, responseBody.getInteger("totalCount").intValue());
async.complete();
}

@Test
public void shouldReturnEmptyResponseOnSearchMarcRecordIdsWhenLimitIs0(TestContext testContext) {
// given
Expand Down
2 changes: 1 addition & 1 deletion ramls/raml-storage

0 comments on commit 755b9cf

Please sign in to comment.