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.service.impl;
017
018import org.apache.commons.beanutils.PropertyUtils;
019import org.apache.commons.lang.StringUtils;
020import org.apache.commons.lang.builder.ToStringBuilder;
021import org.apache.log4j.Logger;
022import org.kuali.rice.core.api.CoreApiServiceLocator;
023import org.kuali.rice.core.api.config.property.ConfigurationService;
024import org.kuali.rice.coreservice.framework.CoreFrameworkServiceLocator;
025import org.kuali.rice.coreservice.framework.parameter.ParameterService;
026import org.kuali.rice.krad.bo.BusinessObject;
027import org.kuali.rice.krad.bo.DataObjectRelationship;
028import org.kuali.rice.krad.bo.ExternalizableBusinessObject;
029import org.kuali.rice.krad.bo.ModuleConfiguration;
030import org.kuali.rice.krad.data.KradDataServiceLocator;
031import org.kuali.rice.krad.data.provider.PersistenceProvider;
032import org.kuali.rice.krad.data.provider.Provider;
033import org.kuali.rice.krad.datadictionary.BusinessObjectEntry;
034import org.kuali.rice.krad.datadictionary.PrimitiveAttributeDefinition;
035import org.kuali.rice.krad.datadictionary.RelationshipDefinition;
036import org.kuali.rice.krad.service.*;
037import org.kuali.rice.krad.uif.UifParameters;
038import org.kuali.rice.krad.util.ExternalizableBusinessObjectUtils;
039import org.kuali.rice.krad.util.KRADConstants;
040import org.kuali.rice.krad.util.UrlFactory;
041import org.springframework.beans.BeansException;
042import org.springframework.beans.factory.NoSuchBeanDefinitionException;
043import org.springframework.context.ApplicationContext;
044
045import java.lang.reflect.Modifier;
046import java.util.HashMap;
047import java.util.List;
048import java.util.Map;
049import java.util.Properties;
050
051/**
052 * @author Kuali Rice Team (rice.collab@kuali.org)
053 */
054public abstract class RemoteModuleServiceBase implements ModuleService {
055    protected static final Logger LOG = Logger.getLogger(RemoteModuleServiceBase.class);
056
057    protected ModuleConfiguration moduleConfiguration;
058    protected KualiModuleService kualiModuleService;
059    protected ApplicationContext applicationContext;
060    protected ConfigurationService kualiConfigurationService;
061    protected LookupService lookupService;
062    protected LegacyDataAdapter legacyDataAdapter;
063
064    /**
065     * @see org.kuali.rice.krad.service.ModuleService#isResponsibleFor(java.lang.Class)
066     */
067    @Override
068    public boolean isResponsibleFor(Class businessObjectClass) {
069        ModuleConfiguration mc = getModuleConfiguration();
070
071        if (mc == null) {
072            throw new IllegalStateException("Module configuration has not been initialized for the module service.");
073        }
074
075        if (businessObjectClass == null) {
076            return false;
077        }
078
079        if (packagePrefixesMatchesDataObject(businessObjectClass)) {
080            return true;
081        }
082
083        if (persistenceProvidersMatchDataObject(businessObjectClass)) {
084            return true;
085        }
086
087        if (ExternalizableBusinessObject.class.isAssignableFrom(businessObjectClass)) {
088            Class externalizableBusinessObjectInterface =
089                    ExternalizableBusinessObjectUtils.determineExternalizableBusinessObjectSubInterface(
090                            businessObjectClass);
091            if (externalizableBusinessObjectInterface != null) {
092                for (String prefix : getModuleConfiguration().getPackagePrefixes()) {
093                    if (externalizableBusinessObjectInterface.getPackage().getName().startsWith(prefix)) {
094                        return true;
095                    }
096                }
097            }
098        }
099        return false;
100    }
101
102    /**
103     * @param dataObjectClass the dataobject class
104     * @return true if package prefixes has been defined and matches a package containing the dataObject
105     */
106    protected boolean packagePrefixesMatchesDataObject(Class dataObjectClass) {
107        if (getModuleConfiguration().getPackagePrefixes() != null) {
108            for (String prefix : getModuleConfiguration().getPackagePrefixes()) {
109                if (dataObjectClass.getPackage().getName().startsWith(prefix)) {
110                    return true;
111                }
112            }
113        }
114        return false;
115    }
116
117    /**
118     * @param dataObjectClass the dataobject class
119     * @return true if a PersistenceProvider which handles the class is registered with the ModuleConfiguration
120     */
121    protected boolean persistenceProvidersMatchDataObject(Class dataObjectClass) {
122        List<Provider> providers = getModuleConfiguration().getProviders();
123        if (providers != null) {
124            for (Provider provider: providers) {
125                if (provider instanceof PersistenceProvider) {
126                    if (((PersistenceProvider) provider).handles(dataObjectClass)) {
127                        return true;
128                    }
129                }
130            }
131        }
132        return false;
133    }
134
135    /**
136     * Utility method to check for the presence of a non blank value in the map for the given key
137     * Note: returns false if a null map is passed in.
138     *
139     * @param map the map to retrieve the value from
140     * @param key the key to use
141     * @return true if there is a non-blank value in the map for the given key.
142     */
143    protected static boolean isNonBlankValueForKey(Map<String, Object> map, String key) {
144        if (map == null) return false;
145
146        Object result = map.get(key);
147        if (result instanceof String) {
148            return !StringUtils.isBlank((String)result);
149        }
150        return result != null;
151    }
152
153    @Override
154    public List listPrimaryKeyFieldNames(Class businessObjectInterfaceClass) {
155        Class clazz = getExternalizableBusinessObjectImplementation(businessObjectInterfaceClass);
156        return KRADServiceLocatorWeb.getLegacyDataAdapter().listPrimaryKeyFieldNames(clazz);
157    }
158
159    /**
160     * @see org.kuali.rice.krad.service.ModuleService#getExternalizableBusinessObjectDictionaryEntry(java.lang.Class)
161     */
162    @Override
163    public BusinessObjectEntry getExternalizableBusinessObjectDictionaryEntry(Class businessObjectInterfaceClass) {
164        Class boClass = getExternalizableBusinessObjectImplementation(businessObjectInterfaceClass);
165
166        return boClass == null ? null : KRADServiceLocatorWeb.getDataDictionaryService().getDataDictionary()
167                .getBusinessObjectEntryForConcreteClass(boClass.getName());
168    }
169
170    /**
171     * @see org.kuali.rice.krad.service.ModuleService#getExternalizableDataObjectInquiryUrl(java.lang.Class,
172     * java.util.Properties)
173     */
174    @Override
175    public String getExternalizableDataObjectInquiryUrl(Class<?> inquiryDataObjectClass, Properties parameters) {
176        String baseUrl = getBaseInquiryUrl();
177
178        // if external business object, replace data object in request with the actual impl object class
179        if (ExternalizableBusinessObject.class.isAssignableFrom(inquiryDataObjectClass)) {
180            Class implementationClass = getExternalizableBusinessObjectImplementation(inquiryDataObjectClass.asSubclass(
181                    ExternalizableBusinessObject.class));
182            if (implementationClass == null) {
183                throw new RuntimeException("Can't find ExternalizableBusinessObject implementation class for "
184                        + inquiryDataObjectClass.getName());
185            }
186
187            parameters.put(UifParameters.DATA_OBJECT_CLASS_NAME, implementationClass.getName());
188        }
189
190        return UrlFactory.parameterizeUrl(baseUrl, parameters);
191    }
192
193    /**
194     * Returns the base URL to use for inquiry requests to objects within the module
195     *
196     * @return String base inquiry URL
197     */
198    protected String getBaseInquiryUrl() {
199        return getKualiConfigurationService().getPropertyValueAsString(KRADConstants.KRAD_INQUIRY_URL_KEY);
200    }
201
202    /**
203     * @see org.kuali.rice.krad.service.ModuleService#getExternalizableDataObjectLookupUrl(java.lang.Class,
204     * java.util.Properties)
205     */
206    @Override
207    public String getExternalizableDataObjectLookupUrl(Class<?> lookupDataObjectClass, Properties parameters) {
208        String baseUrl = getBaseLookupUrl();
209
210        // if external business object, replace data object in request with the actual impl object class
211        if (ExternalizableBusinessObject.class.isAssignableFrom(lookupDataObjectClass)) {
212            Class implementationClass = getExternalizableBusinessObjectImplementation(lookupDataObjectClass.asSubclass(
213                    ExternalizableBusinessObject.class));
214            if (implementationClass == null) {
215                throw new RuntimeException("Can't find ExternalizableBusinessObject implementation class for "
216                        + lookupDataObjectClass.getName());
217            }
218
219            parameters.put(UifParameters.DATA_OBJECT_CLASS_NAME, implementationClass.getName());
220        }
221
222        return UrlFactory.parameterizeUrl(baseUrl, parameters);
223    }
224
225    /**
226     * Returns the base lookup URL for the Rice server
227     *
228     * @return String base lookup URL
229     */
230    protected String getRiceBaseLookupUrl() {
231        return BaseLookupUrlsHolder.remoteKradBaseLookupUrl;
232    }
233
234    // Lazy initialization holder class idiom, see Effective Java item #71
235    protected static final class BaseLookupUrlsHolder {
236
237        public static final String localKradBaseLookupUrl;
238        public static final String remoteKradBaseLookupUrl;
239
240        static {
241            remoteKradBaseLookupUrl = CoreApiServiceLocator.getKualiConfigurationService().getPropertyValueAsString(KRADConstants.KRAD_SERVER_LOOKUP_URL_KEY);
242            localKradBaseLookupUrl = CoreApiServiceLocator.getKualiConfigurationService().getPropertyValueAsString(KRADConstants.KRAD_LOOKUP_URL_KEY);
243        }
244    }
245
246    /**
247     * Returns the base URL to use for lookup requests to objects within the module
248     *
249     * @return String base lookup URL
250     */
251    protected String getBaseLookupUrl() {
252        return getRiceBaseLookupUrl();
253    }
254
255    @Override
256    @Deprecated
257    public String getExternalizableBusinessObjectInquiryUrl(Class inquiryBusinessObjectClass,
258            Map<String, String[]> parameters) {
259        if (!isExternalizable(inquiryBusinessObjectClass)) {
260            return KRADConstants.EMPTY_STRING;
261        }
262        String businessObjectClassAttribute;
263
264        Class implementationClass = getExternalizableBusinessObjectImplementation(inquiryBusinessObjectClass);
265        if (implementationClass == null) {
266            LOG.error("Can't find ExternalizableBusinessObject implementation class for " + inquiryBusinessObjectClass
267                    .getName());
268            throw new RuntimeException("Can't find ExternalizableBusinessObject implementation class for interface "
269                    + inquiryBusinessObjectClass.getName());
270        }
271        businessObjectClassAttribute = implementationClass.getName();
272        return UrlFactory.parameterizeUrl(getInquiryUrl(inquiryBusinessObjectClass), getUrlParameters(
273                businessObjectClassAttribute, parameters));
274    }
275
276    /**
277     * This overridden method ...
278     *
279     * @see org.kuali.rice.krad.service.ModuleService#getExternalizableBusinessObjectLookupUrl(java.lang.Class,
280     *      java.util.Map)
281     */
282    @Deprecated
283    @Override
284    public String getExternalizableBusinessObjectLookupUrl(Class inquiryBusinessObjectClass,
285            Map<String, String> parameters) {
286        Properties urlParameters = new Properties();
287
288        String riceBaseUrl = CoreApiServiceLocator.getKualiConfigurationService().getPropertyValueAsString(
289                KRADConstants.KUALI_RICE_URL_KEY);
290        String lookupUrl = riceBaseUrl;
291        if (!lookupUrl.endsWith("/")) {
292            lookupUrl = lookupUrl + "/";
293        }
294        if (parameters.containsKey(KRADConstants.MULTIPLE_VALUE)) {
295            lookupUrl = lookupUrl + KRADConstants.MULTIPLE_VALUE_LOOKUP_ACTION;
296        } else {
297            lookupUrl = lookupUrl + KRADConstants.LOOKUP_ACTION;
298        }
299        for (String paramName : parameters.keySet()) {
300            urlParameters.put(paramName, parameters.get(paramName));
301        }
302
303        Class clazz = getExternalizableBusinessObjectImplementation(inquiryBusinessObjectClass);
304        urlParameters.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, clazz == null ? "" : clazz.getName());
305
306        return UrlFactory.parameterizeUrl(lookupUrl, urlParameters);
307    }
308
309    /**
310     * @see org.kuali.rice.krad.service.ModuleService#getExternalizableBusinessObjectsListForLookup(java.lang.Class,
311     *      java.util.Map, boolean)
312     */
313    @Override
314    public <T extends ExternalizableBusinessObject> List<T> getExternalizableBusinessObjectsListForLookup(
315            Class<T> externalizableBusinessObjectClass, Map<String, Object> fieldValues, boolean unbounded) {
316        Class<? extends ExternalizableBusinessObject> implementationClass =
317                getExternalizableBusinessObjectImplementation(externalizableBusinessObjectClass);
318        if (isExternalizableBusinessObjectLookupable(implementationClass)) {
319            Map<String, String> searchCriteria = new HashMap<String, String>();
320            for (Map.Entry<String, Object> fieldValue : fieldValues.entrySet()) {
321                if (fieldValue.getValue() != null) {
322                    searchCriteria.put(fieldValue.getKey(), fieldValue.getValue().toString());
323                } else {
324                    searchCriteria.put(fieldValue.getKey(), null);
325                }
326            }
327            return (List<T>) getLookupService().findCollectionBySearchHelper(implementationClass, searchCriteria,
328                    unbounded);
329        } else {
330            throw new BusinessObjectNotLookupableException(
331                    "External business object is not a Lookupable:  " + implementationClass);
332        }
333    }
334
335    /**
336     * This method assumes that the property type for externalizable relationship in the business object is an interface
337     * and gets the concrete implementation for it
338     *
339     * {@inheritDoc}
340     */
341    @Override
342    public <T extends ExternalizableBusinessObject> T retrieveExternalizableBusinessObjectIfNecessary(
343            BusinessObject businessObject, T currentInstanceExternalizableBO, String externalizableRelationshipName) {
344
345        if (businessObject == null) {
346            return null;
347        }
348        Class clazz;
349        try {
350            Class<? extends ExternalizableBusinessObject> propertyType =
351                    (Class<? extends ExternalizableBusinessObject>)PropertyUtils.getPropertyType(businessObject,
352                            externalizableRelationshipName);
353            clazz = getExternalizableBusinessObjectImplementation(propertyType);
354        } catch (Exception iex) {
355            LOG.warn("Exception:"
356                    + iex
357                    + " thrown while trying to get property type for property:"
358                    + externalizableRelationshipName
359                    + " from business object:"
360                    + businessObject);
361            return null;
362        }
363
364        //Get the business object entry for this business object from data dictionary
365        //using the class name (without the package) as key
366        BusinessObjectEntry entry =
367                KRADServiceLocatorWeb.getDataDictionaryService().getDataDictionary().getBusinessObjectEntries().get(
368                        businessObject.getClass().getSimpleName());
369        RelationshipDefinition relationshipDefinition = entry.getRelationshipDefinition(externalizableRelationshipName);
370        List<PrimitiveAttributeDefinition> primitiveAttributeDefinitions =
371                relationshipDefinition.getPrimitiveAttributes();
372
373        Map<String, Object> fieldValuesInEBO = new HashMap<String, Object>();
374        Object sourcePropertyValue;
375        Object targetPropertyValue = null;
376        boolean sourceTargetPropertyValuesSame = true;
377        for (PrimitiveAttributeDefinition primitiveAttributeDefinition : primitiveAttributeDefinitions) {
378            sourcePropertyValue = KradDataServiceLocator.getDataObjectService().wrap(businessObject).getPropertyValueNullSafe(
379                    primitiveAttributeDefinition.getSourceName());
380            if (currentInstanceExternalizableBO != null) {
381                targetPropertyValue = KradDataServiceLocator.getDataObjectService().wrap(currentInstanceExternalizableBO).getPropertyValueNullSafe(
382                    primitiveAttributeDefinition.getTargetName());
383            }
384            if (sourcePropertyValue == null) {
385                return null;
386            } else if (targetPropertyValue == null || (targetPropertyValue != null && !targetPropertyValue.equals(
387                    sourcePropertyValue))) {
388                sourceTargetPropertyValuesSame = false;
389            }
390            fieldValuesInEBO.put(primitiveAttributeDefinition.getTargetName(), sourcePropertyValue);
391        }
392
393        if (!sourceTargetPropertyValuesSame) {
394            return (T) getExternalizableBusinessObject(clazz, fieldValuesInEBO);
395        }
396        return currentInstanceExternalizableBO;
397    }
398
399    /**
400     * This method assumes that the externalizableClazz is an interface
401     * and gets the concrete implementation for it
402     *
403     * {@inheritDoc}
404     */
405    @Override
406    public List<? extends ExternalizableBusinessObject> retrieveExternalizableBusinessObjectsList(
407            BusinessObject businessObject, String externalizableRelationshipName, Class externalizableClazz) {
408
409        if (businessObject == null) {
410            return null;
411        }
412        //Get the business object entry for this business object from data dictionary
413        //using the class name (without the package) as key
414        String className = businessObject.getClass().getName();
415        String key = className.substring(className.lastIndexOf(".") + 1);
416        BusinessObjectEntry entry =
417                KRADServiceLocatorWeb.getDataDictionaryService().getDataDictionary().getBusinessObjectEntries().get(
418                        key);
419        RelationshipDefinition relationshipDefinition = entry.getRelationshipDefinition(externalizableRelationshipName);
420        List<PrimitiveAttributeDefinition> primitiveAttributeDefinitions =
421                relationshipDefinition.getPrimitiveAttributes();
422        Map<String, Object> fieldValuesInEBO = new HashMap<String, Object>();
423        Object sourcePropertyValue;
424        for (PrimitiveAttributeDefinition primitiveAttributeDefinition : primitiveAttributeDefinitions) {
425            sourcePropertyValue = KradDataServiceLocator.getDataObjectService().wrap(businessObject).getPropertyValueNullSafe(
426                    primitiveAttributeDefinition.getSourceName());
427            if (sourcePropertyValue == null) {
428                return null;
429            }
430            fieldValuesInEBO.put(primitiveAttributeDefinition.getTargetName(), sourcePropertyValue);
431        }
432        return getExternalizableBusinessObjectsList(getExternalizableBusinessObjectImplementation(externalizableClazz),
433                fieldValuesInEBO);
434    }
435
436    /**
437     * @see org.kuali.rice.krad.service.ModuleService#getExternalizableBusinessObjectImplementation(java.lang.Class)
438     */
439    @Override
440    public <E extends ExternalizableBusinessObject> Class<E> getExternalizableBusinessObjectImplementation(
441            Class<E> externalizableBusinessObjectInterface) {
442        if (getModuleConfiguration() == null) {
443            throw new IllegalStateException("Module configuration has not been initialized for the module service.");
444        }
445        Map<Class, Class> ebos = getModuleConfiguration().getExternalizableBusinessObjectImplementations();
446        if (ebos == null) {
447            return null;
448        }
449        if (ebos.containsValue(externalizableBusinessObjectInterface)) {
450            return externalizableBusinessObjectInterface;
451        } else {
452            Class<E> implementationClass = ebos.get(externalizableBusinessObjectInterface);
453
454            int implClassModifiers = implementationClass.getModifiers();
455            if (Modifier.isInterface(implClassModifiers) || Modifier.isAbstract(implClassModifiers)) {
456                throw new RuntimeException("Implementation class must be non-abstract class: ebo interface: "
457                        + externalizableBusinessObjectInterface.getName()
458                        + " impl class: "
459                        + implementationClass.getName()
460                        + " module: "
461                        + getModuleConfiguration().getNamespaceCode());
462            }
463            return implementationClass;
464        }
465
466    }
467
468    @Deprecated
469    protected Properties getUrlParameters(String businessObjectClassAttribute, Map<String, String[]> parameters) {
470        Properties urlParameters = new Properties();
471        for (String paramName : parameters.keySet()) {
472            String[] parameterValues = parameters.get(paramName);
473            if (parameterValues.length > 0) {
474                urlParameters.put(paramName, parameterValues[0]);
475            }
476        }
477        urlParameters.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, businessObjectClassAttribute);
478        urlParameters.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, KRADConstants.CONTINUE_WITH_INQUIRY_METHOD_TO_CALL);
479        return urlParameters;
480    }
481
482    @Deprecated
483    protected String getInquiryUrl(Class inquiryBusinessObjectClass) {
484        String riceBaseUrl = CoreApiServiceLocator.getKualiConfigurationService().getPropertyValueAsString(
485                KRADConstants.KUALI_RICE_URL_KEY);
486        String inquiryUrl = riceBaseUrl;
487        if (!inquiryUrl.endsWith("/")) {
488            inquiryUrl = inquiryUrl + "/";
489        }
490        return inquiryUrl + KRADConstants.INQUIRY_ACTION;
491    }
492
493    /**
494     * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
495     */
496    @Override
497    public void afterPropertiesSet() throws Exception {
498        KualiModuleService kualiModuleService = null;
499        try {
500            kualiModuleService = KRADServiceLocatorWeb.getKualiModuleService();
501            if (kualiModuleService == null) {
502                kualiModuleService = ((KualiModuleService) applicationContext.getBean(
503                        KRADServiceLocatorWeb.KUALI_MODULE_SERVICE));
504            }
505        } catch (NoSuchBeanDefinitionException ex) {
506            kualiModuleService = ((KualiModuleService) applicationContext.getBean(
507                    KRADServiceLocatorWeb.KUALI_MODULE_SERVICE));
508        }
509        kualiModuleService.getInstalledModuleServices().add(this);
510    }
511
512    /**
513     * @return the moduleConfiguration
514     */
515    @Override
516    public ModuleConfiguration getModuleConfiguration() {
517        return this.moduleConfiguration;
518    }
519
520    /**
521     * @param moduleConfiguration the moduleConfiguration to set
522     */
523    public void setModuleConfiguration(ModuleConfiguration moduleConfiguration) {
524        this.moduleConfiguration = moduleConfiguration;
525    }
526
527    /**
528     * @see org.kuali.rice.krad.service.ModuleService#isExternalizable(java.lang.Class)
529     */
530    @Override
531    public boolean isExternalizable(Class boClazz) {
532        if (boClazz == null) {
533            return false;
534        }
535        return ExternalizableBusinessObject.class.isAssignableFrom(boClazz);
536    }
537
538    @Override
539    public <T extends ExternalizableBusinessObject> T createNewObjectFromExternalizableClass(Class<T> boClass) {
540        try {
541            return (T) getExternalizableBusinessObjectImplementation(boClass).newInstance();
542        } catch (Exception e) {
543            throw new RuntimeException("Unable to create externalizable business object class", e);
544        }
545    }
546
547    public DataObjectRelationship getBusinessObjectRelationship(Class boClass, String attributeName,
548            String attributePrefix) {
549        return null;
550    }
551
552
553    /**
554     * @return the kualiModuleService
555     */
556    public KualiModuleService getKualiModuleService() {
557        return this.kualiModuleService;
558    }
559
560    /**
561     * @param kualiModuleService the kualiModuleService to set
562     */
563    public void setKualiModuleService(KualiModuleService kualiModuleService) {
564        this.kualiModuleService = kualiModuleService;
565    }
566
567    protected ConfigurationService getKualiConfigurationService() {
568        if (this.kualiConfigurationService == null) {
569            this.kualiConfigurationService = CoreApiServiceLocator.getKualiConfigurationService();
570        }
571
572        return this.kualiConfigurationService;
573    }
574
575    public void setKualiConfigurationService(ConfigurationService kualiConfigurationService) {
576        this.kualiConfigurationService = kualiConfigurationService;
577    }
578
579    /**
580     * @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
581     */
582    @Override
583    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
584        this.applicationContext = applicationContext;
585    }
586
587    /**
588     * This overridden method ...
589     *
590     * @see org.kuali.rice.krad.service.ModuleService#listAlternatePrimaryKeyFieldNames(java.lang.Class)
591     */
592    @Override
593    public List<List<String>> listAlternatePrimaryKeyFieldNames(Class businessObjectInterfaceClass) {
594        return null;
595    }
596
597    /**
598     * This method determines whether or not this module is currently locked
599     *
600     * @see org.kuali.rice.krad.service.ModuleService#isLocked()
601     */
602    @Override
603    public boolean isLocked() {
604        ModuleConfiguration configuration = this.getModuleConfiguration();
605        if (configuration != null) {
606            String namespaceCode = configuration.getNamespaceCode();
607            String componentCode = KRADConstants.DetailTypes.ALL_DETAIL_TYPE;
608            String parameterName = KRADConstants.SystemGroupParameterNames.OLTP_LOCKOUT_ACTIVE_IND;
609            ParameterService parameterService = CoreFrameworkServiceLocator.getParameterService();
610            String shouldLockout = parameterService.getParameterValueAsString(namespaceCode, componentCode,
611                    parameterName);
612            if (StringUtils.isNotBlank(shouldLockout)) {
613                return parameterService.getParameterValueAsBoolean(namespaceCode, componentCode, parameterName);
614            }
615        }
616        return false;
617    }
618
619    /**
620     * Gets the lookupService attribute.
621     *
622     * @return Returns the lookupService.
623     */
624    protected LookupService getLookupService() {
625        return lookupService != null ? lookupService : KRADServiceLocatorWeb.getLookupService();
626    }
627
628    /**
629     * Gets the legacyDataAdapter service.
630     *
631     * @return Returns the legacyDataAdapter service.
632     */
633    protected LegacyDataAdapter getLegacyDataAdapter() {
634        return legacyDataAdapter != null ? legacyDataAdapter : KRADServiceLocatorWeb.getLegacyDataAdapter();
635    }
636
637    @Override
638    public boolean goToCentralRiceForInquiry() {
639        return false;
640    }
641
642    @Override
643    public String toString() {
644        return new ToStringBuilder(this)
645                    .append("applicationContext", applicationContext.getDisplayName())
646                    .append("moduleConfiguration", moduleConfiguration)
647                    .toString();
648    }
649}