View Javadoc

1   /**
2    * Copyright 2005-2014 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 org.kuali.rice.core.web.format.Formatter;
19  import org.kuali.rice.krad.bo.BusinessObject;
20  import org.kuali.rice.krad.datadictionary.AttributeDefinition;
21  import org.kuali.rice.krad.datadictionary.AttributeSecurity;
22  import org.kuali.rice.krad.datadictionary.DataDictionary;
23  import org.kuali.rice.krad.datadictionary.InactivationBlockingMetadata;
24  import org.kuali.rice.krad.datadictionary.control.ControlDefinition;
25  import org.kuali.rice.krad.document.Document;
26  import org.kuali.rice.krad.keyvalues.KeyValuesFinder;
27  import org.kuali.rice.krad.uif.view.View;
28  import org.kuali.rice.krad.uif.UifConstants.ViewType;
29  
30  import java.io.IOException;
31  import java.util.List;
32  import java.util.Map;
33  import java.util.Set;
34  import java.util.regex.Pattern;
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     Class<? extends Formatter> getAttributeFormatter(Class dataObjectClass, String attributeName);
122 
123     /**
124      * indicates whether or not to force input text into uppercase
125      */
126     Boolean getAttributeForceUppercase(Class dataObjectClass, String attributeName);
127 
128     /**
129      * short help text for attribute
130      */
131     String getAttributeSummary(Class dataObjectClass, String attributeName);
132 
133     /**
134      * detailed help text for attribute
135      */
136     String getAttributeDescription(Class dataObjectClass, String attributeName);
137 
138     /**
139      * indicates whether or not the named attribute is required
140      */
141     Boolean isAttributeRequired(Class dataObjectClass, String attributeName);
142 
143     /**
144      * indicates whether or not the named attribute is defined in the business object xml
145      */
146     Boolean isAttributeDefined(Class dataObjectClass, String attributeName);
147 
148     /**
149      * the Class that returns a values list for this attribute
150      */
151     Class<? extends KeyValuesFinder> getAttributeValuesFinderClass(Class dataObjectClass, String attributeName);
152 
153     /**
154      * the label to be used for displaying the collection.
155      */
156     String getCollectionLabel(Class dataObjectClass, String collectionName);
157 
158     /**
159      * the short label to be used for displaying the collection.
160      */
161     String getCollectionShortLabel(Class dataObjectClass, String collectionName);
162 
163     /**
164      * short help text for collection
165      */
166     String getCollectionSummary(Class dataObjectClass, String collectionName);
167 
168     /**
169      * detailed help text for collection
170      */
171     String getCollectionDescription(Class dataObjectClass, String collectionName);
172 
173     /**
174      * the html control type used to render the field
175      */
176     ControlDefinition getAttributeControlDefinition(String entryName, String attributeName);
177 
178     /**
179      * the display size of the field if text control
180      */
181     Integer getAttributeSize(String entryName, String attributeName);
182 
183     /**
184      * the min length defined for the given attribute name.
185      */
186     Integer getAttributeMinLength(String entryName, String attributeName);
187 
188     /**
189      * the max length defined for the given attribute name.
190      */
191     Integer getAttributeMaxLength(String entryName, String attributeName);
192 
193     /**
194      * @param entryName
195      * @param attributeName
196      * @return the exclusive minimum for the specified attribute, or {@code null} if none.
197      */
198     /*BigDecimal*/ String getAttributeExclusiveMin(String entryName, String attributeName);
199 
200     /**
201      * @param entryName
202      * @param attributeName
203      * @return the inclusive maximum for the specified attribute, or {@code null} if none.
204      */
205     /*BigDecimal*/ String getAttributeInclusiveMax(String entryName, String attributeName);
206 
207     /**
208      * the regular expression defined to validate the given attribute name.
209      */
210     Pattern getAttributeValidatingExpression(String entryName, String attributeName);
211 
212     /**
213      * the label to be used for displaying the attribute.
214      */
215     String getAttributeLabel(String entryName, String attributeName);
216 
217     /**
218      * the short label to be used for displaying the attribute.
219      */
220     String getAttributeShortLabel(String entryName, String attributeName);
221 
222     /**
223      * the "label (short label)" used for displaying error messages
224      */
225     String getAttributeErrorLabel(String entryName, String attributeName);
226 
227     /**
228      * the formatter class used to format the attribute value
229      */
230     Class<? extends Formatter> getAttributeFormatter(String entryName, String attributeName);
231 
232     /**
233      * indicates whether or not to force input text into uppercase
234      */
235     Boolean getAttributeForceUppercase(String entryName, String attributeName);
236 
237     /**
238      * the AttributeSecurity object defined for the attribute's data value
239      */
240     AttributeSecurity getAttributeSecurity(String entryName, String attributeName);
241 
242     /**
243      * short help text for attribute
244      */
245     String getAttributeSummary(String entryName, String attributeName);
246 
247     /**
248      * detailed help text for attribute
249      */
250     String getAttributeDescription(String entryName, String attributeName);
251 
252     String getAttributeValidatingErrorMessageKey(String entryName, String attributeName);
253 
254     String[] getAttributeValidatingErrorMessageParameters(String entryName, String attributeName);
255 
256     /**
257      * indicates whether or not the named attribute is required
258      */
259     Boolean isAttributeRequired(String entryName, String attributeName);
260 
261     /**
262      * indicates whether or not the named attribute is defined in the business object xml
263      */
264     Boolean isAttributeDefined(String entryName, String attributeName);
265 
266     /**
267      * the Class that returns a values list for this attribute
268      */
269     Class<? extends KeyValuesFinder> getAttributeValuesFinderClass(String entryName, String attributeName);
270 
271     /**
272      * AttributeDefinition associated with the given attributeName within the given entry
273      */
274     AttributeDefinition getAttributeDefinition(String entryName, String attributeName);
275 
276     /**
277      * the label to be used for displaying the collection.
278      */
279     String getCollectionLabel(String entryName, String collectionName);
280 
281     /**
282      * the short label to be used for displaying the collection.
283      */
284     String getCollectionShortLabel(String entryName, String collectionName);
285 
286     /**
287      * the element label to be used for displaying the collection.
288      */
289     String getCollectionElementLabel(String entryName, String collectionName, Class dataObjectClass);
290 
291     /**
292      * short help text for collection
293      */
294     String getCollectionSummary(String entryName, String collectionName);
295 
296     /**
297      * detailed help text for collection
298      */
299     String getCollectionDescription(String entryName, String collectionName);
300 
301     /**
302      * @param entryName
303      * @param relationshipName
304      * @return source Class for the given relationship, or null if there is no relationship with that name
305      */
306     Class<? extends BusinessObject> getRelationshipSourceClass(String entryName, String relationshipName);
307 
308     /**
309      * @param entryName
310      * @param relationshipName
311      * @return target Class for the given relationship, or null if there is no relationship with that name
312      */
313     Class<? extends BusinessObject> getRelationshipTargetClass(String entryName, String relationshipName);
314 
315     /**
316      * @param entryName
317      * @param relationshipName
318      * @return List<String> of source attributeNames for the given relationship, or null if there is no relationship
319      *         with that name
320      */
321     List<String> getRelationshipSourceAttributes(String entryName, String relationshipName);
322 
323     /**
324      * @param entryName
325      * @param relationshipName
326      * @return List<String> of target attributeNames for the given relationship, or null if there is no relationship
327      *         with that name
328      */
329     List<String> getRelationshipTargetAttributes(String entryName, String relationshipName);
330 
331     /**
332      * returns a Map that specifies the attributes of the relationship
333      *
334      * @param entryName - Name of the Business Object entry
335      * @param relationshipName - Name of the relationship
336      * @return Map - Target field as key, source field as value
337      */
338     Map<String, String> getRelationshipAttributeMap(String entryName, String relationshipName);
339 
340     /**
341      * returns a list of names for all entries whose source parameter matches the parameter
342      *
343      * @param entryName Name of the Business Object entry
344      * @param sourceAttributeName name of the source attribute
345      * @return the names of all entries that use the sourceAttributeName as a primitive attribute
346      */
347     List<String> getRelationshipEntriesForSourceAttribute(String entryName, String sourceAttributeName);
348 
349     /**
350      * returns a list of names for all entries whose source parameter matches the parameter
351      *
352      * @param entryName Name of the Business Object entry
353      * @param targetAttributeName name of the target attribute
354      * @return the names of all entries that use the targetAttributeName as a primitive attribute
355      */
356     List<String> getRelationshipEntriesForTargetAttribute(String entryName, String targetAttributeName);
357 
358     /**
359      * Determines whether there is a relationship defined for the given entry with the given name
360      *
361      * @param entryName name of the BO entry
362      * @param relationshipName name of the relationship for the entry
363      * @return true iff there is a relationship with the given name defined for the BO entry in the DD
364      */
365     boolean hasRelationship(String entryName, String relationshipName);
366 
367     /**
368      * Returns all of the relationships defined for a BO in the DD
369      *
370      * @param entryName of the BO entry
371      * @return a list of all DD defined mappings
372      */
373     List<String> getRelationshipNames(String entryName);
374 
375     //    /**
376     //     * Returns the list of document class names
377     //     *
378     //     * @return
379     //     */
380     //    public List getDocumentObjectClassnames();
381 
382     /**
383      * This method returns the user friendly label based on the workflow doc type name
384      *
385      * @param documentTypeName
386      * @return label
387      */
388     String getDocumentLabelByTypeName(String documentTypeName);
389 
390     /**
391      * This method returns the user friendly label based on the document or business object class
392      *
393      * @param documentOrBusinessObjectClass
394      * @return label
395      */
396     String getDocumentLabelByClass(Class documentOrBusinessObjectClass);
397 
398     /**
399      * Returns the document type name declared in the dd for the given document
400      * class. If no valid document type is found 'null' is returned.
401      *
402      * @param documentClass
403      * @return documentTypeName
404      */
405     String getDocumentTypeNameByClass(Class documentClass);
406 
407     /**
408      * Returns the document type name declared in the dd for the given document
409      * class. If no valid document type is found an
410      * {@link org.kuali.rice.krad.datadictionary.exception.UnknownDocumentTypeException} is thrown.
411      *
412      * @param documentClass
413      * @return documentTypeName
414      */
415     String getValidDocumentTypeNameByClass(Class documentClass);
416 
417     /**
418      * Returns the document class declared in the dd for the given document type
419      * name. If no document entry is found with given document type name, 'null'
420      * will be returned.
421      *
422      * @param documentTypeName
423      * @return document Class
424      */
425     Class<? extends Document> getDocumentClassByTypeName(String documentTypeName);
426 
427     /**
428      * Returns the document class declared in the dd for the given document type
429      * name. If no document entry is found with given document type name, and
430      * {@link org.kuali.rice.krad.datadictionary.exception.UnknownDocumentTypeException} will be thrown.
431      *
432      * @param documentTypeName
433      * @return document Class
434      */
435     Class<? extends Document> getValidDocumentClassByTypeName(String documentTypeName);
436 
437     /**
438      * Returns the list of attributes that should be used for grouping when determining the current
439      * status of a business object that implements InactivateableFromTo
440      *
441      * @param businessObjectClass - business object class to get configured list for
442      * @return List of string attribute names that gives the group by list
443      */
444     List<String> getGroupByAttributesForEffectiveDating(Class businessObjectClass);
445 
446     /**
447      * Returns all of the inactivation blocks registered for a particular business object
448      *
449      * @param inactivationBlockedBusinessObjectClass
450      * @return a set of all registered inactivation blocks for a particular business object
451      */
452     Set<InactivationBlockingMetadata> getAllInactivationBlockingDefinitions(
453             Class inactivationBlockedBusinessObjectClass);
454 
455     /**
456      * Returns the View entry identified by the given id
457      *
458      * @param viewId - unique id for view
459      * @return View instance associated with the id
460      */
461     View getViewById(String viewId);
462 
463     /**
464      * Returns an object from the dictionary by its spring bean name or id
465      *
466      * @param id - id or name for the bean definition
467      * @return Object object instance created or the singleton being maintained
468      */
469     Object getDictionaryObject(String id);
470 
471     /**
472      * Indicates whether the data dictionary contains a bean with the given id
473      *
474      * @param id - id of the bean to check for
475      * @return boolean true if dictionary contains bean, false otherwise
476      */
477     boolean containsDictionaryObject(String id);
478 
479     /**
480      * Returns View instance identified by the view type name and index
481      *
482      * @param viewTypeName - type name for the view
483      * @param indexKey - Map of index key parameters, these are the parameters the
484      * indexer used to index the view initially and needs to identify
485      * an unique view instance
486      * @return View instance that matches the given index
487      */
488     View getViewByTypeIndex(ViewType viewTypeName, Map<String, String> indexKey);
489 
490     /**
491      * Returns the view id for the view that matches the given view type 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 id for the view that matches the view type and index or null if a match is not found
498      */
499     String getViewIdByTypeIndex(ViewType viewTypeName, Map<String, String> indexKey);
500 }