func (controller *Controller) loadRepository() { ID := controller.Ctx.Input.Param(":repository") repository, err := repository.NewRepository(ID) if err == nil { controller.Data["repository"] = repository controller.repository = repository controller.SetCustomTitle("Admin - " + repository.Name) } }
// ShowPanel shows the panel to collect data from repository func (controller *Harvest) ShowPanel() { ID := controller.Ctx.Input.Param(":id") repository, err := repository.NewRepository(ID) if err != nil { controller.Abort("show-database-error") } controller.Data["repository"] = repository controller.Data["host"] = controller.Ctx.Request.Host controller.LoadTemplate("init") }
func (controller *Controller) loadRepository() { ID := controller.Ctx.Input.Param(":repository") repository, err := repository.NewRepository(ID) if err != nil { controller.Abort("show-database-error") } controller.Data["repository"] = repository controller.repository = repository controller.SetCustomTitle(repository.Name) }
func (analyser ModuleAnalyser) digestKeywords(text string) *word.Digester { digester := word.NewDigester(text) // apply filter for each reposioty for _, repositoryID := range analyser.repositories { repository, _ := repository.NewRepository(repositoryID) digester = NewRepositoryAnalyseFilter(repository, digester).GetData() } newText := digester.ToText() return analyser.digestText(newText) }
func buildProcess(ID string, process *action.Process) *Process { local, _ := repository.NewRepository(ID) remoteServer, _ := remote.New(local) harvestProcess := &Process{ Process: process, remote: remoteServer, repository: local, notifyController: true, } return harvestProcess }
// 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 } } } }
// GetProcessesByRepository returns the processes of for the repository // 0 for showing all func GetProcessesByRepository(repositoryID, number int) []*Process { var ( list []*Process processID, harvestID int repID, limit string formats, collections, records, identifiers int ) repID = strconv.Itoa(repositoryID) if number != 0 { limit = "LIMIT 0, " + strconv.Itoa(number) } fieldList := "`id`, `process`, `formats`, `collections`, `records`, `identifiers`" orderByClause := "ORDER BY process DESC " + limit sql := "SELECT " + fieldList + " FROM `process_harvest` WHERE `repository` = ? " + orderByClause rows, err := database.Connection.Query(sql, repositoryID) if err != nil { fmt.Println("Error while selecting the processes by repository: ") fmt.Println(repositoryID) } for rows.Next() { rows.Scan(&harvestID, &processID, &formats, &collections, &records, &identifiers) rep, _ := repository.NewRepository(repID) process := Process{ Formats: formats, Records: records, Collections: collections, Identifiers: identifiers, HarvestID: harvestID, repository: rep, Process: action.NewProcess(processID), } list = append(list, &process) } return list }
// NewProcess selects from database and creates a harvest.Process by ID // NOTE! It returns only the Repository func NewProcess(processID int) *Process { var ( repID, harvestID int local *repository.Repository formats, collections, records, identifiers int ) fieldList := "`id`, `repository`, `formats`, `collections`, `records`, `identifiers`" sql := "SELECT " + fieldList + " FROM `process_harvest` WHERE process=?" query, err := database.Connection.Prepare(sql) if err != nil { fmt.Println("Error when selecting the ID of repository from harvest process:") fmt.Println(err) } query.QueryRow(processID).Scan(&harvestID, &repID, &formats, &collections, &records, &identifiers) local, err2 := repository.NewRepository(strconv.Itoa(repID)) if err2 != nil { fmt.Println(err2) } remoteServer, _ := remote.New(local) return &Process{ Formats: formats, Records: records, Collections: collections, Identifiers: identifiers, HarvestID: harvestID, repository: local, remote: remoteServer, Process: &*action.NewProcess(processID), } }