View Javadoc
1   package org.kuali.ole.service.impl;
2   
3   import org.kuali.ole.pojo.edi.*;
4   import org.kuali.ole.service.OverlayFileReaderService;
5   
6   import java.util.HashMap;
7   import java.util.Map;
8   
9   /**
10   * Created with IntelliJ IDEA.
11   * User: vivekb
12   * Date: 2/22/13
13   * Time: 4:14 PM
14   * To change this template use File | Settings | File Templates.
15   */
16  public class OverlayEdiFileReaderServiceImpl implements OverlayFileReaderService {
17  
18      private Object object;
19  
20      @Override
21      public void setObject(Object object) {
22          this.object = object;
23      }
24  
25      public String getInputFieldValue(String incomingField){
26          Map<String, String> referenceNumberMap = new HashMap<String, String>();
27          if(object!=null && object instanceof LineItemOrder){
28              LineItemOrder lineItemOrder = (LineItemOrder) object;
29              for(BuyerReferenceInformation buyerReferenceInformation : lineItemOrder.getBuyerReferenceInformation()){
30                  for(BuyerLineItemReference buyerLineItemReference : buyerReferenceInformation.getBuyerLineItemReference()){
31                      referenceNumberMap.put(buyerLineItemReference.getBuyersOrderLine(),buyerLineItemReference.getOrderLineNumber());
32                      break;
33                  }
34              }
35  
36              for(SupplierReferenceInformation supplierReferenceInformation : lineItemOrder.getSupplierReferenceInformation()){
37                  for(SupplierLineItemReference supplierLineItemReference : supplierReferenceInformation.getSupplierLineItemReference()){
38                      referenceNumberMap.put(supplierLineItemReference.getSuppliersOrderLine(),supplierLineItemReference.getVendorReferenceNumber());
39                      break;
40                  }
41              }
42          }
43          return referenceNumberMap.get(incomingField)!=null?referenceNumberMap.get(incomingField):"";
44      }
45  }