1 /** 2 * Copyright 2005-2015 The Kuali Foundation 3 * 4 * Licensed under the Educational Community License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.opensource.org/licenses/ecl2.php 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package org.kuali.rice.krad.service; 17 18 import java.io.IOException; 19 import java.util.List; 20 import java.util.Map; 21 import java.util.Set; 22 import java.util.regex.Pattern; 23 24 import org.kuali.rice.core.web.format.Formatter; 25 import org.kuali.rice.krad.bo.BusinessObject; 26 import org.kuali.rice.krad.datadictionary.AttributeDefinition; 27 import org.kuali.rice.krad.datadictionary.AttributeSecurity; 28 import org.kuali.rice.krad.datadictionary.DataDictionary; 29 import org.kuali.rice.krad.datadictionary.InactivationBlockingMetadata; 30 import org.kuali.rice.krad.datadictionary.control.ControlDefinition; 31 import org.kuali.rice.krad.document.Document; 32 import org.kuali.rice.krad.keyvalues.KeyValuesFinder; 33 import org.kuali.rice.krad.uif.UifConstants.ViewType; 34 import org.kuali.rice.krad.uif.view.View; 35 36 /** 37 * Defines the API for interacting with the data dictionary 38 * 39 * @author Kuali Rice Team (rice.collab@kuali.org) 40 */ 41 public interface DataDictionaryService { 42 43 /** 44 * Adds additional dictionary files to the data dictionary (files that will not be loaded through one of 45 * the module configurations) 46 * 47 * <p> 48 * Additional files must be associated with a namespace thus a map is specified with the key giving the 49 * namespace the list of files should be associated with 50 * </p> 51 * 52 * <p> 53 * Duplicate entries among any of the XML files in any of these packages will result in exceptions 54 * being thrown, hence service-initialization failure 55 * </p> 56 * 57 * @param additionalDictionaryFiles map where key is namespace and value is list of dictionary files that 58 * should be added to that namespace 59 * @throws IOException if any of the given packages can't be located 60 */ 61 public void setAdditionalDictionaryFiles(Map<String, List<String>> additionalDictionaryFiles) throws IOException; 62 63 /** 64 * Sequentially adds each package named (as a String) in the given List as a source of unique entries to the 65 * DataDictionary being constructed 66 * 67 * <p> 68 * Duplicate entries among any of the XML files in any of these packages will result in exceptions 69 * being thrown, hence service-initialization failure 70 * </p> 71 * 72 * @param namespaceCode - namespace the beans loaded from the location should be associated with 73 * @param locations - list of locations to add (either classpath entries or file/folder locations) 74 * @throws IOException if any of the given packages can't be located 75 */ 76 public void addDataDictionaryLocations(String namespaceCode, List<String> locations) throws IOException; 77 78 /** 79 * @return current DataDictionary 80 */ 81 public DataDictionary getDataDictionary(); 82 83 /** 84 * the html control type used to render the field 85 */ 86 ControlDefinition getAttributeControlDefinition(Class<?> dataObjectClass, String attributeName); 87 88 /** 89 * the display size of the field if text control 90 */ 91 Integer getAttributeSize(Class<?> dataObjectClass, String attributeName); 92 93 /** 94 * the max length defined for the given attribute name. 95 */ 96 Integer getAttributeMaxLength(Class<?> dataObjectClass, String attributeName); 97 98 /** 99 * the regular expression defined to validate the given attribute name. 100 */ 101 Pattern getAttributeValidatingExpression(Class<?> dataObjectClass, String attributeName); 102 103 /** 104 * the label to be used for displaying the attribute. 105 */ 106 String getAttributeLabel(Class<?> dataObjectClass, String attributeName); 107 108 /** 109 * the short label to be used for displaying the attribute. 110 */ 111 String getAttributeShortLabel(Class<?> dataObjectClass, String attributeName); 112 113 /** 114 * the "label (short label)" used for displaying error messages 115 */ 116 String getAttributeErrorLabel(Class<?> dataObjectClass, String attributeName); 117 118 /** 119 * the formatter class used to format the attribute value 120 */ 121 @Deprecated 122 Class<? extends Formatter> getAttributeFormatter(Class<?> dataObjectClass, String attributeName); 123 124 /** 125 * indicates whether or not to force input text into uppercase 126 */ 127 Boolean getAttributeForceUppercase(Class<?> dataObjectClass, String attributeName); 128 129 /** 130 * short help text for attribute 131 */ 132 String getAttributeSummary(Class<?> dataObjectClass, String attributeName); 133 134 /** 135 * detailed help text for attribute 136 */ 137 String getAttributeDescription(Class<?> dataObjectClass, String attributeName); 138 139 /** 140 * indicates whether or not the named attribute is required 141 */ 142 Boolean isAttributeRequired(Class<?> dataObjectClass, String attributeName); 143 144 /** 145 * indicates whether or not the named attribute is defined in the business object xml 146 */ 147 Boolean isAttributeDefined(Class<?> dataObjectClass, String attributeName); 148 149 /** 150 * the Class that returns a values list for this attribute 151 */ 152 Class<? extends KeyValuesFinder> getAttributeValuesFinderClass(Class<?> dataObjectClass, String attributeName); 153 154 /** 155 * the label to be used for displaying the collection. 156 */ 157 String getCollectionLabel(Class<?> dataObjectClass, String collectionName); 158 159 /** 160 * the short label to be used for displaying the collection. 161 */ 162 String getCollectionShortLabel(Class<?> dataObjectClass, String collectionName); 163 164 /** 165 * short help text for collection 166 */ 167 String getCollectionSummary(Class<?> dataObjectClass, String collectionName); 168 169 /** 170 * detailed help text for collection 171 */ 172 String getCollectionDescription(Class<?> dataObjectClass, String collectionName); 173 174 /** 175 * the html control type used to render the field 176 */ 177 ControlDefinition getAttributeControlDefinition(String entryName, String attributeName); 178 179 /** 180 * the display size of the field if text control 181 */ 182 Integer getAttributeSize(String entryName, String attributeName); 183 184 /** 185 * the min length defined for the given attribute name. 186 */ 187 Integer getAttributeMinLength(String entryName, String attributeName); 188 189 /** 190 * the max length defined for the given attribute name. 191 */ 192 Integer getAttributeMaxLength(String entryName, String attributeName); 193 194 /** 195 * @param entryName 196 * @param attributeName 197 * @return the exclusive minimum for the specified attribute, or {@code null} if none. 198 */ 199 /*BigDecimal*/ String getAttributeExclusiveMin(String entryName, String attributeName); 200 201 /** 202 * @param entryName 203 * @param attributeName 204 * @return the inclusive maximum for the specified attribute, or {@code null} if none. 205 */ 206 /*BigDecimal*/ String getAttributeInclusiveMax(String entryName, String attributeName); 207 208 /** 209 * the regular expression defined to validate the given attribute name. 210 */ 211 Pattern getAttributeValidatingExpression(String entryName, String attributeName); 212 213 /** 214 * the label to be used for displaying the attribute. 215 */ 216 String getAttributeLabel(String entryName, String attributeName); 217 218 /** 219 * the short label to be used for displaying the attribute. 220 */ 221 String getAttributeShortLabel(String entryName, String attributeName); 222 223 /** 224 * the "label (short label)" used for displaying error messages 225 */ 226 String getAttributeErrorLabel(String entryName, String attributeName); 227 228 /** 229 * the formatter class used to format the attribute value 230 */ 231 @Deprecated 232 Class<? extends Formatter> getAttributeFormatter(String entryName, String attributeName); 233 234 /** 235 * indicates whether or not to force input text into uppercase 236 */ 237 Boolean getAttributeForceUppercase(String entryName, String attributeName); 238 239 /** 240 * the AttributeSecurity object defined for the attribute's data value 241 */ 242 AttributeSecurity getAttributeSecurity(String entryName, String attributeName); 243 244 /** 245 * short help text for attribute 246 */ 247 String getAttributeSummary(String entryName, String attributeName); 248 249 /** 250 * detailed help text for attribute 251 */ 252 String getAttributeDescription(String entryName, String attributeName); 253 254 String getAttributeValidatingErrorMessageKey(String entryName, String attributeName); 255 256 String[] getAttributeValidatingErrorMessageParameters(String entryName, String attributeName); 257 258 /** 259 * indicates whether or not the named attribute is required 260 */ 261 Boolean isAttributeRequired(String entryName, String attributeName); 262 263 /** 264 * indicates whether or not the named attribute is defined in the business object xml 265 */ 266 Boolean isAttributeDefined(String entryName, String attributeName); 267 268 /** 269 * the Class that returns a values list for this attribute 270 */ 271 Class<? extends KeyValuesFinder> getAttributeValuesFinderClass(String entryName, String attributeName); 272 273 /** 274 * AttributeDefinition associated with the given attributeName within the given entry 275 */ 276 AttributeDefinition getAttributeDefinition(String entryName, String attributeName); 277 278 /** 279 * the label to be used for displaying the collection. 280 */ 281 String getCollectionLabel(String entryName, String collectionName); 282 283 /** 284 * the short label to be used for displaying the collection. 285 */ 286 String getCollectionShortLabel(String entryName, String collectionName); 287 288 /** 289 * the element label to be used for displaying the collection. 290 */ 291 String getCollectionElementLabel(String entryName, String collectionName, Class<?> dataObjectClass); 292 293 /** 294 * short help text for collection 295 */ 296 String getCollectionSummary(String entryName, String collectionName); 297 298 /** 299 * detailed help text for collection 300 */ 301 String getCollectionDescription(String entryName, String collectionName); 302 303 /** 304 * @param entryName 305 * @param relationshipName 306 * @return source Class for the given relationship, or null if there is no relationship with that name 307 */ 308 Class<? extends BusinessObject> getRelationshipSourceClass(String entryName, String relationshipName); 309 310 /** 311 * @param entryName 312 * @param relationshipName 313 * @return target Class for the given relationship, or null if there is no relationship with that name 314 */ 315 Class<? extends BusinessObject> getRelationshipTargetClass(String entryName, String relationshipName); 316 317 /** 318 * @param entryName 319 * @param relationshipName 320 * @return List<String> of source attributeNames for the given relationship, or null if there is no relationship 321 * with that name 322 */ 323 List<String> getRelationshipSourceAttributes(String entryName, String relationshipName); 324 325 /** 326 * @param entryName 327 * @param relationshipName 328 * @return List<String> of target attributeNames for the given relationship, or null if there is no relationship 329 * with that name 330 */ 331 List<String> getRelationshipTargetAttributes(String entryName, String relationshipName); 332 333 /** 334 * returns a Map that specifies the attributes of the relationship 335 * 336 * @param entryName - Name of the Business Object entry 337 * @param relationshipName - Name of the relationship 338 * @return Map - Target field as key, source field as value 339 */ 340 Map<String, String> getRelationshipAttributeMap(String entryName, String relationshipName); 341 342 /** 343 * returns a list of names for all entries whose source parameter matches the parameter 344 * 345 * @param entryName Name of the Business Object entry 346 * @param sourceAttributeName name of the source attribute 347 * @return the names of all entries that use the sourceAttributeName as a primitive attribute 348 */ 349 List<String> getRelationshipEntriesForSourceAttribute(String entryName, String sourceAttributeName); 350 351 /** 352 * returns a list of names for all entries whose source parameter matches the parameter 353 * 354 * @param entryName Name of the Business Object entry 355 * @param targetAttributeName name of the target attribute 356 * @return the names of all entries that use the targetAttributeName as a primitive attribute 357 */ 358 List<String> getRelationshipEntriesForTargetAttribute(String entryName, String targetAttributeName); 359 360 /** 361 * Determines whether there is a relationship defined for the given entry with the given name 362 * 363 * @param entryName name of the BO entry 364 * @param relationshipName name of the relationship for the entry 365 * @return true iff there is a relationship with the given name defined for the BO entry in the DD 366 */ 367 boolean hasRelationship(String entryName, String relationshipName); 368 369 /** 370 * Returns all of the relationships defined for a BO in the DD 371 * 372 * @param entryName of the BO entry 373 * @return a list of all DD defined mappings 374 */ 375 List<String> getRelationshipNames(String entryName); 376 377 // /** 378 // * Returns the list of document class names 379 // * 380 // * @return 381 // */ 382 // public List getDocumentObjectClassnames(); 383 384 /** 385 * This method returns the user friendly label based on the workflow doc type name 386 * 387 * @param documentTypeName 388 * @return label 389 */ 390 String getDocumentLabelByTypeName(String documentTypeName); 391 392 /** 393 * This method returns the user friendly label based on the document or business object class 394 * 395 * @param documentOrBusinessObjectClass 396 * @return label 397 */ 398 String getDocumentLabelByClass(Class<?> documentOrBusinessObjectClass); 399 400 /** 401 * Returns the document type name declared in the dd for the given document 402 * class. If no valid document type is found 'null' is returned. 403 * 404 * @param documentClass 405 * @return documentTypeName 406 */ 407 String getDocumentTypeNameByClass(Class<?> documentClass); 408 409 /** 410 * Returns the document type name declared in the dd for the given document 411 * class. If no valid document type is found an 412 * {@link org.kuali.rice.krad.datadictionary.exception.UnknownDocumentTypeException} is thrown. 413 * 414 * @param documentClass 415 * @return documentTypeName 416 */ 417 String getValidDocumentTypeNameByClass(Class<?> documentClass); 418 419 /** 420 * Returns the document class declared in the dd for the given document type 421 * name. If no document entry is found with given document type name, 'null' 422 * will be returned. 423 * 424 * @param documentTypeName 425 * @return document Class 426 */ 427 Class<? extends Document> getDocumentClassByTypeName(String documentTypeName); 428 429 /** 430 * Returns the document class declared in the dd for the given document type 431 * name. If no document entry is found with given document type name, and 432 * {@link org.kuali.rice.krad.datadictionary.exception.UnknownDocumentTypeException} will be thrown. 433 * 434 * @param documentTypeName 435 * @return document Class 436 */ 437 Class<? extends Document> getValidDocumentClassByTypeName(String documentTypeName); 438 439 /** 440 * Returns the list of attributes that should be used for grouping when determining the current 441 * status of a business object that implements InactivateableFromTo 442 * 443 * @param businessObjectClass - business object class to get configured list for 444 * @return List of string attribute names that gives the group by list 445 */ 446 List<String> getGroupByAttributesForEffectiveDating(Class<?> businessObjectClass); 447 448 /** 449 * Returns all of the inactivation blocks registered for a particular business object 450 * 451 * @param inactivationBlockedBusinessObjectClass 452 * @return a set of all registered inactivation blocks for a particular business object 453 */ 454 Set<InactivationBlockingMetadata> getAllInactivationBlockingDefinitions( 455 Class<?> inactivationBlockedBusinessObjectClass); 456 457 /** 458 * Returns the View entry identified by the given id 459 * 460 * @param viewId - unique id for view 461 * @return View instance associated with the id 462 */ 463 View getViewById(String viewId); 464 465 /** 466 * Returns an object from the dictionary by its spring bean name or id 467 * 468 * @param id id or name for the bean definition 469 * @return Object object instance created or the singleton being maintained 470 */ 471 Object getDictionaryBean(String id); 472 473 /** 474 * Indicates whether the data dictionary contains a bean with the given id 475 * 476 * @param id id of the bean to check for 477 * @return boolean true if dictionary contains bean, false otherwise 478 */ 479 boolean containsDictionaryBean(String id); 480 481 /** 482 * Returns a property value for the bean with the given name from the dictionary. 483 * 484 * @param beanName id or name for the bean definition 485 * @param propertyName name of the property to retrieve 486 * @return Object property value for property 487 */ 488 Object getDictionaryBeanProperty(String beanName, String propertyName); 489 490 /** 491 * Returns View instance identified by the view type name and index 492 * 493 * @param viewTypeName - type name for the view 494 * @param indexKey - Map of index key parameters, these are the parameters the 495 * indexer used to index the view initially and needs to identify 496 * an unique view instance 497 * @return View instance that matches the given index 498 */ 499 View getViewByTypeIndex(ViewType viewTypeName, Map<String, String> indexKey); 500 501 /** 502 * Returns the view id for the view that matches the given view type and index 503 * 504 * @param viewTypeName type name for the view 505 * @param indexKey Map of index key parameters, these are the parameters the 506 * indexer used to index the view initially and needs to identify 507 * an unique view instance 508 * @return id for the view that matches the view type and index or null if a match is not found 509 */ 510 String getViewIdByTypeIndex(ViewType viewTypeName, Map<String, String> indexKey); 511 512 /** 513 * Returns a mapping from property type to property editor prototype name, for use in defining editors 514 * for {@link org.springframework.beans.PropertyEditorRegistry}. 515 * 516 * @return Mapping of property editors by property type. 517 */ 518 Map<Class<?>, String> getPropertyEditorMap(); 519 520 }