From d4880ab5d857856773416dc73a9f358e891f2aaf Mon Sep 17 00:00:00 2001 From: sheiksalahudeen Date: Tue, 5 Jul 2016 09:14:04 -0400 Subject: [PATCH] OLE-8900 : Fixed the issue with holdings / eholdings / item overlays by Ids. --- .../processor/BatchBibFileProcessor.java | 10 ++-- .../processor/OleDsNgOverlayProcessor.java | 47 +------------------ 2 files changed, 7 insertions(+), 50 deletions(-) diff --git a/ole-app/olefs/src/main/java/org/kuali/ole/spring/batch/processor/BatchBibFileProcessor.java b/ole-app/olefs/src/main/java/org/kuali/ole/spring/batch/processor/BatchBibFileProcessor.java index 915cf7fca7..492ba710c9 100644 --- a/ole-app/olefs/src/main/java/org/kuali/ole/spring/batch/processor/BatchBibFileProcessor.java +++ b/ole-app/olefs/src/main/java/org/kuali/ole/spring/batch/processor/BatchBibFileProcessor.java @@ -200,6 +200,9 @@ private JSONObject prepareRequest(Integer index, String bibId, Record marcRecord // Prepare data mapping before MARC Transformation Map> dataMappingsMapPreTransformation = prepareDataMapping(marcRecord, batchProcessProfile, OleNGConstants.PRE_MARC_TRANSFORMATION); + JSONObject holdingsData = getMatchPointProcessor().prepareMatchPointsForHoldings(marcRecord, batchProcessProfile); + JSONObject eholdingsData = getMatchPointProcessor().prepareMatchPointsForEHoldings(marcRecord, batchProcessProfile); + JSONObject itemData = getMatchPointProcessor().prepareMatchPointsForItem(marcRecord, batchProcessProfile); //Transformations pertaining to MARC record (001,003,035$a etc..) handleBatchProfileTransformations(marcRecord, batchProcessProfile); @@ -214,19 +217,16 @@ private JSONObject prepareRequest(Integer index, String bibId, Record marcRecord List bibDataMappingsPostTrans = dataMappingsMapPostTransformations.get(OleNGConstants.BIB_DATAMAPPINGS); bibData.put(OleNGConstants.DATAMAPPING, buildOneObjectForList(bibDataMappingsPreTrans, bibDataMappingsPostTrans)); - JSONObject holdingsData = getMatchPointProcessor().prepareMatchPointsForHoldings(marcRecord, batchProcessProfile); List holdingsDataMappingsPreTrans = dataMappingsMapPreTransformation.get(OleNGConstants.HOLDINGS_DATAMAPPINGS); List holdingsDataMappingsPostTrans = dataMappingsMapPostTransformations.get(OleNGConstants.HOLDINGS_DATAMAPPINGS); holdingsData.put(OleNGConstants.DATAMAPPING, buildOneObjectForList(holdingsDataMappingsPreTrans, holdingsDataMappingsPostTrans)); bibData.put(OleNGConstants.HOLDINGS, holdingsData); - JSONObject eholdingsData = getMatchPointProcessor().prepareMatchPointsForEHoldings(marcRecord, batchProcessProfile); List eholdingsDataMappingsPreTrans = dataMappingsMapPreTransformation.get(OleNGConstants.EHOLDINGS_DATAMAPPINGS); List eholdingsDataMappingsPostTrans = dataMappingsMapPostTransformations.get(OleNGConstants.EHOLDINGS_DATAMAPPINGS); eholdingsData.put(OleNGConstants.DATAMAPPING, buildOneObjectForList(eholdingsDataMappingsPreTrans, eholdingsDataMappingsPostTrans)); bibData.put(OleNGConstants.EHOLDINGS, eholdingsData); - JSONObject itemData = getMatchPointProcessor().prepareMatchPointsForItem(marcRecord, batchProcessProfile); List itemsDataMappingsPreTrans = dataMappingsMapPreTransformation.get(OleNGConstants.ITEM_DATAMAPPINGS); List itemsDataMappingsPostTrans = dataMappingsMapPostTransformations.get(OleNGConstants.ITEM_DATAMAPPINGS); itemData.put(OleNGConstants.DATAMAPPING, buildOneObjectForList(itemsDataMappingsPreTrans, itemsDataMappingsPostTrans)); @@ -286,8 +286,8 @@ public List buildOneObjectForList(List dataMappingsPreTr List finalObjects = new ArrayList<>(); for (int index = 0; index < dataMappingsPreTrans.size(); index++) { - JSONObject preTransformObject = dataMappingsPreTrans.get(index); - JSONObject postTransformObject = dataMappingsPostTrans.get(index); + JSONObject preTransformObject = dataMappingsPreTrans.size() > index ? dataMappingsPreTrans.get(index) : new JSONObject(); + JSONObject postTransformObject = dataMappingsPostTrans.size() > index ? dataMappingsPostTrans.get(index) : new JSONObject(); finalObjects.add(buildOneObject(preTransformObject, postTransformObject)); } diff --git a/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/rest/processor/OleDsNgOverlayProcessor.java b/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/rest/processor/OleDsNgOverlayProcessor.java index 32a1ec9f93..8ad5a40003 100644 --- a/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/rest/processor/OleDsNgOverlayProcessor.java +++ b/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/rest/processor/OleDsNgOverlayProcessor.java @@ -330,7 +330,7 @@ public void buildItemResponse(HoldingsResponse holdingsResponse, Exchange exchan if (CollectionUtils.isNotEmpty(createItemRecordAndDataMappings)) { for (ItemRecordAndDataMapping itemRecordAndDataMapping : createItemRecordAndDataMappings) { ItemRecord itemRecord = itemRecordAndDataMapping.getItemRecord(); - if (holdingsRecord.getHoldingsId().equals(itemRecord.getHoldingsId())) { + if (null != itemRecord && StringUtils.isNotBlank(itemRecord.getItemId()) && holdingsRecord.getHoldingsId().equals(itemRecord.getHoldingsId())) { ItemResponse itemResponse = new ItemResponse(); itemResponse.setItemId(DocumentUniqueIDPrefix.PREFIX_WORK_ITEM_OLEML+ "-" + itemRecord.getItemId()); itemResponse.setOperation(OleNGConstants.CREATED); @@ -348,7 +348,7 @@ public void buildItemResponse(HoldingsResponse holdingsResponse, Exchange exchan ItemRecord itemRecord = itemRecordAndDataMapping.getItemRecord(); if (holdingsRecord.getHoldingsId().equals(itemRecord.getHoldingsId())) { ItemResponse itemResponse = new ItemResponse(); - itemResponse.setItemId(itemRecord.getItemId()); + itemResponse.setItemId(DocumentUniqueIDPrefix.PREFIX_WORK_ITEM_OLEML+ "-" + itemRecord.getItemId()); itemResponse.setOperation(status); itemResponses.add(itemResponse); } @@ -1105,49 +1105,6 @@ private BibRecord prepareBib(JSONObject bibJSONDataObject) { return bibRecord; } - private List holdingsResponse(Exchange exchange, List holdingRecords, String operation) { - List holdingsResponses = new ArrayList(); - if (CollectionUtils.isNotEmpty(holdingRecords)) { - for (Iterator iterator = holdingRecords.iterator(); iterator.hasNext(); ) { - HoldingsResponse holdingsResponse = new HoldingsResponse(); - HoldingsRecord holdingsRecord = (HoldingsRecord) iterator.next(); - holdingsResponse.setOperation(operation); - holdingsResponse.setHoldingsId(holdingsRecord.getUniqueIdPrefix() + "-" + holdingsRecord.getHoldingsId()); - holdingsResponse.setItemResponses(prepareItemsResponse(holdingsRecord, exchange)); - holdingsResponses.add(holdingsResponse); - } - } - return holdingsResponses; - } - - private List prepareItemsResponse(HoldingsRecord holdingsRecord, Exchange exchange) { - List itemResponses = new ArrayList(); - - List itemRecordsToCreate = (List) exchange.get(OleNGConstants.ITEMS_CREATED); - itemResponses.addAll(itemResponse(holdingsRecord, itemRecordsToCreate, OleNGConstants.CREATED)); - - List itemRecordsToUpdate = (List) exchange.get(OleNGConstants.ITEMS_UPDATED); - itemResponses.addAll(itemResponse(holdingsRecord, itemRecordsToUpdate, OleNGConstants.UPDATED)); - - return itemResponses; - } - - private List itemResponse(HoldingsRecord holdingsRecord, List itemRecords, String operation) { - List itemResponses = new ArrayList(); - if (CollectionUtils.isNotEmpty(itemRecords)) { - for (Iterator iterator = itemRecords.iterator(); iterator.hasNext(); ) { - ItemRecord itemRecord = (ItemRecord) iterator.next(); - if (itemRecord.getHoldingsId().equalsIgnoreCase(holdingsRecord.getHoldingsId())) { - ItemResponse itemResponse = new ItemResponse(); - itemResponse.setOperation(operation); - itemResponse.setItemId(itemRecord.getUniqueIdPrefix() + "-" + itemRecord.getItemId()); - itemResponses.add(itemResponse); - } - } - } - return itemResponses; - } - private JSONObject findDataMappingByValue(JSONArray dataMappings, String type, String value) { if (null != dataMappings) { for (int index = 0; index < dataMappings.length(); index++) {