| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
package org.kuali.rice.kns.datadictionary; |
| 18 | |
|
| 19 | |
import java.util.List; |
| 20 | |
|
| 21 | |
import org.apache.commons.lang.StringUtils; |
| 22 | |
import org.kuali.rice.kns.bo.BusinessObject; |
| 23 | |
import org.kuali.rice.kns.bo.Exporter; |
| 24 | |
import org.kuali.rice.kns.datadictionary.exception.AttributeValidationException; |
| 25 | |
import org.kuali.rice.kns.datadictionary.exception.ClassValidationException; |
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | |
|
| 38 | |
|
| 39 | |
|
| 40 | |
|
| 41 | |
|
| 42 | |
|
| 43 | |
|
| 44 | |
|
| 45 | |
|
| 46 | |
|
| 47 | |
|
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
|
| 52 | |
|
| 53 | |
|
| 54 | |
public class BusinessObjectEntry extends DataDictionaryEntryBase { |
| 55 | |
|
| 56 | |
|
| 57 | |
|
| 58 | |
protected Class<? extends BusinessObject> businessObjectClass; |
| 59 | |
protected Class<? extends BusinessObject> baseBusinessObjectClass; |
| 60 | |
protected Class<? extends Exporter> exporterClass; |
| 61 | |
|
| 62 | 0 | protected boolean boNotesEnabled = false; |
| 63 | |
|
| 64 | |
protected InquiryDefinition inquiryDefinition; |
| 65 | |
protected LookupDefinition lookupDefinition; |
| 66 | |
protected HelpDefinition helpDefinition; |
| 67 | |
|
| 68 | |
protected String titleAttribute; |
| 69 | |
protected String objectLabel; |
| 70 | |
protected String objectDescription; |
| 71 | |
|
| 72 | |
protected List<InactivationBlockingDefinition> inactivationBlockingDefinitions; |
| 73 | |
|
| 74 | |
protected List<String> primaryKeys; |
| 75 | |
|
| 76 | |
protected List<String> groupByAttributesForEffectiveDating; |
| 77 | |
|
| 78 | 0 | public BusinessObjectEntry() {} |
| 79 | |
|
| 80 | |
|
| 81 | |
|
| 82 | |
|
| 83 | |
public String getJstlKey() { |
| 84 | 0 | if (businessObjectClass == null) { |
| 85 | 0 | throw new IllegalStateException("cannot generate JSTL key: businessObjectClass is null"); |
| 86 | |
} |
| 87 | |
|
| 88 | 0 | return (baseBusinessObjectClass != null) ? baseBusinessObjectClass.getSimpleName() : businessObjectClass.getSimpleName(); |
| 89 | |
} |
| 90 | |
|
| 91 | |
public void setBusinessObjectClass(Class<? extends BusinessObject> businessObjectClass) { |
| 92 | 0 | if (businessObjectClass == null) { |
| 93 | 0 | throw new IllegalArgumentException("invalid (null) businessObjectClass"); |
| 94 | |
} |
| 95 | |
|
| 96 | 0 | if ( getRelationships() != null ) { |
| 97 | 0 | for ( RelationshipDefinition rd : getRelationships() ) { |
| 98 | 0 | rd.setSourceClass(businessObjectClass); |
| 99 | |
} |
| 100 | |
} |
| 101 | |
|
| 102 | 0 | this.businessObjectClass = businessObjectClass; |
| 103 | 0 | } |
| 104 | |
|
| 105 | |
public Class<? extends BusinessObject> getBusinessObjectClass() { |
| 106 | 0 | return businessObjectClass; |
| 107 | |
} |
| 108 | |
|
| 109 | |
|
| 110 | |
|
| 111 | |
|
| 112 | |
|
| 113 | |
|
| 114 | |
|
| 115 | |
public void setBaseBusinessObjectClass(Class<? extends BusinessObject> baseBusinessObjectClass) { |
| 116 | |
|
| 117 | 0 | this.baseBusinessObjectClass = baseBusinessObjectClass; |
| 118 | 0 | } |
| 119 | |
|
| 120 | |
public Class<? extends BusinessObject> getBaseBusinessObjectClass() { |
| 121 | 0 | return baseBusinessObjectClass; |
| 122 | |
} |
| 123 | |
|
| 124 | |
public Class<? extends Exporter> getExporterClass() { |
| 125 | 0 | return this.exporterClass; |
| 126 | |
} |
| 127 | |
|
| 128 | |
public void setExporterClass(Class<? extends Exporter> exporterClass) { |
| 129 | 0 | this.exporterClass = exporterClass; |
| 130 | 0 | } |
| 131 | |
|
| 132 | |
public boolean isBoNotesEnabled() { |
| 133 | 0 | return boNotesEnabled; |
| 134 | |
} |
| 135 | |
|
| 136 | |
|
| 137 | |
|
| 138 | |
|
| 139 | |
|
| 140 | |
|
| 141 | |
|
| 142 | |
|
| 143 | |
public void setBoNotesEnabled(boolean boNotesEnabled) { |
| 144 | 0 | this.boNotesEnabled = boNotesEnabled; |
| 145 | 0 | } |
| 146 | |
|
| 147 | |
|
| 148 | |
|
| 149 | |
|
| 150 | |
public boolean hasInquiryDefinition() { |
| 151 | 0 | return (inquiryDefinition != null); |
| 152 | |
} |
| 153 | |
|
| 154 | |
|
| 155 | |
|
| 156 | |
|
| 157 | |
public InquiryDefinition getInquiryDefinition() { |
| 158 | 0 | return inquiryDefinition; |
| 159 | |
} |
| 160 | |
|
| 161 | |
|
| 162 | |
|
| 163 | |
|
| 164 | |
|
| 165 | |
|
| 166 | |
|
| 167 | |
|
| 168 | |
|
| 169 | |
|
| 170 | |
|
| 171 | |
|
| 172 | |
|
| 173 | |
|
| 174 | |
public void setInquiryDefinition(InquiryDefinition inquiryDefinition) { |
| 175 | 0 | this.inquiryDefinition = inquiryDefinition; |
| 176 | 0 | } |
| 177 | |
|
| 178 | |
|
| 179 | |
|
| 180 | |
|
| 181 | |
public boolean hasLookupDefinition() { |
| 182 | 0 | return (lookupDefinition != null); |
| 183 | |
} |
| 184 | |
|
| 185 | |
|
| 186 | |
|
| 187 | |
|
| 188 | |
public LookupDefinition getLookupDefinition() { |
| 189 | 0 | return lookupDefinition; |
| 190 | |
} |
| 191 | |
|
| 192 | |
|
| 193 | |
|
| 194 | |
|
| 195 | |
|
| 196 | |
|
| 197 | |
|
| 198 | |
|
| 199 | |
|
| 200 | |
|
| 201 | |
|
| 202 | |
|
| 203 | |
|
| 204 | |
|
| 205 | |
|
| 206 | |
|
| 207 | |
|
| 208 | |
|
| 209 | |
|
| 210 | |
|
| 211 | |
|
| 212 | |
public void setLookupDefinition(LookupDefinition lookupDefinition) { |
| 213 | 0 | this.lookupDefinition = lookupDefinition; |
| 214 | 0 | } |
| 215 | |
|
| 216 | |
|
| 217 | |
|
| 218 | |
|
| 219 | |
public String getTitleAttribute() { |
| 220 | 0 | return titleAttribute; |
| 221 | |
} |
| 222 | |
|
| 223 | |
|
| 224 | |
|
| 225 | |
|
| 226 | |
|
| 227 | |
|
| 228 | |
|
| 229 | |
|
| 230 | |
|
| 231 | |
|
| 232 | |
|
| 233 | |
public void setTitleAttribute(String titleAttribute) { |
| 234 | 0 | this.titleAttribute = titleAttribute; |
| 235 | 0 | } |
| 236 | |
|
| 237 | |
|
| 238 | |
|
| 239 | |
|
| 240 | |
|
| 241 | |
public void completeValidation() { |
| 242 | |
try { |
| 243 | |
|
| 244 | 0 | if (StringUtils.isBlank(getObjectLabel())) { |
| 245 | 0 | throw new AttributeValidationException("Object label cannot be blank for class " + businessObjectClass.getName()); |
| 246 | |
} |
| 247 | |
|
| 248 | 0 | if (baseBusinessObjectClass != null && !baseBusinessObjectClass.isAssignableFrom(businessObjectClass)) { |
| 249 | 0 | throw new ClassValidationException("The baseBusinessObjectClass " + baseBusinessObjectClass.getName() + |
| 250 | |
" is not a superclass of the businessObjectClass " + businessObjectClass.getName()); |
| 251 | |
} |
| 252 | |
|
| 253 | 0 | super.completeValidation(); |
| 254 | |
|
| 255 | 0 | if (hasInquiryDefinition()) { |
| 256 | 0 | inquiryDefinition.completeValidation(businessObjectClass, null); |
| 257 | |
} |
| 258 | |
|
| 259 | 0 | if (hasLookupDefinition()) { |
| 260 | 0 | lookupDefinition.completeValidation(businessObjectClass, null); |
| 261 | |
} |
| 262 | |
|
| 263 | 0 | if (inactivationBlockingDefinitions != null && !inactivationBlockingDefinitions.isEmpty()) { |
| 264 | 0 | for (InactivationBlockingDefinition inactivationBlockingDefinition : inactivationBlockingDefinitions) { |
| 265 | 0 | inactivationBlockingDefinition.completeValidation(businessObjectClass, null); |
| 266 | |
} |
| 267 | |
} |
| 268 | 0 | } catch ( DataDictionaryException ex ) { |
| 269 | |
|
| 270 | 0 | throw ex; |
| 271 | 0 | } catch ( Exception ex ) { |
| 272 | 0 | throw new DataDictionaryException( "Exception validating " + this, ex); |
| 273 | 0 | } |
| 274 | 0 | } |
| 275 | |
|
| 276 | |
|
| 277 | |
|
| 278 | |
|
| 279 | |
@SuppressWarnings("unchecked") |
| 280 | |
public Class getEntryClass() { |
| 281 | 0 | return businessObjectClass; |
| 282 | |
} |
| 283 | |
|
| 284 | |
|
| 285 | |
|
| 286 | |
|
| 287 | |
|
| 288 | |
public String getFullClassName() { |
| 289 | 0 | return businessObjectClass.getName(); |
| 290 | |
} |
| 291 | |
|
| 292 | |
|
| 293 | |
|
| 294 | |
|
| 295 | |
public String getObjectLabel() { |
| 296 | 0 | return objectLabel; |
| 297 | |
} |
| 298 | |
|
| 299 | |
|
| 300 | |
|
| 301 | |
|
| 302 | |
|
| 303 | |
|
| 304 | |
|
| 305 | |
public void setObjectLabel(String objectLabel) { |
| 306 | 0 | this.objectLabel = objectLabel; |
| 307 | 0 | } |
| 308 | |
|
| 309 | |
|
| 310 | |
|
| 311 | |
|
| 312 | |
public String getObjectDescription() { |
| 313 | 0 | return objectDescription; |
| 314 | |
} |
| 315 | |
|
| 316 | |
|
| 317 | |
|
| 318 | |
|
| 319 | |
|
| 320 | |
|
| 321 | |
|
| 322 | |
public void setObjectDescription(String objectDescription) { |
| 323 | 0 | this.objectDescription = objectDescription; |
| 324 | 0 | } |
| 325 | |
|
| 326 | |
|
| 327 | |
|
| 328 | |
|
| 329 | |
|
| 330 | |
|
| 331 | |
public HelpDefinition getHelpDefinition() { |
| 332 | 0 | return helpDefinition; |
| 333 | |
} |
| 334 | |
|
| 335 | |
|
| 336 | |
|
| 337 | |
|
| 338 | |
|
| 339 | |
|
| 340 | |
|
| 341 | |
|
| 342 | |
|
| 343 | |
|
| 344 | |
|
| 345 | |
|
| 346 | |
|
| 347 | |
public void setHelpDefinition(HelpDefinition helpDefinition) { |
| 348 | 0 | this.helpDefinition = helpDefinition; |
| 349 | 0 | } |
| 350 | |
|
| 351 | |
|
| 352 | |
|
| 353 | |
|
| 354 | |
public String toString() { |
| 355 | 0 | return "BusinessObjectEntry for " + getBusinessObjectClass(); |
| 356 | |
} |
| 357 | |
|
| 358 | |
public List<InactivationBlockingDefinition> getInactivationBlockingDefinitions() { |
| 359 | 0 | return this.inactivationBlockingDefinitions; |
| 360 | |
} |
| 361 | |
|
| 362 | |
public void setInactivationBlockingDefinitions(List<InactivationBlockingDefinition> inactivationBlockingDefinitions) { |
| 363 | 0 | this.inactivationBlockingDefinitions = inactivationBlockingDefinitions; |
| 364 | 0 | } |
| 365 | |
|
| 366 | |
|
| 367 | |
|
| 368 | |
|
| 369 | |
public List<String> getPrimaryKeys() { |
| 370 | 0 | return this.primaryKeys; |
| 371 | |
} |
| 372 | |
|
| 373 | |
|
| 374 | |
|
| 375 | |
|
| 376 | |
public void setPrimaryKeys(List<String> primaryKeys) { |
| 377 | 0 | this.primaryKeys = primaryKeys; |
| 378 | 0 | } |
| 379 | |
|
| 380 | |
public List<String> getGroupByAttributesForEffectiveDating() { |
| 381 | 0 | return this.groupByAttributesForEffectiveDating; |
| 382 | |
} |
| 383 | |
|
| 384 | |
public void setGroupByAttributesForEffectiveDating(List<String> groupByAttributesForEffectiveDating) { |
| 385 | 0 | this.groupByAttributesForEffectiveDating = groupByAttributesForEffectiveDating; |
| 386 | 0 | } |
| 387 | |
|
| 388 | |
|
| 389 | |
|
| 390 | |
|
| 391 | |
@SuppressWarnings("unchecked") |
| 392 | |
@Override |
| 393 | |
public void afterPropertiesSet() throws Exception { |
| 394 | 0 | super.afterPropertiesSet(); |
| 395 | 0 | if ( inactivationBlockingDefinitions != null ) { |
| 396 | 0 | for ( InactivationBlockingDefinition ibd : inactivationBlockingDefinitions ) { |
| 397 | 0 | ibd.setBusinessObjectClass( getBusinessObjectClass() ); |
| 398 | 0 | if (StringUtils.isNotBlank(ibd.getBlockedReferencePropertyName()) && ibd.getBlockedBusinessObjectClass() == null) { |
| 399 | |
|
| 400 | 0 | ibd.setBlockedBusinessObjectClass( DataDictionary.getAttributeClass(businessObjectClass, ibd.getBlockedReferencePropertyName()) ); |
| 401 | |
} |
| 402 | 0 | ibd.setBlockingReferenceBusinessObjectClass(getBusinessObjectClass()); |
| 403 | |
} |
| 404 | |
} |
| 405 | 0 | } |
| 406 | |
} |