Skip to content

Commit

Permalink
OLE-8929 : Fixed the issue with mapping item status when doing order …
Browse files Browse the repository at this point in the history
…import.
  • Loading branch information
sheiksalahudeen committed Jul 5, 2016
1 parent d4880ab commit f19bf8b
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 9 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
@@ -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 @@ -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 f19bf8b

Please sign in to comment.