1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package edu.sampleu.bookstore.maintenance;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 import org.kuali.rice.kns.maintenance.KualiMaintainableImpl;
22 import org.kuali.rice.krad.service.KRADServiceLocator;
23 import edu.sampleu.bookstore.bo.Account;
24 import edu.sampleu.bookstore.bo.Address;
25 import edu.sampleu.bookstore.bo.Author;
26
27
28
29
30
31
32 public class AuthorMaintainable extends KualiMaintainableImpl {
33
34
35 private static final long serialVersionUID = 1L;
36
37 @Override
38 public void saveBusinessObject() {
39
40 Author author = (Author) this.getBusinessObject();
41
42 Account account = (Account)author.getExtension();
43 if(account != null && account.getAuthorId() == null) {
44 author.setExtension(null);
45 }
46
47 List<Address> addresses = new ArrayList<Address>();
48 addresses = author.getAddresses();
49 for(Address address : addresses){
50 if(address != null && address.getAuthorId() == null) {
51 address.setAuthorId(null);
52 }
53 }
54
55 KRADServiceLocator.getBusinessObjectService().save(author);
56
57 if(account != null && account.getAuthorId() == null) {
58 account.setAuthorId(author.getAuthorId());
59 KRADServiceLocator.getBusinessObjectService().save(account);
60 }
61 for(Address address : addresses){
62 if(address != null && address.getAuthorId() == null) {
63 address.setAuthorId(author.getAuthorId());
64 KRADServiceLocator.getBusinessObjectService().save(address);
65 }
66 }
67 }
68
69 }