-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CIRCSTORE-541: added ItemRetrievalServicePointUpdateProcessorForReque…
…st for retrival SP for request (#505) * CIRCSTORE-540: ItemUpdateProcessorForRequest update item's location and SP * CIRCSTORE-540: added log for debugging * CIRCSTORE-540: added log for debugging * CIRCSTORE-540: set additionalProperties true inside location.json * CIRCSTORE-540: fix exception issue * CIRCSTORE-540: fix exception issue * CIRCSTORE-540: 1) added async mechanism in EventProcessor class to execute and support non-blocking api calls. 2) Added test case. * CIRCSTORE-540: removed unnecessary log and code * CIRCSTORE-540: using location and SP constants * CIRCSTORE-540: fix NLP due to logging of null object * CIRCSTORE-540: fixed sonar issues * CIRCSTORE-541: added ItemRetrievalServicePointUpdateProcessorForRequest for retrival SP for request * CIRCSTORE-541: fix duplicate code line sonar issue * CIRCSTORE-540: added interface dependency for location and service-point api * CIRCSTORE-541: resolved merge conflict
- Loading branch information
1 parent
6d3700b
commit b46a339
Showing
3 changed files
with
107 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...o/service/event/handler/processor/ItemRetrievalServicePointUpdateProcessorForRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package org.folio.service.event.handler.processor; | ||
|
||
import io.vertx.core.Future; | ||
import io.vertx.core.json.JsonObject; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.folio.persist.RequestRepository; | ||
import org.folio.rest.jaxrs.model.Request; | ||
import org.folio.rest.persist.Criteria.Criteria; | ||
import org.folio.rest.persist.Criteria.Criterion; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import static org.apache.commons.lang3.ObjectUtils.notEqual; | ||
import static org.folio.service.event.InventoryEventType.INVENTORY_SERVICE_POINT_UPDATED; | ||
import static org.folio.service.event.handler.processor.ItemUpdateProcessorForRequest.RETRIEVAL_SERVICE_POINT_ID; | ||
|
||
public class ItemRetrievalServicePointUpdateProcessorForRequest extends UpdateEventProcessor<Request> { | ||
private static final Logger log = LogManager.getLogger(ItemRetrievalServicePointUpdateProcessorForRequest.class); | ||
private static final String SERVICE_POINT_NAME_KEY = "name"; | ||
|
||
public ItemRetrievalServicePointUpdateProcessorForRequest(RequestRepository requestRepository) { | ||
super(INVENTORY_SERVICE_POINT_UPDATED, requestRepository); | ||
} | ||
|
||
@Override | ||
protected Future<List<Change<Request>>> collectRelevantChanges(JsonObject payload) { | ||
JsonObject newObject = payload.getJsonObject("new"); | ||
JsonObject oldObject = payload.getJsonObject("old"); | ||
List<Change<Request>> changes = new ArrayList<>(); | ||
|
||
// compare service point names | ||
String newServicePointName = newObject.getString(SERVICE_POINT_NAME_KEY); | ||
String oldServicePointName = oldObject.getString(SERVICE_POINT_NAME_KEY); | ||
if (notEqual(oldServicePointName, newServicePointName)) { | ||
log.info("ItemRetrievalServicePointUpdateProcessorForRequest :: collectRelevantChanges:: changing item.retrievalServicePointName from {} to {}", | ||
oldServicePointName, newServicePointName); | ||
changes.add(new Change<>(request -> request.getItem().setRetrievalServicePointName(newServicePointName))); | ||
} | ||
return Future.succeededFuture(changes); | ||
} | ||
|
||
@Override | ||
protected Criterion criterionForObjectsToBeUpdated(String oldObjectId) { | ||
log.info("ItemRetrievalServicePointUpdateProcessorForRequest :: criterionForObjectsToBeUpdated:: oldObjectId: {}", | ||
oldObjectId); | ||
return new Criterion( | ||
new Criteria() | ||
.addField("'item'") | ||
.addField(String.format("'%s'", RETRIEVAL_SERVICE_POINT_ID)) | ||
.setOperation("=") | ||
.setVal(oldObjectId)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters