001/**
002 * Copyright 2005-2018 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.datadictionary;
017
018import java.util.List;
019import java.util.Map;
020import java.util.Set;
021
022import org.kuali.rice.krad.datadictionary.uif.UifDictionaryIndex;
023import org.kuali.rice.krad.uif.UifConstants;
024import org.kuali.rice.krad.uif.UifConstants.ViewType;
025import org.kuali.rice.krad.uif.view.View;
026import org.springframework.beans.PropertyValues;
027
028/**
029 * Maps one Document type to other document Type.
030 *
031 * This interface can be used to implement KNS to workflow document type
032 * mapping relationships other than one-to-one.
033 *
034 * @author mpk35
035 */
036public interface DataDictionaryMapper {
037    /**
038     * This method gets the business object entry for a concrete class
039     *
040     * @param className
041     * @return business object entry
042     */
043    @Deprecated
044    public BusinessObjectEntry getBusinessObjectEntryForConcreteClass(DataDictionaryIndex index, String className);
045
046    /**
047     * This method gets the DataOjectEntry (or subclass) for a concrete class
048     *
049     * @param className
050     * @return the DataObjectEntry for the class or null if not found
051     */
052    public DataObjectEntry getDataObjectEntryForConcreteClass(DataDictionaryIndex index, String className);
053
054    /**
055     * @return List of businessObject classnames
056     */
057    @Deprecated
058    public List<String> getBusinessObjectClassNames(DataDictionaryIndex index);
059
060    /**
061     * @param className
062     * @return BusinessObjectEntry for the named class, or null if none exists
063     */
064    @Deprecated
065    public BusinessObjectEntry getBusinessObjectEntry(DataDictionaryIndex index, String className);
066
067    /**
068     * @param className
069     * @return DataObjectEntry for the named class, or null if none exists
070     */
071    public DataObjectEntry getDataObjectEntry(DataDictionaryIndex index, String className);
072
073    /**
074     * @return Map of (classname, BusinessObjectEntry) pairs
075     */
076    @Deprecated
077    public Map<String, BusinessObjectEntry> getBusinessObjectEntries(DataDictionaryIndex index);
078
079    /**
080     * @return Map of (classname, DataObjectEntry) pairs
081     */
082    public Map<String, DataObjectEntry> getDataObjectEntries(DataDictionaryIndex index);
083
084    /**
085     * @param className
086     * @return DataDictionaryEntryBase for the named class, or null if none
087     *         exists
088     */
089    public DataDictionaryEntry getDictionaryObjectEntry(DataDictionaryIndex index, String className);
090
091    /**
092     * Returns the KNS document entry for the given lookup key.  The documentTypeDDKey is interpreted
093     * successively in the following ways until a mapping is found (or none if found):
094     * <ol>
095     * <li>KEW/workflow document type</li>
096     * <li>business object class name</li>
097     * <li>maintainable class name</li>
098     * </ol>
099     * This mapping is compiled when DataDictionary files are parsed on startup (or demand).  Currently this
100     * means the mapping is static, and one-to-one (one KNS document maps directly to one and only
101     * one key).
102     *
103     * @param documentTypeDDKey the KEW/workflow document type name
104     * @return the KNS DocumentEntry if it exists
105     */
106    public DocumentEntry getDocumentEntry(DataDictionaryIndex index, String documentTypeDDKey);
107
108    /**
109     * Note: only MaintenanceDocuments are indexed by businessObject Class
110     *
111     * This is a special case that is referenced in one location. Do we need
112     * another map for this stuff??
113     *
114     * @param businessObjectClass
115     * @return DocumentEntry associated with the given Class, or null if there
116     *         is none
117     */
118    public MaintenanceDocumentEntry getMaintenanceDocumentEntryForBusinessObjectClass(DataDictionaryIndex index,
119            Class<?> businessObjectClass);
120
121    public Map<String, DocumentEntry> getDocumentEntries(DataDictionaryIndex index);
122
123    public Set<InactivationBlockingMetadata> getAllInactivationBlockingMetadatas(DataDictionaryIndex index,
124            Class<?> blockedClass);
125
126    /**
127     * Returns mapped document type based on the given document type.
128     *
129     * @param index data dictionary index
130     * @param documentTypeName document type name to check for
131     * @return new document type or null if given documentType was not found.
132     */
133    public String getDocumentTypeName(DataDictionaryIndex index, String documentTypeName);
134
135    /**
136     * Returns mapped document type class based on the given document type.
137     *
138     * @param documentType
139     * @return the class of the mapped document type or null if given documentType was not found.
140     */
141    //public Class getDocumentTypeClass(String documentTypeName);
142
143    /**
144     * Returns the View entry identified by the given id
145     *
146     * @param index - the view dictionary index
147     * @param viewId - unique id for view
148     * @return View instance associated with the id
149     */
150    public View getViewById(UifDictionaryIndex index, String viewId);
151
152    /**
153     * Gets a view instance from the pool or factory but does not replace the view, meant for view readonly
154     * access (not running the lifecycle but just checking configuration)
155     *
156     * @param index the view dictionary index
157     * @param viewId the unique id for the view
158     * @return View instance with the given id
159     */
160    public View getImmutableViewById(UifDictionaryIndex index, String viewId);
161
162    /**
163     * Called to retrieve a <code>View</code> instance that is of the given type
164     * based on the index key
165     *
166     * @param index - the view dictionary index
167     * @param viewTypeName - type name for the view
168     * @param indexKey - Map of index key parameters, these are the parameters the
169     * indexer used to index the view initially and needs to identify
170     * an unique view instance
171     * @return View instance that matches the given index
172     */
173    public View getViewByTypeIndex(UifDictionaryIndex index, ViewType viewTypeName, Map<String, String> indexKey);
174
175    /**
176     * Returns the view id for the view that matches the given view type and index
177     *
178     * @param index the view dictionary index
179     * @param viewTypeName type name for the view
180     * @param indexKey Map of index key parameters, these are the parameters the
181     * indexer used to index the view initially and needs to identify
182     * an unique view instance
183     * @return id for the view that matches the view type and index or null if a match is not found
184     */
185    public String getViewIdByTypeIndex(UifDictionaryIndex index, ViewType viewTypeName, Map<String, String> indexKey);
186
187    /**
188     * Indicates whether a <code>View</code> exists for the given view type and index information
189     *
190     * @param index - the view dictionary index
191     * @param viewTypeName - type name for the view
192     * @param indexKey - Map of index key parameters, these are the parameters the
193     * indexer used to index the view initially and needs to identify
194     * an unique view instance
195     * @return boolean true if view exists, false if not
196     */
197    public boolean viewByTypeExist(UifDictionaryIndex index, ViewType viewTypeName, Map<String, String> indexKey);
198
199    /**
200     * Gets all <code>View</code> prototypes configured for the given view type
201     * name
202     *
203     * @param index - the view dictionary index
204     * @param viewTypeName - view type name to retrieve
205     * @return List<View> view prototypes with the given type name, or empty
206     *         list
207     */
208    public List<View> getViewsForType(UifDictionaryIndex index, UifConstants.ViewType viewTypeName);
209
210    /**
211     * Retrieves the configured property values for the view bean definition associated with the given id
212     *
213     * <p>
214     * Since constructing the View object can be expensive, when metadata only is needed this method can be used
215     * to retrieve the configured property values. Note this looks at the merged bean definition
216     * </p>
217     *
218     * @param index - the view dictionary index
219     * @param viewId - id for the view to retrieve
220     * @return PropertyValues configured on the view bean definition, or null if view is not found
221     */
222    public PropertyValues getViewPropertiesById(UifDictionaryIndex index, String viewId);
223
224    /**
225     * Retrieves the configured property values for the view bean definition associated with the given type and
226     * index
227     *
228     * <p>
229     * Since constructing the View object can be expensive, when metadata only is needed this method can be used
230     * to retrieve the configured property values. Note this looks at the merged bean definition
231     * </p>
232     *
233     * @param index - the view dictionary index
234     * @param viewTypeName - type name for the view
235     * @param indexKey - Map of index key parameters, these are the parameters the indexer used to index
236     * the view initially and needs to identify an unique view instance
237     * @return PropertyValues configured on the view bean definition, or null if view is not found
238     */
239    public PropertyValues getViewPropertiesByType(UifDictionaryIndex index, UifConstants.ViewType viewTypeName,
240            Map<String, String> indexKey);
241
242}