Beispiel #1
0
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
}
Beispiel #2
0
// 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),
	}
}