import org.springframework.beans.factory.InitializingBean class RasterEntryController implements InitializingBean { def grailsApplication def baseWMS def dataWMS def rasterEntrySearchService def index = { redirect(action: list, params: params) } // the delete, save and update actions only accept POST requests def allowedMethods = [delete: 'POST', save: 'POST', update: 'POST'] def list = { if ( !params.max ) params.max = 10 def rasterEntryList = RasterEntry.createCriteria().list(params) {} if ( params.rasterDataSetId ) { def rasterDataSet = RasterDataSet.get(params.rasterDataSetId) rasterEntryList = RasterEntry.createCriteria().list(params) { eq("rasterDataSet", rasterDataSet) } } else { rasterEntryList = RasterEntry.createCriteria().list(params) {} } [rasterEntryList: rasterEntryList] } def show = { def rasterEntry = RasterEntry.get(params.id) if ( !rasterEntry ) { flash.message = "RasterEntry not found with id ${params.id}" redirect(action: list) } else { return [rasterEntry: rasterEntry] } } def delete = { def rasterEntry = RasterEntry.get(params.id) if ( rasterEntry ) { rasterEntry.delete() flash.message = "RasterEntry ${params.id} deleted" redirect(action: list) } else { flash.message = "RasterEntry not found with id ${params.id}" redirect(action: list) } } def edit = { def rasterEntry = RasterEntry.get(params.id) if ( !rasterEntry ) { flash.message = "RasterEntry not found with id ${params.id}" redirect(action: list) } else { return [rasterEntry: rasterEntry] } } def update = { def rasterEntry = RasterEntry.get(params.id) if ( rasterEntry ) { rasterEntry.properties = params if ( !rasterEntry.hasErrors() && rasterEntry.save() ) { flash.message = "RasterEntry ${params.id} updated" redirect(action: show, id: rasterEntry.id) } else { render(view: 'edit', model: [rasterEntry: rasterEntry]) } } else { flash.message = "RasterEntry not found with id ${params.id}" redirect(action: edit, id: params.id) } } def create = { def rasterEntry = new RasterEntry() rasterEntry.properties = params return ['rasterEntry': rasterEntry] } def save = { def rasterEntry = new RasterEntry(params) if ( !rasterEntry.hasErrors() && rasterEntry.save() ) { flash.message = "RasterEntry ${rasterEntry.id} created" redirect(action: show, id: rasterEntry.id) } else { render(view: 'create', model: [rasterEntry: rasterEntry]) } } def search = { def queryParams = new RasterEntryQuery() bindData(queryParams, params) println "searchTag.id: ${queryParams.searchTag?.id}" if ( request.method == 'POST' ) { if ( !params.max ) params.max = 10 def rasterEntries = rasterEntrySearchService.runQuery(queryParams, params) chain(action: results, model: [rasterEntries: rasterEntries], params: params) } else return [queryParams: queryParams, baseWMS: baseWMS, dataWMS: dataWMS, sidebar:"rasterSearch"] } def results = { if ( !params.max ) params.max = 10 def rasterEntries = null def queryParams = new RasterEntryQuery() bindData(queryParams, params) if ( chainModel ) { rasterEntries = chainModel.rasterEntries } else { rasterEntries = rasterEntrySearchService.runQuery(queryParams, params) } render(view: 'results', model: [rasterEntries: rasterEntries, queryParams: queryParams]) } public void afterPropertiesSet() { baseWMS = grailsApplication.config.wms.base dataWMS = grailsApplication.config.wms.data.raster } }