001/**
002 * Copyright 2005-2016 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.rice.krad.service;
017
018import org.kuali.rice.core.web.format.Formatter;
019import org.kuali.rice.krad.bo.BusinessObject;
020import org.kuali.rice.krad.datadictionary.AttributeDefinition;
021import org.kuali.rice.krad.datadictionary.AttributeSecurity;
022import org.kuali.rice.krad.datadictionary.DataDictionary;
023import org.kuali.rice.krad.datadictionary.InactivationBlockingMetadata;
024import org.kuali.rice.krad.datadictionary.control.ControlDefinition;
025import org.kuali.rice.krad.datadictionary.exception.UnknownDocumentTypeException;
026import org.kuali.rice.krad.document.Document;
027import org.kuali.rice.krad.keyvalues.KeyValuesFinder;
028import org.kuali.rice.krad.uif.view.View;
029import org.kuali.rice.krad.uif.UifConstants.ViewType;
030
031import java.io.IOException;
032import java.util.List;
033import java.util.Map;
034import java.util.Set;
035import java.util.regex.Pattern;
036
037/**
038 * Defines the API for interacting with the data dictionary
039 *
040 * @author Kuali Rice Team (rice.collab@kuali.org)
041 */
042public interface DataDictionaryService {
043
044    /**
045     * Sequentially adds each package named (as a String) in the given List as a source of unique entries to the DataDictionary
046     * being constructed. Duplicate entries among any of the XML files in any of these packages will result in exceptions being
047     * thrown, hence service-initialization failure.
048     *
049     * @param baselinePackages
050     * @throws SourceException if any of the given packages can't be located
051     */
052    public void setBaselinePackages(List baselinePackages) throws IOException;
053
054    /**
055     * @return current DataDictionary
056     */
057    public DataDictionary getDataDictionary();
058
059    public void addDataDictionaryLocations(List<String> locations) throws IOException;
060
061//    /**
062//     * Hook to allow the dataDictionary service to perform any post-build initialization tasks needed before the dataDictionary
063//     * itself will be publicly available.
064//     */
065//    public void completeInitialization();
066
067    /**
068     * the html control type used to render the field
069     */
070    public ControlDefinition getAttributeControlDefinition(Class dataObjectClass, String attributeName);
071
072    /**
073     * the display size of the field if text control
074     */
075    public Integer getAttributeSize(Class dataObjectClass, String attributeName);
076
077    /**
078     * the max length defined for the given attribute name.
079     */
080    public Integer getAttributeMaxLength(Class dataObjectClass, String attributeName);
081
082    /**
083     * the regular expression defined to validate the given attribute name.
084     */
085    public Pattern getAttributeValidatingExpression(Class dataObjectClass, String attributeName);
086
087    /**
088     * the label to be used for displaying the attribute.
089     */
090    public String getAttributeLabel(Class dataObjectClass, String attributeName);
091
092    /**
093     * the short label to be used for displaying the attribute.
094     */
095    public String getAttributeShortLabel(Class dataObjectClass, String attributeName);
096
097    /**
098     * the "label (short label)" used for displaying error messages
099     */
100    public String getAttributeErrorLabel(Class dataObjectClass, String attributeName);
101
102    /**
103     * the formatter class used to format the attribute value
104     */
105    public Class<? extends Formatter> getAttributeFormatter(Class dataObjectClass, String attributeName);
106
107    /**
108     * indicates whether or not to force input text into uppercase
109     */
110    public Boolean getAttributeForceUppercase(Class dataObjectClass, String attributeName);
111
112    /**
113     * short help text for attribute
114     */
115    public String getAttributeSummary(Class dataObjectClass, String attributeName);
116
117    /**
118     * detailed help text for attribute
119     */
120    public String getAttributeDescription(Class dataObjectClass, String attributeName);
121
122    /**
123     * indicates whether or not the named attribute is required
124     */
125    public Boolean isAttributeRequired(Class dataObjectClass, String attributeName);
126
127    /**
128     * indicates whether or not the named attribute is defined in the business object xml
129     */
130    public Boolean isAttributeDefined(Class dataObjectClass, String attributeName);
131
132    /**
133     * the Class that returns a values list for this attribute
134     */
135    public Class<? extends KeyValuesFinder> getAttributeValuesFinderClass(Class dataObjectClass, String attributeName);
136
137    /**
138     * the label to be used for displaying the collection.
139     */
140    public String getCollectionLabel(Class dataObjectClass, String collectionName);
141
142    /**
143     * the short label to be used for displaying the collection.
144     */
145    public String getCollectionShortLabel(Class dataObjectClass, String collectionName);
146
147    /**
148     * short help text for collection
149     */
150    public String getCollectionSummary(Class dataObjectClass, String collectionName);
151
152    /**
153     * detailed help text for collection
154     */
155    public String getCollectionDescription(Class dataObjectClass, String collectionName);
156
157    /**
158     * the html control type used to render the field
159     */
160    public ControlDefinition getAttributeControlDefinition(String entryName, String attributeName);
161
162    /**
163     * the display size of the field if text control
164     */
165    public Integer getAttributeSize(String entryName, String attributeName);
166
167    /**
168     * the min length defined for the given attribute name.
169     */
170    public Integer getAttributeMinLength(String entryName, String attributeName);
171
172    /**
173     * the max length defined for the given attribute name.
174     */
175    public Integer getAttributeMaxLength(String entryName, String attributeName);
176
177    /**
178     * @param entryName
179     * @param attributeName
180     * @return the exclusive minimum for the specified attribute, or <code>null</code> if none.
181     */
182    public /*BigDecimal*/ String getAttributeExclusiveMin(String entryName, String attributeName);
183
184    /**
185     * @param entryName
186     * @param attributeName
187     * @return the inclusive maximum for the specified attribute, or <code>null</code> if none.
188     */
189    public /*BigDecimal*/ String getAttributeInclusiveMax(String entryName, String attributeName);
190
191    /**
192     * the regular expression defined to validate the given attribute name.
193     */
194    public Pattern getAttributeValidatingExpression(String entryName, String attributeName);
195
196    /**
197     * the label to be used for displaying the attribute.
198     */
199    public String getAttributeLabel(String entryName, String attributeName);
200
201    /**
202     * the short label to be used for displaying the attribute.
203     */
204    public String getAttributeShortLabel(String entryName, String attributeName);
205
206    /**
207     * the "label (short label)" used for displaying error messages
208     */
209    public String getAttributeErrorLabel(String entryName, String attributeName);
210
211    /**
212     * the formatter class used to format the attribute value
213     */
214    public Class<? extends Formatter> getAttributeFormatter(String entryName, String attributeName);
215
216    /**
217     * indicates whether or not to force input text into uppercase
218     */
219    public Boolean getAttributeForceUppercase(String entryName, String attributeName);
220
221    /**
222     * the AttributeSecurity object defined for the attribute's data value
223     */
224    public AttributeSecurity getAttributeSecurity(String entryName, String attributeName);
225
226    /**
227     * short help text for attribute
228     */
229    public String getAttributeSummary(String entryName, String attributeName);
230
231    /**
232     * detailed help text for attribute
233     */
234    public String getAttributeDescription(String entryName, String attributeName);
235
236    public String getAttributeValidatingErrorMessageKey(String entryName, String attributeName);
237
238    public String[] getAttributeValidatingErrorMessageParameters(String entryName, String attributeName);
239
240    /**
241     * indicates whether or not the named attribute is required
242     */
243    public Boolean isAttributeRequired(String entryName, String attributeName);
244
245    /**
246     * indicates whether or not the named attribute is defined in the business object xml
247     */
248    public Boolean isAttributeDefined(String entryName, String attributeName);
249
250    /**
251     * the Class that returns a values list for this attribute
252     */
253    public Class<? extends KeyValuesFinder> getAttributeValuesFinderClass(String entryName, String attributeName);
254
255    /**
256     * AttributeDefinition associated with the given attributeName within the given entry
257     */
258    public AttributeDefinition getAttributeDefinition(String entryName, String attributeName);
259
260    /**
261     * the label to be used for displaying the collection.
262     */
263    public String getCollectionLabel(String entryName, String collectionName);
264
265    /**
266     * the short label to be used for displaying the collection.
267     */
268    public String getCollectionShortLabel(String entryName, String collectionName);
269
270    /**
271     * the element label to be used for displaying the collection.
272     */
273    public String getCollectionElementLabel(String entryName, String collectionName, Class dataObjectClass);
274
275    /**
276     * short help text for collection
277     */
278    public String getCollectionSummary(String entryName, String collectionName);
279
280    /**
281     * detailed help text for collection
282     */
283    public String getCollectionDescription(String entryName, String collectionName);
284
285    /**
286     * @param entryName
287     * @param relationshipName
288     * @return source Class for the given relationship, or null if there is no relationship with that name
289     */
290    public Class<? extends BusinessObject> getRelationshipSourceClass(String entryName, String relationshipName);
291
292    /**
293     * @param entryName
294     * @param relationshipName
295     * @return target Class for the given relationship, or null if there is no relationship with that name
296     */
297    public Class<? extends BusinessObject> getRelationshipTargetClass(String entryName, String relationshipName);
298
299    /**
300     * @param entryName
301     * @param relationshipName
302     * @return List<String> of source attributeNames for the given relationship, or null if there is no relationship with that name
303     */
304    public List<String> getRelationshipSourceAttributes(String entryName, String relationshipName);
305
306    /**
307     * @param entryName
308     * @param relationshipName
309     * @return List<String> of target attributeNames for the given relationship, or null if there is no relationship with that name
310     */
311    public List<String> getRelationshipTargetAttributes(String entryName, String relationshipName);
312
313    /**
314     * returns a Map that specifies the attributes of the relationship
315     *
316     * @param entryName - Name of the Business Object entry
317     * @param relationshipName - Name of the relationship
318     * @return Map - Target field as key, source field as value
319     */
320    public Map<String, String> getRelationshipAttributeMap(String entryName, String relationshipName);
321
322    /**
323     * returns a list of names for all entries whose source parameter matches the parameter
324     *
325     * @param entryName Name of the Business Object entry
326     * @param sourceAttributeName name of the source attribute
327     * @return the names of all entries that use the sourceAttributeName as a primitive attribute
328     */
329    public List<String> getRelationshipEntriesForSourceAttribute(String entryName, String sourceAttributeName);
330
331    /**
332     * returns a list of names for all entries whose source parameter matches the parameter
333     *
334     * @param entryName Name of the Business Object entry
335     * @param targetAttributeName name of the target attribute
336     * @return the names of all entries that use the targetAttributeName as a primitive attribute
337     */
338    public List<String> getRelationshipEntriesForTargetAttribute(String entryName, String targetAttributeName);
339
340    /**
341     * Determines whether there is a relationship defined for the given entry with the given name
342     *
343     * @param entryName name of the BO entry
344     * @param relationshipName name of the relationship for the entry
345     * @return true iff there is a relationship with the given name defined for the BO entry in the DD
346     */
347    public boolean hasRelationship(String entryName, String relationshipName);
348
349    /**
350     * Returns all of the relationships defined for a BO in the DD
351     *
352     * @param name of the BO entry
353     * @return a list of all DD defined mappings
354     */
355    public List<String> getRelationshipNames(String entryName);
356
357//    /**
358//     * Returns the list of document class names
359//     * 
360//     * @return
361//     */
362//    public List getDocumentObjectClassnames();
363
364    /**
365     * This method returns the user friendly label based on the workflow doc type name
366     *
367     * @param documentTypeName
368     * @return label
369     */
370    public String getDocumentLabelByTypeName(String documentTypeName);
371
372    /**
373     * This method returns the user friendly label based on the document or business object class
374     *
375     * @param documentTypeName
376     * @return label
377     */
378    public String getDocumentLabelByClass(Class documentOrBusinessObjectClass);
379
380    /**
381     * Returns the document type name declared in the dd for the given document
382     * class. If no valid document type is found 'null' is returned.
383     *
384     * @param documentClass
385     * @return documentTypeName
386     */
387    public String getDocumentTypeNameByClass(Class documentClass);
388
389    /**
390     * Returns the document type name declared in the dd for the given document
391     * class. If no valid document type is found an
392     * {@link UnknownDocumentTypeException} is thrown.
393     *
394     * @param documentClass
395     * @return documentTypeName
396     */
397    public String getValidDocumentTypeNameByClass(Class documentClass);
398
399    /**
400     * Returns the document class declared in the dd for the given document type
401     * name. If no document entry is found with given document type name, 'null'
402     * will be returned.
403     *
404     * @param documentTypeName
405     * @return document Class
406     */
407    public Class<? extends Document> getDocumentClassByTypeName(String documentTypeName);
408
409    /**
410     * Returns the document class declared in the dd for the given document type
411     * name. If no document entry is found with given document type name, and
412     * {@link UnknownDocumentTypeException} will be thrown.
413     *
414     * @param documentTypeName
415     * @return document Class
416     */
417    public Class<? extends Document> getValidDocumentClassByTypeName(String documentTypeName);
418
419    /**
420     * Returns the list of attributes that should be used for grouping when determining the current
421     * status of a business object that implements InactivateableFromTo
422     *
423     * @param businessObjectClass - business object class to get configured list for
424     * @return List of string attribute names that gives the group by list
425     */
426    public List<String> getGroupByAttributesForEffectiveDating(Class businessObjectClass);
427
428    /**
429     * Returns all of the inactivation blocks registered for a particular business object
430     *
431     * @param inactivationBlockedBusinessObjectClass
432     * @return a set of all registered inactivation blocks for a particular business object
433     */
434    public Set<InactivationBlockingMetadata> getAllInactivationBlockingDefinitions(
435            Class inactivationBlockedBusinessObjectClass);
436
437    /**
438     * Returns the View entry identified by the given id
439     *
440     * @param viewId - unique id for view
441     * @return View instance associated with the id
442     */
443    public View getViewById(String viewId);
444
445    /**
446     * Returns an object from the dictionary by its spring bean name or id
447     *
448     * @param id - id or name for the bean definition
449     * @return Object object instance created or the singleton being maintained
450     */
451    public Object getDictionaryObject(String id);
452
453    /**
454     * Indicates whether the data dictionary contains a bean with the given id
455     *
456     * @param id - id of the bean to check for
457     * @return boolean true if dictionary contains bean, false otherwise
458     */
459    public boolean containsDictionaryObject(String id);
460
461    /**
462     * Returns View instance identified by the view type name and index
463     *
464     * @param viewTypeName - type name for the view
465     * @param indexKey - Map of index key parameters, these are the parameters the
466     * indexer used to index the view initially and needs to identify
467     * an unique view instance
468     * @return View instance that matches the given index
469     */
470    public View getViewByTypeIndex(ViewType viewTypeName, Map<String, String> indexKey);
471}