Coverage Report - edu.sampleu.bookstore.maintenance.BookMaintainable
 
Classes in this File Line Coverage Branch Coverage Complexity
BookMaintainable
0%
0/19
0%
0/10
3.5
 
 1  
 package edu.sampleu.bookstore.maintenance;
 2  
 
 3  
 import java.util.List;
 4  
 import java.util.Map;
 5  
 
 6  
 import org.kuali.rice.kns.maintenance.KualiMaintainableImpl;
 7  
 import org.kuali.rice.krad.document.MaintenanceDocument;
 8  
 import org.kuali.rice.krad.service.KRADServiceLocator;
 9  
 import edu.sampleu.bookstore.bo.Account;
 10  
 import edu.sampleu.bookstore.bo.Author;
 11  
 import edu.sampleu.bookstore.bo.Book;
 12  
 
 13  
 /**
 14  
  * maintainableClass for Book document. 
 15  
  * Action to be taken before saving the BO
 16  
  */
 17  
 
 18  0
 public class BookMaintainable extends KualiMaintainableImpl {
 19  
 
 20  
         
 21  
         private static final long serialVersionUID = 1L;
 22  
 
 23  
         @Override
 24  
         public void saveBusinessObject() {
 25  
                 // TODO Auto-generated method stub
 26  0
                 Book book = (Book) this.getBusinessObject();
 27  
         
 28  
 
 29  
                 // /-----------------------------------------------------///
 30  
                 // /-----------------------------------------------------///
 31  
                 // /---IF author has to be edited from Book Document-----///
 32  
                 // /---follow the below mentioned code else comment out--///
 33  
                 // /-----------------------------------------------------///
 34  
                 // /-----------------------------------------------------///
 35  0
                 List<Author> authors = book.getAuthors();
 36  0
                 for (Author author : authors) {
 37  0
                         Account account = (Account) author.getExtension();
 38  0
                         if (account != null && account.getAuthorId() == null) {
 39  0
                                 author.setExtension(null);
 40  
                         }
 41  
 
 42  0
                         KRADServiceLocator.getBusinessObjectService().save(author);
 43  
 
 44  0
                         if (account != null && account.getAuthorId() == null) {
 45  0
                                 account.setAuthorId(author.getAuthorId());
 46  0
                                 KRADServiceLocator.getBusinessObjectService().save(account);
 47  
                         }
 48  0
                 }
 49  
 
 50  0
                 book.setAuthors(authors);
 51  0
                 KRADServiceLocator.getBusinessObjectService().save(book);
 52  
 
 53  0
         }
 54  
 
 55  
         @Override
 56  
         public void processAfterCopy(MaintenanceDocument document,
 57  
                         Map<String, String[]> parameters) {
 58  0
                 super.processAfterCopy(document, parameters);
 59  0
                 Book book = ((Book) document.getNewMaintainableObject()
 60  
                                 .getDataObject());
 61  0
                 book.setIsbn(null);
 62  0
         }
 63  
 
 64  
 }