Coverage Report - org.kuali.rice.krad.uif.service.impl.DocumentViewHelperServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
DocumentViewHelperServiceImpl
0%
0/12
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 org.kuali.rice.krad.uif.service.impl;
 17  
 
 18  
 import org.kuali.rice.krad.bo.AdHocRoutePerson;
 19  
 import org.kuali.rice.krad.bo.AdHocRouteWorkgroup;
 20  
 import org.kuali.rice.krad.rule.event.AddAdHocRoutePersonEvent;
 21  
 import org.kuali.rice.krad.rule.event.AddAdHocRouteWorkgroupEvent;
 22  
 import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
 23  
 import org.kuali.rice.krad.service.KualiRuleService;
 24  
 import org.kuali.rice.krad.uif.container.CollectionGroup;
 25  
 import org.kuali.rice.krad.uif.view.View;
 26  
 import org.kuali.rice.krad.web.form.DocumentFormBase;
 27  
 
 28  
 /**
 29  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 30  
  */
 31  0
 public class DocumentViewHelperServiceImpl extends ViewHelperServiceImpl {
 32  
 
 33  
     private KualiRuleService kualiRuleService;
 34  
 
 35  
     /**
 36  
      * Performs validation on the new collection line before it is added to the
 37  
      * corresponding collection
 38  
      *
 39  
      * @param view - view instance that the action was taken on
 40  
      * @param collectionGroup - collection group component for the collection
 41  
      * @param addLine - new line instance to validate
 42  
      * @param model - object instance that contains the views data
 43  
      * @return boolean true if the line is valid and it should be added to the
 44  
      *         collection, false if it was not valid and should not be added to
 45  
      *         the collection
 46  
      */
 47  
     @Override
 48  
     protected boolean performAddLineValidation(View view, CollectionGroup collectionGroup, Object model,
 49  
             Object addLine) {
 50  0
         boolean isValidLine = true;
 51  
 
 52  0
         if (model instanceof DocumentFormBase && addLine instanceof AdHocRoutePerson) {
 53  0
             DocumentFormBase form = (DocumentFormBase) model;
 54  0
             isValidLine = getKualiRuleService()
 55  
                     .applyRules(new AddAdHocRoutePersonEvent(form.getDocument(), (AdHocRoutePerson) addLine));
 56  0
         } else if (model instanceof DocumentFormBase && addLine instanceof AdHocRouteWorkgroup) {
 57  0
             DocumentFormBase form = (DocumentFormBase) model;
 58  0
             isValidLine = getKualiRuleService()
 59  
                     .applyRules(new AddAdHocRouteWorkgroupEvent(form.getDocument(), (AdHocRouteWorkgroup) addLine));
 60  
         }
 61  
 
 62  0
         return isValidLine;
 63  
     }
 64  
 
 65  
     protected KualiRuleService getKualiRuleService() {
 66  0
         if (kualiRuleService == null) {
 67  0
             kualiRuleService = KRADServiceLocatorWeb.getKualiRuleService();
 68  
         }
 69  0
         return this.kualiRuleService;
 70  
     }
 71  
 }