// Region handles the higher level business processing for this API Call func Region(controller *bc.BaseController, region string) { defer bc.CatchPanic(controller, "Region") tracelog.STARTEDf(controller.UserId, "Region", "Region[%s]", region) buoyStations, err := buoyService.FindRegion(&controller.Service, region) if err != nil { tracelog.COMPLETED_ERRORf(err, controller.UserId, "Region", "Region[%s]", region) controller.ServeError(err) return } controller.Data["json"] = &buoyStations controller.ServeJson() tracelog.COMPLETED(controller.UserId, "Region") }
// Station handles the higher level business processing for this API Call func Station(controller *bc.BaseController, stationId string) { defer bc.CatchPanic(controller, "Station") tracelog.STARTEDf(controller.UserId, "Station", "StationId[%s]", stationId) buoyStation, err := buoyService.FindStation(&controller.Service, stationId) if err != nil { tracelog.COMPLETED_ERRORf(err, controller.UserId, "Station", "StationId[%s]", stationId) controller.ServeError(err) return } controller.Data["json"] = &buoyStation controller.ServeJson() tracelog.COMPLETED(controller.UserId, "Station") }
// Stations handles the example 3 tab // http://localhost:9003/buoy/station/42002 func (controller *BuoyController) RetrieveStationJson() { params := struct { StationId string `form:":stationId" valid:"Required; MinSize(4)" error:"invalid_station_id"` }{} if controller.ParseAndValidate(¶ms) == false { return } buoyStation, err := buoyService.FindStation(&controller.Service, params.StationId) if err != nil { tracelog.COMPLETED_ERRORf(err, controller.UserId, "Station", "StationId[%s]", params.StationId) controller.ServeError(err) return } controller.Data["json"] = &buoyStation controller.ServeJson() }
// Index is the initial view for the buoy system func (controller *BuoyController) Index() { region := "Gulf Of Mexico" tracelog.STARTEDf(controller.UserId, "BuoyController.Index", "Region[%s]", region) buoyStations, err := buoyService.FindRegion(&controller.Service, region) if err != nil { tracelog.COMPLETED_ERRORf(err, controller.UserId, "BuoyController.Index", "Region[%s]", region) controller.ServeError(err) return } controller.Data["Stations"] = buoyStations controller.Layout = "shared/basic-layout.html" controller.TplNames = "buoy/content.html" controller.LayoutSections = map[string]string{} controller.LayoutSections["PageHead"] = "buoy/page-head.html" controller.LayoutSections["Header"] = "shared/header.html" controller.LayoutSections["Modal"] = "shared/modal.html" }
// RetrieveStation handles the example 2 tab func (controller *BuoyController) RetrieveStation() { params := struct { StationId string `form:"stationId" valid:"Required; MinSize(4)" error:"invalid_station_id"` }{} if controller.ParseAndValidate(¶ms) == false { return } buoyStation, err := buoyService.FindStation(&controller.Service, params.StationId) if err != nil { tracelog.COMPLETED_ERRORf(err, controller.UserId, "BuoyController.RetrieveStation", "StationId[%s]", params.StationId) controller.ServeError(err) return } controller.Data["Station"] = buoyStation controller.Layout = "" controller.TplNames = "buoy/modal/pv_station-detail.html" view, _ := controller.RenderString() controller.AjaxResponse(0, "SUCCESS", view) }
// LoadJSON takes a json document of translations and manually // loads them into the system func LoadJSON(userLocale string, translationDocument string) error { tracelog.STARTEDf("localize", "LoadJSON", "UserLocale[%s] Length[%d]", userLocale, len(translationDocument)) tranDocuments := []map[string]interface{}{} err := json.Unmarshal([]byte(translationDocument), &tranDocuments) if err != nil { tracelog.COMPLETED_ERRORf(err, "localize", "LoadJSON", "**************>") return err } for _, tranDocument := range tranDocuments { tran, err := translation.NewTranslation(tranDocument) if err != nil { tracelog.COMPLETED_ERROR(err, "localize", "LoadJSON") return err } i18n.AddTranslation(locale.MustNew(userLocale), tran) } tracelog.COMPLETED("localize", "LoadJSON") return nil }