| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.rice.krad.datadictionary; |
| 17 | |
|
| 18 | |
import org.apache.commons.lang.StringUtils; |
| 19 | |
import org.kuali.rice.krad.datadictionary.exception.ClassValidationException; |
| 20 | |
import org.kuali.rice.krad.datadictionary.exception.DuplicateEntryException; |
| 21 | |
import org.kuali.rice.krad.document.Document; |
| 22 | |
import org.kuali.rice.krad.document.authorization.DocumentAuthorizer; |
| 23 | |
import org.kuali.rice.krad.document.authorization.DocumentPresentationController; |
| 24 | |
import org.kuali.rice.krad.keyvalues.KeyValuesFinder; |
| 25 | |
import org.kuali.rice.krad.rule.BusinessRule; |
| 26 | |
|
| 27 | |
import java.util.ArrayList; |
| 28 | |
import java.util.LinkedHashMap; |
| 29 | |
import java.util.List; |
| 30 | |
import java.util.Map; |
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | |
|
| 38 | |
|
| 39 | |
|
| 40 | |
|
| 41 | 0 | abstract public class DocumentEntry extends DataDictionaryEntryBase { |
| 42 | 0 | private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(DocumentEntry.class); |
| 43 | |
private static final long serialVersionUID = 8231730871830055356L; |
| 44 | |
|
| 45 | |
protected String documentTypeName; |
| 46 | |
|
| 47 | |
protected Class<? extends Document> documentClass; |
| 48 | |
protected Class<? extends Document> baseDocumentClass; |
| 49 | |
protected Class<? extends BusinessRule> businessRulesClass; |
| 50 | |
|
| 51 | 0 | protected boolean allowsNoteAttachments = true; |
| 52 | 0 | protected boolean allowsNoteFYI = false; |
| 53 | |
protected Class<? extends KeyValuesFinder> attachmentTypesValuesFinderClass; |
| 54 | 0 | protected boolean displayTopicFieldInNotes = false; |
| 55 | 0 | protected boolean usePessimisticLocking = false; |
| 56 | 0 | protected boolean useWorkflowPessimisticLocking = false; |
| 57 | 0 | protected boolean encryptDocumentDataInPersistentSessionStorage = false; |
| 58 | |
|
| 59 | 0 | protected boolean allowsCopy = false; |
| 60 | |
protected WorkflowProperties workflowProperties; |
| 61 | |
protected WorkflowAttributes workflowAttributes; |
| 62 | |
|
| 63 | 0 | protected List<ReferenceDefinition> defaultExistenceChecks = new ArrayList<ReferenceDefinition>(); |
| 64 | 0 | protected Map<String, ReferenceDefinition> defaultExistenceCheckMap = |
| 65 | |
new LinkedHashMap<String, ReferenceDefinition>(); |
| 66 | |
|
| 67 | |
protected Class<? extends DocumentAuthorizer> documentAuthorizerClass; |
| 68 | |
protected Class<? extends DocumentPresentationController> documentPresentationControllerClass; |
| 69 | |
|
| 70 | |
|
| 71 | |
|
| 72 | |
|
| 73 | |
public String getJstlKey() { |
| 74 | 0 | return documentTypeName; |
| 75 | |
} |
| 76 | |
|
| 77 | |
|
| 78 | |
|
| 79 | |
|
| 80 | |
|
| 81 | |
public void setDocumentClass(Class<? extends Document> documentClass) { |
| 82 | 0 | if (documentClass == null) { |
| 83 | 0 | throw new IllegalArgumentException("invalid (null) documentClass"); |
| 84 | |
} |
| 85 | |
|
| 86 | 0 | this.documentClass = documentClass; |
| 87 | 0 | } |
| 88 | |
|
| 89 | |
public Class<? extends Document> getDocumentClass() { |
| 90 | 0 | return documentClass; |
| 91 | |
} |
| 92 | |
|
| 93 | |
|
| 94 | |
|
| 95 | |
|
| 96 | |
|
| 97 | |
|
| 98 | |
public void setBaseDocumentClass(Class<? extends Document> baseDocumentClass) { |
| 99 | 0 | this.baseDocumentClass = baseDocumentClass; |
| 100 | 0 | } |
| 101 | |
|
| 102 | |
public Class<? extends Document> getBaseDocumentClass() { |
| 103 | 0 | return baseDocumentClass; |
| 104 | |
} |
| 105 | |
|
| 106 | |
|
| 107 | |
|
| 108 | |
|
| 109 | |
|
| 110 | |
public void setBusinessRulesClass(Class<? extends BusinessRule> businessRulesClass) { |
| 111 | 0 | this.businessRulesClass = businessRulesClass; |
| 112 | 0 | } |
| 113 | |
|
| 114 | |
public Class<? extends BusinessRule> getBusinessRulesClass() { |
| 115 | 0 | return businessRulesClass; |
| 116 | |
} |
| 117 | |
|
| 118 | |
|
| 119 | |
|
| 120 | |
|
| 121 | |
|
| 122 | |
|
| 123 | |
public void setDocumentTypeName(String documentTypeName) { |
| 124 | 0 | if (StringUtils.isBlank(documentTypeName)) { |
| 125 | 0 | throw new IllegalArgumentException("invalid (blank) documentTypeName"); |
| 126 | |
} |
| 127 | 0 | this.documentTypeName = documentTypeName; |
| 128 | 0 | } |
| 129 | |
|
| 130 | |
public String getDocumentTypeName() { |
| 131 | 0 | return this.documentTypeName; |
| 132 | |
} |
| 133 | |
|
| 134 | |
|
| 135 | |
|
| 136 | |
|
| 137 | |
|
| 138 | |
|
| 139 | |
public void completeValidation() { |
| 140 | 0 | super.completeValidation(); |
| 141 | |
|
| 142 | 0 | if (baseDocumentClass != null && !baseDocumentClass.isAssignableFrom(documentClass)) { |
| 143 | 0 | throw new ClassValidationException("The baseDocumentClass " + baseDocumentClass.getName() + |
| 144 | |
" is not a superclass of the documentClass " + documentClass.getName()); |
| 145 | |
} |
| 146 | |
|
| 147 | 0 | if (workflowProperties != null && workflowAttributes != null) { |
| 148 | 0 | throw new DataDictionaryException(documentTypeName + |
| 149 | |
": workflowProperties and workflowAttributes cannot both be defined for a document"); |
| 150 | |
} |
| 151 | 0 | } |
| 152 | |
|
| 153 | |
|
| 154 | |
|
| 155 | |
|
| 156 | |
public String getFullClassName() { |
| 157 | 0 | if (getBaseDocumentClass() != null) { |
| 158 | 0 | return getBaseDocumentClass().getName(); |
| 159 | |
} |
| 160 | 0 | if (getDocumentClass() != null) { |
| 161 | 0 | return getDocumentClass().getName(); |
| 162 | |
} |
| 163 | 0 | return ""; |
| 164 | |
} |
| 165 | |
|
| 166 | |
|
| 167 | |
|
| 168 | |
|
| 169 | |
public Class getEntryClass() { |
| 170 | 0 | return getDocumentClass(); |
| 171 | |
} |
| 172 | |
|
| 173 | |
public String toString() { |
| 174 | 0 | return "DocumentEntry for documentType " + documentTypeName; |
| 175 | |
} |
| 176 | |
|
| 177 | |
|
| 178 | |
|
| 179 | |
|
| 180 | |
|
| 181 | |
|
| 182 | |
public boolean getDisplayTopicFieldInNotes() { |
| 183 | 0 | return displayTopicFieldInNotes; |
| 184 | |
} |
| 185 | |
|
| 186 | |
|
| 187 | |
|
| 188 | |
|
| 189 | |
|
| 190 | |
public void setDisplayTopicFieldInNotes(boolean displayTopicFieldInNotes) { |
| 191 | 0 | this.displayTopicFieldInNotes = displayTopicFieldInNotes; |
| 192 | 0 | } |
| 193 | |
|
| 194 | |
|
| 195 | |
|
| 196 | |
|
| 197 | |
|
| 198 | |
|
| 199 | |
public boolean getUsePessimisticLocking() { |
| 200 | 0 | return this.usePessimisticLocking; |
| 201 | |
} |
| 202 | |
|
| 203 | |
|
| 204 | |
|
| 205 | |
|
| 206 | |
public void setUsePessimisticLocking(boolean usePessimisticLocking) { |
| 207 | 0 | if (LOG.isDebugEnabled()) { |
| 208 | 0 | LOG.debug("calling setUsePessimisticLocking '" + usePessimisticLocking + "'"); |
| 209 | |
} |
| 210 | |
|
| 211 | 0 | this.usePessimisticLocking = usePessimisticLocking; |
| 212 | 0 | } |
| 213 | |
|
| 214 | |
|
| 215 | |
|
| 216 | |
|
| 217 | |
|
| 218 | |
|
| 219 | |
public boolean getUseWorkflowPessimisticLocking() { |
| 220 | 0 | return this.useWorkflowPessimisticLocking; |
| 221 | |
} |
| 222 | |
|
| 223 | |
|
| 224 | |
|
| 225 | |
|
| 226 | |
public void setUseWorkflowPessimisticLocking(boolean useWorkflowPessimisticLocking) { |
| 227 | 0 | if (LOG.isDebugEnabled()) { |
| 228 | 0 | LOG.debug("calling setuseWorkflowPessimisticLocking '" + useWorkflowPessimisticLocking + "'"); |
| 229 | |
} |
| 230 | |
|
| 231 | 0 | this.useWorkflowPessimisticLocking = useWorkflowPessimisticLocking; |
| 232 | 0 | } |
| 233 | |
|
| 234 | |
|
| 235 | |
|
| 236 | |
|
| 237 | |
|
| 238 | |
|
| 239 | |
public void setAttachmentTypesValuesFinderClass(Class<? extends KeyValuesFinder> attachmentTypesValuesFinderClass) { |
| 240 | 0 | if (attachmentTypesValuesFinderClass == null) { |
| 241 | 0 | throw new IllegalArgumentException("invalid (null) attachmentTypesValuesFinderClass"); |
| 242 | |
} |
| 243 | |
|
| 244 | 0 | this.attachmentTypesValuesFinderClass = attachmentTypesValuesFinderClass; |
| 245 | 0 | } |
| 246 | |
|
| 247 | |
|
| 248 | |
|
| 249 | |
|
| 250 | |
public Class<? extends KeyValuesFinder> getAttachmentTypesValuesFinderClass() { |
| 251 | 0 | return attachmentTypesValuesFinderClass; |
| 252 | |
} |
| 253 | |
|
| 254 | |
|
| 255 | |
|
| 256 | |
|
| 257 | |
|
| 258 | |
|
| 259 | |
public void setAllowsCopy(boolean allowsCopy) { |
| 260 | 0 | this.allowsCopy = allowsCopy; |
| 261 | 0 | } |
| 262 | |
|
| 263 | |
public boolean getAllowsCopy() { |
| 264 | 0 | return allowsCopy; |
| 265 | |
} |
| 266 | |
|
| 267 | |
|
| 268 | |
|
| 269 | |
|
| 270 | |
public boolean getAllowsNoteAttachments() { |
| 271 | 0 | return this.allowsNoteAttachments; |
| 272 | |
} |
| 273 | |
|
| 274 | |
|
| 275 | |
|
| 276 | |
|
| 277 | |
|
| 278 | |
|
| 279 | |
public void setAllowsNoteAttachments(boolean allowsNoteAttachments) { |
| 280 | 0 | this.allowsNoteAttachments = allowsNoteAttachments; |
| 281 | 0 | } |
| 282 | |
|
| 283 | |
|
| 284 | |
|
| 285 | |
|
| 286 | |
public boolean getAllowsNoteFYI() { |
| 287 | 0 | return allowsNoteFYI; |
| 288 | |
} |
| 289 | |
|
| 290 | |
|
| 291 | |
|
| 292 | |
|
| 293 | |
public void setAllowsNoteFYI(boolean allowsNoteFYI) { |
| 294 | 0 | this.allowsNoteFYI = allowsNoteFYI; |
| 295 | 0 | } |
| 296 | |
|
| 297 | |
public WorkflowProperties getWorkflowProperties() { |
| 298 | 0 | return this.workflowProperties; |
| 299 | |
} |
| 300 | |
|
| 301 | |
|
| 302 | |
|
| 303 | |
|
| 304 | |
|
| 305 | |
|
| 306 | |
public void setWorkflowProperties(WorkflowProperties workflowProperties) { |
| 307 | 0 | this.workflowProperties = workflowProperties; |
| 308 | 0 | } |
| 309 | |
|
| 310 | |
public WorkflowAttributes getWorkflowAttributes() { |
| 311 | 0 | return this.workflowAttributes; |
| 312 | |
} |
| 313 | |
|
| 314 | |
public void setWorkflowAttributes(WorkflowAttributes workflowAttributes) { |
| 315 | 0 | this.workflowAttributes = workflowAttributes; |
| 316 | 0 | } |
| 317 | |
|
| 318 | |
|
| 319 | |
|
| 320 | |
|
| 321 | |
|
| 322 | |
|
| 323 | |
public List<ReferenceDefinition> getDefaultExistenceChecks() { |
| 324 | 0 | return defaultExistenceChecks; |
| 325 | |
} |
| 326 | |
|
| 327 | |
|
| 328 | |
|
| 329 | |
|
| 330 | |
|
| 331 | |
|
| 332 | |
|
| 333 | |
|
| 334 | |
|
| 335 | |
public void setDefaultExistenceChecks(List<ReferenceDefinition> defaultExistenceChecks) { |
| 336 | 0 | this.defaultExistenceChecks = defaultExistenceChecks; |
| 337 | 0 | } |
| 338 | |
|
| 339 | |
|
| 340 | |
|
| 341 | |
|
| 342 | |
|
| 343 | |
|
| 344 | |
public List<String> getDefaultExistenceCheckFieldNames() { |
| 345 | 0 | List<String> fieldNames = new ArrayList<String>(); |
| 346 | 0 | fieldNames.addAll(this.defaultExistenceCheckMap.keySet()); |
| 347 | |
|
| 348 | 0 | return fieldNames; |
| 349 | |
} |
| 350 | |
|
| 351 | |
public boolean isEncryptDocumentDataInPersistentSessionStorage() { |
| 352 | 0 | return this.encryptDocumentDataInPersistentSessionStorage; |
| 353 | |
} |
| 354 | |
|
| 355 | |
public void setEncryptDocumentDataInPersistentSessionStorage( |
| 356 | |
boolean encryptDocumentDataInPersistentSessionStorage) { |
| 357 | 0 | this.encryptDocumentDataInPersistentSessionStorage = encryptDocumentDataInPersistentSessionStorage; |
| 358 | 0 | } |
| 359 | |
|
| 360 | |
|
| 361 | |
|
| 362 | |
|
| 363 | |
|
| 364 | |
|
| 365 | |
public void setDocumentAuthorizerClass(Class<? extends DocumentAuthorizer> documentAuthorizerClass) { |
| 366 | 0 | this.documentAuthorizerClass = documentAuthorizerClass; |
| 367 | 0 | } |
| 368 | |
|
| 369 | |
|
| 370 | |
|
| 371 | |
|
| 372 | |
|
| 373 | |
|
| 374 | |
|
| 375 | |
|
| 376 | |
|
| 377 | |
public Class<? extends DocumentAuthorizer> getDocumentAuthorizerClass() { |
| 378 | 0 | return documentAuthorizerClass; |
| 379 | |
} |
| 380 | |
|
| 381 | |
|
| 382 | |
|
| 383 | |
|
| 384 | |
|
| 385 | |
|
| 386 | |
|
| 387 | |
|
| 388 | |
|
| 389 | |
|
| 390 | |
public Class<? extends DocumentPresentationController> getDocumentPresentationControllerClass() { |
| 391 | 0 | return this.documentPresentationControllerClass; |
| 392 | |
} |
| 393 | |
|
| 394 | |
|
| 395 | |
|
| 396 | |
|
| 397 | |
public void setDocumentPresentationControllerClass( |
| 398 | |
Class<? extends DocumentPresentationController> documentPresentationControllerClass) { |
| 399 | 0 | this.documentPresentationControllerClass = documentPresentationControllerClass; |
| 400 | 0 | } |
| 401 | |
|
| 402 | |
|
| 403 | |
|
| 404 | |
|
| 405 | |
|
| 406 | |
|
| 407 | |
@Override |
| 408 | |
public void afterPropertiesSet() throws Exception { |
| 409 | 0 | super.afterPropertiesSet(); |
| 410 | 0 | if (defaultExistenceChecks != null) { |
| 411 | 0 | defaultExistenceCheckMap.clear(); |
| 412 | 0 | for (ReferenceDefinition reference : defaultExistenceChecks) { |
| 413 | 0 | if (reference == null) { |
| 414 | 0 | throw new IllegalArgumentException("invalid (null) defaultExistenceCheck"); |
| 415 | |
} |
| 416 | |
|
| 417 | 0 | String keyName = reference.isCollectionReference() ? |
| 418 | |
(reference.getCollection() + "." + reference.getAttributeName()) : reference.getAttributeName(); |
| 419 | 0 | if (defaultExistenceCheckMap.containsKey(keyName)) { |
| 420 | 0 | throw new DuplicateEntryException( |
| 421 | |
"duplicate defaultExistenceCheck entry for attribute '" + keyName + "'"); |
| 422 | |
} |
| 423 | 0 | reference.setBusinessObjectClass(getEntryClass()); |
| 424 | 0 | defaultExistenceCheckMap.put(keyName, reference); |
| 425 | 0 | } |
| 426 | |
} |
| 427 | 0 | } |
| 428 | |
} |