コード例 #1
0
ファイル: controller.go プロジェクト: cristian-sima/Wisply
func (controller *Controller) loadProcess() {
	ID := controller.Ctx.Input.Param(":process")
	intID, err := strconv.Atoi(ID)
	if err == nil {
		process := action.NewProcess(intID)
		controller.Data["process"] = process
		controller.process = process
		controller.SetCustomTitle("Process #" + strconv.Itoa(process.ID))
	}
}
コード例 #2
0
ファイル: main.go プロジェクト: cristian-sima/Wisply
// 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
}