use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.
the class ValidateProjectStep method execute.
@Override
public void execute() {
try (DbSession dbSession = dbClient.openSession(false)) {
Component root = treeRootHolder.getRoot();
List<ComponentDto> baseModules = dbClient.componentDao().selectEnabledModulesFromProjectKey(dbSession, root.getKey());
Map<String, ComponentDto> baseModulesByKey = from(baseModules).uniqueIndex(ComponentDto::key);
ValidateProjectsVisitor visitor = new ValidateProjectsVisitor(dbSession, dbClient.componentDao(), baseModulesByKey);
new DepthTraversalTypeAwareCrawler(visitor).visit(root);
if (!visitor.validationMessages.isEmpty()) {
throw MessageException.of("Validation of project failed:\n o " + MESSAGES_JOINER.join(visitor.validationMessages));
}
}
}
use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.
the class IssueUpdater method saveIssue.
public void saveIssue(DbSession session, DefaultIssue issue, IssueChangeContext context, @Nullable String comment) {
issueStorage.save(session, issue);
Optional<RuleDto> rule = getRuleByKey(session, issue.getRuleKey());
ComponentDto project = dbClient.componentDao().selectOrFailByUuid(session, issue.projectUuid());
notificationService.scheduleForSending(new IssueChangeNotification().setIssue(issue).setChangeAuthorLogin(context.login()).setRuleName(rule.isPresent() ? rule.get().getName() : null).setProject(project.getKey(), project.name()).setComponent(dbClient.componentDao().selectOrFailByUuid(session, issue.componentUuid())).setComment(comment));
}
use of org.sonar.db.component.ComponentDto 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();
}
use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.
the class DuplicationsJsonWriter method getParentProject.
private ComponentDto getParentProject(String rootUuid, Map<String, ComponentDto> subProjectsByUuid, DbSession session) {
ComponentDto project = subProjectsByUuid.get(rootUuid);
if (project == null) {
Optional<ComponentDto> projectOptional = componentDao.selectByUuid(session, rootUuid);
if (projectOptional.isPresent()) {
project = projectOptional.get();
subProjectsByUuid.put(project.uuid(), project);
}
}
return project;
}
use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.
the class DuplicationsJsonWriter method writeFiles.
private void writeFiles(Map<String, String> refByComponentKey, JsonWriter json, DbSession session) {
Map<String, ComponentDto> projectsByUuid = newHashMap();
Map<String, ComponentDto> parentProjectsByUuid = newHashMap();
for (Map.Entry<String, String> entry : refByComponentKey.entrySet()) {
String componentKey = entry.getKey();
String ref = entry.getValue();
Optional<ComponentDto> fileOptional = componentDao.selectByKey(session, componentKey);
if (fileOptional.isPresent()) {
ComponentDto file = fileOptional.get();
json.name(ref).beginObject();
addFile(json, file);
ComponentDto project = getProject(file.projectUuid(), projectsByUuid, session);
ComponentDto parentProject = getParentProject(file.getRootUuid(), parentProjectsByUuid, session);
addProject(json, project, parentProject);
json.endObject();
}
}
}
Aggregations