Skip to content

Commit

Permalink
[MODINVSTOR-1243] Compile new schemas to parse the request body
Browse files Browse the repository at this point in the history
  • Loading branch information
Saba-Zedginidze-EPAM committed Aug 23, 2024
1 parent 8288e26 commit fbdc18a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,8 @@
<path>${basedir}/ramls/items_update_ownership.json</path>
<path>${basedir}/ramls/update_ownership_response.json</path>
<path>${basedir}/ramls/instance-ingress-event.json</path>
<path>${basedir}/ramls/tenantItemPair.json</path>
<path>${basedir}/ramls/tenantItemPairCollection.json</path>
</sourcePaths>
<targetPackage>org.folio</targetPackage>
<generateBuilders>true</generateBuilders>
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/folio/inventory/resources/TenantItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.folio.TenantItemPair;
import org.folio.TenantItemPairCollection;
import org.folio.inventory.common.WebContext;
import org.folio.inventory.storage.Storage;
import org.folio.inventory.storage.external.CollectionResourceClient;
Expand All @@ -36,11 +38,8 @@ public class TenantItems extends Items {
private static final Logger log = LogManager.getLogger(MethodHandles.lookup().lookupClass());

private static final String TENANT_ITEMS_PATH = "/inventory/tenant-items";
private static final String TENANT_ITEM_PAIRS_FIELD = "itemTenantPairs";
private static final String ITEMS_FIELD = "items";
private static final String TOTAL_RECORDS_FIELD = "items";
private static final String ITEM_ID_FIELD = "itemId";
private static final String TENANT_ID_FIELD = "tenantId";

public TenantItems(final Storage storage, final HttpClient client) {
super(storage, client);
Expand All @@ -57,8 +56,9 @@ public void register(Router router) {
*
*/
private void getItemsFromTenants(RoutingContext routingContext) {
var getItemsFutures = JsonArrayHelper.toList(routingContext.body().asJsonObject(), TENANT_ITEM_PAIRS_FIELD).stream()
.collect(groupingBy(json -> json.getString(TENANT_ID_FIELD), mapping(json -> json.getString(ITEM_ID_FIELD), toList())))
var getItemsFutures = routingContext.body().asPojo(TenantItemPairCollection.class)
.getItemTenantPairs().stream()
.collect(groupingBy(TenantItemPair::getTenantId, mapping(TenantItemPair::getTenantId, toList())))
.entrySet().stream()
.map(tenantToItems -> getItemsWithTenantId(tenantToItems.getKey(), tenantToItems.getValue(), routingContext))
.toList();
Expand Down

0 comments on commit fbdc18a

Please sign in to comment.