View Javadoc
1   /**
2    * Copyright 2005-2015 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.CascadeType;
19  import javax.persistence.Column;
20  import javax.persistence.Convert;
21  import javax.persistence.Entity;
22  import javax.persistence.GeneratedValue;
23  import javax.persistence.Id;
24  import javax.persistence.JoinColumn;
25  import javax.persistence.ManyToOne;
26  import javax.persistence.Table;
27  import javax.persistence.Transient;
28  
29  import org.eclipse.persistence.annotations.JoinFetch;
30  import org.eclipse.persistence.annotations.JoinFetchType;
31  import org.kuali.rice.kew.api.util.CodeTranslator;
32  import org.kuali.rice.kim.api.responsibility.Responsibility;
33  import org.kuali.rice.kim.api.services.KimApiServiceLocator;
34  import org.kuali.rice.kim.impl.responsibility.ResponsibilityBo;
35  import org.kuali.rice.kim.impl.role.RoleResponsibilityBo;
36  import org.kuali.rice.krad.data.KradDataServiceLocator;
37  import org.kuali.rice.krad.data.jpa.converters.BooleanYNConverter;
38  import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator;
39  
40  /**
41   * This is a description of what this class does - shyu don't forget to fill this in. 
42   * 
43   * @author Kuali Rice Team (rice.collab@kuali.org)
44   *
45   */
46  @Entity
47  @Table(name = "KRIM_PND_ROLE_RSP_ACTN_MT")
48  public class KimDocumentRoleResponsibilityAction extends KimDocumentBoEditableBase {
49  
50      private static final long serialVersionUID = 696663543888096105L;
51  
52      @PortableSequenceGenerator(name = "KRIM_ROLE_RSP_ACTN_ID_S")
53      @GeneratedValue(generator = "KRIM_ROLE_RSP_ACTN_ID_S")
54      @Id
55      @Column(name = "ROLE_RSP_ACTN_ID")
56      protected String roleResponsibilityActionId;
57  
58      @Column(name = "ROLE_RSP_ID")
59      protected String roleResponsibilityId;
60  
61      @Column(name = "ROLE_MBR_ID")
62      protected String roleMemberId;
63  
64      @Column(name = "ACTN_TYP_CD")
65      protected String actionTypeCode;
66  
67      @Column(name = "ACTN_PLCY_CD")
68      protected String actionPolicyCode;
69  
70      @Column(name = "PRIORITY_NBR")
71      protected Integer priorityNumber;
72  
73      @Column(name = "FRC_ACTN")
74      @Convert(converter = BooleanYNConverter.class)
75      protected boolean forceAction;
76  
77      // temporary default value in lieu of optimistic locking                       
78  //    @Column(name = "VER_NBR")
79  //    protected Long versionNumber = (long) 0;
80  
81      @Transient
82      protected ResponsibilityBo kimResponsibility;
83  
84      @JoinFetch(value= JoinFetchType.OUTER)
85      @ManyToOne(targetEntity = RoleResponsibilityBo.class, cascade = { CascadeType.REFRESH })
86      @JoinColumn(name = "ROLE_RSP_ID", referencedColumnName = "ROLE_RSP_ID", insertable = false, updatable = false)
87      protected RoleResponsibilityBo roleResponsibility;
88  
89      /*{
90  		roleResponsibility = new RoleResponsibilityImpl();
91  		roleResponsibility.setKimResponsibility(new KimResponsibilityImpl());
92  		roleResponsibility.getKimResponsibility().setTemplate(new KimResponsibilityTemplateImpl());
93  	}*/
94      /**
95  	 * @return the kimResponsibility
96  	 */
97      public ResponsibilityBo getKimResponsibility() {
98          if (kimResponsibility == null && getRoleResponsibility() != null) {
99              //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 }