REST endpoint for retrieving all features for a given sprint and team
(the sprint is derived)

@param scopeId
A given scope-owner's source-system ID
@return A data response list of type Feature containing all features for
the given team and current sprint
502606
@RequestMapping(value = "/scope/{scopeId}", method = GET, produces = APPLICATION_JSON_VALUE)
	public DataResponse<List<Scope>> scope(
			@RequestParam(value = "component", required = true) String cId,
			@PathVariable String scopeId) {
		ObjectId componentId = new ObjectId(cId);
		return this.scopeService.getScope(componentId, scopeId);
	}
238197
@BenchmarkMode(Mode.AverageTime)
  @OutputTimeUnit(TimeUnit.NANOSECONDS)
  public Scope scopeTagContext(Data data) {
    Scope scope = data.tagger.withTagContext(data.tagContext);
    scope.close();
    return scope;
  }
296382
private void removeInactiveScopeOwnerByTeamId(String teamId) {
		if (!StringUtils.isEmpty(teamId)
				&& teamRepo.findByTeamId(teamId) != null) {
			ObjectId inactiveTeamId = teamRepo.findByTeamId(teamId).getId();
			if (inactiveTeamId != null) {
				teamRepo.delete(inactiveTeamId);
			}
		}
	}
1363253
@SuppressWarnings("PMD.NPathComplexity")
    protected Feature getFeature(JSONObject issue, Team board) {
        Feature feature = new Feature();
        feature.setsId(getString(issue, "id"));
        feature.setsNumber(getString(issue, "key"));

        JSONObject fields = (JSONObject) issue.get("fields");

        JSONObject epic = (JSONObject) fields.get("epic");
        String epicId = getString(fields, featureSettings.getJiraEpicIdFieldName());
        feature.setsEpicID(epic != null ? getString(epic, "id") : epicId);

        JSONObject issueType = (JSONObject) fields.get("issuetype");
        if (issueType != null) {
            feature.setsTypeId(getString(issueType, "id"));
            feature.setsTypeName(getString(issueType, "name"));
        }

        JSONObject status = (JSONObject) fields.get("status");
        String sStatus = getStatus(status);
        feature.setsState(sStatus);
        feature.setsStatus(feature.getsState());

        String summary = getString(fields, "summary");
        feature.setsName(summary);

        feature.setsUrl(featureSettings.getJiraBaseUrl() + (featureSettings.getJiraBaseUrl().endsWith("/") ? "" : "/") + "browse/" + feature.getsNumber());

        long aggEstimate = getLong(fields, "aggregatetimeoriginalestimate");
        Long estimate = getLong(fields, "timeoriginalestimate");

        int originalEstimate = 0;
        // Tasks use timetracking, stories use aggregatetimeoriginalestimate and aggregatetimeestimate
        if (estimate != 0) {
            originalEstimate = estimate.intValue();
        } else if (aggEstimate != 0) {
            // this value is in seconds
            originalEstimate = Math.round((float) aggEstimate / 3600);
        }

        feature.setsEstimateTime(originalEstimate);

        String storyPoints = getString(fields, featureSettings.getJiraStoryPointsFieldName());

        feature.setsEstimate(storyPoints);

        feature.setChangeDate(getString(fields, "updated"));
        feature.setIsDeleted("False");

        JSONObject project = (JSONObject) fields.get("project");
        feature.setsProjectID(project != null ? getString(project, "id") : "");
        feature.setsProjectName(project != null ? getString(project, "name") : "");
        // sProjectBeginDate - does not exist in Jira
        feature.setsProjectBeginDate("");
        // sProjectEndDate - does not exist in Jira
        feature.setsProjectEndDate("");
        // sProjectChangeDate - does not exist for this asset level in Jira
        feature.setsProjectChangeDate("");
        // sProjectState - does not exist in Jira
        feature.setsProjectState("");
        // sProjectIsDeleted - does not exist in Jira
        feature.setsProjectIsDeleted("False");
        // sProjectPath - does not exist in Jira
        feature.setsProjectPath("");

        if(board != null){
            feature.setsTeamID(board.getTeamId());
            feature.setsTeamName(board.getName());
        } else {
            JSONObject team = (JSONObject) fields.get(featureSettings.getJiraTeamFieldName());
            if (team != null) {
                feature.setsTeamID(getString(team, "id"));
                feature.setsTeamName(getString(team, "value"));
            }
        }
        // sTeamChangeDate - not able to retrieve at this asset level from Jira
        feature.setsTeamChangeDate("");
        // sTeamAssetState
        feature.setsTeamAssetState("");
        // sTeamIsDeleted
        feature.setsTeamIsDeleted("False");
        // sOwnersState - does not exist in Jira at this level
        feature.setsOwnersState(Collections.singletonList("Active"));
        // sOwnersChangeDate - does not exist in Jira
        feature.setsOwnersChangeDate(Collections.EMPTY_LIST);
        // sOwnersIsDeleted - does not exist in Jira
        feature.setsOwnersIsDeleted(Collections.EMPTY_LIST);
        // issueLinks
        JSONArray issueLinkArray = (JSONArray) fields.get("issuelinks");
        feature.setIssueLinks(getIssueLinks(issueLinkArray));

        Sprint sprint = getSprint(fields);
        if (sprint != null) {
            processSprintData(feature, sprint);
        }
        JSONObject assignee = (JSONObject) fields.get("assignee");
        processAssigneeData(feature, assignee);
        return feature;
    }
