/*
The objective of this PRIVATE method is to create a full data
of the Match, with it's Group and Teams (A an B teams)
175804
function findAssociated(id, next){

	var model;
	var checked = 0;

	app.models.Match.findById(id).exec(function afterFound(err, models) {
		if(!err) return afterFindMatch(models);
		next(err, null);
	});


	// Called after match is fetched. Associate with Group and Teams
	function afterFindMatch(models){
		if(models.length != 1) return next(404);

		model = models[0];

		// Fetch Both Teams
		app.models.Team.findById(model.teamAId).exec(function(err, models){
			model.teamA = models.length ? models[0] : null;
			checkFetch();
		});

		app.models.Team.findById(model.teamBId).exec(function(err, models){
			model.teamB = models.length ? models[0] : null;
			checkFetch();
		});

		// Fetch Group
		app.models.Group.findById(model.groupId).exec(function(err, models){
			model.group = models.length ? models[0] : null;
			checkFetch();
		});
	}

	function checkFetch(){
		if(++checked == 3) return next(null, model);
	}
}
456516
public void addTeamNamesCommand() {
        StringBuilder buf = new StringBuilder();
        buf.append("(team_names)");
        fifo.add(fifo.size(), buf.toString());
    }
1363271
public ApiKey createApiKey(final Team team) {
        final List<Team> teams = new ArrayList<>();
        teams.add(team);
        pm.currentTransaction().begin();
        final ApiKey apiKey = new ApiKey();
        apiKey.setKey(ApiKeyGenerator.generate());
        apiKey.setTeams(teams);
        pm.makePersistent(apiKey);
        pm.currentTransaction().commit();
        return pm.getObjectById(ApiKey.class, apiKey.getId());
    }
89299
public function team()
    {
        $teams = $this->rec->teams();
        foreach ($teams as $team) {
            if ($team->index() === $this->teamIndex) {
                return $team;
            }
        }
    }
1046279
@Override
    public Iterable<Team> getAllTeams() {
        // Get all available teams
        Iterable<Team> teams = teamRepository.findAll();

        for (Team team : teams) {
            Collector collector = collectorRepository
                    .findOne(team.getCollectorId());
            team.setCollector(collector);
        }

        return teams;
    }
1267156
public Team getTeam() throws HelloSignException {
        return new Team(httpClient.withAuth(auth).get(BASE_URI + TEAM_URI).asJson());
    }
581189
def map_team_id(code):
    """"""
    for team in TEAM_DATA:
        if team["code"] == code:
            click.secho(team["name"], fg="green")
            break
    else:
        click.secho("No team found for this code", fg="red", bold=True)
506631
def import_team_for_month(team_abbrev, year, month)
      start_date = Date.new(year.to_i, month.to_i) # first day of month
      end_date = (start_date >> 1)-1 # last day of month
      ((start_date)..(end_date)).each do |dt| 
        puts year.to_s + '/' + month.to_s + '/' + dt.day
        team = Team.new('det')
        games = team.games_for_date(year, month, dt.day.to_s)
        games.each do |game|
          import_for_game(game.gid)
        end
      end
    end
716508
public JSONObject getByTeamLimited(String company, String team, HashMap<String, String> params) throws JSONException {
        return _getByType(company, team, null, params, true);
    }
830008
@SuppressWarnings("unchecked")
    public MappedLdapGroup getMappedLdapGroup(final Team team, final String dn) {
        final Query query = pm.newQuery(MappedLdapGroup.class, "team == :team && dn == :dn");
        final List<MappedLdapGroup> result = (List<MappedLdapGroup>) query.execute(team, dn);
        return Collections.isEmpty(result) ? null : result.get(0);
    }
118017
function players (resp) {
  return base(resp).map(function (player) {
    var names = player.displayLastCommaFirst.split(", ").reverse();
    return {
      firstName: names[0].trim(),
      lastName: (names[1] ? names[1] : "").trim(),
      playerId: player.personId,
      teamId: player.teamId,
    };
  });
}
895847
public function deserialize($data, Team $team, array $options = [])
    {
        // TODO : rewrite. persist/flush are not allowed in serializers
        $this->om->startFlushSuite();

        if (!in_array(Options::REFRESH_UUID, $options)) {
            $team->setUuid($data['id']);
        }

        $this->sipe('name', 'setName', $data, $team);
        $this->sipe('description', 'setDescription', $data, $team);
        $this->sipe('selfRegistration', 'setSelfRegistration', $data, $team);
        $this->sipe('selfUnregistration', 'setSelfUnregistration', $data, $team);
        $this->sipe('publicDirectory', 'setIsPublic', $data, $team);
        $this->sipe('deletableDirectory', 'setDirDeletable', $data, $team);

        if (isset($data['workspace']['uuid'])) {
            $workspace = $this->workspaceRepo->findOneBy(['uuid' => $data['workspace']['uuid']]);

            if ($workspace) {
                $team->setWorkspace($workspace);
            }
        }

        // Checks and creates role for team members & team manager if needed.
        $teamRole = $team->getRole();
        $teamManagerRole = $team->getTeamManagerRole();

        if (empty($teamRole)) {
            $teamRole = $this->teamManager->createTeamRole($team);
            $team->setRole($teamRole);
        }
        $maxUsers = !empty($data['maxUsers']) ? $data['maxUsers'] : null;
        $team->setMaxUsers($maxUsers);
        $teamRole->setMaxUsers($maxUsers);
        $this->om->persist($teamRole);

        if (empty($teamManagerRole)) {
            $teamManagerRole = $this->teamManager->createTeamRole($team, true);
            $team->setTeamManagerRole($teamManagerRole);
        }

        // Checks and creates team directory
        $directory = $team->getDirectory();
        $user = $this->tokenStorage->getToken()->getUser();

        if (empty($directory) && 'anon.' !== $user) {
            if (isset($data['createPublicDirectory']) && $data['createPublicDirectory']) {
                $defaultResource = isset($data['defaultResource']['id']) ?
                  $this->resourceNodeRepo->findOneBy(['uuid' => $data['defaultResource']['id']]) :
                  null;
                $creatableResources = isset($data['creatableResources']) ?
                  $data['creatableResources'] :
                  [];
                $directory = $this->teamManager->createTeamDirectory(
                  $team,
                  $user,
                  $defaultResource,
                  $creatableResources
              );
                $team->setDirectory($directory);
                $this->teamManager->initializeTeamRights($team);
            }
        } elseif ('anon.' !== $user) {
            $this->teamManager->updateTeamDirectoryPerms($team);
        }

        $this->om->persist($team);
        $this->om->endFlushSuite();

        return $team;
    }
804943
function(match){
			/*
				Depending on the match state, we shall render
				a different match view. Templates are:
					+ pageview-group.match.scheduled
					+ pageview-group.match.playing
					+ pageview-group.match.endend
			*/
			var templates = {
				'scheduled': JST['pageview-group.match.scheduled'],
				'playing': JST['pageview-group.match.playing'],
				'ended': JST['pageview-group.match.ended'],
			};

			if(match.state == 'scheduled'){

				return JST['pageview-group.match.scheduled']({match: match});

			}else if(match.state == 'playing'){

				return JST['pageview-group.match.playing']({match: match});

			}else if(match.state == 'ended'){

				// In this case, we need to set the class for A and B.
				// (teamAClass and teamBClass to null, team-win, team-loose)
				return JST['pageview-group.match.ended']({
					match: match,
					
					teamAClass: (match.teamAScore > match.teamBScore ? 'team-win'
								:match.teamAScore < match.teamBScore ? 'team-loose' : ''),

					teamBClass: (match.teamBScore > match.teamAScore ? 'team-win'
								:match.teamBScore < match.teamAScore ? 'team-loose' : ''),
				});
			}
		}
