예제 #1
0
func GetWorkflow(tx *hood.Hood, workflowId int64) *Workflow {
	var results []Workflow
	err := tx.Where("id", "=", workflowId).Find(&results)
	if err != nil {
		panic(err)
	}

	if len(results) == 0 {
		panic("could not find workflow with given id")
	} else {
		return &results[0]
	}
}
예제 #2
0
func (rdd *Rdd) GetWorkflowBatch(tx *hood.Hood) *WorkflowBatch {
	var results []WorkflowBatch
	err := tx.Where("id", "=", rdd.WorkflowBatchId).Find(&results)
	if err != nil {
		panic(err)
	}

	if len(results) == 0 {
		panic("workflow batch for rdd not found")
	} else {
		return &results[0]
	}
}
예제 #3
0
func GetSegmentCopy(tx *hood.Hood, segmentCopyId int64) *SegmentCopy {
	var results []SegmentCopy
	err := tx.Where("id", "=", segmentCopyId).Find(&results)
	if err != nil {
		panic(err)
	}

	if len(results) == 0 {
		panic("could not find segment copy with given id")
	} else {
		return &results[0]
	}
}
예제 #4
0
func (segment *Segment) GetWorker(tx *hood.Hood) *Worker {
	var results []Worker
	err := tx.Where("id", "=", segment.WorkerId).Find(&results)
	if err != nil {
		panic(err)
	}

	if len(results) == 0 {
		panic("could not find worker for segment")
	} else {
		return &results[0]
	}
}
예제 #5
0
func (segmentCopy *SegmentCopy) GetSegment(tx *hood.Hood) *Segment {
	var results []Segment
	err := tx.Where("id", "=", segmentCopy.SegmentId).Find(&results)
	if err != nil {
		panic(err)
	}

	if len(results) == 0 {
		panic("could not find rdd with given id")
	} else {
		return &results[0]
	}
}
예제 #6
0
func (segment *Segment) GetRdd(tx *hood.Hood) *Rdd {
	var results []Rdd
	err := tx.Where("id", "=", segment.RddId).Find(&results)
	if err != nil {
		panic(err)
	}

	if len(results) == 0 {
		panic("could not find rdd with given id")
	} else {
		return &results[0]
	}
}
예제 #7
0
func (workflowBatch *WorkflowBatch) GetWorkflow(tx *hood.Hood) *Workflow {
	var results []Workflow
	err := tx.Where("id", "=", workflowBatch.WorkflowId).Find(&results)
	if err != nil {
		panic(err)
	}

	if len(results) == 0 {
		panic("could not find workflow for the given workflow batch")
	} else {
		return &results[0]
	}
}
예제 #8
0
func (p *PlayerPokemon) loadMoves(_hood *hood.Hood) {
	var pokemonMoves []entities.PlayerPokemonMove

	if err := _hood.Where("pokemon_id", "=", p.GetPlayerPokemonId()).Find(&pokemonMoves); err != nil {
		log.Error("PlayerPokemon", "loadMoves", "Failed to load PlayerPokemonMoves for PlayerPokemon: %d. Error: %s", p.GetPlayerPokemonId(), err.Error())
	} else {
		for _, move := range pokemonMoves {
			if playerPokemonMove := NewPlayerPokemonMove(&move); playerPokemonMove != nil {
				p.moves[playerPokemonMove.GetPlayerPokemonMoveId()] = playerPokemonMove
			}
		}
	}
}
예제 #9
0
func (rdd *Rdd) GetProtojob(tx *hood.Hood) *Protojob {
	var results []Protojob
	err := tx.Where("id", "=", rdd.ProtojobId).Find(&results)
	if err != nil {
		panic(err)
	}

	if len(results) == 0 {
		panic("Rdd is missing protojob")
	} else {
		return &results[0]
	}
}
예제 #10
0
func (workflow *Workflow) GetLastWorkflowBatch(tx *hood.Hood) *WorkflowBatch {
	var results []WorkflowBatch
	err := tx.Where("workflow_id", "=", workflow.Id).OrderBy("start_time").Desc().Limit(1).Find(&results)
	if err != nil {
		panic(err)
	}

	if len(results) == 0 {
		return nil
	} else {
		return &results[0]
	}
}
예제 #11
0
func GetWorker(tx *hood.Hood, id int64) *Worker {
	var results []Worker
	err := tx.Where("id", "=", id).Find(&results)
	if err != nil {
		panic(err)
	}

	if len(results) == 0 {
		return nil
	} else {
		return &results[0]
	}
}
예제 #12
0
func (rdd *Rdd) GetInputEdges(tx *hood.Hood) []*RddEdge {
	var results []RddEdge
	err := tx.Where("dest_rdd_id", "=", rdd.Id).Find(&results)
	if err != nil {
		panic(err)
	}

	// Should return pointers to the result objects so that
	// they can be mutated
	pointerResults := make([]*RddEdge, len(results))
	for i := range results {
		pointerResults[i] = &results[i]
	}

	return pointerResults
}
예제 #13
0
func (protojob *Protojob) GetInputEdges(tx *hood.Hood) []*WorkflowEdge {
	var results []WorkflowEdge
	err := tx.Where("dest_job_id", "=", protojob.Id).Find(&results)
	if err != nil {
		panic(err)
	}

	// Should return pointers to the result objects so that
	// they can be mutated
	pointerResults := make([]*WorkflowEdge, len(results))
	for i := range results {
		pointerResults[i] = &results[i]
	}

	return pointerResults
}
예제 #14
0
func (segment *Segment) GetSegmentCopies(tx *hood.Hood) []*SegmentCopy {
	var results []SegmentCopy
	err := tx.Where("segment_id", "=", segment.Id).Find(&results)
	if err != nil {
		panic(err)
	}

	// Should return pointers to the result objects so that
	// they can be mutated
	pointerResults := make([]*SegmentCopy, len(results))
	for i := range results {
		pointerResults[i] = &results[i]
	}

	return pointerResults
}
예제 #15
0
func (workflow *Workflow) GetProtojobs(tx *hood.Hood) []*Protojob {
	var results []Protojob
	err := tx.Where("workflow_id", "=", workflow.Id).Find(&results)
	if err != nil {
		panic(err)
	}

	// Should return pointers to the result objects so that
	// they can be mutated
	pointerResults := make([]*Protojob, len(results))
	for i := range results {
		pointerResults[i] = &results[i]
	}

	return pointerResults
}
예제 #16
0
func GetWorkersAtAddress(tx *hood.Hood, address string) []*Worker {
	var results []Worker
	err := tx.Where("url", "=", address).Find(&results)
	if err != nil {
		panic(err)
	}

	// Should return pointers to the result objects so that
	// they can be mutated
	pointerResults := make([]*Worker, len(results))
	for i := range results {
		pointerResults[i] = &results[i]
	}

	return pointerResults
}
예제 #17
0
func GetAliveWorkers(tx *hood.Hood) []*Worker {
	var results []Worker
	err := tx.Where("status", "=", WORKER_ALIVE).Find(&results)
	if err != nil {
		panic(err)
	}

	// Should return pointers to the result objects so that
	// they can be mutated
	pointerResults := make([]*Worker, len(results))
	for i := range results {
		pointerResults[i] = &results[i]
	}

	return pointerResults
}
예제 #18
0
func (workflowBatch *WorkflowBatch) GetRdds(tx *hood.Hood) []*Rdd {
	var results []Rdd
	err := tx.Where("workflow_batch_id", "=", workflowBatch.Id).Find(&results)
	if err != nil {
		panic(err)
	}

	// Should return pointers to the result objects so that
	// they can be mutated
	pointerResults := make([]*Rdd, len(results))
	for i := range results {
		pointerResults[i] = &results[i]
	}

	return pointerResults
}
예제 #19
0
func (p *Pokemon) LinkMoves(_hood *hood.Hood) error {
	var pokemonMoves []entities.PokemonMove
	if err := _hood.Where("pokemon_id", "=", p.GetPokemonId()).Find(&pokemonMoves); err != nil {
		return err
	}

	if len(pokemonMoves) == 0 {
		return fmt.Errorf("No moves found for pokemon %d", p.GetPokemonId())
	}

	for _, pokeMove := range pokemonMoves {
		if move, found := GetMoveById(pokeMove.MoveId); found {
			p.moves[pokeMove.Level] = move
		} else {
			log.Error("Pokemon", "LinkMoves", "Move with id %d could not be found.", pokeMove.MoveId)
		}
	}

	return nil
}
예제 #20
0
func (ph *playerHelper) GetPlayerUsingCredentials(_orm *hood.Hood, _username, _password string) (interfaces.IPlayer, error) {
	var result *entities.Player
	err := _orm.Where("Username", "=", _username).Find(result)
	if err != nil {
		return nil, err
	}
	if result == nil {
		return nil, fmt.Errorf("Player '%s' not found", _username)
	}

	// Do some funky stuff to compare passwords
	if result.Password != _password {
		return nil, fmt.Errorf("Supplied credentials for username '%s' are not valid", _username)
	}

	playerModel, err := ph.ConvertPlayerEntityToModel(result)
	if err != nil {
		return nil, err
	}

	return playerModel, nil
}