895343
protected List<Team> updateTeamInformation(FeatureCollector collector) {
        long projectDataStart = System.currentTimeMillis();
        List<Team> teams = featureSettings.isJiraBoardAsTeam() ? jiraClient.getBoards() : jiraClient.getTeams();
        //Add or update teams that we got from api
        teams.forEach(newTeam -> {
            String teamId = newTeam.getTeamId();
            newTeam.setCollectorId(collector.getId());
            LOGGER.info(String.format("Adding %s:%s-%s", collector.getMode(), teamId, newTeam.getName()));
            Team existing = teamRepository.findByTeamId(teamId);
            if (existing == null) {
                teamRepository.save(newTeam);
            } else {
                newTeam.setId(existing.getId());
                teamRepository.save(newTeam);
            }
        });
        log(collector.getMode() + " Data Collected. Added ", projectDataStart, teams.size());
        projectDataStart = System.currentTimeMillis();

        // Delete the ones that are gone from JIRA
        List<Team> existingTeams = teamRepository.findByCollectorId(collector.getId());
        Set<String> newTeamIds = teams.stream().map(Team::getTeamId).collect(Collectors.toSet());
        Set<Team> toDelete = existingTeams.stream().filter(e -> !newTeamIds.contains(e.getTeamId())).collect(Collectors.toSet());

        if (!CollectionUtils.isEmpty(toDelete)) {
            toDelete.forEach(td -> {
                LOGGER.info(String.format("Deleting %s:%s-%s", collector.getMode(), td.getTeamId(), td.getName()));
            });
            teamRepository.delete(toDelete);
            log(collector.getMode() + " Data Collected. Deleted ", projectDataStart, toDelete.size());
        }
        return teams;
    }
322452
public JSONObject getByTeamFull(String company, String team, HashMap<String, String> params) throws JSONException {
        return _getByType(company, team, null, params, false);
    }
624019
def get_event_team(self, id, team_id, **data):
        
        
        return self.get("/events/{0}/teams/{0}/".format(id,team_id), data=data)
1203368
@Override
	public List<CPDefinitionSpecificationOptionValue> findByGroupId(
		long groupId) {
		return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
	}
582328
@Override
    public Set<Scope> getProjects() {

        try {
            String url = featureSettings.getJiraBaseUrl() + (featureSettings.getJiraBaseUrl().endsWith("/") ? "" : "/")
                    + PROJECT_REST_SUFFIX;
            ResponseEntity<String> responseEntity = makeRestCall(url);
            String responseBody = responseEntity.getBody();

            JSONArray projects = (JSONArray) parser.parse(responseBody);

            return parseAsScopes(projects);

        } catch (ParseException pe) {
            LOGGER.error("Parser exception when parsing teams", pe);
        } catch (HygieiaException e) {
            LOGGER.error("Error in calling JIRA API", e);
        }
        return Collections.EMPTY_SET;
    }
627361
@Override
	public List<CPDefinitionOptionRel> findByGroupId(long groupId) {
		return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
	}
1142099
public FeatureList selectByGroup(String groupid) {
		FeatureList list = new FeatureList();
		for (FeatureI f : this) {
			if (f.group().equals(groupid)) {
				list.add(f);
			}
		}

		return list;
	}
1347958
public static java.util.List<com.liferay.commerce.product.model.CPDefinitionLink> getCPDefinitionLinksByUuidAndCompanyId(
		String uuid, long companyId) {
		return getService()
				   .getCPDefinitionLinksByUuidAndCompanyId(uuid, companyId);
	}
625408
public static Specification<JpaTarget> byControllerIdWithTagsInJoin(final Collection<String> controllerIDs) {
        return (targetRoot, query, cb) -> {
            final Predicate predicate = targetRoot.get(JpaTarget_.controllerId).in(controllerIDs);
            targetRoot.fetch(JpaTarget_.tags, JoinType.LEFT);
            query.distinct(true);
            return predicate;
        };
    }
263217
public com.google.api.ads.admanager.axis.v201902.TeamAccessType getTeamAccessType() {
        return teamAccessType;
    }
634811
@Override
    public void getScope(final String scopeName, final SecurityContext securityContext,
                         final AsyncResponse asyncResponse) {
        long traceId = LoggerHelpers.traceEnter(log, "getScope");

        try {
            restAuthHelper.authenticateAuthorize(
                    getAuthorizationHeader(),
                    AuthResourceRepresentation.ofScope(scopeName), READ);
        } catch (AuthException e) {
            log.warn("Get scope for {} failed due to authentication failure.", scopeName);
            asyncResponse.resume(Response.status(Status.fromStatusCode(e.getResponseCode())).build());
            LoggerHelpers.traceLeave(log, "getScope", traceId);
            return;
        }

        controllerService.getScope(scopeName)
                .thenApply(scope -> {
                        return Response.status(Status.OK).entity(new ScopeProperty().scopeName(scope)).build();
                })
                .exceptionally( exception -> {
                    if (exception.getCause() instanceof StoreException.DataNotFoundException) {
                        log.warn("Scope: {} not found", scopeName);
                        return Response.status(Status.NOT_FOUND).build();
                    } else {
                        log.warn("getScope for {} failed with exception: {}", scopeName, exception);
                        return Response.status(Status.INTERNAL_SERVER_ERROR).build();
                    }
                }).thenApply(asyncResponse::resume)
                .thenAccept(x -> LoggerHelpers.traceLeave(log, "getScope", traceId));
    }
656975
@Override
	public Page<Scope> getScopeByCollectorWithFilter(ObjectId collectorId, String projectName, Pageable pageable){

		Page<Scope> scopeItems =  scopeRepository.findAllByCollectorIdAndNameContainingIgnoreCase(collectorId,projectName,pageable);
		return scopeItems;
	}
817663
public MigrationInstruction getInstructionFor(String scopeId) {
    List<MigrationInstruction> instructions = instructionsBySourceScope.get(scopeId);

    if (instructions == null || instructions.isEmpty()) {
      return null;
    }
    else {
      return instructions.get(0);
    }
  }