239404
public Team createTeam(String name, String tag) {
        return client.sendRpcAndWait(SERVICE, "createTeam", name, tag);
    }
286104
protected function processPlayersAndTeams(Buffer &$buffer, Result &$result)
    {

        /*
         * Explode the data into groups. First is player, next is team (item_t)
         * Each group should be as follows:
         *
         * [0] => item_
         * [1] => information for item_
         * ...
         */
        $data = explode("\x00\x00", $buffer->getBuffer());

        // By default item_group is blank, this will be set for each loop thru the data
        $item_group = '';
        // By default the item_type is blank, this will be set on each loop
        $item_type = '';
        // Loop through all of the $data for information and pull it out into the result
        for ($x = 0; $x < count($data) - 1; $x++) {
            // Pull out the item
            $item = $data[$x];
            // If this is an empty item, move on
            if ($item == '' || $item == "\x00") {
                continue;
            }
            /*
            * Left as reference:
            *
            * Each block of player_ and team_t have preceding junk chars
            *
            * player_ is actually \x01player_
            * team_t is actually \x00\x02team_t
            *
            * Probably a by-product of the change to exploding the data from the original.
            *
            * For now we just strip out these characters
            */
            // Check to see if $item has a _ at the end, this is player info
            if (substr($item, -1) == '_') {
                // Set the item group
                $item_group = 'players';
                // Set the item type, rip off any trailing stuff and bad chars
                $item_type = rtrim(str_replace("\x01", '', $item), '_');
            } elseif (substr($item, -2) == '_t') {
                // Check to see if $item has a _t at the end, this is team info
                // Set the item group
                $item_group = 'teams';
                // Set the item type, rip off any trailing stuff and bad chars
                $item_type = rtrim(str_replace(["\x00", "\x02"], '', $item), '_t');
            } else {
                // We can assume it is data belonging to a previously defined item

                // Make a temp buffer so we have easier access to the data
                $buf_temp = new Buffer($item, Buffer::NUMBER_TYPE_BIGENDIAN);
                // Get the values
                while ($buf_temp->getLength()) {
                    // No value so break the loop, end of string
                    if (($val = $buf_temp->readString()) === '') {
                        break;
                    }
                    // Add the value to the proper item in the correct group
                    $result->addSub($item_group, $item_type, utf8_encode(trim($val)));
                }
                // Unset our buffer
                unset($buf_temp);
            }
        }
        // Free up some memory
        unset($data, $item, $item_group, $item_type, $val);
    }
698209
def team(self):
        """"""
        team_dict = self._json_data.get('team')
        if team_dict and team_dict.get('id'):
            return self._client.team(id=team_dict.get('id'))
        else:
            return None
401780
private static SQLPatternPart makeGroup(boolean capture, String captureLabel, SQLPatternPart part)
    {
        // Need an outer part if capturing something that's already a group (capturing or not)
        boolean alreadyGroup = (part.m_flags & (SQLPatternFactory.GROUP | SQLPatternFactory.CAPTURE)) != 0;
        SQLPatternPart retPart = alreadyGroup ? new SQLPatternPartElement(part) : part;
        if (capture) {
            retPart.m_flags |= SQLPatternFactory.CAPTURE;
            retPart.setCaptureLabel(captureLabel);
        }
        else {
            retPart.m_flags |= SQLPatternFactory.GROUP;
        }
        return retPart;
    }