use of org.sonar.db.component.ComponentLinkDto in project sonarqube by SonarSource.
the class SearchMyProjectsDataLoader method load.
SearchMyProjectsData load(DbSession dbSession, SearchMyProjectsRequest request) {
SearchMyProjectsData.Builder data = builder();
ProjectsResult searchResult = searchProjects(dbSession, request);
List<ComponentDto> projects = searchResult.projects;
List<String> projectUuids = Lists.transform(projects, ComponentDto::projectUuid);
List<ComponentLinkDto> projectLinks = dbClient.componentLinkDao().selectByComponentUuids(dbSession, projectUuids);
List<SnapshotDto> snapshots = dbClient.snapshotDao().selectLastAnalysesByRootComponentUuids(dbSession, projectUuids);
MetricDto gateStatusMetric = dbClient.metricDao().selectOrFailByKey(dbSession, CoreMetrics.ALERT_STATUS_KEY);
MeasureQuery measureQuery = MeasureQuery.builder().setProjectUuids(projectUuids).setMetricId(gateStatusMetric.getId()).build();
List<MeasureDto> qualityGates = dbClient.measureDao().selectByQuery(dbSession, measureQuery);
data.setProjects(projects).setProjectLinks(projectLinks).setSnapshots(snapshots).setQualityGates(qualityGates).setTotalNbOfProjects(searchResult.total);
return data.build();
}
use of org.sonar.db.component.ComponentLinkDto in project sonarqube by SonarSource.
the class CreateAction method doHandle.
private CreateWsResponse doHandle(CreateWsRequest createWsRequest) {
validateRequest(createWsRequest);
String name = createWsRequest.getName();
String url = createWsRequest.getUrl();
try (DbSession dbSession = dbClient.openSession(false)) {
ComponentDto component = getComponentByUuidOrKey(dbSession, createWsRequest);
userSession.checkComponentPermission(UserRole.ADMIN, component);
ComponentLinkDto link = new ComponentLinkDto().setComponentUuid(component.uuid()).setName(name).setHref(url).setType(nameToType(name));
dbClient.componentLinkDao().insert(dbSession, link);
dbSession.commit();
return buildResponse(link);
}
}
use of org.sonar.db.component.ComponentLinkDto in project sonarqube by SonarSource.
the class SearchAction method doHandle.
private SearchWsResponse doHandle(SearchWsRequest searchWsRequest) {
try (DbSession dbSession = dbClient.openSession(false)) {
ComponentDto component = getComponentByUuidOrKey(dbSession, searchWsRequest);
List<ComponentLinkDto> links = dbClient.componentLinkDao().selectByComponentUuid(dbSession, component.uuid());
return buildResponse(links);
}
}
use of org.sonar.db.component.ComponentLinkDto in project sonarqube by SonarSource.
the class SearchActionTest method response_fields.
@Test
public void response_fields() throws IOException {
ComponentDto project = insertProject();
ComponentLinkDto homepageLink = insertHomepageLink(project.uuid());
ComponentLinkDto customLink = insertCustomLink(project.uuid());
logInAsProjectAdministrator(project);
SearchWsResponse response = callByKey(project.key());
assertThat(response.getLinksCount()).isEqualTo(2);
assertThat(response.getLinksList()).extracting(Link::getId, Link::getName, Link::getType, Link::getUrl).containsOnlyOnce(tuple(homepageLink.getIdAsString(), homepageLink.getName(), homepageLink.getType(), homepageLink.getHref()), tuple(customLink.getIdAsString(), customLink.getName(), customLink.getType(), customLink.getHref()));
}
use of org.sonar.db.component.ComponentLinkDto in project sonarqube by SonarSource.
the class SearchActionTest method several_projects.
@Test
public void several_projects() throws IOException {
ComponentDto project1 = insertProject();
ComponentDto project2 = insertProject("another", "abcd");
ComponentLinkDto customLink1 = insertCustomLink(project1.uuid());
insertCustomLink(project2.uuid());
userSession.logIn().setRoot();
SearchWsResponse response = callByKey(project1.key());
assertThat(response.getLinksCount()).isEqualTo(1);
assertThat(response.getLinks(0).getId()).isEqualTo(customLink1.getIdAsString());
}
Aggregations