source: trunk/grails-app/jobs/InventoryIndexJob.groovy @ 911

Last change on this file since 911 was 622, checked in by gav, 14 years ago

Apply bug fix for ticket #76.
Rename all instances of Lucene to Searchable.
Improved global directory config.
Add log levels for searchable plugin and compass.

File size: 1.6 KB
RevLine 
[622]1import org.codehaus.groovy.grails.commons.ConfigurationHolder
[579]2
3/**
[622]4* Provides a quartz job that rebuilds the searchable index for the inventory search.
5* With concurrent=false the next job is blocked until the previous job completes.
[579]6* We need a hibernate session otherwise we get a LazyInitializationException, default is true but we specify it to be sure.
[622]7* Rebuilding the index is required since searchable components are not updated when they change, that is
8* until the parent is updated and reindexed. Cascade update is broken in searchable-0.5.5
[579]9*/
[622]10class InventoryIndexJob {
[579]11
12    def concurrent = false
13    def sessionRequired = true
14
15    static triggers = {
16        // Cron fields:
17        // 'Seconds Minutes Hours DOM Month DOW Year(Optional)'
18        // See: http://www.quartz-scheduler.org/docs/tutorials/crontrigger.html
19        // Trigger every hour on the hour:
[622]20        //cron name: 'RebuildInventoryIndex', cronExpression: "0 0 * * * ?"
[579]21    }
22
[622]23    def execute(context) {
[579]24
25        // Some information can be accessed if we run with "def execute(context) ".
26        // For more info see: http://quartz.sourceforge.net/javadoc/org/quartz/JobExecutionContext.html
27        // log.debug context.getTrigger()
28        // log.debug context.getPreviousFireTime()
29        // log.debug context.getFireTime()
30
[622]31        // Called by.
32        def calledBy =  context.mergedJobDataMap.get('calledBy')
33        log.info "Called By: " + calledBy
34
35        // Rebuild the Inventory searchable index.
36        log.info "Calling, Inventory.index()."
37        InventoryItem.index()
[579]38    }
39}
Note: See TracBrowser for help on using the repository browser.