View Javadoc

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.kim.bo.ui;
17  
18  import javax.persistence.Column;
19  import javax.persistence.Entity;
20  import javax.persistence.GeneratedValue;
21  import javax.persistence.Id;
22  import javax.persistence.IdClass;
23  import javax.persistence.Table;
24  import javax.persistence.Transient;
25  
26  import org.apache.commons.lang.StringUtils;
27  import org.hibernate.annotations.GenericGenerator;
28  import org.hibernate.annotations.Parameter;
29  import org.kuali.rice.kim.api.permission.Permission;
30  import org.kuali.rice.kim.api.services.KimApiServiceLocator;
31  
32  /**
33   * @author Kuali Rice Team (rice.collab@kuali.org)
34   */
35  @IdClass(KimDocumentRolePermissionId.class)
36  @Entity
37  @Table(name="KRIM_PND_ROLE_PERM_T")
38  public class KimDocumentRolePermission extends KimDocumentBoActivatableBase {
39  
40  	private static final long serialVersionUID = 1L;
41  	@Id
42  	@GeneratedValue(generator="KRIM_ROLE_PERM_ID_S")
43  	@GenericGenerator(name="KRIM_ROLE_PERM_ID_S",strategy="org.kuali.rice.core.jpa.spring.RiceNumericStringSequenceStyleGenerator",parameters={
44  			@Parameter(name="sequence_name",value="KRIM_ROLE_PERM_ID_S"),
45  			@Parameter(name="value_column",value="id")
46  		})
47  	@Column(name="ROLE_PERM_ID")
48  	protected String rolePermissionId;
49  	@Column(name="ROLE_ID")
50  	protected String roleId;
51  	@Column(name="PERM_ID")
52  	protected String permissionId;
53  	@Transient
54  	protected Permission permission;
55  	
56  	public String getPermissionId() {
57  		return permissionId;
58  	}
59  	
60  	public String getRoleId() {
61  		return roleId;
62  	}
63  
64  	public String getRolePermissionId() {
65  		return rolePermissionId;
66  	}
67  
68  	public void setPermissionId(String permissionId) {
69  		this.permissionId = permissionId;
70  	}
71  
72  	public void setRoleId(String roleId) {
73  		this.roleId = roleId;
74  	}
75  
76  	public void setRolePermissionId(String rolePermissionId) {
77  		this.rolePermissionId = rolePermissionId;
78  	}
79  
80  	/**
81  	 * @return the permission
82  	 */
83  	public Permission getPermission() {
84  		if ( permission == null || !StringUtils.equals( permission.getId(), permissionId ) ) {
85  			permission = KimApiServiceLocator.getPermissionService().getPermission(permissionId);
86  		}
87  		return permission;
88  	}
89  
90  	/**
91  	 * @param permission the permission to set
92  	 */
93  	public void setPermission(Permission permission) {
94  		this.permission = permission;
95  	}
96  	
97  }