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 java.util.List;
19  import java.util.Map;
20  import java.util.Properties;
21  
22  import org.kuali.rice.krad.bo.BusinessObject;
23  import org.kuali.rice.krad.bo.ExternalizableBusinessObject;
24  import org.kuali.rice.krad.bo.ModuleConfiguration;
25  import org.kuali.rice.krad.datadictionary.BusinessObjectEntry;
26  import org.springframework.beans.factory.InitializingBean;
27  import org.springframework.context.ApplicationContextAware;
28  
29  /**
30   * Defines service methods for module services
31   *
32   * @author Kuali Rice Team (rice.collab@kuali.org)
33   */
34  public interface ModuleService extends InitializingBean, ApplicationContextAware {
35  
36      /**
37       * This method returns the module configuration.
38       *
39       * @return module configuration
40       */
41      public ModuleConfiguration getModuleConfiguration();
42  
43      /**
44       * This method determines whether this service is responsible for the business object class passed in, or not.
45       *
46       * @param businessObjectClass
47       * @return true if this module is responsible for the business object
48       */
49      public boolean isResponsibleFor(Class businessObjectClass);
50  
51      /**
52       * This method returns the list of primary keys for the EBO.
53       *
54       * @param businessObjectInterfaceClass
55       * @return list of primary key field names
56       */
57      public List listPrimaryKeyFieldNames(Class businessObjectInterfaceClass);
58  
59      /**
60       * This method returns a list of alternate primary keys.  This is used when the "real" primary
61       * key is not the only one that can be used.  For example, documentType has "documentTypeId"
62       * as its primary key, but the "name" could also be used.
63       * A List of Lists is returned because because there can be component keys:
64       * Ex:
65       * {name, date}
66       * {department, personId}
67       *
68       * @param businessObjectInterfaceClass
69       * @return List of List of Strings.
70       */
71      public List<List<String>> listAlternatePrimaryKeyFieldNames(Class businessObjectInterfaceClass);
72  
73      /**
74       * This method gets the business object dictionary entry for the passed in externalizable business object class.
75       *
76       * @param businessObjectInterfaceClass
77       * @return business object
78       */
79      public BusinessObjectEntry getExternalizableBusinessObjectDictionaryEntry(Class businessObjectInterfaceClass);
80  
81      /**
82       * This method gets the externalizable business object, given its type and a map of primary keys and values
83       *
84       * @param businessObjectClass
85       * @param fieldValues
86       * @return business object
87       */
88      public <T extends ExternalizableBusinessObject> T getExternalizableBusinessObject(Class<T> businessObjectClass,
89              Map<String, Object> fieldValues);
90  
91      /**
92       * This method gets the list of externalizable business objects, given its type and a map of primary keys and
93       * values.
94       *
95       * @param businessObjectClass
96       * @param fieldValues
97       * @return list of business objects
98       */
99      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