Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MODSOURMAN-1232 Add the option to exclude job profile names to GET "/metadata-provider/jobExecutions" endpoint #937

Merged
merged 7 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## 2024-xx-xx v3.9.0-SNAPSHOT
* [MODSOURMAN-1232](https://folio-org.atlassian.net/browse/MODSOURMAN-1232) Add the option to exclude job profile names to GET "/metadata-provider/jobExecutions" endpoint
* [MODSOURMAN-1195](https://folio-org.atlassian.net/browse/MODSOURMAN-1195) Save job execution progress in batches
* [MODSOURMAN-1166](https://folio-org.atlassian.net/browse/MODSOURMAN-1166) Sorting by Autority, Order and Error columns is not working on Log details page
* [MODDATAIMP-1029](https://folio-org.atlassian.net/browse/MODDATAIMP-1029) The authority record loaded via data-import using Default - Create SRS MARC Authority job profile is duplicated on the job-summary page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class JobExecutionFilter {
private String userId;
private Date completedAfter;
private Date completedBefore;
private String excludeJobProfileNames;

public JobExecutionFilter withStatusAny(List<JobExecution.Status> statusAny) {
this.statusAny = statusAny;
Expand Down Expand Up @@ -68,6 +69,11 @@ public JobExecutionFilter withFileNamePattern(String fileNamePattern) {
return this;
}

public JobExecutionFilter withExcludeJobProfileName(String excludeJobProfileNames) {
this.excludeJobProfileNames = excludeJobProfileNames;
return this;
}

public JobExecutionFilter withFileNameNotAny(List<String> fileNameNotAny) {
this.fileNameNotAny = fileNameNotAny;
return this;
Expand Down Expand Up @@ -131,6 +137,9 @@ public String buildCriteria() {
addCondition(conditionBuilder, buildCaseInsensitiveLikeCondition(FILE_NAME_FIELD, fileNamePattern));
}
}
if (isNotEmpty(excludeJobProfileNames)) {
addCondition(conditionBuilder, buildNotEqualCondition(FILE_NAME_FIELD, excludeJobProfileNames));
}
if (isNotEmpty(fileNameNotAny)) {
addCondition(conditionBuilder, buildNotInCondition(FILE_NAME_FIELD, fileNameNotAny));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ public MetadataProviderImpl(Vertx vertx, String tenantId) { //NOSONAR
}

@Override
public void getMetadataProviderJobExecutions(List<String> statusAny, List<String> profileIdNotAny, String statusNot,
List<String> uiStatusAny, String hrId, String fileName, List<String> fileNameNotAny,
public void getMetadataProviderJobExecutions(String excludeJobProfileNames, List<String> statusAny, List<String> profileIdNotAny,
String statusNot, List<String> uiStatusAny, String hrId, String fileName, List<String> fileNameNotAny,
List<String> profileIdAny, List<String> subordinationTypeNotAny, String userId, Date completedAfter,
Date completedBefore, List<String> sortBy, String totalRecords, int offset, int limit, Map<String, String> okapiHeaders,
Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) {
Expand All @@ -72,7 +72,7 @@ public void getMetadataProviderJobExecutions(List<String> statusAny, List<String
LOGGER.debug("getMetadataProviderJobExecutions:: sortBy {}", sortBy);
List<SortField> sortFields = mapSortQueryToSortFields(sortBy);
JobExecutionFilter filter = buildJobExecutionFilter(statusAny, profileIdNotAny, statusNot, uiStatusAny, hrId, fileName, fileNameNotAny, profileIdAny,
subordinationTypeNotAny, userId, completedAfter, completedBefore);
subordinationTypeNotAny, userId, completedAfter, completedBefore, excludeJobProfileNames);
jobExecutionService.getJobExecutionsWithoutParentMultiple(filter, sortFields, offset, limit, tenantId)
.map(GetMetadataProviderJobExecutionsResponse::respond200WithApplicationJson)
.map(Response.class::cast)
Expand Down Expand Up @@ -223,7 +223,8 @@ public void getMetadataProviderIncomingRecordsByRecordId(String recordId, Map<St
private JobExecutionFilter buildJobExecutionFilter(List<String> statusAny, List<String> profileIdNotAny, String statusNot,
List<String> uiStatusAny, String hrIdPattern, String fileNamePattern,
List<String> fileNameNotAny, List<String> profileIdAny, List<String> subordinationTypeNotAny,
String userId, Date completedAfter, Date completedBefore) {
String userId, Date completedAfter, Date completedBefore,
String excludeJobProfileNames) {
List<JobExecution.Status> statuses = statusAny.stream()
.map(JobExecution.Status::fromValue)
.toList();
Expand All @@ -239,6 +240,7 @@ private JobExecutionFilter buildJobExecutionFilter(List<String> statusAny, List<
return new JobExecutionFilter()
.withStatusAny(statuses)
.withProfileIdNotAny(profileIdNotAny)
.withExcludeJobProfileName(excludeJobProfileNames)
.withStatusNot(statusNot == null ? null : JobExecution.Status.fromValue(statusNot))
.withUiStatusAny(uiStatuses)
.withHrIdPattern(hrIdPattern)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,21 @@ public void shouldReturnFilteredCollectionByHrIdOnGet() {
.body("jobExecutions[0].hrId", is(expectedHrid));
}

@Test
public void shouldReturnFilteredCollectionByExcludeJobProfileNameOnGet() {
constructAndPostInitJobExecutionRqDto(5);

RestAssured.given()
.spec(spec)
.when()
.queryParam("excludeJobProfileNames", "importBib2.bib")
JavokhirAbdullayev marked this conversation as resolved.
Show resolved Hide resolved
.get(GET_JOB_EXECUTIONS_PATH)
.then()
.statusCode(HttpStatus.SC_OK)
.body("jobExecutions.size()", is(4))
.body("totalRecords", is(4));
}

@Test
public void shouldReturnFilteredCollectionByFileNameOnGet() {
constructAndPostInitJobExecutionRqDto(5);
Expand Down
5 changes: 5 additions & 0 deletions ramls/metadata-provider.raml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ resourceTypes:
pageable
]
queryParameters:
excludeJobProfileNames:
description: Filter by Job profiles name
type: string
example: Bulk operations data import job profile - *
required: false
statusAny:
description: JobExecution statuses to filter by
type: string[]
Expand Down
Loading