1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.gl.service.impl;
17
18 import java.util.HashMap;
19 import java.util.List;
20 import java.util.Map;
21
22 import org.apache.commons.codec.binary.Base64;
23 import org.kuali.ole.gl.businessobject.OriginEntryFull;
24 import org.kuali.ole.gl.service.GlCorrectionProcessOriginEntryService;
25 import org.kuali.ole.sys.OLEConstants;
26 import org.kuali.ole.sys.context.SpringContext;
27 import org.kuali.rice.core.api.datetime.DateTimeService;
28 import org.kuali.rice.kns.lookup.LookupResults;
29 import org.kuali.rice.krad.service.BusinessObjectService;
30 import org.kuali.rice.krad.util.GlobalVariables;
31 import org.kuali.rice.krad.util.ObjectUtils;
32 import org.springframework.transaction.annotation.Transactional;
33
34
35
36
37
38
39
40
41 @Transactional
42 public class GlCorrectionProcessOriginEntryServiceImpl implements GlCorrectionProcessOriginEntryService {
43
44 private BusinessObjectService businessObjectService;
45
46
47
48
49
50
51
52
53
54
55 public void persistAllEntries(String glcpSearchResuiltsSequenceNumber, List<OriginEntryFull> allEntries) throws Exception {
56 String serializedOriginEntries = new String(Base64.encodeBase64(ObjectUtils.toByteArray(allEntries)));
57
58 LookupResults lookupResults = retrieveGlcpAllOriginEntries(glcpSearchResuiltsSequenceNumber);
59 if (lookupResults == null) {
60 lookupResults = new LookupResults();
61 lookupResults.setLookupResultsSequenceNumber(glcpSearchResuiltsSequenceNumber);
62 lookupResults.setLookupPersonId(GlobalVariables.getUserSession().getPerson().getPrincipalId());
63 }
64 lookupResults.setLookupDate(SpringContext.getBean(DateTimeService.class).getCurrentTimestamp());
65 lookupResults.setSerializedLookupResults(serializedOriginEntries);
66 businessObjectService.save(lookupResults);
67 }
68
69
70
71
72
73
74
75
76
77 public List<OriginEntryFull> retrieveAllEntries(String glcpSearchResuiltsSequenceNumber) throws Exception {
78 LookupResults lookupResults = retrieveGlcpAllOriginEntries(glcpSearchResuiltsSequenceNumber);
79 if (lookupResults == null) {
80 return null;
81 }
82 List<OriginEntryFull> allOEs = (List<OriginEntryFull>) ObjectUtils.fromByteArray(Base64.decodeBase64(lookupResults.getSerializedLookupResults().getBytes()));
83 return allOEs;
84 }
85
86 protected LookupResults retrieveGlcpAllOriginEntries(String glcpSearchResuiltsSequenceNumber) {
87 Map<String, String> criteria = new HashMap<String, String>();
88 criteria.put(OLEConstants.LOOKUP_RESULTS_SEQUENCE_NUMBER, glcpSearchResuiltsSequenceNumber);
89 LookupResults gaoe = (LookupResults) getBusinessObjectService().findByPrimaryKey(LookupResults.class, criteria);
90 return gaoe;
91 }
92
93
94
95
96
97
98 protected BusinessObjectService getBusinessObjectService() {
99 return businessObjectService;
100 }
101
102
103
104
105
106
107 public void setBusinessObjectService(BusinessObjectService businessObjectService) {
108 this.businessObjectService = businessObjectService;
109 }
110 }
111