Beispiel #1
0
// Test_Station checks the station service call is working
func Test_Station(t *testing.T) {
	service := Prepare()
	defer Finish(service)

	stationId := "42002"

	buoyStation, err := buoyService.FindStation(service, stationId)

	Convey("Subject: Test Station Service", t, func() {
		Convey("Should Be Able To Perform A Search", func() {
			So(err, ShouldEqual, nil)
		})
		Convey("Should Have Station Data", func() {
			So(buoyStation.StationId, ShouldEqual, stationId)
		})
	})
}
Beispiel #2
0
// 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(&params) == false {
		return
	}

	buoyStation, err := buoyService.FindStation(&controller.Service, params.StationId)
	if err != nil {
		tracelog.CompletedErrorf(err, controller.UserId, "Station", "StationId[%s]", params.StationId)
		controller.ServeError(err)
		return
	}

	controller.Data["json"] = &buoyStation
	controller.ServeJson()
}
Beispiel #3
0
// Stations handles the example 3 tab
// http://localhost:9003/buoy/station/42002
func (this *BuoyController) RetrieveStationJson() {
	params := struct {
		StationId string `form:":stationId" valid:"Required; MinSize(4)"`
	}{}

	if this.ParseAndValidate(&params) == false {
		return
	}

	buoyStation, err := buoyService.FindStation(&this.Service, params.StationId)
	if err != nil {
		tracelog.COMPLETED_ERRORf(err, this.UserId, "Station", "StationId[%s]", params.StationId)
		this.ServeError(err)
		return
	}

	this.Data["json"] = &buoyStation
	this.ServeJson()
}
Beispiel #4
0
// RetrieveStationJSON handles the example 3 tab.
// http://localhost:9003/buoy/station/42002
func (controller *BuoyController) RetrieveStationJSON() {
	// The call to ParseForm inside of ParseAndValidate is failing. This is a BAD FIX
	params := struct {
		StationID string `form:":stationId" valid:"Required; MinSize(4)" error:"invalid_station_id"`
	}{controller.GetString(":stationId")}

	if controller.ParseAndValidate(&params) == false {
		return
	}

	buoyStation, err := buoyService.FindStation(&controller.Service, params.StationID)
	if err != nil {
		log.CompletedErrorf(err, controller.UserID, "Station", "StationID[%s]", params.StationID)
		controller.ServeError(err)
		return
	}

	controller.Data["json"] = buoyStation
	controller.ServeJson()
}
Beispiel #5
0
// RetrieveStation handles the example 2 tab.
func (controller *BuoyController) RetrieveStation() {
	var params struct {
		StationID string `form:"stationID" valid:"Required; MinSize(4)" error:"invalid_station_id"`
	}

	if controller.ParseAndValidate(&params) == false {
		return
	}

	buoyStation, err := buoyService.FindStation(&controller.Service, params.StationID)
	if err != nil {
		log.CompletedErrorf(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)
}
Beispiel #6
0
// RetrieveStation handles the example 2 tab
func (this *BuoyController) RetrieveStation() {
	params := struct {
		StationId string `form:"stationId" valid:"Required; MinSize(4)"`
	}{}

	if this.ParseAndValidate(&params) == false {
		return
	}

	buoyStation, err := buoyService.FindStation(&this.Service, params.StationId)
	if err != nil {
		tracelog.COMPLETED_ERRORf(err, this.UserId, "BuoyController.RetrieveStation", "StationId[%s]", params.StationId)
		this.ServeError(err)
		return
	}

	this.Data["Station"] = buoyStation
	this.Layout = ""
	this.TplNames = "buoy/modal/pv_station-detail.html"
	view, _ := this.RenderString()

	this.AjaxResponse(0, "SUCCESS", view)
}