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
762
763
764
765
766 }
767 else if (OLEConstants.OLEBatchProcess.REQUESTOR_NAME.equals(destinationField)) {
768 String requestorName = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList, dataMapCount, bibMarcRecord, dataField, tagField);
769 if(!StringUtils.isBlank(requestorName)){
770 boolean validRequestorName = checkRequestorName(requestorName);
771 if(!validRequestorName){
772 mappingFailures.put(OLEConstants.OLEBatchProcess.REQUESTOR_NAME, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.INVALID_REQUESTOR_NAME + " " +dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField +" " + requestorName);
773 requestorName = null;
774 }
775 oleTxRecord.setRequestorName(requestorName);
776 }
777 else{
778 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);
779 }
780 }
781 else if (OLEConstants.OLEBatchProcess.ITEM_STATUS.equals(destinationField)) {
782 String itemStatus = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList,dataMapCount,bibMarcRecord, dataField, tagField);
783 if(!StringUtils.isBlank(itemStatus)){
784 boolean validItemStatus = validateItemStatus(itemStatus);
785 if(!validItemStatus){
786 mappingFailures.put(OLEConstants.OLEBatchProcess.ITEM_STATUS, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.INVALID_ITEM_STATUS + " " +dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField +" " + itemStatus);
787 itemStatus = null;
788 }
789 oleTxRecord.setItemStatus(itemStatus);
790 }
791 else{
792 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);
793 }
794 }
795 else if (OLEConstants.OLEBatchProcess.DISCOUNT.equals(destinationField)) {
796 String discount = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList,dataMapCount,bibMarcRecord,dataField,tagField);
797 if(!StringUtils.isBlank(discount)){
798 boolean validDiscount = validateDestinationFieldValues(discount);
799 if(!validDiscount){
800 mappingFailures.put(OLEConstants.OLEBatchProcess.DISCOUNT, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.INVALID_DISCOUNT + " " +dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField +" " + discount);
801 discount = null;
802 }
803 oleTxRecord.setDiscount(discount);
804 }
805 else{
806 mappingFailures.put(OLEConstants.OLEBatchProcess.DISCOUNT, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.REQUIRED_DISCOUNT + " " + dataField + OLEConstants.DELIMITER_DOLLAR + tagField + " " + OLEConstants.NULL_VALUE_MESSAGE);
807 }
808 }
809 else if (OLEConstants.OLEBatchProcess.DISCOUNT_TYPE.equals(destinationField)) {
810 String discountType = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList,dataMapCount,bibMarcRecord,dataField,tagField);
811 if(!StringUtils.isBlank(discountType)){
812 if(!discountType.equalsIgnoreCase(OLEConstants.PERCENTAGE) && !discountType.equalsIgnoreCase(OLEConstants.DELIMITER_HASH)){
813 mappingFailures.put(OLEConstants.OLEBatchProcess.DISCOUNT_TYPE, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.INVALID_DISCOUNT_TYPE + " " +dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField +" " + discountType);
814 discountType = null;
815 }
816 oleTxRecord.setDiscountType(discountType);
817 }
818 else{
819 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);
820 }
821 }
822 else if (OLEConstants.OLEBatchProcess.ACCOUNT_NUMBER.equals(destinationField)) {
823 String accountNumber = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList,dataMapCount,bibMarcRecord,dataField,tagField);
824 if(!StringUtils.isBlank(accountNumber)){
825 Map<String,String> accountNumberMap = new HashMap<>();
826 accountNumberMap.put(OLEConstants.OLEBatchProcess.ACCOUNT_NUMBER, accountNumber);
827 List<Account> accountNumberList = (List) getLookupService().findCollectionBySearchHelper(Account.class, accountNumberMap,true);
828 if(accountNumberList.size() == 0){
829 mappingFailures.put(OLEConstants.OLEBatchProcess.ACCOUNT_NUMBER, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.INVALID_ACCOUNT_NUMBER + " " +dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField +" " + accountNumber);
830 accountNumber = null;
831 }
832 oleTxRecord.setAccountNumber(accountNumber);
833 if (StringUtils.isNotBlank(accountNumber)) {
834 oleTxRecord.setAccountNumber(accountNumberList.get(0).getAccountNumber());
835 }
836 }
837 else{
838 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);
839 }
840 }
841 else if (OLEConstants.OLEBatchProcess.OBJECT_CODE.equals(destinationField)) {
842 String objectCode = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList,dataMapCount,bibMarcRecord,dataField,tagField);
843 if(!StringUtils.isBlank(objectCode)) {
844 Map<String,String> objectCodeMap = new HashMap<>();
845 objectCodeMap.put(OLEConstants.OLEBatchProcess.OBJECT_CODE, objectCode);
846 List<ObjectCode> objectCodeList = (List) getBusinessObjectService().findMatching(ObjectCode.class, objectCodeMap);
847 if(objectCodeList.size() == 0){
848 mappingFailures.put(OLEConstants.OLEBatchProcess.OBJECT_CODE, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.INVALID_OBJECT_CODE + " " +dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField +" " + objectCode);
849 objectCode = null;
850 }
851 oleTxRecord.setObjectCode(objectCode);
852 }
853 else{
854 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);
855 }
856 }
857 else if (OLEConstants.OLEBatchProcess.ITEM_CHART_CODE.equals(destinationField)) {
858 String itemChartCode = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList,dataMapCount,bibMarcRecord,dataField,tagField);
859 if(!StringUtils.isBlank(itemChartCode)) {
860 Map<String,String> itemChartCodeMap = new HashMap<>();
861 itemChartCodeMap.put(OLEConstants.OLEBatchProcess.CHART_OF_ACCOUNTS_CODE, itemChartCode);
862 List<Chart> itemChartCodeList = (List) getBusinessObjectService().findMatching(Chart.class, itemChartCodeMap);
863 if(itemChartCodeList.size() == 0){
864 mappingFailures.put(OLEConstants.OLEBatchProcess.ITEM_CHART_CODE, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.INVALID_ITEM_CHART_CD + " " +dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField +" " + itemChartCode);
865 itemChartCode = null;
866 }
867 oleTxRecord.setItemChartCode(itemChartCode);
868 }
869 else{
870 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);
871 }
872 }
873 else if (OLEConstants.OLEBatchProcess.FORMAT_TYP_NM.equals(destinationField)) {
874 String formatTypeName = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList,dataMapCount,bibMarcRecord,dataField,tagField);
875 if(!StringUtils.isBlank(formatTypeName)) {
876 Map<String,String> formatTypeMap = new HashMap<>();
877 formatTypeMap.put(OLEConstants.OLEBatchProcess.FORMAT_TYP_NM, formatTypeName);
878 List<OleFormatType> formatTypeList = (List) getBusinessObjectService().findMatching(OleFormatType.class, formatTypeMap);
879 if(formatTypeList == null || formatTypeList.size() == 0){
880 mappingFailures.put(OLEConstants.OLEBatchProcess.FORMAT_TYP_NM, OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.INVALID_FORMAT + " " +dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField +" " + formatTypeName);
881 }
882 else{
883 oleTxRecord.setFormatTypeId(formatTypeList.get(0).getFormatTypeId().toString());
884 }
885 }
886 else{
887 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);
888 }
889 }
890 else if (OLEConstants.OLEBatchProcess.MISC_NOTE.equals(destinationField)) {
891 String miscellaneousNote = setDataMappingValuesForDonorAndNotesSection(oleBatchProcessProfileDataMappingOptionsBoList, dataMapCount, bibMarcRecord, dataField, tagField);
892 if (!StringUtils.isBlank(miscellaneousNote)) {
893 if (miscellaneousNote.length() > 2000) {
894 miscellaneousNote = miscellaneousNote.substring(0, 2000);
895 }
896 miscellaneousNotes.add(miscellaneousNote);
897 }
898 }
899 else if (OLEConstants.OLEBatchProcess.RCPT_NOTE.equals(destinationField)) {
900 String receiptNote = setDataMappingValuesForDonorAndNotesSection(oleBatchProcessProfileDataMappingOptionsBoList, dataMapCount, bibMarcRecord, dataField, tagField);
901 if (!StringUtils.isBlank(receiptNote)) {
902 if (receiptNote.length() > 2000) {
903 receiptNote = receiptNote.substring(0, 2000);
904 }
905 receiptNotes.add(receiptNote);
906 }
907 }
908 else if (OLEConstants.OLEBatchProcess.RQST_NOTE.equals(destinationField)) {
909 String requestorNote = setDataMappingValuesForDonorAndNotesSection(oleBatchProcessProfileDataMappingOptionsBoList, dataMapCount, bibMarcRecord, dataField, tagField);
910 if (!StringUtils.isBlank(requestorNote)) {
911 if (requestorNote.length() > 2000) {
912 requestorNote = requestorNote.substring(0, 2000);
913 }
914 requestorNotes.add(requestorNote);
915 }
916 }
917 else if (OLEConstants.OLEBatchProcess.SELECTOR_NOTE.equals(destinationField)) {
918 String selectorNote = setDataMappingValuesForDonorAndNotesSection(oleBatchProcessProfileDataMappingOptionsBoList, dataMapCount, bibMarcRecord, dataField, tagField);
919 if (!StringUtils.isBlank(selectorNote)) {
920 if (selectorNote.length() > 2000) {
921 selectorNote = selectorNote.substring(0, 2000);
922 }
923 selectorNotes.add(selectorNote);
924 }
925 }
926 else if (OLEConstants.OLEBatchProcess.SPL_PROCESS_NOTE.equals(destinationField)) {
927 String splProcessInstrNote = setDataMappingValuesForDonorAndNotesSection(oleBatchProcessProfileDataMappingOptionsBoList, dataMapCount, bibMarcRecord, dataField, tagField);
928 if (!StringUtils.isBlank(splProcessInstrNote)) {
929 if (splProcessInstrNote.length() > 2000) {
930 splProcessInstrNote = splProcessInstrNote.substring(0, 2000);
931 }
932 splProcessInstrNotes.add(splProcessInstrNote);
933 }
934 }
935 else if (OLEConstants.OLEBatchProcess.VNDR_INSTR_NOTE.equals(destinationField)) {
936 String vendorInstrNote = setDataMappingValuesForDonorAndNotesSection(oleBatchProcessProfileDataMappingOptionsBoList, dataMapCount, bibMarcRecord, dataField, tagField);
937 if (!StringUtils.isBlank(vendorInstrNote)) {
938 if (vendorInstrNote.length() > 2000) {
939 vendorInstrNote = vendorInstrNote.substring(0, 2000);
940 }
941 vendorInstrNotes.add(vendorInstrNote);
942 }
943 }
944 else if (OLEConstants.OLEBatchProcess.CAPTION.equals(destinationField)) {
945 String caption = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList,dataMapCount,bibMarcRecord,dataField,tagField);
946 oleTxRecord.setCaption(caption);
947 }
948 else if (OLEConstants.OLEBatchProcess.VOLUME_NUMBER.equals(destinationField)) {
949 String volumeNumber = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList, dataMapCount, bibMarcRecord, dataField, tagField);
950 oleTxRecord.setVolumeNumber(volumeNumber);
951 }
952 }
953 }
954 if (donors.size()>0){
955 oleTxRecord.setOleDonors(donors);
956 }
957 if(miscellaneousNotes.size() > 0){
958 oleTxRecord.setMiscellaneousNote(OLEConstants.OLEBatchProcess.MISC_NOTE);
959 oleTxRecord.setMiscellaneousNotes(miscellaneousNotes);
960 }
961 if(receiptNotes.size() > 0){
962 oleTxRecord.setReceiptNote(OLEConstants.OLEBatchProcess.RCPT_NOTE);
963 oleTxRecord.setReceiptNotes(receiptNotes);
964 }
965 if(requestorNotes.size() > 0){
966 oleTxRecord.setRequestorNote(OLEConstants.OLEBatchProcess.RQST_NOTE);
967 oleTxRecord.setRequestorNotes(requestorNotes);
968 }
969 if(selectorNotes.size() > 0){
970 oleTxRecord.setSelectorNote(OLEConstants.OLEBatchProcess.SELECTOR_NOTE);
971 oleTxRecord.setSelectorNotes(selectorNotes);
972 }
973 if(splProcessInstrNotes.size() > 0){
974 oleTxRecord.setSplProcessInstrNote(OLEConstants.OLEBatchProcess.SPL_PROCESS_NOTE);
975 oleTxRecord.setSplProcessInstrNotes(splProcessInstrNotes);
976 }
977 if(vendorInstrNotes.size() > 0){
978 oleTxRecord.setVendorInstrNote(OLEConstants.OLEBatchProcess.VNDR_INSTR_NOTE);
979 oleTxRecord.setVendorInstrNotes(vendorInstrNotes);
980 }
981 if (LOG.isDebugEnabled()){
982 LOG.debug("*******************FailureRecords**************" + failureRecords.toString());
983 }
984 }
985 LOG.debug("----End of mapDataFieldsToTxnRecord()------------------------------");
986 return mappingFailures;
987 }
988
989 private boolean validateDate(String recurringDate){
990 SimpleDateFormat dateFromRawFile = new SimpleDateFormat(org.kuali.ole.OLEConstants.DATE_FORMAT);
991 try {
992 dateFromRawFile.parse(recurringDate);
993 return true;
994 }
995 catch (ParseException e) {
996 return false;
997 }
998 }
999
1000 private String setDataMappingValues(List<OLEBatchProcessProfileDataMappingOptionsBo> oleBatchProcessProfileDataMappingOptionsBoList,int dataMapCount,BibMarcRecord bibMarcRecord,String dataField,String tagField){
1001 String subFieldValue = getSubFieldValueFor(bibMarcRecord, dataField, tagField);
1002 if (StringUtils.isBlank(subFieldValue)) {
1003 OLEBatchProcessProfileDataMappingOptionsBo oleBatchProcessProfileDataMappingOptionsBo = oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount);
1004 if (dataMapCount+1 <= oleBatchProcessProfileDataMappingOptionsBoList.size()) {
1005 if(dataMapCount+1 == oleBatchProcessProfileDataMappingOptionsBoList.size()) {
1006 subFieldValue = oleBatchProcessProfileDataMappingOptionsBo.getDestinationFieldValue();
1007 }
1008 else if(!oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount+1).getDestinationField().equalsIgnoreCase(oleBatchProcessProfileDataMappingOptionsBo.getDestinationField())){
1009 subFieldValue = oleBatchProcessProfileDataMappingOptionsBo.getDestinationFieldValue();
1010 }
1011 }
1012 }
1013 return subFieldValue;
1014 }
1015
1016 private String setDataMappingValuesForDonorAndNotesSection(List<OLEBatchProcessProfileDataMappingOptionsBo> oleBatchProcessProfileDataMappingOptionsBoList, int dataMapCount, BibMarcRecord bibMarcRecord, String dataField, String tagField) {
1017 String subFieldValue = getSubFieldValueFor(bibMarcRecord, dataField, tagField);
1018 if (StringUtils.isBlank(subFieldValue)) {
1019 OLEBatchProcessProfileDataMappingOptionsBo oleBatchProcessProfileDataMappingOptionsBo = oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount);
1020 while (dataMapCount + 1 <= oleBatchProcessProfileDataMappingOptionsBoList.size()) {
1021 if (dataMapCount + 1 == oleBatchProcessProfileDataMappingOptionsBoList.size()) {
1022 subFieldValue = oleBatchProcessProfileDataMappingOptionsBo.getDestinationFieldValue();
1023 break;
1024 } else if (!oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount + 1).getDestinationField().equalsIgnoreCase(oleBatchProcessProfileDataMappingOptionsBo.getDestinationField())) {
1025 subFieldValue = oleBatchProcessProfileDataMappingOptionsBo.getDestinationFieldValue();
1026 break;
1027 }
1028 dataMapCount++;
1029 }
1030 }
1031 return subFieldValue;
1032 }
1033
1034 private String getSubFieldValueFor(BibMarcRecord bibMarcRecord, String dataField, String tag) {
1035 String subFieldValue = null;
1036 org.kuali.ole.docstore.common.document.content.bib.marc.DataField dataFieldForTag = getDataFieldForTag(bibMarcRecord, dataField);
1037 if (null != dataFieldForTag) {
1038 List<org.kuali.ole.docstore.common.document.content.bib.marc.SubField> subfields = dataFieldForTag.getSubFields();
1039 for (Iterator<org.kuali.ole.docstore.common.document.content.bib.marc.SubField> iterator = subfields.iterator(); iterator.hasNext(); ) {
1040 org.kuali.ole.docstore.common.document.content.bib.marc.SubField marcSubField = iterator.next();
1041 if (marcSubField.getCode().equals(tag)) {
1042 subFieldValue = marcSubField.getValue();
1043 return subFieldValue;
1044 }
1045 }
1046 }
1047 return subFieldValue;
1048 }
1049
1050 public org.kuali.ole.docstore.common.document.content.bib.marc.DataField getDataFieldForTag(BibMarcRecord bibMarcRecord, String tag) {
1051 for (Iterator<org.kuali.ole.docstore.common.document.content.bib.marc.DataField> iterator = bibMarcRecord.getDataFields().iterator(); iterator.hasNext(); ) {
1052 org.kuali.ole.docstore.common.document.content.bib.marc.DataField marcDataField = iterator.next();
1053 if (marcDataField.getTag().equalsIgnoreCase(tag)) {
1054 return marcDataField;
1055 }
1056 }
1057 return null;
1058 }
1059
1060
1061
1062
1063
1064
1065 private void setAccountingLinesDetails(OleTxRecord oleTxRecord,int recordPosition, OLEBatchProcessJobDetailsBo job){
1066 OrderImportHelperBo orderImportHelperBo = job.getOrderImportHelperBo();
1067 if(oleTxRecord.getAccountNumber() != null && oleTxRecord.getObjectCode() != null && oleTxRecord.getItemChartCode() != null){
1068 Map<String,String> accLinesMap = new HashMap<>();
1069 accLinesMap.put(OLEConstants.ACCOUNT_NUMBER,oleTxRecord.getAccountNumber());
1070 accLinesMap.put(OLEConstants.OLEBatchProcess.CHART_OF_ACCOUNTS_CODE,oleTxRecord.getItemChartCode());
1071 List<Account> accountList = (List) getBusinessObjectService().findMatching(Account.class, accLinesMap);
1072
1073 List<String> reasonForFailure = orderImportHelperBo.getFailureReason();
1074 if(accountList != null && accountList.size() > 0){
1075 Account account = accountList.get(0);
1076 if (account.isClosed()){
1077 reasonForFailure.add(OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + oleTxRecord.getAccountNumber() +OLEConstants.OLEBatchProcess.CLOSED_ACC_NO);
1078 }
1079 accLinesMap.remove(OLEConstants.ACCOUNT_NUMBER);
1080 accLinesMap.put(OLEConstants.OLEBatchProcess.OBJECT_CODE,oleTxRecord.getObjectCode());
1081 List<ObjectCode> objectCodeList = (List) getBusinessObjectService().findMatching(ObjectCode.class, accLinesMap);
1082 if(objectCodeList == null || objectCodeList.size() == 0){
1083 if(reasonForFailure != null){
1084 reasonForFailure.add(OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.OLEBatchProcess.INVALID_ACNO_OBJCD_COMBINATION);
1085
1086 }
1087 }
1088 orderImportHelperBo.setFailureReason(reasonForFailure);
1089 }
1090 else{
1091 if(reasonForFailure != null){
1092 reasonForFailure.add(OLEConstants.OLEBatchProcess.REC_POSITION + (recordPosition+1) + " " + OLEConstants.OLEBatchProcess.INVALID_ACNO_OBJCD_COMBINATION);
1093
1094 orderImportHelperBo.setFailureReason(reasonForFailure);
1095 }
1096 }
1097 }
1098 }
1099
1100
1101
1102
1103
1104 private Map<String,String> setDefaultAndConstantValuesToTxnRecord(OleTxRecord oleTxRecord, Map<String,String> failureRecords, OLEBatchProcessJobDetailsBo job) {
1105 if (failureRecords == null) {
1106 failureRecords = new HashMap<String,String>();
1107 }
1108 String attributeName = null;
1109 String attributeValue = null;
1110 LOG.debug("----Inside setDefaultAndConstantValuesToTxnRecord()------------------------------");
1111 List<OLEBatchProcessProfileConstantsBo> oleBatchProcessProfileConstantsBoList = job.getOrderImportHelperBo().getOleBatchProcessProfileBo().getOleBatchProcessProfileConstantsList();
1112 for (OLEBatchProcessProfileConstantsBo oleBatchProcessProfileConstantsBo : oleBatchProcessProfileConstantsBoList) {
1113 attributeName = oleBatchProcessProfileConstantsBo.getAttributeName();
1114 attributeValue = oleBatchProcessProfileConstantsBo.getAttributeValue();
1115 if (OLEConstants.OLEBatchProcess.CONSTANT.equals(oleBatchProcessProfileConstantsBo.getDefaultValue())) {
1116
1117 if (OLEConstants.OLEBatchProcess.CHART_CODE.equals(attributeName)) {
1118 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.CHART_CODE)) {
1119 failureRecords.remove(OLEConstants.OLEBatchProcess.CHART_CODE);
1120 }
1121 oleTxRecord.setChartCode(attributeValue);
1122 } else if (OLEConstants.OLEBatchProcess.ORG_CODE.equals(attributeName)) {
1123 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.ORG_CODE)) {
1124 failureRecords.remove(OLEConstants.OLEBatchProcess.ORG_CODE);
1125 }
1126 oleTxRecord.setOrgCode(attributeValue);
1127 }
1128 else if(OLEConstants.OLEBatchProcess.RECEIVING_REQUIRED.equals(attributeName)) {
1129 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.RECEIVING_REQUIRED)) {
1130 failureRecords.remove(OLEConstants.OLEBatchProcess.RECEIVING_REQUIRED);
1131 }
1132 oleTxRecord.setReceivingRequired(Boolean.parseBoolean(attributeValue));
1133 }
1134 else if (OLEConstants.OLEBatchProcess.CONTRACT_MANAGER.equals(attributeName)) {
1135 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.CONTRACT_MANAGER)) {
1136 failureRecords.remove(OLEConstants.OLEBatchProcess.CONTRACT_MANAGER);
1137 }
1138 oleTxRecord.setContractManager(attributeValue);
1139 } else if (OLEConstants.OLEBatchProcess.ASSIGN_TO_USER.equals(attributeName)) {
1140 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.ASSIGN_TO_USER)) {
1141 failureRecords.remove(OLEConstants.OLEBatchProcess.ASSIGN_TO_USER);
1142 }
1143 oleTxRecord.setAssignToUser(attributeValue);
1144 }
1145 else if(OLEConstants.OLEBatchProcess.USE_TAX_INDICATOR.equals(attributeName)) {
1146 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.USE_TAX_INDICATOR)) {
1147 failureRecords.remove(OLEConstants.OLEBatchProcess.USE_TAX_INDICATOR);
1148 }
1149 oleTxRecord.setUseTaxIndicator(Boolean.parseBoolean(attributeValue));
1150 }
1151 else if (OLEConstants.OLEBatchProcess.ORDER_TYPE.equals(attributeName)) {
1152 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.ORDER_TYPE)) {
1153 failureRecords.remove(OLEConstants.OLEBatchProcess.ORDER_TYPE);
1154 }
1155 oleTxRecord.setOrderType(attributeValue);
1156 } else if (OLEConstants.OLEBatchProcess.FUNDING_SOURCE.equals(attributeName)) {
1157 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.FUNDING_SOURCE)) {
1158 failureRecords.remove(OLEConstants.OLEBatchProcess.FUNDING_SOURCE);
1159 }
1160 oleTxRecord.setFundingSource(attributeValue);
1161 }
1162 else if(OLEConstants.OLEBatchProcess.PREQ_POSITIVE_APPROVAL_REQ.equals(attributeName)) {
1163 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.PREQ_POSITIVE_APPROVAL_REQ)) {
1164 failureRecords.remove(OLEConstants.OLEBatchProcess.PREQ_POSITIVE_APPROVAL_REQ);
1165 }
1166 oleTxRecord.setPayReqPositiveApprovalReq(Boolean.parseBoolean(attributeValue));
1167 }
1168 else if(OLEConstants.OLEBatchProcess.PO_CONFIRMATION_INDICATOR.equals(attributeName)) {
1169 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.PO_CONFIRMATION_INDICATOR)) {
1170 failureRecords.remove(OLEConstants.OLEBatchProcess.PO_CONFIRMATION_INDICATOR);
1171 }
1172 oleTxRecord.setPurchaseOrderConfirmationIndicator(Boolean.parseBoolean(attributeValue));
1173 }
1174 else if (OLEConstants.OLEBatchProcess.DELIVERY_CAMPUS_CODE.equals(attributeName)) {
1175 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.DELIVERY_CAMPUS_CODE)) {
1176 failureRecords.remove(OLEConstants.OLEBatchProcess.DELIVERY_CAMPUS_CODE);
1177 }
1178 oleTxRecord.setDeliveryCampusCode(attributeValue);
1179 } else if (OLEConstants.OLEBatchProcess.BUILDING_CODE.equals(attributeName)) {
1180 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.BUILDING_CODE)) {
1181 failureRecords.remove(OLEConstants.OLEBatchProcess.BUILDING_CODE);
1182 }
1183 oleTxRecord.setBuildingCode(attributeValue);
1184 } else if (OLEConstants.OLEBatchProcess.VENDOR_CHOICE.equals(attributeName)) {
1185 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.VENDOR_CHOICE)) {
1186 failureRecords.remove(OLEConstants.OLEBatchProcess.VENDOR_CHOICE);
1187 }
1188 oleTxRecord.setVendorChoice(attributeValue);
1189 }
1190 else if(OLEConstants.OLEBatchProcess.ROUTE_TO_REQUESTOR.equals(attributeName)) {
1191 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.ROUTE_TO_REQUESTOR)) {
1192 failureRecords.remove(OLEConstants.OLEBatchProcess.ROUTE_TO_REQUESTOR);
1193 }
1194 oleTxRecord.setRouteToRequestor(Boolean.parseBoolean(attributeValue));
1195 }
1196 else if (OLEConstants.OLEBatchProcess.METHOD_OF_PO_TRANSMISSION.equals(attributeName)) {
1197 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.METHOD_OF_PO_TRANSMISSION)) {
1198 failureRecords.remove(OLEConstants.OLEBatchProcess.METHOD_OF_PO_TRANSMISSION);
1199 }
1200 oleTxRecord.setMethodOfPOTransmission(attributeValue);
1201 } else if (OLEConstants.OLEBatchProcess.COST_SOURCE.equals(attributeName)) {
1202 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.COST_SOURCE)) {
1203 failureRecords.remove(OLEConstants.OLEBatchProcess.COST_SOURCE);
1204 }
1205 oleTxRecord.setCostSource(attributeValue);
1206 } else if (OLEConstants.OLEBatchProcess.PERCENT.equals(attributeName)) {
1207 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.PERCENT)) {
1208 failureRecords.remove(OLEConstants.OLEBatchProcess.PERCENT);
1209 }
1210 oleTxRecord.setPercent(attributeValue);
1211 } else if (OLEConstants.OLEBatchProcess.DEFAULT_LOCATION.equals(attributeName)) {
1212 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.DEFAULT_LOCATION)) {
1213 failureRecords.remove(OLEConstants.OLEBatchProcess.DEFAULT_LOCATION);
1214 }
1215 oleTxRecord.setDefaultLocation(attributeValue);
1216 } else if (OLEConstants.OLEBatchProcess.LIST_PRICE.equals(attributeName)) {
1217 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.LIST_PRICE)) {
1218 failureRecords.remove(OLEConstants.OLEBatchProcess.LIST_PRICE);
1219 }
1220 oleTxRecord.setListPrice(attributeValue);
1221 } else if (OLEConstants.OLEBatchProcess.VENDOR_NUMBER.equals(attributeName)) {
1222 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.VENDOR_NUMBER)) {
1223 failureRecords.remove(OLEConstants.OLEBatchProcess.VENDOR_NUMBER);
1224 }
1225 oleTxRecord.setVendorNumber(attributeValue);
1226 }
1227 else if (OLEConstants.OLEBatchProcess.VENDOR_CUST_NBR.equals(attributeName)) {
1228 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.VENDOR_CUST_NBR)) {
1229 failureRecords.remove(OLEConstants.OLEBatchProcess.VENDOR_CUST_NBR);
1230 }
1231 oleTxRecord.setVendorInfoCustomer(attributeValue);
1232 }
1233 else if (OLEConstants.OLEBatchProcess.QUANTITY.equals(attributeName)) {
1234 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.QUANTITY)) {
1235 failureRecords.remove(OLEConstants.OLEBatchProcess.QUANTITY);
1236 }
1237 oleTxRecord.setQuantity(attributeValue);
1238 }
1239 else if (OLEConstants.OLEBatchProcess.ITEM_NO_OF_PARTS.equals(attributeName)) {
1240 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.ITEM_NO_OF_PARTS)) {
1241 failureRecords.remove(OLEConstants.OLEBatchProcess.ITEM_NO_OF_PARTS);
1242 }
1243 oleTxRecord.setItemNoOfParts(attributeValue);
1244 }
1245 else if (OLEConstants.OLEBatchProcess.VENDOR_REFERENCE_NUMBER.equals(attributeName)) {
1246 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.VENDOR_REFERENCE_NUMBER)) {
1247 failureRecords.remove(OLEConstants.OLEBatchProcess.VENDOR_REFERENCE_NUMBER);
1248 }
1249 oleTxRecord.setVendorItemIdentifier(attributeValue);
1250 }
1251 else if (OLEConstants.OLEBatchProcess.REQUESTOR_NAME.equals(attributeName)) {
1252 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.REQUESTOR_NAME)) {
1253 failureRecords.remove(OLEConstants.OLEBatchProcess.REQUESTOR_NAME);
1254 }
1255 oleTxRecord.setRequestorName(attributeValue);
1256 }
1257 else if (OLEConstants.OLEBatchProcess.ITEM_STATUS.equals(attributeName)) {
1258 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.ITEM_STATUS)) {
1259 failureRecords.remove(OLEConstants.OLEBatchProcess.ITEM_STATUS);
1260 }
1261 oleTxRecord.setItemStatus(attributeValue);
1262 }
1263 else if (OLEConstants.OLEBatchProcess.DISCOUNT.equals(attributeName)) {
1264 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.DISCOUNT)) {
1265 failureRecords.remove(OLEConstants.OLEBatchProcess.DISCOUNT);
1266 }
1267 oleTxRecord.setDiscount(attributeValue);
1268 }
1269 else if (OLEConstants.OLEBatchProcess.DISCOUNT_TYPE.equals(attributeName)) {
1270 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.DISCOUNT_TYPE)) {
1271 failureRecords.remove(OLEConstants.OLEBatchProcess.DISCOUNT_TYPE);
1272 }
1273 oleTxRecord.setDiscountType(attributeValue);
1274 }
1275 else if (OLEConstants.OLEBatchProcess.ACCOUNT_NUMBER.equals(attributeName)) {
1276 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.ACCOUNT_NUMBER)) {
1277 failureRecords.remove(OLEConstants.OLEBatchProcess.ACCOUNT_NUMBER);
1278 }
1279 oleTxRecord.setAccountNumber(attributeValue);
1280 }
1281 else if (OLEConstants.OLEBatchProcess.OBJECT_CODE.equals(attributeName)) {
1282 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.OBJECT_CODE)) {
1283 failureRecords.remove(OLEConstants.OLEBatchProcess.OBJECT_CODE);
1284 }
1285 oleTxRecord.setObjectCode(attributeValue);
1286 }
1287 else if (OLEConstants.OLEBatchProcess.ITEM_CHART_CODE.equals(attributeName)) {
1288 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.ITEM_CHART_CODE)) {
1289 failureRecords.remove(OLEConstants.OLEBatchProcess.ITEM_CHART_CODE);
1290 }
1291 oleTxRecord.setItemChartCode(attributeValue);
1292 }
1293 else if (OLEConstants.OLEBatchProcess.REQUEST_SRC.equals(attributeName)) {
1294 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.REQUEST_SRC)) {
1295 failureRecords.remove(OLEConstants.OLEBatchProcess.REQUEST_SRC);
1296 }
1297 oleTxRecord.setRequestSourceType(attributeValue);
1298 }
1299 else if (OLEConstants.OLEBatchProcess.CAPTION.equals(attributeName)) {
1300 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.CAPTION)) {
1301 failureRecords.remove(OLEConstants.OLEBatchProcess.CAPTION);
1302 }
1303 oleTxRecord.setCaption(attributeValue);
1304 }
1305 else if (OLEConstants.OLEBatchProcess.VOLUME_NUMBER.equals(attributeName)) {
1306 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.VOLUME_NUMBER)) {
1307 failureRecords.remove(OLEConstants.OLEBatchProcess.VOLUME_NUMBER);
1308 }
1309 oleTxRecord.setVolumeNumber(attributeValue);
1310 }
1311 else if (OLEConstants.OLEBatchProcess.DELIVERY_BUILDING_ROOM_NUMBER.equals(attributeName)) {
1312 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.DELIVERY_BUILDING_ROOM_NUMBER)) {
1313 failureRecords.remove(OLEConstants.OLEBatchProcess.DELIVERY_BUILDING_ROOM_NUMBER);
1314 }
1315 oleTxRecord.setDeliveryBuildingRoomNumber(attributeValue);
1316 }else if(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_TYP.equals(attributeName)) {
1317 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_TYP)) {
1318 failureRecords.remove(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_TYP);
1319 }
1320 oleTxRecord.setRecurringPaymentType(attributeValue);
1321 }else if(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_BEGIN_DT.equals(attributeName)) {
1322 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_BEGIN_DT)) {
1323 failureRecords.remove(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_BEGIN_DT);
1324 }
1325 oleTxRecord.setRecurringPaymentBeginDate(attributeValue);
1326 }else if(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_END_DT.equals(attributeName)) {
1327 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_END_DT)) {
1328 failureRecords.remove(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_END_DT);
1329 }
1330 oleTxRecord.setRecurringPaymentEndDate(attributeValue);
1331 }
1332
1333 } else if (OLEConstants.OLEBatchProcess.DEFAULT.equals(oleBatchProcessProfileConstantsBo.getDefaultValue())) {
1334
1335 if (OLEConstants.OLEBatchProcess.CHART_CODE.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getChartCode())) {
1336 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.CHART_CODE)) {
1337 failureRecords.remove(OLEConstants.OLEBatchProcess.CHART_CODE);
1338 }
1339 oleTxRecord.setChartCode(attributeValue);
1340 }
1341 else if (OLEConstants.OLEBatchProcess.ORG_CODE.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getOrgCode())) {
1342 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.ORG_CODE)) {
1343 failureRecords.remove(OLEConstants.OLEBatchProcess.ORG_CODE);
1344 }
1345 oleTxRecord.setOrgCode(attributeValue);
1346 }
1347 else if(OLEConstants.OLEBatchProcess.RECEIVING_REQUIRED.equals(attributeName)) {
1348 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.RECEIVING_REQUIRED)) {
1349 failureRecords.remove(OLEConstants.OLEBatchProcess.RECEIVING_REQUIRED);
1350 }
1351 oleTxRecord.setReceivingRequired(Boolean.parseBoolean(attributeValue));
1352 }
1353 else if (OLEConstants.OLEBatchProcess.CONTRACT_MANAGER.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getContractManager())) {
1354 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.CONTRACT_MANAGER)) {
1355 failureRecords.remove(OLEConstants.OLEBatchProcess.CONTRACT_MANAGER);
1356 }
1357 oleTxRecord.setContractManager(attributeValue);
1358 }
1359 else if (OLEConstants.OLEBatchProcess.ASSIGN_TO_USER.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getAssignToUser())) {
1360 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.ASSIGN_TO_USER)) {
1361 failureRecords.remove(OLEConstants.OLEBatchProcess.ASSIGN_TO_USER);
1362 }
1363 oleTxRecord.setAssignToUser(attributeValue);
1364 }
1365 else if(OLEConstants.OLEBatchProcess.USE_TAX_INDICATOR.equals(attributeName)) {
1366 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.USE_TAX_INDICATOR)) {
1367 failureRecords.remove(OLEConstants.OLEBatchProcess.USE_TAX_INDICATOR);
1368 }
1369 oleTxRecord.setUseTaxIndicator(Boolean.parseBoolean(attributeValue));
1370 }
1371 else if (OLEConstants.OLEBatchProcess.ORDER_TYPE.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getOrderType())) {
1372 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.ORDER_TYPE)) {
1373 failureRecords.remove(OLEConstants.OLEBatchProcess.ORDER_TYPE);
1374 }
1375 oleTxRecord.setOrderType(attributeValue);
1376 }
1377 else if (OLEConstants.OLEBatchProcess.FUNDING_SOURCE.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getFundingSource())) {
1378 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.FUNDING_SOURCE)) {
1379 failureRecords.remove(OLEConstants.OLEBatchProcess.FUNDING_SOURCE);
1380 }
1381 oleTxRecord.setFundingSource(attributeValue);
1382 }
1383 else if(OLEConstants.OLEBatchProcess.PREQ_POSITIVE_APPROVAL_REQ.equals(attributeName)) {
1384 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.PREQ_POSITIVE_APPROVAL_REQ)) {
1385 failureRecords.remove(OLEConstants.OLEBatchProcess.PREQ_POSITIVE_APPROVAL_REQ);
1386 }
1387 oleTxRecord.setPayReqPositiveApprovalReq(Boolean.parseBoolean(attributeValue));
1388 }
1389 else if(OLEConstants.OLEBatchProcess.PO_CONFIRMATION_INDICATOR.equals(attributeName)) {
1390 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.PO_CONFIRMATION_INDICATOR)) {
1391 failureRecords.remove(OLEConstants.OLEBatchProcess.PO_CONFIRMATION_INDICATOR);
1392 }
1393 oleTxRecord.setPurchaseOrderConfirmationIndicator(Boolean.parseBoolean(attributeValue));
1394 }
1395 else if (OLEConstants.OLEBatchProcess.DELIVERY_CAMPUS_CODE.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getDeliveryCampusCode())) {
1396 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.DELIVERY_CAMPUS_CODE)) {
1397 failureRecords.remove(OLEConstants.OLEBatchProcess.DELIVERY_CAMPUS_CODE);
1398 }
1399 oleTxRecord.setDeliveryCampusCode(attributeValue);
1400 }
1401 else if (OLEConstants.OLEBatchProcess.BUILDING_CODE.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getBuildingCode())) {
1402 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.BUILDING_CODE)) {
1403 failureRecords.remove(OLEConstants.OLEBatchProcess.BUILDING_CODE);
1404 }
1405 oleTxRecord.setBuildingCode(attributeValue);
1406 }
1407 else if (OLEConstants.OLEBatchProcess.VENDOR_CHOICE.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getVendorChoice())) {
1408 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.VENDOR_CHOICE)) {
1409 failureRecords.remove(OLEConstants.OLEBatchProcess.VENDOR_CHOICE);
1410 }
1411 oleTxRecord.setVendorChoice(attributeValue);
1412 }
1413 else if(OLEConstants.OLEBatchProcess.ROUTE_TO_REQUESTOR.equals(attributeName)) {
1414 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.ROUTE_TO_REQUESTOR)) {
1415 failureRecords.remove(OLEConstants.OLEBatchProcess.ROUTE_TO_REQUESTOR);
1416 }
1417 oleTxRecord.setRouteToRequestor(Boolean.parseBoolean(attributeValue));
1418 }
1419 else if (OLEConstants.OLEBatchProcess.METHOD_OF_PO_TRANSMISSION.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getMethodOfPOTransmission())) {
1420 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.METHOD_OF_PO_TRANSMISSION)) {
1421 failureRecords.remove(OLEConstants.OLEBatchProcess.METHOD_OF_PO_TRANSMISSION);
1422 }
1423 oleTxRecord.setMethodOfPOTransmission(attributeValue);
1424 }
1425 else if (OLEConstants.OLEBatchProcess.COST_SOURCE.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getCostSource())) {
1426 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.COST_SOURCE)) {
1427 failureRecords.remove(OLEConstants.OLEBatchProcess.COST_SOURCE);
1428 }
1429 oleTxRecord.setCostSource(attributeValue);
1430 }
1431 else if (OLEConstants.OLEBatchProcess.PERCENT.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getPercent())) {
1432 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.PERCENT)) {
1433 failureRecords.remove(OLEConstants.OLEBatchProcess.PERCENT);
1434 }
1435 oleTxRecord.setPercent(attributeValue);
1436 }
1437 else if (OLEConstants.OLEBatchProcess.DEFAULT_LOCATION.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getDefaultLocation())) {
1438 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.DEFAULT_LOCATION)) {
1439 failureRecords.remove(OLEConstants.OLEBatchProcess.DEFAULT_LOCATION);
1440 }
1441 oleTxRecord.setDefaultLocation(attributeValue);
1442 }
1443 else if (OLEConstants.OLEBatchProcess.LIST_PRICE.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getListPrice())) {
1444 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.LIST_PRICE)) {
1445 failureRecords.remove(OLEConstants.OLEBatchProcess.LIST_PRICE);
1446 }
1447 oleTxRecord.setListPrice(attributeValue);
1448 }
1449 else if (OLEConstants.OLEBatchProcess.VENDOR_NUMBER.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getVendorNumber())) {
1450 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.VENDOR_NUMBER)) {
1451 failureRecords.remove(OLEConstants.OLEBatchProcess.VENDOR_NUMBER);
1452 }
1453 oleTxRecord.setVendorNumber(attributeValue);
1454 }
1455 else if (OLEConstants.OLEBatchProcess.VENDOR_CUST_NBR.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getVendorInfoCustomer())) {
1456 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.VENDOR_CUST_NBR)) {
1457 failureRecords.remove(OLEConstants.OLEBatchProcess.VENDOR_CUST_NBR);
1458 }
1459 oleTxRecord.setVendorInfoCustomer(attributeValue);
1460 }
1461 else if (OLEConstants.OLEBatchProcess.QUANTITY.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getQuantity())) {
1462 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.QUANTITY)) {
1463 failureRecords.remove(OLEConstants.OLEBatchProcess.QUANTITY);
1464 }
1465 oleTxRecord.setQuantity(attributeValue);
1466 }
1467 else if (OLEConstants.OLEBatchProcess.ITEM_NO_OF_PARTS.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getItemNoOfParts())) {
1468 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.ITEM_NO_OF_PARTS)) {
1469 failureRecords.remove(OLEConstants.OLEBatchProcess.ITEM_NO_OF_PARTS);
1470 }
1471 oleTxRecord.setItemNoOfParts(attributeValue);
1472 }
1473 else if (OLEConstants.OLEBatchProcess.VENDOR_REFERENCE_NUMBER.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getVendorItemIdentifier())) {
1474 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.VENDOR_REFERENCE_NUMBER)) {
1475 failureRecords.remove(OLEConstants.OLEBatchProcess.VENDOR_REFERENCE_NUMBER);
1476 }
1477 oleTxRecord.setVendorItemIdentifier(attributeValue);
1478 }
1479 else if (OLEConstants.OLEBatchProcess.REQUESTOR_NAME.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getRequestorName())) {
1480 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.REQUESTOR_NAME)) {
1481 failureRecords.remove(OLEConstants.OLEBatchProcess.REQUESTOR_NAME);
1482 }
1483 oleTxRecord.setRequestorName(attributeValue);
1484 }
1485 else if (OLEConstants.OLEBatchProcess.ITEM_STATUS.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getItemStatus())) {
1486 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.ITEM_STATUS)) {
1487 failureRecords.remove(OLEConstants.OLEBatchProcess.ITEM_STATUS);
1488 }
1489 oleTxRecord.setItemStatus(attributeValue);
1490 }
1491 else if (OLEConstants.OLEBatchProcess.DISCOUNT.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getDiscount())) {
1492 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.DISCOUNT)) {
1493 failureRecords.remove(OLEConstants.OLEBatchProcess.DISCOUNT);
1494 }
1495 oleTxRecord.setDiscount(attributeValue);
1496 }
1497 else if (OLEConstants.OLEBatchProcess.DISCOUNT_TYPE.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getDiscountType())) {
1498 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.DISCOUNT_TYPE)) {
1499 failureRecords.remove(OLEConstants.OLEBatchProcess.DISCOUNT_TYPE);
1500 }
1501 oleTxRecord.setDiscountType(attributeValue);
1502 }
1503 else if (OLEConstants.OLEBatchProcess.ACCOUNT_NUMBER.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getAccountNumber())) {
1504 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.ACCOUNT_NUMBER)) {
1505 failureRecords.remove(OLEConstants.OLEBatchProcess.ACCOUNT_NUMBER);
1506 }
1507 oleTxRecord.setAccountNumber(attributeValue);
1508 }
1509 else if (OLEConstants.OLEBatchProcess.OBJECT_CODE.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getObjectCode())) {
1510 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.OBJECT_CODE)) {
1511 failureRecords.remove(OLEConstants.OLEBatchProcess.OBJECT_CODE);
1512 }
1513 oleTxRecord.setObjectCode(attributeValue);
1514 }
1515 else if (OLEConstants.OLEBatchProcess.ITEM_CHART_CODE.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getItemChartCode())) {
1516 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.ITEM_CHART_CODE)) {
1517 failureRecords.remove(OLEConstants.OLEBatchProcess.ITEM_CHART_CODE);
1518 }
1519 oleTxRecord.setItemChartCode(attributeValue);
1520 }
1521 else if (OLEConstants.OLEBatchProcess.REQUEST_SRC.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getRequestSourceType())) {
1522 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.REQUEST_SRC)) {
1523 failureRecords.remove(OLEConstants.OLEBatchProcess.REQUEST_SRC);
1524 }
1525 oleTxRecord.setRequestSourceType(attributeValue);
1526 }
1527 else if (OLEConstants.OLEBatchProcess.CAPTION.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getCaption())) {
1528 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.CAPTION)) {
1529 failureRecords.remove(OLEConstants.OLEBatchProcess.CAPTION);
1530 }
1531 oleTxRecord.setCaption(attributeValue);
1532 }
1533 else if (OLEConstants.OLEBatchProcess.VOLUME_NUMBER.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getVolumeNumber())) {
1534 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.VOLUME_NUMBER)) {
1535 failureRecords.remove(OLEConstants.OLEBatchProcess.VOLUME_NUMBER);
1536 }
1537 oleTxRecord.setVolumeNumber(attributeValue);
1538 }
1539 else if (OLEConstants.OLEBatchProcess.DELIVERY_BUILDING_ROOM_NUMBER.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getVolumeNumber())) {
1540 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.DELIVERY_BUILDING_ROOM_NUMBER)) {
1541 failureRecords.remove(OLEConstants.OLEBatchProcess.DELIVERY_BUILDING_ROOM_NUMBER);
1542 }
1543 oleTxRecord.setDeliveryBuildingRoomNumber(attributeValue);
1544 }else if(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_TYP.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getRecurringPaymentType())) {
1545 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_TYP)) {
1546 failureRecords.remove(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_TYP);
1547 }
1548 oleTxRecord.setRecurringPaymentType(attributeValue);
1549 }else if(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_BEGIN_DT.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getRecurringPaymentBeginDate())) {
1550 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_BEGIN_DT)) {
1551 failureRecords.remove(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_BEGIN_DT);
1552 }
1553 oleTxRecord.setRecurringPaymentBeginDate(attributeValue);
1554 }else if(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_END_DT.equals(attributeName) && StringUtils.isBlank(oleTxRecord.getRecurringPaymentEndDate())) {
1555 if (failureRecords.containsKey(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_END_DT)) {
1556 failureRecords.remove(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_END_DT);
1557 }
1558 oleTxRecord.setRecurringPaymentEndDate(attributeValue);
1559 }
1560
1561 }
1562 }
1563 LOG.debug("----End of setDefaultAndConstantValuesToTxnRecord()------------------------------");
1564 return failureRecords;
1565 }
1566
1567
1568
1569
1570
1571
1572 public boolean checkRequestorName(String requestorName){
1573 LOG.debug("----Inside checkRequestorName() of Order Record Import------------------------------");
1574 boolean requestorAvailable = false;
1575 String[] requestorNames = requestorName.split(", ");
1576 if(requestorNames.length == 2){
1577 String lastName = requestorNames[0];
1578 String firstName = requestorNames[1];
1579 Map<String,String> requestorNameMap = new HashMap<>();
1580 requestorNameMap.put(org.kuali.ole.sys.OLEConstants.OlePersonRequestorLookupable.FIRST_NAME,firstName);
1581 requestorNameMap.put(org.kuali.ole.sys.OLEConstants.OlePersonRequestorLookupable.LAST_NAME,lastName);
1582 List<OLERequestorPatronDocument> olePatronDocumentList = getOleSelectDocumentService().getPatronDocumentListFromWebService();
1583 if(olePatronDocumentList != null && olePatronDocumentList.size()>0){
1584 for(int recCount = 0;recCount < olePatronDocumentList.size();recCount++) {
1585 if(olePatronDocumentList.get(recCount).getFirstName().equalsIgnoreCase(firstName) && olePatronDocumentList.get(recCount).getLastName().equalsIgnoreCase(lastName)){
1586 requestorAvailable = true;
1587 break;
1588 }
1589 }
1590 }
1591 }
1592 return requestorAvailable;
1593
1594 }
1595
1596 public boolean validateItemStatus(String itemStatus) {
1597 List<KeyValue> itemStatusList = getKeyValues();
1598 boolean validItemStatus = false;
1599 for(int itemStatusCount = 0; itemStatusCount < itemStatusList.size(); itemStatusCount++){
1600 if(itemStatusList.get(itemStatusCount).getKey().equalsIgnoreCase(itemStatus)) {
1601 validItemStatus = true;
1602 break;
1603 }
1604 }
1605 return validItemStatus;
1606 }
1607
1608 public List<KeyValue> getKeyValues() {
1609
1610 List<KeyValue> options = new ArrayList<KeyValue>();
1611 Collection<OleItemAvailableStatus> oleItemAvailableStatuses = KRADServiceLocator.getBusinessObjectService().findAll(OleItemAvailableStatus.class);
1612 String excludeItemStatus = getParameter(OLEConstants.EXCLUDE_ITEM_STATUS);
1613 Map<String,String> map = new HashMap<>();
1614 if(excludeItemStatus!=null && !excludeItemStatus.isEmpty()){
1615 String[] itemStatusList = excludeItemStatus.split(",");
1616 for(String itemStatus : itemStatusList){
1617 map.put(itemStatus,itemStatus);
1618 }
1619 }
1620 for (OleItemAvailableStatus type : oleItemAvailableStatuses) {
1621 if (type.isActive() && !map.containsKey(type.getItemAvailableStatusCode())) {
1622 options.add(new ConcreteKeyValue(type.getItemAvailableStatusCode(), type.getItemAvailableStatusName()));
1623 }
1624 }
1625 return options;
1626 }
1627
1628 public String getParameter(String name){
1629 ParameterKey parameterKey = ParameterKey.create(OLEConstants.APPL_ID, OLEConstants.SELECT_NMSPC, OLEConstants.SELECT_CMPNT,name);
1630 Parameter parameter = CoreServiceApiServiceLocator.getParameterRepositoryService().getParameter(parameterKey);
1631 return parameter!=null?parameter.getValue():null;
1632 }
1633
1634 public boolean validateForNumber(String fieldValue){
1635 try {
1636 Integer quantity = Integer.parseInt(fieldValue);
1637 if(quantity <= 0){
1638 return false;
1639 }
1640 }
1641 catch(NumberFormatException nfe){
1642 return false;
1643 }
1644 return true;
1645 }
1646
1647 public boolean validateDestinationFieldValues(String destinationFieldValue){
1648 try {
1649 Float fieldValue = Float.parseFloat(destinationFieldValue);
1650 if(fieldValue < 0){
1651 return false;
1652 }
1653 }
1654 catch(NumberFormatException nfe){
1655 return false;
1656 }
1657 return true;
1658 }
1659
1660 public boolean validateForPercentage(String percentage){
1661 try {
1662 Float fieldValue = Float.parseFloat(percentage);
1663 if(fieldValue != 100){
1664 return false;
1665 }
1666 }
1667 catch(NumberFormatException nfe){
1668 return false;
1669 }
1670 return true;
1671 }
1672
1673 public boolean validateDefaultLocation(String defaultLocation){
1674 List<String> locationList = getItemLocation();
1675 Boolean isLocationAvailable = false;
1676 for(int locationCount = 0;locationCount < locationList.size();locationCount++) {
1677 if(locationList.get(locationCount).equalsIgnoreCase(defaultLocation)){
1678 isLocationAvailable = true;
1679 break;
1680 }
1681 }
1682 return isLocationAvailable;
1683 }
1684
1685 public boolean validateVendorNumber(String vendorNumber){
1686 LOG.debug("----Inside validateVendorNumber()------------------------------");
1687 boolean isValidVendor = false;
1688 String[] vendorDetail = vendorNumber.split("-");
1689 if(vendorDetail.length == 2){
1690 String vendorHeaderGeneratedIdentifier = vendorDetail[0];
1691 String vendorDetailAssignedIdentifier = vendorDetail[1];
1692 try {
1693 Map<String,Integer> vendorMap = new HashMap<>();
1694 vendorMap.put(OLEConstants.VENDOR_HEADER_GENERATED_ID, Integer.parseInt(vendorHeaderGeneratedIdentifier));
1695 vendorMap.put(OLEConstants.VENDOR_DETAILED_ASSIGNED_ID, Integer.parseInt(vendorDetailAssignedIdentifier));
1696 List<VendorDetail> vendorDetailList = (List) getBusinessObjectService().findMatching(VendorDetail.class, vendorMap);
1697 if(vendorDetail != null && vendorDetailList.size() > 0){
1698 return true;
1699 }
1700 }
1701 catch (NumberFormatException nfe) {
1702 return false;
1703 }
1704 }
1705 else {
1706 return false;
1707 }
1708 return isValidVendor;
1709 }
1710
1711 public List<String> getItemLocation() {
1712 LOG.debug(" Inside get Item Location Method of Order Record Import");
1713 List<String> locationList = new ArrayList<String>();
1714 List<KeyValue> options = new ArrayList<KeyValue>();
1715 Map parentCriteria1 = new HashMap();
1716 parentCriteria1.put(OLEConstants.OLEBatchProcess.LEVEL_CODE, OLEConstants.LOC_LEVEL_SHELVING);
1717 List<OleLocationLevel> oleLocationLevel = (List<OleLocationLevel>) getBusinessObjectService().findMatching(OleLocationLevel.class, parentCriteria1);
1718 String shelvingId = oleLocationLevel.get(0).getLevelId();
1719 Map parentCriteria = new HashMap();
1720 parentCriteria.put(OLEConstants.LEVEL_ID, shelvingId);
1721 Collection<OleLocation> oleLocationCollection = getBusinessObjectService().findMatching(OleLocation.class, parentCriteria);
1722 for (OleLocation oleLocation : oleLocationCollection) {
1723 String locationName = oleLocation.getLocationName();
1724 String levelCode = oleLocation.getLocationCode();
1725 boolean parentId = oleLocation.getParentLocationId() != null ? true : false;
1726 while (parentId) {
1727 Map criteriaMap = new HashMap();
1728 criteriaMap.put(OLEConstants.LOCATION_ID, oleLocation.getParentLocationId());
1729 OleLocation location = getBusinessObjectService().findByPrimaryKey(OleLocation.class,
1730 criteriaMap);
1731 if (locationName != null) {
1732 locationName = location.getLocationName() + OLEConstants.SLASH + locationName;
1733 }
1734 if (levelCode != null) {
1735 levelCode = location.getLocationCode() + OLEConstants.SLASH + levelCode;
1736 }
1737 parentId = location.getParentLocationId() != null ? true : false;
1738 oleLocation = location;
1739 }
1740 options.add(new ConcreteKeyValue(levelCode, levelCode));
1741 }
1742 Map<String, String> map = new HashMap<String, String>();
1743 for (KeyValue option : options) {
1744 map.put(option.getKey(), option.getValue());
1745 }
1746 Map<String, Object> map1 = sortByLocation(map);
1747 for (Map.Entry<String, Object> entry : map1.entrySet()) {
1748 locationList.add((String) entry.getValue());
1749 }
1750 return locationList;
1751 }
1752
1753 private Map<String, Object> sortByLocation(Map<String, String> parentCriteria) {
1754 Map<String, Object> map = new LinkedHashMap<String, Object>();
1755 List<String> keyList = new ArrayList<String>(parentCriteria.keySet());
1756 List<String> valueList = new ArrayList<String>(parentCriteria.values());
1757 Set<String> sortedSet = new TreeSet<String>(valueList);
1758 Object[] sortedArray = sortedSet.toArray();
1759 int size = sortedArray.length;
1760 for (int i = 0; i < size; i++) {
1761 map.put(keyList.get(valueList.indexOf(sortedArray[i])), sortedArray[i]);
1762 }
1763 return map;
1764 }
1765
1766 public List<OleTxRecord> getQuantityItemPartsLocation(List<BibMarcRecord> bibMarcRecords, OLEBatchProcessJobDetailsBo job) {
1767 OrderImportHelperBo orderImportHelperBo = job.getOrderImportHelperBo();
1768 List<BibMarcRecord> bibMarcRecordList = new ArrayList<>();
1769 List<OleTxRecord> oleTxRecordList = new ArrayList<>();
1770 for (BibMarcRecord bibMarcRecord : bibMarcRecords) {
1771 Map<String, String> mappingFailures = new HashMap<String, String>();
1772 OleTxRecord oleTxRecord = new OleTxRecord();
1773 List<OLEBatchProcessProfileMappingOptionsBo> oleBatchProcessProfileMappingOptionsBoList = job.getOrderImportHelperBo().getOleBatchProcessProfileBo().getOleBatchProcessProfileMappingOptionsList();
1774 for (OLEBatchProcessProfileMappingOptionsBo oleBatchProcessProfileMappingOptionsBo : oleBatchProcessProfileMappingOptionsBoList) {
1775 List<OLEBatchProcessProfileDataMappingOptionsBo> oleBatchProcessProfileDataMappingOptionsBoList = oleBatchProcessProfileMappingOptionsBo.getOleBatchProcessProfileDataMappingOptionsBoList();
1776 for (int dataMapCount = 0; dataMapCount < oleBatchProcessProfileDataMappingOptionsBoList.size(); dataMapCount++) {
1777 String sourceField = oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getSourceField();
1778 String sourceFields[] = sourceField.split("\\$");
1779 if (sourceFields.length == 2) {
1780 String dataField = sourceFields[0].trim();
1781 String tagField = sourceFields[1].trim();
1782 if (OLEConstants.OLEBatchProcess.QUANTITY.equals(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField())) {
1783 String quantity = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList, dataMapCount, bibMarcRecord, dataField, tagField);
1784 if (!StringUtils.isBlank(quantity)) {
1785 boolean validQuantity = validateForNumber(quantity);
1786 if (!validQuantity) {
1787 mappingFailures.put(OLEConstants.OLEBatchProcess.QUANTITY, OLEConstants.INVALID_QTY + " " + dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField + " " + quantity);
1788 quantity = null;
1789 }
1790 oleTxRecord.setQuantity(quantity);
1791 } else {
1792 mappingFailures.put(OLEConstants.OLEBatchProcess.QUANTITY, OLEConstants.REQUIRED_QTY + " " + dataField + OLEConstants.DELIMITER_DOLLAR + tagField + " " + OLEConstants.NULL_VALUE_MESSAGE);
1793 }
1794 } else if (OLEConstants.OLEBatchProcess.ITEM_NO_OF_PARTS.equals(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField())) {
1795 String itemNoOfParts = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList, dataMapCount, bibMarcRecord, dataField, tagField);
1796 if (!StringUtils.isBlank(itemNoOfParts)) {
1797 boolean validNoOfParts = validateForNumber(itemNoOfParts);
1798 if (!validNoOfParts) {
1799 mappingFailures.put(OLEConstants.OLEBatchProcess.ITEM_NO_OF_PARTS, OLEConstants.INVALID_NO_OF_PARTS + " " + dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField + " " + itemNoOfParts);
1800 itemNoOfParts = null;
1801 }
1802 oleTxRecord.setItemNoOfParts(itemNoOfParts);
1803 } else {
1804 mappingFailures.put(OLEConstants.OLEBatchProcess.ITEM_NO_OF_PARTS, OLEConstants.REQUIRED_NO_OF_PARTS + " " + dataField + OLEConstants.DELIMITER_DOLLAR + tagField + " " + OLEConstants.NULL_VALUE_MESSAGE);
1805 }
1806 } else if (OLEConstants.OLEBatchProcess.DEFAULT_LOCATION.equals(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField())) {
1807 String defaultLocation = setDataMappingValues(oleBatchProcessProfileDataMappingOptionsBoList, dataMapCount, bibMarcRecord, dataField, tagField);
1808 if (!StringUtils.isBlank(defaultLocation)) {
1809 boolean validDefaultLocation = validateDefaultLocation(defaultLocation);
1810 if (!validDefaultLocation) {
1811 mappingFailures.put(OLEConstants.OLEBatchProcess.DEFAULT_LOCATION, OLEConstants.INVALID_LOCN_NM + " " + dataField + " " + OLEConstants.DELIMITER_DOLLAR + tagField + " " + defaultLocation);
1812 defaultLocation = null;
1813 }
1814 oleTxRecord.setDefaultLocation(defaultLocation);
1815 } else {
1816 mappingFailures.put(OLEConstants.OLEBatchProcess.DEFAULT_LOCATION, OLEConstants.REQUIRED_LOCATION_NM + " " + dataField + OLEConstants.DELIMITER_DOLLAR + tagField + " " + OLEConstants.NULL_VALUE_MESSAGE);
1817 }
1818 }
1819 }
1820 }
1821 }
1822
1823 List<OLEBatchProcessProfileConstantsBo> oleBatchProcessProfileConstantsBoList = job.getOrderImportHelperBo().getOleBatchProcessProfileBo().getOleBatchProcessProfileConstantsList();
1824 for (OLEBatchProcessProfileConstantsBo oleBatchProcessProfileConstantsBo : oleBatchProcessProfileConstantsBoList) {
1825 if (OLEConstants.OLEBatchProcess.CONSTANT.equals(oleBatchProcessProfileConstantsBo.getDefaultValue())) {
1826 if (OLEConstants.OLEBatchProcess.QUANTITY.equals(oleBatchProcessProfileConstantsBo.getAttributeName())) {
1827 if (mappingFailures.containsKey(OLEConstants.OLEBatchProcess.QUANTITY)) {
1828 mappingFailures.remove(OLEConstants.OLEBatchProcess.QUANTITY);
1829 }
1830 oleTxRecord.setQuantity(oleBatchProcessProfileConstantsBo.getAttributeValue());
1831 } else if (OLEConstants.OLEBatchProcess.ITEM_NO_OF_PARTS.equals(oleBatchProcessProfileConstantsBo.getAttributeName())) {
1832 if (mappingFailures.containsKey(OLEConstants.OLEBatchProcess.ITEM_NO_OF_PARTS)) {
1833 mappingFailures.remove(OLEConstants.OLEBatchProcess.ITEM_NO_OF_PARTS);
1834 }
1835 oleTxRecord.setItemNoOfParts(oleBatchProcessProfileConstantsBo.getAttributeValue());
1836 } else if (OLEConstants.OLEBatchProcess.DEFAULT_LOCATION.equals(oleBatchProcessProfileConstantsBo.getAttributeName())) {
1837 if (mappingFailures.containsKey(OLEConstants.OLEBatchProcess.DEFAULT_LOCATION)) {
1838 mappingFailures.remove(OLEConstants.OLEBatchProcess.DEFAULT_LOCATION);
1839 }
1840 oleTxRecord.setDefaultLocation(oleBatchProcessProfileConstantsBo.getAttributeValue());
1841 }
1842 } else if (OLEConstants.OLEBatchProcess.DEFAULT.equals(oleBatchProcessProfileConstantsBo.getDefaultValue())) {
1843 if (OLEConstants.OLEBatchProcess.QUANTITY.equals(oleBatchProcessProfileConstantsBo.getAttributeName()) && StringUtils.isBlank(oleTxRecord.getQuantity()) && !mappingFailures.containsKey(OLEConstants.OLEBatchProcess.QUANTITY)) {
1844 oleTxRecord.setQuantity(oleBatchProcessProfileConstantsBo.getAttributeValue());
1845 } else if (OLEConstants.OLEBatchProcess.ITEM_NO_OF_PARTS.equals(oleBatchProcessProfileConstantsBo.getAttributeName()) && StringUtils.isBlank(oleTxRecord.getItemNoOfParts()) && !mappingFailures.containsKey(OLEConstants.OLEBatchProcess.ITEM_NO_OF_PARTS)) {
1846 oleTxRecord.setItemNoOfParts(oleBatchProcessProfileConstantsBo.getAttributeValue());
1847 } else if (OLEConstants.OLEBatchProcess.DEFAULT_LOCATION.equals(oleBatchProcessProfileConstantsBo.getAttributeName()) && StringUtils.isBlank(oleTxRecord.getDefaultLocation()) && !mappingFailures.containsKey(OLEConstants.OLEBatchProcess.DEFAULT_LOCATION)) {
1848 oleTxRecord.setDefaultLocation(oleBatchProcessProfileConstantsBo.getAttributeValue());
1849 }
1850 }
1851 }
1852 if (mappingFailures.size() == 0) {
1853 oleTxRecordList.add(oleTxRecord);
1854
1855 } else {
1856 bibMarcRecordList.add(bibMarcRecord);
1857 Collection failureList = mappingFailures.values();
1858 if (failureList != null && failureList.size() > 0) {
1859
1860 List reasonForFailure = orderImportHelperBo.getFailureReason();
1861 if (reasonForFailure == null) {
1862 reasonForFailure = new ArrayList();
1863 }
1864 reasonForFailure.addAll(failureList);
1865
1866 orderImportHelperBo.setFailureReason(reasonForFailure);
1867 failureList.clear();
1868 }
1869 }
1870 }
1871 bibMarcRecords.removeAll(bibMarcRecordList);
1872 return oleTxRecordList;
1873 }
1874
1875 }