Skip to content

Commit

Permalink
Merge pull request #824 from sheiksalahudeen/release-2.1
Browse files Browse the repository at this point in the history
Fixed issues and merged
  • Loading branch information
sheiksalahudeen authored Jul 5, 2016
2 parents 7eb3417 + f19bf8b commit 8d5673e
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -44,4 +45,5 @@ public interface OleNGMemorizeService {
public List<OleVendorAccountInfo> getVendorAccountInfo(String code);
public List<Account> getAccount(String accountNumber);
public List<OleFundCode> getFundCode(String fundCode);
public ItemStatusRecord fetchItemStatusByName(String itemStatusTypeName);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -195,6 +198,11 @@ public List<OleFundCode> 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){
Expand Down Expand Up @@ -227,4 +235,13 @@ public OlePurapService getOlePurapService() {
return olePurapService;
}

public ItemUtil getItemUtil() {
if(null == itemUtil) {
itemUtil = new ItemUtil();
}
return itemUtil;
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public Map<Integer, Set<Integer>> processReqAndPo(List<RecordDetails> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ private JSONObject prepareRequest(Integer index, String bibId, Record marcRecord
// Prepare data mapping before MARC Transformation
Map<String, List<JSONObject>> 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);
Expand All @@ -214,19 +217,16 @@ private JSONObject prepareRequest(Integer index, String bibId, Record marcRecord
List<JSONObject> bibDataMappingsPostTrans = dataMappingsMapPostTransformations.get(OleNGConstants.BIB_DATAMAPPINGS);
bibData.put(OleNGConstants.DATAMAPPING, buildOneObjectForList(bibDataMappingsPreTrans, bibDataMappingsPostTrans));

JSONObject holdingsData = getMatchPointProcessor().prepareMatchPointsForHoldings(marcRecord, batchProcessProfile);
List<JSONObject> holdingsDataMappingsPreTrans = dataMappingsMapPreTransformation.get(OleNGConstants.HOLDINGS_DATAMAPPINGS);
List<JSONObject> 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<JSONObject> eholdingsDataMappingsPreTrans = dataMappingsMapPreTransformation.get(OleNGConstants.EHOLDINGS_DATAMAPPINGS);
List<JSONObject> 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<JSONObject> itemsDataMappingsPreTrans = dataMappingsMapPreTransformation.get(OleNGConstants.ITEM_DATAMAPPINGS);
List<JSONObject> itemsDataMappingsPostTrans = dataMappingsMapPostTransformations.get(OleNGConstants.ITEM_DATAMAPPINGS);
itemData.put(OleNGConstants.DATAMAPPING, buildOneObjectForList(itemsDataMappingsPreTrans, itemsDataMappingsPostTrans));
Expand Down Expand Up @@ -286,8 +286,8 @@ public List<JSONObject> buildOneObjectForList(List<JSONObject> dataMappingsPreTr
List<JSONObject> 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));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
Expand Down Expand Up @@ -1105,49 +1105,6 @@ private BibRecord prepareBib(JSONObject bibJSONDataObject) {
return bibRecord;
}

private List<HoldingsResponse> holdingsResponse(Exchange exchange, List holdingRecords, String operation) {
List<HoldingsResponse> holdingsResponses = new ArrayList<HoldingsResponse>();
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<ItemResponse> prepareItemsResponse(HoldingsRecord holdingsRecord, Exchange exchange) {
List<ItemResponse> itemResponses = new ArrayList<ItemResponse>();

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> itemResponse(HoldingsRecord holdingsRecord, List itemRecords, String operation) {
List<ItemResponse> itemResponses = new ArrayList<ItemResponse>();
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++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 8d5673e

Please sign in to comment.