1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.module.purap.service.impl;
17
18 import org.kuali.ole.module.purap.businessobject.ElectronicInvoiceItemMapping;
19 import org.kuali.ole.module.purap.businessobject.ItemType;
20 import org.kuali.ole.module.purap.dataaccess.ElectronicInvoiceItemMappingDao;
21 import org.kuali.ole.module.purap.service.ElectronicInvoiceItemMappingService;
22 import org.kuali.ole.sys.context.SpringContext;
23 import org.kuali.rice.krad.service.BusinessObjectService;
24
25 import java.util.List;
26
27 public class ElectronicInvoiceItemMappingServiceImpl implements ElectronicInvoiceItemMappingService {
28 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ElectronicInvoiceItemMappingServiceImpl.class);
29
30 private ElectronicInvoiceItemMappingDao electronicInvoiceItemMappingDao;
31
32 public void setElectronicInvoiceItemMappingDao(ElectronicInvoiceItemMappingDao d) {
33 this.electronicInvoiceItemMappingDao = d;
34 }
35
36 public List getAll() {
37 return electronicInvoiceItemMappingDao.getAll();
38 }
39
40 public List getAllItemTypes() {
41 return electronicInvoiceItemMappingDao.getAllItemTypes();
42 }
43
44 public ElectronicInvoiceItemMapping getById(String id) {
45 return electronicInvoiceItemMappingDao.getById(id);
46 }
47
48 public ItemType getItemTypeByCode(String code) {
49 return electronicInvoiceItemMappingDao.getItemTypeByCode(code);
50 }
51
52 public List save(ElectronicInvoiceItemMapping ei) {
53
54
55 ElectronicInvoiceItemMapping existing = electronicInvoiceItemMappingDao.getByUniqueKeys(ei.getVendorHeaderGeneratedIdentifier(), ei.getVendorDetailAssignedIdentifier(), ei.getInvoiceItemTypeCode());
56 if ((existing != null && ei.getInvoiceMapIdentifier() == null) || (ei.getInvoiceMapIdentifier() != null && !existing.getInvoiceMapIdentifier().equals(ei.getInvoiceMapIdentifier()))) {
57
58
59
60
61 } else {
62 SpringContext.getBean(BusinessObjectService.class).save(ei);
63 }
64 return getAll();
65 }
66
67 public List delete(String id) {
68 ElectronicInvoiceItemMapping ei = getById(id);
69
70
71 if (ei.getVendorDetailAssignedIdentifier() == null && ei.getVendorHeaderGeneratedIdentifier() == null) {
72
73
74
75
76 } else {
77 electronicInvoiceItemMappingDao.delete(ei);
78 }
79 return getAll();
80 }
81
82 }