001 /**
002 * Copyright 2005-2012 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 @Transient
056 protected ResponsibilityBo kimResponsibility;
057 @Transient
058 protected List<KimDocumentRoleResponsibilityAction> roleRspActions = new AutoPopulatingList(KimDocumentRoleResponsibilityAction.class);
059 @Transient
060 protected String name;
061 @Transient
062 protected String namespaceCode;
063
064 public String getRoleId() {
065 return roleId;
066 }
067
068 public void setRoleId(String roleId) {
069 this.roleId = roleId;
070 }
071
072 public void setRoleResponsibilityId(String roleResponsibilityId) {
073 this.roleResponsibilityId = roleResponsibilityId;
074 }
075
076 /**
077 * @return the roleResponsibilityId
078 */
079 public String getRoleResponsibilityId() {
080 return this.roleResponsibilityId;
081 }
082
083 /**
084 * @return the kimResponsibility
085 */
086 public ResponsibilityBo getKimResponsibility() {
087 if ( kimResponsibility == null && responsibilityId != null ) {
088 //TODO: this needs to be changed to use the KimResponsibilityInfo object
089 // but the changes are involved in the UiDocumentService based on the copyProperties method used
090 // to move the data to/from the document/real objects
091 Responsibility info = KimApiServiceLocator.getResponsibilityService().getResponsibility(getResponsibilityId());
092 kimResponsibility = ResponsibilityBo.from(info);
093 }
094 return this.kimResponsibility;
095 }
096
097 /**
098 * @param responsibilityId the responsibilityId to set
099 */
100 public void setResponsibilityId(String responsibilityId) {
101 this.responsibilityId = responsibilityId;
102 }
103
104 /**
105 * @param kimResponsibility the kimResponsibility to set
106 */
107 public void setKimResponsibility(ResponsibilityBo kimResponsibility) {
108 this.kimResponsibility = kimResponsibility;
109 }
110
111 /**
112 * @return the responsibilityId
113 */
114 public String getResponsibilityId() {
115 return this.responsibilityId;
116 }
117
118 /**
119 * @return the roleRspActions
120 */
121 public KimDocumentRoleResponsibilityAction getRoleRspAction() {
122 if(this.roleRspActions!=null && this.roleRspActions.size()>0)
123 return this.roleRspActions.get(0);
124 return null;
125 }
126
127 /**
128 * @return the roleRspActions
129 */
130 public List<KimDocumentRoleResponsibilityAction> getRoleRspActions() {
131 return this.roleRspActions;
132 }
133
134 /**
135 * @param roleRspActions the roleRspActions to set
136 */
137 public void setRoleRspActions(
138 List<KimDocumentRoleResponsibilityAction> roleRspActions) {
139 this.roleRspActions = roleRspActions;
140 }
141
142 public String getName(){
143 if( null == kimResponsibility ) {
144 getKimResponsibility();
145 }
146
147 if (null == kimResponsibility) {
148 return "";
149 }
150
151 return kimResponsibility.getName();
152 }
153
154 public String getNamespaceCode(){
155 if( null == kimResponsibility ) {
156 getKimResponsibility();
157 }
158
159 if (null == kimResponsibility) {
160 return "";
161 }
162
163 return kimResponsibility.getNamespaceCode();
164 }
165 }