1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.gl.batch.service.impl;
17
18 import java.util.Collection;
19 import java.util.HashMap;
20 import java.util.Map;
21
22 import org.kuali.ole.gl.batch.dataaccess.OrganizationReversionUnitOfWorkDao;
23 import org.kuali.ole.gl.batch.service.OrganizationReversionUnitOfWorkService;
24 import org.kuali.ole.gl.businessobject.OrgReversionUnitOfWork;
25 import org.kuali.ole.gl.businessobject.OrgReversionUnitOfWorkCategoryAmount;
26 import org.kuali.rice.krad.service.BusinessObjectService;
27 import org.springframework.transaction.annotation.Transactional;
28
29
30
31
32 @Transactional
33 public class OrganizationReversionUnitOfWorkServiceImpl implements OrganizationReversionUnitOfWorkService {
34 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OrganizationReversionUnitOfWorkServiceImpl.class);
35
36 protected BusinessObjectService businessObjectService;
37 protected OrganizationReversionUnitOfWorkDao orgReversionUnitOfWorkDao;
38
39
40
41
42
43
44
45
46 public OrgReversionUnitOfWork loadCategories(OrgReversionUnitOfWork orgRevUnitOfWork) {
47 Map<String,Object> criteria = new HashMap<String, Object>();
48 criteria.put("chartOfAccountsCode", orgRevUnitOfWork.chartOfAccountsCode);
49 criteria.put("accountNbr", orgRevUnitOfWork.accountNumber);
50 criteria.put("subAccountNbr", orgRevUnitOfWork.subAccountNumber);
51
52 Collection<OrgReversionUnitOfWorkCategoryAmount> categoryAmounts = businessObjectService.findMatching(OrgReversionUnitOfWorkCategoryAmount.class, criteria);
53 Map<String, OrgReversionUnitOfWorkCategoryAmount> categories = orgRevUnitOfWork.getCategoryAmounts();
54 for ( OrgReversionUnitOfWorkCategoryAmount catAmount : categoryAmounts ) {
55 categories.put(catAmount.getCategoryCode(), catAmount);
56 }
57 return orgRevUnitOfWork;
58 }
59
60
61
62
63
64
65
66 public void destroyAllUnitOfWorkSummaries() {
67 orgReversionUnitOfWorkDao.destroyAllUnitOfWorkSummaries();
68 }
69
70
71
72
73
74
75
76 public void save(OrgReversionUnitOfWork orgRevUnitOfWork) {
77 if (LOG.isDebugEnabled()) {
78 LOG.debug("Saving org reversion summary for " + orgRevUnitOfWork.toString() + "; its category keys are: " + orgRevUnitOfWork.getCategoryAmounts().keySet());
79 }
80 businessObjectService.save(orgRevUnitOfWork);
81 for (String category: orgRevUnitOfWork.getCategoryAmounts().keySet()) {
82 final OrgReversionUnitOfWorkCategoryAmount categoryAmount = orgRevUnitOfWork.getCategoryAmounts().get(category);
83 if (LOG.isDebugEnabled()) {
84 LOG.debug("Saving category amount for " + categoryAmount.toString());
85 }
86 businessObjectService.save(categoryAmount);
87 }
88 }
89
90
91
92
93
94
95 public void setBusinessObjectService(BusinessObjectService businessObjectService) {
96 this.businessObjectService = businessObjectService;
97 }
98
99
100
101
102
103
104 public void setOrgReversionUnitOfWorkDao(OrganizationReversionUnitOfWorkDao orgReversionUnitOfWorkDao) {
105 this.orgReversionUnitOfWorkDao = orgReversionUnitOfWorkDao;
106 }
107
108 }