View Javadoc

1   /*
2    * Copyright 2007-2009 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 members and
14   * limitations under the License.
15   */
16  package org.kuali.rice.kim.rules.ui;
17  
18  import org.apache.commons.lang.StringUtils;
19  import org.kuali.rice.core.api.util.RiceKeyConstants;
20  import org.kuali.rice.kim.bo.ui.RoleDocumentDelegationMember;
21  import org.kuali.rice.kim.document.IdentityManagementPersonDocument;
22  import org.kuali.rice.kim.document.rule.AttributeValidationHelper;
23  import org.kuali.rice.kim.rule.event.ui.AddPersonDelegationMemberEvent;
24  import org.kuali.rice.kim.rule.ui.AddPersonDelegationMemberRule;
25  import org.kuali.rice.krad.rules.DocumentRuleBase;
26  import org.kuali.rice.krad.util.GlobalVariables;
27  
28  /**
29   * This is a description of what this class does - shyu don't forget to fill this in. 
30   * 
31   * @author Kuali Rice Team (rice.collab@kuali.org)
32   *
33   */
34  public class PersonDocumentDelegationMemberRule extends DocumentRuleBase implements AddPersonDelegationMemberRule {
35  
36  	public static final String ERROR_PATH = "document.newDelegationMember";
37  
38  	protected AttributeValidationHelper attributeValidationHelper = new AttributeValidationHelper();
39  	
40  	public boolean processAddPersonDelegationMember(AddPersonDelegationMemberEvent addPersonDelegationMemberEvent){
41  		RoleDocumentDelegationMember newDelegationMember = addPersonDelegationMemberEvent.getDelegationMember();
42  		IdentityManagementPersonDocument document = (IdentityManagementPersonDocument)addPersonDelegationMemberEvent.getDocument();
43  	    boolean rulePassed = true;
44          if(newDelegationMember == null){
45              GlobalVariables.getMessageMap().putError(ERROR_PATH, RiceKeyConstants.ERROR_EMPTY_ENTRY, new String[] {"Delegation Member"});
46              return false;
47          }
48          if(StringUtils.isBlank(newDelegationMember.getRoleMemberId())){
49              GlobalVariables.getMessageMap().putError(ERROR_PATH, RiceKeyConstants.ERROR_EMPTY_ENTRY, new String[] {"Role Member"});
50              return false;
51          }
52  		return rulePassed;
53  	} 
54  
55  }