// because it can override existing mapping information. Also, it requires
// access to the application config object.
AppConfigClassMapper overrideClassMapper = new AppConfigClassMapper(grailsApplication.getConfig());
overrideClassMapper.init(compassConfiguration, (Map) configurationContext.get("customConverters"), defaultExcludes, defaultFormats);
AppConfigMappingConfigurator appConfigConfigurator = new AppConfigMappingConfigurator(grailsApplication.getConfig());
appConfigConfigurator.setMappingDescriptionProviderManager(overrideClassMapper);
appConfigConfigurator.setCompassClassMappingXmlBuilder(classMappingXmlBuilder);
Collection appConfigMapped = appConfigConfigurator.getMappedBy(grailsDomainClasses);
mappableClasses.addAll(appConfigMapped);
// Check whether search has been explicitly removed from any domain classes.
Collection unmapped = appConfigConfigurator.getUnmapped(grailsDomainClasses);
mappableClasses.removeAll(unmapped);
notMapped.addAll(unmapped);
if (LOG.isDebugEnabled() && !notMapped.isEmpty()) {
for (Iterator iter = notMapped.iterator(); iter.hasNext(); ) {
GrailsDomainClass grailsDomainClass = (GrailsDomainClass) iter.next();
LOG.debug("No mapping strategy found for class [" + grailsDomainClass.getClazz().getName() + "]: assuming this class is not searchable");
}
}
// map classes in the order defined by the classMappingConfigurators
for (int i = 0; i < classMappingConfigurators.length; i++) {
SearchableGrailsDomainClassMappingConfigurator classMappingConfigurator = classMappingConfigurators[i];
Collection classes = (Collection) classesByStrategy.get(classMappingConfigurator);
if (classes != null && !classes.isEmpty()) {
classMappingConfigurator.configureMappings(compassConfiguration, configurationContext, classes, mappableClasses);
}
}
// Finally, execute the config-based configurator so that it can add and
// override mappings.
if (appConfigMapped != null && !appConfigMapped.isEmpty()) {
appConfigConfigurator.configureMappings(compassConfiguration, configurationContext, appConfigMapped, mappableClasses);
}
}