001/**
002 * Copyright 2005-2015 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.rice.kim.impl.role;
017
018import javax.persistence.Column;
019import javax.persistence.Convert;
020import javax.persistence.Entity;
021import javax.persistence.GeneratedValue;
022import javax.persistence.Id;
023import javax.persistence.Table;
024import javax.persistence.Transient;
025
026import org.kuali.rice.kim.api.role.Role;
027import org.kuali.rice.kim.api.services.KimApiServiceLocator;
028import org.kuali.rice.kim.api.type.KimTypeInfoService;
029import org.kuali.rice.kim.framework.role.RoleEbo;
030import org.kuali.rice.kim.impl.type.KimTypeBo;
031import org.kuali.rice.krad.bo.DataObjectBase;
032import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
033import org.kuali.rice.krad.data.jpa.converters.BooleanYNConverter;
034import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator;
035
036/**
037 * This is a copy of the RoleBo except it doesn't load the member information.
038 * Most of the methods in the RoleServiceImpl do not require the member
039 * information so loading all of it adds a lot of extra overhead.
040 *
041 * @author Kuali Rice Team (rice.collab@kuali.org)
042 */
043@Entity
044@Table(name = "KRIM_ROLE_T")
045public class RoleBoLite extends DataObjectBase implements RoleEbo {
046    private static final long serialVersionUID = 1L;
047
048    @PortableSequenceGenerator(name = "KRIM_ROLE_ID_S")
049    @GeneratedValue(generator = "KRIM_ROLE_ID_S")
050    @Id
051    @Column(name = "ROLE_ID")
052    private String id;
053
054    @Column(name = "ROLE_NM")
055    private String name;
056
057    @Column(name = "DESC_TXT")
058    private String description;
059
060    @Column(name = "ACTV_IND")
061    @Convert(converter = BooleanYNConverter.class)
062    private boolean active;
063
064    @Column(name = "KIM_TYP_ID")
065    private String kimTypeId;
066
067    @Column(name = "NMSPC_CD")
068    private String namespaceCode;
069
070    @Transient
071    private String principalName;
072
073    @Transient
074    private String groupNamespaceCode;
075
076    @Transient
077    private String groupName;
078
079    @Transient
080    private String permNamespaceCode;
081
082    @Transient
083    private String permName;
084
085    @Transient
086    private String permTmplNamespaceCode;
087
088    @Transient
089    private String permTmplName;
090
091    @Transient
092    private String respNamespaceCode;
093
094    @Transient
095    private String respName;
096
097    @Transient
098    private String respTmplNamespaceCode;
099
100    @Transient
101    private String respTmplName;
102
103    @Transient
104    private transient KimTypeInfoService kimTypeInfoService;
105
106    public KimTypeBo getKimRoleType() {
107        return KimTypeBo.from(getTypeInfoService().getKimType(kimTypeId));
108    }
109
110    protected KimTypeInfoService getTypeInfoService() {
111        if (kimTypeInfoService == null) {
112            kimTypeInfoService = KimApiServiceLocator.getKimTypeInfoService();
113        }
114        return kimTypeInfoService;
115    }
116
117    public static Role to(RoleBoLite bo) {
118        if (bo == null) {
119            return null;
120        }
121        return Role.Builder.create(bo).build();
122    }
123
124    public static RoleBo from(Role immutable) {
125        if (immutable == null) {
126            return null;
127        }
128        RoleBo bo = new RoleBo();
129        bo.setId(immutable.getId());
130        bo.setName(immutable.getName());
131        bo.setNamespaceCode(immutable.getNamespaceCode());
132        bo.setDescription(immutable.getDescription());
133        bo.setKimTypeId(immutable.getKimTypeId());
134        bo.setActive(immutable.isActive());
135        bo.setVersionNumber(immutable.getVersionNumber());
136        bo.setObjectId(immutable.getObjectId());
137        return bo;
138    }
139
140    public String getId() {
141        return id;
142    }
143
144    public void setId(String id) {
145        this.id = id;
146    }
147
148    public String getName() {
149        return name;
150    }
151
152    public void setName(String name) {
153        this.name = name;
154    }
155
156    public String getDescription() {
157        return description;
158    }
159
160    public void setDescription(String description) {
161        this.description = description;
162    }
163
164    public boolean getActive() {
165        return active;
166    }
167
168    public boolean isActive() {
169        return active;
170    }
171
172    public void setActive(boolean active) {
173        this.active = active;
174    }
175
176    public String getKimTypeId() {
177        return kimTypeId;
178    }
179
180    public void setKimTypeId(String kimTypeId) {
181        this.kimTypeId = kimTypeId;
182    }
183
184    public String getNamespaceCode() {
185        return namespaceCode;
186    }
187
188    public void setNamespaceCode(String namespaceCode) {
189        this.namespaceCode = namespaceCode;
190    }
191
192    public String getPrincipalName() {
193        return principalName;
194    }
195
196    public void setPrincipalName(String principalName) {
197        this.principalName = principalName;
198    }
199
200    public String getGroupNamespaceCode() {
201        return groupNamespaceCode;
202    }
203
204    public void setGroupNamespaceCode(String groupNamespaceCode) {
205        this.groupNamespaceCode = groupNamespaceCode;
206    }
207
208    public String getGroupName() {
209        return groupName;
210    }
211
212    public void setGroupName(String groupName) {
213        this.groupName = groupName;
214    }
215
216    public String getPermNamespaceCode() {
217        return permNamespaceCode;
218    }
219
220    public void setPermNamespaceCode(String permNamespaceCode) {
221        this.permNamespaceCode = permNamespaceCode;
222    }
223
224    public String getPermName() {
225        return permName;
226    }
227
228    public void setPermName(String permName) {
229        this.permName = permName;
230    }
231
232    public String getPermTmplNamespaceCode() {
233        return permTmplNamespaceCode;
234    }
235
236    public void setPermTmplNamespaceCode(String permTmplNamespaceCode) {
237        this.permTmplNamespaceCode = permTmplNamespaceCode;
238    }
239
240    public String getPermTmplName() {
241        return permTmplName;
242    }
243
244    public void setPermTmplName(String permTmplName) {
245        this.permTmplName = permTmplName;
246    }
247
248    public String getRespNamespaceCode() {
249        return respNamespaceCode;
250    }
251
252    public void setRespNamespaceCode(String respNamespaceCode) {
253        this.respNamespaceCode = respNamespaceCode;
254    }
255
256    public String getRespName() {
257        return respName;
258    }
259
260    public void setRespName(String respName) {
261        this.respName = respName;
262    }
263
264    public String getRespTmplNamespaceCode() {
265        return respTmplNamespaceCode;
266    }
267
268    public void setRespTmplNamespaceCode(String respTmplNamespaceCode) {
269        this.respTmplNamespaceCode = respTmplNamespaceCode;
270    }
271
272    public String getRespTmplName() {
273        return respTmplName;
274    }
275
276    public void setRespTmplName(String respTmplName) {
277        this.respTmplName = respTmplName;
278    }
279
280    @Override
281    public void refresh() {
282    }
283}