Search in sources :

Example 1 with IssueDto

use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.

the class ViewIndexerTest method addProjectWithIssue.

private ComponentDto addProjectWithIssue(RuleDto rule, OrganizationDto org) {
    ComponentDto project = ComponentTesting.newProjectDto(org);
    ComponentDto file = ComponentTesting.newFileDto(project, null);
    dbTester.components().insertComponents(project, file);
    dbTester.users().insertProjectPermissionOnAnyone(UserRole.USER, project);
    IssueDto issue = IssueTesting.newDto(rule, file, project);
    dbClient.issueDao().insert(dbSession, issue);
    dbSession.commit();
    return project;
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) IssueDto(org.sonar.db.issue.IssueDto)

Example 2 with IssueDto

use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.

the class UpdateConflictResolver method resolve.

public void resolve(DefaultIssue issue, IssueMapper mapper) {
    LOG.debug("Resolve conflict on issue {}", issue.key());
    IssueDto dbIssue = mapper.selectByKey(issue.key());
    if (dbIssue != null) {
        mergeFields(dbIssue, issue);
        mapper.update(IssueDto.toDtoForUpdate(issue, System.currentTimeMillis()));
    }
}
Also used : IssueDto(org.sonar.db.issue.IssueDto)

Example 3 with IssueDto

use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.

the class ServerIssueStorage method doInsert.

@Override
protected String doInsert(DbSession session, long now, DefaultIssue issue) {
    ComponentDto component = component(session, issue);
    ComponentDto project = project(session, issue);
    int ruleId = rule(issue).getId();
    IssueDto dto = IssueDto.toDtoForServerInsert(issue, component, project, ruleId, now);
    getDbClient().issueDao().insert(session, dto);
    return dto.getKey();
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) IssueDto(org.sonar.db.issue.IssueDto)

Example 4 with IssueDto

use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.

the class ServerIssueStorage method doUpdate.

@Override
protected String doUpdate(DbSession session, long now, DefaultIssue issue) {
    IssueDto dto = IssueDto.toDtoForUpdate(issue, now);
    getDbClient().issueDao().update(session, dto);
    return dto.getKey();
}
Also used : IssueDto(org.sonar.db.issue.IssueDto)

Example 5 with IssueDto

use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.

the class SearchResponseFormat method formatIssues.

private List<Issues.Issue> formatIssues(Set<SearchAdditionalField> fields, SearchResponseData data) {
    List<Issues.Issue> result = new ArrayList<>();
    Issues.Issue.Builder issueBuilder = Issues.Issue.newBuilder();
    for (IssueDto dto : data.getIssues()) {
        issueBuilder.clear();
        formatIssue(issueBuilder, dto, data);
        if (fields.contains(SearchAdditionalField.ACTIONS)) {
            formatIssueActions(data, issueBuilder, dto);
        }
        if (fields.contains(SearchAdditionalField.TRANSITIONS)) {
            formatIssueTransitions(data, issueBuilder, dto);
        }
        if (fields.contains(SearchAdditionalField.COMMENTS)) {
            formatIssueComments(data, issueBuilder, dto);
        }
        result.add(issueBuilder.build());
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) IssueDto(org.sonar.db.issue.IssueDto)

Aggregations

IssueDto (org.sonar.db.issue.IssueDto)478 Test (org.junit.Test)425 ComponentDto (org.sonar.db.component.ComponentDto)324 RuleDefinitionDto (org.sonar.db.rule.RuleDefinitionDto)213 UserDto (org.sonar.db.user.UserDto)136 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)77 TestRequest (org.sonar.server.ws.TestRequest)66 Date (java.util.Date)60 Hotspots (org.sonarqube.ws.Hotspots)57 DefaultIssue (org.sonar.core.issue.DefaultIssue)55 IssueIndexer (org.sonar.server.issue.index.IssueIndexer)53 NotFoundException (org.sonar.server.exceptions.NotFoundException)51 DbClient (org.sonar.db.DbClient)50 List (java.util.List)49 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)49 Rule (org.junit.Rule)49 System2 (org.sonar.api.utils.System2)49 DbTester (org.sonar.db.DbTester)49 RuleDto (org.sonar.db.rule.RuleDto)49 IntStream (java.util.stream.IntStream)48