Coverage Report - org.kuali.rice.kim.rules.ui.PersonDocumentRoleRule
 
Classes in this File Line Coverage Branch Coverage Complexity
PersonDocumentRoleRule
0%
0/12
0%
0/8
5
 
 1  
 /*
 2  
  * Copyright 2007-2008 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.kim.rules.ui;
 17  
 
 18  
 import java.util.HashMap;
 19  
 import java.util.Map;
 20  
 
 21  
 import org.apache.commons.lang.StringUtils;
 22  
 import org.kuali.rice.kim.bo.impl.KimAttributes;
 23  
 import org.kuali.rice.kim.bo.ui.PersonDocumentRole;
 24  
 import org.kuali.rice.kim.document.IdentityManagementPersonDocument;
 25  
 import org.kuali.rice.kim.document.IdentityManagementRoleDocument;
 26  
 import org.kuali.rice.kim.rule.event.ui.AddRoleEvent;
 27  
 import org.kuali.rice.kim.rule.ui.AddRoleRule;
 28  
 import org.kuali.rice.kim.util.KimConstants;
 29  
 import org.kuali.rice.kns.rules.DocumentRuleBase;
 30  
 import org.kuali.rice.kns.util.GlobalVariables;
 31  
 import org.kuali.rice.kns.util.RiceKeyConstants;
 32  
 
 33  
 /**
 34  
  * This is a description of what this class does - shyu don't forget to fill this in. 
 35  
  * 
 36  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 37  
  *
 38  
  */
 39  0
 public class PersonDocumentRoleRule extends DocumentRuleBase implements AddRoleRule {
 40  
     public static final String ERROR_PATH = "newRole.roleId";
 41  
 
 42  
         public boolean processAddRole(AddRoleEvent addRoleEvent) {
 43  0
                 PersonDocumentRole newRole = addRoleEvent.getRole();
 44  0
                 IdentityManagementPersonDocument document = (IdentityManagementPersonDocument)addRoleEvent.getDocument();
 45  0
                 boolean rulePassed = true;
 46  
 //            List<String> roleIds = KIMServiceLocator.getUiDocumentService().getAssignableRoleIds();
 47  
 
 48  0
         if (newRole == null || StringUtils.isBlank(newRole.getRoleId())) {
 49  0
             rulePassed = false;
 50  0
             GlobalVariables.getMessageMap().putError(ERROR_PATH, RiceKeyConstants.ERROR_EMPTY_ENTRY, new String[] {"Role"});
 51  
                 
 52  
 //        } else if (roleIds.isEmpty() || !roleIds.contains(newRole.getRoleId())) {
 53  
 //            errorMap.putError(ERROR_PATH, RiceKeyConstants.ERROR_ASSIGN_ROLE, new String[] {newRole.getRoleId()});
 54  
 //            rulePassed = false;
 55  
         } else {
 56  0
                     for (PersonDocumentRole role : document.getRoles()) {
 57  0
                             if (role.getRoleId().equals(newRole.getRoleId())) {
 58  0
                             rulePassed = false;
 59  0
                             GlobalVariables.getMessageMap().putError(ERROR_PATH, RiceKeyConstants.ERROR_DUPLICATE_ENTRY, new String[] {"Role"});
 60  
                                     
 61  
                             }
 62  
                     }
 63  
         }
 64  0
                 return rulePassed;
 65  
         } 
 66  
 
 67  
 }