From 69f8c95aa2c9b676ee3d2a116a1621a67ada947e Mon Sep 17 00:00:00 2001 From: sheiksalahudeen Date: Tue, 5 Jul 2016 12:35:27 -0400 Subject: [PATCH] OLE-8938 : Fixed issue with overlay if bib status equals does not protect attached eholdings --- .../kuali/ole/constants/OleNGConstants.java | 2 ++ .../storage/rdbms/pojo/HoldingsRecord.java | 9 +++++ .../storage/rdbms/pojo/ItemRecord.java | 9 +++++ .../kuali/ole/dsng/rest/handler/Handler.java | 6 ++++ .../rest/handler/bib/UpdateBibHandler.java | 11 ++++-- .../holdings/CreateHoldingsHanlder.java | 29 ++++++++------- .../holdings/UpdateHoldingsHandler.java | 35 +++++++++++++------ .../rest/handler/items/CreateItemHandler.java | 22 ++++++++---- .../rest/handler/items/UpdateItemHandler.java | 27 ++++++++------ .../processor/OleDsNgOverlayProcessor.java | 31 ++++++++-------- .../org/kuali/ole/dsng/util/HoldingsUtil.java | 8 ++--- 11 files changed, 128 insertions(+), 61 deletions(-) diff --git a/ole-common/ole-utility/src/main/java/org/kuali/ole/constants/OleNGConstants.java b/ole-common/ole-utility/src/main/java/org/kuali/ole/constants/OleNGConstants.java index 5d434c9836..65b4fa5d80 100644 --- a/ole-common/ole-utility/src/main/java/org/kuali/ole/constants/OleNGConstants.java +++ b/ole-common/ole-utility/src/main/java/org/kuali/ole/constants/OleNGConstants.java @@ -133,6 +133,8 @@ public static final class BatchProcess { public static final String MATCHPOINT_FOR_DATAMAPPING = "matchpointForDataMapping"; public static final String ADDED_OPS = "addedOps"; public static final String ADDITIONAL_OVERLAY_OPS = "additionalOverlayOps"; + public static final String DISCARDED_BIB_FOR_ADDITIONAL_OVERLAY_OPS = "discardedBibForAdditionalOverlayOps"; + public static final String DISCARDED_HOLDINGS_FOR_ADDITIONAL_OVERLAY_OPS = "discardedHoldingsForAdditionalOverlayOps"; public static final String ACTION_OPS = "actionOps"; public static final String FIELD_OPS = "fieldOps"; public static final String BIB_DATAMAPPINGS = "bibDataMappings"; diff --git a/ole-docstore/ole-docstore-engine/src/main/java/org/kuali/ole/docstore/engine/service/storage/rdbms/pojo/HoldingsRecord.java b/ole-docstore/ole-docstore-engine/src/main/java/org/kuali/ole/docstore/engine/service/storage/rdbms/pojo/HoldingsRecord.java index 5d5d6dd0b5..6f4368744e 100644 --- a/ole-docstore/ole-docstore-engine/src/main/java/org/kuali/ole/docstore/engine/service/storage/rdbms/pojo/HoldingsRecord.java +++ b/ole-docstore/ole-docstore-engine/src/main/java/org/kuali/ole/docstore/engine/service/storage/rdbms/pojo/HoldingsRecord.java @@ -96,6 +96,7 @@ public class HoldingsRecord extends PersistableBusinessObjectBase private List bibRecords; private List donorList; private List accessUriRecords; + private String operationType; public List getAccessUriRecords() { return accessUriRecords; @@ -584,4 +585,12 @@ public List getDonorList() { public void setDonorList(List donorList) { this.donorList = donorList; } + + public String getOperationType() { + return operationType; + } + + public void setOperationType(String operationType) { + this.operationType = operationType; + } } diff --git a/ole-docstore/ole-docstore-engine/src/main/java/org/kuali/ole/docstore/engine/service/storage/rdbms/pojo/ItemRecord.java b/ole-docstore/ole-docstore-engine/src/main/java/org/kuali/ole/docstore/engine/service/storage/rdbms/pojo/ItemRecord.java index 65a5ea6d1f..7f59cd4378 100644 --- a/ole-docstore/ole-docstore-engine/src/main/java/org/kuali/ole/docstore/engine/service/storage/rdbms/pojo/ItemRecord.java +++ b/ole-docstore/ole-docstore-engine/src/main/java/org/kuali/ole/docstore/engine/service/storage/rdbms/pojo/ItemRecord.java @@ -100,6 +100,7 @@ public class ItemRecord extends PersistableBusinessObjectBase @AuditField private Timestamp originalDueDate; private HoldingsRecord holdingsRecord; + private String operationType; public List getMissingPieceItemRecordList() { return missingPieceItemRecordList; @@ -630,4 +631,12 @@ public HoldingsRecord getHoldingsRecord() { public void setHoldingsRecord(HoldingsRecord holdingsRecord) { this.holdingsRecord = holdingsRecord; } + + public String getOperationType() { + return operationType; + } + + public void setOperationType(String operationType) { + this.operationType = operationType; + } } \ No newline at end of file diff --git a/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/rest/handler/Handler.java b/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/rest/handler/Handler.java index ab050df978..f62e167ad1 100644 --- a/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/rest/handler/Handler.java +++ b/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/rest/handler/Handler.java @@ -1,5 +1,6 @@ package org.kuali.ole.dsng.rest.handler; +import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.type.TypeReference; @@ -102,4 +103,9 @@ public List parseCommaSeperatedValues(String value){ } return values; } + + + public boolean isDiscardedByAdditionalOverlayOps(Set discardedIdsForAdditionalOverlayOps, String id) { + return CollectionUtils.isNotEmpty(discardedIdsForAdditionalOverlayOps) ? discardedIdsForAdditionalOverlayOps.contains(id) : false; + } } diff --git a/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/rest/handler/bib/UpdateBibHandler.java b/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/rest/handler/bib/UpdateBibHandler.java index 5511d5205d..86933dca55 100644 --- a/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/rest/handler/bib/UpdateBibHandler.java +++ b/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/rest/handler/bib/UpdateBibHandler.java @@ -12,9 +12,7 @@ import org.marc4j.marc.VariableField; import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; +import java.util.*; /** * Created by pvsubrah on 12/23/15. @@ -78,6 +76,13 @@ public void process(JSONObject requestJsonObject, Exchange exchange) { bibRecord.setOperationType(OleNGConstants.UPDATED); saveBibInfoRecord(bibRecord,false); + } else { + Set discardedBibIdsForAdditionalOps = (Set) exchange.get(OleNGConstants.DISCARDED_BIB_FOR_ADDITIONAL_OVERLAY_OPS); + if(null == discardedBibIdsForAdditionalOps) { + discardedBibIdsForAdditionalOps = new HashSet(); + } + discardedBibIdsForAdditionalOps.add(bibRecord.getBibId()); + exchange.add(OleNGConstants.DISCARDED_BIB_FOR_ADDITIONAL_OVERLAY_OPS, discardedBibIdsForAdditionalOps); } } diff --git a/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/rest/handler/holdings/CreateHoldingsHanlder.java b/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/rest/handler/holdings/CreateHoldingsHanlder.java index 647395ad3a..44fe863667 100644 --- a/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/rest/handler/holdings/CreateHoldingsHanlder.java +++ b/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/rest/handler/holdings/CreateHoldingsHanlder.java @@ -12,9 +12,7 @@ import org.kuali.ole.dsng.rest.handler.Handler; import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; +import java.util.*; /** * Created by pvsubrah on 1/22/16. @@ -35,6 +33,7 @@ public Boolean isInterested(String operation) { @Override public void process(JSONObject requestJsonObject, Exchange exchange) { List holdingsRecordAndDataMappings = (List) exchange.get(OleNGConstants.HOLDINGS_FOR_CREATE); + Set discardedBibForAdditionalOverlayOps = (Set) exchange.get(OleNGConstants.DISCARDED_BIB_FOR_ADDITIONAL_OVERLAY_OPS); List holdingsRecords = new ArrayList(); if (CollectionUtils.isNotEmpty(holdingsRecordAndDataMappings)) { for (Iterator iterator = holdingsRecordAndDataMappings.iterator(); iterator.hasNext(); ) { @@ -43,16 +42,18 @@ public void process(JSONObject requestJsonObject, Exchange exchange) { HoldingsRecord holdingsRecord = holdingsRecordAndDataMapping.getHoldingsRecord(); String bibId = holdingsRecord.getBibRecords().get(0).getBibId(); if (StringUtils.isNotBlank(bibId)) { - JSONObject dataMapping = holdingsRecordAndDataMapping.getDataMapping(); - holdingsRecord.setBibId(bibId); - exchange.add(OleNGConstants.HOLDINGS_RECORD, holdingsRecord); - JSONObject holdingsJSONObject = requestJsonObject.getJSONObject(OleNGConstants.HOLDINGS); - if (null != dataMapping) { - exchange.add(OleNGConstants.DATAMAPPING, dataMapping); - processDataMappings(holdingsJSONObject, exchange); + if (!isDiscardedByAdditionalOverlayOps(discardedBibForAdditionalOverlayOps, bibId)) { + JSONObject dataMapping = holdingsRecordAndDataMapping.getDataMapping(); + holdingsRecord.setBibId(bibId); + exchange.add(OleNGConstants.HOLDINGS_RECORD, holdingsRecord); + JSONObject holdingsJSONObject = requestJsonObject.getJSONObject(OleNGConstants.HOLDINGS); + if (null != dataMapping) { + exchange.add(OleNGConstants.DATAMAPPING, dataMapping); + processDataMappings(holdingsJSONObject, exchange); + } + setCommonValuesToHoldingsRecord(requestJsonObject, holdingsRecord); + holdingsRecords.add(holdingsRecord); } - setCommonValuesToHoldingsRecord(requestJsonObject, holdingsRecord); - holdingsRecords.add(holdingsRecord); } } catch (Exception e) { e.printStackTrace(); @@ -64,6 +65,10 @@ public void process(JSONObject requestJsonObject, Exchange exchange) { exchange.remove(OleNGConstants.DATAMAPPING); try { getOleDsNGMemorizeService().getHoldingDAO().saveAll(holdingsRecords); + for (Iterator iterator = holdingsRecords.iterator(); iterator.hasNext(); ) { + HoldingsRecord holdingsRecord = iterator.next(); + holdingsRecord.setOperationType(OleNGConstants.CREATED); + } } catch (Exception e) { e.printStackTrace(); addFailureReportToExchange(requestJsonObject, exchange,OleNGConstants.NO_OF_FAILURE_HOLDINGS, e, holdingsRecords.size()); diff --git a/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/rest/handler/holdings/UpdateHoldingsHandler.java b/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/rest/handler/holdings/UpdateHoldingsHandler.java index 83a244d672..578675c793 100644 --- a/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/rest/handler/holdings/UpdateHoldingsHandler.java +++ b/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/rest/handler/holdings/UpdateHoldingsHandler.java @@ -57,6 +57,7 @@ public Boolean isInterested(String operation) { public void process(JSONObject requestJsonObject, Exchange exchange) { List holdingsRecordAndDataMappings = (List) exchange.get(OleNGConstants.HOLDINGS_FOR_UPDATE); + Set discardedBibForAdditionalOverlayOps = (Set) exchange.get(OleNGConstants.DISCARDED_BIB_FOR_ADDITIONAL_OVERLAY_OPS); List holdingsRecords = new ArrayList(); if (CollectionUtils.isNotEmpty(holdingsRecordAndDataMappings)) { String updatedBy = getStringValueFromJsonObject(requestJsonObject, OleNGConstants.UPDATED_BY); @@ -67,17 +68,27 @@ public void process(JSONObject requestJsonObject, Exchange exchange) { try { HoldingsRecordAndDataMapping holdingsRecordAndDataMapping = iterator.next(); HoldingsRecord holdingsRecord = holdingsRecordAndDataMapping.getHoldingsRecord(); - holdingsRecord.setUpdatedDate(updatedDate); - holdingsRecord.setUpdatedBy(updatedBy); - if(holdingsRecord.getStaffOnlyFlag()==null){ - holdingsRecord.setStaffOnlyFlag(false); - } - exchange.add(OleNGConstants.HOLDINGS_RECORD, holdingsRecord); - JSONObject dataMappingByValue = holdingsRecordAndDataMapping.getDataMapping(); - if (null != dataMappingByValue) { - processOverlay(exchange, holdingsRecord, dataMappingByValue); - holdingsRecords.add(holdingsRecord); + String bibId = holdingsRecord.getBibId(); + if (!isDiscardedByAdditionalOverlayOps(discardedBibForAdditionalOverlayOps, bibId)) { + holdingsRecord.setUpdatedDate(updatedDate); + holdingsRecord.setUpdatedBy(updatedBy); + if(holdingsRecord.getStaffOnlyFlag()==null){ + holdingsRecord.setStaffOnlyFlag(false); + } + exchange.add(OleNGConstants.HOLDINGS_RECORD, holdingsRecord); + JSONObject dataMappingByValue = holdingsRecordAndDataMapping.getDataMapping(); + if (null != dataMappingByValue) { + processOverlay(exchange, holdingsRecord, dataMappingByValue); + } HoldingsUtil.getInstance().processIfDeleteAllExistOpsFound(holdingsRecord, requestJsonObject); + holdingsRecords.add(holdingsRecord); + }else { + Set discardedHoldingsIdsForAdditionalOps = (Set) exchange.get(OleNGConstants.DISCARDED_HOLDINGS_FOR_ADDITIONAL_OVERLAY_OPS); + if(null == discardedHoldingsIdsForAdditionalOps) { + discardedHoldingsIdsForAdditionalOps = new HashSet(); + } + discardedHoldingsIdsForAdditionalOps.add(holdingsRecord.getHoldingsId()); + exchange.add(OleNGConstants.DISCARDED_HOLDINGS_FOR_ADDITIONAL_OVERLAY_OPS, discardedHoldingsIdsForAdditionalOps); } } catch (Exception e) { e.printStackTrace(); @@ -87,6 +98,10 @@ public void process(JSONObject requestJsonObject, Exchange exchange) { exchange.remove(OleNGConstants.HOLDINGS_RECORD); try { getOleDsNGMemorizeService().getHoldingDAO().saveAll(holdingsRecords); + for (Iterator iterator = holdingsRecords.iterator(); iterator.hasNext(); ) { + HoldingsRecord holdingsRecord = iterator.next(); + holdingsRecord.setOperationType(OleNGConstants.UPDATED); + } } catch (Exception e) { e.printStackTrace(); addFailureReportToExchange(requestJsonObject, exchange, OleNGConstants.NO_OF_FAILURE_HOLDINGS, e , 1); diff --git a/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/rest/handler/items/CreateItemHandler.java b/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/rest/handler/items/CreateItemHandler.java index a4f7e0b73e..52c77f927f 100644 --- a/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/rest/handler/items/CreateItemHandler.java +++ b/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/rest/handler/items/CreateItemHandler.java @@ -14,6 +14,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.util.Set; /** * Created by SheikS on 12/26/2015. @@ -35,6 +36,7 @@ public Boolean isInterested(String operation) { @Override public void process(JSONObject requestJsonObject, Exchange exchange) { List itemRecordAndDataMappings = (List) exchange.get(OleNGConstants.ITEMS_FOR_CREATE); + Set discardedHoldingsForAdditionalOverlayOps = (Set) exchange.get(OleNGConstants.DISCARDED_HOLDINGS_FOR_ADDITIONAL_OVERLAY_OPS); List itemRecords = new ArrayList(); if (CollectionUtils.isNotEmpty(itemRecordAndDataMappings)) { @@ -45,13 +47,15 @@ public void process(JSONObject requestJsonObject, Exchange exchange) { ItemRecord itemRecord = itemRecordAndDataMapping.getItemRecord(); String holdingsId = itemRecord.getHoldingsRecord().getHoldingsId(); if (StringUtils.isNotBlank(holdingsId)) { - JSONObject dataMapping = itemRecordAndDataMapping.getDataMapping(); - exchange.add(OleNGConstants.DATAMAPPING,dataMapping); - itemRecord.setHoldingsId(holdingsId); - exchange.add(OleNGConstants.ITEM_RECORD, itemRecord); - processDataMappings(itemJSONObject, exchange); - setCommonValuesToItemRecord(requestJsonObject, itemRecord); - itemRecords.add(itemRecord); + if (!isDiscardedByAdditionalOverlayOps(discardedHoldingsForAdditionalOverlayOps, holdingsId)) { + JSONObject dataMapping = itemRecordAndDataMapping.getDataMapping(); + exchange.add(OleNGConstants.DATAMAPPING,dataMapping); + itemRecord.setHoldingsId(holdingsId); + exchange.add(OleNGConstants.ITEM_RECORD, itemRecord); + processDataMappings(itemJSONObject, exchange); + setCommonValuesToItemRecord(requestJsonObject, itemRecord); + itemRecords.add(itemRecord); + } } } catch (Exception e) { e.printStackTrace(); @@ -63,6 +67,10 @@ public void process(JSONObject requestJsonObject, Exchange exchange) { exchange.remove(OleNGConstants.DATAMAPPING); try { getOleDsNGMemorizeService().getItemDAO().saveAll(itemRecords); + for (Iterator iterator = itemRecords.iterator(); iterator.hasNext(); ) { + ItemRecord itemRecord = iterator.next(); + itemRecord.setOperationType(OleNGConstants.CREATED); + } } catch (Exception e) { e.printStackTrace(); addFailureReportToExchange(requestJsonObject, exchange, OleNGConstants.NO_OF_FAILURE_ITEM, e , itemRecords.size()); diff --git a/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/rest/handler/items/UpdateItemHandler.java b/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/rest/handler/items/UpdateItemHandler.java index 85ac0f0878..174d83c25f 100644 --- a/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/rest/handler/items/UpdateItemHandler.java +++ b/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/rest/handler/items/UpdateItemHandler.java @@ -14,10 +14,7 @@ import java.io.IOException; import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Map; +import java.util.*; /** * Created by SheikS on 12/26/2015. @@ -41,6 +38,7 @@ public Boolean isInterested(String operation) { @Override public void process(JSONObject requestJsonObject, Exchange exchange) { List itemRecordAndDataMappings = (List) exchange.get(OleNGConstants.ITEMS_FOR_UPDATE); + Set discardedHoldingsForAdditionalOverlayOps = (Set) exchange.get(OleNGConstants.DISCARDED_HOLDINGS_FOR_ADDITIONAL_OVERLAY_OPS); List itemRecords = new ArrayList(); if (CollectionUtils.isNotEmpty(itemRecordAndDataMappings)) { @@ -52,14 +50,17 @@ public void process(JSONObject requestJsonObject, Exchange exchange) { try { ItemRecordAndDataMapping itemRecordAndDataMapping = iterator.next(); ItemRecord itemRecord = itemRecordAndDataMapping.getItemRecord(); - JSONObject dataMapping = itemRecordAndDataMapping.getDataMapping(); - itemRecord.setUpdatedBy(updatedBy); - itemRecord.setUpdatedDate(updatedDate); - exchange.add(OleNGConstants.ITEM_RECORD, itemRecord); - if (null != dataMapping) { - processOverlay(exchange, dataMapping, itemRecord); + String holdingsId = itemRecord.getHoldingsId(); + if (!isDiscardedByAdditionalOverlayOps(discardedHoldingsForAdditionalOverlayOps, holdingsId)) { + JSONObject dataMapping = itemRecordAndDataMapping.getDataMapping(); + itemRecord.setUpdatedBy(updatedBy); + itemRecord.setUpdatedDate(updatedDate); + exchange.add(OleNGConstants.ITEM_RECORD, itemRecord); + if (null != dataMapping) { + processOverlay(exchange, dataMapping, itemRecord); + } + itemRecords.add(itemRecord); } - itemRecords.add(itemRecord); } catch (Exception e) { e.printStackTrace(); addFailureReportToExchange(requestJsonObject, exchange, OleNGConstants.NO_OF_FAILURE_ITEM, e, 1); @@ -69,6 +70,10 @@ public void process(JSONObject requestJsonObject, Exchange exchange) { exchange.remove(OleNGConstants.ITEM_RECORD); try { getOleDsNGMemorizeService().getItemDAO().saveAll(itemRecords); + for (Iterator iterator = itemRecords.iterator(); iterator.hasNext(); ) { + ItemRecord itemRecord = iterator.next(); + itemRecord.setOperationType(OleNGConstants.UPDATED); + } } catch (Exception e) { e.printStackTrace(); addFailureReportToExchange(requestJsonObject, exchange, OleNGConstants.NO_OF_FAILURE_ITEM, e , itemRecords.size()); 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 8ad5a40003..c24c0c915a 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 @@ -255,13 +255,14 @@ public void buildEHoldingResponses(BibResponse bibResponse, Exchange exchange, L } } if (CollectionUtils.isNotEmpty(updateEHoldingsRecordAndDataMappings)) { - String status = OleNGConstants.DISCARDED; - if (options.contains("142")) { - status = OleNGConstants.UPDATED; - } for (HoldingsRecordAndDataMapping holdingsRecordAndDataMapping : updateEHoldingsRecordAndDataMappings) { HoldingsRecord holdingsRecord = holdingsRecordAndDataMapping.getHoldingsRecord(); - if (StringUtils.isNotBlank(holdingsRecord.getHoldingsId())) { + if (null != holdingsRecord && StringUtils.isNotBlank(holdingsRecord.getHoldingsId())) { + String operationType = holdingsRecord.getOperationType(); + String status = OleNGConstants.DISCARDED; + if (options.contains("142") && StringUtils.isNotBlank(operationType) && operationType.equalsIgnoreCase(OleNGConstants.UPDATED)) { + status = OleNGConstants.UPDATED; + } HoldingsResponse holdingsResponse = new HoldingsResponse(); holdingsResponse.setHoldingsId(DocumentUniqueIDPrefix.PREFIX_WORK_HOLDINGS_OLEML + "-" + holdingsRecord.getHoldingsId()); holdingsResponse.setOperation(status); @@ -298,13 +299,14 @@ public void buildHoldingResponses(BibResponse bibResponse, Exchange exchange, Li } if (CollectionUtils.isNotEmpty(updateHoldingsRecordAndDataMappings)) { - String status = OleNGConstants.DISCARDED; - if (options.contains("122")) { - status = OleNGConstants.UPDATED; - } for (HoldingsRecordAndDataMapping holdingsRecordAndDataMapping : updateHoldingsRecordAndDataMappings) { HoldingsRecord holdingsRecord = holdingsRecordAndDataMapping.getHoldingsRecord(); if (null != holdingsRecord && StringUtils.isNotBlank(holdingsRecord.getHoldingsId())) { + String operationType = holdingsRecord.getOperationType(); + String status = OleNGConstants.DISCARDED; + if (options.contains("122") && StringUtils.isNotBlank(operationType) && operationType.equalsIgnoreCase(OleNGConstants.UPDATED)) { + status = OleNGConstants.UPDATED; + } HoldingsResponse holdingsResponse = new HoldingsResponse(); holdingsResponse.setHoldingsId(DocumentUniqueIDPrefix.PREFIX_WORK_HOLDINGS_OLEML + "-" + holdingsRecord.getHoldingsId()); holdingsResponse.setOperation(status); @@ -340,13 +342,14 @@ public void buildItemResponse(HoldingsResponse holdingsResponse, Exchange exchan } if (!(OleNGConstants.CREATED.equalsIgnoreCase(holdingsResponse.getOperation()))) { if (CollectionUtils.isNotEmpty(updateItemRecordAndDataMappings)) { - String status = OleNGConstants.DISCARDED; - if (options.contains("122")) { - status = OleNGConstants.UPDATED; - } for (ItemRecordAndDataMapping itemRecordAndDataMapping : updateItemRecordAndDataMappings) { ItemRecord itemRecord = itemRecordAndDataMapping.getItemRecord(); - if (holdingsRecord.getHoldingsId().equals(itemRecord.getHoldingsId())) { + if (null != itemRecord && StringUtils.isNotBlank(itemRecord.getItemId()) && holdingsRecord.getHoldingsId().equals(itemRecord.getHoldingsId())) { + String operationType = itemRecord.getOperationType(); + String status = OleNGConstants.DISCARDED; + if (options.contains("122") && StringUtils.isNotBlank(operationType) && operationType.equalsIgnoreCase(OleNGConstants.UPDATED)) { + status = OleNGConstants.UPDATED; + } ItemResponse itemResponse = new ItemResponse(); itemResponse.setItemId(DocumentUniqueIDPrefix.PREFIX_WORK_ITEM_OLEML+ "-" + itemRecord.getItemId()); itemResponse.setOperation(status); diff --git a/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/util/HoldingsUtil.java b/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/util/HoldingsUtil.java index 5e6986e412..459b3c4e4c 100644 --- a/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/util/HoldingsUtil.java +++ b/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/util/HoldingsUtil.java @@ -31,14 +31,14 @@ public static HoldingsUtil getInstance() { } public void processIfDeleteAllExistOpsFound(HoldingsRecord holdingsRecord, JSONObject requestJsonObject) { - ArrayList holdingsListToDelete = getListOfItemsToDelete(holdingsRecord, requestJsonObject); + ArrayList itemListToDelete = getListOfItemsToDelete(holdingsRecord, requestJsonObject); - if (CollectionUtils.isNotEmpty(holdingsListToDelete)) { + if (CollectionUtils.isNotEmpty(itemListToDelete)) { - getBusinessObjectService().delete(holdingsListToDelete); + getBusinessObjectService().delete(itemListToDelete); StringBuilder itemIdsString = new StringBuilder(); - for (Iterator iterator = holdingsListToDelete.iterator(); iterator.hasNext(); ) { + for (Iterator iterator = itemListToDelete.iterator(); iterator.hasNext(); ) { ItemRecord itemRecord = iterator.next(); String itemId = itemRecord.getItemId(); itemIdsString.append(DocumentUniqueIDPrefix.PREFIX_WORK_ITEM_OLEML + "-" + itemId);