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.bo.ui;
017
018 import org.hibernate.annotations.GenericGenerator;
019 import org.hibernate.annotations.Parameter;
020 import org.kuali.rice.kim.api.responsibility.Responsibility;
021 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
022 import org.kuali.rice.kim.impl.responsibility.ResponsibilityBo;
023 import org.springframework.util.AutoPopulatingList;
024
025 import javax.persistence.Column;
026 import javax.persistence.Entity;
027 import javax.persistence.GeneratedValue;
028 import javax.persistence.Id;
029 import javax.persistence.IdClass;
030 import javax.persistence.Table;
031 import javax.persistence.Transient;
032 import java.util.List;
033
034 /**
035 * @author Kuali Rice Team (rice.collab@kuali.org)
036 */
037 @IdClass(KimDocumentRoleResponsibilityId.class)
038 @Entity
039 @Table(name="KRIM_PND_ROLE_RSP_T")
040 public class KimDocumentRoleResponsibility extends KimDocumentBoActivatableBase {
041
042 private static final long serialVersionUID = -4465768714850961538L;
043 @Id
044 @GeneratedValue(generator="KRIM_ROLE_RSP_ACTN_ID_S")
045 @GenericGenerator(name="KRIM_ROLE_RSP_ACTN_ID_S",strategy="org.kuali.rice.core.jpa.spring.RiceNumericStringSequenceStyleGenerator",parameters={
046 @Parameter(name="sequence_name",value="KRIM_ROLE_RSP_ACTN_ID_S"),
047 @Parameter(name="value_column",value="id")
048 })
049 @Column(name="ROLE_RSP_ID")
050 protected String roleResponsibilityId;
051 @Column(name="ROLE_ID")
052 protected String roleId;
053 @Column(name="RSP_ID")
054 protected String responsibilityId;
055 // temporary default value in lieu of optimistic locking
056 @Column(name="VER_NBR")
057 protected Long versionNumber = (long) 0;
058 @Transient
059 protected ResponsibilityBo kimResponsibility;
060 @Transient
061 protected List<KimDocumentRoleResponsibilityAction> roleRspActions = new AutoPopulatingList(KimDocumentRoleResponsibilityAction.class);
062 @Transient
063 protected String name;
064 @Transient
065 protected String namespaceCode;
066
067 public String getRoleId() {
068 return roleId;
069 }
070
071 public void setRoleId(String roleId) {
072 this.roleId = roleId;
073 }
074
075 public void setRoleResponsibilityId(String roleResponsibilityId) {
076 this.roleResponsibilityId = roleResponsibilityId;
077 }
078
079 /**
080 * @return the roleResponsibilityId
081 */
082 public String getRoleResponsibilityId() {
083 return this.roleResponsibilityId;
084 }
085
086 /**
087 * @return the kimResponsibility
088 */
089 public ResponsibilityBo getKimResponsibility() {
090 if ( kimResponsibility == null && responsibilityId != null ) {
091 //TODO: this needs to be changed to use the KimResponsibilityInfo object
092 // but the changes are involved in the UiDocumentService based on the copyProperties method used
093 // to move the data to/from the document/real objects
094 Responsibility info = KimApiServiceLocator.getResponsibilityService().getResponsibility(getResponsibilityId());
095 kimResponsibility = ResponsibilityBo.from(info);
096 }
097 return this.kimResponsibility;
098 }
099
100 /**
101 * @param responsibilityId the responsibilityId to set
102 */
103 public void setResponsibilityId(String responsibilityId) {
104 this.responsibilityId = responsibilityId;
105 }
106
107 /**
108 * @param kimResponsibility the kimResponsibility to set
109 */
110 public void setKimResponsibility(ResponsibilityBo kimResponsibility) {
111 this.kimResponsibility = kimResponsibility;
112 }
113
114 /**
115 * @return the responsibilityId
116 */
117 public String getResponsibilityId() {
118 return this.responsibilityId;
119 }
120
121 /**
122 * @return the roleRspActions
123 */
124 public KimDocumentRoleResponsibilityAction getRoleRspAction() {
125 if(this.roleRspActions!=null && this.roleRspActions.size()>0)
126 return this.roleRspActions.get(0);
127 return null;
128 }
129
130 /**
131 * @return the roleRspActions
132 */
133 public List<KimDocumentRoleResponsibilityAction> getRoleRspActions() {
134 return this.roleRspActions;
135 }
136
137 /**
138 * @param roleRspActions the roleRspActions to set
139 */
140 public void setRoleRspActions(
141 List<KimDocumentRoleResponsibilityAction> roleRspActions) {
142 this.roleRspActions = roleRspActions;
143 }
144
145 public String getName(){
146 if( null == kimResponsibility ) {
147 getKimResponsibility();
148 }
149
150 if (null == kimResponsibility) {
151 return "";
152 }
153
154 return kimResponsibility.getName();
155 }
156
157 public String getNamespaceCode(){
158 if( null == kimResponsibility ) {
159 getKimResponsibility();
160 }
161
162 if (null == kimResponsibility) {
163 return "";
164 }
165
166 return kimResponsibility.getNamespaceCode();
167 }
168 }