use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.
the class IssueUpdater method saveIssueAndPreloadSearchResponseData.
public SearchResponseData saveIssueAndPreloadSearchResponseData(DbSession dbSession, DefaultIssue issue, IssueChangeContext context, boolean refreshMeasures) {
Optional<RuleDefinitionDto> rule = getRuleByKey(dbSession, issue.getRuleKey());
ComponentDto project = dbClient.componentDao().selectOrFailByUuid(dbSession, issue.projectUuid());
BranchDto branch = getBranch(dbSession, issue, issue.projectUuid());
ComponentDto component = getComponent(dbSession, issue, issue.componentUuid());
IssueDto issueDto = doSaveIssue(dbSession, issue, context, rule, project, branch);
SearchResponseData result = new SearchResponseData(issueDto);
rule.ifPresent(r -> result.addRules(singletonList(r)));
result.addComponents(singleton(project));
result.addComponents(singleton(component));
if (refreshMeasures) {
List<DefaultIssue> changedIssues = result.getIssues().stream().map(IssueDto::toDefaultIssue).collect(MoreCollectors.toList(result.getIssues().size()));
issueChangePostProcessor.process(dbSession, changedIssues, singleton(component));
}
return result;
}
use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.
the class SearchResponseFormat method formatOperation.
Operation formatOperation(SearchResponseData data) {
Operation.Builder response = Operation.newBuilder();
if (data.getIssues().size() == 1) {
Issue.Builder issueBuilder = Issue.newBuilder();
IssueDto dto = data.getIssues().get(0);
formatIssue(issueBuilder, dto, data);
formatIssueActions(data, issueBuilder, dto);
formatIssueTransitions(data, issueBuilder, dto);
formatIssueComments(data, issueBuilder, dto);
response.setIssue(issueBuilder.build());
}
response.addAllComponents(formatComponents(data));
response.addAllRules(formatRules(data).getRulesList());
response.addAllUsers(formatUsers(data).getUsersList());
return response.build();
}
use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.
the class ChangelogAction method handle.
@Override
public void handle(Request request, Response response) throws Exception {
try (DbSession dbSession = dbClient.openSession(false)) {
IssueDto issue = issueFinder.getByKey(dbSession, request.mandatoryParam(PARAM_ISSUE));
ChangelogWsResponse build = handle(dbSession, issue);
writeProtobuf(build, request, response);
}
}
use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.
the class SearchResponseLoader method loadActionsAndTransitions.
private void loadActionsAndTransitions(SearchResponseData result, Set<SearchAdditionalField> fields) {
if (fields.contains(ACTIONS) || fields.contains(TRANSITIONS)) {
Map<String, ComponentDto> componentsByProjectUuid = result.getComponents().stream().filter(ComponentDto::isRootProject).collect(MoreCollectors.uniqueIndex(ComponentDto::projectUuid));
for (IssueDto issueDto : result.getIssues()) {
// so that IssueDto can be used.
if (fields.contains(ACTIONS)) {
ComponentDto project = componentsByProjectUuid.get(issueDto.getProjectUuid());
result.addActions(issueDto.getKey(), listAvailableActions(issueDto, project));
}
if (fields.contains(TRANSITIONS) && !issueDto.isExternal()) {
// TODO workflow and action engines must not depend on org.sonar.api.issue.Issue but on a generic interface
DefaultIssue issue = issueDto.toDefaultIssue();
result.addTransitions(issue.key(), transitionService.listTransitions(issue));
}
}
}
}
use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.
the class SetTagsAction method setTags.
private SearchResponseData setTags(String issueKey, List<String> tags) {
userSession.checkLoggedIn();
try (DbSession session = dbClient.openSession(false)) {
IssueDto issueDto = issueFinder.getByKey(session, issueKey);
DefaultIssue issue = issueDto.toDefaultIssue();
IssueChangeContext context = IssueChangeContext.createUser(new Date(), userSession.getUuid());
if (issueFieldsSetter.setTags(issue, tags, context)) {
return issueUpdater.saveIssueAndPreloadSearchResponseData(session, issue, context, false);
}
return new SearchResponseData(issueDto);
}
}
Aggregations