From d4880ab5d857856773416dc73a9f358e891f2aaf Mon Sep 17 00:00:00 2001 From: sheiksalahudeen Date: Tue, 5 Jul 2016 09:14:04 -0400 Subject: [PATCH 1/2] 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++) { From f19bf8b76ba2dcb97aab4366204383ea543cf6ce Mon Sep 17 00:00:00 2001 From: sheiksalahudeen Date: Tue, 5 Jul 2016 09:17:17 -0400 Subject: [PATCH 2/2] OLE-8929 : Fixed the issue with mapping item status when doing order import. --- .../oleng/service/OleNGMemorizeService.java | 2 ++ .../impl/OleNGMemorizeServiceImpl.java | 17 ++++++++++ .../ole/oleng/util/OleNGPOHelperUtil.java | 1 + .../ole/oleng/util/OleNGPOValidationUtil.java | 31 ++++++++++++++++--- .../java/org/kuali/ole}/util/ItemUtil.java | 2 +- .../rest/handler/items/ItemStatusHandler.java | 1 - .../rest/handler/items/ItemTypeHandler.java | 1 - .../impl/OleDsNGMemorizeServiceImpl.java | 2 +- 8 files changed, 48 insertions(+), 9 deletions(-) rename ole-docstore/{ole-docstore-webapp/src/main/java/org/kuali/ole/dsng => ole-docstore-engine/src/main/java/org/kuali/ole}/util/ItemUtil.java (97%) diff --git a/ole-app/olefs/src/main/java/org/kuali/ole/oleng/service/OleNGMemorizeService.java b/ole-app/olefs/src/main/java/org/kuali/ole/oleng/service/OleNGMemorizeService.java index e2a8c0ed65..f889f3b2d3 100644 --- a/ole-app/olefs/src/main/java/org/kuali/ole/oleng/service/OleNGMemorizeService.java +++ b/ole-app/olefs/src/main/java/org/kuali/ole/oleng/service/OleNGMemorizeService.java @@ -2,6 +2,7 @@ import org.kuali.ole.coa.businessobject.Account; import org.kuali.ole.coa.businessobject.OleFundCode; +import org.kuali.ole.docstore.engine.service.storage.rdbms.pojo.ItemStatusRecord; import org.kuali.ole.module.purap.businessobject.ItemType; import org.kuali.ole.module.purap.businessobject.PurchaseOrderType; import org.kuali.ole.module.purap.document.service.OlePurapService; @@ -44,4 +45,5 @@ public interface OleNGMemorizeService { public List getVendorAccountInfo(String code); public List getAccount(String accountNumber); public List getFundCode(String fundCode); + public ItemStatusRecord fetchItemStatusByName(String itemStatusTypeName); } diff --git a/ole-app/olefs/src/main/java/org/kuali/ole/oleng/service/impl/OleNGMemorizeServiceImpl.java b/ole-app/olefs/src/main/java/org/kuali/ole/oleng/service/impl/OleNGMemorizeServiceImpl.java index 2a5090633e..97674eb9f1 100644 --- a/ole-app/olefs/src/main/java/org/kuali/ole/oleng/service/impl/OleNGMemorizeServiceImpl.java +++ b/ole-app/olefs/src/main/java/org/kuali/ole/oleng/service/impl/OleNGMemorizeServiceImpl.java @@ -9,6 +9,7 @@ import org.kuali.ole.coa.businessobject.Account; import org.kuali.ole.coa.businessobject.OleFundCode; import org.kuali.ole.docstore.common.util.BusinessObjectServiceHelperUtil; +import org.kuali.ole.docstore.engine.service.storage.rdbms.pojo.ItemStatusRecord; import org.kuali.ole.module.purap.businessobject.ItemType; import org.kuali.ole.module.purap.businessobject.PurchaseOrderTransmissionMethod; import org.kuali.ole.module.purap.businessobject.PurchaseOrderType; @@ -25,6 +26,7 @@ import org.kuali.ole.sys.businessobject.Building; import org.kuali.ole.sys.businessobject.Room; import org.kuali.ole.sys.context.SpringContext; +import org.kuali.ole.util.ItemUtil; import org.kuali.ole.utility.LocationUtil; import org.kuali.ole.vnd.businessobject.*; import org.kuali.ole.vnd.document.service.VendorService; @@ -52,6 +54,7 @@ public class OleNGMemorizeServiceImpl extends BusinessObjectServiceHelperUtil private OleDocstoreHelperService oleDocstoreHelperService; private VendorService vendorService; private OlePurapService olePurapService; + private ItemUtil itemUtil; @Override public OleNgCommonMemorizeService getOleNgCommonMemorizeService() { @@ -195,6 +198,11 @@ public List getFundCode(String fundCode) { return (List) getBusinessObjectService().findMatching(OleFundCode.class, fundCodeMap); } + @Memoize + public ItemStatusRecord fetchItemStatusByName(String itemStatusTypeName) { + return getItemUtil().fetchItemStatusByName(itemStatusTypeName); + } + @Override public LocationUtil getLocationUtil() { if(null == locationUtil){ @@ -227,4 +235,13 @@ public OlePurapService getOlePurapService() { return olePurapService; } + public ItemUtil getItemUtil() { + if(null == itemUtil) { + itemUtil = new ItemUtil(); + } + return itemUtil; + } + + + } diff --git a/ole-app/olefs/src/main/java/org/kuali/ole/oleng/util/OleNGPOHelperUtil.java b/ole-app/olefs/src/main/java/org/kuali/ole/oleng/util/OleNGPOHelperUtil.java index 05697d90d8..1b5fcb2d64 100644 --- a/ole-app/olefs/src/main/java/org/kuali/ole/oleng/util/OleNGPOHelperUtil.java +++ b/ole-app/olefs/src/main/java/org/kuali/ole/oleng/util/OleNGPOHelperUtil.java @@ -89,6 +89,7 @@ public Map> processReqAndPo(List recordDeta String bibProfileName = batchProcessProfile.getBibImportProfileForOrderImport(); oleOrderRecord.setBibImportProfileName(bibProfileName); oleOrderRecord.setRecordIndex(recordIndex); + getOleNGPOValidationUtil().setOleNGMemorizeService(createReqAndPOServiceHandler.getOleNGMemorizeService()); boolean valid = getOleNGPOValidationUtil().validateOleOrderRecord(oleOrderRecord, exchange, recordIndex); if(valid) { oleOrderRecords.add(oleOrderRecord); diff --git a/ole-app/olefs/src/main/java/org/kuali/ole/oleng/util/OleNGPOValidationUtil.java b/ole-app/olefs/src/main/java/org/kuali/ole/oleng/util/OleNGPOValidationUtil.java index 0e73a59c1b..920306a43a 100644 --- a/ole-app/olefs/src/main/java/org/kuali/ole/oleng/util/OleNGPOValidationUtil.java +++ b/ole-app/olefs/src/main/java/org/kuali/ole/oleng/util/OleNGPOValidationUtil.java @@ -3,7 +3,10 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; import org.kuali.ole.Exchange; +import org.kuali.ole.docstore.engine.service.storage.rdbms.pojo.ItemStatusRecord; import org.kuali.ole.oleng.exception.ValidationException; +import org.kuali.ole.oleng.service.OleNGMemorizeService; +import org.kuali.ole.oleng.service.impl.OleNGMemorizeServiceImpl; import org.kuali.ole.pojo.OleBibRecord; import org.kuali.ole.pojo.OleOrderRecord; import org.kuali.ole.pojo.OleTxRecord; @@ -14,6 +17,7 @@ */ public class OleNGPOValidationUtil { private BatchUtil batchUtil; + private OleNGMemorizeService oleNGMemorizeService; public boolean validateOleOrderRecord(OleOrderRecord oleOrderRecord, Exchange exchange, Integer recordIndex) { boolean valid = true; @@ -159,12 +163,18 @@ private boolean validateNumberOfParts(OleTxRecord oleTxRecord, Exchange exchange private boolean validateItemStatus(OleTxRecord oleTxRecord, Exchange exchange, Integer recordIndex) { String itemStatus = oleTxRecord.getItemStatus(); - if (StringUtils.isBlank(itemStatus)){ - getBatchUtil().addOrderFaiureResponseToExchange( - new ValidationException("Item Status cannot be blank or null"), recordIndex, exchange); - return false; + if (StringUtils.isNotBlank(itemStatus)) { + ItemStatusRecord itemStatusRecord = getOleNGMemorizeService().fetchItemStatusByName(itemStatus); + if (null == itemStatusRecord) { + getBatchUtil().addOrderFaiureResponseToExchange( + new ValidationException("Invalid Item Status : " + itemStatus), recordIndex, exchange); + oleTxRecord.setItemStatus(null); + } else { + oleTxRecord.setItemStatus(itemStatusRecord.getCode()); + return true; + } } - return true; + return false; } private boolean validateOrganizationCode(OleTxRecord oleTxRecord, Exchange exchange, Integer recordIndex) { @@ -239,4 +249,15 @@ public BatchUtil getBatchUtil() { } return batchUtil; } + + public OleNGMemorizeService getOleNGMemorizeService() { + if(null == oleNGMemorizeService) { + oleNGMemorizeService = new OleNGMemorizeServiceImpl(); + } + return oleNGMemorizeService; + } + + public void setOleNGMemorizeService(OleNGMemorizeService oleNGMemorizeService) { + this.oleNGMemorizeService = oleNGMemorizeService; + } } diff --git a/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/util/ItemUtil.java b/ole-docstore/ole-docstore-engine/src/main/java/org/kuali/ole/util/ItemUtil.java similarity index 97% rename from ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/util/ItemUtil.java rename to ole-docstore/ole-docstore-engine/src/main/java/org/kuali/ole/util/ItemUtil.java index 94258c8efe..67fe05bd7b 100644 --- a/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/util/ItemUtil.java +++ b/ole-docstore/ole-docstore-engine/src/main/java/org/kuali/ole/util/ItemUtil.java @@ -1,4 +1,4 @@ -package org.kuali.ole.dsng.util; +package org.kuali.ole.util; import org.apache.commons.collections.CollectionUtils; import org.kuali.ole.docstore.common.util.BusinessObjectServiceHelperUtil; diff --git a/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/rest/handler/items/ItemStatusHandler.java b/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/rest/handler/items/ItemStatusHandler.java index 2fdb66d4b4..8b68edc576 100644 --- a/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/rest/handler/items/ItemStatusHandler.java +++ b/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/rest/handler/items/ItemStatusHandler.java @@ -8,7 +8,6 @@ import org.kuali.ole.docstore.engine.service.storage.rdbms.pojo.ItemRecord; import org.kuali.ole.docstore.engine.service.storage.rdbms.pojo.ItemStatusRecord; import org.kuali.ole.Exchange; -import org.kuali.ole.dsng.util.ItemUtil; import java.util.Iterator; import java.util.List; diff --git a/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/rest/handler/items/ItemTypeHandler.java b/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/rest/handler/items/ItemTypeHandler.java index 7030e22f77..1953780b94 100644 --- a/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/rest/handler/items/ItemTypeHandler.java +++ b/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/rest/handler/items/ItemTypeHandler.java @@ -8,7 +8,6 @@ import org.kuali.ole.docstore.engine.service.storage.rdbms.pojo.ItemRecord; import org.kuali.ole.docstore.engine.service.storage.rdbms.pojo.ItemTypeRecord; import org.kuali.ole.Exchange; -import org.kuali.ole.dsng.util.ItemUtil; import java.util.Iterator; import java.util.List; diff --git a/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/service/impl/OleDsNGMemorizeServiceImpl.java b/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/service/impl/OleDsNGMemorizeServiceImpl.java index c2082b03f1..12806c503a 100644 --- a/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/service/impl/OleDsNGMemorizeServiceImpl.java +++ b/ole-docstore/ole-docstore-webapp/src/main/java/org/kuali/ole/dsng/service/impl/OleDsNGMemorizeServiceImpl.java @@ -11,7 +11,7 @@ import org.kuali.ole.oleng.common.service.OleNgCommonMemorizeService; import org.kuali.ole.oleng.common.service.impl.OleNgCommonMemorizeServiceImpl; import org.kuali.ole.select.bo.OLEDonor; -import org.kuali.ole.utility.DonorUtil; +import org.kuali.ole.util.ItemUtil; import org.kuali.ole.utility.LocationUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component;