| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
package org.kuali.rice.kim.bo.role.impl; |
| 17 |
|
|
| 18 |
|
import org.apache.commons.lang.StringUtils; |
| 19 |
|
import org.hibernate.annotations.Fetch; |
| 20 |
|
import org.hibernate.annotations.FetchMode; |
| 21 |
|
import org.hibernate.annotations.Type; |
| 22 |
|
import org.kuali.rice.core.xml.dto.AttributeSet; |
| 23 |
|
import org.kuali.rice.kim.bo.role.KimResponsibility; |
| 24 |
|
import org.kuali.rice.kim.bo.role.dto.KimResponsibilityInfo; |
| 25 |
|
import org.kuali.rice.kim.bo.types.dto.KimTypeAttributeInfo; |
| 26 |
|
import org.kuali.rice.kim.bo.types.dto.KimTypeInfo; |
| 27 |
|
import org.kuali.rice.kim.service.KIMServiceLocatorWeb; |
| 28 |
|
import org.kuali.rice.kim.service.KimTypeInfoService; |
| 29 |
|
import org.kuali.rice.kim.util.KimConstants; |
| 30 |
|
import org.kuali.rice.kns.bo.PersistableBusinessObjectBase; |
| 31 |
|
import org.kuali.rice.kns.service.DataDictionaryService; |
| 32 |
|
import org.kuali.rice.kns.service.KNSServiceLocatorWeb; |
| 33 |
|
import org.springframework.util.AutoPopulatingList; |
| 34 |
|
|
| 35 |
|
import javax.persistence.*; |
| 36 |
|
import java.util.Iterator; |
| 37 |
|
import java.util.List; |
| 38 |
|
|
| 39 |
|
|
| 40 |
|
@author |
| 41 |
|
|
| 42 |
|
@Entity |
| 43 |
|
@Table(name="KRIM_RSP_T") |
|
|
|
| 0% |
Uncovered Elements: 116 (116) |
Complexity: 38 |
Complexity Density: 0.55 |
|
| 44 |
|
public class KimResponsibilityImpl extends PersistableBusinessObjectBase implements KimResponsibility { |
| 45 |
|
|
| 46 |
|
private static final long serialVersionUID = 1L; |
| 47 |
|
|
| 48 |
|
@Id |
| 49 |
|
@Column(name="RSP_ID") |
| 50 |
|
protected String responsibilityId; |
| 51 |
|
@Column(name="NMSPC_CD") |
| 52 |
|
protected String namespaceCode; |
| 53 |
|
@Column(name="NM") |
| 54 |
|
protected String name; |
| 55 |
|
@Column(name="DESC_TXT", length=400) |
| 56 |
|
protected String description; |
| 57 |
|
@Type(type="yes_no") |
| 58 |
|
@Column(name="ACTV_IND") |
| 59 |
|
protected boolean active; |
| 60 |
|
|
| 61 |
|
@OneToMany(targetEntity=ResponsibilityAttributeDataImpl.class,cascade={CascadeType.ALL},fetch=FetchType.EAGER,mappedBy="responsibilityId") |
| 62 |
|
@Fetch(value = FetchMode.SELECT) |
| 63 |
|
|
| 64 |
|
protected List<ResponsibilityAttributeDataImpl> detailObjects = new AutoPopulatingList(ResponsibilityAttributeDataImpl.class); |
| 65 |
|
|
| 66 |
|
@Column(name="RSP_TMPL_ID") |
| 67 |
|
protected String templateId; |
| 68 |
|
@OneToOne(cascade={},fetch=FetchType.EAGER) |
| 69 |
|
@JoinColumn(name="RSP_TMPL_ID", insertable=false, updatable=false) |
| 70 |
|
protected KimResponsibilityTemplateImpl template = new KimResponsibilityTemplateImpl(); |
| 71 |
|
|
| 72 |
|
@OneToMany(targetEntity=RoleResponsibilityImpl.class,cascade={CascadeType.ALL},fetch=FetchType.EAGER,mappedBy="responsibilityId") |
| 73 |
|
@Fetch(value = FetchMode.SELECT) |
| 74 |
|
|
| 75 |
|
protected List<RoleResponsibilityImpl> roleResponsibilities = new AutoPopulatingList(RoleResponsibilityImpl.class); |
| 76 |
|
|
| 77 |
|
|
| 78 |
|
@see |
| 79 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 80 |
0
|
public boolean isActive() {... |
| 81 |
0
|
return active; |
| 82 |
|
} |
| 83 |
|
|
| 84 |
|
|
| 85 |
|
@see |
| 86 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 87 |
0
|
public void setActive(boolean active) {... |
| 88 |
0
|
this.active = active; |
| 89 |
|
} |
| 90 |
|
|
| 91 |
|
|
| 92 |
|
@see |
| 93 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 94 |
0
|
public String getDescription() {... |
| 95 |
0
|
return description; |
| 96 |
|
} |
| 97 |
|
|
| 98 |
|
|
| 99 |
|
@see |
| 100 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 101 |
0
|
public String getResponsibilityId() {... |
| 102 |
0
|
return responsibilityId; |
| 103 |
|
} |
| 104 |
|
|
| 105 |
|
|
| 106 |
|
@see |
| 107 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 108 |
0
|
public String getName() {... |
| 109 |
0
|
return name; |
| 110 |
|
} |
| 111 |
|
|
| 112 |
|
|
| 113 |
|
@see |
| 114 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
| 115 |
0
|
public String getNameToDisplay() {... |
| 116 |
0
|
if(template!=null && StringUtils.equals(template.getName(), name)){ |
| 117 |
0
|
return name; |
| 118 |
|
} else{ |
| 119 |
0
|
return template.getName()+" "+name; |
| 120 |
|
} |
| 121 |
|
} |
| 122 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 123 |
0
|
public void setDescription(String responsibilityDescription) {... |
| 124 |
0
|
this.description = responsibilityDescription; |
| 125 |
|
} |
| 126 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 127 |
0
|
public void setName(String responsibilityName) {... |
| 128 |
0
|
this.name = responsibilityName; |
| 129 |
|
} |
| 130 |
|
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
| 131 |
0
|
public KimResponsibilityInfo toSimpleInfo() {... |
| 132 |
0
|
KimResponsibilityInfo dto = new KimResponsibilityInfo(); |
| 133 |
|
|
| 134 |
0
|
dto.setResponsibilityId( getResponsibilityId() ); |
| 135 |
0
|
dto.setNamespaceCode( getNamespaceCode() ); |
| 136 |
0
|
dto.setName( getName() ); |
| 137 |
0
|
dto.setDescription( getDescription() ); |
| 138 |
0
|
dto.setActive( isActive() ); |
| 139 |
0
|
dto.setDetails( getDetails() ); |
| 140 |
|
|
| 141 |
0
|
return dto; |
| 142 |
|
} |
| 143 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 144 |
0
|
public List<ResponsibilityAttributeDataImpl> getDetailObjects() {... |
| 145 |
0
|
return this.detailObjects; |
| 146 |
|
} |
| 147 |
|
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 148 |
0
|
public void setDetailObjects(List<ResponsibilityAttributeDataImpl> detailObjects) {... |
| 149 |
0
|
this.detailObjects = detailObjects; |
| 150 |
0
|
detailsAsAttributeSet = null; |
| 151 |
|
} |
| 152 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 153 |
0
|
public boolean hasDetails() {... |
| 154 |
0
|
return !detailObjects.isEmpty(); |
| 155 |
|
} |
| 156 |
|
|
| 157 |
|
protected transient AttributeSet detailsAsAttributeSet = null; |
| 158 |
|
|
|
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 4 |
Complexity Density: 0.33 |
|
| 159 |
0
|
public AttributeSet getDetails() {... |
| 160 |
0
|
if ( detailsAsAttributeSet == null ) { |
| 161 |
0
|
KimTypeInfo kimType = getTypeInfoService().getKimType( getTemplate().getKimTypeId() ); |
| 162 |
0
|
AttributeSet m = new AttributeSet(); |
| 163 |
0
|
for ( ResponsibilityAttributeDataImpl data : getDetailObjects() ) { |
| 164 |
0
|
KimTypeAttributeInfo attribute = null; |
| 165 |
0
|
if ( kimType != null ) { |
| 166 |
0
|
attribute = kimType.getAttributeDefinition( data.getKimAttributeId() ); |
| 167 |
|
} |
| 168 |
0
|
if ( attribute != null ) { |
| 169 |
0
|
m.put( attribute.getAttributeName(), data.getAttributeValue() ); |
| 170 |
|
} else { |
| 171 |
0
|
m.put( data.getKimAttribute().getAttributeName(), data.getAttributeValue() ); |
| 172 |
|
} |
| 173 |
|
} |
| 174 |
0
|
detailsAsAttributeSet = m; |
| 175 |
|
} |
| 176 |
0
|
return detailsAsAttributeSet; |
| 177 |
|
} |
| 178 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 179 |
0
|
public KimResponsibilityTemplateImpl getTemplate() {... |
| 180 |
0
|
return this.template; |
| 181 |
|
} |
| 182 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 183 |
0
|
public void setTemplate(KimResponsibilityTemplateImpl template) {... |
| 184 |
0
|
this.template = template; |
| 185 |
|
} |
| 186 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 187 |
0
|
public String getNamespaceCode() {... |
| 188 |
0
|
return this.namespaceCode; |
| 189 |
|
} |
| 190 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 191 |
0
|
public void setNamespaceCode(String namespaceCode) {... |
| 192 |
0
|
this.namespaceCode = namespaceCode; |
| 193 |
|
} |
| 194 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 195 |
0
|
public String getTemplateId() {... |
| 196 |
0
|
return this.templateId; |
| 197 |
|
} |
| 198 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 199 |
0
|
public void setTemplateId(String templateId) {... |
| 200 |
0
|
this.templateId = templateId; |
| 201 |
|
} |
| 202 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 203 |
0
|
public void setResponsibilityId(String responsibilityId) {... |
| 204 |
0
|
this.responsibilityId = responsibilityId; |
| 205 |
|
} |
| 206 |
|
|
| 207 |
|
|
| 208 |
|
@return |
| 209 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 210 |
0
|
public List<RoleResponsibilityImpl> getRoleResponsibilities() {... |
| 211 |
0
|
return this.roleResponsibilities; |
| 212 |
|
} |
| 213 |
|
|
| 214 |
|
|
| 215 |
|
@param |
| 216 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 217 |
0
|
public void setRoleResponsibilities(... |
| 218 |
|
List<RoleResponsibilityImpl> roleResponsibilities) { |
| 219 |
0
|
this.roleResponsibilities = roleResponsibilities; |
| 220 |
|
} |
| 221 |
|
|
| 222 |
|
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 3 |
Complexity Density: 0.38 |
|
| 223 |
0
|
public String getDetailObjectsValues(){... |
| 224 |
0
|
StringBuffer detailObjectsToDisplay = new StringBuffer(); |
| 225 |
0
|
Iterator<ResponsibilityAttributeDataImpl> respIter = getDetailObjects().iterator(); |
| 226 |
0
|
while ( respIter.hasNext() ) { |
| 227 |
0
|
ResponsibilityAttributeDataImpl responsibilityAttributeData = respIter.next(); |
| 228 |
0
|
detailObjectsToDisplay.append( responsibilityAttributeData.getAttributeValue() ); |
| 229 |
0
|
if ( respIter.hasNext() ) { |
| 230 |
0
|
detailObjectsToDisplay.append( KimConstants.KimUIConstants.COMMA_SEPARATOR ); |
| 231 |
|
} |
| 232 |
|
} |
| 233 |
0
|
return detailObjectsToDisplay.toString(); |
| 234 |
|
} |
| 235 |
|
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 3 |
Complexity Density: 0.27 |
|
| 236 |
0
|
public String getDetailObjectsToDisplay() {... |
| 237 |
0
|
KimTypeInfo kimType = getTypeInfoService().getKimType( getTemplate().getKimTypeId() ); |
| 238 |
0
|
StringBuffer detailObjectsToDisplay = new StringBuffer(); |
| 239 |
0
|
Iterator<ResponsibilityAttributeDataImpl> respIter = getDetailObjects().iterator(); |
| 240 |
0
|
while ( respIter.hasNext() ) { |
| 241 |
0
|
ResponsibilityAttributeDataImpl responsibilityAttributeData = respIter.next(); |
| 242 |
0
|
detailObjectsToDisplay.append( getKimAttributeLabelFromDD(kimType.getAttributeDefinition(responsibilityAttributeData.getKimAttributeId()))); |
| 243 |
0
|
detailObjectsToDisplay.append( KimConstants.KimUIConstants.NAME_VALUE_SEPARATOR ); |
| 244 |
0
|
detailObjectsToDisplay.append( responsibilityAttributeData.getAttributeValue() ); |
| 245 |
0
|
if ( respIter.hasNext() ) { |
| 246 |
0
|
detailObjectsToDisplay.append( KimConstants.KimUIConstants.COMMA_SEPARATOR ); |
| 247 |
|
} |
| 248 |
|
} |
| 249 |
0
|
return detailObjectsToDisplay.toString(); |
| 250 |
|
} |
| 251 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 252 |
0
|
protected String getKimAttributeLabelFromDD( KimTypeAttributeInfo attribute ){... |
| 253 |
0
|
return getDataDictionaryService().getAttributeLabel(attribute.getComponentName(), attribute.getAttributeName() ); |
| 254 |
|
} |
| 255 |
|
|
| 256 |
|
transient private DataDictionaryService dataDictionaryService; |
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 257 |
0
|
public DataDictionaryService getDataDictionaryService() {... |
| 258 |
0
|
if(dataDictionaryService == null){ |
| 259 |
0
|
dataDictionaryService = KNSServiceLocatorWeb.getDataDictionaryService(); |
| 260 |
|
} |
| 261 |
0
|
return dataDictionaryService; |
| 262 |
|
} |
| 263 |
|
|
| 264 |
|
private transient static KimTypeInfoService kimTypeInfoService; |
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 265 |
0
|
protected KimTypeInfoService getTypeInfoService() {... |
| 266 |
0
|
if(kimTypeInfoService == null){ |
| 267 |
0
|
kimTypeInfoService = KIMServiceLocatorWeb.getTypeInfoService(); |
| 268 |
|
} |
| 269 |
0
|
return kimTypeInfoService; |
| 270 |
|
} |
| 271 |
|
} |