Coverage Report - org.kuali.rice.krms.impl.validation.ValidationActionTypeServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
ValidationActionTypeServiceImpl
0%
0/20
0%
0/14
3.8
 
 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.krms.impl.validation;
 17  
 
 18  
 import org.apache.commons.lang.StringUtils;
 19  
 import org.kuali.rice.core.api.exception.RiceIllegalArgumentException;
 20  
 import org.kuali.rice.core.api.uif.RemotableAttributeField;
 21  
 import org.kuali.rice.krms.api.repository.action.ActionDefinition;
 22  
 import org.kuali.rice.krms.framework.type.ValidationActionService;
 23  
 import org.kuali.rice.krms.framework.engine.Action;
 24  
 import org.kuali.rice.krms.framework.type.ActionTypeService;
 25  
 import org.kuali.rice.krms.framework.type.ValidationActionType;
 26  
 import org.kuali.rice.krms.framework.type.ValidationActionTypeService;
 27  
 import org.kuali.rice.krms.impl.type.KrmsTypeServiceBase;
 28  
 
 29  
 import javax.jws.WebParam;
 30  
 import java.util.List;
 31  
 
 32  
 /**
 33  
  * @author Kuali Rice Team (rice.collab@kuali.org).
 34  
  */
 35  
 public class ValidationActionTypeServiceImpl extends KrmsTypeServiceBase implements ValidationActionTypeService {
 36  
     private ValidationActionService validationService;
 37  
 
 38  0
     private ValidationActionTypeServiceImpl() {}
 39  
 
 40  
     /**
 41  
      * Factory method for getting a {@link ActionTypeService}
 42  
      * @return a {@link ActionTypeService}
 43  
      */
 44  
     public static ActionTypeService getInstance() {
 45  0
         return new ValidationActionTypeServiceImpl();
 46  
     }
 47  
 
 48  
     @Override
 49  
     public Action loadAction(ActionDefinition validationActionDefinition) {
 50  
 
 51  0
         if (validationActionDefinition == null) { throw new RiceIllegalArgumentException("validationActionDefinition must not be null"); }
 52  0
         if (validationActionDefinition.getAttributes() == null) { throw new RiceIllegalArgumentException("validationActionDefinition must not be null");}
 53  0
         if (!validationActionDefinition.getAttributes().containsKey(ValidationActionTypeService.VALIDATIONS_ACTION_TYPE_CODE_ATTRIBUTE)) {
 54  0
             throw new RiceIllegalArgumentException("validationActionDefinition does not contain an " +
 55  
                     ValidationActionTypeService.VALIDATIONS_ACTION_TYPE_CODE_ATTRIBUTE + " attribute");
 56  
         }
 57  0
         String validationActionTypeCode = validationActionDefinition.getAttributes().get(ValidationActionTypeService.VALIDATIONS_ACTION_TYPE_CODE_ATTRIBUTE);
 58  
 
 59  0
         if (StringUtils.isBlank(validationActionTypeCode)) {
 60  0
             throw new RiceIllegalArgumentException(ValidationActionTypeService.VALIDATIONS_ACTION_TYPE_CODE_ATTRIBUTE + " attribute must not be null or blank");
 61  
         }
 62  
 
 63  0
         if (ValidationActionType.WARNING.getCode().equals(validationActionTypeCode)) {
 64  0
             return new ValidationAction(ValidationActionType.WARNING, validationActionDefinition.getDescription());
 65  
         }
 66  0
         if (ValidationActionType.ERROR.getCode().equals(validationActionTypeCode)) {
 67  0
             return new ValidationAction(ValidationActionType.ERROR, validationActionDefinition.getDescription());
 68  
         }
 69  0
         return null;
 70  
     }
 71  
 
 72  
     @Override
 73  
     public List<RemotableAttributeField> getAttributeFields(@WebParam(name = "krmsTypeId") String krmsTypeId) throws RiceIllegalArgumentException {
 74  0
         RadioButtonTypeServiceUtil radioButtonTypeServiceUtil = new RadioButtonTypeServiceUtil();
 75  0
         return radioButtonTypeServiceUtil.getAttributeFields(krmsTypeId);
 76  
     }
 77  
     
 78  
     @Override
 79  
     public void setValidationService(ValidationActionService mockValidationService) {
 80  0
         if (mockValidationService == null) {
 81  0
             throw new RiceIllegalArgumentException("validationService must not be null");
 82  
         }
 83  0
         this.validationService = mockValidationService;
 84  0
     }
 85  
 }