use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.
the class ShowAction method loadUsers.
private Users loadUsers(DbSession dbSession, IssueDto hotspot) {
UserDto assignee = ofNullable(hotspot.getAssigneeUuid()).map(uuid -> dbClient.userDao().selectByUuid(dbSession, uuid)).orElse(null);
UserDto author = ofNullable(hotspot.getAuthorLogin()).map(login -> {
if (assignee != null && assignee.getLogin().equals(login)) {
return assignee;
}
return dbClient.userDao().selectByLogin(dbSession, login);
}).orElse(null);
return new Users(assignee, author);
}
use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.
the class ShowAction method handle.
@Override
public void handle(Request request, Response response) throws Exception {
String hotspotKey = request.mandatoryParam(PARAM_HOTSPOT_KEY);
try (DbSession dbSession = dbClient.openSession(false)) {
IssueDto hotspot = hotspotWsSupport.loadHotspot(dbSession, hotspotKey);
Components components = loadComponents(dbSession, hotspot);
Users users = loadUsers(dbSession, hotspot);
RuleDefinitionDto rule = loadRule(dbSession, hotspot);
ShowWsResponse.Builder responseBuilder = ShowWsResponse.newBuilder();
formatHotspot(responseBuilder, hotspot, users);
formatComponents(components, responseBuilder);
formatRule(responseBuilder, rule);
formatTextRange(responseBuilder, hotspot);
formatFlows(dbSession, responseBuilder, hotspot);
FormattingContext formattingContext = formatChangeLogAndComments(dbSession, hotspot, users, components, responseBuilder);
formatUsers(responseBuilder, users, formattingContext);
writeProtobuf(responseBuilder.build(), request, response);
}
}
use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.
the class ChangeStatusAction method handle.
@Override
public void handle(Request request, Response response) throws Exception {
hotspotWsSupport.checkLoggedIn();
String hotspotKey = request.mandatoryParam(PARAM_HOTSPOT_KEY);
String newStatus = request.mandatoryParam(PARAM_STATUS);
String newResolution = resolutionParam(request, newStatus);
try (DbSession dbSession = dbClient.openSession(false)) {
IssueDto hotspot = hotspotWsSupport.loadHotspot(dbSession, hotspotKey);
hotspotWsSupport.loadAndCheckProject(dbSession, hotspot, UserRole.SECURITYHOTSPOT_ADMIN);
if (needStatusUpdate(hotspot, newStatus, newResolution)) {
String transitionKey = toTransitionKey(newStatus, newResolution);
doTransition(dbSession, hotspot, transitionKey, trimToNull(request.param(PARAM_COMMENT)));
}
response.noContent();
}
}
use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.
the class ExportIssuesChangelogStepTest method insertIssue.
private void insertIssue(String projectUuid, String uuid, String status) {
IssueDto dto = new IssueDto().setKee(uuid).setProjectUuid(projectUuid).setStatus(status);
dbClient.issueDao().insert(dbSession, dto);
dbSession.commit();
}
use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.
the class PersistIssuesStepTest method close_issue.
@Test
public void close_issue() {
ComponentDto project = db.components().insertPrivateProject();
ComponentDto file = db.components().insertComponent(newFileDto(project));
RuleDefinitionDto rule = db.rules().insert();
IssueDto issue = db.issues().insert(rule, project, file, i -> i.setStatus(STATUS_OPEN).setResolution(null).setCreatedAt(NOW - 1_000_000_000L).setUpdatedAt(NOW - 1_000_000_000L));
DiskCache.CacheAppender issueCacheAppender = protoIssueCache.newAppender();
issueCacheAppender.append(issue.toDefaultIssue().setStatus(STATUS_CLOSED).setResolution(RESOLUTION_FIXED).setSelectedAt(NOW).setNew(false).setChanged(true)).close();
TestComputationStepContext context = new TestComputationStepContext();
underTest.execute(context);
IssueDto issueReloaded = db.getDbClient().issueDao().selectByKey(db.getSession(), issue.getKey()).get();
assertThat(issueReloaded.getStatus()).isEqualTo(STATUS_CLOSED);
assertThat(issueReloaded.getResolution()).isEqualTo(RESOLUTION_FIXED);
assertThat(context.getStatistics().getAll()).contains(entry("inserts", "0"), entry("updates", "1"), entry("merged", "0"));
}
Aggregations