Search in sources :

Example 1 with DateUtils

use of org.sonar.api.utils.DateUtils in project sonarqube by SonarSource.

the class SearchResponseFormat method formatIssue.

private void formatIssue(Issues.Issue.Builder issueBuilder, IssueDto dto, SearchResponseData data) {
    issueBuilder.setKey(dto.getKey());
    setNullable(dto.getType(), issueBuilder::setType, Common.RuleType::valueOf);
    ComponentDto component = data.getComponentByUuid(dto.getComponentUuid());
    issueBuilder.setOrganization(data.getOrganizationKey(component.getOrganizationUuid()));
    issueBuilder.setComponent(component.key());
    // Only used for the compatibility with the Java WS Client <= 4.4 used by Eclipse
    issueBuilder.setComponentId(component.getId());
    ComponentDto project = data.getComponentByUuid(dto.getProjectUuid());
    if (project != null) {
        issueBuilder.setProject(project.getKey());
        ComponentDto subProject = data.getComponentByUuid(dto.getModuleUuid());
        if (subProject != null && !subProject.getKey().equals(project.getKey())) {
            issueBuilder.setSubProject(subProject.getKey());
        }
    }
    issueBuilder.setRule(dto.getRuleKey().toString());
    issueBuilder.setSeverity(Common.Severity.valueOf(dto.getSeverity()));
    setNullable(emptyToNull(dto.getAssignee()), issueBuilder::setAssignee);
    setNullable(emptyToNull(dto.getResolution()), issueBuilder::setResolution);
    issueBuilder.setStatus(dto.getStatus());
    issueBuilder.setMessage(nullToEmpty(dto.getMessage()));
    issueBuilder.addAllTags(dto.getTags());
    Long effort = dto.getEffort();
    if (effort != null) {
        String effortValue = durations.encode(Duration.create(effort));
        issueBuilder.setDebt(effortValue);
        issueBuilder.setEffort(effortValue);
    }
    setNullable(dto.getLine(), issueBuilder::setLine);
    completeIssueLocations(dto, issueBuilder);
    issueBuilder.setAuthor(nullToEmpty(dto.getAuthorLogin()));
    setNullable(dto.getIssueCreationDate(), issueBuilder::setCreationDate, DateUtils::formatDateTime);
    setNullable(dto.getIssueUpdateDate(), issueBuilder::setUpdateDate, DateUtils::formatDateTime);
    setNullable(dto.getIssueCloseDate(), issueBuilder::setCloseDate, DateUtils::formatDateTime);
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) DateUtils(org.sonar.api.utils.DateUtils)

Aggregations

DateUtils (org.sonar.api.utils.DateUtils)1 ComponentDto (org.sonar.db.component.ComponentDto)1