import org.springframework.beans.factory.InitializingBean import org.grails.plugins.springsecurity.service.AuthenticateService import grails.converters.* class VideoDataSetController implements InitializingBean { def ext = (System.properties["os.name"] == "Windows XP") ? ".exe" : "" def serverAddress = "localhost" def mapFile = "/data/bmng.map" def baseWMS def dataWMS def index = { redirect(action: list, params: params) } AuthenticateService authenticateService def videoDataSetSearchService // the delete, save and update actions only accept POST requests def static allowedMethods = [delete: 'POST', save: 'POST', update: 'POST'] def list = { if ( !params.max ) params.max = 10 def videoDataSetList = null if ( params.repositoryId ) { def repository = Repository.get(params.repositoryId) videoDataSetList = VideoDataSet.createCriteria().list(params) { eq("repository", repository) } } else { videoDataSetList = VideoDataSet.createCriteria().list(params) {} } [videoDataSetList: videoDataSetList] /* withFormat { html { [ videoDataSetList: videoDataSetList ] } xml { render videoDataSetList as XML } json { render videoDataSetList as JSON } } */ } def show = { def videoDataSet = VideoDataSet.get(params.id) if ( !videoDataSet ) { flash.message = "VideoDataSet not found with id ${params.id}" redirect(action: list) } else { return [videoDataSet: videoDataSet] } } def delete = { def videoDataSet = VideoDataSet.get(params.id) if ( videoDataSet ) { videoDataSet.delete() flash.message = "VideoDataSet ${params.id} deleted" redirect(action: list) } else { flash.message = "VideoDataSet not found with id ${params.id}" redirect(action: list) } } def edit = { def videoDataSet = VideoDataSet.get(params.id) if ( !videoDataSet ) { flash.message = "VideoDataSet not found with id ${params.id}" redirect(action: list) } else { return [videoDataSet: videoDataSet] } } def update = { def videoDataSet = VideoDataSet.get(params.id) if ( videoDataSet ) { videoDataSet.properties = params if ( !videoDataSet.hasErrors() && videoDataSet.save() ) { flash.message = "VideoDataSet ${params.id} updated" redirect(action: show, id: videoDataSet.id) } else { render(view: 'edit', model: [videoDataSet: videoDataSet]) } } else { flash.message = "VideoDataSet not found with id ${params.id}" redirect(action: edit, id: params.id) } } def create = { def videoDataSet = new VideoDataSet() videoDataSet.properties = params return ['videoDataSet': videoDataSet] } def save = { def videoDataSet = new VideoDataSet(params) if ( !videoDataSet.hasErrors() && videoDataSet.save() ) { flash.message = "VideoDataSet ${videoDataSet.id} created" redirect(action: show, id: videoDataSet.id) } else { render(view: 'create', model: [videoDataSet: videoDataSet]) } } def search = { def queryParams = new VideoDataSetQuery() //println params bindData(queryParams, params) if ( request.method == 'POST' ) { if ( !params.max ) params.max = 10 def user = authenticateService.principal().username def starttime = System.currentTimeMillis() def videoDataSets = videoDataSetSearchService.runQuery(queryParams, params) def endtime = System.currentTimeMillis() def logData = [ TYPE: "video_search", START: new Date(starttime), END: new Date(endtime), ELAPSE_TIME_MILLIS: endtime - starttime, USER: user, PARAMS: params ] log.info(logData) println logData chain(action: results, model: [videoDataSets: videoDataSets], params: params) } else return [queryParams: queryParams, baseWMS: baseWMS, dataWMS: dataWMS, sidebar: "videoSearch"] } def results = { if ( !params.max ) { params.max = 10 } def videoDataSets = null def queryParams = new VideoDataSetQuery() bindData(queryParams, params) if ( chainModel ) { videoDataSets = chainModel.videoDataSets } else { def user = authenticateService.principal().username def starttime = System.currentTimeMillis() videoDataSets = videoDataSetSearchService.runQuery(queryParams, params) def endtime = System.currentTimeMillis() def logData = [ TYPE: "video_search", START: new Date(starttime), END: new Date(endtime), ELAPSE_TIME_MILLIS: endtime - starttime, USER: user, PARAMS: params ] log.info(logData) println logData } render(view: 'results', model: [videoDataSets: videoDataSets, queryParams: queryParams]) } public void afterPropertiesSet() { baseWMS = grailsApplication.config.wms.base dataWMS = grailsApplication.config.wms.data.video } }