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  
 /**
 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.List;
 19  
 import java.util.Map;
 20  
 
 21  
 import org.kuali.rice.kns.maintenance.KualiMaintainableImpl;
 22  
 import org.kuali.rice.krad.document.MaintenanceDocument;
 23  
 import org.kuali.rice.krad.service.KRADServiceLocator;
 24  
 import edu.sampleu.bookstore.bo.Account;
 25  
 import edu.sampleu.bookstore.bo.Author;
 26  
 import edu.sampleu.bookstore.bo.Book;
 27  
 
 28  
 /**
 29  
  * maintainableClass for Book document. 
 30  
  * Action to be taken before saving the BO
 31  
  */
 32  
 
 33  0
 public class BookMaintainable extends KualiMaintainableImpl {
 34  
 
 35  
         
 36  
         private static final long serialVersionUID = 1L;
 37  
 
 38  
         @Override
 39  
         public void saveBusinessObject() {
 40  
                 // TODO Auto-generated method stub
 41  0
                 Book book = (Book) this.getBusinessObject();
 42  
         
 43  
 
 44  
                 // /-----------------------------------------------------///
 45  
                 // /-----------------------------------------------------///
 46  
                 // /---IF author has to be edited from Book Document-----///
 47  
                 // /---follow the below mentioned code else comment out--///
 48  
                 // /-----------------------------------------------------///
 49  
                 // /-----------------------------------------------------///
 50  0
                 List<Author> authors = book.getAuthors();
 51  0
                 for (Author author : authors) {
 52  0
                         Account account = (Account) author.getExtension();
 53  0
                         if (account != null && account.getAuthorId() == null) {
 54  0
                                 author.setExtension(null);
 55  
                         }
 56  
 
 57  0
                         KRADServiceLocator.getBusinessObjectService().save(author);
 58  
 
 59  0
                         if (account != null && account.getAuthorId() == null) {
 60  0
                                 account.setAuthorId(author.getAuthorId());
 61  0
                                 KRADServiceLocator.getBusinessObjectService().save(account);
 62  
                         }
 63  0
                 }
 64  
 
 65  0
                 book.setAuthors(authors);
 66  0
                 KRADServiceLocator.getBusinessObjectService().save(book);
 67  
 
 68  0
         }
 69  
 
 70  
         @Override
 71  
         public void processAfterCopy(MaintenanceDocument document,
 72  
                         Map<String, String[]> parameters) {
 73  0
                 super.processAfterCopy(document, parameters);
 74  0
                 Book book = ((Book) document.getNewMaintainableObject()
 75  
                                 .getDataObject());
 76  0
                 book.setIsbn(null);
 77  0
         }
 78  
 
 79  
 }