Exemple #1
0
// GetResources returns the resources for the repository
func (controller *Repository) GetResources() {

	ID := controller.Ctx.Input.Param(":id")
	min := controller.Ctx.Input.Param(":min")
	offset := controller.Ctx.Input.Param(":number")
	repo, err := repository.NewRepository(ID)
	collection := strings.TrimSpace(controller.GetString("collection"))
	orderBy := strings.TrimSpace(controller.GetString("orderBy"))

	if err != nil {
		controller.Abort("show-database-error")
	} else {
		options, err := database.NewSQLOptions(database.Temp{
			LimitMin: min,
			Offset:   offset,
			Limit:    100,
			OrderBy:  orderBy,
			Where: map[string]string{
				"collection": collection,
			},
		})

		if err != nil {
			controller.Abort("show-database-error")
		} else {
			records := wisply.GetRecords(repo.ID, options)
			switch strings.TrimSpace(controller.GetString("format")) {
			case "html":
				controller.Data["records"] = records
				controller.LoadTemplate("html")
				break
			case "json":
				controller.Ctx.Output.Json(records, false, false)
				break
			default:
				controller.ShowBlankPage()
				break
			}
		}
	}
}
Exemple #2
0
// SearchAnything searches for the query in all the
// - institutions
// It limits the number of results for each one to 5
func (request *Request) SearchAnything() {
	options, _ := database.NewSQLOptions(database.Temp{
		LimitMin: "0",
		Offset:   "5",
	})
	response := request.Response
	search := &search{
		query:    request.query,
		request:  request,
		response: response,
	}
	search.changeOptions(options)

	request.addEnquire(NewSubjectsSearch(search))
	request.addEnquire(NewInstitutionsSearch(search))
	request.addEnquire(NewRepositoriesSearch(search))
	request.addEnquire(NewCollectionsSearch(search))
	request.addEnquire(NewProgramsSearch(search))
	request.addEnquire(NewModulesSearch(search))

	request.addEnquire(NewResourcesSearch(search))

	request.enquireData()
}