View Javadoc

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.bo.role.impl;
17  
18  import org.hibernate.annotations.Type;
19  import org.kuali.rice.kim.api.services.KimApiServiceLocator;
20  import org.kuali.rice.kim.api.type.KimType;
21  import org.kuali.rice.kim.bo.role.KimPermissionTemplate;
22  import org.kuali.rice.kim.bo.role.dto.KimPermissionTemplateInfo;
23  import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
24  
25  import javax.persistence.Column;
26  import javax.persistence.Entity;
27  import javax.persistence.Id;
28  import javax.persistence.Table;
29  
30  /**
31   * @author Kuali Rice Team (rice.collab@kuali.org)
32   */
33  @Entity
34  @Table(name="KRIM_PERM_TMPL_T")
35  public class KimPermissionTemplateImpl extends PersistableBusinessObjectBase implements KimPermissionTemplate {
36  
37  	private static final long serialVersionUID = 1L;
38  	
39  	@Id
40  	@Column(name="PERM_TMPL_ID")
41  	protected String permissionTemplateId;
42  	@Column(name="NMSPC_CD")
43  	protected String namespaceCode;
44  	@Column(name="NM")
45  	protected String name;
46  	@Column(name="KIM_TYP_ID")
47  	protected String kimTypeId;
48  	@Column(name="DESC_TXT", length=400)
49  	protected String description;
50  	@Type(type="yes_no")
51  	@Column(name="ACTV_IND")
52  	protected boolean active;
53  
54  	public String getKimTypeId() {
55  		return kimTypeId;
56  	}
57  
58  	/**
59  	 * @see org.kuali.rice.krad.bo.MutableInactivatable#isActive()
60  	 */
61  	public boolean isActive() {
62  		return active;
63  	}
64  
65  	/**
66  	 * @see org.kuali.rice.krad.bo.MutableInactivatable#setActive(boolean)
67  	 */
68  	public void setActive(boolean active) {
69  		this.active = active;
70  	}
71  
72  	public KimType getKimType() {
73  		return KimApiServiceLocator.getKimTypeInfoService().getKimType(kimTypeId);
74  	}
75  
76  	/**
77  	 * @see org.kuali.rice.kim.bo.role.KimPermission#getDescription()
78  	 */
79  	public String getDescription() {
80  		return description;
81  	}
82  
83  	/**
84  	 * @see org.kuali.rice.kim.bo.role.KimPermission#getPermissionId()
85  	 */
86  	public String getPermissionTemplateId() {
87  		return permissionTemplateId;
88  	}
89  
90  	/**
91  	 * @see org.kuali.rice.kim.bo.role.KimPermission#getName()
92  	 */
93  	public String getName() {
94  		return name;
95  	}
96  
97  	public void setKimTypeId(String kimTypeId) {
98  		this.kimTypeId = kimTypeId;
99  	}
100 
101 	public void setDescription(String description) {
102 		this.description = description;
103 	}
104 
105 	public void setName(String name) {
106 		this.name = name;
107 	}
108 
109 	public String getNamespaceCode() {
110 		return this.namespaceCode;
111 	}
112 
113 	public void setNamespaceCode(String namespaceCode) {
114 		this.namespaceCode = namespaceCode;
115 	}
116 
117 	public void setPermissionTemplateId(String permissionTemplateId) {
118 		this.permissionTemplateId = permissionTemplateId;
119 	}
120 	
121 	public KimPermissionTemplateInfo toSimpleInfo() {
122 		KimPermissionTemplateInfo dto = new KimPermissionTemplateInfo();
123 		
124 		dto.setPermissionTemplateId( getPermissionTemplateId() );
125 		dto.setName( getName() );
126 		dto.setNamespaceCode( getNamespaceCode() );
127 		dto.setDescription( getDescription() );
128 		dto.setKimTypeId( getKimTypeId() );
129 		dto.setActive( isActive() );
130 		
131 		return dto;
132 	}
133 	
134 }