Search in sources :

Example 1 with ComponentMapping

use of org.compass.core.mapping.osem.ComponentMapping in project Gemma by PavlidisLab.

the class SearchServiceImpl method process.

/**
 * Recursively cache the highlighted text. This must be done during the search transaction.
 *
 * @param givenMappings on first call, the root mapping(s)
 */
private void process(ResourceMapping[] givenMappings, CompassHits hits) {
    for (ResourceMapping resourceMapping : givenMappings) {
        // one for each property.
        Iterator<Mapping> mappings = resourceMapping.mappingsIt();
        for (; mappings.hasNext(); ) {
            Mapping m = mappings.next();
            if (m instanceof ComponentMapping) {
                ClassMapping[] refClassMappings = ((ComponentMapping) m).getRefClassMappings();
                this.process(refClassMappings, hits);
            } else {
                String name = m.getName();
                for (int i = 0; i < hits.getLength(); i++) {
                    try {
                        // we might want to bail as soon as we find something?
                        hits.highlighter(i).fragment(name);
                        if (SearchServiceImpl.log.isDebugEnabled())
                            SearchServiceImpl.log.debug("Cached " + name);
                    } catch (Exception e) {
                        // skip this property entirely...
                        break;
                    }
                }
            }
        }
    }
}
Also used : ClassMapping(org.compass.core.mapping.osem.ClassMapping) ResourceMapping(org.compass.core.mapping.ResourceMapping) ComponentMapping(org.compass.core.mapping.osem.ComponentMapping) ResourceMapping(org.compass.core.mapping.ResourceMapping) ClassMapping(org.compass.core.mapping.osem.ClassMapping) Mapping(org.compass.core.mapping.Mapping) CompassMapping(org.compass.core.mapping.CompassMapping) ComponentMapping(org.compass.core.mapping.osem.ComponentMapping) InvocationTargetException(java.lang.reflect.InvocationTargetException) CacheException(net.sf.ehcache.CacheException)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)1 CacheException (net.sf.ehcache.CacheException)1 CompassMapping (org.compass.core.mapping.CompassMapping)1 Mapping (org.compass.core.mapping.Mapping)1 ResourceMapping (org.compass.core.mapping.ResourceMapping)1 ClassMapping (org.compass.core.mapping.osem.ClassMapping)1 ComponentMapping (org.compass.core.mapping.osem.ComponentMapping)1