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 java.util.List;
019import java.util.Map;
020import java.util.Properties;
021
022import org.kuali.rice.krad.bo.BusinessObject;
023import org.kuali.rice.krad.bo.ExternalizableBusinessObject;
024import org.kuali.rice.krad.bo.ModuleConfiguration;
025import org.kuali.rice.krad.datadictionary.BusinessObjectEntry;
026import org.springframework.beans.factory.InitializingBean;
027import org.springframework.context.ApplicationContextAware;
028
029/**
030 * Defines service methods for module services
031 *
032 * @author Kuali Rice Team (rice.collab@kuali.org)
033 */
034public interface ModuleService extends InitializingBean, ApplicationContextAware {
035
036    /**
037     * This method returns the module configuration.
038     *
039     * @return module configuration
040     */
041    public ModuleConfiguration getModuleConfiguration();
042
043    /**
044     * This method determines whether this service is responsible for the business object class passed in, or not.
045     *
046     * @param businessObjectClass
047     * @return true if this module is responsible for the business object
048     */
049    public boolean isResponsibleFor(Class businessObjectClass);
050
051    /**
052     * This method returns the list of primary keys for the EBO.
053     *
054     * @param businessObjectInterfaceClass
055     * @return list of primary key field names
056     */
057    public List listPrimaryKeyFieldNames(Class businessObjectInterfaceClass);
058
059    /**
060     * This method returns a list of alternate primary keys.  This is used when the "real" primary
061     * key is not the only one that can be used.  For example, documentType has "documentTypeId"
062     * as its primary key, but the "name" could also be used.
063     * A List of Lists is returned because because there can be component keys:
064     * Ex:
065     * {name, date}
066     * {department, personId}
067     *
068     * @param businessObjectInterfaceClass
069     * @return List of List of Strings.
070     */
071    public List<List<String>> listAlternatePrimaryKeyFieldNames(Class businessObjectInterfaceClass);
072
073    /**
074     * This method gets the business object dictionary entry for the passed in externalizable business object class.
075     *
076     * @param businessObjectInterfaceClass
077     * @return business object
078     */
079    public BusinessObjectEntry getExternalizableBusinessObjectDictionaryEntry(Class businessObjectInterfaceClass);
080
081    /**
082     * This method gets the externalizable business object, given its type and a map of primary keys and values
083     *
084     * @param businessObjectClass
085     * @param fieldValues
086     * @return business object
087     */
088    public <T extends ExternalizableBusinessObject> T getExternalizableBusinessObject(Class<T> businessObjectClass,
089            Map<String, Object> fieldValues);
090
091    /**
092     * This method gets the list of externalizable business objects, given its type and a map of primary keys and
093     * values.
094     *
095     * @param businessObjectClass
096     * @param fieldValues
097     * @return list of business objects
098     */
099    public <T extends ExternalizableBusinessObject> List<T> getExternalizableBusinessObjectsList(
100            Class<T> businessObjectClass, Map<String, Object> fieldValues);
101
102    /**
103     * This method gets the list of externalizable business objects for lookup, given its type and a map of primary keys
104     * and values.
105     *
106     * @param <T>
107     * @param businessObjectClass
108     * @param fieldValues
109     * @param unbounded
110     * @return list of business objects
111     */
112    public <T extends ExternalizableBusinessObject> List<T> getExternalizableBusinessObjectsListForLookup(
113            Class<T> businessObjectClass, Map<String, Object> fieldValues, boolean unbounded);
114
115    /**
116     * Returns a URL so that the inquiry framework may redirect a user to the appropriate (possibly
117     * external) website at which to view inquiry information
118     *
119     * @param inquiryDataObjectClass - a {@link ExternalizableBusinessObject} managed by this module
120     * @param parameters - any inquiry parameters, and the primary key values of the inquiry class would be
121     * in here
122     * @return String URL where externalizable object information may be viewed
123     */
124    public String getExternalizableDataObjectInquiryUrl(Class<?> inquiryDataObjectClass, Properties parameters);
125
126    /**
127     * Returns a URL so that the lookup framework may redirect a user to the appropriate (possibly
128     * external) website at which to the data for the object may be searched
129     *
130     * @param inquiryDataObjectClass - a {@link ExternalizableBusinessObject} managed by this module
131     * @param parameters - any parameters for the lookup call
132     * @return String URL where externalizable object information may be searched
133     */
134    public String getExternalizableDataObjectLookupUrl(Class<?> inquiryDataObjectClass, Properties parameters);
135
136    /**
137     * This method returns a URL so that the inquiry framework may redirect a user to the appropriate (possibly
138     * external) website
139     * at which to view inquiry information.
140     *
141     * @param inquiryBusinessObjectClass a {@link ExternalizableBusinessObject} managed by this module
142     * @param parameters any inquiry parameters, and the primary key values of the inquiryBusinessObjectClass would be
143     * in here
144     * @return a URL where externalizable business object information may be viewed.
145     * @deprecated legacy KNS call, replaced by {@link #getExternalizableDataObjectInquiryUrl(Class, java.util.Properties)}
146     * in KRAD
147     */
148    @Deprecated
149    public String getExternalizableBusinessObjectInquiryUrl(Class inquiryBusinessObjectClass,
150            Map<String, String[]> parameters);
151
152    /**
153     * This method gets the lookup url for the given externalizable business object properties.
154     *
155     * @param parameters
156     * @return lookup url
157     * @deprecated legacy KNS call, replaced by {@link #getExternalizableDataObjectLookupUrl(Class, java.util.Properties)}
158     * in KRAD
159     */
160    @Deprecated
161    public String getExternalizableBusinessObjectLookupUrl(Class inquiryBusinessObjectClass,
162            Map<String, String> parameters);
163
164    /**
165     * This method retrieves the externalizable business object, if it is not already populated
166     * with the matching primary key values.
167     *
168     * @param businessObject
169     * @param currentInstanceExternalizableBO
170     * @param externalizableRelationshipName
171     * @return business object
172     */
173    public <T extends ExternalizableBusinessObject> T retrieveExternalizableBusinessObjectIfNecessary(
174            BusinessObject businessObject, T currentInstanceExternalizableBO, String externalizableRelationshipName);
175
176    /**
177     * This method retrieves a list of externalizable business objects given a business object,
178     * name of the relationship between the business object and the externalizable business object, and
179     * the externalizable business object class.
180     *
181     * @param businessObject
182     * @param externalizableRelationshipName
183     * @param externalizableClazz
184     * @return list of externalizable business objects
185     */
186    public <T extends ExternalizableBusinessObject> List<T> retrieveExternalizableBusinessObjectsList(
187            BusinessObject businessObject, String externalizableRelationshipName, Class<T> externalizableClazz);
188
189    /**
190     * This method determines whether or not a bo class is externalizable.
191     *
192     * @param boClass
193     * @return true if the class is externalizable
194     */
195    public boolean isExternalizable(Class boClass);
196
197    /**
198     * @param boClass
199     * @return true if the class is lookupable and externalizable
200     */
201    public boolean isExternalizableBusinessObjectLookupable(Class boClass);
202
203    /**
204     * @param boClass
205     * @return true if the class is inquirable and externalizable
206     */
207    public boolean isExternalizableBusinessObjectInquirable(Class boClass);
208
209    /**
210     * @param <T> business object type
211     * @param boClass business object class
212     * @return business object
213     */
214    public <T extends ExternalizableBusinessObject> T createNewObjectFromExternalizableClass(Class<T> boClass);
215
216    /**
217     * For a given ExternalizableBusinessObject interface, return the implementation class provided by this module.
218     */
219    public <E extends ExternalizableBusinessObject> Class<E> getExternalizableBusinessObjectImplementation(
220            Class<E> externalizableBusinessObjectInterface);
221
222    /**
223     * This method determines whether or not this module is currently locked
224     */
225    public boolean isLocked();
226
227    /**
228     * This method determines whether or not the central rice server should be used for lookups.
229     *
230     * @return true if the central rice server should be used for lookups
231     */
232    public boolean goToCentralRiceForInquiry();
233}
234