View Javadoc
1   package org.kuali.ole.service.impl;
2   
3   import org.kuali.ole.OLEConstants;
4   import org.kuali.ole.OLEKeyConstants;
5   import org.kuali.ole.docstore.common.client.DocstoreClientLocator;
6   import org.kuali.ole.docstore.common.document.ItemOleml;
7   import org.kuali.ole.docstore.common.document.content.instance.Item;
8   import org.kuali.ole.docstore.common.document.content.instance.ItemType;
9   import org.kuali.ole.docstore.common.document.content.instance.xstream.ItemOlemlRecordProcessor;
10  import org.kuali.ole.docstore.model.enums.DocCategory;
11  import org.kuali.ole.select.bo.OLESerialReceivingDocument;
12  import org.kuali.ole.select.bo.OLESerialReceivingHistory;
13  import org.kuali.ole.select.bo.OLESerialReceivingType;
14  import org.kuali.ole.select.bo.OLESerialRelatedPODocument;
15  import org.kuali.ole.select.businessobject.OleCopy;
16  import org.kuali.ole.select.document.OlePurchaseOrderDocument;
17  import org.kuali.ole.sys.context.SpringContext;
18  import org.kuali.ole.vnd.businessobject.VendorAlias;
19  import org.kuali.ole.vnd.businessobject.VendorDetail;
20  import org.kuali.rice.coreservice.api.CoreServiceApiServiceLocator;
21  import org.kuali.rice.coreservice.api.parameter.Parameter;
22  import org.kuali.rice.coreservice.api.parameter.ParameterKey;
23  import org.kuali.rice.krad.service.BusinessObjectService;
24  import org.kuali.rice.krad.service.KRADServiceLocator;
25  import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
26  import org.kuali.rice.krad.service.LookupService;
27  import org.kuali.rice.krad.util.GlobalVariables;
28  
29  import java.sql.Timestamp;
30  import java.util.*;
31  import java.util.concurrent.ConcurrentHashMap;
32  
33  import org.apache.commons.lang.StringUtils;
34  
35  /**
36   * Created with IntelliJ IDEA.
37   * User: rajeshbabuk
38   * Date: 7/9/13
39   * Time: 7:21 PM
40   * To change this template use File | Settings | File Templates.
41   */
42  public class OLESerialReceivingServiceImpl implements OLESerialReceivingService {
43  
44  
45  
46      private DocstoreClientLocator docstoreClientLocator;
47  
48      public DocstoreClientLocator getDocstoreClientLocator() {
49  
50          if (docstoreClientLocator == null) {
51              docstoreClientLocator = SpringContext.getBean(DocstoreClientLocator.class);
52  
53          }
54          return docstoreClientLocator;
55      }
56  
57      private ItemOlemlRecordProcessor itemOlemlRecordProcessor;
58  
59      BusinessObjectService   businessObject = SpringContext.getBean(BusinessObjectService.class);
60      private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OLESerialReceivingServiceImpl.class);
61  
62  
63  
64      private ItemOlemlRecordProcessor getItemOlemlRecordProcessor() {
65          if (itemOlemlRecordProcessor == null) {
66              itemOlemlRecordProcessor = new ItemOlemlRecordProcessor();
67          }
68          return itemOlemlRecordProcessor;
69      }
70  
71  
72      public void receiveRecord(OLESerialReceivingDocument oleSerialReceivingDocument,String receiptStatus){
73          List<OLESerialReceivingHistory> oleSerialReceivingHistoryList = oleSerialReceivingDocument.getOleSerialReceivingHistoryList();
74          OLESerialReceivingHistory oleSerialReceivingHistory = new OLESerialReceivingHistory();
75          oleSerialReceivingHistory.setReceivingRecordType(oleSerialReceivingDocument.getReceivingRecordType());
76          oleSerialReceivingHistory.setReceiptStatus(receiptStatus);
77          oleSerialReceivingHistory.setPublicDisplay(oleSerialReceivingDocument.isPublicDisplay());
78          oleSerialReceivingHistory.setOperatorId(oleSerialReceivingDocument.getOperatorId());
79          if(oleSerialReceivingDocument.isPublicDisplay()){
80              oleSerialReceivingHistory.setPublicDisplayHistory(OLEConstants.DISPLAY_YES);
81          }else{
82              oleSerialReceivingHistory.setPublicDisplayHistory(OLEConstants.DISPLAY_NO);
83          }
84          oleSerialReceivingHistory.setSerialReceivingRecordId(oleSerialReceivingDocument.getSerialReceivingRecordId());
85          oleSerialReceivingHistory.setDocumentNumber(oleSerialReceivingDocument.getDocumentNumber());
86          Date date = new Date(System.currentTimeMillis());
87          if(receiptStatus.equalsIgnoreCase(OLEConstants.RECEIVED)){
88              oleSerialReceivingHistory.setReceiptDate(new Timestamp(date.getTime()));
89          }else  if(receiptStatus.equalsIgnoreCase(OLEConstants.CLAIMED)){
90              oleSerialReceivingHistory.setClaimDate(new Timestamp(date.getTime()));
91              oleSerialReceivingHistory.setClaimNote(oleSerialReceivingDocument.getClaimIntervalInformation());
92              oleSerialReceivingHistory.setClaimType(oleSerialReceivingDocument.getClaimType());
93              if(oleSerialReceivingHistory.getClaimCount()!=null && !oleSerialReceivingHistory.getClaimCount().isEmpty()){
94                  Integer count = Integer.parseInt(oleSerialReceivingHistory.getClaimCount());
95                  count++;
96                  oleSerialReceivingHistory.setClaimCount(count.toString());
97              }else {
98                  oleSerialReceivingHistory.setClaimCount("1");
99              }
100         }
101         if(oleSerialReceivingDocument.isSpecialIssueFlag()){
102             oleSerialReceivingHistory.setEnumerationCaptionLevel1(oleSerialReceivingDocument.getEnumerationCaptionLevel1());
103         }else{
104             updateEnumCaptionValues(oleSerialReceivingDocument,oleSerialReceivingHistory);
105         }
106         if(oleSerialReceivingHistoryList != null){
107             oleSerialReceivingHistoryList.add(oleSerialReceivingHistory);
108         }else{
109             oleSerialReceivingHistoryList = new ArrayList<OLESerialReceivingHistory>();
110             oleSerialReceivingHistoryList.add(oleSerialReceivingHistory);
111         }
112         setEnumerationAndChronologyValues(oleSerialReceivingHistory);
113         if (oleSerialReceivingDocument.isCreateItem()) {
114             Item item = setItemDetails(oleSerialReceivingHistory.getEnumerationCaption(),oleSerialReceivingHistory.getChronologyCaption());
115             String oleItemXMLString = getItemOlemlRecordProcessor().toXML(item);
116             org.kuali.ole.docstore.common.document.Item itemc = new ItemOleml();
117 
118             itemc.setContent(oleItemXMLString);
119             itemc.setCategory(DocCategory.WORK.getCode());
120             itemc.setFormat(OLEConstants.OLEML_FORMAT);
121             itemc.setType(OLEConstants.ITEM_DOC_TYPE);
122             try{
123                 itemc.setHolding(getDocstoreClientLocator().getDocstoreClient().retrieveHoldings(oleSerialReceivingDocument.getInstanceId()));
124                 getDocstoreClientLocator().getDocstoreClient().createItem(itemc);//holdingsId)
125 
126             }catch (Exception ex){
127                 ex.printStackTrace();
128             }
129 
130             oleSerialReceivingDocument.setItemUUID(itemc.getId());
131         }
132         oleSerialReceivingDocument.setOleSerialReceivingHistoryList(oleSerialReceivingHistoryList);
133 
134     }
135     public List<OLESerialReceivingHistory> sortById(List<OLESerialReceivingHistory> oleSerialReceivingHistoryList){
136         if(oleSerialReceivingHistoryList!=null && oleSerialReceivingHistoryList.size()>0){
137             Collections.sort(oleSerialReceivingHistoryList, new Comparator<OLESerialReceivingHistory>() {
138                 public int compare(OLESerialReceivingHistory obj1, OLESerialReceivingHistory obj2) {
139                     if(obj1.getSerialReceivingRecordHistoryId()!=null && !obj1.getSerialReceivingRecordHistoryId().isEmpty()
140                             && obj2.getSerialReceivingRecordHistoryId()!=null && !obj2.getSerialReceivingRecordHistoryId().isEmpty()){
141                         return Integer.parseInt(obj1.getSerialReceivingRecordHistoryId()) > Integer.parseInt(obj2.getSerialReceivingRecordHistoryId()) ? 1 : -1;
142                     }
143                     return 0;
144                 }
145 
146             });
147             Collections.reverse(oleSerialReceivingHistoryList);
148         } else {
149             return null;
150         }
151         return oleSerialReceivingHistoryList;
152     }
153     public List<OLESerialReceivingHistory> reSortById(List<OLESerialReceivingHistory> oleSerialReceivingHistoryList){
154         if(oleSerialReceivingHistoryList!=null && oleSerialReceivingHistoryList.size()>0){
155             Collections.sort(oleSerialReceivingHistoryList, new Comparator<OLESerialReceivingHistory>() {
156                 public int compare(OLESerialReceivingHistory obj1, OLESerialReceivingHistory obj2) {
157                     if(obj1.getSerialReceivingRecordHistoryId()!=null && !obj1.getSerialReceivingRecordHistoryId().isEmpty()
158                             && obj2.getSerialReceivingRecordHistoryId()!=null && !obj2.getSerialReceivingRecordHistoryId().isEmpty()){
159                         return Integer.parseInt(obj1.getSerialReceivingRecordHistoryId()) < Integer.parseInt(obj2.getSerialReceivingRecordHistoryId()) ? 1 : -1;
160                     }
161                     return 0;
162                 }
163 
164             });
165             Collections.reverse(oleSerialReceivingHistoryList);
166         } else {
167             return null;
168         }
169         return oleSerialReceivingHistoryList;
170     }
171 
172 
173     /**
174      * This method will set values to Item Object and returns it to update or create Item at Docstore.
175      *
176      * @param enumeration
177      * @param chronology
178      * @return Item
179      */
180     private Item setItemDetails(String enumeration, String chronology){
181         Item item = new Item();
182         ItemType docstoreItemType = new ItemType();
183         docstoreItemType.setCodeValue("");
184         docstoreItemType.setFullValue("");
185         item.setItemType(docstoreItemType);
186         item.setEnumeration(enumeration);
187         item.setChronology(chronology);
188         return item;
189     }
190 
191     public void validateVendorDetailsForSave(OLESerialReceivingDocument oleSerialReceivingDocument) {
192         Map vendorAliasMap = new HashMap();
193         vendorAliasMap.put(org.kuali.ole.sys.OLEConstants.VENDOR_ALIAS_NAME, oleSerialReceivingDocument.getVendorAliasName());
194         List<VendorAlias> vendorAliasList = (List<VendorAlias>)getLookupService().findCollectionBySearchHelper(VendorAlias.class, vendorAliasMap, true);
195         if(vendorAliasList != null && vendorAliasList.size() >0) {
196             Map vendorNameMap = new HashMap();
197             vendorNameMap.put(org.kuali.ole.sys.OLEConstants.VENDOR_HEADER_IDENTIFIER,vendorAliasList.get(0).getVendorHeaderGeneratedIdentifier());
198             vendorNameMap.put(org.kuali.ole.sys.OLEConstants.VENDOR_DETAIL_IDENTIFIER,vendorAliasList.get(0).getVendorDetailAssignedIdentifier());
199             List<VendorDetail> vendorDetailList = (List) businessObject.findMatching(VendorDetail.class, vendorNameMap);
200             if(vendorDetailList != null && vendorDetailList.size() >0){
201                 if((vendorAliasList.get(0).getVendorHeaderGeneratedIdentifier().toString() + "-" + vendorAliasList.get(0).getVendorDetailAssignedIdentifier().toString()).equalsIgnoreCase(oleSerialReceivingDocument.getVendorId())) {
202                     LOG.debug("Allowed to save the Vendor Details");
203                 }
204                 else {
205                     GlobalVariables.getMessageMap().putError(OLEKeyConstants.SERIAL_RECEIVE_VENDOR_ALIAS_NOT_SAME,OLEKeyConstants.SERIAL_RECEIVE_VENDOR_ALIAS_NOT_SAME);
206                 }
207             }
208         }
209         else {
210             GlobalVariables.getMessageMap().putError(OLEKeyConstants.SERIAL_RECEIVE_VENDOR_ALIAS_NOT_FOUND,OLEKeyConstants.SERIAL_RECEIVE_VENDOR_ALIAS_NOT_FOUND);
211         }
212     }
213 
214     public void validateVendorDetailsForSelect(OLESerialReceivingDocument oleSerialReceivingDocument) {
215         Map vendorAliasMap = new HashMap();
216         vendorAliasMap.put(org.kuali.ole.sys.OLEConstants.VENDOR_ALIAS_NAME, oleSerialReceivingDocument.getVendorAliasName());
217         List<VendorAlias> vendorAliasList = (List<VendorAlias>)getLookupService().findCollectionBySearchHelper(VendorAlias.class, vendorAliasMap, true);
218         if(vendorAliasList != null && vendorAliasList.size() >0) {
219             Integer vendorHeaderGeneratedIdentifier = vendorAliasList.get(0).getVendorHeaderGeneratedIdentifier();
220             Integer vendorDetailAssignedIdentifier = vendorAliasList.get(0).getVendorDetailAssignedIdentifier();
221             Map vendorNameMap = new HashMap();
222             vendorNameMap.put(org.kuali.ole.sys.OLEConstants.VENDOR_HEADER_IDENTIFIER,vendorHeaderGeneratedIdentifier);
223             vendorNameMap.put(org.kuali.ole.sys.OLEConstants.VENDOR_DETAIL_IDENTIFIER,vendorDetailAssignedIdentifier);
224             List<VendorDetail> vendorDetailList = (List) businessObject.findMatching(VendorDetail.class, vendorNameMap);
225             if(vendorDetailList != null && vendorDetailList.size() >0) {
226                 oleSerialReceivingDocument.setVendorName(vendorDetailList.get(0).getVendorName());
227                 oleSerialReceivingDocument.setVendorId(vendorDetailList.get(0).getVendorHeaderGeneratedIdentifier().toString()
228                         + "-" + vendorDetailList.get(0).getVendorDetailAssignedIdentifier().toString());
229             }
230         }
231         else {
232             oleSerialReceivingDocument.setVendorId(null);
233             GlobalVariables.getMessageMap().putError(OLEKeyConstants.SERIAL_RECEIVE_VENDOR_ALIAS_NOT_FOUND,OLEKeyConstants.SERIAL_RECEIVE_VENDOR_ALIAS_NOT_FOUND);
234         }
235     }
236 
237     public void populateVendorNameFromVendorId(String vendorId,OLESerialReceivingDocument oleSerialReceivingDocument) {
238         String[] vendorDetails = vendorId.split("-");
239         if(vendorDetails.length>1){
240             String vendorHeaderGeneratedIdentifier = vendorDetails[0];
241             String vendorDetailAssignedIdentifier = vendorDetails[1];
242             Map vendorNameMap = new HashMap();
243             vendorNameMap.put(org.kuali.ole.sys.OLEConstants.VENDOR_HEADER_IDENTIFIER,vendorHeaderGeneratedIdentifier);
244             vendorNameMap.put(org.kuali.ole.sys.OLEConstants.VENDOR_DETAIL_IDENTIFIER,vendorDetailAssignedIdentifier);
245             List<VendorDetail> vendorDetailList = (List) businessObject.findMatching(VendorDetail.class, vendorNameMap);
246             List<VendorAlias> vendorAliasList = (List) businessObject.findMatching(VendorAlias.class, vendorNameMap);
247             if(vendorDetailList != null && vendorDetailList.size() >0) {
248                 oleSerialReceivingDocument.setVendorName(vendorDetailList.get(0).getVendorName());
249                 if(oleSerialReceivingDocument.getActionInterval()==null || oleSerialReceivingDocument.getActionInterval().isEmpty()){
250                     oleSerialReceivingDocument.setActionInterval(vendorDetailList.get(0).getClaimInterval());
251                 }
252             }
253             if(vendorAliasList != null && vendorAliasList.size() >0) {
254                 oleSerialReceivingDocument.setVendorAliasName(vendorAliasList.get(0).getVendorAliasName());
255             }
256         }
257     }
258 
259     public void populateVendorAliasNameFromVendorName(OLESerialReceivingDocument oleSerialReceivingDocument) {
260         String vendorId = oleSerialReceivingDocument.getVendorId();
261         if(vendorId != null && !vendorId.isEmpty()) {
262             String[] vendorIds = vendorId.split("-");
263             String vendorHeaderGeneratedIdentifier = vendorIds[0];
264             String vendorDetailAssignedIdentifier = vendorIds[1];
265             Map vendorAliasMap = new HashMap();
266             vendorAliasMap.put(OLEConstants.VENDOR_HEADER_GENERATED_ID,vendorHeaderGeneratedIdentifier);
267             vendorAliasMap.put(OLEConstants.VENDOR_DETAILED_ASSIGNED_ID,vendorDetailAssignedIdentifier);
268             List<VendorAlias> vendorAliasList = (List) businessObject.findMatching(VendorAlias.class, vendorAliasMap);
269             if(vendorAliasList != null && vendorAliasList.size() >0) {
270                 oleSerialReceivingDocument.setVendorAliasName(vendorAliasList.get(0).getVendorAliasName());
271             }
272             else {
273                 oleSerialReceivingDocument.setVendorAliasName(null);
274             }
275         }
276         else {
277             oleSerialReceivingDocument.setVendorAliasName(null);
278         }
279     }
280 
281     public void updateEnumValues(OLESerialReceivingDocument oleSerialReceivingDocument){
282         String enumCaptionSeparator  = getParameter(OLEConstants.ENUMERATION_CAPTION);
283 
284         String enumCaption1= oleSerialReceivingDocument.getEnumCaption1()!=null ?
285                 oleSerialReceivingDocument.getEnumCaption1(): "" ;
286         if(enumCaption1.length() < Integer.parseInt(oleSerialReceivingDocument.getEnumCaption1Length())){
287             enumCaption1 = enumCaption1+" ";
288         }
289         String enumLevel1 = oleSerialReceivingDocument.getEnumLevel1()!=null?
290                 oleSerialReceivingDocument.getEnumLevel1(): "";
291         oleSerialReceivingDocument.setEnumerationCaptionLevel1(!enumCaption1.isEmpty() || !enumLevel1.isEmpty() ?enumCaption1 +enumCaptionSeparator+ enumLevel1:"");
292         String enumCaption2= oleSerialReceivingDocument.getEnumCaption2()!=null ?
293                 oleSerialReceivingDocument.getEnumCaption2(): "" ;
294         if(enumCaption2.length() < Integer.parseInt(oleSerialReceivingDocument.getEnumCaption2Length())){
295             enumCaption2 = enumCaption2+" ";
296         }
297         String enumLevel2 = oleSerialReceivingDocument.getEnumLevel2()!=null?
298                 oleSerialReceivingDocument.getEnumLevel2(): "";
299         oleSerialReceivingDocument.setEnumerationCaptionLevel2(!enumCaption2.isEmpty() || !enumLevel2.isEmpty() ?enumCaption2 +enumCaptionSeparator+ enumLevel2:"");
300         String enumCaption3= oleSerialReceivingDocument.getEnumCaption3()!=null ?
301                 oleSerialReceivingDocument.getEnumCaption3(): "" ;
302         if(enumCaption3.length() < Integer.parseInt(oleSerialReceivingDocument.getEnumCaption3Length())){
303             enumCaption3 = enumCaption3+" ";
304         }
305         String enumLevel3 = oleSerialReceivingDocument.getEnumLevel3()!=null?
306                 oleSerialReceivingDocument.getEnumLevel3(): "";
307         oleSerialReceivingDocument.setEnumerationCaptionLevel3(!enumCaption3.isEmpty() || !enumLevel3.isEmpty() ?enumCaption3 +enumCaptionSeparator+ enumLevel3:"");
308         String enumCaption4= oleSerialReceivingDocument.getEnumCaption4()!=null ?
309                 oleSerialReceivingDocument.getEnumCaption4(): "" ;
310         if(enumCaption4.length() < Integer.parseInt(oleSerialReceivingDocument.getEnumCaption4Length())){
311             enumCaption4 = enumCaption4+" ";
312         }
313         String enumLevel4 = oleSerialReceivingDocument.getEnumLevel4()!=null?
314                 oleSerialReceivingDocument.getEnumLevel4(): "";
315         oleSerialReceivingDocument.setEnumerationCaptionLevel4(!enumCaption4.isEmpty() || !enumLevel4.isEmpty() ?enumCaption4 +enumCaptionSeparator+ enumLevel4:"");
316         String enumCaption5= oleSerialReceivingDocument.getEnumCaption5()!=null ?
317                 oleSerialReceivingDocument.getEnumCaption5(): "" ;
318         if(enumCaption5.length() < Integer.parseInt(oleSerialReceivingDocument.getEnumCaption5Length())){
319             enumCaption5 = enumCaption5+" ";
320         }
321         String enumLevel5 = oleSerialReceivingDocument.getEnumLevel5()!=null?
322                 oleSerialReceivingDocument.getEnumLevel5(): "";
323         oleSerialReceivingDocument.setEnumerationCaptionLevel5(!enumCaption5.isEmpty() || !enumLevel5.isEmpty() ?enumCaption5 +enumCaptionSeparator+ enumLevel5:"");
324         String enumCaption6= oleSerialReceivingDocument.getEnumCaption6()!=null ?
325                 oleSerialReceivingDocument.getEnumCaption6(): "" ;
326         if(enumCaption6.length() < Integer.parseInt(oleSerialReceivingDocument.getEnumCaption6Length())){
327             enumCaption6 = enumCaption6+" ";
328         }
329         String enumLevel6 = oleSerialReceivingDocument.getEnumLevel6()!=null?
330                 oleSerialReceivingDocument.getEnumLevel6(): "";
331         oleSerialReceivingDocument.setEnumerationCaptionLevel6(!enumCaption6.isEmpty() || !enumLevel6.isEmpty() ?enumCaption6 +enumCaptionSeparator+ enumLevel6:"");
332 
333         String chronCaptionSeparator  = getParameter(OLEConstants.CHRONOLOGY_CAPTION);
334 
335         String chronCaption1= oleSerialReceivingDocument.getChronCaption1()!=null ?
336                 oleSerialReceivingDocument.getChronCaption1(): "" ;
337         if(chronCaption1.length() < Integer.parseInt(oleSerialReceivingDocument.getChronCaption1Length())){
338             chronCaption1 = chronCaption1+" ";
339         }
340         String chronLevel1 = oleSerialReceivingDocument.getChronLevel1()!=null?
341                 oleSerialReceivingDocument.getChronLevel1(): "";
342         oleSerialReceivingDocument.setChronologyCaptionLevel1(!chronCaption1.isEmpty() || !chronLevel1.isEmpty() ?chronCaption1 +chronCaptionSeparator+ chronLevel1:"");
343         String chronCaption2= oleSerialReceivingDocument.getChronCaption2()!=null ?
344                 oleSerialReceivingDocument.getChronCaption2(): "" ;
345         if(chronCaption2.length() < Integer.parseInt(oleSerialReceivingDocument.getChronCaption2Length())){
346             chronCaption2 = chronCaption2+" ";
347         }
348         String chronLevel2 = oleSerialReceivingDocument.getChronLevel2()!=null?
349                 oleSerialReceivingDocument.getChronLevel2(): "";
350         oleSerialReceivingDocument.setChronologyCaptionLevel2(!chronCaption2.isEmpty() || !chronLevel2.isEmpty() ?chronCaption2 +chronCaptionSeparator+ chronLevel2:"");
351         String chronCaption3= oleSerialReceivingDocument.getChronCaption3()!=null ?
352                 oleSerialReceivingDocument.getChronCaption3(): "" ;
353         if(chronCaption3.length() < Integer.parseInt(oleSerialReceivingDocument.getChronCaption3Length())){
354             chronCaption3 = chronCaption3+" ";
355         }
356         String chronLevel3 = oleSerialReceivingDocument.getChronLevel3()!=null?
357                 oleSerialReceivingDocument.getChronLevel3(): "";
358         oleSerialReceivingDocument.setChronologyCaptionLevel3(!chronCaption3.isEmpty() || !chronLevel3.isEmpty() ?chronCaption3 +chronCaptionSeparator+ chronLevel3:"");
359         String chronCaption4= oleSerialReceivingDocument.getChronCaption4()!=null ?
360                 oleSerialReceivingDocument.getChronCaption4(): "" ;
361         if(chronCaption4.length() < Integer.parseInt(oleSerialReceivingDocument.getChronCaption4Length())){
362             chronCaption4 = chronCaption4+" ";
363         }
364         String chronLevel4 = oleSerialReceivingDocument.getChronLevel4()!=null?
365                 oleSerialReceivingDocument.getChronLevel4(): "";
366         oleSerialReceivingDocument.setChronologyCaptionLevel4(!chronCaption4.isEmpty() || !chronLevel4.isEmpty() ?chronCaption4 +chronCaptionSeparator+ chronLevel4:"");
367     }
368     public void updateEnumCaptionValues(OLESerialReceivingDocument oleSerialReceivingDocument,OLESerialReceivingHistory oleSerialReceivingHistory){
369 
370         String enumCaptionSeparator  = getParameter(OLEConstants.ENUMERATION_CAPTION);
371 
372         String [] enumCaptions;
373         if(oleSerialReceivingDocument.getEnumerationCaptionLevel1()!=null){
374             enumCaptions = oleSerialReceivingDocument.getEnumerationCaptionLevel1().split(enumCaptionSeparator);
375             oleSerialReceivingDocument.setEnumCaption1(enumCaptions.length>0 && !enumCaptions[0].isEmpty()?enumCaptions[0]:getParameter(OLEConstants.ENUM_CAPTION1));
376             if(enumCaptions.length>2){
377                 String enumLevel = "";
378                 for(int i=1;i<enumCaptions.length;i++){
379                     String separator = i<enumCaptions.length-1 ? enumCaptionSeparator : "";
380                     enumLevel += enumCaptions[i] + separator;
381                 }
382                 oleSerialReceivingDocument.setEnumLevel1(enumLevel);
383             }else{
384                 oleSerialReceivingDocument.setEnumLevel1(enumCaptions.length>1?enumCaptions[1]:"");
385             }
386             if(oleSerialReceivingHistory!=null && !oleSerialReceivingDocument.getEnumLevel1().isEmpty()){
387                 if(oleSerialReceivingDocument.getEnumCaption1().trim().startsWith("[") && oleSerialReceivingDocument.getEnumCaption1().trim().endsWith("]")) {
388                     oleSerialReceivingHistory.setEnumerationCaptionLevel1(oleSerialReceivingDocument.getEnumLevel1());
389                 }
390                 else {
391                     oleSerialReceivingHistory.setEnumerationCaptionLevel1(oleSerialReceivingDocument.getEnumCaption1() + oleSerialReceivingDocument.getEnumLevel1());
392                 }
393             }
394         }else {
395             oleSerialReceivingDocument.setEnumCaption1(getParameter(OLEConstants.ENUM_CAPTION1));
396             oleSerialReceivingDocument.setEnumLevel1("");
397         }
398         if(oleSerialReceivingDocument.getEnumerationCaptionLevel2()!=null){
399             enumCaptions = oleSerialReceivingDocument.getEnumerationCaptionLevel2().split(enumCaptionSeparator);
400             oleSerialReceivingDocument.setEnumCaption2(enumCaptions.length>0 && !enumCaptions[0].isEmpty() ?enumCaptions[0]:getParameter(OLEConstants.ENUM_CAPTION2));
401             if(enumCaptions.length>2){
402                 String enumLevel = "";
403                 for(int i=1;i<enumCaptions.length;i++){
404                     String separator = i<enumCaptions.length-1 ? enumCaptionSeparator : "";
405                     enumLevel += enumCaptions[i] + separator;
406                 }
407                 oleSerialReceivingDocument.setEnumLevel2(enumLevel);
408             }else{
409                 oleSerialReceivingDocument.setEnumLevel2(enumCaptions.length>1?enumCaptions[1]:"");
410             }
411             if(oleSerialReceivingHistory!=null && !oleSerialReceivingDocument.getEnumLevel2().isEmpty()){
412                 if(oleSerialReceivingDocument.getEnumCaption2().trim().startsWith("[") && oleSerialReceivingDocument.getEnumCaption2().trim().endsWith("]")) {
413                     oleSerialReceivingHistory.setEnumerationCaptionLevel2(oleSerialReceivingDocument.getEnumLevel2());
414                 }
415                 else {
416                     oleSerialReceivingHistory.setEnumerationCaptionLevel2(oleSerialReceivingDocument.getEnumCaption2() + oleSerialReceivingDocument.getEnumLevel2());
417                 }
418             }
419         }else {
420             oleSerialReceivingDocument.setEnumCaption2(getParameter(OLEConstants.ENUM_CAPTION2));
421             oleSerialReceivingDocument.setEnumLevel2("");
422         }
423         if(oleSerialReceivingDocument.getEnumerationCaptionLevel3()!=null){
424             enumCaptions = oleSerialReceivingDocument.getEnumerationCaptionLevel3().split(enumCaptionSeparator);
425             oleSerialReceivingDocument.setEnumCaption3(enumCaptions.length>0 && !enumCaptions[0].isEmpty() ?enumCaptions[0]:getParameter(OLEConstants.ENUM_CAPTION3));
426             if(enumCaptions.length>2){
427                 String enumLevel = "";
428                 for(int i=1;i<enumCaptions.length;i++){
429                     String separator = i<enumCaptions.length-1 ? enumCaptionSeparator : "";
430                     enumLevel += enumCaptions[i] + separator;
431                 }
432                 oleSerialReceivingDocument.setEnumLevel3(enumLevel);
433             }else{
434                 oleSerialReceivingDocument.setEnumLevel3(enumCaptions.length>1?enumCaptions[1]:"");
435             }
436             if(oleSerialReceivingHistory!=null && !oleSerialReceivingDocument.getEnumLevel3().isEmpty()){
437                 if(oleSerialReceivingDocument.getEnumCaption3().trim().startsWith("[") && oleSerialReceivingDocument.getEnumCaption3().trim().endsWith("]")) {
438                     oleSerialReceivingHistory.setEnumerationCaptionLevel3(oleSerialReceivingDocument.getEnumLevel3());
439                 }
440                 else {
441                     oleSerialReceivingHistory.setEnumerationCaptionLevel3(oleSerialReceivingDocument.getEnumCaption3() + oleSerialReceivingDocument.getEnumLevel3());
442                 }
443             }
444         }else {
445             oleSerialReceivingDocument.setEnumCaption3(getParameter(OLEConstants.ENUM_CAPTION3));
446             oleSerialReceivingDocument.setEnumLevel3("");
447         }
448         if(oleSerialReceivingDocument.getEnumerationCaptionLevel4()!=null){
449             enumCaptions = oleSerialReceivingDocument.getEnumerationCaptionLevel4().split(enumCaptionSeparator);
450             oleSerialReceivingDocument.setEnumCaption4(enumCaptions.length>0 && !enumCaptions[0].isEmpty() ?enumCaptions[0]:getParameter(OLEConstants.ENUM_CAPTION4));
451             if(enumCaptions.length>2){
452                 String enumLevel = "";
453                 for(int i=1;i<enumCaptions.length;i++){
454                     String separator = i<enumCaptions.length-1 ? enumCaptionSeparator : "";
455                     enumLevel += enumCaptions[i] + separator;
456                 }
457                 oleSerialReceivingDocument.setEnumLevel4(enumLevel);
458             }else{
459                 oleSerialReceivingDocument.setEnumLevel4(enumCaptions.length>1?enumCaptions[1]:"");
460             }
461             if(oleSerialReceivingHistory!=null && !oleSerialReceivingDocument.getEnumLevel4().isEmpty()){
462                 if(oleSerialReceivingDocument.getEnumCaption4().trim().startsWith("[") && oleSerialReceivingDocument.getEnumCaption4().trim().endsWith("]")) {
463                     oleSerialReceivingHistory.setEnumerationCaptionLevel4(oleSerialReceivingDocument.getEnumLevel4());
464                 }
465                 else {
466                     oleSerialReceivingHistory.setEnumerationCaptionLevel4(oleSerialReceivingDocument.getEnumCaption4() + oleSerialReceivingDocument.getEnumLevel4());
467                 }
468             }
469         }else {
470             oleSerialReceivingDocument.setEnumCaption4(getParameter(OLEConstants.ENUM_CAPTION4));
471             oleSerialReceivingDocument.setEnumLevel4("");
472         }
473         if(oleSerialReceivingDocument.getEnumerationCaptionLevel5()!=null){
474             enumCaptions = oleSerialReceivingDocument.getEnumerationCaptionLevel5().split(enumCaptionSeparator);
475             oleSerialReceivingDocument.setEnumCaption5(enumCaptions.length>0 && !enumCaptions[0].isEmpty() ?enumCaptions[0]:getParameter(OLEConstants.ENUM_CAPTION5));
476             if(enumCaptions.length>2){
477                 String enumLevel = "";
478                 for(int i=1;i<enumCaptions.length;i++){
479                     String separator = i<enumCaptions.length-1 ? enumCaptionSeparator : "";
480                     enumLevel += enumCaptions[i] + separator;
481                 }
482                 oleSerialReceivingDocument.setEnumLevel5(enumLevel);
483             }else{
484                 oleSerialReceivingDocument.setEnumLevel5(enumCaptions.length>1?enumCaptions[1]:"");
485             }
486             if(oleSerialReceivingHistory!=null && !oleSerialReceivingDocument.getEnumLevel5().isEmpty()){
487                 if(oleSerialReceivingDocument.getEnumCaption5().trim().startsWith("[") && oleSerialReceivingDocument.getEnumCaption5().trim().endsWith("]")) {
488                     oleSerialReceivingHistory.setEnumerationCaptionLevel5(oleSerialReceivingDocument.getEnumLevel5());
489                 }
490                 else {
491                     oleSerialReceivingHistory.setEnumerationCaptionLevel5(oleSerialReceivingDocument.getEnumCaption5() + oleSerialReceivingDocument.getEnumLevel5());
492                 }
493             }
494         }else {
495             oleSerialReceivingDocument.setEnumCaption5(getParameter(OLEConstants.ENUM_CAPTION5));
496             oleSerialReceivingDocument.setEnumLevel5("");
497         }
498         if(oleSerialReceivingDocument.getEnumerationCaptionLevel6()!=null){
499             enumCaptions = oleSerialReceivingDocument.getEnumerationCaptionLevel6().split(enumCaptionSeparator);
500             oleSerialReceivingDocument.setEnumCaption6(enumCaptions.length>0 && !enumCaptions[0].isEmpty() ?enumCaptions[0]:getParameter(OLEConstants.ENUM_CAPTION6));
501             if(enumCaptions.length>2){
502                 String enumLevel = "";
503                 for(int i=1;i<enumCaptions.length;i++){
504                     String separator = i<enumCaptions.length-1 ? enumCaptionSeparator : "";
505                     enumLevel += enumCaptions[i] + separator;
506                 }
507                 oleSerialReceivingDocument.setEnumLevel6(enumLevel);
508             }else{
509                 oleSerialReceivingDocument.setEnumLevel6(enumCaptions.length>1?enumCaptions[1]:"");
510             }
511             if(oleSerialReceivingHistory!=null && !oleSerialReceivingDocument.getEnumLevel6().isEmpty()){
512                 if(oleSerialReceivingDocument.getEnumCaption6().trim().startsWith("[") && oleSerialReceivingDocument.getEnumCaption6().trim().endsWith("]")) {
513                     oleSerialReceivingHistory.setEnumerationCaptionLevel6(oleSerialReceivingDocument.getEnumLevel6());
514                 }
515                 else {
516                     oleSerialReceivingHistory.setEnumerationCaptionLevel6(oleSerialReceivingDocument.getEnumCaption6() + oleSerialReceivingDocument.getEnumLevel6());
517                 }
518             }
519         }else {
520             oleSerialReceivingDocument.setEnumCaption6(getParameter(OLEConstants.ENUM_CAPTION6));
521             oleSerialReceivingDocument.setEnumLevel6("");
522         }
523         String chronCaptionSeparator  = getParameter(OLEConstants.CHRONOLOGY_CAPTION);
524 
525         if(oleSerialReceivingDocument.getChronologyCaptionLevel1()!=null){
526             enumCaptions = oleSerialReceivingDocument.getChronologyCaptionLevel1().split(chronCaptionSeparator);
527             oleSerialReceivingDocument.setChronCaption1(enumCaptions.length>0 && !enumCaptions[0].isEmpty() ?enumCaptions[0]:getParameter(OLEConstants.CHRON_CAPTION1));
528             if(enumCaptions.length>2){
529                 String chronLevel = "";
530                 for(int i=1;i<enumCaptions.length;i++){
531                     String separator = i<enumCaptions.length-1 ? chronCaptionSeparator : "";
532                     chronLevel += enumCaptions[i] + separator;
533                 }
534                 oleSerialReceivingDocument.setChronLevel1(chronLevel);
535             }else{
536                 oleSerialReceivingDocument.setChronLevel1(enumCaptions.length>1?enumCaptions[1]:"");
537             }
538             if(oleSerialReceivingHistory!=null && !oleSerialReceivingDocument.getChronLevel1().isEmpty()){
539                 if(oleSerialReceivingDocument.getChronCaption1().trim().startsWith("[") && oleSerialReceivingDocument.getChronCaption1().trim().endsWith("]")){
540                     oleSerialReceivingHistory.setChronologyCaptionLevel1(oleSerialReceivingDocument.getChronLevel1());
541                 }
542                 else {
543                     oleSerialReceivingHistory.setChronologyCaptionLevel1(oleSerialReceivingDocument.getChronCaption1() + oleSerialReceivingDocument.getChronLevel1());
544                 }
545             }
546         } else {
547             oleSerialReceivingDocument.setChronCaption1(getParameter(OLEConstants.CHRON_CAPTION1));
548             oleSerialReceivingDocument.setChronLevel1("");
549         }
550         if(oleSerialReceivingDocument.getChronologyCaptionLevel2()!=null){
551             enumCaptions = oleSerialReceivingDocument.getChronologyCaptionLevel2().split(chronCaptionSeparator);
552             oleSerialReceivingDocument.setChronCaption2(enumCaptions.length>0 && !enumCaptions[0].isEmpty() ?enumCaptions[0]:getParameter(OLEConstants.CHRON_CAPTION2));
553             if(enumCaptions.length>2){
554                 String chronLevel = "";
555                 for(int i=1;i<enumCaptions.length;i++){
556                     String separator = i<enumCaptions.length-1 ? chronCaptionSeparator : "";
557                     chronLevel += enumCaptions[i] + separator;
558                 }
559                 oleSerialReceivingDocument.setChronLevel2(chronLevel);
560             }else{
561                 oleSerialReceivingDocument.setChronLevel2(enumCaptions.length>1?enumCaptions[1]:"");
562             }
563 
564             if(oleSerialReceivingHistory!=null && !oleSerialReceivingDocument.getChronLevel2().isEmpty()){
565                 if(oleSerialReceivingDocument.getChronCaption2().trim().startsWith("[") && oleSerialReceivingDocument.getChronCaption2().trim().endsWith("]")){
566                     oleSerialReceivingHistory.setChronologyCaptionLevel2(oleSerialReceivingDocument.getChronLevel2());
567                 }
568                 else {
569                     oleSerialReceivingHistory.setChronologyCaptionLevel2(oleSerialReceivingDocument.getChronCaption2() + oleSerialReceivingDocument.getChronLevel2());
570                 }
571             }
572         }else {
573             oleSerialReceivingDocument.setChronCaption2(getParameter(OLEConstants.CHRON_CAPTION2));
574             oleSerialReceivingDocument.setChronLevel2("");
575         }
576         if(oleSerialReceivingDocument.getChronologyCaptionLevel3()!=null){
577             enumCaptions = oleSerialReceivingDocument.getChronologyCaptionLevel3().split(chronCaptionSeparator);
578             oleSerialReceivingDocument.setChronCaption3(enumCaptions.length>0 && !enumCaptions[0].isEmpty() ?enumCaptions[0]:getParameter(OLEConstants.CHRON_CAPTION3));
579             if(enumCaptions.length>2){
580                 String chronLevel = "";
581                 for(int i=1;i<enumCaptions.length;i++){
582                     String separator = i<enumCaptions.length-1 ? chronCaptionSeparator : "";
583                     chronLevel += enumCaptions[i] + separator;
584                 }
585                 oleSerialReceivingDocument.setChronLevel3(chronLevel);
586             }else{
587                 oleSerialReceivingDocument.setChronLevel3(enumCaptions.length>1?enumCaptions[1]:"");
588             }
589             if(oleSerialReceivingHistory!=null && !oleSerialReceivingDocument.getChronLevel3().isEmpty()){
590                 if(oleSerialReceivingDocument.getChronCaption3().trim().startsWith("[") && oleSerialReceivingDocument.getChronCaption3().trim().endsWith("]")){
591                     oleSerialReceivingHistory.setChronologyCaptionLevel3(oleSerialReceivingDocument.getChronLevel3());
592                 }
593                 else {
594                     oleSerialReceivingHistory.setChronologyCaptionLevel3(oleSerialReceivingDocument.getChronCaption3() + oleSerialReceivingDocument.getChronLevel3());
595                 }
596             }
597         }else {
598             oleSerialReceivingDocument.setChronCaption3(getParameter(OLEConstants.CHRON_CAPTION3));
599             oleSerialReceivingDocument.setChronLevel3("");
600         }
601         if(oleSerialReceivingDocument.getChronologyCaptionLevel4()!=null){
602             enumCaptions = oleSerialReceivingDocument.getChronologyCaptionLevel4().split(chronCaptionSeparator);
603             oleSerialReceivingDocument.setChronCaption4(enumCaptions.length>0 && !enumCaptions[0].isEmpty() ?enumCaptions[0]:getParameter(OLEConstants.CHRON_CAPTION4));
604             if(enumCaptions.length>2){
605                 String chronLevel = "";
606                 for(int i=1;i<enumCaptions.length;i++){
607                     String separator = i<enumCaptions.length-1 ? chronCaptionSeparator : "";
608                     chronLevel += enumCaptions[i] + separator;
609                 }
610                 oleSerialReceivingDocument.setChronLevel4(chronLevel);
611             }else{
612                 oleSerialReceivingDocument.setChronLevel4(enumCaptions.length>1?enumCaptions[1]:"");
613             }
614             if(oleSerialReceivingHistory!=null && !oleSerialReceivingDocument.getChronLevel4().isEmpty()){
615                 if(oleSerialReceivingDocument.getChronCaption4().trim().startsWith("[") && oleSerialReceivingDocument.getChronCaption4().trim().endsWith("]")){
616                     oleSerialReceivingHistory.setChronologyCaptionLevel4(oleSerialReceivingDocument.getChronLevel4());
617                 }
618                 else {
619                     oleSerialReceivingHistory.setChronologyCaptionLevel4(oleSerialReceivingDocument.getChronCaption4() + oleSerialReceivingDocument.getChronLevel4());
620                 }
621             }
622         }else {
623             oleSerialReceivingDocument.setChronCaption4(getParameter(OLEConstants.CHRON_CAPTION4));
624             oleSerialReceivingDocument.setChronLevel4("");
625         }
626     }
627     public String getParameter(String name){
628         ParameterKey parameterKey = ParameterKey.create(OLEConstants.APPL_ID, OLEConstants.SELECT_NMSPC, OLEConstants.SELECT_CMPNT,name);
629         Parameter parameter = CoreServiceApiServiceLocator.getParameterRepositoryService().getParameter(parameterKey);
630         return parameter!=null?parameter.getValue():null;
631     }
632 
633     @Override
634     public void createOrUpdateReceivingRecordType(OLESerialReceivingDocument oleSerialReceivingDocument) {
635         List<OLESerialReceivingType> oleSerialReceivingTypeList = oleSerialReceivingDocument.getOleSerialReceivingTypes()!=null?oleSerialReceivingDocument.getOleSerialReceivingTypes():
636                 new ArrayList<OLESerialReceivingType>();
637         boolean isReceivingTypeExists = false;
638         for(OLESerialReceivingType oleSerialReceivingType : oleSerialReceivingTypeList){
639             if(oleSerialReceivingType.getReceivingRecordType().equalsIgnoreCase(oleSerialReceivingDocument.getReceivingRecordType())){
640                 isReceivingTypeExists = true;
641                 oleSerialReceivingType.setReceivingRecordType(oleSerialReceivingDocument.getReceivingRecordType());
642                 oleSerialReceivingType.setActionDate(oleSerialReceivingDocument.getActionDate());
643                 oleSerialReceivingType.setActionInterval(oleSerialReceivingDocument.getActionInterval());
644                 oleSerialReceivingType.setEnumerationCaptionLevel1(oleSerialReceivingDocument.getEnumerationCaptionLevel1());
645                 oleSerialReceivingType.setEnumerationCaptionLevel2(oleSerialReceivingDocument.getEnumerationCaptionLevel2());
646                 oleSerialReceivingType.setEnumerationCaptionLevel3(oleSerialReceivingDocument.getEnumerationCaptionLevel3());
647                 oleSerialReceivingType.setEnumerationCaptionLevel4(oleSerialReceivingDocument.getEnumerationCaptionLevel4());
648                 oleSerialReceivingType.setEnumerationCaptionLevel5(oleSerialReceivingDocument.getEnumerationCaptionLevel5());
649                 oleSerialReceivingType.setEnumerationCaptionLevel6(oleSerialReceivingDocument.getEnumerationCaptionLevel6());
650                 oleSerialReceivingType.setChronologyCaptionLevel1(oleSerialReceivingDocument.getChronologyCaptionLevel1());
651                 oleSerialReceivingType.setChronologyCaptionLevel2(oleSerialReceivingDocument.getChronologyCaptionLevel2());
652                 oleSerialReceivingType.setChronologyCaptionLevel3(oleSerialReceivingDocument.getChronologyCaptionLevel3());
653                 oleSerialReceivingType.setChronologyCaptionLevel4(oleSerialReceivingDocument.getChronologyCaptionLevel4());
654             }
655         }
656         if(oleSerialReceivingTypeList.size()==0 || !isReceivingTypeExists) {
657             OLESerialReceivingType oleSerialReceivingType =  new OLESerialReceivingType();
658             oleSerialReceivingType.setReceivingRecordType(oleSerialReceivingDocument.getReceivingRecordType());
659             oleSerialReceivingType.setActionDate(oleSerialReceivingDocument.getActionDate());
660             oleSerialReceivingType.setActionInterval(oleSerialReceivingDocument.getActionInterval());
661             oleSerialReceivingType.setEnumerationCaptionLevel1(oleSerialReceivingDocument.getEnumerationCaptionLevel1());
662             oleSerialReceivingType.setEnumerationCaptionLevel2(oleSerialReceivingDocument.getEnumerationCaptionLevel2());
663             oleSerialReceivingType.setEnumerationCaptionLevel3(oleSerialReceivingDocument.getEnumerationCaptionLevel3());
664             oleSerialReceivingType.setEnumerationCaptionLevel4(oleSerialReceivingDocument.getEnumerationCaptionLevel4());
665             oleSerialReceivingType.setEnumerationCaptionLevel5(oleSerialReceivingDocument.getEnumerationCaptionLevel5());
666             oleSerialReceivingType.setEnumerationCaptionLevel6(oleSerialReceivingDocument.getEnumerationCaptionLevel6());
667             oleSerialReceivingType.setChronologyCaptionLevel1(oleSerialReceivingDocument.getChronologyCaptionLevel1());
668             oleSerialReceivingType.setChronologyCaptionLevel2(oleSerialReceivingDocument.getChronologyCaptionLevel2());
669             oleSerialReceivingType.setChronologyCaptionLevel3(oleSerialReceivingDocument.getChronologyCaptionLevel3());
670             oleSerialReceivingType.setChronologyCaptionLevel4(oleSerialReceivingDocument.getChronologyCaptionLevel4());
671             if(oleSerialReceivingDocument.getOleSerialReceivingTypes()==null){
672                 oleSerialReceivingDocument.setOleSerialReceivingTypes(new ArrayList<OLESerialReceivingType>());
673             }
674             oleSerialReceivingDocument.getOleSerialReceivingTypes().add(oleSerialReceivingType);
675         }
676     }
677 
678     @Override
679     public void readReceivingRecordType(OLESerialReceivingDocument oleSerialReceivingDocument) {
680         List<OLESerialReceivingType> oleSerialReceivingTypeList = oleSerialReceivingDocument.getOleSerialReceivingTypes()!=null?oleSerialReceivingDocument.getOleSerialReceivingTypes():
681                 new ArrayList<OLESerialReceivingType>();
682         boolean isReceivingTypeExists = false;
683         for(OLESerialReceivingType oleSerialReceivingType : oleSerialReceivingTypeList){
684             if(oleSerialReceivingType.getReceivingRecordType().equalsIgnoreCase(oleSerialReceivingDocument.getReceivingRecordType())){
685                 isReceivingTypeExists = true;
686                 oleSerialReceivingDocument.setActionDate(oleSerialReceivingType.getActionDate());
687                 oleSerialReceivingDocument.setActionInterval(oleSerialReceivingType.getActionInterval());
688                 oleSerialReceivingDocument.setEnumerationCaptionLevel1(oleSerialReceivingType.getEnumerationCaptionLevel1());
689                 oleSerialReceivingDocument.setEnumerationCaptionLevel2(oleSerialReceivingType.getEnumerationCaptionLevel2());
690                 oleSerialReceivingDocument.setEnumerationCaptionLevel3(oleSerialReceivingType.getEnumerationCaptionLevel3());
691                 oleSerialReceivingDocument.setEnumerationCaptionLevel4(oleSerialReceivingType.getEnumerationCaptionLevel4());
692                 oleSerialReceivingDocument.setEnumerationCaptionLevel5(oleSerialReceivingType.getEnumerationCaptionLevel5());
693                 oleSerialReceivingDocument.setEnumerationCaptionLevel6(oleSerialReceivingType.getEnumerationCaptionLevel6());
694                 oleSerialReceivingDocument.setChronologyCaptionLevel1(oleSerialReceivingType.getChronologyCaptionLevel1());
695                 oleSerialReceivingDocument.setChronologyCaptionLevel2(oleSerialReceivingType.getChronologyCaptionLevel2());
696                 oleSerialReceivingDocument.setChronologyCaptionLevel3(oleSerialReceivingType.getChronologyCaptionLevel3());
697                 oleSerialReceivingDocument.setChronologyCaptionLevel4(oleSerialReceivingType.getChronologyCaptionLevel4());
698             }
699         }
700         if(!isReceivingTypeExists){
701             oleSerialReceivingDocument.setActionDate(null);
702             oleSerialReceivingDocument.setActionInterval("");
703             oleSerialReceivingDocument.setEnumerationCaptionLevel1("");
704             oleSerialReceivingDocument.setEnumerationCaptionLevel2("");
705             oleSerialReceivingDocument.setEnumerationCaptionLevel3("");
706             oleSerialReceivingDocument.setEnumerationCaptionLevel4("");
707             oleSerialReceivingDocument.setEnumerationCaptionLevel5("");
708             oleSerialReceivingDocument.setEnumerationCaptionLevel6("");
709             oleSerialReceivingDocument.setChronologyCaptionLevel1("");
710             oleSerialReceivingDocument.setChronologyCaptionLevel2("");
711             oleSerialReceivingDocument.setChronologyCaptionLevel3("");
712             oleSerialReceivingDocument.setChronologyCaptionLevel4("");
713         }
714     }
715 
716     @Override
717     public void validateSerialReceivingDocument(OLESerialReceivingDocument oleSerialReceivingDocument) {
718         if((oleSerialReceivingDocument.getEnumLevel1()==null || oleSerialReceivingDocument.getEnumLevel1().isEmpty()) &&
719                 (oleSerialReceivingDocument.getChronLevel1()==null || oleSerialReceivingDocument.getChronLevel1().isEmpty()) ) {
720             GlobalVariables.getMessageMap().putError(OLEKeyConstants.SERIAL_RECEIVE_ENUM1_OR_CHRON1_REQUIRED,OLEKeyConstants.SERIAL_RECEIVE_ENUM1_OR_CHRON1_REQUIRED);
721         }
722         if((oleSerialReceivingDocument.getEnumCaption1()==null || oleSerialReceivingDocument.getEnumCaption1().isEmpty()) &&
723                 !oleSerialReceivingDocument.getEnumLevel1().isEmpty()) {
724             GlobalVariables.getMessageMap().putError(OLEKeyConstants.SERIAL_RECEIVE_ENUM_WITHOUT_CAPTION,OLEKeyConstants.SERIAL_RECEIVE_ENUM_WITHOUT_CAPTION,new String[]{"L1"});
725         }
726         if((oleSerialReceivingDocument.getEnumCaption2()==null || oleSerialReceivingDocument.getEnumCaption2().isEmpty()) &&
727                 !oleSerialReceivingDocument.getEnumLevel2().isEmpty() ) {
728             GlobalVariables.getMessageMap().putError(OLEKeyConstants.SERIAL_RECEIVE_ENUM_WITHOUT_CAPTION,OLEKeyConstants.SERIAL_RECEIVE_ENUM_WITHOUT_CAPTION,new String[]{"L2"});
729         }
730         if((oleSerialReceivingDocument.getEnumCaption3()==null || oleSerialReceivingDocument.getEnumCaption3().isEmpty()) &&
731                 !oleSerialReceivingDocument.getEnumLevel3().isEmpty() ) {
732             GlobalVariables.getMessageMap().putError(OLEKeyConstants.SERIAL_RECEIVE_ENUM_WITHOUT_CAPTION,OLEKeyConstants.SERIAL_RECEIVE_ENUM_WITHOUT_CAPTION,new String[]{"L3"});
733         }
734         if((oleSerialReceivingDocument.getEnumCaption4()==null || oleSerialReceivingDocument.getEnumCaption4().isEmpty()) &&
735                 !oleSerialReceivingDocument.getEnumLevel4().isEmpty() ) {
736             GlobalVariables.getMessageMap().putError(OLEKeyConstants.SERIAL_RECEIVE_ENUM_WITHOUT_CAPTION,OLEKeyConstants.SERIAL_RECEIVE_ENUM_WITHOUT_CAPTION,new String[]{"L4"});
737         }
738         if((oleSerialReceivingDocument.getEnumCaption5()==null || oleSerialReceivingDocument.getEnumCaption5().isEmpty()) &&
739                 !oleSerialReceivingDocument.getEnumLevel5().isEmpty() ) {
740             GlobalVariables.getMessageMap().putError(OLEKeyConstants.SERIAL_RECEIVE_ENUM_WITHOUT_CAPTION,OLEKeyConstants.SERIAL_RECEIVE_ENUM_WITHOUT_CAPTION,new String[]{"L5"});
741         }
742         if((oleSerialReceivingDocument.getEnumCaption6()==null || oleSerialReceivingDocument.getEnumCaption6().isEmpty()) &&
743                 !oleSerialReceivingDocument.getEnumLevel6().isEmpty() ) {
744             GlobalVariables.getMessageMap().putError(OLEKeyConstants.SERIAL_RECEIVE_ENUM_WITHOUT_CAPTION,OLEKeyConstants.SERIAL_RECEIVE_ENUM_WITHOUT_CAPTION,new String[]{"L6"});
745         }
746         if((oleSerialReceivingDocument.getChronCaption1()==null || oleSerialReceivingDocument.getChronCaption1().isEmpty()) &&
747                 !oleSerialReceivingDocument.getChronLevel1().isEmpty() ) {
748             GlobalVariables.getMessageMap().putError(OLEKeyConstants.SERIAL_RECEIVE_CHRON_WITHOUT_CAPTION,OLEKeyConstants.SERIAL_RECEIVE_CHRON_WITHOUT_CAPTION,new String[]{"L1"});
749         }
750         if((oleSerialReceivingDocument.getChronCaption2()==null || oleSerialReceivingDocument.getChronCaption2().isEmpty()) &&
751                 !oleSerialReceivingDocument.getChronLevel2().isEmpty() ) {
752             GlobalVariables.getMessageMap().putError(OLEKeyConstants.SERIAL_RECEIVE_CHRON_WITHOUT_CAPTION,OLEKeyConstants.SERIAL_RECEIVE_CHRON_WITHOUT_CAPTION,new String[]{"L2"});
753         }
754         if((oleSerialReceivingDocument.getChronCaption3()==null || oleSerialReceivingDocument.getChronCaption3().isEmpty()) &&
755                 !oleSerialReceivingDocument.getChronLevel3().isEmpty() ) {
756             GlobalVariables.getMessageMap().putError(OLEKeyConstants.SERIAL_RECEIVE_CHRON_WITHOUT_CAPTION,OLEKeyConstants.SERIAL_RECEIVE_CHRON_WITHOUT_CAPTION,new String[]{"L3"});
757         }
758         if((oleSerialReceivingDocument.getChronCaption4()==null || oleSerialReceivingDocument.getChronCaption4().isEmpty()) &&
759                 !oleSerialReceivingDocument.getChronLevel4().isEmpty() ) {
760             GlobalVariables.getMessageMap().putError(OLEKeyConstants.SERIAL_RECEIVE_CHRON_WITHOUT_CAPTION,OLEKeyConstants.SERIAL_RECEIVE_CHRON_WITHOUT_CAPTION,new String[]{"L4"});
761         }
762     }
763 
764     public void updatePOVendorDetail(OLESerialReceivingDocument oleSerialReceivingDocument){
765         BusinessObjectService businessObjectService= KRADServiceLocator.getBusinessObjectService();
766         Map parentCriterial = new HashMap();
767         parentCriterial.put(OLEConstants.BIB_ID,oleSerialReceivingDocument.getBibId());
768         parentCriterial.put(OLEConstants.INSTANCE_ID,oleSerialReceivingDocument.getInstanceId());
769         List<OleCopy> copyList = (List<OleCopy>) businessObjectService.findMatching(OleCopy.class,parentCriterial);
770         Map<String,String> poMap =  new ConcurrentHashMap<String,String>();
771         for(OleCopy oleCopy : copyList){
772             poMap.put(oleCopy.getPoDocNum(),oleCopy.getPoDocNum());
773         }
774         Iterator<Map.Entry<String,String>> entries = poMap.entrySet().iterator();
775         List<OLESerialRelatedPODocument> oleSerialRelatedPODocuments = new ArrayList<>();
776         while (entries.hasNext()) {
777             Map.Entry<String, String> entry = entries.next();
778             String poDocNum = entry.getValue();
779             parentCriterial.clear();
780             parentCriterial.put(OLEConstants.DOC_NUM,poDocNum);
781             OlePurchaseOrderDocument olePurchaseOrderDocument=  businessObjectService.findByPrimaryKey(OlePurchaseOrderDocument.class,parentCriterial);
782             if(!olePurchaseOrderDocument.getPurchaseOrderCurrentIndicatorForSearching()){
783                 poMap.remove(olePurchaseOrderDocument.getDocumentNumber());
784             }
785             if(olePurchaseOrderDocument!=null && olePurchaseOrderDocument.getPurchaseOrderCurrentIndicatorForSearching())    {
786                 String vendorHeaderGeneratedIdentifier = olePurchaseOrderDocument.getVendorHeaderGeneratedIdentifier()!=null ? olePurchaseOrderDocument.getVendorHeaderGeneratedIdentifier().toString() : "";
787                 String vendorDetailAssignedIdentifier = olePurchaseOrderDocument.getVendorDetailAssignedIdentifier()!=null ? olePurchaseOrderDocument.getVendorDetailAssignedIdentifier().toString() : "";
788                 Map vendorAliasMap = new HashMap();
789                 vendorAliasMap.put(org.kuali.ole.sys.OLEConstants.VENDOR_HEADER_IDENTIFIER,vendorHeaderGeneratedIdentifier);
790                 vendorAliasMap.put(org.kuali.ole.sys.OLEConstants.VENDOR_DETAIL_IDENTIFIER,vendorDetailAssignedIdentifier);
791                 List<VendorAlias> vendorAliasList = (List) businessObject.findMatching(VendorAlias.class, vendorAliasMap);
792                 List<VendorDetail> vendorDetailList = (List) businessObject.findMatching(VendorDetail.class, vendorAliasMap);
793                 if(poMap.size()==1){
794                     oleSerialReceivingDocument.setPoId(olePurchaseOrderDocument.getPurapDocumentIdentifier()!=null ? olePurchaseOrderDocument.getPurapDocumentIdentifier().toString() : "");
795                     oleSerialReceivingDocument.setPoIdLink(oleSerialReceivingDocument.formPoIdLinkUsingPoDocumentNumber(olePurchaseOrderDocument.getDocumentNumber()));
796                     oleSerialReceivingDocument.setVendorId(vendorHeaderGeneratedIdentifier + "-" + vendorDetailAssignedIdentifier);
797                     if(vendorAliasList != null && vendorAliasList.size() >0) {
798                         oleSerialReceivingDocument.setVendorAliasName(vendorAliasList.get(0).getVendorAliasName());
799                     }
800                     if(vendorDetailList != null && vendorDetailList.size() >0) {
801                         oleSerialReceivingDocument.setVendorName(vendorDetailList.get(0).getVendorName());
802                         if(oleSerialReceivingDocument.getActionInterval()==null || oleSerialReceivingDocument.getActionInterval().isEmpty()){
803                             oleSerialReceivingDocument.setActionInterval(vendorDetailList.get(0).getClaimInterval());
804                         }
805                     }
806                 } else {
807                     oleSerialReceivingDocument.setLinkPO(true);
808                     OLESerialRelatedPODocument oleSerialRelatedPODocument = new OLESerialRelatedPODocument();
809                     oleSerialRelatedPODocument.setPoId(olePurchaseOrderDocument.getPurapDocumentIdentifier() != null ? olePurchaseOrderDocument.getPurapDocumentIdentifier().toString() : "");
810                     oleSerialRelatedPODocument.setPoIdLink(olePurchaseOrderDocument.getDocumentNumber());
811                     oleSerialRelatedPODocument.setVendorId(vendorHeaderGeneratedIdentifier + "-" + vendorDetailAssignedIdentifier);
812                     if(vendorAliasList != null && vendorAliasList.size() >0) {
813                         oleSerialRelatedPODocument.setVendorAliasName(vendorAliasList.get(0).getVendorAliasName());
814                     }
815                     if(vendorDetailList != null && vendorDetailList.size() >0) {
816                         oleSerialRelatedPODocument.setVendorName(vendorDetailList.get(0).getVendorName());
817                         if(oleSerialReceivingDocument.getActionInterval()==null || oleSerialReceivingDocument.getActionInterval().isEmpty()){
818                             oleSerialRelatedPODocument.setActionInterval(vendorDetailList.get(0).getClaimInterval());
819                         }
820                     }
821                     oleSerialRelatedPODocuments.add(oleSerialRelatedPODocument) ;
822                 }
823             }
824         }
825         if(oleSerialRelatedPODocuments.size()>1){
826             oleSerialReceivingDocument.setOleSerialRelatedPODocuments(oleSerialRelatedPODocuments);
827         }else if (oleSerialRelatedPODocuments.size()==1){
828             oleSerialReceivingDocument.setLinkPO(false);
829             OLESerialRelatedPODocument oleSerialRelatedPODocument = oleSerialRelatedPODocuments.get(0);
830             oleSerialReceivingDocument.setPoId(oleSerialRelatedPODocument.getPoId());
831             oleSerialReceivingDocument.setPoIdLink(oleSerialRelatedPODocument.getPoIdLink());
832             oleSerialReceivingDocument.setVendorId(oleSerialRelatedPODocument.getVendorId());
833             oleSerialReceivingDocument.setVendorAliasName(oleSerialRelatedPODocument.getVendorAliasName());
834             oleSerialReceivingDocument.setVendorName(oleSerialRelatedPODocument.getVendorName());
835             oleSerialReceivingDocument.setActionInterval(oleSerialRelatedPODocument.getActionInterval());
836         }
837     }
838 
839     private LookupService getLookupService() {
840         return KRADServiceLocatorWeb.getLookupService();
841     }
842     public void updateSerialIdInCopy(OLESerialReceivingDocument oleSerialReceivingDocument){
843         BusinessObjectService businessObjectService= KRADServiceLocator.getBusinessObjectService();
844         Map parentCriterial = new HashMap();
845         parentCriterial.put(OLEConstants.BIB_ID,oleSerialReceivingDocument.getBibId());
846         parentCriterial.put(OLEConstants.INSTANCE_ID,oleSerialReceivingDocument.getInstanceId());
847 
848         Map oldInstanceMap = new HashMap();
849         oldInstanceMap.put(OLEConstants.BIB_ID,oleSerialReceivingDocument.getBibId());
850         oldInstanceMap.put(OLEConstants.INSTANCE_ID,oleSerialReceivingDocument.getTempInstanceId());
851 
852 
853         if(oleSerialReceivingDocument.getTempInstanceId().equalsIgnoreCase(oleSerialReceivingDocument.getInstanceId())){
854             List<OleCopy> copyList = (List<OleCopy>) businessObjectService.findMatching(OleCopy.class,parentCriterial);
855             for(OleCopy oleCopy :copyList){
856                 oleCopy.setSerialReceivingIdentifier(oleSerialReceivingDocument.getSerialReceivingRecordId());
857                 businessObjectService.save(oleCopy);
858             }
859         } else {
860             List<OleCopy> oldCopyList = (List<OleCopy>) businessObjectService.findMatching(OleCopy.class,oldInstanceMap);
861             for(OleCopy oleCopy :oldCopyList){
862                 oleCopy.setSerialReceivingIdentifier(null);
863                 businessObjectService.save(oleCopy);
864             }
865             List<OleCopy> newCopyList = (List<OleCopy>) businessObjectService.findMatching(OleCopy.class,parentCriterial);
866             for(OleCopy oleCopy :newCopyList){
867                 oleCopy.setSerialReceivingIdentifier(oleSerialReceivingDocument.getSerialReceivingRecordId());
868                 businessObjectService.save(oleCopy);
869             }
870         }
871     }
872 
873     public void listOutHistoryBasedOnReceivingRecord(OLESerialReceivingDocument oleSerialReceivingDocument){
874         List<OLESerialReceivingHistory> oleSerialReceivingHistoryList =  oleSerialReceivingDocument.getOleSerialReceivingHistoryList()!=null?
875                 oleSerialReceivingDocument.getOleSerialReceivingHistoryList():new ArrayList<OLESerialReceivingHistory>();
876         List<OLESerialReceivingHistory> mainSerialReceivingHistoryList = new ArrayList<>();
877         List<OLESerialReceivingHistory> supplementSerialReceivingHistoryList = new ArrayList<>();
878         List<OLESerialReceivingHistory> indexSerialReceivingHistoryList = new ArrayList<>();
879         for(OLESerialReceivingHistory oleSerialReceivingHistory : oleSerialReceivingHistoryList){
880             if(oleSerialReceivingHistory.getReceivingRecordType().equalsIgnoreCase(OLEConstants.MAIN_RCV_REC_TYP)){
881                 mainSerialReceivingHistoryList.add(oleSerialReceivingHistory);
882             }else if(oleSerialReceivingHistory.getReceivingRecordType().equalsIgnoreCase(OLEConstants.SUPPLEMENT_RCV_REC_TYP)){
883                 supplementSerialReceivingHistoryList.add(oleSerialReceivingHistory);
884             }else if(oleSerialReceivingHistory.getReceivingRecordType().equalsIgnoreCase(OLEConstants.INDEX_RCV_REC_TYP)){
885                 indexSerialReceivingHistoryList.add(oleSerialReceivingHistory);
886             }
887         }
888         String searchLimit;
889         if((mainSerialReceivingHistoryList.size()>0 && supplementSerialReceivingHistoryList.size()>0) ||
890                 (mainSerialReceivingHistoryList.size()>0 && indexSerialReceivingHistoryList.size()>0) ||
891                 (supplementSerialReceivingHistoryList.size()>0 && indexSerialReceivingHistoryList.size()>0)){
892             searchLimit = getParameter(OLEConstants.SERIAL_MULTI_SEC_LIMIT);
893             oleSerialReceivingDocument.setSearchLimit(searchLimit!=null?searchLimit:"0");
894         }else {
895             searchLimit = getParameter(OLEConstants.SERIAL_SINGLE_SEC_LIMIT);
896             oleSerialReceivingDocument.setSearchLimit(searchLimit!=null?searchLimit:"0");
897         }
898         oleSerialReceivingDocument.setMainSerialReceivingHistoryList(mainSerialReceivingHistoryList);
899         oleSerialReceivingDocument.setSupplementSerialReceivingHistoryList(supplementSerialReceivingHistoryList);
900         oleSerialReceivingDocument.setIndexSerialReceivingHistoryList(indexSerialReceivingHistoryList);
901     }
902 
903     public void disapproveCreateNewWithExisting(OLESerialReceivingDocument newSerialReceivingDocument,OLESerialReceivingDocument oldSerialReceivingDocument){
904         newSerialReceivingDocument.setTitle(oldSerialReceivingDocument.getTitle());
905         newSerialReceivingDocument.setActionDate(oldSerialReceivingDocument.getActionDate());
906         newSerialReceivingDocument.setActionInterval(oldSerialReceivingDocument.getActionInterval());
907         newSerialReceivingDocument.setBibId(oldSerialReceivingDocument.getBibId());
908         newSerialReceivingDocument.setBoundLocation(oldSerialReceivingDocument.getBoundLocation());
909         newSerialReceivingDocument.setCallNumber(oldSerialReceivingDocument.getCallNumber());
910         List<OLESerialReceivingType> oleSerialReceivingTypeList = new ArrayList<OLESerialReceivingType>();
911         for(OLESerialReceivingType oleSerialReceivingType : oldSerialReceivingDocument.getOleSerialReceivingTypes()){
912             OLESerialReceivingType newSerialReceivingType = new OLESerialReceivingType();
913             newSerialReceivingType.setSerialReceivingRecordId(oldSerialReceivingDocument.getSerialReceivingRecordId());
914             newSerialReceivingType.setReceivingRecordType(oleSerialReceivingType.getReceivingRecordType());
915             newSerialReceivingType.setActionDate(oleSerialReceivingType.getActionDate());
916             newSerialReceivingType.setActionInterval(oleSerialReceivingType.getActionInterval());
917             newSerialReceivingType.setChronologyCaptionLevel1(oleSerialReceivingType.getChronologyCaptionLevel1());
918             newSerialReceivingType.setChronologyCaptionLevel2(oleSerialReceivingType.getChronologyCaptionLevel2());
919             newSerialReceivingType.setChronologyCaptionLevel3(oleSerialReceivingType.getChronologyCaptionLevel3());
920             newSerialReceivingType.setChronologyCaptionLevel4(oleSerialReceivingType.getChronologyCaptionLevel4());
921             newSerialReceivingType.setEnumerationCaptionLevel1(oleSerialReceivingType.getEnumerationCaptionLevel1());
922             newSerialReceivingType.setEnumerationCaptionLevel2(oleSerialReceivingType.getEnumerationCaptionLevel2());
923             newSerialReceivingType.setEnumerationCaptionLevel3(oleSerialReceivingType.getEnumerationCaptionLevel3());
924             newSerialReceivingType.setEnumerationCaptionLevel4(oleSerialReceivingType.getEnumerationCaptionLevel4());
925             newSerialReceivingType.setEnumerationCaptionLevel5(oleSerialReceivingType.getEnumerationCaptionLevel5());
926             newSerialReceivingType.setEnumerationCaptionLevel6(oleSerialReceivingType.getEnumerationCaptionLevel6());
927             oleSerialReceivingTypeList.add(newSerialReceivingType);
928 
929         }
930         newSerialReceivingDocument.setOleSerialReceivingTypes(oleSerialReceivingTypeList);
931         newSerialReceivingDocument.setReceivingRecordType(oldSerialReceivingDocument.getReceivingRecordType());
932         newSerialReceivingDocument.setChronologyCaptionLevel1(oldSerialReceivingDocument.getChronologyCaptionLevel1());
933         newSerialReceivingDocument.setChronologyCaptionLevel2(oldSerialReceivingDocument.getChronologyCaptionLevel2());
934         newSerialReceivingDocument.setChronologyCaptionLevel3(oldSerialReceivingDocument.getChronologyCaptionLevel3());
935         newSerialReceivingDocument.setChronologyCaptionLevel4(oldSerialReceivingDocument.getChronologyCaptionLevel4());
936         newSerialReceivingDocument.setClaim(oldSerialReceivingDocument.isClaim());
937         newSerialReceivingDocument.setClaimIntervalInformation(oldSerialReceivingDocument.getClaimIntervalInformation());
938         newSerialReceivingDocument.setCopyNumber(oldSerialReceivingDocument.getCopyNumber());
939         newSerialReceivingDocument.setCorporateAuthor(oldSerialReceivingDocument.getCorporateAuthor());
940         newSerialReceivingDocument.setCreateItem(oldSerialReceivingDocument.isCreateItem());
941         newSerialReceivingDocument.setEnumerationCaptionLevel1(oldSerialReceivingDocument.getEnumerationCaptionLevel1());
942         newSerialReceivingDocument.setEnumerationCaptionLevel2(oldSerialReceivingDocument.getEnumerationCaptionLevel2());
943         newSerialReceivingDocument.setEnumerationCaptionLevel3(oldSerialReceivingDocument.getEnumerationCaptionLevel3());
944         newSerialReceivingDocument.setEnumerationCaptionLevel4(oldSerialReceivingDocument.getEnumerationCaptionLevel4());
945         newSerialReceivingDocument.setEnumerationCaptionLevel5(oldSerialReceivingDocument.getEnumerationCaptionLevel5());
946         newSerialReceivingDocument.setEnumerationCaptionLevel6(oldSerialReceivingDocument.getEnumerationCaptionLevel6());
947         newSerialReceivingDocument.setGeneralReceivingNote(oldSerialReceivingDocument.getGeneralReceivingNote());
948         newSerialReceivingDocument.setInstanceId(oldSerialReceivingDocument.getInstanceId());
949         newSerialReceivingDocument.setIssn(oldSerialReceivingDocument.getIssn());
950         newSerialReceivingDocument.setPoId(oldSerialReceivingDocument.getPoId());
951         newSerialReceivingDocument.setPrintLabel(oldSerialReceivingDocument.isPrintLabel());
952         newSerialReceivingDocument.setPublicDisplay(oldSerialReceivingDocument.isPublicDisplay());
953         newSerialReceivingDocument.setPublisher(oldSerialReceivingDocument.getPublisher());
954         newSerialReceivingDocument.setSerialReceiptLocation(oldSerialReceivingDocument.getSerialReceiptLocation());
955         newSerialReceivingDocument.setSerialReceivingRecord(oldSerialReceivingDocument.getSerialReceivingRecord());
956         newSerialReceivingDocument.setSubscriptionStatus(oldSerialReceivingDocument.getSubscriptionStatus());
957         newSerialReceivingDocument.setTreatmentInstructionNote(oldSerialReceivingDocument.getTreatmentInstructionNote());
958         newSerialReceivingDocument.setUnboundLocation(oldSerialReceivingDocument.getUnboundLocation());
959         newSerialReceivingDocument.setUrgentNote(oldSerialReceivingDocument.getUrgentNote());
960         newSerialReceivingDocument.setVendorId(oldSerialReceivingDocument.getVendorId());
961         newSerialReceivingDocument.setCreateDate(oldSerialReceivingDocument.getCreateDate());
962         newSerialReceivingDocument.setOperatorId(oldSerialReceivingDocument.getOperatorId());
963         newSerialReceivingDocument.setMachineId(oldSerialReceivingDocument.getMachineId());
964         newSerialReceivingDocument.setSubscriptionStatusDate(oldSerialReceivingDocument.getSubscriptionStatusDate());
965         newSerialReceivingDocument.setActive(true);
966         List<OLESerialReceivingHistory> newSerialReceivingHistoryList = new ArrayList<>();
967         reSortById(oldSerialReceivingDocument.getOleSerialReceivingHistoryList());
968         for(OLESerialReceivingHistory oleSerialReceivingHistory : oldSerialReceivingDocument.getOleSerialReceivingHistoryList()){
969             OLESerialReceivingHistory newSerialReceivingHistory = new OLESerialReceivingHistory();
970             newSerialReceivingHistory.setReceivingRecordType(oleSerialReceivingHistory.getReceivingRecordType());
971             newSerialReceivingHistory.setChronologyCaptionLevel1(oleSerialReceivingHistory.getChronologyCaptionLevel1());
972             newSerialReceivingHistory.setChronologyCaptionLevel2(oleSerialReceivingHistory.getChronologyCaptionLevel2());
973             newSerialReceivingHistory.setChronologyCaptionLevel3(oleSerialReceivingHistory.getChronologyCaptionLevel3());
974             newSerialReceivingHistory.setChronologyCaptionLevel4(oleSerialReceivingHistory.getChronologyCaptionLevel4());
975             newSerialReceivingHistory.setClaimCount(oleSerialReceivingHistory.getClaimCount());
976             newSerialReceivingHistory.setClaimDate(oleSerialReceivingHistory.getClaimDate());
977             newSerialReceivingHistory.setClaimNote(oleSerialReceivingHistory.getClaimNote());
978             newSerialReceivingHistory.setClaimResponse(oleSerialReceivingHistory.getClaimResponse());
979             newSerialReceivingHistory.setClaimType(oleSerialReceivingHistory.getClaimType());
980             newSerialReceivingHistory.setEnumerationCaptionLevel1(oleSerialReceivingHistory.getEnumerationCaptionLevel1());
981             newSerialReceivingHistory.setEnumerationCaptionLevel2(oleSerialReceivingHistory.getEnumerationCaptionLevel2());
982             newSerialReceivingHistory.setEnumerationCaptionLevel3(oleSerialReceivingHistory.getEnumerationCaptionLevel3());
983             newSerialReceivingHistory.setEnumerationCaptionLevel4(oleSerialReceivingHistory.getEnumerationCaptionLevel4());
984             newSerialReceivingHistory.setEnumerationCaptionLevel5(oleSerialReceivingHistory.getEnumerationCaptionLevel5());
985             newSerialReceivingHistory.setEnumerationCaptionLevel6(oleSerialReceivingHistory.getEnumerationCaptionLevel6());
986             newSerialReceivingHistory.setPublicDisplay(oleSerialReceivingHistory.isPublicDisplay());
987             newSerialReceivingHistory.setSerialReceiptNote(oleSerialReceivingHistory.getSerialReceiptNote());
988             newSerialReceivingHistory.setOperatorId(oleSerialReceivingHistory.getOperatorId());
989             newSerialReceivingHistory.setMachineId(oleSerialReceivingHistory.getMachineId());
990             newSerialReceivingHistory.setReceiptStatus(oleSerialReceivingHistory.getReceiptStatus());
991             newSerialReceivingHistory.setReceiptDate(oleSerialReceivingHistory.getReceiptDate());
992             newSerialReceivingHistory.setPublicReceipt(oleSerialReceivingHistory.getPublicReceipt());
993             newSerialReceivingHistory.setStaffOnlyReceipt(oleSerialReceivingHistory.getStaffOnlyReceipt());
994             newSerialReceivingHistoryList.add(newSerialReceivingHistory);
995         }
996         newSerialReceivingDocument.setOleSerialReceivingHistoryList(newSerialReceivingHistoryList);
997     }
998 
999 
1000     public void createNewWithExisting(OLESerialReceivingDocument newSerialReceivingDocument,OLESerialReceivingDocument oldSerialReceivingDocument){
1001         newSerialReceivingDocument.setTitle(oldSerialReceivingDocument.getTitle());
1002         newSerialReceivingDocument.setActionDate(oldSerialReceivingDocument.getActionDate());
1003         newSerialReceivingDocument.setActionInterval(oldSerialReceivingDocument.getActionInterval());
1004         newSerialReceivingDocument.setBibId(oldSerialReceivingDocument.getBibId());
1005         newSerialReceivingDocument.setBoundLocation(oldSerialReceivingDocument.getBoundLocation());
1006         newSerialReceivingDocument.setCallNumber(oldSerialReceivingDocument.getCallNumber());
1007         List<OLESerialReceivingType> oleSerialReceivingTypeList = new ArrayList<OLESerialReceivingType>();
1008         if (oldSerialReceivingDocument.getOleSerialReceivingTypes() != null) {
1009             for (OLESerialReceivingType oleSerialReceivingType : oldSerialReceivingDocument.getOleSerialReceivingTypes()) {
1010                 OLESerialReceivingType newSerialReceivingType = new OLESerialReceivingType();
1011                 newSerialReceivingType.setReceivingRecordType(oleSerialReceivingType.getReceivingRecordType());
1012                 newSerialReceivingType.setActionDate(oleSerialReceivingType.getActionDate());
1013                 newSerialReceivingType.setActionInterval(oleSerialReceivingType.getActionInterval());
1014                 newSerialReceivingType.setChronologyCaptionLevel1(oleSerialReceivingType.getChronologyCaptionLevel1());
1015                 newSerialReceivingType.setChronologyCaptionLevel2(oleSerialReceivingType.getChronologyCaptionLevel2());
1016                 newSerialReceivingType.setChronologyCaptionLevel3(oleSerialReceivingType.getChronologyCaptionLevel3());
1017                 newSerialReceivingType.setChronologyCaptionLevel4(oleSerialReceivingType.getChronologyCaptionLevel4());
1018                 newSerialReceivingType.setEnumerationCaptionLevel1(oleSerialReceivingType.getEnumerationCaptionLevel1());
1019                 newSerialReceivingType.setEnumerationCaptionLevel2(oleSerialReceivingType.getEnumerationCaptionLevel2());
1020                 newSerialReceivingType.setEnumerationCaptionLevel3(oleSerialReceivingType.getEnumerationCaptionLevel3());
1021                 newSerialReceivingType.setEnumerationCaptionLevel4(oleSerialReceivingType.getEnumerationCaptionLevel4());
1022                 newSerialReceivingType.setEnumerationCaptionLevel5(oleSerialReceivingType.getEnumerationCaptionLevel5());
1023                 newSerialReceivingType.setEnumerationCaptionLevel6(oleSerialReceivingType.getEnumerationCaptionLevel6());
1024             oleSerialReceivingTypeList.add(newSerialReceivingType);
1025 
1026             }
1027         }
1028         newSerialReceivingDocument.setOleSerialReceivingTypes(oleSerialReceivingTypeList);
1029         newSerialReceivingDocument.setReceivingRecordType(oldSerialReceivingDocument.getReceivingRecordType());
1030         newSerialReceivingDocument.setChronologyCaptionLevel1(oldSerialReceivingDocument.getChronologyCaptionLevel1());
1031         newSerialReceivingDocument.setChronologyCaptionLevel2(oldSerialReceivingDocument.getChronologyCaptionLevel2());
1032         newSerialReceivingDocument.setChronologyCaptionLevel3(oldSerialReceivingDocument.getChronologyCaptionLevel3());
1033         newSerialReceivingDocument.setChronologyCaptionLevel4(oldSerialReceivingDocument.getChronologyCaptionLevel4());
1034         newSerialReceivingDocument.setClaim(oldSerialReceivingDocument.isClaim());
1035         newSerialReceivingDocument.setClaimIntervalInformation(oldSerialReceivingDocument.getClaimIntervalInformation());
1036         newSerialReceivingDocument.setCopyNumber(oldSerialReceivingDocument.getCopyNumber());
1037         newSerialReceivingDocument.setCorporateAuthor(oldSerialReceivingDocument.getCorporateAuthor());
1038         newSerialReceivingDocument.setCreateItem(oldSerialReceivingDocument.isCreateItem());
1039         newSerialReceivingDocument.setEnumerationCaptionLevel1(oldSerialReceivingDocument.getEnumerationCaptionLevel1());
1040         newSerialReceivingDocument.setEnumerationCaptionLevel2(oldSerialReceivingDocument.getEnumerationCaptionLevel2());
1041         newSerialReceivingDocument.setEnumerationCaptionLevel3(oldSerialReceivingDocument.getEnumerationCaptionLevel3());
1042         newSerialReceivingDocument.setEnumerationCaptionLevel4(oldSerialReceivingDocument.getEnumerationCaptionLevel4());
1043         newSerialReceivingDocument.setEnumerationCaptionLevel5(oldSerialReceivingDocument.getEnumerationCaptionLevel5());
1044         newSerialReceivingDocument.setEnumerationCaptionLevel6(oldSerialReceivingDocument.getEnumerationCaptionLevel6());
1045         newSerialReceivingDocument.setGeneralReceivingNote(oldSerialReceivingDocument.getGeneralReceivingNote());
1046         newSerialReceivingDocument.setInstanceId(oldSerialReceivingDocument.getInstanceId());
1047         newSerialReceivingDocument.setIssn(oldSerialReceivingDocument.getIssn());
1048         newSerialReceivingDocument.setPoId(oldSerialReceivingDocument.getPoId());
1049         newSerialReceivingDocument.setPrintLabel(oldSerialReceivingDocument.isPrintLabel());
1050         newSerialReceivingDocument.setPublicDisplay(oldSerialReceivingDocument.isPublicDisplay());
1051         newSerialReceivingDocument.setPublisher(oldSerialReceivingDocument.getPublisher());
1052         newSerialReceivingDocument.setSerialReceiptLocation(oldSerialReceivingDocument.getSerialReceiptLocation());
1053         newSerialReceivingDocument.setSerialReceivingRecord(oldSerialReceivingDocument.getSerialReceivingRecord());
1054         newSerialReceivingDocument.setSubscriptionStatus(oldSerialReceivingDocument.getSubscriptionStatus());
1055         newSerialReceivingDocument.setTreatmentInstructionNote(oldSerialReceivingDocument.getTreatmentInstructionNote());
1056         newSerialReceivingDocument.setUnboundLocation(oldSerialReceivingDocument.getUnboundLocation());
1057         newSerialReceivingDocument.setUrgentNote(oldSerialReceivingDocument.getUrgentNote());
1058         newSerialReceivingDocument.setVendorId(oldSerialReceivingDocument.getVendorId());
1059         newSerialReceivingDocument.setCreateDate(oldSerialReceivingDocument.getCreateDate());
1060         newSerialReceivingDocument.setOperatorId(oldSerialReceivingDocument.getOperatorId());
1061         newSerialReceivingDocument.setMachineId(oldSerialReceivingDocument.getMachineId());
1062         newSerialReceivingDocument.setSubscriptionStatusDate(oldSerialReceivingDocument.getSubscriptionStatusDate());
1063         newSerialReceivingDocument.setActive(true);
1064         List<OLESerialReceivingHistory> newSerialReceivingHistoryList = new ArrayList<>();
1065         if (oldSerialReceivingDocument.getOleSerialReceivingHistoryList() != null) {
1066             for (OLESerialReceivingHistory oleSerialReceivingHistory : oldSerialReceivingDocument.getOleSerialReceivingHistoryList()) {
1067                 OLESerialReceivingHistory newSerialReceivingHistory = new OLESerialReceivingHistory();
1068                 newSerialReceivingHistory.setReceivingRecordType(oleSerialReceivingHistory.getReceivingRecordType());
1069                 newSerialReceivingHistory.setChronologyCaptionLevel1(oleSerialReceivingHistory.getChronologyCaptionLevel1());
1070                 newSerialReceivingHistory.setChronologyCaptionLevel2(oleSerialReceivingHistory.getChronologyCaptionLevel2());
1071                 newSerialReceivingHistory.setChronologyCaptionLevel3(oleSerialReceivingHistory.getChronologyCaptionLevel3());
1072                 newSerialReceivingHistory.setChronologyCaptionLevel4(oleSerialReceivingHistory.getChronologyCaptionLevel4());
1073                 newSerialReceivingHistory.setClaimCount(oleSerialReceivingHistory.getClaimCount());
1074                 newSerialReceivingHistory.setClaimDate(oleSerialReceivingHistory.getClaimDate());
1075                 newSerialReceivingHistory.setClaimNote(oleSerialReceivingHistory.getClaimNote());
1076                 newSerialReceivingHistory.setClaimResponse(oleSerialReceivingHistory.getClaimResponse());
1077                 newSerialReceivingHistory.setClaimType(oleSerialReceivingHistory.getClaimType());
1078                 newSerialReceivingHistory.setEnumerationCaptionLevel1(oleSerialReceivingHistory.getEnumerationCaptionLevel1());
1079                 newSerialReceivingHistory.setEnumerationCaptionLevel2(oleSerialReceivingHistory.getEnumerationCaptionLevel2());
1080                 newSerialReceivingHistory.setEnumerationCaptionLevel3(oleSerialReceivingHistory.getEnumerationCaptionLevel3());
1081                 newSerialReceivingHistory.setEnumerationCaptionLevel4(oleSerialReceivingHistory.getEnumerationCaptionLevel4());
1082                 newSerialReceivingHistory.setEnumerationCaptionLevel5(oleSerialReceivingHistory.getEnumerationCaptionLevel5());
1083                 newSerialReceivingHistory.setEnumerationCaptionLevel6(oleSerialReceivingHistory.getEnumerationCaptionLevel6());
1084                 newSerialReceivingHistory.setPublicDisplay(oleSerialReceivingHistory.isPublicDisplay());
1085                 newSerialReceivingHistory.setSerialReceiptNote(oleSerialReceivingHistory.getSerialReceiptNote());
1086                 newSerialReceivingHistory.setOperatorId(oleSerialReceivingHistory.getOperatorId());
1087                 newSerialReceivingHistory.setMachineId(oleSerialReceivingHistory.getMachineId());
1088                 newSerialReceivingHistory.setReceiptStatus(oleSerialReceivingHistory.getReceiptStatus());
1089                 newSerialReceivingHistory.setReceiptDate(oleSerialReceivingHistory.getReceiptDate());
1090                 newSerialReceivingHistory.setPublicReceipt(oleSerialReceivingHistory.getPublicReceipt());
1091                 newSerialReceivingHistory.setStaffOnlyReceipt(oleSerialReceivingHistory.getStaffOnlyReceipt());
1092                 newSerialReceivingHistoryList.add(newSerialReceivingHistory);
1093             }
1094         }
1095         newSerialReceivingDocument.setOleSerialReceivingHistoryList(newSerialReceivingHistoryList);
1096     }
1097 
1098     public void setEnumerationAndChronologyValues(OLESerialReceivingHistory oleSerialReceivingHistory){
1099         String enumCaptionParameter = OLEConstants.ENUMERATION_CAPTION;
1100         StringBuffer enumerationCaption =  new StringBuffer();
1101         enumerationCaption.append(StringUtils.isEmpty(oleSerialReceivingHistory.getEnumerationCaptionLevel1())?"":oleSerialReceivingHistory.getEnumerationCaptionLevel1());
1102         enumerationCaption.append(StringUtils.isEmpty(oleSerialReceivingHistory.getEnumerationCaptionLevel2())?"":getParameter(enumCaptionParameter) + oleSerialReceivingHistory.getEnumerationCaptionLevel2());
1103         enumerationCaption.append(StringUtils.isEmpty(oleSerialReceivingHistory.getEnumerationCaptionLevel3())?"":getParameter(enumCaptionParameter) + oleSerialReceivingHistory.getEnumerationCaptionLevel3());
1104         enumerationCaption.append(StringUtils.isEmpty(oleSerialReceivingHistory.getEnumerationCaptionLevel4())?"":getParameter(enumCaptionParameter) + oleSerialReceivingHistory.getEnumerationCaptionLevel4());
1105         enumerationCaption.append(StringUtils.isEmpty(oleSerialReceivingHistory.getEnumerationCaptionLevel5())?"":getParameter(enumCaptionParameter) + oleSerialReceivingHistory.getEnumerationCaptionLevel5());
1106         enumerationCaption.append(StringUtils.isEmpty(oleSerialReceivingHistory.getEnumerationCaptionLevel6())?"":getParameter(enumCaptionParameter) + oleSerialReceivingHistory.getEnumerationCaptionLevel6());
1107         if(!StringUtils.isEmpty(enumerationCaption.toString())) {
1108             if(enumerationCaption.subSequence(0,1).equals(getParameter(enumCaptionParameter))) {
1109                 enumerationCaption.deleteCharAt(0);
1110             }
1111         }
1112         oleSerialReceivingHistory.setEnumerationCaption(enumerationCaption.toString());
1113         String chronologyCaptionParameter = OLEConstants.CHRONOLOGY_CAPTION;
1114         StringBuffer chronologyCaption =  new StringBuffer();
1115         chronologyCaption.append(StringUtils.isEmpty(oleSerialReceivingHistory.getChronologyCaptionLevel1())?"":oleSerialReceivingHistory.getChronologyCaptionLevel1());
1116         chronologyCaption.append(StringUtils.isEmpty(oleSerialReceivingHistory.getChronologyCaptionLevel2())?"":getParameter(chronologyCaptionParameter) + oleSerialReceivingHistory.getChronologyCaptionLevel2());
1117         chronologyCaption.append(StringUtils.isEmpty(oleSerialReceivingHistory.getChronologyCaptionLevel3())?"":getParameter(chronologyCaptionParameter) + oleSerialReceivingHistory.getChronologyCaptionLevel3());
1118         chronologyCaption.append(StringUtils.isEmpty(oleSerialReceivingHistory.getChronologyCaptionLevel4())?"":getParameter(chronologyCaptionParameter) + oleSerialReceivingHistory.getChronologyCaptionLevel4());
1119         if(!StringUtils.isEmpty(chronologyCaption.toString())) {
1120             if(chronologyCaption.subSequence(0,1).equals(getParameter(chronologyCaptionParameter))) {
1121                 chronologyCaption.deleteCharAt(0);
1122             }
1123         }
1124         oleSerialReceivingHistory.setChronologyCaption(chronologyCaption.toString());
1125     }
1126 
1127     public void populateEnumerationAndChronologyValues(OLESerialReceivingDocument oleSerialReceivingDocument, OLESerialReceivingType oleSerialReceivingType) {
1128         oleSerialReceivingDocument.setSerialReceivingRecordId(oleSerialReceivingType.getSerialReceivingRecordId());
1129         oleSerialReceivingDocument.setReceivingRecordType(oleSerialReceivingType.getReceivingRecordType());
1130         oleSerialReceivingDocument.setActionDate(oleSerialReceivingType.getActionDate());
1131         oleSerialReceivingDocument.setActionInterval(oleSerialReceivingType.getActionInterval());
1132         oleSerialReceivingDocument.setChronologyCaptionLevel1(oleSerialReceivingType.getChronologyCaptionLevel1());
1133         oleSerialReceivingDocument.setChronologyCaptionLevel2(oleSerialReceivingType.getChronologyCaptionLevel2());
1134         oleSerialReceivingDocument.setChronologyCaptionLevel3(oleSerialReceivingType.getChronologyCaptionLevel3());
1135         oleSerialReceivingDocument.setChronologyCaptionLevel4(oleSerialReceivingType.getChronologyCaptionLevel4());
1136         oleSerialReceivingDocument.setEnumerationCaptionLevel1(oleSerialReceivingType.getEnumerationCaptionLevel1());
1137         oleSerialReceivingDocument.setEnumerationCaptionLevel2(oleSerialReceivingType.getEnumerationCaptionLevel2());
1138         oleSerialReceivingDocument.setEnumerationCaptionLevel3(oleSerialReceivingType.getEnumerationCaptionLevel3());
1139         oleSerialReceivingDocument.setEnumerationCaptionLevel4(oleSerialReceivingType.getEnumerationCaptionLevel4());
1140         oleSerialReceivingDocument.setEnumerationCaptionLevel5(oleSerialReceivingType.getEnumerationCaptionLevel5());
1141         oleSerialReceivingDocument.setEnumerationCaptionLevel6(oleSerialReceivingType.getEnumerationCaptionLevel6());
1142     }
1143     public void validateClaim(OLESerialReceivingDocument oleSerialReceivingDocument){
1144         if (StringUtils.isBlank(oleSerialReceivingDocument.getActionInterval())) {
1145             GlobalVariables.getMessageMap().putError(OLEKeyConstants.SERIAL_RECEIVE_ACTIONINTERVAL, OLEKeyConstants.SERIAL_RECEIVE_ACTIONINTERVAL);
1146         }
1147         if (oleSerialReceivingDocument.getActionDate() == null) {
1148             GlobalVariables.getMessageMap().putError(OLEKeyConstants.SERIAL_RECEIVE_ACTIONDATE, OLEKeyConstants.SERIAL_RECEIVE_ACTIONDATE);
1149         }
1150         if (StringUtils.isBlank(oleSerialReceivingDocument.getVendorId())) {
1151             GlobalVariables.getMessageMap().putError(OLEKeyConstants.SERIAL_RECEIVE_VENDOR_ID, OLEKeyConstants.SERIAL_RECEIVE_VENDOR_ID);
1152         }
1153     }
1154 
1155     @Override
1156     public void updateEnumerationAndChronologyValues(OLESerialReceivingDocument oleSerialReceivingDocument, OLESerialReceivingHistory oleSerialReceivingHistory) {
1157         oleSerialReceivingHistory.setEnumerationCaptionLevel1(oleSerialReceivingDocument.getEnumerationHistoryCaptionLevel1());
1158         oleSerialReceivingHistory.setEnumerationCaptionLevel2(oleSerialReceivingDocument.getEnumerationHistoryCaptionLevel2());
1159         oleSerialReceivingHistory.setEnumerationCaptionLevel3(oleSerialReceivingDocument.getEnumerationHistoryCaptionLevel3());
1160         oleSerialReceivingHistory.setEnumerationCaptionLevel4(oleSerialReceivingDocument.getEnumerationHistoryCaptionLevel4());
1161         oleSerialReceivingHistory.setEnumerationCaptionLevel5(oleSerialReceivingDocument.getEnumerationHistoryCaptionLevel5());
1162         oleSerialReceivingHistory.setEnumerationCaptionLevel6(oleSerialReceivingDocument.getEnumerationHistoryCaptionLevel6());
1163 
1164         oleSerialReceivingHistory.setChronologyCaptionLevel1(oleSerialReceivingDocument.getChronologyHistoryCaptionLevel1());
1165         oleSerialReceivingHistory.setChronologyCaptionLevel2(oleSerialReceivingDocument.getChronologyHistoryCaptionLevel2());
1166         oleSerialReceivingHistory.setChronologyCaptionLevel3(oleSerialReceivingDocument.getChronologyHistoryCaptionLevel3());
1167         oleSerialReceivingHistory.setChronologyCaptionLevel4(oleSerialReceivingDocument.getChronologyHistoryCaptionLevel4());
1168     }
1169 
1170     @Override
1171     public void setEnumerationAndChronologyValues(OLESerialReceivingDocument oleSerialReceivingDocument, OLESerialReceivingHistory oleSerialReceivingHistory) {
1172         oleSerialReceivingDocument.setEnumerationHistoryCaptionLevel1(oleSerialReceivingHistory.getEnumerationCaptionLevel1());
1173         oleSerialReceivingDocument.setEnumerationHistoryCaptionLevel2(oleSerialReceivingHistory.getEnumerationCaptionLevel2());
1174         oleSerialReceivingDocument.setEnumerationHistoryCaptionLevel3(oleSerialReceivingHistory.getEnumerationCaptionLevel3());
1175         oleSerialReceivingDocument.setEnumerationHistoryCaptionLevel4(oleSerialReceivingHistory.getEnumerationCaptionLevel4());
1176         oleSerialReceivingDocument.setEnumerationHistoryCaptionLevel5(oleSerialReceivingHistory.getEnumerationCaptionLevel5());
1177         oleSerialReceivingDocument.setEnumerationHistoryCaptionLevel6(oleSerialReceivingHistory.getEnumerationCaptionLevel6());
1178 
1179         oleSerialReceivingDocument.setChronologyHistoryCaptionLevel1(oleSerialReceivingHistory.getChronologyCaptionLevel1());
1180         oleSerialReceivingDocument.setChronologyHistoryCaptionLevel2(oleSerialReceivingHistory.getChronologyCaptionLevel2());
1181         oleSerialReceivingDocument.setChronologyHistoryCaptionLevel3(oleSerialReceivingHistory.getChronologyCaptionLevel3());
1182         oleSerialReceivingDocument.setChronologyHistoryCaptionLevel4(oleSerialReceivingHistory.getChronologyCaptionLevel4());
1183     }
1184 
1185 }