001/**
002 * Copyright 2005-2017 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.bo.ui;
017
018import javax.persistence.CascadeType;
019import javax.persistence.Column;
020import javax.persistence.Convert;
021import javax.persistence.Entity;
022import javax.persistence.GeneratedValue;
023import javax.persistence.Id;
024import javax.persistence.JoinColumn;
025import javax.persistence.ManyToOne;
026import javax.persistence.Table;
027import javax.persistence.Transient;
028
029import org.eclipse.persistence.annotations.JoinFetch;
030import org.eclipse.persistence.annotations.JoinFetchType;
031import org.kuali.rice.kew.api.util.CodeTranslator;
032import org.kuali.rice.kim.api.responsibility.Responsibility;
033import org.kuali.rice.kim.api.services.KimApiServiceLocator;
034import org.kuali.rice.kim.impl.responsibility.ResponsibilityBo;
035import org.kuali.rice.kim.impl.role.RoleResponsibilityBo;
036import org.kuali.rice.krad.data.KradDataServiceLocator;
037import org.kuali.rice.krad.data.jpa.converters.BooleanYNConverter;
038import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator;
039
040/**
041 * This is a description of what this class does - shyu don't forget to fill this in. 
042 * 
043 * @author Kuali Rice Team (rice.collab@kuali.org)
044 *
045 */
046@Entity
047@Table(name = "KRIM_PND_ROLE_RSP_ACTN_MT")
048public class KimDocumentRoleResponsibilityAction extends KimDocumentBoEditableBase {
049
050    private static final long serialVersionUID = 696663543888096105L;
051
052    @PortableSequenceGenerator(name = "KRIM_ROLE_RSP_ACTN_ID_S")
053    @GeneratedValue(generator = "KRIM_ROLE_RSP_ACTN_ID_S")
054    @Id
055    @Column(name = "ROLE_RSP_ACTN_ID")
056    protected String roleResponsibilityActionId;
057
058    @Column(name = "ROLE_RSP_ID")
059    protected String roleResponsibilityId;
060
061    @Column(name = "ROLE_MBR_ID")
062    protected String roleMemberId;
063
064    @Column(name = "ACTN_TYP_CD")
065    protected String actionTypeCode;
066
067    @Column(name = "ACTN_PLCY_CD")
068    protected String actionPolicyCode;
069
070    @Column(name = "PRIORITY_NBR")
071    protected Integer priorityNumber;
072
073    @Column(name = "FRC_ACTN")
074    @Convert(converter = BooleanYNConverter.class)
075    protected boolean forceAction;
076
077    // temporary default value in lieu of optimistic locking                       
078//    @Column(name = "VER_NBR")
079//    protected Long versionNumber = (long) 0;
080
081    @Transient
082    protected ResponsibilityBo kimResponsibility;
083
084    @JoinFetch(value= JoinFetchType.OUTER)
085    @ManyToOne(targetEntity = RoleResponsibilityBo.class, cascade = { CascadeType.REFRESH })
086    @JoinColumn(name = "ROLE_RSP_ID", referencedColumnName = "ROLE_RSP_ID", insertable = false, updatable = false)
087    protected RoleResponsibilityBo roleResponsibility;
088
089    /*{
090                roleResponsibility = new RoleResponsibilityImpl();
091                roleResponsibility.setKimResponsibility(new KimResponsibilityImpl());
092                roleResponsibility.getKimResponsibility().setTemplate(new KimResponsibilityTemplateImpl());
093        }*/
094    /**
095         * @return the kimResponsibility
096         */
097    public ResponsibilityBo getKimResponsibility() {
098        if (kimResponsibility == null && getRoleResponsibility() != null) {
099            //TODO: this needs to be changed to use the KimResponsibilityInfo object                       
100            // but the changes are involved in the UiDocumentService based on the copyProperties method used                       
101            // to move the data to/from the document/real objects                       
102            Responsibility info = KimApiServiceLocator.getResponsibilityService().getResponsibility(getRoleResponsibility().getResponsibilityId());
103            kimResponsibility = ResponsibilityBo.from(info);
104        }
105        return kimResponsibility;
106    }
107
108    /**
109         * @param kimResponsibility the kimResponsibility to set
110         */
111    public void setKimResponsibility(ResponsibilityBo kimResponsibility) {
112        this.kimResponsibility = kimResponsibility;
113    }
114
115    public String getRoleResponsibilityActionId() {
116        return this.roleResponsibilityActionId;
117    }
118
119    public void setRoleResponsibilityActionId(String roleResponsibilityResolutionId) {
120        this.roleResponsibilityActionId = roleResponsibilityResolutionId;
121    }
122
123    public String getRoleResponsibilityId() {
124        return this.roleResponsibilityId;
125    }
126
127    public void setRoleResponsibilityId(String roleResponsibilityId) {
128        this.roleResponsibilityId = roleResponsibilityId;
129    }
130
131    public String getActionTypeCode() {
132        return this.actionTypeCode;
133    }
134
135    public void setActionTypeCode(String actionTypeCode) {
136        this.actionTypeCode = actionTypeCode;
137    }
138
139    public Integer getPriorityNumber() {
140        return this.priorityNumber;
141    }
142
143    public void setPriorityNumber(Integer priorityNumber) {
144        this.priorityNumber = priorityNumber;
145    }
146
147    public String getActionPolicyCode() {
148        return this.actionPolicyCode;
149    }
150
151    public void setActionPolicyCode(String actionPolicyCode) {
152        this.actionPolicyCode = actionPolicyCode;
153    }
154
155    public String getRoleMemberId() {
156        return this.roleMemberId;
157    }
158
159    public void setRoleMemberId(String roleMemberId) {
160        this.roleMemberId = roleMemberId;
161    }
162
163    /**
164         * 
165         * This method fore readonlyalterdisplay
166         * 
167         * @return
168         */
169    public String getActionPolicyDescription() {
170        return CodeTranslator.approvePolicyLabels.get(this.actionPolicyCode);
171    }
172
173    /**
174         * 
175         * This method fore readonlyalterdisplay
176         * 
177         * @return
178         */
179    public String getActionTypeDescription() {
180        return CodeTranslator.arLabels.get(this.actionTypeCode);
181    }
182
183    /**
184         * @return the roleResponsibility
185         */
186    public RoleResponsibilityBo getRoleResponsibility() {
187        if (roleResponsibility == null && roleResponsibilityId != null) {
188            //TODO: this needs to be changed to use the KimResponsibilityInfo object                       
189            // but the changes are involved in the UiDocumentService based on the copyProperties method used                       
190            // to move the data to/from the document/real objects                       
191            roleResponsibility = KradDataServiceLocator.getDataObjectService().find(RoleResponsibilityBo.class, getRoleResponsibilityId());
192        }
193        return roleResponsibility;
194    }
195
196    /**
197         * @param roleResponsibility the roleResponsibility to set
198         */
199    public void setRoleResponsibility(RoleResponsibilityBo roleResponsibility) {
200        this.roleResponsibility = roleResponsibility;
201    }
202
203    /**
204         * @return the forceAction
205         */
206    public boolean isForceAction() {
207        return this.forceAction;
208    }
209
210    /**
211         * @param forceAction the forceAction to set
212         */
213    public void setForceAction(boolean forceAction) {
214        this.forceAction = forceAction;
215    }
216}