001    /**
002     * Copyright 2005-2013 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     */
016    package org.kuali.rice.kim.impl.role;
017    
018    import org.kuali.rice.kim.api.role.RoleResponsibility;
019    import org.kuali.rice.kim.api.role.RoleResponsibilityContract;
020    import org.kuali.rice.kim.impl.responsibility.ResponsibilityBo;
021    import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
022    import org.kuali.rice.krad.data.jpa.converters.BooleanYNConverter;
023    
024    import javax.persistence.Column;
025    import javax.persistence.Entity;
026    import javax.persistence.FetchType;
027    import javax.persistence.Id;
028    import javax.persistence.JoinColumn;
029    import javax.persistence.ManyToOne;
030    import javax.persistence.Table;
031    
032    /**
033     * @author Kuali Rice Team (rice.collab@kuali.org)
034     */
035    @Entity
036    @Table(name = "KRIM_ROLE_RSP_T")
037    public class RoleResponsibilityBo extends PersistableBusinessObjectBase implements RoleResponsibilityContract {
038        private static final long serialVersionUID = 1L;
039        @Id
040        @Column(name = "ROLE_RSP_ID")
041        private String roleResponsibilityId;
042        @Column(name = "ROLE_ID")
043        private String roleId;
044        @Column(name = "RSP_ID")
045        private String responsibilityId;
046        @javax.persistence.Convert(converter=BooleanYNConverter.class)
047        @Column(name = "ACTV_IND")
048        private boolean active;
049        @ManyToOne(targetEntity = ResponsibilityBo.class, fetch = FetchType.EAGER, cascade = {})
050        @JoinColumn(name = "RSP_ID", insertable = false, updatable = false)
051        private ResponsibilityBo kimResponsibility;
052    
053    
054        public static RoleResponsibility to(RoleResponsibilityBo bo) {
055            if (bo == null) {
056                return null;
057            }
058    
059            return RoleResponsibility.Builder.create(bo).build();
060        }
061    
062        public static RoleResponsibilityBo from(RoleResponsibility immutable) {
063            if (immutable == null) {
064                return null;
065            }
066    
067            RoleResponsibilityBo bo = new RoleResponsibilityBo();
068            bo.roleResponsibilityId = immutable.getRoleResponsibilityId();
069            bo.roleId = immutable.getRoleId();
070            bo.responsibilityId = immutable.getResponsibilityId();
071            bo.active = immutable.isActive();
072            bo.setVersionNumber(immutable.getVersionNumber());
073    
074            return bo;
075        }
076    
077        @Override
078        public String getRoleResponsibilityId() {
079            return roleResponsibilityId;
080        }
081    
082        public void setRoleResponsibilityId(String roleResponsibilityId) {
083            this.roleResponsibilityId = roleResponsibilityId;
084        }
085    
086        @Override
087        public String getRoleId() {
088            return roleId;
089        }
090    
091        public void setRoleId(String roleId) {
092            this.roleId = roleId;
093        }
094    
095        @Override
096        public String getResponsibilityId() {
097            return responsibilityId;
098        }
099    
100        public void setResponsibilityId(String responsibilityId) {
101            this.responsibilityId = responsibilityId;
102        }
103    
104        public boolean getActive() {
105            return active;
106        }
107    
108        @Override
109        public boolean isActive() {
110            return active;
111        }
112    
113        public void setActive(boolean active) {
114            this.active = active;
115        }
116    
117        public ResponsibilityBo getKimResponsibility() {
118            return kimResponsibility;
119        }
120    
121        public void setKimResponsibility(ResponsibilityBo kimResponsibility) {
122            this.kimResponsibility = kimResponsibility;
123        }
124    
125    
126    }