| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.rice.kns.service.impl; |
| 17 | |
|
| 18 | |
import java.io.IOException; |
| 19 | |
import java.util.ArrayList; |
| 20 | |
import java.util.Collections; |
| 21 | |
import java.util.HashMap; |
| 22 | |
import java.util.Iterator; |
| 23 | |
import java.util.List; |
| 24 | |
import java.util.Map; |
| 25 | |
import java.util.Set; |
| 26 | |
import java.util.regex.Pattern; |
| 27 | |
|
| 28 | |
import org.apache.commons.lang.StringUtils; |
| 29 | |
import org.apache.log4j.Logger; |
| 30 | |
import org.kuali.rice.core.api.config.property.ConfigurationService; |
| 31 | |
import org.kuali.rice.core.util.ClassLoaderUtils; |
| 32 | |
import org.kuali.rice.core.web.format.Formatter; |
| 33 | |
import org.kuali.rice.kew.dto.DocumentTypeDTO; |
| 34 | |
import org.kuali.rice.kew.exception.WorkflowException; |
| 35 | |
import org.kuali.rice.kns.bo.BusinessObject; |
| 36 | |
import org.kuali.rice.kns.datadictionary.AttributeDefinition; |
| 37 | |
import org.kuali.rice.kns.datadictionary.AttributeSecurity; |
| 38 | |
import org.kuali.rice.kns.datadictionary.BusinessObjectEntry; |
| 39 | |
import org.kuali.rice.kns.datadictionary.CollectionDefinition; |
| 40 | |
import org.kuali.rice.kns.datadictionary.DataDictionary; |
| 41 | |
import org.kuali.rice.kns.datadictionary.DataDictionaryEntryBase; |
| 42 | |
import org.kuali.rice.kns.datadictionary.DocumentEntry; |
| 43 | |
import org.kuali.rice.kns.datadictionary.InactivationBlockingMetadata; |
| 44 | |
import org.kuali.rice.kns.datadictionary.PrimitiveAttributeDefinition; |
| 45 | |
import org.kuali.rice.kns.datadictionary.RelationshipDefinition; |
| 46 | |
import org.kuali.rice.kns.datadictionary.control.ControlDefinition; |
| 47 | |
import org.kuali.rice.kns.datadictionary.exception.UnknownBusinessClassAttributeException; |
| 48 | |
import org.kuali.rice.kns.datadictionary.exception.UnknownDocumentTypeException; |
| 49 | |
import org.kuali.rice.kns.datadictionary.exporter.DataDictionaryMap; |
| 50 | |
import org.kuali.rice.kns.datadictionary.validation.ValidationPattern; |
| 51 | |
import org.kuali.rice.kns.document.Document; |
| 52 | |
import org.kuali.rice.kns.lookup.keyvalues.KeyValuesFinder; |
| 53 | |
import org.kuali.rice.kns.rule.PromptBeforeValidation; |
| 54 | |
import org.kuali.rice.kns.service.DataDictionaryService; |
| 55 | |
import org.kuali.rice.kns.service.KNSServiceLocatorWeb; |
| 56 | |
import org.kuali.rice.kns.service.KualiModuleService; |
| 57 | |
import org.kuali.rice.kns.uif.container.View; |
| 58 | |
import org.kuali.rice.kns.workflow.service.KualiWorkflowInfo; |
| 59 | |
|
| 60 | |
|
| 61 | |
|
| 62 | |
|
| 63 | |
|
| 64 | |
public class DataDictionaryServiceImpl implements DataDictionaryService { |
| 65 | 0 | private static final Logger LOG = Logger.getLogger( DataDictionaryServiceImpl.class ); |
| 66 | |
|
| 67 | |
|
| 68 | |
private DataDictionary dataDictionary; |
| 69 | 0 | private DataDictionaryMap dataDictionaryMap = new DataDictionaryMap(this); |
| 70 | |
|
| 71 | |
private ConfigurationService kualiConfigurationService; |
| 72 | |
private KualiModuleService kualiModuleService; |
| 73 | |
private KualiWorkflowInfo workflowInfoService; |
| 74 | |
|
| 75 | |
|
| 76 | |
|
| 77 | |
|
| 78 | |
|
| 79 | |
public void setBaselinePackages(List baselinePackages) throws IOException { |
| 80 | 0 | this.addDataDictionaryLocations(baselinePackages); |
| 81 | 0 | } |
| 82 | |
|
| 83 | |
|
| 84 | |
|
| 85 | |
|
| 86 | 0 | public DataDictionaryServiceImpl() { |
| 87 | 0 | this.dataDictionary = new DataDictionary(); |
| 88 | 0 | } |
| 89 | |
|
| 90 | 0 | public DataDictionaryServiceImpl(DataDictionary dataDictionary) { |
| 91 | 0 | this.dataDictionary = dataDictionary; |
| 92 | 0 | } |
| 93 | |
|
| 94 | |
|
| 95 | |
|
| 96 | |
|
| 97 | |
public DataDictionary getDataDictionary() { |
| 98 | 0 | return dataDictionary; |
| 99 | |
} |
| 100 | |
|
| 101 | |
|
| 102 | |
|
| 103 | |
|
| 104 | |
public ControlDefinition getAttributeControlDefinition(String entryName, String attributeName) { |
| 105 | 0 | ControlDefinition controlDefinition = null; |
| 106 | |
|
| 107 | 0 | AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName); |
| 108 | 0 | if (attributeDefinition != null) { |
| 109 | 0 | controlDefinition = attributeDefinition.getControl(); |
| 110 | |
} |
| 111 | |
|
| 112 | 0 | return controlDefinition; |
| 113 | |
} |
| 114 | |
|
| 115 | |
|
| 116 | |
|
| 117 | |
|
| 118 | |
public Integer getAttributeSize(String entryName, String attributeName) { |
| 119 | 0 | Integer size = null; |
| 120 | |
|
| 121 | 0 | AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName); |
| 122 | 0 | if (attributeDefinition != null) { |
| 123 | 0 | ControlDefinition controlDefinition = attributeDefinition.getControl(); |
| 124 | 0 | if (controlDefinition.isText() || controlDefinition.isCurrency()) { |
| 125 | 0 | size = controlDefinition.getSize(); |
| 126 | |
} |
| 127 | |
} |
| 128 | |
|
| 129 | 0 | return size; |
| 130 | |
} |
| 131 | |
|
| 132 | |
|
| 133 | |
|
| 134 | |
|
| 135 | |
public Integer getAttributeMinLength(String entryName, String attributeName) { |
| 136 | 0 | Integer minLength = null; |
| 137 | |
|
| 138 | 0 | AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName); |
| 139 | 0 | if (attributeDefinition != null) { |
| 140 | 0 | minLength = attributeDefinition.getMinLength(); |
| 141 | |
} |
| 142 | |
|
| 143 | 0 | return minLength; |
| 144 | |
} |
| 145 | |
|
| 146 | |
|
| 147 | |
|
| 148 | |
|
| 149 | |
public Integer getAttributeMaxLength(String entryName, String attributeName) { |
| 150 | 0 | Integer maxLength = null; |
| 151 | |
|
| 152 | 0 | AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName); |
| 153 | 0 | if (attributeDefinition != null) { |
| 154 | 0 | maxLength = attributeDefinition.getMaxLength(); |
| 155 | |
} |
| 156 | |
|
| 157 | 0 | return maxLength; |
| 158 | |
} |
| 159 | |
|
| 160 | |
|
| 161 | |
|
| 162 | |
|
| 163 | |
public String getAttributeExclusiveMin(String entryName, String attributeName) { |
| 164 | 0 | AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName); |
| 165 | 0 | return attributeDefinition == null ? null : attributeDefinition.getExclusiveMin(); |
| 166 | |
} |
| 167 | |
|
| 168 | |
|
| 169 | |
|
| 170 | |
|
| 171 | |
public String getAttributeInclusiveMax(String entryName, String attributeName) { |
| 172 | 0 | AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName); |
| 173 | 0 | return attributeDefinition == null ? null : attributeDefinition.getInclusiveMax(); |
| 174 | |
} |
| 175 | |
|
| 176 | |
|
| 177 | |
|
| 178 | |
|
| 179 | |
public Pattern getAttributeValidatingExpression(String entryName, String attributeName) { |
| 180 | 0 | Pattern regex = null; |
| 181 | |
|
| 182 | 0 | AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName); |
| 183 | 0 | if (attributeDefinition != null) { |
| 184 | 0 | if (attributeDefinition.hasValidationPattern()) { |
| 185 | 0 | regex = attributeDefinition.getValidationPattern().getRegexPattern(); |
| 186 | |
} else { |
| 187 | |
|
| 188 | 0 | regex = Pattern.compile(".*"); |
| 189 | |
} |
| 190 | |
} |
| 191 | |
|
| 192 | 0 | return regex; |
| 193 | |
} |
| 194 | |
|
| 195 | |
|
| 196 | |
|
| 197 | |
|
| 198 | |
public String getAttributeLabel(String entryName, String attributeName) { |
| 199 | 0 | String label = ""; |
| 200 | |
|
| 201 | 0 | AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName); |
| 202 | 0 | if (attributeDefinition != null) { |
| 203 | |
|
| 204 | 0 | label = attributeDefinition.getLabel(); |
| 205 | 0 | if (!StringUtils.isEmpty(attributeDefinition.getDisplayLabelAttribute())) { |
| 206 | 0 | attributeDefinition = getAttributeDefinition(entryName, attributeDefinition.getDisplayLabelAttribute()); |
| 207 | 0 | if (attributeDefinition != null) { |
| 208 | 0 | label = attributeDefinition.getLabel(); |
| 209 | |
} |
| 210 | |
} |
| 211 | |
} |
| 212 | |
|
| 213 | 0 | return label; |
| 214 | |
} |
| 215 | |
|
| 216 | |
|
| 217 | |
|
| 218 | |
|
| 219 | |
public String getAttributeShortLabel(String entryName, String attributeName) { |
| 220 | 0 | String shortLabel = ""; |
| 221 | |
|
| 222 | 0 | AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName); |
| 223 | 0 | if (attributeDefinition != null) { |
| 224 | 0 | if (!StringUtils.isEmpty(attributeDefinition.getDisplayLabelAttribute())) { |
| 225 | 0 | attributeDefinition = getAttributeDefinition(entryName, attributeDefinition.getDisplayLabelAttribute()); |
| 226 | 0 | if (attributeDefinition != null) { |
| 227 | 0 | shortLabel = attributeDefinition.getShortLabel(); |
| 228 | |
} |
| 229 | |
} else { |
| 230 | 0 | shortLabel = attributeDefinition.getShortLabel(); |
| 231 | |
} |
| 232 | |
} |
| 233 | |
|
| 234 | 0 | return shortLabel; |
| 235 | |
} |
| 236 | |
|
| 237 | |
|
| 238 | |
|
| 239 | |
|
| 240 | |
public String getAttributeErrorLabel(String entryName, String attributeName) { |
| 241 | 0 | String longAttributeLabel = this.getAttributeLabel(entryName, attributeName); |
| 242 | 0 | String shortAttributeLabel = this.getAttributeShortLabel(entryName, attributeName); |
| 243 | 0 | return longAttributeLabel + " (" + shortAttributeLabel + ")"; |
| 244 | |
} |
| 245 | |
|
| 246 | |
|
| 247 | |
|
| 248 | |
|
| 249 | |
public Class<? extends Formatter> getAttributeFormatter(String entryName, String attributeName) { |
| 250 | 0 | Class formatterClass = null; |
| 251 | |
|
| 252 | 0 | AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName); |
| 253 | 0 | if (attributeDefinition != null) { |
| 254 | 0 | if (attributeDefinition.hasFormatterClass()) { |
| 255 | 0 | formatterClass = ClassLoaderUtils.getClass(attributeDefinition.getFormatterClass()); |
| 256 | |
} |
| 257 | |
} |
| 258 | |
|
| 259 | 0 | return formatterClass; |
| 260 | |
} |
| 261 | |
|
| 262 | |
|
| 263 | |
|
| 264 | |
|
| 265 | |
public Boolean getAttributeForceUppercase(String entryName, String attributeName) throws UnknownBusinessClassAttributeException { |
| 266 | 0 | Boolean forceUppercase = null; |
| 267 | |
|
| 268 | 0 | AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName); |
| 269 | 0 | if (attributeDefinition == null) { |
| 270 | 0 | throw new UnknownBusinessClassAttributeException("Could not find a matching data dictionary business class attribute entry for " + entryName + "." + attributeName); |
| 271 | |
} |
| 272 | 0 | forceUppercase = attributeDefinition.getForceUppercase(); |
| 273 | |
|
| 274 | 0 | return forceUppercase; |
| 275 | |
} |
| 276 | |
|
| 277 | |
|
| 278 | |
|
| 279 | |
|
| 280 | |
public AttributeSecurity getAttributeSecurity(String entryName, String attributeName) { |
| 281 | 0 | AttributeSecurity attributeSecurity = null; |
| 282 | |
|
| 283 | 0 | AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName); |
| 284 | 0 | if (attributeDefinition != null) { |
| 285 | 0 | attributeSecurity = attributeDefinition.getAttributeSecurity(); |
| 286 | |
} |
| 287 | |
|
| 288 | 0 | return attributeSecurity; |
| 289 | |
} |
| 290 | |
|
| 291 | |
|
| 292 | |
|
| 293 | |
|
| 294 | |
|
| 295 | |
public String getAttributeSummary(String entryName, String attributeName) { |
| 296 | 0 | String summary = null; |
| 297 | |
|
| 298 | 0 | AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName); |
| 299 | 0 | if (attributeDefinition != null) { |
| 300 | 0 | summary = attributeDefinition.getSummary(); |
| 301 | |
} |
| 302 | |
|
| 303 | 0 | return summary; |
| 304 | |
} |
| 305 | |
|
| 306 | |
|
| 307 | |
|
| 308 | |
|
| 309 | |
public String getAttributeDescription(String entryName, String attributeName) { |
| 310 | 0 | String description = null; |
| 311 | |
|
| 312 | 0 | AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName); |
| 313 | 0 | if (attributeDefinition != null) { |
| 314 | 0 | description = attributeDefinition.getDescription(); |
| 315 | |
} |
| 316 | |
|
| 317 | 0 | return description; |
| 318 | |
} |
| 319 | |
|
| 320 | |
|
| 321 | |
|
| 322 | |
|
| 323 | |
public Boolean isAttributeRequired(String entryName, String attributeName) { |
| 324 | 0 | Boolean required = null; |
| 325 | |
|
| 326 | 0 | AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName); |
| 327 | 0 | if (attributeDefinition != null) { |
| 328 | 0 | required = attributeDefinition.isRequired(); |
| 329 | |
} |
| 330 | |
|
| 331 | 0 | return required; |
| 332 | |
} |
| 333 | |
|
| 334 | |
|
| 335 | |
|
| 336 | |
|
| 337 | |
public Boolean isAttributeDefined(String entryName, String attributeName) { |
| 338 | 0 | boolean isDefined = false; |
| 339 | |
|
| 340 | 0 | AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName); |
| 341 | 0 | if (attributeDefinition != null) { |
| 342 | 0 | isDefined = true; |
| 343 | |
} |
| 344 | |
|
| 345 | 0 | return isDefined; |
| 346 | |
} |
| 347 | |
|
| 348 | |
|
| 349 | |
|
| 350 | |
|
| 351 | |
|
| 352 | |
public Class<? extends KeyValuesFinder> getAttributeValuesFinderClass(String entryName, String attributeName) { |
| 353 | 0 | Class valuesFinderClass = null; |
| 354 | |
|
| 355 | 0 | AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName); |
| 356 | 0 | if (attributeDefinition != null) { |
| 357 | 0 | String valuesFinderClassName = attributeDefinition.getControl().getValuesFinderClass(); |
| 358 | 0 | valuesFinderClass = ClassLoaderUtils.getClass(valuesFinderClassName); |
| 359 | |
} |
| 360 | |
|
| 361 | 0 | return valuesFinderClass; |
| 362 | |
} |
| 363 | |
|
| 364 | |
|
| 365 | |
|
| 366 | |
|
| 367 | |
public String getCollectionLabel(String entryName, String collectionName) { |
| 368 | 0 | String label = ""; |
| 369 | |
|
| 370 | 0 | CollectionDefinition collectionDefinition = getCollectionDefinition(entryName, collectionName); |
| 371 | 0 | if (collectionDefinition != null) { |
| 372 | 0 | label = collectionDefinition.getLabel(); |
| 373 | |
} |
| 374 | |
|
| 375 | 0 | return label; |
| 376 | |
} |
| 377 | |
|
| 378 | |
|
| 379 | |
|
| 380 | |
|
| 381 | |
public String getCollectionShortLabel(String entryName, String collectionName) { |
| 382 | 0 | String shortLabel = ""; |
| 383 | |
|
| 384 | 0 | CollectionDefinition collectionDefinition = getCollectionDefinition(entryName, collectionName); |
| 385 | 0 | if (collectionDefinition != null) { |
| 386 | 0 | shortLabel = collectionDefinition.getShortLabel(); |
| 387 | |
} |
| 388 | |
|
| 389 | 0 | return shortLabel; |
| 390 | |
} |
| 391 | |
|
| 392 | |
|
| 393 | |
|
| 394 | |
|
| 395 | |
|
| 396 | |
public String getCollectionElementLabel(String entryName, String collectionName, Class businessObjectClass) { |
| 397 | 0 | String elementLabel = ""; |
| 398 | |
|
| 399 | 0 | CollectionDefinition collectionDefinition = getCollectionDefinition(entryName, collectionName); |
| 400 | 0 | if (collectionDefinition != null) { |
| 401 | 0 | elementLabel = collectionDefinition.getElementLabel(); |
| 402 | 0 | if (StringUtils.isEmpty(elementLabel)) { |
| 403 | 0 | BusinessObjectEntry boe = getDataDictionary().getBusinessObjectEntry(businessObjectClass.getName()); |
| 404 | 0 | if (boe != null) { |
| 405 | 0 | elementLabel = boe.getObjectLabel(); |
| 406 | |
} |
| 407 | |
} |
| 408 | |
} |
| 409 | |
|
| 410 | 0 | return elementLabel; |
| 411 | |
} |
| 412 | |
|
| 413 | |
|
| 414 | |
|
| 415 | |
|
| 416 | |
public String getCollectionSummary(String entryName, String collectionName) { |
| 417 | 0 | String summary = null; |
| 418 | |
|
| 419 | 0 | CollectionDefinition collectionDefinition = getCollectionDefinition(entryName, collectionName); |
| 420 | 0 | if (collectionDefinition != null) { |
| 421 | 0 | summary = collectionDefinition.getSummary(); |
| 422 | |
} |
| 423 | |
|
| 424 | 0 | return summary; |
| 425 | |
} |
| 426 | |
|
| 427 | |
|
| 428 | |
|
| 429 | |
|
| 430 | |
|
| 431 | |
public String getCollectionDescription(String entryName, String collectionName) { |
| 432 | 0 | String description = null; |
| 433 | |
|
| 434 | 0 | CollectionDefinition collectionDefinition = getCollectionDefinition(entryName, collectionName); |
| 435 | 0 | if (collectionDefinition != null) { |
| 436 | 0 | description = collectionDefinition.getDescription(); |
| 437 | |
} |
| 438 | |
|
| 439 | 0 | return description; |
| 440 | |
} |
| 441 | |
|
| 442 | |
public Class<? extends BusinessObject> getRelationshipSourceClass(String entryName, String relationshipName) { |
| 443 | 0 | Class sourceClass = null; |
| 444 | |
|
| 445 | 0 | RelationshipDefinition rd = getRelationshipDefinition(entryName, relationshipName); |
| 446 | 0 | if (rd != null) { |
| 447 | 0 | sourceClass = rd.getSourceClass(); |
| 448 | |
} |
| 449 | |
|
| 450 | 0 | return sourceClass; |
| 451 | |
} |
| 452 | |
|
| 453 | |
public Class<? extends BusinessObject> getRelationshipTargetClass(String entryName, String relationshipName) { |
| 454 | 0 | Class targetClass = null; |
| 455 | |
|
| 456 | 0 | RelationshipDefinition rd = getRelationshipDefinition(entryName, relationshipName); |
| 457 | 0 | if (rd != null) { |
| 458 | 0 | targetClass = rd.getTargetClass(); |
| 459 | |
} |
| 460 | |
|
| 461 | 0 | return targetClass; |
| 462 | |
} |
| 463 | |
|
| 464 | |
public List<String> getRelationshipSourceAttributes(String entryName, String relationshipName) { |
| 465 | 0 | List<String> sourceAttributes = null; |
| 466 | |
|
| 467 | 0 | RelationshipDefinition rd = getRelationshipDefinition(entryName, relationshipName); |
| 468 | 0 | if (rd != null) { |
| 469 | 0 | sourceAttributes = new ArrayList<String>(); |
| 470 | |
|
| 471 | 0 | for (PrimitiveAttributeDefinition pad : rd.getPrimitiveAttributes()) { |
| 472 | 0 | sourceAttributes.add(pad.getSourceName()); |
| 473 | |
} |
| 474 | |
} |
| 475 | |
|
| 476 | 0 | return sourceAttributes; |
| 477 | |
} |
| 478 | |
|
| 479 | |
public List<String> getRelationshipTargetAttributes(String entryName, String relationshipName) { |
| 480 | 0 | List<String> targetAttributes = null; |
| 481 | |
|
| 482 | 0 | RelationshipDefinition rd = getRelationshipDefinition(entryName, relationshipName); |
| 483 | 0 | if (rd != null) { |
| 484 | 0 | targetAttributes = new ArrayList<String>(); |
| 485 | |
|
| 486 | 0 | for (PrimitiveAttributeDefinition pad : rd.getPrimitiveAttributes()) { |
| 487 | 0 | targetAttributes.add(pad.getTargetName()); |
| 488 | |
} |
| 489 | |
} |
| 490 | |
|
| 491 | 0 | return targetAttributes; |
| 492 | |
} |
| 493 | |
|
| 494 | |
public List<String> getRelationshipEntriesForSourceAttribute(String entryName, String sourceAttributeName) { |
| 495 | 0 | List<String> relationships = new ArrayList<String>(); |
| 496 | |
|
| 497 | 0 | DataDictionaryEntryBase entry = (DataDictionaryEntryBase) getDataDictionary().getDictionaryObjectEntry(entryName); |
| 498 | |
|
| 499 | 0 | for (RelationshipDefinition def : entry.getRelationships()) { |
| 500 | 0 | for (PrimitiveAttributeDefinition pddef : def.getPrimitiveAttributes()) { |
| 501 | 0 | if (StringUtils.equals(sourceAttributeName, pddef.getSourceName())) { |
| 502 | 0 | relationships.add(def.getObjectAttributeName()); |
| 503 | 0 | break; |
| 504 | |
} |
| 505 | |
} |
| 506 | |
} |
| 507 | 0 | return relationships; |
| 508 | |
} |
| 509 | |
|
| 510 | |
public List<String> getRelationshipEntriesForTargetAttribute(String entryName, String targetAttributeName) { |
| 511 | 0 | List<String> relationships = new ArrayList<String>(); |
| 512 | |
|
| 513 | 0 | DataDictionaryEntryBase entry = (DataDictionaryEntryBase) getDataDictionary().getDictionaryObjectEntry(entryName); |
| 514 | |
|
| 515 | 0 | for (RelationshipDefinition def : entry.getRelationships()) { |
| 516 | 0 | for (PrimitiveAttributeDefinition pddef : def.getPrimitiveAttributes()) { |
| 517 | 0 | if (StringUtils.equals(targetAttributeName, pddef.getTargetName())) { |
| 518 | 0 | relationships.add(def.getObjectAttributeName()); |
| 519 | 0 | break; |
| 520 | |
} |
| 521 | |
} |
| 522 | |
} |
| 523 | 0 | return relationships; |
| 524 | |
} |
| 525 | |
|
| 526 | |
|
| 527 | |
|
| 528 | |
|
| 529 | |
|
| 530 | |
|
| 531 | |
|
| 532 | |
|
| 533 | |
public AttributeDefinition getAttributeDefinition(String entryName, String attributeName) { |
| 534 | 0 | if (StringUtils.isBlank(attributeName)) { |
| 535 | 0 | throw new IllegalArgumentException("invalid (blank) attributeName"); |
| 536 | |
} |
| 537 | 0 | AttributeDefinition attributeDefinition = null; |
| 538 | |
|
| 539 | 0 | DataDictionaryEntryBase entry = (DataDictionaryEntryBase) getDataDictionary().getDictionaryObjectEntry(entryName); |
| 540 | 0 | if (entry != null) { |
| 541 | 0 | attributeDefinition = entry.getAttributeDefinition(attributeName); |
| 542 | |
} |
| 543 | |
|
| 544 | 0 | return attributeDefinition; |
| 545 | |
} |
| 546 | |
|
| 547 | |
|
| 548 | |
|
| 549 | |
|
| 550 | |
|
| 551 | |
|
| 552 | |
|
| 553 | |
private CollectionDefinition getCollectionDefinition(String entryName, String collectionName) { |
| 554 | 0 | if (StringUtils.isBlank(collectionName)) { |
| 555 | 0 | throw new IllegalArgumentException("invalid (blank) collectionName"); |
| 556 | |
} |
| 557 | 0 | CollectionDefinition collectionDefinition = null; |
| 558 | |
|
| 559 | 0 | DataDictionaryEntryBase entry = (DataDictionaryEntryBase) getDataDictionary().getDictionaryObjectEntry(entryName); |
| 560 | 0 | if (entry != null) { |
| 561 | 0 | collectionDefinition = entry.getCollectionDefinition(collectionName); |
| 562 | |
} |
| 563 | |
|
| 564 | 0 | return collectionDefinition; |
| 565 | |
} |
| 566 | |
|
| 567 | |
|
| 568 | |
|
| 569 | |
|
| 570 | |
|
| 571 | |
|
| 572 | |
private RelationshipDefinition getRelationshipDefinition(String entryName, String relationshipName) { |
| 573 | 0 | if (StringUtils.isBlank(relationshipName)) { |
| 574 | 0 | throw new IllegalArgumentException("invalid (blank) relationshipName"); |
| 575 | |
} |
| 576 | |
|
| 577 | 0 | RelationshipDefinition relationshipDefinition = null; |
| 578 | |
|
| 579 | 0 | DataDictionaryEntryBase entry = (DataDictionaryEntryBase) getDataDictionary().getDictionaryObjectEntry(entryName); |
| 580 | 0 | if (entry != null) { |
| 581 | 0 | relationshipDefinition = entry.getRelationshipDefinition(relationshipName); |
| 582 | |
} |
| 583 | |
|
| 584 | 0 | return relationshipDefinition; |
| 585 | |
} |
| 586 | |
|
| 587 | |
|
| 588 | |
|
| 589 | |
|
| 590 | |
public Map<String, String> getRelationshipAttributeMap(String entryName, String relationshipName) { |
| 591 | 0 | Map<String, String> attributeMap = new HashMap<String, String>(); |
| 592 | 0 | RelationshipDefinition relationshipDefinition = getRelationshipDefinition(entryName, relationshipName); |
| 593 | 0 | for (Iterator iter = relationshipDefinition.getPrimitiveAttributes().iterator(); iter.hasNext();) { |
| 594 | 0 | PrimitiveAttributeDefinition attribute = (PrimitiveAttributeDefinition) iter.next(); |
| 595 | 0 | attributeMap.put(attribute.getTargetName(), attribute.getSourceName()); |
| 596 | 0 | } |
| 597 | 0 | return attributeMap; |
| 598 | |
} |
| 599 | |
|
| 600 | |
public boolean hasRelationship(String entryName, String relationshipName) { |
| 601 | 0 | return getRelationshipDefinition(entryName, relationshipName) != null; |
| 602 | |
} |
| 603 | |
|
| 604 | |
public List<String> getRelationshipNames(String entryName) { |
| 605 | 0 | DataDictionaryEntryBase entry = (DataDictionaryEntryBase) getDataDictionary().getDictionaryObjectEntry(entryName); |
| 606 | |
|
| 607 | 0 | List<String> relationshipNames = new ArrayList<String>(); |
| 608 | 0 | for (RelationshipDefinition def : entry.getRelationships()) { |
| 609 | 0 | relationshipNames.add(def.getObjectAttributeName()); |
| 610 | |
} |
| 611 | 0 | return relationshipNames; |
| 612 | |
} |
| 613 | |
|
| 614 | |
|
| 615 | |
|
| 616 | |
|
| 617 | |
public ControlDefinition getAttributeControlDefinition(Class businessObjectClass, String attributeName) { |
| 618 | 0 | return getAttributeControlDefinition(businessObjectClass.getName(), attributeName); |
| 619 | |
} |
| 620 | |
|
| 621 | |
|
| 622 | |
|
| 623 | |
|
| 624 | |
public String getAttributeDescription(Class businessObjectClass, String attributeName) { |
| 625 | 0 | return getAttributeDescription(businessObjectClass.getName(), attributeName); |
| 626 | |
} |
| 627 | |
|
| 628 | |
|
| 629 | |
|
| 630 | |
|
| 631 | |
public Boolean getAttributeForceUppercase(Class businessObjectClass, String attributeName) { |
| 632 | 0 | return getAttributeForceUppercase(businessObjectClass.getName(), attributeName); |
| 633 | |
} |
| 634 | |
|
| 635 | |
|
| 636 | |
|
| 637 | |
|
| 638 | |
public Class<? extends Formatter> getAttributeFormatter(Class businessObjectClass, String attributeName) { |
| 639 | 0 | return getAttributeFormatter(businessObjectClass.getName(), attributeName); |
| 640 | |
} |
| 641 | |
|
| 642 | |
|
| 643 | |
|
| 644 | |
|
| 645 | |
public String getAttributeLabel(Class businessObjectClass, String attributeName) { |
| 646 | 0 | return getAttributeLabel(businessObjectClass.getName(), attributeName); |
| 647 | |
} |
| 648 | |
|
| 649 | |
|
| 650 | |
|
| 651 | |
|
| 652 | |
public Integer getAttributeMaxLength(Class businessObjectClass, String attributeName) { |
| 653 | 0 | return getAttributeMaxLength(businessObjectClass.getName(), attributeName); |
| 654 | |
} |
| 655 | |
|
| 656 | |
|
| 657 | |
|
| 658 | |
|
| 659 | |
public String getAttributeShortLabel(Class businessObjectClass, String attributeName) { |
| 660 | 0 | return getAttributeShortLabel(businessObjectClass.getName(), attributeName); |
| 661 | |
} |
| 662 | |
|
| 663 | |
|
| 664 | |
|
| 665 | |
|
| 666 | |
public String getAttributeErrorLabel(Class businessObjectClass, String attributeName) { |
| 667 | 0 | return getAttributeErrorLabel(businessObjectClass.getName(), attributeName); |
| 668 | |
} |
| 669 | |
|
| 670 | |
|
| 671 | |
|
| 672 | |
|
| 673 | |
public Integer getAttributeSize(Class businessObjectClass, String attributeName) { |
| 674 | 0 | return getAttributeSize(businessObjectClass.getName(), attributeName); |
| 675 | |
} |
| 676 | |
|
| 677 | |
|
| 678 | |
|
| 679 | |
|
| 680 | |
public String getAttributeSummary(Class businessObjectClass, String attributeName) { |
| 681 | 0 | return getAttributeSummary(businessObjectClass.getName(), attributeName); |
| 682 | |
} |
| 683 | |
|
| 684 | |
|
| 685 | |
|
| 686 | |
|
| 687 | |
public Pattern getAttributeValidatingExpression(Class businessObjectClass, String attributeName) { |
| 688 | 0 | return getAttributeValidatingExpression(businessObjectClass.getName(), attributeName); |
| 689 | |
} |
| 690 | |
|
| 691 | |
|
| 692 | |
|
| 693 | |
|
| 694 | |
public Class getAttributeValuesFinderClass(Class businessObjectClass, String attributeName) { |
| 695 | 0 | return getAttributeValuesFinderClass(businessObjectClass.getName(), attributeName); |
| 696 | |
} |
| 697 | |
|
| 698 | |
|
| 699 | |
|
| 700 | |
|
| 701 | |
public String getAttributeValidatingErrorMessageKey(String entryName, String attributeName) { |
| 702 | 0 | AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName); |
| 703 | 0 | if (attributeDefinition != null) { |
| 704 | 0 | if (attributeDefinition.hasValidationPattern()) { |
| 705 | 0 | ValidationPattern validationPattern = attributeDefinition.getValidationPattern(); |
| 706 | 0 | return validationPattern.getValidationErrorMessageKey(); |
| 707 | |
} |
| 708 | |
} |
| 709 | 0 | return null; |
| 710 | |
} |
| 711 | |
|
| 712 | |
|
| 713 | |
|
| 714 | |
|
| 715 | |
public String[] getAttributeValidatingErrorMessageParameters(String entryName, String attributeName) { |
| 716 | 0 | AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName); |
| 717 | 0 | if (attributeDefinition != null) { |
| 718 | 0 | if (attributeDefinition.hasValidationPattern()) { |
| 719 | 0 | ValidationPattern validationPattern = attributeDefinition.getValidationPattern(); |
| 720 | 0 | String attributeLabel = getAttributeErrorLabel(entryName, attributeName); |
| 721 | 0 | return validationPattern.getValidationErrorMessageParameters(attributeLabel); |
| 722 | |
} |
| 723 | |
} |
| 724 | 0 | return null; |
| 725 | |
} |
| 726 | |
|
| 727 | |
|
| 728 | |
|
| 729 | |
|
| 730 | |
public String getCollectionDescription(Class businessObjectClass, String collectionName) { |
| 731 | 0 | return getCollectionDescription(businessObjectClass.getName(), collectionName); |
| 732 | |
} |
| 733 | |
|
| 734 | |
|
| 735 | |
|
| 736 | |
|
| 737 | |
public String getCollectionLabel(Class businessObjectClass, String collectionName) { |
| 738 | 0 | return getCollectionLabel(businessObjectClass.getName(), collectionName); |
| 739 | |
} |
| 740 | |
|
| 741 | |
|
| 742 | |
|
| 743 | |
|
| 744 | |
public String getCollectionShortLabel(Class businessObjectClass, String collectionName) { |
| 745 | 0 | return getCollectionShortLabel(businessObjectClass.getName(), collectionName); |
| 746 | |
} |
| 747 | |
|
| 748 | |
|
| 749 | |
|
| 750 | |
|
| 751 | |
public String getCollectionSummary(Class businessObjectClass, String collectionName) { |
| 752 | 0 | return getCollectionSummary(businessObjectClass.getName(), collectionName); |
| 753 | |
} |
| 754 | |
|
| 755 | |
|
| 756 | |
|
| 757 | |
|
| 758 | |
public Boolean isAttributeDefined(Class businessObjectClass, String attributeName) { |
| 759 | 0 | return isAttributeDefined(businessObjectClass.getName(), attributeName); |
| 760 | |
} |
| 761 | |
|
| 762 | |
|
| 763 | |
|
| 764 | |
|
| 765 | |
public Boolean isAttributeRequired(Class businessObjectClass, String attributeName) { |
| 766 | 0 | return isAttributeRequired(businessObjectClass.getName(), attributeName); |
| 767 | |
|
| 768 | |
} |
| 769 | |
|
| 770 | |
|
| 771 | |
|
| 772 | |
|
| 773 | |
public String getDocumentLabelByClass(Class documentOrBusinessObjectClass) { |
| 774 | 0 | return getDocumentLabelByTypeName(getDocumentTypeNameByClass(documentOrBusinessObjectClass)); |
| 775 | |
} |
| 776 | |
|
| 777 | |
|
| 778 | |
|
| 779 | |
|
| 780 | |
public String getDocumentLabelByTypeName(String documentTypeName) { |
| 781 | 0 | String label = null; |
| 782 | 0 | if (StringUtils.isNotBlank(documentTypeName)) { |
| 783 | |
try { |
| 784 | 0 | DocumentTypeDTO documentType = getWorkflowInfoService().getDocType(documentTypeName); |
| 785 | 0 | if (documentType != null) { |
| 786 | 0 | label = documentType.getDocTypeLabel(); |
| 787 | |
} |
| 788 | 0 | } catch (WorkflowException e) { |
| 789 | |
|
| 790 | 0 | LOG.error("Caught Workflow Exception trying to get document type '" + documentTypeName + "'", e); |
| 791 | 0 | return documentTypeName; |
| 792 | 0 | } |
| 793 | |
} |
| 794 | 0 | return label; |
| 795 | |
} |
| 796 | |
|
| 797 | |
|
| 798 | |
|
| 799 | |
|
| 800 | |
public String getDocumentTypeNameByClass(Class documentClass) { |
| 801 | 0 | if (documentClass == null) { |
| 802 | 0 | throw new IllegalArgumentException("invalid (null) documentClass"); |
| 803 | |
} |
| 804 | 0 | if (!Document.class.isAssignableFrom(documentClass)) { |
| 805 | 0 | throw new IllegalArgumentException("invalid (non-Document) documentClass"); |
| 806 | |
} |
| 807 | |
|
| 808 | 0 | String documentTypeName = null; |
| 809 | |
|
| 810 | 0 | DocumentEntry documentEntry = getDataDictionary().getDocumentEntry(documentClass.getName()); |
| 811 | 0 | if (documentEntry != null) { |
| 812 | 0 | documentTypeName = documentEntry.getDocumentTypeName(); |
| 813 | |
} |
| 814 | |
|
| 815 | 0 | return documentTypeName; |
| 816 | |
} |
| 817 | |
|
| 818 | |
|
| 819 | |
|
| 820 | |
|
| 821 | |
public String getValidDocumentTypeNameByClass(Class documentClass) { |
| 822 | 0 | String documentTypeName = getDocumentTypeNameByClass(documentClass); |
| 823 | 0 | if (StringUtils.isBlank(documentTypeName)) { |
| 824 | 0 | throw new UnknownDocumentTypeException("unable to get documentTypeName for unknown documentClass '" + documentClass.getName() + "'"); |
| 825 | |
} |
| 826 | 0 | return documentTypeName; |
| 827 | |
} |
| 828 | |
|
| 829 | |
|
| 830 | |
|
| 831 | |
|
| 832 | |
public Class<? extends Document> getDocumentClassByTypeName(String documentTypeName) { |
| 833 | 0 | Class clazz = null; |
| 834 | |
|
| 835 | 0 | DocumentEntry documentEntry = getDataDictionary().getDocumentEntry(documentTypeName); |
| 836 | 0 | if (documentEntry != null) { |
| 837 | 0 | clazz = documentEntry.getDocumentClass(); |
| 838 | |
} |
| 839 | |
|
| 840 | 0 | return clazz; |
| 841 | |
} |
| 842 | |
|
| 843 | |
|
| 844 | |
|
| 845 | |
|
| 846 | |
public Class<? extends Document> getValidDocumentClassByTypeName(String documentTypeName) { |
| 847 | 0 | Class clazz = getDocumentClassByTypeName(documentTypeName); |
| 848 | 0 | if (clazz == null) { |
| 849 | 0 | throw new UnknownDocumentTypeException("unable to get class for unknown documentTypeName '" + documentTypeName + "'"); |
| 850 | |
} |
| 851 | 0 | return clazz; |
| 852 | |
} |
| 853 | |
|
| 854 | |
|
| 855 | |
|
| 856 | |
|
| 857 | |
public Class<? extends PromptBeforeValidation> getPromptBeforeValidationClass(String docTypeName) { |
| 858 | 0 | Class preRulesCheckClass = null; |
| 859 | |
|
| 860 | 0 | DocumentEntry documentEntry = getDataDictionary().getDocumentEntry(docTypeName); |
| 861 | 0 | if (documentEntry != null) { |
| 862 | 0 | preRulesCheckClass = documentEntry.getPromptBeforeValidationClass(); |
| 863 | |
} |
| 864 | |
|
| 865 | 0 | return preRulesCheckClass; |
| 866 | |
} |
| 867 | |
|
| 868 | |
|
| 869 | |
|
| 870 | |
|
| 871 | |
public View getViewById(String viewId) { |
| 872 | 0 | return dataDictionary.getViewById(viewId); |
| 873 | |
} |
| 874 | |
|
| 875 | |
|
| 876 | |
|
| 877 | |
|
| 878 | |
|
| 879 | |
public View getViewByTypeIndex(String viewTypeName, Map<String, String> indexKey) { |
| 880 | 0 | return dataDictionary.getViewByTypeIndex(viewTypeName, indexKey); |
| 881 | |
} |
| 882 | |
|
| 883 | |
public void addDataDictionaryLocation(String location) throws IOException { |
| 884 | 0 | dataDictionary.addConfigFileLocation(location); |
| 885 | 0 | } |
| 886 | |
|
| 887 | |
public void addDataDictionaryLocations(List<String> locations) throws IOException { |
| 888 | 0 | for (String location : locations) { |
| 889 | 0 | addDataDictionaryLocation(location); |
| 890 | |
} |
| 891 | 0 | } |
| 892 | |
|
| 893 | |
public Map getDataDictionaryMap() { |
| 894 | 0 | return dataDictionaryMap; |
| 895 | |
} |
| 896 | |
|
| 897 | |
public void setKualiConfigurationService(ConfigurationService kualiConfigurationService) { |
| 898 | 0 | this.kualiConfigurationService = kualiConfigurationService; |
| 899 | 0 | } |
| 900 | |
|
| 901 | |
public ConfigurationService getKualiConfigurationService() { |
| 902 | 0 | return kualiConfigurationService; |
| 903 | |
} |
| 904 | |
|
| 905 | |
public KualiModuleService getKualiModuleService() { |
| 906 | 0 | return kualiModuleService; |
| 907 | |
} |
| 908 | |
|
| 909 | |
public void setKualiModuleService(KualiModuleService kualiModuleService) { |
| 910 | 0 | this.kualiModuleService = kualiModuleService; |
| 911 | 0 | } |
| 912 | |
|
| 913 | |
|
| 914 | |
|
| 915 | |
|
| 916 | |
|
| 917 | |
|
| 918 | |
public Set<InactivationBlockingMetadata> getAllInactivationBlockingDefinitions(Class inactivationBlockedBusinessObjectClass) { |
| 919 | 0 | Set<InactivationBlockingMetadata> blockingClasses = dataDictionary.getAllInactivationBlockingMetadatas(inactivationBlockedBusinessObjectClass); |
| 920 | 0 | if (blockingClasses == null) { |
| 921 | 0 | return Collections.emptySet(); |
| 922 | |
} |
| 923 | 0 | return blockingClasses; |
| 924 | |
} |
| 925 | |
|
| 926 | |
public KualiWorkflowInfo getWorkflowInfoService() { |
| 927 | 0 | if ( workflowInfoService == null ) { |
| 928 | 0 | workflowInfoService = KNSServiceLocatorWeb.getWorkflowInfoService(); |
| 929 | |
} |
| 930 | 0 | return workflowInfoService; |
| 931 | |
} |
| 932 | |
|
| 933 | |
|
| 934 | |
} |