Coverage Report - edu.sampleu.bookstore.maintenance.AuthorMaintainable
 
Classes in this File Line Coverage Branch Coverage Complexity
AuthorMaintainable
0%
0/19
0%
0/20
11
 
 1  
 /**
 2  
  * Copyright 2005-2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 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  
  * maintainableClass for Author document.
 29  
  * Action to be taken before saving the BO
 30  
  */
 31  
 
 32  0
 public class AuthorMaintainable extends KualiMaintainableImpl {
 33  
         
 34  
         
 35  
         private static final long serialVersionUID = 1L;
 36  
 
 37  
         @Override
 38  
         public void saveBusinessObject() {
 39  
                 // TODO Auto-generated method stub
 40  0
                 Author author = (Author) this.getBusinessObject();
 41  
                  
 42  0
                 Account account = (Account)author.getExtension();
 43  0
                 if(account != null && account.getAuthorId() == null) {                        
 44  0
                         author.setExtension(null);
 45  
                 }
 46  
                 
 47  0
                 List<Address> addresses = new ArrayList<Address>();
 48  0
                 addresses = author.getAddresses();
 49  0
                 for(Address address : addresses){
 50  0
                         if(address != null && address.getAuthorId() == null) {                        
 51  0
                                 address.setAuthorId(null);
 52  
                         }
 53  
                 }
 54  
                 
 55  0
                 KRADServiceLocator.getBusinessObjectService().save(author);
 56  
                 
 57  0
                 if(account != null && account.getAuthorId() == null) {                        
 58  0
                         account.setAuthorId(author.getAuthorId());                        
 59  0
                         KRADServiceLocator.getBusinessObjectService().save(account);
 60  
                 }
 61  0
                 for(Address address : addresses){
 62  0
                         if(address != null && address.getAuthorId() == null) {                        
 63  0
                                 address.setAuthorId(author.getAuthorId());                        
 64  0
                                 KRADServiceLocator.getBusinessObjectService().save(address);
 65  
                         }
 66  
                 }
 67  0
         }
 68  
 
 69  
 }