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