View Javadoc
1   /**
2    * Copyright 2005-2014 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.kuali.rice.kew.api.util.CodeTranslator;
30  import org.kuali.rice.kim.api.responsibility.Responsibility;
31  import org.kuali.rice.kim.api.services.KimApiServiceLocator;
32  import org.kuali.rice.kim.impl.responsibility.ResponsibilityBo;
33  import org.kuali.rice.kim.impl.role.RoleResponsibilityBo;
34  import org.kuali.rice.krad.data.KradDataServiceLocator;
35  import org.kuali.rice.krad.data.jpa.converters.BooleanYNConverter;
36  import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator;
37  
38  /**
39   * This is a description of what this class does - shyu don't forget to fill this in. 
40   * 
41   * @author Kuali Rice Team (rice.collab@kuali.org)
42   *
43   */
44  @Entity
45  @Table(name = "KRIM_PND_ROLE_RSP_ACTN_MT")
46  public class KimDocumentRoleResponsibilityAction extends KimDocumentBoEditableBase {
47  
48      private static final long serialVersionUID = 696663543888096105L;
49  
50      @PortableSequenceGenerator(name = "KRIM_ROLE_RSP_ACTN_ID_S")
51      @GeneratedValue(generator = "KRIM_ROLE_RSP_ACTN_ID_S")
52      @Id
53      @Column(name = "ROLE_RSP_ACTN_ID")
54      protected String roleResponsibilityActionId;
55  
56      @Column(name = "ROLE_RSP_ID")
57      protected String roleResponsibilityId;
58  
59      @Column(name = "ROLE_MBR_ID")
60      protected String roleMemberId;
61  
62      @Column(name = "ACTN_TYP_CD")
63      protected String actionTypeCode;
64  
65      @Column(name = "ACTN_PLCY_CD")
66      protected String actionPolicyCode;
67  
68      @Column(name = "PRIORITY_NBR")
69      protected Integer priorityNumber;
70  
71      @Column(name = "FRC_ACTN")
72      @Convert(converter = BooleanYNConverter.class)
73      protected boolean forceAction;
74  
75      // temporary default value in lieu of optimistic locking                       
76  //    @Column(name = "VER_NBR")
77  //    protected Long versionNumber = (long) 0;
78  
79      @Transient
80      protected ResponsibilityBo kimResponsibility;
81  
82      @ManyToOne(targetEntity = RoleResponsibilityBo.class, cascade = { CascadeType.REFRESH })
83      @JoinColumn(name = "ROLE_RSP_ID", referencedColumnName = "ROLE_RSP_ID", insertable = false, updatable = false)
84      protected RoleResponsibilityBo roleResponsibility;
85  
86      /*{
87  		roleResponsibility = new RoleResponsibilityImpl();
88  		roleResponsibility.setKimResponsibility(new KimResponsibilityImpl());
89  		roleResponsibility.getKimResponsibility().setTemplate(new KimResponsibilityTemplateImpl());
90  	}*/
91      /**
92  	 * @return the kimResponsibility
93  	 */
94      public ResponsibilityBo getKimResponsibility() {
95          if (kimResponsibility == null && getRoleResponsibility() != null) {
96              //TODO: this needs to be changed to use the KimResponsibilityInfo object                       
97              // but the changes are involved in the UiDocumentService based on the copyProperties method used                       
98              // to move the data to/from the document/real objects                       
99              Responsibility info = KimApiServiceLocator.getResponsibilityService().getResponsibility(getRoleResponsibility().getResponsibilityId());
100             kimResponsibility = ResponsibilityBo.from(info);
101         }
102         return kimResponsibility;
103     }
104 
105     /**
106 	 * @param kimResponsibility the kimResponsibility to set
107 	 */
108     public void setKimResponsibility(ResponsibilityBo kimResponsibility) {
109         this.kimResponsibility = kimResponsibility;
110     }
111 
112     public String getRoleResponsibilityActionId() {
113         return this.roleResponsibilityActionId;
114     }
115 
116     public void setRoleResponsibilityActionId(String roleResponsibilityResolutionId) {
117         this.roleResponsibilityActionId = roleResponsibilityResolutionId;
118     }
119 
120     public String getRoleResponsibilityId() {
121         return this.roleResponsibilityId;
122     }
123 
124     public void setRoleResponsibilityId(String roleResponsibilityId) {
125         this.roleResponsibilityId = roleResponsibilityId;
126     }
127 
128     public String getActionTypeCode() {
129         return this.actionTypeCode;
130     }
131 
132     public void setActionTypeCode(String actionTypeCode) {
133         this.actionTypeCode = actionTypeCode;
134     }
135 
136     public Integer getPriorityNumber() {
137         return this.priorityNumber;
138     }
139 
140     public void setPriorityNumber(Integer priorityNumber) {
141         this.priorityNumber = priorityNumber;
142     }
143 
144     public String getActionPolicyCode() {
145         return this.actionPolicyCode;
146     }
147 
148     public void setActionPolicyCode(String actionPolicyCode) {
149         this.actionPolicyCode = actionPolicyCode;
150     }
151 
152     public String getRoleMemberId() {
153         return this.roleMemberId;
154     }
155 
156     public void setRoleMemberId(String roleMemberId) {
157         this.roleMemberId = roleMemberId;
158     }
159 
160     /**
161 	 * 
162 	 * This method fore readonlyalterdisplay
163 	 * 
164 	 * @return
165 	 */
166     public String getActionPolicyDescription() {
167         return CodeTranslator.approvePolicyLabels.get(this.actionPolicyCode);
168     }
169 
170     /**
171 	 * 
172 	 * This method fore readonlyalterdisplay
173 	 * 
174 	 * @return
175 	 */
176     public String getActionTypeDescription() {
177         return CodeTranslator.arLabels.get(this.actionTypeCode);
178     }
179 
180     /**
181 	 * @return the roleResponsibility
182 	 */
183     public RoleResponsibilityBo getRoleResponsibility() {
184         if (roleResponsibility == null && roleResponsibilityId != null) {
185             //TODO: this needs to be changed to use the KimResponsibilityInfo object                       
186             // but the changes are involved in the UiDocumentService based on the copyProperties method used                       
187             // to move the data to/from the document/real objects                       
188             roleResponsibility = KradDataServiceLocator.getDataObjectService().find(RoleResponsibilityBo.class, getRoleResponsibilityId());
189         }
190         return roleResponsibility;
191     }
192 
193     /**
194 	 * @param roleResponsibility the roleResponsibility to set
195 	 */
196     public void setRoleResponsibility(RoleResponsibilityBo roleResponsibility) {
197         this.roleResponsibility = roleResponsibility;
198     }
199 
200     /**
201 	 * @return the forceAction
202 	 */
203     public boolean isForceAction() {
204         return this.forceAction;
205     }
206 
207     /**
208 	 * @param forceAction the forceAction to set
209 	 */
210     public void setForceAction(boolean forceAction) {
211         this.forceAction = forceAction;
212     }
213 }