1 package org.kuali.ole.service.impl;
2
3 import org.apache.commons.lang.StringUtils;
4 import org.kuali.ole.DataCarrierService;
5 import org.kuali.ole.OLEConstants;
6 import org.kuali.ole.batch.bo.*;
7 import org.kuali.ole.batch.controller.OLEBatchProcessProfileController;
8 import org.kuali.ole.coa.businessobject.Account;
9 import org.kuali.ole.coa.businessobject.Chart;
10 import org.kuali.ole.coa.businessobject.ObjectCode;
11 import org.kuali.ole.coa.businessobject.Organization;
12 import org.kuali.ole.describe.bo.OleItemAvailableStatus;
13 import org.kuali.ole.describe.bo.OleLocation;
14 import org.kuali.ole.describe.bo.OleLocationLevel;
15 import org.kuali.ole.docstore.common.client.DocstoreClientLocator;
16 import org.kuali.ole.docstore.common.document.content.bib.marc.BibMarcRecord;
17 import org.kuali.ole.ingest.LineItemOrderMatcherForBib;
18 import org.kuali.ole.ingest.OleTxRecordBuilder;
19 import org.kuali.ole.module.purap.businessobject.*;
20 import org.kuali.ole.pojo.OleOrderRecord;
21 import org.kuali.ole.pojo.OleTxRecord;
22 import org.kuali.ole.pojo.edi.EDIOrder;
23 import org.kuali.ole.pojo.edi.LineItemOrder;
24 import org.kuali.ole.select.OleSelectConstant;
25 import org.kuali.ole.select.bo.OLEDonor;
26 import org.kuali.ole.select.businessobject.OLERequestorPatronDocument;
27 import org.kuali.ole.select.businessobject.OleFormatType;
28 import org.kuali.ole.select.document.service.OleDocstoreHelperService;
29 import org.kuali.ole.select.document.service.OleSelectDocumentService;
30 import org.kuali.ole.service.OleOrderRecordService;
31 import org.kuali.ole.sys.businessobject.Building;
32 import org.kuali.ole.sys.businessobject.Room;
33 import org.kuali.ole.sys.context.SpringContext;
34 import org.kuali.ole.vnd.businessobject.ContractManager;
35 import org.kuali.ole.vnd.businessobject.PurchaseOrderCostSource;
36 import org.kuali.ole.vnd.businessobject.VendorCustomerNumber;
37 import org.kuali.ole.vnd.businessobject.VendorDetail;
38 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
39 import org.kuali.rice.core.api.util.ConcreteKeyValue;
40 import org.kuali.rice.core.api.util.KeyValue;
41 import org.kuali.rice.coreservice.api.CoreServiceApiServiceLocator;
42 import org.kuali.rice.coreservice.api.parameter.Parameter;
43 import org.kuali.rice.coreservice.api.parameter.ParameterKey;
44 import org.kuali.rice.kim.api.identity.Person;
45 import org.kuali.rice.kim.api.identity.PersonService;
46 import org.kuali.rice.krad.service.BusinessObjectService;
47 import org.kuali.rice.krad.service.KRADServiceLocator;
48 import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
49 import org.kuali.rice.krad.service.LookupService;
50
51 import java.text.ParseException;
52 import java.text.SimpleDateFormat;
53 import java.util.*;
54
55
56
57
58
59
60
61
62 public class OleOrderRecordServiceImpl implements OleOrderRecordService {
63
64
65 private DocstoreClientLocator docstoreClientLocator;
66 private BusinessObjectService businessObjectService;
67 private OleSelectDocumentService oleSelectDocumentService;
68 protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OleOrderRecordServiceImpl.class);
69 private OleDocstoreHelperService oleDocstoreHelperService;
70
71 public DocstoreClientLocator getDocstoreClientLocator() {
72 if (docstoreClientLocator == null) {
73 docstoreClientLocator = SpringContext.getBean(DocstoreClientLocator.class);
74 }
75 return docstoreClientLocator;
76 }
77
78 public BusinessObjectService getBusinessObjectService() {
79 if(businessObjectService==null)
80 businessObjectService = KRADServiceLocator.getBusinessObjectService();
81 return businessObjectService;
82 }
83
84 public OleSelectDocumentService getOleSelectDocumentService() {
85 if (oleSelectDocumentService == null) {
86 oleSelectDocumentService = SpringContext.getBean(OleSelectDocumentService.class);
87 }
88 return oleSelectDocumentService;
89 }
90
91 public OleDocstoreHelperService getOleDocstoreHelperService() {
92 if (oleDocstoreHelperService == null) {
93 oleDocstoreHelperService = SpringContext.getBean(OleDocstoreHelperService.class);
94 }
95 return oleDocstoreHelperService;
96 }
97
98 private Map<String,String> fundDetails = new HashMap<String,String>();
99 private List<String> failureRecords = new ArrayList<>();
100
101 private LookupService getLookupService() {
102 return KRADServiceLocatorWeb.getLookupService();
103 }
104
105
106 @Override
107 public OleOrderRecord fetchOleOrderRecordForMarcEdi(String bibId,EDIOrder ediOrder,BibMarcRecord bibMarcRecord,int recordPosition, OLEBatchProcessJobDetailsBo job) throws Exception{
108 LOG.debug("----Inside fetchOleOrderRecordForMarcEdi()------------------------------");
109 OrderImportHelperBo orderImportHelperBo = job.getOrderImportHelperBo();
110 OleOrderRecord oleOrderRecord = new OleOrderRecord();
111 oleOrderRecord.setOriginalRecord(bibMarcRecord);
112 oleOrderRecord.setOriginalEdi(ediOrder);
113 boolean validBFNFlag=isValidBFN(ediOrder,bibMarcRecord);
114 if (validBFNFlag) {
115 OleTxRecord oleTxRecord = getMatchingTxRecord(ediOrder, bibMarcRecord);
116 oleTxRecord.setItemType(OLEConstants.ITEM_TYP);
117 oleTxRecord.setAccountNumber(fundDetails.keySet().iterator().next());
118 oleTxRecord.setObjectCode(fundDetails.get(oleTxRecord.getAccountNumber()));
119 Map<String,String> accLinesMap = new HashMap<>();
120 accLinesMap.put(OLEConstants.ACCOUNT_NUMBER,oleTxRecord.getAccountNumber());
121 List<Account> accountList = (List) getBusinessObjectService().findMatching(Account.class, accLinesMap);
122 if(accountList != null && accountList.size() > 0){
123 oleTxRecord.setItemChartCode(accountList.get(0).getChartOfAccountsCode());
124 }
125 fundDetails.clear();
126 setDefaultAndConstantValuesToTxnRecord(oleTxRecord,null,job);
127 setAccountingLinesDetails(oleTxRecord,recordPosition,job);
128 validateChartCodeAndOrgCodeCombination(oleTxRecord.getChartCode(),oleTxRecord.getOrgCode(),recordPosition,job);
129 validateDeliveryDetails(oleTxRecord.getBuildingCode(), oleTxRecord.getDeliveryCampusCode(), recordPosition, oleTxRecord.getDeliveryBuildingRoomNumber(), job);
130
131 oleTxRecord.setRequisitionSource(OleSelectConstant.REQUISITON_SRC_TYPE_AUTOINGEST);
132 oleOrderRecord.setOleTxRecord(oleTxRecord);
133 oleOrderRecord.addMessageToMap(OLEConstants.IS_VALID_BFN,validBFNFlag);
134 } else {
135 oleOrderRecord.addMessageToMap(OLEConstants.IS_VALID_BFN,OLEConstants.FALSE);
136 if(bibId!=null){
137 try{
138 getDocstoreClientLocator().getDocstoreClient().deleteBib(bibId);
139 }catch (Exception e){
140 LOG.error("Exception while deleting bib " +bibId);
141 }
142 }
143 OleTxRecord oleTxRecord = getMatchingTxRecord(ediOrder, bibMarcRecord);
144 setDefaultAndConstantValuesToTxnRecord(oleTxRecord,null,job);
145 setAccountingLinesDetails(oleTxRecord,recordPosition,job);
146 validateChartCodeAndOrgCodeCombination(oleTxRecord.getChartCode(),oleTxRecord.getOrgCode(),recordPosition,job);
147 validateDeliveryDetails(oleTxRecord.getBuildingCode(), oleTxRecord.getDeliveryCampusCode(), recordPosition, oleTxRecord.getDeliveryBuildingRoomNumber(), job);
148
149 oleTxRecord.setRequisitionSource(OleSelectConstant.REQUISITON_SRC_TYPE_AUTOINGEST);
150 oleOrderRecord.setOleTxRecord(oleTxRecord);
151 }
152
153 orderImportHelperBo.setOleTxRecord(oleOrderRecord.getOleTxRecord());
154 LOG.debug("----End of fetchOleOrderRecordForMarcEdi()------------------------------");
155 return oleOrderRecord;
156 }
157
158
159 @Override
160 public OleOrderRecord fetchOleOrderRecordForMarc(String bibId, BibMarcRecord bibMarcRecord,int recordPosition, OLEBatchProcessJobDetailsBo job) throws Exception{
161 LOG.debug("----Inside fetchOleOrderRecordForMarc()------------------------------");
162 OrderImportHelperBo orderImportHelperBo = job.getOrderImportHelperBo();
163 OleOrderRecord oleOrderRecord = new OleOrderRecord();
164 oleOrderRecord.setOriginalRecord(bibMarcRecord);
165 OleTxRecord oleTxRecord = new OleTxRecord();
166 oleTxRecord.setItemType(OLEConstants.ITEM_TYP);
167 Map<String,String> failureMsges = new HashMap<>();
168 failureMsges = mapDataFieldsToTxnRecord(oleTxRecord, bibMarcRecord,recordPosition, job);
169 failureMsges = setDefaultAndConstantValuesToTxnRecord(oleTxRecord,failureMsges, job);
170 validateChartCodeAndOrgCodeCombination(oleTxRecord.getChartCode(),oleTxRecord.getOrgCode(),recordPosition, job);
171 validateDeliveryDetails(oleTxRecord.getBuildingCode(), oleTxRecord.getDeliveryCampusCode(), recordPosition, oleTxRecord.getDeliveryBuildingRoomNumber(), job);
172
173 Collection failureList = failureMsges.values();
174 if(failureList != null && failureList.size() > 0){
175
176 List reasonForFailure = orderImportHelperBo.getFailureReason();
177 if(reasonForFailure != null){
178 reasonForFailure.addAll(failureList);
179
180 orderImportHelperBo.setFailureReason(reasonForFailure);
181 failureList.clear();
182 failureRecords.clear();
183 }
184 }
185 oleTxRecord.setRequisitionSource(OleSelectConstant.REQUISITON_SRC_TYPE_AUTOINGEST);
186 if(oleTxRecord.getOrderType() == null){
187 oleTxRecord.setOrderType(OLEConstants.ORDER_TYPE_VALUE);
188 }
189 setAccountingLinesDetails(oleTxRecord,recordPosition,job);
190 oleOrderRecord.setOleTxRecord(oleTxRecord);
191
192 orderImportHelperBo.setOleTxRecord(oleOrderRecord.getOleTxRecord());
193 LOG.debug("----End of fetchOleOrderRecordForMarc()------------------------------");
194 return oleOrderRecord;
195 }
196
197
198
199
200
201
202 private String getValueForVendorProfileCodeFromProfile(OLEBatchProcessProfileBo oleBatchProcessProfileBo){
203 LOG.debug("----Inside getValueForVendorProfileCodeFromProfile()------------------------------");
204 List<OLEBatchProcessProfileMappingOptionsBo> oleBatchProcessProfileMappingOptionsBoList = oleBatchProcessProfileBo.getOleBatchProcessProfileMappingOptionsList();
205 for (OLEBatchProcessProfileMappingOptionsBo oleBatchProcessProfileMappingOptionsBo : oleBatchProcessProfileMappingOptionsBoList) {
206 List<OLEBatchProcessProfileDataMappingOptionsBo> oleBatchProcessProfileDataMappingOptionsBoList = oleBatchProcessProfileMappingOptionsBo.getOleBatchProcessProfileDataMappingOptionsBoList();
207 for (int dataMapCount = 0;dataMapCount<oleBatchProcessProfileDataMappingOptionsBoList.size();dataMapCount++) {
208 String sourceField = oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getSourceField();
209 String sourceFields[] = sourceField.split("\\$");
210 if (sourceFields.length == 2) {
211 if (OLEConstants.OLEBatchProcess.VENDOR_PROFILE_CODE.equals(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField())) {
212 return oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationFieldValue();
213 }
214 }
215 }
216 }
217 List<OLEBatchProcessProfileConstantsBo> oleBatchProcessProfileConstantsBoList = oleBatchProcessProfileBo.getOleBatchProcessProfileConstantsList();
218 for (OLEBatchProcessProfileConstantsBo oleBatchProcessProfileConstantsBo : oleBatchProcessProfileConstantsBoList) {
219 if (StringUtils.isNotBlank(oleBatchProcessProfileConstantsBo.getDataType()) && OLEConstants.OLEBatchProcess.ORDER_IMPORT.equalsIgnoreCase(oleBatchProcessProfileConstantsBo.getDataType())
220 && StringUtils.isNotBlank(oleBatchProcessProfileConstantsBo.getAttributeValue()) && StringUtils.isNotBlank(oleBatchProcessProfileConstantsBo.getAttributeName())) {
221 if (OLEConstants.OLEBatchProcess.CONSTANT.equals(oleBatchProcessProfileConstantsBo.getDefaultValue())) {
222 if (OLEConstants.OLEBatchProcess.VENDOR_PROFILE_CODE.equals(oleBatchProcessProfileConstantsBo.getAttributeName())) {
223 return oleBatchProcessProfileConstantsBo.getAttributeValue();
224 }
225 }
226 else if (OLEConstants.OLEBatchProcess.DEFAULT.equals(oleBatchProcessProfileConstantsBo.getDefaultValue())) {
227 if (OLEConstants.OLEBatchProcess.VENDOR_PROFILE_CODE.equals(oleBatchProcessProfileConstantsBo.getAttributeName())) {
228 return oleBatchProcessProfileConstantsBo.getAttributeValue();
229 }
230 }
231 }
232 }
233 return null;
234 }
235
236
237
238
239
240
241 private void validateChartCodeAndOrgCodeCombination(String chartCode,String orgCode,int recordPosition, OLEBatchProcessJobDetailsBo job){
242 OrderImportHelperBo orderImportHelperBo = job.getOrderImportHelperBo();
243 Map<String,String> orgCodeMap = new HashMap<>();
244 orgCodeMap.put(OLEConstants.OLEBatchProcess.ORGANIZATION_CODE, orgCode);
245 orgCodeMap.put(OLEConstants.OLEBatchProcess.CHART_OF_ACCOUNTS_CODE, chartCode);
246 List<Organization> organizationCodeList = (List) getBusinessObjectService().findMatching(Organization.class, orgCodeMap);
247 if(organizationCodeList == null || organizationCodeList.size() == 0){
248
249 List<String> reasonForFailure = orderImportHelperBo.getFailureReason();
250 if(reasonForFailure != null){
251 reasonForFailure.add(OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.OLEBatchProcess.INVALID_ORGCD_CHARTCD_COMBINATION);
252
253 orderImportHelperBo.setFailureReason(reasonForFailure);
254 }
255 }
256 }
257
258 private void validateDeliveryDetails(String buildingCode, String campusCode, int recordPosition, String deliveryBuildingRoomNumber, OLEBatchProcessJobDetailsBo job){
259 OrderImportHelperBo orderImportHelperBo = job.getOrderImportHelperBo();
260 Map<String,String> deliveryMap = new HashMap<>();
261 deliveryMap.put(OLEConstants.OLEBatchProcess.BUILDING_CODE, buildingCode);
262 deliveryMap.put(OLEConstants.OLEBatchProcess.CAMPUS_CODE, campusCode);
263 deliveryMap.put(OLEConstants.BUILDING_ROOM_NUMBER, deliveryBuildingRoomNumber);
264 List<Room> roomList = (List) getBusinessObjectService().findMatching(Room.class, deliveryMap);
265 if(roomList == null || roomList.size() == 0){
266
267 List<String> reasonForFailure = orderImportHelperBo.getFailureReason();
268 if(reasonForFailure != null){
269 reasonForFailure.add(OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.OLEBatchProcess.INVALID_BLDGCD_CMPCD_ROOM_COMBINATION);
270
271 orderImportHelperBo.setFailureReason(reasonForFailure);
272 }
273 }
274 }
275
276 private void validateVendorCustomerNumber(OleTxRecord oleTxRecord, OLEBatchProcessJobDetailsBo job){
277 OrderImportHelperBo orderImportHelperBo = job.getOrderImportHelperBo();
278 String[] vendorDetail = oleTxRecord.getVendorNumber().split("-");
279 String vendorHeaderGeneratedIdentifier = vendorDetail[0];
280 String vendorDetailAssignedIdentifier = vendorDetail[1];
281 try {
282 Map<String,Object> vendorCustomerMap = new HashMap<>();
283 vendorCustomerMap.put(OLEConstants.VENDOR_HEADER_GENERATED_ID, vendorHeaderGeneratedIdentifier);
284 vendorCustomerMap.put(OLEConstants.VENDOR_DETAILED_ASSIGNED_ID, vendorDetailAssignedIdentifier);
285 vendorCustomerMap.put(OLEConstants.OLEBatchProcess.VENDOR_CUST_NBR,oleTxRecord.getVendorInfoCustomer());
286 List<VendorCustomerNumber> vendorCustomerList = (List) getBusinessObjectService().findMatching(VendorCustomerNumber.class, vendorCustomerMap);
287 if(vendorCustomerList == null || vendorCustomerList.size() == 0){
288 List reasonForFailure = new ArrayList();
289 reasonForFailure.add(OLEConstants.OLEBatchProcess.INVALID_VNDRNBR_CUSTNBR_COMBINATION);
290
291 orderImportHelperBo.setFailureReason(reasonForFailure);
292 }
293 }
294 catch (NumberFormatException nfe) {
295 nfe.printStackTrace();
296 }
297 }
298
299
300
301
302
303
304
305
306 private boolean isValidBFN(EDIOrder ediOrder, BibMarcRecord bibMarcRecord) throws Exception {
307 LOG.debug("----Inside isValidBFN()------------------------------");
308 LineItemOrderMatcherForBib lineItemOrderMatcherForBib = new LineItemOrderMatcherForBib();
309 String vendorProfileCode = OLEConstants.PROFILE_AGENDA_NM;
310 LineItemOrder lineItemOrder = lineItemOrderMatcherForBib.getLineItemOrder(ediOrder.getLineItemOrder(), bibMarcRecord, vendorProfileCode);
311 String bfn=null;
312 if(lineItemOrder!=null){
313 Map<String, String> accountInfo = OleTxRecordBuilder.getInstance().getAccountInfo(lineItemOrder);
314 if(accountInfo != null && accountInfo.size()>0) {
315 fundDetails.putAll(accountInfo);
316 }
317 bfn = accountInfo!=null?"1":null;
318 }
319 if(bfn!=null)
320 return true;
321 return false;
322 }
323
324
325
326
327
328
329 private OleTxRecord getMatchingTxRecord(EDIOrder ediOrder, BibMarcRecord bibMarcRecord) throws Exception {
330 LineItemOrderMatcherForBib lineItemOrderMatcherForBib = new LineItemOrderMatcherForBib();
331 String vendorProfileCode = OLEConstants.PROFILE_AGENDA_NM;
332 LineItemOrder lineItemOrder = lineItemOrderMatcherForBib.getLineItemOrder(ediOrder.getLineItemOrder(), bibMarcRecord, vendorProfileCode);
333 OleTxRecord oleTxRecord = OleTxRecordBuilder.getInstance().build(lineItemOrder, ediOrder);
334 return oleTxRecord;
335 }
336
337 private Map<String,String> mapDataFieldsToTxnRecord(OleTxRecord oleTxRecord, BibMarcRecord bibMarcRecord,int recordPosition, OLEBatchProcessJobDetailsBo job) {
338 Map<String,String> mappingFailures = new HashMap<String,String>();
339 LOG.debug("----Inside mapDataFieldsToTxnRecord()------------------------------");
340 String destinationField = null;
341 List<OLEBatchProcessProfileMappingOptionsBo> oleBatchProcessProfileMappingOptionsBoList = job.getOrderImportHelperBo().getOleBatchProcessProfileBo().getOleBatchProcessProfileMappingOptionsList();
342 for (OLEBatchProcessProfileMappingOptionsBo oleBatchProcessProfileMappingOptionsBo : oleBatchProcessProfileMappingOptionsBoList) {
343 List<OLEBatchProcessProfileDataMappingOptionsBo> oleBatchProcessProfileDataMappingOptionsBoList = oleBatchProcessProfileMappingOptionsBo.getOleBatchProcessProfileDataMappingOptionsBoList();
344 Collections.sort(oleBatchProcessProfileDataMappingOptionsBoList, new Comparator<OLEBatchProcessProfileDataMappingOptionsBo>() {
345 @Override
346 public int compare(OLEBatchProcessProfileDataMappingOptionsBo obj1, OLEBatchProcessProfileDataMappingOptionsBo obj2) {
347 int result = obj1.getDestinationField().compareTo(obj2.getDestinationField());
348 if(result != 0){
349 return result;
350 }
351 return obj1.getPriority() > obj2.getPriority() ? -1 : obj1.getPriority() < obj2.getPriority() ? 1 : 0;
352 }
353 });
354 List<String> donors=new ArrayList<>();
355 List<String> miscellaneousNotes = new ArrayList<>();
356 List<String> receiptNotes = new ArrayList<>();
357 List<String> requestorNotes = new ArrayList<>();
358 List<String> selectorNotes = new ArrayList<>();
359 List<String> splProcessInstrNotes = new ArrayList<>();
360 List<String> vendorInstrNotes = new ArrayList<>();
361 for (int dataMapCount = 0;dataMapCount<oleBatchProcessProfileDataMappingOptionsBoList.size();dataMapCount++) {
362 destinationField = oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField();
363 String sourceField = oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getSourceField();
364 String sourceFields[] = sourceField.split("\\$");
365 if (sourceFields.length == 2) {
366 String dataField = sourceFields[0].trim();
367 String tagField = sourceFields[1].trim();
368 if (OLEConstants.OLEBatchProcess.CHART_CODE.equals(destinationField)) {
369 String chartCode = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList,dataMapCount,bibMarcRecord,dataField,tagField);
370 if(!StringUtils.isBlank(chartCode)) {
371 Map<String,String> chartCodeMap = new HashMap<>();
372 chartCodeMap.put(OLEConstants.OLEBatchProcess.CHART_OF_ACCOUNTS_CODE, chartCode);
373 List<Organization> chartCodeList = (List) getBusinessObjectService().findMatching(Organization.class, chartCodeMap);
374 if(chartCodeList!= null && chartCodeList.size() == 0){
375 mappingFailures.put(OLEConstants.OLEBatchProcess.CHART_OF_ACCOUNTS_CODE, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.INVALID_CHART_CD + " " + dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField + " " + chartCode);
376 chartCode = null;
377 }
378 oleTxRecord.setChartCode(chartCode);
379 }
380 else {
381 mappingFailures.put(OLEConstants.OLEBatchProcess.CHART_OF_ACCOUNTS_CODE, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.REQUIRED_CHART_CODE + " " + dataField + OLEConstants.DELIMITER_DOLLAR + tagField + " " + OLEConstants.NULL_VALUE_MESSAGE);
382 }
383 }
384 else if (OLEConstants.OLEBatchProcess.ORG_CODE.equals(destinationField)) {
385 String orgCode = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList,dataMapCount,bibMarcRecord,dataField,tagField);
386 if(!StringUtils.isBlank(orgCode)){
387 Map<String,String> orgCodeMap = new HashMap<>();
388 orgCodeMap.put(OLEConstants.OLEBatchProcess.ORGANIZATION_CODE, orgCode);
389 List<Organization> organizationCodeList = (List) getBusinessObjectService().findMatching(Organization.class, orgCodeMap);
390 if(organizationCodeList != null && organizationCodeList.size() == 0){
391 mappingFailures.put(OLEConstants.OLEBatchProcess.ORGANIZATION_CODE, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.INVALID_ORG_CD + " " +dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField + " " + orgCode);
392 orgCode = null;
393 }
394 oleTxRecord.setOrgCode(orgCode);
395 }
396 else {
397 mappingFailures.put(OLEConstants.OLEBatchProcess.ORGANIZATION_CODE, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.REQUIRED_ORG_CODE + " " + dataField + OLEConstants.DELIMITER_DOLLAR + tagField + " " + OLEConstants.NULL_VALUE_MESSAGE);
398 }
399 }
400 else if (OLEConstants.OLEBatchProcess.CONTRACT_MANAGER.equals(destinationField)) {
401 String contractManager = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList,dataMapCount,bibMarcRecord,dataField,tagField);
402 if(!StringUtils.isBlank(contractManager)){
403 Map<String,String> contractManagerMap = new HashMap<>();
404 contractManagerMap.put(OLEConstants.OLEBatchProcess.CONTRACT_MANAGER_NAME, contractManager);
405 List<ContractManager> contractManagerList = (List) getBusinessObjectService().findMatching(ContractManager.class, contractManagerMap);
406 if(contractManagerList != null && contractManagerList.size() == 0){
407 mappingFailures.put(OLEConstants.OLEBatchProcess.CONTRACT_MANAGER_NAME, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.INVALID_CONTRACT_MANAGER_NM + " " +dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField + " " + contractManager);
408 contractManager = null;
409 }
410 oleTxRecord.setContractManager(contractManager);
411 }
412 else {
413 mappingFailures.put(OLEConstants.OLEBatchProcess.CONTRACT_MANAGER_NAME,OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.REQUIRED_CONTRACT_MGR_NM + " " + dataField + OLEConstants.DELIMITER_DOLLAR + tagField + " " + OLEConstants.NULL_VALUE_MESSAGE);
414 }
415 }
416 else if (OLEConstants.OLEBatchProcess.ASSIGN_TO_USER.equals(destinationField)) {
417 String assignToUser = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList,dataMapCount,bibMarcRecord,dataField,tagField);
418 if(!StringUtils.isBlank(assignToUser)){
419 Person assignedUser = SpringContext.getBean(PersonService.class).getPersonByPrincipalName(assignToUser);
420 if(assignedUser == null){
421 mappingFailures.put(OLEConstants.OLEBatchProcess.ASSIGN_TO_USER,OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.INVALID_ASSIGN_TO_USER + " " +dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField + " " + assignToUser);
422 assignToUser = null;
423 }
424 oleTxRecord.setAssignToUser(assignToUser);
425 }
426 else{
427 mappingFailures.put(OLEConstants.OLEBatchProcess.ASSIGN_TO_USER,OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.REQUIRED_ASSIGN_TO_USER + " " + dataField + OLEConstants.DELIMITER_DOLLAR + tagField + " " + OLEConstants.NULL_VALUE_MESSAGE);
428 }
429 }
430 else if (OLEConstants.OLEBatchProcess.ORDER_TYPE.equals(destinationField)) {
431 String orderType = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList,dataMapCount,bibMarcRecord,dataField,tagField);
432 if(!StringUtils.isBlank(orderType)){
433 Map<String,String> orderTypeMap = new HashMap<>();
434 orderTypeMap.put(OLEConstants.OLEBatchProcess.PURCHASE_ORDER_TYPE, orderType);
435 List<PurchaseOrderType> purchaseOrderTypeList = (List) getBusinessObjectService().findMatching(PurchaseOrderType.class, orderTypeMap);
436 if(purchaseOrderTypeList != null && purchaseOrderTypeList.size() == 0){
437 mappingFailures.put(OLEConstants.OLEBatchProcess.PURCHASE_ORDER_TYPE,OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.INVALID_ORDER_TYPE + " " +dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField + " " + orderType);
438 orderType = null;
439 }
440 oleTxRecord.setOrderType(orderType);
441 }
442 else {
443 mappingFailures.put(OLEConstants.OLEBatchProcess.PURCHASE_ORDER_TYPE,OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.REQUIRED_ORDER_TYPE + " " + dataField + OLEConstants.DELIMITER_DOLLAR + tagField + " " + OLEConstants.NULL_VALUE_MESSAGE);
444 }
445 }
446 else if (OLEConstants.OLEBatchProcess.FUNDING_SOURCE.equals(destinationField)) {
447 String fundingSource = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList,dataMapCount,bibMarcRecord,dataField,tagField);
448 if(!StringUtils.isBlank(fundingSource)){
449 Map<String,String> fundingSourceMap = new HashMap<>();
450 fundingSourceMap.put(OLEConstants.OLEBatchProcess.FUNDING_SOURCE_CODE, fundingSource);
451 List<FundingSource> fundingSourceList = (List) getBusinessObjectService().findMatching(FundingSource.class, fundingSourceMap);
452 if(fundingSourceList != null && fundingSourceList.size() == 0){
453 mappingFailures.put(OLEConstants.OLEBatchProcess.FUNDING_SOURCE_CODE,OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.INVALID_FUNDING_SOURCE_CD + " " +dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField + " " + fundingSource);
454 fundingSource = null;
455 }
456 oleTxRecord.setFundingSource(fundingSource);
457 }
458 else {
459 mappingFailures.put(OLEConstants.OLEBatchProcess.FUNDING_SOURCE_CODE,OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.REQUIRED_FUNDING_SOURCE+ " " + dataField + OLEConstants.DELIMITER_DOLLAR + tagField + " " + OLEConstants.NULL_VALUE_MESSAGE);
460 }
461 }
462 else if (OLEConstants.OLEBatchProcess.DELIVERY_CAMPUS_CODE.equals(destinationField)) {
463 String deliveryCampusCode = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList,dataMapCount,bibMarcRecord,dataField,tagField);
464 if(!StringUtils.isBlank(deliveryCampusCode)){
465 Map<String,String> campusCodeMap = new HashMap<>();
466 campusCodeMap.put(OLEConstants.OLEBatchProcess.CAMPUS_CODE, deliveryCampusCode);
467 List<Building> campusList= (List) getBusinessObjectService().findMatching(Building.class, campusCodeMap);
468 if(campusList != null && campusList.size() == 0){
469 mappingFailures.put(OLEConstants.OLEBatchProcess.CAMPUS_CODE,OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.INVALID_CAMPUS_CODE + " " +dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField + " " + deliveryCampusCode);
470 deliveryCampusCode = null;
471 }
472 oleTxRecord.setDeliveryCampusCode(deliveryCampusCode);
473 }
474 else {
475 mappingFailures.put(OLEConstants.OLEBatchProcess.CAMPUS_CODE,OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.REQUIRED_DELIVERY_CAMPUS_CODE + " " + dataField + OLEConstants.DELIMITER_DOLLAR + tagField + " " + OLEConstants.NULL_VALUE_MESSAGE);
476 }
477 }
478 else if (OLEConstants.OLEBatchProcess.BUILDING_CODE.equals(destinationField)) {
479 String buildingCode = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList,dataMapCount,bibMarcRecord,dataField,tagField);
480 if(!StringUtils.isBlank(buildingCode)){
481 Map<String,String> buildingCodeMap = new HashMap<>();
482 buildingCodeMap.put(OLEConstants.OLEBatchProcess.BUILDING_CODE, buildingCode);
483 List<Building> buildingList= (List) getBusinessObjectService().findMatching(Building.class, buildingCodeMap);
484 if(buildingList != null && buildingList.size() == 0){
485 mappingFailures.put(OLEConstants.OLEBatchProcess.BUILDING_CODE,OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.INVALID_BUILDING_CD + " " +dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField + " " + buildingCode);
486 buildingCode = null;
487 }
488 oleTxRecord.setBuildingCode(buildingCode);
489 }
490 else{
491 mappingFailures.put(OLEConstants.OLEBatchProcess.BUILDING_CODE,OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.REQUIRED_BUILDING_CD + " " + dataField + OLEConstants.DELIMITER_DOLLAR + tagField + " " + OLEConstants.NULL_VALUE_MESSAGE);
492 }
493 }
494 else if (OLEConstants.OLEBatchProcess.DELIVERY_BUILDING_ROOM_NUMBER.equals(destinationField)) {
495 String deliveryBuildingRoomNumber = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList,dataMapCount,bibMarcRecord,dataField,tagField);
496 if(!StringUtils.isBlank(deliveryBuildingRoomNumber)){
497 Map<String,String> deliveryBuildingRoomNumberMap = new HashMap<>();
498 deliveryBuildingRoomNumberMap.put(OLEConstants.BUILDING_ROOM_NUMBER, deliveryBuildingRoomNumber);
499 List<Room> roomList= (List) getBusinessObjectService().findMatching(Room.class, deliveryBuildingRoomNumberMap);
500 if(roomList != null && roomList.size() == 0){
501 mappingFailures.put(OLEConstants.OLEBatchProcess.DELIVERY_BUILDING_ROOM_NUMBER,OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.INVALID_DELIVERY_BUILDING_ROOM_NUMBER + " " +dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField + " " + deliveryBuildingRoomNumber);
502 deliveryBuildingRoomNumber = null;
503 }
504 oleTxRecord.setDeliveryBuildingRoomNumber(deliveryBuildingRoomNumber);
505 }
506 else{
507 mappingFailures.put(OLEConstants.OLEBatchProcess.DELIVERY_BUILDING_ROOM_NUMBER,OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.REQUIRED_DELIVERY_BUILDING_ROOM_NUMBER + " " + dataField + OLEConstants.DELIMITER_DOLLAR + tagField + " " + OLEConstants.NULL_VALUE_MESSAGE);
508 }
509 }
510 else if (OLEConstants.OLEBatchProcess.VENDOR_CHOICE.equals(destinationField)) {
511 String vendorChoice = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList,dataMapCount,bibMarcRecord,dataField,tagField);
512 if(!StringUtils.isBlank(vendorChoice)){
513 Map<String,String> vendorChoiceMap = new HashMap<>();
514 vendorChoiceMap.put(OLEConstants.OLEBatchProcess.PO_VENDOR_CHOICE_CODE, vendorChoice);
515 List<PurchaseOrderVendorChoice> purchaseOrderVendorChoiceList = (List) getBusinessObjectService().findMatching(PurchaseOrderVendorChoice.class, vendorChoiceMap);
516 if(purchaseOrderVendorChoiceList != null && purchaseOrderVendorChoiceList.size() == 0){
517 mappingFailures.put(OLEConstants.OLEBatchProcess.PO_VENDOR_CHOICE_CODE,OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.INVALID_VENDOR_CHOICE_CD + " " +dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField + " " + vendorChoice);
518 vendorChoice = null;
519 }
520 oleTxRecord.setVendorChoice(vendorChoice);
521 }
522 else{
523 mappingFailures.put(OLEConstants.OLEBatchProcess.PO_VENDOR_CHOICE_CODE,OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.REQUIRED_VENDOR_CHOICE + " " + dataField + OLEConstants.DELIMITER_DOLLAR + tagField + " " + OLEConstants.NULL_VALUE_MESSAGE);
524 }
525 }
526 else if (OLEConstants.OLEBatchProcess.METHOD_OF_PO_TRANSMISSION.equals(destinationField)) {
527 String methodOfPOTransmission = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList,dataMapCount,bibMarcRecord,dataField,tagField);
528 if(!StringUtils.isBlank(methodOfPOTransmission)){
529 Map<String,String> methodOfPOTransmissionMap = new HashMap<>();
530 methodOfPOTransmissionMap.put(OLEConstants.OLEBatchProcess.PO_TRANSMISSION_METHOD_CODE, methodOfPOTransmission);
531 List<PurchaseOrderTransmissionMethod> purchaseOrderTransmissionMethodList = (List) getBusinessObjectService().findMatching(PurchaseOrderTransmissionMethod.class, methodOfPOTransmissionMap);
532 if(purchaseOrderTransmissionMethodList != null && purchaseOrderTransmissionMethodList.size() == 0){
533 mappingFailures.put(OLEConstants.OLEBatchProcess.PO_TRANSMISSION_METHOD_CODE,OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.INVALID_METHOD_OF_PO_TRANSMISSION_CD + " " +dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField + " " + methodOfPOTransmission);
534 methodOfPOTransmission = null;
535 }
536 oleTxRecord.setMethodOfPOTransmission(methodOfPOTransmission);
537 }
538 else {
539 mappingFailures.put(OLEConstants.OLEBatchProcess.PO_TRANSMISSION_METHOD_CODE,OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.REQUIRED_METHOD_OF_PO_TRANSMISSION + " " + dataField + OLEConstants.DELIMITER_DOLLAR + tagField + " " + OLEConstants.NULL_VALUE_MESSAGE);
540 }
541 }
542 else if (OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_TYP.equals(destinationField)) {
543 String recurringPaymentType = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList,dataMapCount,bibMarcRecord,dataField,tagField);
544 if(!StringUtils.isBlank(recurringPaymentType)){
545 Map<String,String> recurringPaymentTypeMap = new HashMap<>();
546 recurringPaymentTypeMap.put(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_TYP_CODE, recurringPaymentType);
547 List<RecurringPaymentType> recurringPaymentTypeList = (List) getBusinessObjectService().findMatching(RecurringPaymentType.class, recurringPaymentTypeMap);
548 if(recurringPaymentTypeList != null && recurringPaymentTypeList.size() == 0){
549 mappingFailures.put(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_TYP_CODE,OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.INVALID_RECURRING_PAYMENT_TYP_CD + " " +dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField + " " + recurringPaymentType);
550 recurringPaymentType = null;
551 }
552 oleTxRecord.setMethodOfPOTransmission(recurringPaymentType);
553 }
554 else {
555 mappingFailures.put(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_TYP_CODE,OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.INVALID_RECURRING_PAYMENT_TYP_CD + " " + dataField + OLEConstants.DELIMITER_DOLLAR + tagField + " " + OLEConstants.NULL_VALUE_MESSAGE);
556 }
557 }
558 else if (OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_BEGIN_DT.equals(destinationField)) {
559 String recurringPaymentBeginDate = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList,dataMapCount,bibMarcRecord,dataField,tagField);
560 if(!StringUtils.isBlank(recurringPaymentBeginDate)){
561 boolean validDate = new OLEBatchProcessProfileController().validateRecurringPaymentDate(recurringPaymentBeginDate);
562 if(!validDate){
563 mappingFailures.put(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_BEGIN_DT,OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.INVALID_RECURRING_BEGIN_DT + " " +dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField + " " + recurringPaymentBeginDate);
564 recurringPaymentBeginDate = null;
565 }
566 oleTxRecord.setRecurringPaymentBeginDate(recurringPaymentBeginDate);
567 }
568 else {
569 mappingFailures.put(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_BEGIN_DT,OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.RECURRING_BEGIN_DT + " " + dataField + OLEConstants.DELIMITER_DOLLAR + tagField + " " + OLEConstants.NULL_VALUE_MESSAGE);
570 }
571 }
572 else if (OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_END_DT.equals(destinationField)) {
573 String recurringPaymentEndDate = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList,dataMapCount,bibMarcRecord,dataField,tagField);
574 if(!StringUtils.isBlank(recurringPaymentEndDate)){
575 boolean validDate = new OLEBatchProcessProfileController().validateRecurringPaymentDate(recurringPaymentEndDate);
576 if(!validDate){
577 mappingFailures.put(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_END_DT,OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.INVALID_RECURRING_END_DT + " " +dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField + " " + recurringPaymentEndDate);
578 recurringPaymentEndDate = null;
579 }
580 oleTxRecord.setRecurringPaymentEndDate(recurringPaymentEndDate);
581 }
582 else {
583 mappingFailures.put(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_END_DT,OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.RECURRING_END_DT + " " + dataField + OLEConstants.DELIMITER_DOLLAR + tagField + " " + OLEConstants.NULL_VALUE_MESSAGE);
584 }
585 }
586 else if (OLEConstants.OLEBatchProcess.COST_SOURCE.equals(destinationField)) {
587 String costSource = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList,dataMapCount,bibMarcRecord,dataField,tagField);
588 if(!StringUtils.isBlank(costSource)){
589 Map<String,String> costSourceMap = new HashMap<>();
590 costSourceMap.put(OLEConstants.OLEBatchProcess.PO_COST_SOURCE_CODE, costSource);
591 List<PurchaseOrderCostSource> purchaseOrderCostSourceList= (List) getBusinessObjectService().findMatching(PurchaseOrderCostSource.class, costSourceMap);
592 if(purchaseOrderCostSourceList != null && purchaseOrderCostSourceList.size() == 0){
593 mappingFailures.put(OLEConstants.OLEBatchProcess.PO_COST_SOURCE_CODE,OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.INVALID_COST_SOURCE_CD + " " +dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField + " " + costSource);
594 costSource = null;
595 }
596 oleTxRecord.setCostSource(costSource);
597 }
598 else{
599 mappingFailures.put(OLEConstants.OLEBatchProcess.PO_COST_SOURCE_CODE,OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.REQUIRED_COST_SOURCE + " " + dataField + OLEConstants.DELIMITER_DOLLAR + tagField + " " + OLEConstants.NULL_VALUE_MESSAGE);
600 }
601 }
602 else if (OLEConstants.OLEBatchProcess.PERCENT.equals(destinationField)) {
603 String percent = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList, dataMapCount, bibMarcRecord, dataField, tagField);
604 if(!StringUtils.isBlank(percent)){
605 boolean validPercent = validateForPercentage(percent);
606 if(!validPercent){
607 mappingFailures.put(OLEConstants.OLEBatchProcess.PERCENT,OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.INVALID_PERCENT + " " +dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField + " " + percent);
608 percent = null;
609 }
610 oleTxRecord.setPercent(percent);
611 }
612 else{
613 mappingFailures.put(OLEConstants.OLEBatchProcess.PERCENT,OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.REQUIRED_PERCENT + " " + dataField + OLEConstants.DELIMITER_DOLLAR + tagField + " " + OLEConstants.NULL_VALUE_MESSAGE);
614 }
615 }
616 else if (OLEConstants.OLEBatchProcess.DEFAULT_LOCATION.equals(destinationField)) {
617 String defaultLocation = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList,dataMapCount,bibMarcRecord,dataField,tagField);
618 if(!StringUtils.isBlank(defaultLocation)){
619 boolean validDefaultLocation = validateDefaultLocation(defaultLocation);
620 if(!validDefaultLocation){
621 mappingFailures.put(OLEConstants.OLEBatchProcess.DEFAULT_LOCATION, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.INVALID_LOCN_NM + " " +dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField + " " + defaultLocation);
622 defaultLocation = null;
623 }
624 oleTxRecord.setDefaultLocation(defaultLocation);
625 }
626 else{
627 mappingFailures.put(OLEConstants.OLEBatchProcess.DEFAULT_LOCATION, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.REQUIRED_LOCATION_NM + " " + dataField + OLEConstants.DELIMITER_DOLLAR + tagField + " " + OLEConstants.NULL_VALUE_MESSAGE);
628 }
629 }
630 else if (OLEConstants.OLEBatchProcess.LIST_PRICE.equals(destinationField)) {
631 String listPrice = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList,dataMapCount,bibMarcRecord,dataField,tagField);
632 if(!StringUtils.isBlank(listPrice)){
633 boolean validListPrice = validateDestinationFieldValues(listPrice);
634 if(!validListPrice){
635 mappingFailures.put(OLEConstants.OLEBatchProcess.LIST_PRICE, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.INVALID_LIST_PRICE + " " +dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField +" " + listPrice);
636 listPrice = null;
637 }
638 else {
639 listPrice = Float.parseFloat(listPrice) + "";
640 }
641 oleTxRecord.setListPrice(listPrice);
642 }
643 else {
644 mappingFailures.put(OLEConstants.OLEBatchProcess.LIST_PRICE, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.REQUIRED_LIST_PRICE + " " + dataField + OLEConstants.DELIMITER_DOLLAR + tagField + " " + OLEConstants.NULL_VALUE_MESSAGE);
645 }
646 }
647 else if (OLEConstants.OLEBatchProcess.VENDOR_NUMBER.equals(destinationField)) {
648 String vendorNumber = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList,dataMapCount,bibMarcRecord,dataField,tagField);
649 if(!StringUtils.isBlank(vendorNumber)){
650 boolean validVendorNumber = validateVendorNumber(vendorNumber);
651 if(!validVendorNumber){
652 mappingFailures.put(OLEConstants.OLEBatchProcess.VENDOR_NUMBER, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.INVALID_VENDOR_NUMBER + " " +dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField + " " + vendorNumber);
653 vendorNumber = null;
654 }
655 oleTxRecord.setVendorNumber(vendorNumber);
656 }
657 else {
658 mappingFailures.put(OLEConstants.OLEBatchProcess.VENDOR_NUMBER, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.REQUIRED_VENDOR_NUMBER + " " + dataField + OLEConstants.DELIMITER_DOLLAR + tagField + " " + OLEConstants.NULL_VALUE_MESSAGE);
659 }
660 }
661 else if (OLEConstants.OLEBatchProcess.VENDOR_CUST_NBR.equals(destinationField)) {
662 String vendorCustomerNumber = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList,dataMapCount,bibMarcRecord,dataField,tagField);
663 if(!StringUtils.isBlank(vendorCustomerNumber)){
664 Map<String,String> vendorCustomerMap = new HashMap<>();
665 vendorCustomerMap.put(OLEConstants.OLEBatchProcess.VENDOR_CUST_NBR, vendorCustomerNumber);
666 List<VendorCustomerNumber> vendorCustomerList = (List) getBusinessObjectService().findMatching(VendorCustomerNumber.class, vendorCustomerMap);
667 if(vendorCustomerList != null && vendorCustomerList.size() == 0){
668 mappingFailures.put(OLEConstants.OLEBatchProcess.VENDOR_CUST_NBR,OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.INVALID_VENDOR_CUST_NBR + " " +dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField + " " + vendorCustomerNumber);
669 vendorCustomerNumber = null;
670 }
671 oleTxRecord.setVendorInfoCustomer(vendorCustomerNumber);
672 }
673 else{
674 mappingFailures.put(OLEConstants.OLEBatchProcess.VENDOR_CUST_NBR,OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.REQUIRED_VENDOR_CUST_NBR + " " + dataField + OLEConstants.DELIMITER_DOLLAR + tagField + " " + OLEConstants.NULL_VALUE_MESSAGE);
675 }
676 }
677 else if (OLEConstants.OLEBatchProcess.QUANTITY.equals(destinationField)) {
678 String quantity = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList,dataMapCount,bibMarcRecord,dataField,tagField);
679 if(!StringUtils.isBlank(quantity)){
680 boolean validQuantity = validateForNumber(quantity);
681 if(!validQuantity){
682 mappingFailures.put(OLEConstants.OLEBatchProcess.QUANTITY, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.INVALID_QTY + " " +dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField + " " + quantity);
683 quantity = null;
684 }
685 oleTxRecord.setQuantity(quantity);
686 }
687 else{
688 mappingFailures.put(OLEConstants.OLEBatchProcess.QUANTITY, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.REQUIRED_QTY + " " + dataField + OLEConstants.DELIMITER_DOLLAR + tagField + " " + OLEConstants.NULL_VALUE_MESSAGE);
689 }
690 }
691 else if (OLEConstants.OLEBatchProcess.ITEM_NO_OF_PARTS.equals(destinationField)) {
692 String itemNoOfParts = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList,dataMapCount,bibMarcRecord,dataField,tagField);
693 if(!StringUtils.isBlank(itemNoOfParts)){
694 boolean validNoOfParts = validateForNumber(itemNoOfParts);
695 if(!validNoOfParts){
696 mappingFailures.put(OLEConstants.OLEBatchProcess.ITEM_NO_OF_PARTS, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.INVALID_NO_OF_PARTS + " " +dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField + " " + itemNoOfParts);
697 itemNoOfParts = null;
698 }
699 oleTxRecord.setItemNoOfParts(itemNoOfParts);
700 }
701 else{
702 mappingFailures.put(OLEConstants.OLEBatchProcess.ITEM_NO_OF_PARTS, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.REQUIRED_NO_OF_PARTS + " " + dataField + OLEConstants.DELIMITER_DOLLAR + tagField + " " + OLEConstants.NULL_VALUE_MESSAGE);
703 }
704 }
705 else if (OLEConstants.OLEBatchProcess.VENDOR_REFERENCE_NUMBER.equals(destinationField)) {
706 String vendorReferenceNumber = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList,dataMapCount,bibMarcRecord,dataField,tagField);
707 if(!StringUtils.isBlank(vendorReferenceNumber)){
708 oleTxRecord.setVendorItemIdentifier(vendorReferenceNumber);
709 }
710 else{
711 mappingFailures.put(OLEConstants.OLEBatchProcess.VENDOR_REFERENCE_NUMBER, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.REQUIRED_VENDOR_REF_NMBR + " " + dataField + OLEConstants.DELIMITER_DOLLAR + tagField + " " + OLEConstants.NULL_VALUE_MESSAGE);
712 }
713 }
714 else if (OLEConstants.OLEBatchProcess.RECEIVING_REQUIRED.equals(destinationField)) {
715 String receivingRequired = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList,dataMapCount,bibMarcRecord,dataField,tagField);
716 if(!receivingRequired.equalsIgnoreCase(OLEConstants.OLEBatchProcess.TRUE) && !receivingRequired.equalsIgnoreCase(OLEConstants.OLEBatchProcess.FALSE)){
717 mappingFailures.put(OLEConstants.OLEBatchProcess.RECEIVING_REQUIRED, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.INVALID_RECEIVING_REQUIRED + " " +dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField + " " + receivingRequired);
718 }
719 oleTxRecord.setReceivingRequired(Boolean.parseBoolean(receivingRequired));
720 }
721 else if (OLEConstants.OLEBatchProcess.USE_TAX_INDICATOR.equals(destinationField)) {
722 String useTaxIndicator = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList, dataMapCount, bibMarcRecord, dataField, tagField);
723 if(!useTaxIndicator.equalsIgnoreCase(OLEConstants.OLEBatchProcess.TRUE) && !useTaxIndicator.equalsIgnoreCase(OLEConstants.OLEBatchProcess.FALSE)){
724 mappingFailures.put(OLEConstants.OLEBatchProcess.USE_TAX_INDICATOR, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition + 1) + " " + OLEConstants.INVALID_USE_TAX_INDICATOR + " " + dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField + " " + useTaxIndicator);
725 }
726 oleTxRecord.setUseTaxIndicator(Boolean.parseBoolean(useTaxIndicator));
727 }
728 else if (OLEConstants.OLEBatchProcess.PREQ_POSITIVE_APPROVAL_REQ.equals(destinationField)) {
729 String payReqPositiveApprovalReq = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList, dataMapCount, bibMarcRecord, dataField, tagField);
730 if(!payReqPositiveApprovalReq.equalsIgnoreCase(OLEConstants.OLEBatchProcess.TRUE) && !payReqPositiveApprovalReq.equalsIgnoreCase(OLEConstants.OLEBatchProcess.FALSE)){
731 mappingFailures.put(OLEConstants.OLEBatchProcess.PREQ_POSITIVE_APPROVAL_REQ, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition + 1) + " " + OLEConstants.INVALID_PREQ_POSITIVE_APPROVAL_REQ + " " + dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField + " " + payReqPositiveApprovalReq);
732 }
733 oleTxRecord.setPayReqPositiveApprovalReq(Boolean.parseBoolean(payReqPositiveApprovalReq));
734 }
735 else if (OLEConstants.OLEBatchProcess.PO_CONFIRMATION_INDICATOR.equals(destinationField)) {
736 String purchaseOrderConfirmationIndicator = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList, dataMapCount, bibMarcRecord, dataField, tagField);
737 if(!purchaseOrderConfirmationIndicator.equalsIgnoreCase(OLEConstants.OLEBatchProcess.TRUE) && !purchaseOrderConfirmationIndicator.equalsIgnoreCase(OLEConstants.OLEBatchProcess.FALSE)){
738 mappingFailures.put(OLEConstants.OLEBatchProcess.PO_CONFIRMATION_INDICATOR, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.INVALID_PO_CONFIRMATION_INDICATOR + " " +dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField + " " + purchaseOrderConfirmationIndicator);
739 }
740 oleTxRecord.setPurchaseOrderConfirmationIndicator(Boolean.parseBoolean(purchaseOrderConfirmationIndicator));
741 }
742 else if (OLEConstants.OLEBatchProcess.ROUTE_TO_REQUESTOR.equals(destinationField)) {
743 String routeToRequestor = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList, dataMapCount, bibMarcRecord, dataField, tagField);
744 if(!routeToRequestor.equalsIgnoreCase(OLEConstants.OLEBatchProcess.TRUE) && !routeToRequestor.equalsIgnoreCase(OLEConstants.OLEBatchProcess.FALSE)){
745 mappingFailures.put(OLEConstants.OLEBatchProcess.ROUTE_TO_REQUESTOR, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition + 1) + " " + OLEConstants.INVALID_ROUTE_TO_REQUESTOR + " " + dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField + " " + routeToRequestor);
746 }
747 oleTxRecord.setRouteToRequestor(Boolean.parseBoolean(routeToRequestor));
748 }
749 else if (OLEConstants.DONOR_CODE.equals(destinationField)) {
750 String donorCode = setDataMappingValuesForDonorAndNotesSection(oleBatchProcessProfileDataMappingOptionsBoList, dataMapCount, bibMarcRecord, dataField, tagField);
751 if (donorCode != null && !donorCode.isEmpty()) {
752 Map<String, String> donorCodeMap = new HashMap<>();
753 donorCodeMap.put(OLEConstants.DONOR_CODE, donorCode);
754 List<OLEDonor> donorCodeList = (List) KRADServiceLocator.getBusinessObjectService().findMatching(OLEDonor.class, donorCodeMap);
755 if (donorCodeList != null && donorCodeList.size() > 0) {
756 donors.add(donorCodeList.get(0).getDonorCode());
757 } else {
758 mappingFailures.put(OLEConstants.DONOR_CODE, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.INVALID_DONOR_CODE + " " + dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField + " " + donorCode);
759 }
760 }
761 else{
762 mappingFailures.put(OLEConstants.DONOR_CODE, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition + 1) + " " + OLEConstants.REQUIRED_DONOR_CD + " " + dataField + OLEConstants.DELIMITER_DOLLAR + tagField + " " + OLEConstants.NULL_VALUE_MESSAGE);
763 }
764 }
765 else if (OLEConstants.OLEBatchProcess.REQUESTOR_NAME.equals(destinationField)) {
766 String requestorName = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList, dataMapCount, bibMarcRecord, dataField, tagField);
767 if(!StringUtils.isBlank(requestorName)){
768 boolean validRequestorName = checkRequestorName(requestorName);
769 if(!validRequestorName){
770 mappingFailures.put(OLEConstants.OLEBatchProcess.REQUESTOR_NAME, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.INVALID_REQUESTOR_NAME + " " +dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField +" " + requestorName);
771 requestorName = null;
772 }
773 oleTxRecord.setRequestorName(requestorName);
774 }
775 else{
776 mappingFailures.put(OLEConstants.OLEBatchProcess.REQUESTOR_NAME, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition + 1) + " " + OLEConstants.REQUIRED_REQUESTOR_NM + " " + dataField + OLEConstants.DELIMITER_DOLLAR + tagField + " " + OLEConstants.NULL_VALUE_MESSAGE);
777 }
778 }
779 else if (OLEConstants.OLEBatchProcess.ITEM_STATUS.equals(destinationField)) {
780 String itemStatus = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList,dataMapCount,bibMarcRecord, dataField, tagField);
781 if(!StringUtils.isBlank(itemStatus)){
782 boolean validItemStatus = validateItemStatus(itemStatus);
783 if(!validItemStatus){
784 mappingFailures.put(OLEConstants.OLEBatchProcess.ITEM_STATUS, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.INVALID_ITEM_STATUS + " " +dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField +" " + itemStatus);
785 itemStatus = null;
786 }
787 oleTxRecord.setItemStatus(itemStatus);
788 }
789 else{
790 mappingFailures.put(OLEConstants.OLEBatchProcess.ITEM_STATUS, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.REQUIRED_ITEM_STATUS + " " + dataField + OLEConstants.DELIMITER_DOLLAR + tagField + " " + OLEConstants.NULL_VALUE_MESSAGE);
791 }
792 }
793 else if (OLEConstants.OLEBatchProcess.DISCOUNT.equals(destinationField)) {
794 String discount = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList,dataMapCount,bibMarcRecord,dataField,tagField);
795 if(!StringUtils.isBlank(discount)){
796 boolean validDiscount = validateDestinationFieldValues(discount);
797 if(!validDiscount){
798 mappingFailures.put(OLEConstants.OLEBatchProcess.DISCOUNT, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.INVALID_DISCOUNT + " " +dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField +" " + discount);
799 discount = null;
800 }
801 oleTxRecord.setDiscount(discount);
802 }
803 else{
804 mappingFailures.put(OLEConstants.OLEBatchProcess.DISCOUNT, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.REQUIRED_DISCOUNT + " " + dataField + OLEConstants.DELIMITER_DOLLAR + tagField + " " + OLEConstants.NULL_VALUE_MESSAGE);
805 }
806 }
807 else if (OLEConstants.OLEBatchProcess.DISCOUNT_TYPE.equals(destinationField)) {
808 String discountType = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList,dataMapCount,bibMarcRecord,dataField,tagField);
809 if(!StringUtils.isBlank(discountType)){
810 if(!discountType.equalsIgnoreCase(OLEConstants.PERCENTAGE) && !discountType.equalsIgnoreCase(OLEConstants.DELIMITER_HASH)){
811 mappingFailures.put(OLEConstants.OLEBatchProcess.DISCOUNT_TYPE, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.INVALID_DISCOUNT_TYPE + " " +dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField +" " + discountType);
812 discountType = null;
813 }
814 oleTxRecord.setDiscountType(discountType);
815 }
816 else{
817 mappingFailures.put(OLEConstants.OLEBatchProcess.DISCOUNT_TYPE, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.REQUIRED_DISCOUNT_TYPE+ " " + dataField + OLEConstants.DELIMITER_DOLLAR + tagField + " " + OLEConstants.NULL_VALUE_MESSAGE);
818 }
819 }
820 else if (OLEConstants.OLEBatchProcess.ACCOUNT_NUMBER.equals(destinationField)) {
821 String accountNumber = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList,dataMapCount,bibMarcRecord,dataField,tagField);
822 if(!StringUtils.isBlank(accountNumber)){
823 Map<String,String> accountNumberMap = new HashMap<>();
824 accountNumberMap.put(OLEConstants.OLEBatchProcess.ACCOUNT_NUMBER, accountNumber);
825 List<Account> accountNumberList = (List) getLookupService().findCollectionBySearchHelper(Account.class, accountNumberMap,true);
826 if(accountNumberList.size() == 0){
827 mappingFailures.put(OLEConstants.OLEBatchProcess.ACCOUNT_NUMBER, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.INVALID_ACCOUNT_NUMBER + " " +dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField +" " + accountNumber);
828 accountNumber = null;
829 }
830 oleTxRecord.setAccountNumber(accountNumber);
831 if (StringUtils.isNotBlank(accountNumber)) {
832 oleTxRecord.setAccountNumber(accountNumberList.get(0).getAccountNumber());
833 }
834 }
835 else{
836 mappingFailures.put(OLEConstants.OLEBatchProcess.ACCOUNT_NUMBER, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.REQUIRED_ACCOUNT_NUMBER + " " + dataField + OLEConstants.DELIMITER_DOLLAR + tagField + " " + OLEConstants.NULL_VALUE_MESSAGE);
837 }
838 }
839 else if (OLEConstants.OLEBatchProcess.OBJECT_CODE.equals(destinationField)) {
840 String objectCode = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList,dataMapCount,bibMarcRecord,dataField,tagField);
841 if(!StringUtils.isBlank(objectCode)) {
842 Map<String,String> objectCodeMap = new HashMap<>();
843 objectCodeMap.put(OLEConstants.OLEBatchProcess.OBJECT_CODE, objectCode);
844 List<ObjectCode> objectCodeList = (List) getBusinessObjectService().findMatching(ObjectCode.class, objectCodeMap);
845 if(objectCodeList.size() == 0){
846 mappingFailures.put(OLEConstants.OLEBatchProcess.OBJECT_CODE, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.INVALID_OBJECT_CODE + " " +dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField +" " + objectCode);
847 objectCode = null;
848 }
849 oleTxRecord.setObjectCode(objectCode);
850 }
851 else{
852 mappingFailures.put(OLEConstants.OLEBatchProcess.OBJECT_CODE, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.REQUIRED_OBJECT_CODE + " " + dataField + OLEConstants.DELIMITER_DOLLAR + tagField + " " + OLEConstants.NULL_VALUE_MESSAGE);
853 }
854 }
855 else if (OLEConstants.OLEBatchProcess.ITEM_CHART_CODE.equals(destinationField)) {
856 String itemChartCode = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList,dataMapCount,bibMarcRecord,dataField,tagField);
857 if(!StringUtils.isBlank(itemChartCode)) {
858 Map<String,String> itemChartCodeMap = new HashMap<>();
859 itemChartCodeMap.put(OLEConstants.OLEBatchProcess.CHART_OF_ACCOUNTS_CODE, itemChartCode);
860 List<Chart> itemChartCodeList = (List) getBusinessObjectService().findMatching(Chart.class, itemChartCodeMap);
861 if(itemChartCodeList.size() == 0){
862 mappingFailures.put(OLEConstants.OLEBatchProcess.ITEM_CHART_CODE, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.INVALID_ITEM_CHART_CD + " " +dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField +" " + itemChartCode);
863 itemChartCode = null;
864 }
865 oleTxRecord.setItemChartCode(itemChartCode);
866 }
867 else{
868 mappingFailures.put(OLEConstants.OLEBatchProcess.ITEM_CHART_CODE, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.REQUIRED_ITEM_CHART_CD + " " + dataField + OLEConstants.DELIMITER_DOLLAR + tagField + " " + OLEConstants.NULL_VALUE_MESSAGE);
869 }
870 }
871 else if (OLEConstants.OLEBatchProcess.FORMAT_TYP_NM.equals(destinationField)) {
872 String formatTypeName = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList,dataMapCount,bibMarcRecord,dataField,tagField);
873 if(!StringUtils.isBlank(formatTypeName)) {
874 Map<String,String> formatTypeMap = new HashMap<>();
875 formatTypeMap.put(OLEConstants.OLEBatchProcess.FORMAT_TYP_NM, formatTypeName);
876 List<OleFormatType> formatTypeList = (List) getBusinessObjectService().findMatching(OleFormatType.class, formatTypeMap);
877 if(formatTypeList == null || formatTypeList.size() == 0){
878 mappingFailures.put(OLEConstants.OLEBatchProcess.FORMAT_TYP_NM, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.INVALID_FORMAT + " " +dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField +" " + formatTypeName);
879 }
880 else{
881 oleTxRecord.setFormatTypeId(formatTypeList.get(0).getFormatTypeId().toString());
882 }
883 }
884 else{
885 mappingFailures.put(OLEConstants.OLEBatchProcess.FORMAT_TYP_NM, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.REQUIRED_FORMAT + " " + dataField + OLEConstants.DELIMITER_DOLLAR + tagField + " " + OLEConstants.NULL_VALUE_MESSAGE);
886 }
887 }
888 else if (OLEConstants.OLEBatchProcess.MISC_NOTE.equals(destinationField)) {
889 String miscellaneousNote = setDataMappingValuesForDonorAndNotesSection(oleBatchProcessProfileDataMappingOptionsBoList, dataMapCount, bibMarcRecord, dataField, tagField);
890 if (!StringUtils.isBlank(miscellaneousNote)) {
891 if (miscellaneousNote.length() > 2000) {
892 miscellaneousNote = miscellaneousNote.substring(0, 2000);
893 }
894 miscellaneousNotes.add(miscellaneousNote);
895 }
896 }
897 else if (OLEConstants.OLEBatchProcess.RCPT_NOTE.equals(destinationField)) {
898 String receiptNote = setDataMappingValuesForDonorAndNotesSection(oleBatchProcessProfileDataMappingOptionsBoList, dataMapCount, bibMarcRecord, dataField, tagField);
899 if (!StringUtils.isBlank(receiptNote)) {
900 if (receiptNote.length() > 2000) {
901 receiptNote = receiptNote.substring(0, 2000);
902 }
903 receiptNotes.add(receiptNote);
904 }
905 }
906 else if (OLEConstants.OLEBatchProcess.RQST_NOTE.equals(destinationField)) {
907 String requestorNote = setDataMappingValuesForDonorAndNotesSection(oleBatchProcessProfileDataMappingOptionsBoList, dataMapCount, bibMarcRecord, dataField, tagField);
908 if (!StringUtils.isBlank(requestorNote)) {
909 if (requestorNote.length() > 2000) {
910 requestorNote = requestorNote.substring(0, 2000);
911 }
912 requestorNotes.add(requestorNote);
913 }
914 }
915 else if (OLEConstants.OLEBatchProcess.SELECTOR_NOTE.equals(destinationField)) {
916 String selectorNote = setDataMappingValuesForDonorAndNotesSection(oleBatchProcessProfileDataMappingOptionsBoList, dataMapCount, bibMarcRecord, dataField, tagField);
917 if (!StringUtils.isBlank(selectorNote)) {
918 if (selectorNote.length() > 2000) {
919 selectorNote = selectorNote.substring(0, 2000);
920 }
921 selectorNotes.add(selectorNote);
922 }
923 }
924 else if (OLEConstants.OLEBatchProcess.SPL_PROCESS_NOTE.equals(destinationField)) {
925 String splProcessInstrNote = setDataMappingValuesForDonorAndNotesSection(oleBatchProcessProfileDataMappingOptionsBoList, dataMapCount, bibMarcRecord, dataField, tagField);
926 if (!StringUtils.isBlank(splProcessInstrNote)) {
927 if (splProcessInstrNote.length() > 2000) {
928 splProcessInstrNote = splProcessInstrNote.substring(0, 2000);
929 }
930 splProcessInstrNotes.add(splProcessInstrNote);
931 }
932 }
933 else if (OLEConstants.OLEBatchProcess.VNDR_INSTR_NOTE.equals(destinationField)) {
934 String vendorInstrNote = setDataMappingValuesForDonorAndNotesSection(oleBatchProcessProfileDataMappingOptionsBoList, dataMapCount, bibMarcRecord, dataField, tagField);
935 if (!StringUtils.isBlank(vendorInstrNote)) {
936 if (vendorInstrNote.length() > 2000) {
937 vendorInstrNote = vendorInstrNote.substring(0, 2000);
938 }
939 vendorInstrNotes.add(vendorInstrNote);
940 }
941 }
942 else if (OLEConstants.OLEBatchProcess.CAPTION.equals(destinationField)) {
943 String caption = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList,dataMapCount,bibMarcRecord,dataField,tagField);
944 oleTxRecord.setCaption(caption);
945 }
946 else if (OLEConstants.OLEBatchProcess.VOLUME_NUMBER.equals(destinationField)) {
947 String volumeNumber = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList, dataMapCount, bibMarcRecord, dataField, tagField);
948 oleTxRecord.setVolumeNumber(volumeNumber);
949 }
950 }
951 }
952 if (donors.size()>0){
953 oleTxRecord.setOleDonors(donors);
954 }
955 if(miscellaneousNotes.size() > 0){
956 oleTxRecord.setMiscellaneousNote(OLEConstants.OLEBatchProcess.MISC_NOTE);
957 oleTxRecord.setMiscellaneousNotes(miscellaneousNotes);
958 }
959 if(receiptNotes.size() > 0){
960 oleTxRecord.setReceiptNote(OLEConstants.OLEBatchProcess.RCPT_NOTE);
961 oleTxRecord.setReceiptNotes(receiptNotes);
962 }
963 if(requestorNotes.size() > 0){
964 oleTxRecord.setRequestorNote(OLEConstants.OLEBatchProcess.RQST_NOTE);
965 oleTxRecord.setRequestorNotes(requestorNotes);
966 }
967 if(selectorNotes.size() > 0){
968 oleTxRecord.setSelectorNote(OLEConstants.OLEBatchProcess.SELECTOR_NOTE);
969 oleTxRecord.setSelectorNotes(selectorNotes);
970 }
971 if(splProcessInstrNotes.size() > 0){
972 oleTxRecord.setSplProcessInstrNote(OLEConstants.OLEBatchProcess.SPL_PROCESS_NOTE);
973 oleTxRecord.setSplProcessInstrNotes(splProcessInstrNotes);
974 }
975 if(vendorInstrNotes.size() > 0){
976 oleTxRecord.setVendorInstrNote(OLEConstants.OLEBatchProcess.VNDR_INSTR_NOTE);
977 oleTxRecord.setVendorInstrNotes(vendorInstrNotes);
978 }
979 if (LOG.isDebugEnabled()){
980 LOG.debug("*******************FailureRecords**************" + failureRecords.toString());
981 }
982 }
983 LOG.debug("----End of mapDataFieldsToTxnRecord()------------------------------");
984 return mappingFailures;
985 }
986
987 private boolean validateDate(String recurringDate){
988 SimpleDateFormat dateFromRawFile = new SimpleDateFormat(org.kuali.ole.OLEConstants.DATE_FORMAT);
989 try {
990 dateFromRawFile.parse(recurringDate);
991 return true;
992 }
993 catch (ParseException e) {
994 return false;
995 }
996 }
997
998 private String setDataMappingValues(List<OLEBatchProcessProfileDataMappingOptionsBo> oleBatchProcessProfileDataMappingOptionsBoList,int dataMapCount,BibMarcRecord bibMarcRecord,String dataField,String tagField){
999 String subFieldValue = getSubFieldValueFor(bibMarcRecord, dataField, tagField);
1000 if (StringUtils.isBlank(subFieldValue)) {
1001 OLEBatchProcessProfileDataMappingOptionsBo oleBatchProcessProfileDataMappingOptionsBo = oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount);
1002 if (dataMapCount+1 <= oleBatchProcessProfileDataMappingOptionsBoList.size()) {
1003 if(dataMapCount+1 == oleBatchProcessProfileDataMappingOptionsBoList.size()) {
1004 subFieldValue = oleBatchProcessProfileDataMappingOptionsBo.getDestinationFieldValue();
1005 }
1006 else if(!oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount+1).getDestinationField().equalsIgnoreCase(oleBatchProcessProfileDataMappingOptionsBo.getDestinationField())){
1007 subFieldValue = oleBatchProcessProfileDataMappingOptionsBo.getDestinationFieldValue();
1008 }
1009 }
1010 }
1011 return subFieldValue;
1012 }
1013
1014 private String setDataMappingValuesForDonorAndNotesSection(List<OLEBatchProcessProfileDataMappingOptionsBo> oleBatchProcessProfileDataMappingOptionsBoList, int dataMapCount, BibMarcRecord bibMarcRecord, String dataField, String tagField) {
1015 String subFieldValue = getSubFieldValueFor(bibMarcRecord, dataField, tagField);
1016 if (StringUtils.isBlank(subFieldValue)) {
1017 OLEBatchProcessProfileDataMappingOptionsBo oleBatchProcessProfileDataMappingOptionsBo = oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount);
1018 while (dataMapCount + 1 <= oleBatchProcessProfileDataMappingOptionsBoList.size()) {
1019 if (dataMapCount + 1 == oleBatchProcessProfileDataMappingOptionsBoList.size()) {
1020 subFieldValue = oleBatchProcessProfileDataMappingOptionsBo.getDestinationFieldValue();
1021 break;
1022 } else if (!oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount + 1).getDestinationField().equalsIgnoreCase(oleBatchProcessProfileDataMappingOptionsBo.getDestinationField())) {
1023 subFieldValue = oleBatchProcessProfileDataMappingOptionsBo.getDestinationFieldValue();
1024 break;
1025 }
1026 dataMapCount++;
1027 }
1028 }
1029 return subFieldValue;
1030 }
1031
1032 private String getSubFieldValueFor(BibMarcRecord bibMarcRecord, String dataField, String tag) {
1033 String subFieldValue = null;
1034 org.kuali.ole.docstore.common.document.content.bib.marc.DataField dataFieldForTag = getDataFieldForTag(bibMarcRecord, dataField);
1035 if (null != dataFieldForTag) {
1036 List<org.kuali.ole.docstore.common.document.content.bib.marc.SubField> subfields = dataFieldForTag.getSubFields();
1037 for (Iterator<org.kuali.ole.docstore.common.document.content.bib.marc.SubField> iterator = subfields.iterator(); iterator.hasNext(); ) {
1038 org.kuali.ole.docstore.common.document.content.bib.marc.SubField marcSubField = iterator.next();
1039 if (marcSubField.getCode().equals(tag)) {
1040 subFieldValue = marcSubField.getValue();
1041 return subFieldValue;
1042 }
1043 }
1044 }
1045 return subFieldValue;
1046 }
1047
1048 public org.kuali.ole.docstore.common.document.content.bib.marc.DataField getDataFieldForTag(BibMarcRecord bibMarcRecord, String tag) {
1049 for (Iterator<org.kuali.ole.docstore.common.document.content.bib.marc.DataField> iterator = bibMarcRecord.getDataFields().iterator(); iterator.hasNext(); ) {
1050 org.kuali.ole.docstore.common.document.content.bib.marc.DataField marcDataField = iterator.next();
1051 if (marcDataField.getTag().equalsIgnoreCase(tag)) {
1052 return marcDataField;
1053 }
1054 }
1055 return null;
1056 }
1057
1058
1059
1060
1061
1062
1063 private void setAccountingLinesDetails(OleTxRecord oleTxRecord,int recordPosition, OLEBatchProcessJobDetailsBo job){
1064 OrderImportHelperBo orderImportHelperBo = job.getOrderImportHelperBo();
1065 if(oleTxRecord.getAccountNumber() != null && oleTxRecord.getObjectCode() != null && oleTxRecord.getItemChartCode() != null){
1066 Map<String,String> accLinesMap = new HashMap<>();
1067 accLinesMap.put(OLEConstants.ACCOUNT_NUMBER,oleTxRecord.getAccountNumber());
1068 accLinesMap.put(OLEConstants.OLEBatchProcess.CHART_OF_ACCOUNTS_CODE,oleTxRecord.getItemChartCode());
1069 List<Account> accountList = (List) getBusinessObjectService().findMatching(Account.class, accLinesMap);
1070
1071 List<String> reasonForFailure = orderImportHelperBo.getFailureReason();
1072 if(accountList != null && accountList.size() > 0){
1073 Account account = accountList.get(0);
1074 if (account.isClosed()){
1075 reasonForFailure.add(OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + oleTxRecord.getAccountNumber() +OLEConstants.OLEBatchProcess.CLOSED_ACC_NO);
1076 }
1077 accLinesMap.remove(OLEConstants.ACCOUNT_NUMBER);
1078 accLinesMap.put(OLEConstants.OLEBatchProcess.OBJECT_CODE,oleTxRecord.getObjectCode());
1079 List<ObjectCode> objectCodeList = (List) getBusinessObjectService().findMatching(ObjectCode.class, accLinesMap);
1080 if(objectCodeList == null || objectCodeList.size() == 0){
1081 if(reasonForFailure != null){
1082 reasonForFailure.add(OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.OLEBatchProcess.INVALID_ACNO_OBJCD_COMBINATION);
1083
1084 }
1085 }
1086 orderImportHelperBo.setFailureReason(reasonForFailure);
1087 }
1088 else{
1089 if(reasonForFailure != null){
1090 reasonForFailure.add(OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.OLEBatchProcess.INVALID_ACNO_OBJCD_COMBINATION);
1091
1092 orderImportHelperBo.setFailureReason(reasonForFailure);
1093 }
1094 }
1095 }
1096 }
1097
1098
1099
1100
1101
1102 private Map<String,String> setDefaultAndConstantValuesToTxnRecord(OleTxRecord oleTxRecord, Map<String,String> failureRecords, OLEBatchProcessJobDetailsBo job) {
1103 if (failureRecords == null) {
1104 failureRecords = new HashMap<String,String>();
1105 }
1106 String attributeName = null;
1107 String attributeValue = null;
1108 LOG.debug("----Inside setDefaultAndConstantValuesToTxnRecord()------------------------------");
1109 List<OLEBatchProcessProfileConstantsBo> oleBatchProcessProfileConstantsBoList = job.getOrderImportHelperBo().getOleBatchProcessProfileBo().getOleBatchProcessProfileConstantsList();
1110 for (OLEBatchProcessProfileConstantsBo oleBatchProcessProfileConstantsBo : oleBatchProcessProfileConstantsBoList) {
1111 attributeName = oleBatchProcessProfileConstantsBo.getAttributeName();
1112 attributeValue = oleBatchProcessProfileConstantsBo.getAttributeValue();
1113 if (OLEConstants.OLEBatchProcess.CONSTANT.equals(oleBatchProcessProfileConstantsBo.getDefaultValue())) {
1114
1115 if (OLEConstants.OLEBatchProcess.CHART_CODE.equals(attributeName)) {
1116 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.CHART_CODE)) {
1117 failureRecords.remove(OLEConstants.OLEBatchProcess.CHART_CODE);
1118 }
1119 oleTxRecord.setChartCode(attributeValue);
1120 } else if (OLEConstants.OLEBatchProcess.ORG_CODE.equals(attributeName)) {
1121 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.ORG_CODE)) {
1122 failureRecords.remove(OLEConstants.OLEBatchProcess.ORG_CODE);
1123 }
1124 oleTxRecord.setOrgCode(attributeValue);
1125 }
1126 else if(OLEConstants.OLEBatchProcess.RECEIVING_REQUIRED.equals(attributeName)) {
1127 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.RECEIVING_REQUIRED)) {
1128 failureRecords.remove(OLEConstants.OLEBatchProcess.RECEIVING_REQUIRED);
1129 }
1130 oleTxRecord.setReceivingRequired(Boolean.parseBoolean(attributeValue));
1131 }
1132 else if (OLEConstants.OLEBatchProcess.CONTRACT_MANAGER.equals(attributeName)) {
1133 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.CONTRACT_MANAGER)) {
1134 failureRecords.remove(OLEConstants.OLEBatchProcess.CONTRACT_MANAGER);
1135 }
1136 oleTxRecord.setContractManager(attributeValue);
1137 } else if (OLEConstants.OLEBatchProcess.ASSIGN_TO_USER.equals(attributeName)) {
1138 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.ASSIGN_TO_USER)) {
1139 failureRecords.remove(OLEConstants.OLEBatchProcess.ASSIGN_TO_USER);
1140 }
1141 oleTxRecord.setAssignToUser(attributeValue);
1142 }
1143 else if(OLEConstants.OLEBatchProcess.USE_TAX_INDICATOR.equals(attributeName)) {
1144 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.USE_TAX_INDICATOR)) {
1145 failureRecords.remove(OLEConstants.OLEBatchProcess.USE_TAX_INDICATOR);
1146 }
1147 oleTxRecord.setUseTaxIndicator(Boolean.parseBoolean(attributeValue));
1148 }
1149 else if (OLEConstants.OLEBatchProcess.ORDER_TYPE.equals(attributeName)) {
1150 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.ORDER_TYPE)) {
1151 failureRecords.remove(OLEConstants.OLEBatchProcess.ORDER_TYPE);
1152 }
1153 oleTxRecord.setOrderType(attributeValue);
1154 } else if (OLEConstants.OLEBatchProcess.FUNDING_SOURCE.equals(attributeName)) {
1155 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.FUNDING_SOURCE)) {
1156 failureRecords.remove(OLEConstants.OLEBatchProcess.FUNDING_SOURCE);
1157 }
1158 oleTxRecord.setFundingSource(attributeValue);
1159 }
1160 else if(OLEConstants.OLEBatchProcess.PREQ_POSITIVE_APPROVAL_REQ.equals(attributeName)) {
1161 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.PREQ_POSITIVE_APPROVAL_REQ)) {
1162 failureRecords.remove(OLEConstants.OLEBatchProcess.PREQ_POSITIVE_APPROVAL_REQ);
1163 }
1164 oleTxRecord.setPayReqPositiveApprovalReq(Boolean.parseBoolean(attributeValue));
1165 }
1166 else if(OLEConstants.OLEBatchProcess.PO_CONFIRMATION_INDICATOR.equals(attributeName)) {
1167 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.PO_CONFIRMATION_INDICATOR)) {
1168 failureRecords.remove(OLEConstants.OLEBatchProcess.PO_CONFIRMATION_INDICATOR);
1169 }
1170 oleTxRecord.setPurchaseOrderConfirmationIndicator(Boolean.parseBoolean(attributeValue));
1171 }
1172 else if (OLEConstants.OLEBatchProcess.DELIVERY_CAMPUS_CODE.equals(attributeName)) {
1173 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.DELIVERY_CAMPUS_CODE)) {
1174 failureRecords.remove(OLEConstants.OLEBatchProcess.DELIVERY_CAMPUS_CODE);
1175 }
1176 oleTxRecord.setDeliveryCampusCode(attributeValue);
1177 } else if (OLEConstants.OLEBatchProcess.BUILDING_CODE.equals(attributeName)) {
1178 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.BUILDING_CODE)) {
1179 failureRecords.remove(OLEConstants.OLEBatchProcess.BUILDING_CODE);
1180 }
1181 oleTxRecord.setBuildingCode(attributeValue);
1182 } else if (OLEConstants.OLEBatchProcess.VENDOR_CHOICE.equals(attributeName)) {
1183 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.VENDOR_CHOICE)) {
1184 failureRecords.remove(OLEConstants.OLEBatchProcess.VENDOR_CHOICE);
1185 }
1186 oleTxRecord.setVendorChoice(attributeValue);
1187 }
1188 else if(OLEConstants.OLEBatchProcess.ROUTE_TO_REQUESTOR.equals(attributeName)) {
1189 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.ROUTE_TO_REQUESTOR)) {
1190 failureRecords.remove(OLEConstants.OLEBatchProcess.ROUTE_TO_REQUESTOR);
1191 }
1192 oleTxRecord.setRouteToRequestor(Boolean.parseBoolean(attributeValue));
1193 }
1194 else if (OLEConstants.OLEBatchProcess.METHOD_OF_PO_TRANSMISSION.equals(attributeName)) {
1195 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.METHOD_OF_PO_TRANSMISSION)) {
1196 failureRecords.remove(OLEConstants.OLEBatchProcess.METHOD_OF_PO_TRANSMISSION);
1197 }
1198 oleTxRecord.setMethodOfPOTransmission(attributeValue);
1199 } else if (OLEConstants.OLEBatchProcess.COST_SOURCE.equals(attributeName)) {
1200 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.COST_SOURCE)) {
1201 failureRecords.remove(OLEConstants.OLEBatchProcess.COST_SOURCE);
1202 }
1203 oleTxRecord.setCostSource(attributeValue);
1204 } else if (OLEConstants.OLEBatchProcess.PERCENT.equals(attributeName)) {
1205 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.PERCENT)) {
1206 failureRecords.remove(OLEConstants.OLEBatchProcess.PERCENT);
1207 }
1208 oleTxRecord.setPercent(attributeValue);
1209 } else if (OLEConstants.OLEBatchProcess.DEFAULT_LOCATION.equals(attributeName)) {
1210 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.DEFAULT_LOCATION)) {
1211 failureRecords.remove(OLEConstants.OLEBatchProcess.DEFAULT_LOCATION);
1212 }
1213 oleTxRecord.setDefaultLocation(attributeValue);
1214 } else if (OLEConstants.OLEBatchProcess.LIST_PRICE.equals(attributeName)) {
1215 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.LIST_PRICE)) {
1216 failureRecords.remove(OLEConstants.OLEBatchProcess.LIST_PRICE);
1217 }
1218 oleTxRecord.setListPrice(attributeValue);
1219 } else if (OLEConstants.OLEBatchProcess.VENDOR_NUMBER.equals(attributeName)) {
1220 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.VENDOR_NUMBER)) {
1221 failureRecords.remove(OLEConstants.OLEBatchProcess.VENDOR_NUMBER);
1222 }
1223 oleTxRecord.setVendorNumber(attributeValue);
1224 }
1225 else if (OLEConstants.OLEBatchProcess.VENDOR_CUST_NBR.equals(attributeName)) {
1226 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.VENDOR_CUST_NBR)) {
1227 failureRecords.remove(OLEConstants.OLEBatchProcess.VENDOR_CUST_NBR);
1228 }
1229 oleTxRecord.setVendorInfoCustomer(attributeValue);
1230 }
1231 else if (OLEConstants.OLEBatchProcess.QUANTITY.equals(attributeName)) {
1232 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.QUANTITY)) {
1233 failureRecords.remove(OLEConstants.OLEBatchProcess.QUANTITY);
1234 }
1235 oleTxRecord.setQuantity(attributeValue);
1236 }
1237 else if (OLEConstants.OLEBatchProcess.ITEM_NO_OF_PARTS.equals(attributeName)) {
1238 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.ITEM_NO_OF_PARTS)) {
1239 failureRecords.remove(OLEConstants.OLEBatchProcess.ITEM_NO_OF_PARTS);
1240 }
1241 oleTxRecord.setItemNoOfParts(attributeValue);
1242 }
1243 else if (OLEConstants.OLEBatchProcess.VENDOR_REFERENCE_NUMBER.equals(attributeName)) {
1244 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.VENDOR_REFERENCE_NUMBER)) {
1245 failureRecords.remove(OLEConstants.OLEBatchProcess.VENDOR_REFERENCE_NUMBER);
1246 }
1247 oleTxRecord.setVendorItemIdentifier(attributeValue);
1248 }
1249 else if (OLEConstants.OLEBatchProcess.REQUESTOR_NAME.equals(attributeName)) {
1250 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.REQUESTOR_NAME)) {
1251 failureRecords.remove(OLEConstants.OLEBatchProcess.REQUESTOR_NAME);
1252 }
1253 oleTxRecord.setRequestorName(attributeValue);
1254 }
1255 else if (OLEConstants.OLEBatchProcess.ITEM_STATUS.equals(attributeName)) {
1256 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.ITEM_STATUS)) {
1257 failureRecords.remove(OLEConstants.OLEBatchProcess.ITEM_STATUS);
1258 }
1259 oleTxRecord.setItemStatus(attributeValue);
1260 }
1261 else if (OLEConstants.OLEBatchProcess.DISCOUNT.equals(attributeName)) {
1262 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.DISCOUNT)) {
1263 failureRecords.remove(OLEConstants.OLEBatchProcess.DISCOUNT);
1264 }
1265 oleTxRecord.setDiscount(attributeValue);
1266 }
1267 else if (OLEConstants.OLEBatchProcess.DISCOUNT_TYPE.equals(attributeName)) {
1268 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.DISCOUNT_TYPE)) {
1269 failureRecords.remove(OLEConstants.OLEBatchProcess.DISCOUNT_TYPE);
1270 }
1271 oleTxRecord.setDiscountType(attributeValue);
1272 }
1273 else if (OLEConstants.OLEBatchProcess.ACCOUNT_NUMBER.equals(attributeName)) {
1274 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.ACCOUNT_NUMBER)) {
1275 failureRecords.remove(OLEConstants.OLEBatchProcess.ACCOUNT_NUMBER);
1276 }
1277 oleTxRecord.setAccountNumber(attributeValue);
1278 }
1279 else if (OLEConstants.OLEBatchProcess.OBJECT_CODE.equals(attributeName)) {
1280 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.OBJECT_CODE)) {
1281 failureRecords.remove(OLEConstants.OLEBatchProcess.OBJECT_CODE);
1282 }
1283 oleTxRecord.setObjectCode(attributeValue);
1284 }
1285 else if (OLEConstants.OLEBatchProcess.ITEM_CHART_CODE.equals(attributeName)) {
1286 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.ITEM_CHART_CODE)) {
1287 failureRecords.remove(OLEConstants.OLEBatchProcess.ITEM_CHART_CODE);
1288 }
1289 oleTxRecord.setItemChartCode(attributeValue);
1290 }
1291 else if (OLEConstants.OLEBatchProcess.REQUEST_SRC.equals(attributeName)) {
1292 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.REQUEST_SRC)) {
1293 failureRecords.remove(OLEConstants.OLEBatchProcess.REQUEST_SRC);
1294 }
1295 oleTxRecord.setRequestSourceType(attributeValue);
1296 }
1297 else if (OLEConstants.OLEBatchProcess.CAPTION.equals(attributeName)) {
1298 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.CAPTION)) {
1299 failureRecords.remove(OLEConstants.OLEBatchProcess.CAPTION);
1300 }
1301 oleTxRecord.setCaption(attributeValue);
1302 }
1303 else if (OLEConstants.OLEBatchProcess.VOLUME_NUMBER.equals(attributeName)) {
1304 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.VOLUME_NUMBER)) {
1305 failureRecords.remove(OLEConstants.OLEBatchProcess.VOLUME_NUMBER);
1306 }
1307 oleTxRecord.setVolumeNumber(attributeValue);
1308 }
1309 else if (OLEConstants.OLEBatchProcess.DELIVERY_BUILDING_ROOM_NUMBER.equals(attributeName)) {
1310 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.DELIVERY_BUILDING_ROOM_NUMBER)) {
1311 failureRecords.remove(OLEConstants.OLEBatchProcess.DELIVERY_BUILDING_ROOM_NUMBER);
1312 }
1313 oleTxRecord.setDeliveryBuildingRoomNumber(attributeValue);
1314 }else if(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_TYP.equals(attributeName)) {
1315 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_TYP)) {
1316 failureRecords.remove(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_TYP);
1317 }
1318 oleTxRecord.setRecurringPaymentType(attributeValue);
1319 }else if(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_BEGIN_DT.equals(attributeName)) {
1320 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_BEGIN_DT)) {
1321 failureRecords.remove(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_BEGIN_DT);
1322 }
1323 oleTxRecord.setRecurringPaymentBeginDate(attributeValue);
1324 }else if(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_END_DT.equals(attributeName)) {
1325 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_END_DT)) {
1326 failureRecords.remove(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_END_DT);
1327 }
1328 oleTxRecord.setRecurringPaymentEndDate(attributeValue);
1329 }
1330
1331 } else if (OLEConstants.OLEBatchProcess.DEFAULT.equals(oleBatchProcessProfileConstantsBo.getDefaultValue())) {
1332
1333 if (OLEConstants.OLEBatchProcess.CHART_CODE.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getChartCode())) {
1334 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.CHART_CODE)) {
1335 failureRecords.remove(OLEConstants.OLEBatchProcess.CHART_CODE);
1336 }
1337 oleTxRecord.setChartCode(attributeValue);
1338 }
1339 else if (OLEConstants.OLEBatchProcess.ORG_CODE.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getOrgCode())) {
1340 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.ORG_CODE)) {
1341 failureRecords.remove(OLEConstants.OLEBatchProcess.ORG_CODE);
1342 }
1343 oleTxRecord.setOrgCode(attributeValue);
1344 }
1345 else if(OLEConstants.OLEBatchProcess.RECEIVING_REQUIRED.equals(attributeName)) {
1346 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.RECEIVING_REQUIRED)) {
1347 failureRecords.remove(OLEConstants.OLEBatchProcess.RECEIVING_REQUIRED);
1348 }
1349 oleTxRecord.setReceivingRequired(Boolean.parseBoolean(attributeValue));
1350 }
1351 else if (OLEConstants.OLEBatchProcess.CONTRACT_MANAGER.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getContractManager())) {
1352 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.CONTRACT_MANAGER)) {
1353 failureRecords.remove(OLEConstants.OLEBatchProcess.CONTRACT_MANAGER);
1354 }
1355 oleTxRecord.setContractManager(attributeValue);
1356 }
1357 else if (OLEConstants.OLEBatchProcess.ASSIGN_TO_USER.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getAssignToUser())) {
1358 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.ASSIGN_TO_USER)) {
1359 failureRecords.remove(OLEConstants.OLEBatchProcess.ASSIGN_TO_USER);
1360 }
1361 oleTxRecord.setAssignToUser(attributeValue);
1362 }
1363 else if(OLEConstants.OLEBatchProcess.USE_TAX_INDICATOR.equals(attributeName)) {
1364 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.USE_TAX_INDICATOR)) {
1365 failureRecords.remove(OLEConstants.OLEBatchProcess.USE_TAX_INDICATOR);
1366 }
1367 oleTxRecord.setUseTaxIndicator(Boolean.parseBoolean(attributeValue));
1368 }
1369 else if (OLEConstants.OLEBatchProcess.ORDER_TYPE.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getOrderType())) {
1370 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.ORDER_TYPE)) {
1371 failureRecords.remove(OLEConstants.OLEBatchProcess.ORDER_TYPE);
1372 }
1373 oleTxRecord.setOrderType(attributeValue);
1374 }
1375 else if (OLEConstants.OLEBatchProcess.FUNDING_SOURCE.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getFundingSource())) {
1376 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.FUNDING_SOURCE)) {
1377 failureRecords.remove(OLEConstants.OLEBatchProcess.FUNDING_SOURCE);
1378 }
1379 oleTxRecord.setFundingSource(attributeValue);
1380 }
1381 else if(OLEConstants.OLEBatchProcess.PREQ_POSITIVE_APPROVAL_REQ.equals(attributeName)) {
1382 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.PREQ_POSITIVE_APPROVAL_REQ)) {
1383 failureRecords.remove(OLEConstants.OLEBatchProcess.PREQ_POSITIVE_APPROVAL_REQ);
1384 }
1385 oleTxRecord.setPayReqPositiveApprovalReq(Boolean.parseBoolean(attributeValue));
1386 }
1387 else if(OLEConstants.OLEBatchProcess.PO_CONFIRMATION_INDICATOR.equals(attributeName)) {
1388 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.PO_CONFIRMATION_INDICATOR)) {
1389 failureRecords.remove(OLEConstants.OLEBatchProcess.PO_CONFIRMATION_INDICATOR);
1390 }
1391 oleTxRecord.setPurchaseOrderConfirmationIndicator(Boolean.parseBoolean(attributeValue));
1392 }
1393 else if (OLEConstants.OLEBatchProcess.DELIVERY_CAMPUS_CODE.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getDeliveryCampusCode())) {
1394 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.DELIVERY_CAMPUS_CODE)) {
1395 failureRecords.remove(OLEConstants.OLEBatchProcess.DELIVERY_CAMPUS_CODE);
1396 }
1397 oleTxRecord.setDeliveryCampusCode(attributeValue);
1398 }
1399 else if (OLEConstants.OLEBatchProcess.BUILDING_CODE.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getBuildingCode())) {
1400 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.BUILDING_CODE)) {
1401 failureRecords.remove(OLEConstants.OLEBatchProcess.BUILDING_CODE);
1402 }
1403 oleTxRecord.setBuildingCode(attributeValue);
1404 }
1405 else if (OLEConstants.OLEBatchProcess.VENDOR_CHOICE.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getVendorChoice())) {
1406 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.VENDOR_CHOICE)) {
1407 failureRecords.remove(OLEConstants.OLEBatchProcess.VENDOR_CHOICE);
1408 }
1409 oleTxRecord.setVendorChoice(attributeValue);
1410 }
1411 else if(OLEConstants.OLEBatchProcess.ROUTE_TO_REQUESTOR.equals(attributeName)) {
1412 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.ROUTE_TO_REQUESTOR)) {
1413 failureRecords.remove(OLEConstants.OLEBatchProcess.ROUTE_TO_REQUESTOR);
1414 }
1415 oleTxRecord.setRouteToRequestor(Boolean.parseBoolean(attributeValue));
1416 }
1417 else if (OLEConstants.OLEBatchProcess.METHOD_OF_PO_TRANSMISSION.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getMethodOfPOTransmission())) {
1418 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.METHOD_OF_PO_TRANSMISSION)) {
1419 failureRecords.remove(OLEConstants.OLEBatchProcess.METHOD_OF_PO_TRANSMISSION);
1420 }
1421 oleTxRecord.setMethodOfPOTransmission(attributeValue);
1422 }
1423 else if (OLEConstants.OLEBatchProcess.COST_SOURCE.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getCostSource())) {
1424 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.COST_SOURCE)) {
1425 failureRecords.remove(OLEConstants.OLEBatchProcess.COST_SOURCE);
1426 }
1427 oleTxRecord.setCostSource(attributeValue);
1428 }
1429 else if (OLEConstants.OLEBatchProcess.PERCENT.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getPercent())) {
1430 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.PERCENT)) {
1431 failureRecords.remove(OLEConstants.OLEBatchProcess.PERCENT);
1432 }
1433 oleTxRecord.setPercent(attributeValue);
1434 }
1435 else if (OLEConstants.OLEBatchProcess.DEFAULT_LOCATION.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getDefaultLocation())) {
1436 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.DEFAULT_LOCATION)) {
1437 failureRecords.remove(OLEConstants.OLEBatchProcess.DEFAULT_LOCATION);
1438 }
1439 oleTxRecord.setDefaultLocation(attributeValue);
1440 }
1441 else if (OLEConstants.OLEBatchProcess.LIST_PRICE.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getListPrice())) {
1442 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.LIST_PRICE)) {
1443 failureRecords.remove(OLEConstants.OLEBatchProcess.LIST_PRICE);
1444 }
1445 oleTxRecord.setListPrice(attributeValue);
1446 }
1447 else if (OLEConstants.OLEBatchProcess.VENDOR_NUMBER.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getVendorNumber())) {
1448 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.VENDOR_NUMBER)) {
1449 failureRecords.remove(OLEConstants.OLEBatchProcess.VENDOR_NUMBER);
1450 }
1451 oleTxRecord.setVendorNumber(attributeValue);
1452 }
1453 else if (OLEConstants.OLEBatchProcess.VENDOR_CUST_NBR.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getVendorInfoCustomer())) {
1454 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.VENDOR_CUST_NBR)) {
1455 failureRecords.remove(OLEConstants.OLEBatchProcess.VENDOR_CUST_NBR);
1456 }
1457 oleTxRecord.setVendorInfoCustomer(attributeValue);
1458 }
1459 else if (OLEConstants.OLEBatchProcess.QUANTITY.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getQuantity())) {
1460 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.QUANTITY)) {
1461 failureRecords.remove(OLEConstants.OLEBatchProcess.QUANTITY);
1462 }
1463 oleTxRecord.setQuantity(attributeValue);
1464 }
1465 else if (OLEConstants.OLEBatchProcess.ITEM_NO_OF_PARTS.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getItemNoOfParts())) {
1466 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.ITEM_NO_OF_PARTS)) {
1467 failureRecords.remove(OLEConstants.OLEBatchProcess.ITEM_NO_OF_PARTS);
1468 }
1469 oleTxRecord.setItemNoOfParts(attributeValue);
1470 }
1471 else if (OLEConstants.OLEBatchProcess.VENDOR_REFERENCE_NUMBER.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getVendorItemIdentifier())) {
1472 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.VENDOR_REFERENCE_NUMBER)) {
1473 failureRecords.remove(OLEConstants.OLEBatchProcess.VENDOR_REFERENCE_NUMBER);
1474 }
1475 oleTxRecord.setVendorItemIdentifier(attributeValue);
1476 }
1477 else if (OLEConstants.OLEBatchProcess.REQUESTOR_NAME.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getRequestorName())) {
1478 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.REQUESTOR_NAME)) {
1479 failureRecords.remove(OLEConstants.OLEBatchProcess.REQUESTOR_NAME);
1480 }
1481 oleTxRecord.setRequestorName(attributeValue);
1482 }
1483 else if (OLEConstants.OLEBatchProcess.ITEM_STATUS.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getItemStatus())) {
1484 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.ITEM_STATUS)) {
1485 failureRecords.remove(OLEConstants.OLEBatchProcess.ITEM_STATUS);
1486 }
1487 oleTxRecord.setItemStatus(attributeValue);
1488 }
1489 else if (OLEConstants.OLEBatchProcess.DISCOUNT.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getDiscount())) {
1490 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.DISCOUNT)) {
1491 failureRecords.remove(OLEConstants.OLEBatchProcess.DISCOUNT);
1492 }
1493 oleTxRecord.setDiscount(attributeValue);
1494 }
1495 else if (OLEConstants.OLEBatchProcess.DISCOUNT_TYPE.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getDiscountType())) {
1496 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.DISCOUNT_TYPE)) {
1497 failureRecords.remove(OLEConstants.OLEBatchProcess.DISCOUNT_TYPE);
1498 }
1499 oleTxRecord.setDiscountType(attributeValue);
1500 }
1501 else if (OLEConstants.OLEBatchProcess.ACCOUNT_NUMBER.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getAccountNumber())) {
1502 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.ACCOUNT_NUMBER)) {
1503 failureRecords.remove(OLEConstants.OLEBatchProcess.ACCOUNT_NUMBER);
1504 }
1505 oleTxRecord.setAccountNumber(attributeValue);
1506 }
1507 else if (OLEConstants.OLEBatchProcess.OBJECT_CODE.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getObjectCode())) {
1508 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.OBJECT_CODE)) {
1509 failureRecords.remove(OLEConstants.OLEBatchProcess.OBJECT_CODE);
1510 }
1511 oleTxRecord.setObjectCode(attributeValue);
1512 }
1513 else if (OLEConstants.OLEBatchProcess.ITEM_CHART_CODE.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getItemChartCode())) {
1514 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.ITEM_CHART_CODE)) {
1515 failureRecords.remove(OLEConstants.OLEBatchProcess.ITEM_CHART_CODE);
1516 }
1517 oleTxRecord.setItemChartCode(attributeValue);
1518 }
1519 else if (OLEConstants.OLEBatchProcess.REQUEST_SRC.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getRequestSourceType())) {
1520 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.REQUEST_SRC)) {
1521 failureRecords.remove(OLEConstants.OLEBatchProcess.REQUEST_SRC);
1522 }
1523 oleTxRecord.setRequestSourceType(attributeValue);
1524 }
1525 else if (OLEConstants.OLEBatchProcess.CAPTION.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getCaption())) {
1526 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.CAPTION)) {
1527 failureRecords.remove(OLEConstants.OLEBatchProcess.CAPTION);
1528 }
1529 oleTxRecord.setCaption(attributeValue);
1530 }
1531 else if (OLEConstants.OLEBatchProcess.VOLUME_NUMBER.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getVolumeNumber())) {
1532 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.VOLUME_NUMBER)) {
1533 failureRecords.remove(OLEConstants.OLEBatchProcess.VOLUME_NUMBER);
1534 }
1535 oleTxRecord.setVolumeNumber(attributeValue);
1536 }
1537 else if (OLEConstants.OLEBatchProcess.DELIVERY_BUILDING_ROOM_NUMBER.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getVolumeNumber())) {
1538 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.DELIVERY_BUILDING_ROOM_NUMBER)) {
1539 failureRecords.remove(OLEConstants.OLEBatchProcess.DELIVERY_BUILDING_ROOM_NUMBER);
1540 }
1541 oleTxRecord.setDeliveryBuildingRoomNumber(attributeValue);
1542 }else if(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_TYP.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getRecurringPaymentType())) {
1543 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_TYP)) {
1544 failureRecords.remove(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_TYP);
1545 }
1546 oleTxRecord.setRecurringPaymentType(attributeValue);
1547 }else if(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_BEGIN_DT.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getRecurringPaymentBeginDate())) {
1548 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_BEGIN_DT)) {
1549 failureRecords.remove(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_BEGIN_DT);
1550 }
1551 oleTxRecord.setRecurringPaymentBeginDate(attributeValue);
1552 }else if(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_END_DT.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getRecurringPaymentEndDate())) {
1553 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_END_DT)) {
1554 failureRecords.remove(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_END_DT);
1555 }
1556 oleTxRecord.setRecurringPaymentEndDate(attributeValue);
1557 }
1558
1559 }
1560 }
1561 LOG.debug("----End of setDefaultAndConstantValuesToTxnRecord()------------------------------");
1562 return failureRecords;
1563 }
1564
1565
1566
1567
1568
1569
1570 public boolean checkRequestorName(String requestorName){
1571 LOG.debug("----Inside checkRequestorName() of Order Record Import------------------------------");
1572 boolean requestorAvailable = false;
1573 String[] requestorNames = requestorName.split(", ");
1574 if(requestorNames.length == 2){
1575 String lastName = requestorNames[0];
1576 String firstName = requestorNames[1];
1577 Map<String,String> requestorNameMap = new HashMap<>();
1578 requestorNameMap.put(org.kuali.ole.sys.OLEConstants.OlePersonRequestorLookupable.FIRST_NAME,firstName);
1579 requestorNameMap.put(org.kuali.ole.sys.OLEConstants.OlePersonRequestorLookupable.LAST_NAME,lastName);
1580 List<OLERequestorPatronDocument> olePatronDocumentList = getOleSelectDocumentService().getPatronDocumentListFromWebService();
1581 if(olePatronDocumentList != null && olePatronDocumentList.size()>0){
1582 for(int recCount = 0;recCount < olePatronDocumentList.size();recCount++) {
1583 if(olePatronDocumentList.get(recCount).getFirstName().equalsIgnoreCase(firstName) && olePatronDocumentList.get(recCount).getLastName().equalsIgnoreCase(lastName)){
1584 requestorAvailable = true;
1585 break;
1586 }
1587 }
1588 }
1589 }
1590 return requestorAvailable;
1591
1592 }
1593
1594 public boolean validateItemStatus(String itemStatus) {
1595 List<KeyValue> itemStatusList = getKeyValues();
1596 boolean validItemStatus = false;
1597 for(int itemStatusCount = 0; itemStatusCount < itemStatusList.size(); itemStatusCount++){
1598 if(itemStatusList.get(itemStatusCount).getKey().equalsIgnoreCase(itemStatus)) {
1599 validItemStatus = true;
1600 break;
1601 }
1602 }
1603 return validItemStatus;
1604 }
1605
1606 public List<KeyValue> getKeyValues() {
1607
1608 List<KeyValue> options = new ArrayList<KeyValue>();
1609 Collection<OleItemAvailableStatus> oleItemAvailableStatuses = KRADServiceLocator.getBusinessObjectService().findAll(OleItemAvailableStatus.class);
1610 String excludeItemStatus = getParameter(OLEConstants.EXCLUDE_ITEM_STATUS);
1611 Map<String,String> map = new HashMap<>();
1612 if(excludeItemStatus!=null && !excludeItemStatus.isEmpty()){
1613 String[] itemStatusList = excludeItemStatus.split(",");
1614 for(String itemStatus : itemStatusList){
1615 map.put(itemStatus,itemStatus);
1616 }
1617 }
1618 for (OleItemAvailableStatus type : oleItemAvailableStatuses) {
1619 if (type.isActive() && !map.containsKey(type.getItemAvailableStatusCode())) {
1620 options.add(new ConcreteKeyValue(type.getItemAvailableStatusCode(), type.getItemAvailableStatusName()));
1621 }
1622 }
1623 return options;
1624 }
1625
1626 public String getParameter(String name){
1627 ParameterKey parameterKey = ParameterKey.create(OLEConstants.APPL_ID, OLEConstants.SELECT_NMSPC, OLEConstants.SELECT_CMPNT,name);
1628 Parameter parameter = CoreServiceApiServiceLocator.getParameterRepositoryService().getParameter(parameterKey);
1629 return parameter!=null?parameter.getValue():null;
1630 }
1631
1632 public boolean validateForNumber(String fieldValue){
1633 try {
1634 Integer quantity = Integer.parseInt(fieldValue);
1635 if(quantity <= 0){
1636 return false;
1637 }
1638 }
1639 catch(NumberFormatException nfe){
1640 return false;
1641 }
1642 return true;
1643 }
1644
1645 public boolean validateDestinationFieldValues(String destinationFieldValue){
1646 try {
1647 Float fieldValue = Float.parseFloat(destinationFieldValue);
1648 if(fieldValue < 0){
1649 return false;
1650 }
1651 }
1652 catch(NumberFormatException nfe){
1653 return false;
1654 }
1655 return true;
1656 }
1657
1658 public boolean validateForPercentage(String percentage){
1659 try {
1660 Float fieldValue = Float.parseFloat(percentage);
1661 if(fieldValue != 100){
1662 return false;
1663 }
1664 }
1665 catch(NumberFormatException nfe){
1666 return false;
1667 }
1668 return true;
1669 }
1670
1671 public boolean validateDefaultLocation(String defaultLocation){
1672 List<String> locationList = getItemLocation();
1673 Boolean isLocationAvailable = false;
1674 for(int locationCount = 0;locationCount < locationList.size();locationCount++) {
1675 if(locationList.get(locationCount).equalsIgnoreCase(defaultLocation)){
1676 isLocationAvailable = true;
1677 break;
1678 }
1679 }
1680 return isLocationAvailable;
1681 }
1682
1683 public boolean validateVendorNumber(String vendorNumber){
1684 LOG.debug("----Inside validateVendorNumber()------------------------------");
1685 boolean isValidVendor = false;
1686 String[] vendorDetail = vendorNumber.split("-");
1687 if(vendorDetail.length == 2){
1688 String vendorHeaderGeneratedIdentifier = vendorDetail[0];
1689 String vendorDetailAssignedIdentifier = vendorDetail[1];
1690 try {
1691 Map<String,Integer> vendorMap = new HashMap<>();
1692 vendorMap.put(OLEConstants.VENDOR_HEADER_GENERATED_ID, Integer.parseInt(vendorHeaderGeneratedIdentifier));
1693 vendorMap.put(OLEConstants.VENDOR_DETAILED_ASSIGNED_ID, Integer.parseInt(vendorDetailAssignedIdentifier));
1694 List<VendorDetail> vendorDetailList = (List) getBusinessObjectService().findMatching(VendorDetail.class, vendorMap);
1695 if(vendorDetail != null && vendorDetailList.size() > 0){
1696 return true;
1697 }
1698 }
1699 catch (NumberFormatException nfe) {
1700 return false;
1701 }
1702 }
1703 else {
1704 return false;
1705 }
1706 return isValidVendor;
1707 }
1708
1709 public List<String> getItemLocation() {
1710 LOG.debug(" Inside get Item Location Method of Order Record Import");
1711 List<String> locationList = new ArrayList<String>();
1712 List<KeyValue> options = new ArrayList<KeyValue>();
1713 Map parentCriteria1 = new HashMap();
1714 parentCriteria1.put(OLEConstants.OLEBatchProcess.LEVEL_CODE, OLEConstants.LOC_LEVEL_SHELVING);
1715 List<OleLocationLevel> oleLocationLevel = (List<OleLocationLevel>) getBusinessObjectService().findMatching(OleLocationLevel.class, parentCriteria1);
1716 String shelvingId = oleLocationLevel.get(0).getLevelId();
1717 Map parentCriteria = new HashMap();
1718 parentCriteria.put(OLEConstants.LEVEL_ID, shelvingId);
1719 Collection<OleLocation> oleLocationCollection = getBusinessObjectService().findMatching(OleLocation.class, parentCriteria);
1720 for (OleLocation oleLocation : oleLocationCollection) {
1721 String locationName = oleLocation.getLocationName();
1722 String levelCode = oleLocation.getLocationCode();
1723 boolean parentId = oleLocation.getParentLocationId() != null ? true : false;
1724 while (parentId) {
1725 Map criteriaMap = new HashMap();
1726 criteriaMap.put(OLEConstants.LOCATION_ID, oleLocation.getParentLocationId());
1727 OleLocation location = getBusinessObjectService().findByPrimaryKey(OleLocation.class,
1728 criteriaMap);
1729 if (locationName != null) {
1730 locationName = location.getLocationName() + OLEConstants.SLASH + locationName;
1731 }
1732 if (levelCode != null) {
1733 levelCode = location.getLocationCode() + OLEConstants.SLASH + levelCode;
1734 }
1735 parentId = location.getParentLocationId() != null ? true : false;
1736 oleLocation = location;
1737 }
1738 options.add(new ConcreteKeyValue(levelCode, levelCode));
1739 }
1740 Map<String, String> map = new HashMap<String, String>();
1741 for (KeyValue option : options) {
1742 map.put(option.getKey(), option.getValue());
1743 }
1744 Map<String, Object> map1 = sortByLocation(map);
1745 for (Map.Entry<String, Object> entry : map1.entrySet()) {
1746 locationList.add((String) entry.getValue());
1747 }
1748 return locationList;
1749 }
1750
1751 private Map<String, Object> sortByLocation(Map<String, String> parentCriteria) {
1752 Map<String, Object> map = new LinkedHashMap<String, Object>();
1753 List<String> keyList = new ArrayList<String>(parentCriteria.keySet());
1754 List<String> valueList = new ArrayList<String>(parentCriteria.values());
1755 Set<String> sortedSet = new TreeSet<String>(valueList);
1756 Object[] sortedArray = sortedSet.toArray();
1757 int size = sortedArray.length;
1758 for (int i = 0; i < size; i++) {
1759 map.put(keyList.get(valueList.indexOf(sortedArray[i])), sortedArray[i]);
1760 }
1761 return map;
1762 }
1763
1764 public List<OleTxRecord> getQuantityItemPartsLocation(List<BibMarcRecord> bibMarcRecords, OLEBatchProcessJobDetailsBo job) {
1765 OrderImportHelperBo orderImportHelperBo = job.getOrderImportHelperBo();
1766 List<BibMarcRecord> bibMarcRecordList = new ArrayList<>();
1767 List<OleTxRecord> oleTxRecordList = new ArrayList<>();
1768 for (BibMarcRecord bibMarcRecord : bibMarcRecords) {
1769 Map<String, String> mappingFailures = new HashMap<String, String>();
1770 OleTxRecord oleTxRecord = new OleTxRecord();
1771 List<OLEBatchProcessProfileMappingOptionsBo> oleBatchProcessProfileMappingOptionsBoList = job.getOrderImportHelperBo().getOleBatchProcessProfileBo().getOleBatchProcessProfileMappingOptionsList();
1772 for (OLEBatchProcessProfileMappingOptionsBo oleBatchProcessProfileMappingOptionsBo : oleBatchProcessProfileMappingOptionsBoList) {
1773 List<OLEBatchProcessProfileDataMappingOptionsBo> oleBatchProcessProfileDataMappingOptionsBoList = oleBatchProcessProfileMappingOptionsBo.getOleBatchProcessProfileDataMappingOptionsBoList();
1774 for (int dataMapCount = 0; dataMapCount < oleBatchProcessProfileDataMappingOptionsBoList.size(); dataMapCount++) {
1775 String sourceField = oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getSourceField();
1776 String sourceFields[] = sourceField.split("\\$");
1777 if (sourceFields.length == 2) {
1778 String dataField = sourceFields[0].trim();
1779 String tagField = sourceFields[1].trim();
1780 if (OLEConstants.OLEBatchProcess.QUANTITY.equals(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField())) {
1781 String quantity = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList, dataMapCount, bibMarcRecord, dataField, tagField);
1782 if (!StringUtils.isBlank(quantity)) {
1783 boolean validQuantity = validateForNumber(quantity);
1784 if (!validQuantity) {
1785 mappingFailures.put(OLEConstants.OLEBatchProcess.QUANTITY, OLEConstants.INVALID_QTY + " " + dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField + " " + quantity);
1786 quantity = null;
1787 }
1788 oleTxRecord.setQuantity(quantity);
1789 } else {
1790 mappingFailures.put(OLEConstants.OLEBatchProcess.QUANTITY, OLEConstants.REQUIRED_QTY + " " + dataField + OLEConstants.DELIMITER_DOLLAR + tagField + " " + OLEConstants.NULL_VALUE_MESSAGE);
1791 }
1792 } else if (OLEConstants.OLEBatchProcess.ITEM_NO_OF_PARTS.equals(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField())) {
1793 String itemNoOfParts = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList, dataMapCount, bibMarcRecord, dataField, tagField);
1794 if (!StringUtils.isBlank(itemNoOfParts)) {
1795 boolean validNoOfParts = validateForNumber(itemNoOfParts);
1796 if (!validNoOfParts) {
1797 mappingFailures.put(OLEConstants.OLEBatchProcess.ITEM_NO_OF_PARTS, OLEConstants.INVALID_NO_OF_PARTS + " " + dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField + " " + itemNoOfParts);
1798 itemNoOfParts = null;
1799 }
1800 oleTxRecord.setItemNoOfParts(itemNoOfParts);
1801 } else {
1802 mappingFailures.put(OLEConstants.OLEBatchProcess.ITEM_NO_OF_PARTS, OLEConstants.REQUIRED_NO_OF_PARTS + " " + dataField + OLEConstants.DELIMITER_DOLLAR + tagField + " " + OLEConstants.NULL_VALUE_MESSAGE);
1803 }
1804 } else if (OLEConstants.OLEBatchProcess.DEFAULT_LOCATION.equals(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField())) {
1805 String defaultLocation = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList, dataMapCount, bibMarcRecord, dataField, tagField);
1806 if (!StringUtils.isBlank(defaultLocation)) {
1807 boolean validDefaultLocation = validateDefaultLocation(defaultLocation);
1808 if (!validDefaultLocation) {
1809 mappingFailures.put(OLEConstants.OLEBatchProcess.DEFAULT_LOCATION, OLEConstants.INVALID_LOCN_NM + " " + dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField + " " + defaultLocation);
1810 defaultLocation = null;
1811 }
1812 oleTxRecord.setDefaultLocation(defaultLocation);
1813 } else {
1814 mappingFailures.put(OLEConstants.OLEBatchProcess.DEFAULT_LOCATION, OLEConstants.REQUIRED_LOCATION_NM + " " + dataField + OLEConstants.DELIMITER_DOLLAR + tagField + " " + OLEConstants.NULL_VALUE_MESSAGE);
1815 }
1816 }
1817 }
1818 }
1819 }
1820
1821 List<OLEBatchProcessProfileConstantsBo> oleBatchProcessProfileConstantsBoList = job.getOrderImportHelperBo().getOleBatchProcessProfileBo().getOleBatchProcessProfileConstantsList();
1822 for (OLEBatchProcessProfileConstantsBo oleBatchProcessProfileConstantsBo : oleBatchProcessProfileConstantsBoList) {
1823 if (OLEConstants.OLEBatchProcess.CONSTANT.equals(oleBatchProcessProfileConstantsBo.getDefaultValue())) {
1824 if (OLEConstants.OLEBatchProcess.QUANTITY.equals(oleBatchProcessProfileConstantsBo.getAttributeName())) {
1825 if (mappingFailures.containsKey(OLEConstants.OLEBatchProcess.QUANTITY)) {
1826 mappingFailures.remove(OLEConstants.OLEBatchProcess.QUANTITY);
1827 }
1828 oleTxRecord.setQuantity(oleBatchProcessProfileConstantsBo.getAttributeValue());
1829 } else if (OLEConstants.OLEBatchProcess.ITEM_NO_OF_PARTS.equals(oleBatchProcessProfileConstantsBo.getAttributeName())) {
1830 if (mappingFailures.containsKey(OLEConstants.OLEBatchProcess.ITEM_NO_OF_PARTS)) {
1831 mappingFailures.remove(OLEConstants.OLEBatchProcess.ITEM_NO_OF_PARTS);
1832 }
1833 oleTxRecord.setItemNoOfParts(oleBatchProcessProfileConstantsBo.getAttributeValue());
1834 } else if (OLEConstants.OLEBatchProcess.DEFAULT_LOCATION.equals(oleBatchProcessProfileConstantsBo.getAttributeName())) {
1835 if (mappingFailures.containsKey(OLEConstants.OLEBatchProcess.DEFAULT_LOCATION)) {
1836 mappingFailures.remove(OLEConstants.OLEBatchProcess.DEFAULT_LOCATION);
1837 }
1838 oleTxRecord.setDefaultLocation(oleBatchProcessProfileConstantsBo.getAttributeValue());
1839 }
1840 } else if (OLEConstants.OLEBatchProcess.DEFAULT.equals(oleBatchProcessProfileConstantsBo.getDefaultValue())) {
1841 if (OLEConstants.OLEBatchProcess.QUANTITY.equals(oleBatchProcessProfileConstantsBo.getAttributeName()) && StringUtils.isBlank(oleTxRecord.getQuantity()) && !mappingFailures.containsKey(OLEConstants.OLEBatchProcess.QUANTITY)) {
1842 oleTxRecord.setQuantity(oleBatchProcessProfileConstantsBo.getAttributeValue());
1843 } else if (OLEConstants.OLEBatchProcess.ITEM_NO_OF_PARTS.equals(oleBatchProcessProfileConstantsBo.getAttributeName()) && StringUtils.isBlank(oleTxRecord.getItemNoOfParts()) && !mappingFailures.containsKey(OLEConstants.OLEBatchProcess.ITEM_NO_OF_PARTS)) {
1844 oleTxRecord.setItemNoOfParts(oleBatchProcessProfileConstantsBo.getAttributeValue());
1845 } else if (OLEConstants.OLEBatchProcess.DEFAULT_LOCATION.equals(oleBatchProcessProfileConstantsBo.getAttributeName()) && StringUtils.isBlank(oleTxRecord.getDefaultLocation()) && !mappingFailures.containsKey(OLEConstants.OLEBatchProcess.DEFAULT_LOCATION)) {
1846 oleTxRecord.setDefaultLocation(oleBatchProcessProfileConstantsBo.getAttributeValue());
1847 }
1848 }
1849 }
1850 if (mappingFailures.size() == 0) {
1851 oleTxRecordList.add(oleTxRecord);
1852
1853 } else {
1854 bibMarcRecordList.add(bibMarcRecord);
1855 Collection failureList = mappingFailures.values();
1856 if (failureList != null && failureList.size() > 0) {
1857
1858 List reasonForFailure = orderImportHelperBo.getFailureReason();
1859 if (reasonForFailure == null) {
1860 reasonForFailure = new ArrayList();
1861 }
1862 reasonForFailure.addAll(failureList);
1863
1864 orderImportHelperBo.setFailureReason(reasonForFailure);
1865 failureList.clear();
1866 }
1867 }
1868 }
1869 bibMarcRecords.removeAll(bibMarcRecordList);
1870 return oleTxRecordList;
1871 }
1872
1873 }