if (moduleUuid == null) {
throw new IllegalArgumentException(String.format("The component '%s' has no module uuid", component.uuid()));
}
- ComponentDto module = dbClient.componentDao().getByUuid(session, moduleUuid);
+ ComponentDto module = dbClient.componentDao().selectByUuid(session, moduleUuid);
keysByUUid.put(module.uuid(), module.key());
}
return keysByUUid;
private ComponentDto getProject(ComponentDto module, DbSession session) {
if (!module.isRootProject()) {
- return dbClient.componentDao().getNullableByUuid(session, module.projectUuid());
+ return dbClient.componentDao().selectNullableByUuid(session, module.projectUuid());
} else {
return module;
}
private void aggregateParentModules(ComponentDto component, List<ComponentDto> parents, DbSession session) {
String moduleUuid = component.moduleUuid();
if (moduleUuid != null) {
- ComponentDto parent = dbClient.componentDao().getByUuid(session, moduleUuid);
+ ComponentDto parent = dbClient.componentDao().selectByUuid(session, moduleUuid);
if (parent != null) {
parents.add(parent);
aggregateParentModules(parent, parents, session);
public ComponentDto getByUuid(String uuid) {
DbSession session = dbClient.openSession(false);
try {
- return dbClient.componentDao().getByUuid(session, uuid);
+ return dbClient.componentDao().selectByUuid(session, uuid);
} finally {
session.close();
}
public ComponentDto getNullableByUuid(String uuid) {
DbSession session = dbClient.openSession(false);
try {
- return dbClient.componentDao().getNullableByUuid(session, uuid);
+ return dbClient.componentDao().selectNullableByUuid(session, uuid);
} finally {
session.close();
}
public Set<String> getDistinctQualifiers(DbSession session, @Nullable Collection<String> componentUuids) {
Set<String> componentQualifiers = Sets.newHashSet();
if (componentUuids != null && !componentUuids.isEmpty()) {
- List<ComponentDto> components = dbClient.componentDao().getByUuids(session, componentUuids);
+ List<ComponentDto> components = dbClient.componentDao().selectByUuids(session, componentUuids);
for (ComponentDto component : components) {
componentQualifiers.add(component.qualifier());
public Collection<ComponentDto> getByUuids(DbSession session, Collection<String> componentUuids) {
Set<ComponentDto> directoryPaths = Sets.newHashSet();
if (componentUuids != null && !componentUuids.isEmpty()) {
- List<ComponentDto> components = dbClient.componentDao().getByUuids(session, componentUuids);
+ List<ComponentDto> components = dbClient.componentDao().selectByUuids(session, componentUuids);
for (ComponentDto component : components) {
directoryPaths.add(component);
@ServerSide
public class ComponentDao implements DaoComponent {
- public ComponentDto getById(Long id, DbSession session) {
- ComponentDto componentDto = getNullableById(id, session);
+ public ComponentDto selectById(Long id, DbSession session) {
+ ComponentDto componentDto = selectNullableById(id, session);
if (componentDto == null) {
throw new NotFoundException(String.format("Project with id '%s' not found", id));
}
}
@CheckForNull
- public ComponentDto getNullableById(Long id, DbSession session) {
+ public ComponentDto selectNullableById(Long id, DbSession session) {
return mapper(session).selectById(id);
}
@CheckForNull
- public ComponentDto getNullableByUuid(DbSession session, String uuid) {
+ public ComponentDto selectNullableByUuid(DbSession session, String uuid) {
return mapper(session).selectByUuid(uuid);
}
- public ComponentDto getByUuid(DbSession session, String uuid) {
- ComponentDto componentDto = getNullableByUuid(session, uuid);
+ public ComponentDto selectByUuid(DbSession session, String uuid) {
+ ComponentDto componentDto = selectNullableByUuid(session, uuid);
if (componentDto == null) {
throw new NotFoundException(String.format("Component with uuid '%s' not found", uuid));
}
return mapper(session).countById(id) > 0;
}
- public List<ComponentDto> findModulesByProject(String projectKey, DbSession session) {
- return mapper(session).findModulesByProject(projectKey);
+ public List<ComponentDto> selectModulesByProject(String projectKey, DbSession session) {
+ return mapper(session).selectModulesByProject(projectKey);
}
- public List<ComponentDto> findSubProjectsByComponentUuids(DbSession session, Collection<String> keys) {
+ public List<ComponentDto> selectSubProjectsByComponentUuids(DbSession session, Collection<String> keys) {
if (keys.isEmpty()) {
return Collections.emptyList();
}
- return mapper(session).findSubProjectsByComponentUuids(keys);
+ return mapper(session).selectSubProjectsByComponentUuids(keys);
}
public List<ComponentDto> selectDescendantModules(DbSession session, String rootComponentUuid) {
return mapper(session).selectEnabledFilesFromProject(rootComponentUuid);
}
- public List<ComponentDto> getByIds(final DbSession session, Collection<Long> ids) {
+ public List<ComponentDto> selectByIds(final DbSession session, Collection<Long> ids) {
return DaoUtils.executeLargeInputs(ids, new Function<List<Long>, List<ComponentDto>>() {
@Override
public List<ComponentDto> apply(List<Long> partition) {
- return mapper(session).findByIds(partition);
+ return mapper(session).selectByIds(partition);
}
});
}
- public List<ComponentDto> getByUuids(final DbSession session, Collection<String> uuids) {
+ public List<ComponentDto> selectByUuids(final DbSession session, Collection<String> uuids) {
return DaoUtils.executeLargeInputs(uuids, new Function<List<String>, List<ComponentDto>>() {
@Override
public List<ComponentDto> apply(List<String> partition) {
- return mapper(session).findByUuids(partition);
+ return mapper(session).selectByUuids(partition);
}
});
}
}
public List<ComponentDto> selectByKeys(DbSession session, Collection<String> keys) {
- return mapper(session).findByKeys(keys);
+ return mapper(session).selectByKeys(keys);
}
public ComponentDto selectByKey(DbSession session, String key) {
insert(session, Lists.asList(item, others));
}
- public List<String> findProjectUuids(DbSession session) {
- return mapper(session).findProjectUuids();
+ public List<String> selectProjectUuids(DbSession session) {
+ return mapper(session).selectProjectUuids();
}
public List<UuidWithProjectUuidDto> selectAllViewsAndSubViews(DbSession session) {
DbSession session = dbClient.openSession(false);
try {
- ComponentDto component = dbClient.componentDao().getNullableByUuid(session, componentUuid);
+ ComponentDto component = dbClient.componentDao().selectNullableByUuid(session, componentUuid);
if (component == null) {
throw new NotFoundException(String.format("Component '%s' does not exist", componentUuid));
}
json.prop("q", component.qualifier());
ComponentDto parentProject = nullableComponentById(component.parentProjectId(), session);
- ComponentDto project = dbClient.componentDao().getByUuid(session, component.projectUuid());
+ ComponentDto project = dbClient.componentDao().selectByUuid(session, component.projectUuid());
// Do not display parent project if parent project and project are the same
boolean displayParentProject = parentProject != null && !parentProject.getId().equals(project.getId());
@CheckForNull
private ComponentDto nullableComponentById(@Nullable Long componentId, DbSession session) {
if (componentId != null) {
- return dbClient.componentDao().getById(componentId, session);
+ return dbClient.componentDao().selectById(componentId, session);
}
return null;
}
DbSession session = dbClient.openSession(false);
try {
- ComponentDto componentDto = dbClient.componentDao().getByUuid(session, viewOrSubUuid);
+ ComponentDto componentDto = dbClient.componentDao().selectByUuid(session, viewOrSubUuid);
userSession.checkProjectUuidPermission(UserRole.USER, componentDto.projectUuid());
Set<Long> projectIds = newLinkedHashSet(dbClient.componentIndexDao().selectProjectIdsFromQueryAndViewOrSubViewUuid(session, query, componentDto.uuid()));
options.setPage(request.mandatoryParamAsInt(PAGE), request.mandatoryParamAsInt(PAGE_SIZE));
Set<Long> pagedProjectIds = pagedProjectIds(authorizedProjectIds, options);
- List<ComponentDto> projects = dbClient.componentDao().getByIds(session, pagedProjectIds);
+ List<ComponentDto> projects = dbClient.componentDao().selectByIds(session, pagedProjectIds);
options.writeJson(json, authorizedProjectIds.size());
json.name("components").beginArray();
DbSession session = dbClient.openSession(false);
try {
- ComponentDto fromParent = dbClient.componentDao().getByUuid(session, fromParentUuid);
- ComponentDto project = dbClient.componentDao().getByUuid(session, fromParent.projectUuid());
+ ComponentDto fromParent = dbClient.componentDao().selectByUuid(session, fromParentUuid);
+ ComponentDto project = dbClient.componentDao().selectByUuid(session, fromParent.projectUuid());
userSession.checkProjectUuidPermission(UserRole.USER, project.uuid());
List<FileDependencyDto> fileDependencies = dbClient.fileDependencyDao().selectFromParents(session, fromParentUuid, toParentUuid, project.getId());
uuids.add(fileDependency.getToComponentUuid());
}
Map<String, ComponentDto> componentsByUuid = new HashMap<>();
- for (ComponentDto componentDto : dbClient.componentDao().getByUuids(session, uuids)) {
+ for (ComponentDto componentDto : dbClient.componentDao().selectByUuids(session, uuids)) {
componentsByUuid.put(componentDto.uuid(), componentDto);
}
return componentsByUuid;
private ComponentDto getProject(String projectUuid, Map<String, ComponentDto> projectsByUuid, DbSession session) {
ComponentDto project = projectsByUuid.get(projectUuid);
if (project == null) {
- project = componentDao.getNullableByUuid(session, projectUuid);
+ project = componentDao.selectNullableByUuid(session, projectUuid);
if (project != null) {
projectsByUuid.put(project.uuid(), project);
}
private ComponentDto getParentProject(@Nullable Long projectId, Map<Long, ComponentDto> subProjectsById, DbSession session) {
ComponentDto project = subProjectsById.get(projectId);
if (project == null && projectId != null) {
- project = componentDao.getNullableById(projectId, session);
+ project = componentDao.selectNullableById(projectId, session);
if (project != null) {
subProjectsById.put(project.getId(), project);
}
DbSession session = dbClient.openSession(false);
if (fileKey == null) {
- fileKey = componentDao.getByUuid(session, fileUuid).key();
+ fileKey = componentDao.selectByUuid(session, fileUuid).key();
}
userSession.checkComponentPermission(UserRole.CODEVIEWER, fileKey);
}
private void addDeveloperTechnicalProjects(IssueQuery.Builder builder, DbSession session, Collection<String> componentUuids, Collection<String> authors) {
- Collection<ComponentDto> technicalProjects = dbClient.componentDao().getByUuids(session, componentUuids);
+ Collection<ComponentDto> technicalProjects = dbClient.componentDao().selectByUuids(session, componentUuids);
Collection<String> developerUuids = Collections2.transform(technicalProjects, new Function<ComponentDto, String>() {
@Override
public String apply(ComponentDto input) {
return input.getCopyResourceId();
}
});
- List<ComponentDto> originalProjects = dbClient.componentDao().getByIds(session, projectIds);
+ List<ComponentDto> originalProjects = dbClient.componentDao().selectByIds(session, projectIds);
Collection<String> projectUuids = Collections2.transform(originalProjects, new Function<ComponentDto, String>() {
@Override
public String apply(ComponentDto input) {
DbSession session = dbClient.openSession(false);
try {
ComponentDto component = dbClient.componentDao().selectByKey(session, componentKey);
- ComponentDto project = dbClient.componentDao().getByUuid(session, component.projectUuid());
+ ComponentDto project = dbClient.componentDao().selectByUuid(session, component.projectUuid());
userSession.checkProjectPermission(UserRole.USER, project.getKey());
if (!ruleKey.isManual()) {
try {
for (int i = 0; i < 5 && i < componentStats.size(); i++) {
String uuid = componentStats.get(i).getElement();
- String componentName = dbClient.componentDao().getByUuid(dbSession, uuid).name();
+ String componentName = dbClient.componentDao().selectByUuid(dbSession, uuid).name();
setFieldValue(metric + DOT + (i + 1) + LABEL, componentName);
setFieldValue(metric + DOT + (i + 1) + COUNT, String.valueOf(componentStats.get(i).getCount()));
}
}
private void addComponents(DbSession session, Issue issue, JsonWriter json) {
- ComponentDto component = dbClient.componentDao().getByUuid(session, issue.componentUuid());
+ ComponentDto component = dbClient.componentDao().selectByUuid(session, issue.componentUuid());
Long parentProjectId = component.parentProjectId();
- ComponentDto parentProject = parentProjectId != null ? dbClient.componentDao().getNullableById(parentProjectId, session) : null;
- ComponentDto project = dbClient.componentDao().getByUuid(session, component.projectUuid());
+ ComponentDto parentProject = parentProjectId != null ? dbClient.componentDao().selectNullableById(parentProjectId, session) : null;
+ ComponentDto project = dbClient.componentDao().selectByUuid(session, component.projectUuid());
String projectName = project.longName() != null ? project.longName() : project.name();
// Do not display sub project long name if sub project and project are the same
}
usersByLogin = getUsersByLogin(userLogins);
- List<ComponentDto> fileDtos = dbClient.componentDao().getByUuids(session, componentUuids);
- List<ComponentDto> subProjectDtos = dbClient.componentDao().findSubProjectsByComponentUuids(session, componentUuids);
+ List<ComponentDto> fileDtos = dbClient.componentDao().selectByUuids(session, componentUuids);
+ List<ComponentDto> subProjectDtos = dbClient.componentDao().selectSubProjectsByComponentUuids(session, componentUuids);
componentDtos.addAll(fileDtos);
componentDtos.addAll(subProjectDtos);
for (ComponentDto component : componentDtos) {
projectUuids.add(component.projectUuid());
}
- List<ComponentDto> projectDtos = dbClient.componentDao().getByUuids(session, projectUuids);
+ List<ComponentDto> projectDtos = dbClient.componentDao().selectByUuids(session, projectUuids);
componentDtos.addAll(projectDtos);
for (ComponentDto componentDto : componentDtos) {
componentsByUuid.put(componentDto.uuid(), componentDto);
}
private void checkPermission(Long projectId, DbSession session) {
- ComponentDto project = componentDao.getById(projectId, session);
+ ComponentDto project = componentDao.selectById(projectId, session);
if (!userSession.hasGlobalPermission(GlobalPermissions.QUALITY_PROFILE_ADMIN) && !userSession.hasProjectPermission(UserRole.ADMIN, project.key())) {
throw new ForbiddenException("Insufficient privileges");
}
}
void addProject(String profileKey, String projectUuid, UserSession userSession, DbSession session) {
- ComponentDto project = db.componentDao().getByUuid(session, projectUuid);
+ ComponentDto project = db.componentDao().selectByUuid(session, projectUuid);
checkPermission(userSession, project.key());
QualityProfileDto qualityProfile = findNotNull(profileKey, session);
public void removeProject(String profileKey, String projectUuid, UserSession userSession) {
DbSession session = db.openSession(false);
try {
- ComponentDto project = db.componentDao().getByUuid(session, projectUuid);
+ ComponentDto project = db.componentDao().selectByUuid(session, projectUuid);
checkPermission(userSession, project.key());
QualityProfileDto qualityProfile = findNotNull(profileKey, session);
public void removeProject(String language, long projectId, UserSession userSession) {
DbSession session = db.openSession(false);
try {
- ComponentDto project = db.componentDao().getById(projectId, session);
+ ComponentDto project = db.componentDao().selectById(projectId, session);
checkPermission(userSession, project.key());
QualityProfileDto associatedProfile = db.qualityProfileDao().getByProjectAndLanguage(project.getKey(), language, session);
try {
String fileUuid = request.param(PARAM_UUID);
if (fileUuid != null) {
- return dbClient.componentDao().getByUuid(session, fileUuid);
+ return dbClient.componentDao().selectByUuid(session, fileUuid);
}
String fileKey = request.param(PARAM_KEY);
if (fileKey != null) {
DbSession dbSession = dbClient.openSession(false);
List<ComponentDto> components;
try {
- components = dbClient.componentDao().getByUuids(dbSession, sourceFileUuids);
+ components = dbClient.componentDao().selectByUuids(dbSession, sourceFileUuids);
} finally {
MyBatis.closeQuietly(dbSession);
}
return testDoc.fileUuid();
}
});
- List<ComponentDto> components = dbClient.componentDao().getByUuids(dbSession, fileUuids);
+ List<ComponentDto> components = dbClient.componentDao().selectByUuids(dbSession, fileUuids);
return Maps.uniqueIndex(components, new NonNullInputFunction<ComponentDto, String>() {
@Override
}
private void checkComponentUuidPermission(DbSession dbSession, String componentUuid) {
- ComponentDto component = dbClient.componentDao().getByUuid(dbSession, componentUuid);
+ ComponentDto component = dbClient.componentDao().selectByUuid(dbSession, componentUuid);
userSession.checkProjectUuidPermission(UserRole.CODEVIEWER, component.projectUuid());
}
}
SnapshotDto currentSnapshot = snapshot;
while (currentSnapshot.getParentId() != null) {
currentSnapshot = dbClient.snapshotDao().getByKey(session, currentSnapshot.getParentId());
- componentPath.add(0, dbClient.componentDao().getById(currentSnapshot.getResourceId(), session));
+ componentPath.add(0, dbClient.componentDao().selectById(currentSnapshot.getResourceId(), session));
}
}
public void get_by_uuid() {
loadBasicDataInDatabase();
- ComponentDto result = sut.getNullableByUuid(session, "KLMN");
+ ComponentDto result = sut.selectNullableByUuid(session, "KLMN");
assertThat(result).isNotNull();
assertThat(result.uuid()).isEqualTo("KLMN");
assertThat(result.moduleUuid()).isEqualTo("EFGH");
public void get_by_uuid_on_technical_project_copy() {
loadBasicDataInDatabase();
- ComponentDto result = sut.getNullableByUuid(session, "STUV");
+ ComponentDto result = sut.selectNullableByUuid(session, "STUV");
assertThat(result).isNotNull();
assertThat(result.uuid()).isEqualTo("STUV");
assertThat(result.moduleUuid()).isEqualTo("OPQR");
public void get_by_uuid_on_disabled_component() {
loadBasicDataInDatabase();
- ComponentDto result = sut.getNullableByUuid(session, "DCBA");
+ ComponentDto result = sut.selectNullableByUuid(session, "DCBA");
assertThat(result).isNotNull();
assertThat(result.isEnabled()).isFalse();
}
loadBasicDataInDatabase();
- sut.getByUuid(session, "unknown");
+ sut.selectByUuid(session, "unknown");
}
@Test
loadBasicDataInDatabase();
- sut.getByUuid(session, "unknown");
+ sut.selectByUuid(session, "unknown");
}
@Test
public void get_by_ids() {
loadBasicDataInDatabase();
- List<ComponentDto> results = sut.getByIds(session, newArrayList(4L));
+ List<ComponentDto> results = sut.selectByIds(session, newArrayList(4L));
assertThat(results).hasSize(1);
ComponentDto result = results.get(0);
assertThat(result.language()).isEqualTo("java");
assertThat(result.parentProjectId()).isEqualTo(2);
- assertThat(sut.getByIds(session, newArrayList(555L))).isEmpty();
+ assertThat(sut.selectByIds(session, newArrayList(555L))).isEmpty();
}
@Test
public void get_by_uuids() {
loadBasicDataInDatabase();
- List<ComponentDto> results = sut.getByUuids(session, newArrayList("KLMN"));
+ List<ComponentDto> results = sut.selectByUuids(session, newArrayList("KLMN"));
assertThat(results).hasSize(1);
ComponentDto result = results.get(0);
assertThat(result.scope()).isEqualTo("FIL");
assertThat(result.language()).isEqualTo("java");
- assertThat(sut.getByUuids(session, newArrayList("unknown"))).isEmpty();
+ assertThat(sut.selectByUuids(session, newArrayList("unknown"))).isEmpty();
}
@Test
public void get_by_uuids_on_removed_components() {
loadBasicDataInDatabase();
- List<ComponentDto> results = sut.getByUuids(session, newArrayList("DCBA"));
+ List<ComponentDto> results = sut.selectByUuids(session, newArrayList("DCBA"));
assertThat(results).hasSize(1);
ComponentDto result = results.get(0);
public void get_by_id() {
loadBasicDataInDatabase();
- assertThat(sut.getById(4L, session)).isNotNull();
+ assertThat(sut.selectById(4L, session)).isNotNull();
}
@Test
public void get_by_id_on_disabled_component() {
loadBasicDataInDatabase();
- ComponentDto result = sut.getNullableById(10L, session);
+ ComponentDto result = sut.selectNullableById(10L, session);
assertThat(result).isNotNull();
assertThat(result.isEnabled()).isFalse();
}
public void fail_to_get_by_id_when_project_not_found() {
loadBasicDataInDatabase();
- sut.getById(111L, session);
+ sut.selectById(111L, session);
}
@Test
public void get_nullable_by_id() {
loadBasicDataInDatabase();
- assertThat(sut.getNullableById(4L, session)).isNotNull();
- assertThat(sut.getNullableById(111L, session)).isNull();
+ assertThat(sut.selectNullableById(4L, session)).isNotNull();
+ assertThat(sut.selectNullableById(111L, session)).isNull();
}
@Test
public void find_modules_by_project() {
db.prepareDbUnit(getClass(), "multi-modules.xml");
- List<ComponentDto> results = sut.findModulesByProject("org.struts:struts", session);
+ List<ComponentDto> results = sut.selectModulesByProject("org.struts:struts", session);
assertThat(results).hasSize(1);
assertThat(results.get(0).getKey()).isEqualTo("org.struts:struts-core");
- results = sut.findModulesByProject("org.struts:struts-core", session);
+ results = sut.selectModulesByProject("org.struts:struts-core", session);
assertThat(results).hasSize(1);
assertThat(results.get(0).getKey()).isEqualTo("org.struts:struts-data");
- assertThat(sut.findModulesByProject("org.struts:struts-data", session)).isEmpty();
+ assertThat(sut.selectModulesByProject("org.struts:struts-data", session)).isEmpty();
- assertThat(sut.findModulesByProject("unknown", session)).isEmpty();
+ assertThat(sut.selectModulesByProject("unknown", session)).isEmpty();
}
@Test
db.prepareDbUnit(getClass(), "multi-modules.xml");
// Sub project of a file
- List<ComponentDto> results = sut.findSubProjectsByComponentUuids(session, newArrayList("HIJK"));
+ List<ComponentDto> results = sut.selectSubProjectsByComponentUuids(session, newArrayList("HIJK"));
assertThat(results).hasSize(1);
assertThat(results.get(0).getKey()).isEqualTo("org.struts:struts-data");
// Sub project of a directory
- results = sut.findSubProjectsByComponentUuids(session, newArrayList("GHIJ"));
+ results = sut.selectSubProjectsByComponentUuids(session, newArrayList("GHIJ"));
assertThat(results).hasSize(1);
assertThat(results.get(0).getKey()).isEqualTo("org.struts:struts-data");
// Sub project of a sub module
- results = sut.findSubProjectsByComponentUuids(session, newArrayList("FGHI"));
+ results = sut.selectSubProjectsByComponentUuids(session, newArrayList("FGHI"));
assertThat(results).hasSize(1);
assertThat(results.get(0).getKey()).isEqualTo("org.struts:struts");
// Sub project of a module
- results = sut.findSubProjectsByComponentUuids(session, newArrayList("EFGH"));
+ results = sut.selectSubProjectsByComponentUuids(session, newArrayList("EFGH"));
assertThat(results).hasSize(1);
assertThat(results.get(0).getKey()).isEqualTo("org.struts:struts");
// Sub project of a project
- assertThat(sut.findSubProjectsByComponentUuids(session, newArrayList("ABCD"))).isEmpty();
+ assertThat(sut.selectSubProjectsByComponentUuids(session, newArrayList("ABCD"))).isEmpty();
// SUb projects of a component and a sub module
- assertThat(sut.findSubProjectsByComponentUuids(session, newArrayList("HIJK", "FGHI"))).hasSize(2);
+ assertThat(sut.selectSubProjectsByComponentUuids(session, newArrayList("HIJK", "FGHI"))).hasSize(2);
- assertThat(sut.findSubProjectsByComponentUuids(session, newArrayList("unknown"))).isEmpty();
+ assertThat(sut.selectSubProjectsByComponentUuids(session, newArrayList("unknown"))).isEmpty();
- assertThat(sut.findSubProjectsByComponentUuids(session, Collections.<String>emptyList())).isEmpty();
+ assertThat(sut.selectSubProjectsByComponentUuids(session, Collections.<String>emptyList())).isEmpty();
}
@Test
public void find_project_uuids() {
db.prepareDbUnit(getClass(), "find_project_uuids.xml");
- assertThat(sut.findProjectUuids(session)).containsExactly("ABCD");
+ assertThat(sut.selectProjectUuids(session)).containsExactly("ABCD");
}
@Test
.setLongName("src/main/java/org/sonar/api/Plugin.java")
.setPath("src/main/java/org/sonar/api/Plugin.java")
.setParentProjectId(5L);
- when(componentDao.getNullableByUuid(session, COMPONENT_UUID)).thenReturn(file);
- when(componentDao.getById(5L, session)).thenReturn(new ComponentDto().setId(5L).setLongName("SonarQube :: Plugin API").setKey(SUB_PROJECT_KEY));
- when(componentDao.getByUuid(session, project.uuid())).thenReturn(project);
+ when(componentDao.selectNullableByUuid(session, COMPONENT_UUID)).thenReturn(file);
+ when(componentDao.selectById(5L, session)).thenReturn(new ComponentDto().setId(5L).setLongName("SonarQube :: Plugin API").setKey(SUB_PROJECT_KEY));
+ when(componentDao.selectByUuid(session, project.uuid())).thenReturn(project);
when(propertiesDao.selectByQuery(any(PropertyQuery.class), eq(session))).thenReturn(newArrayList(new PropertyDto()));
WsTester.TestRequest request = tester.newGetRequest("api/components", "app").setParam("uuid", COMPONENT_UUID);
@Test
public void fail_on_unknown_component() {
userSessionRule.login("john").addComponentPermission(UserRole.USER, SUB_PROJECT_KEY, COMPONENT_KEY);
- when(componentDao.getNullableByUuid(session, COMPONENT_UUID)).thenReturn(null);
+ when(componentDao.selectNullableByUuid(session, COMPONENT_UUID)).thenReturn(null);
try {
tester.newGetRequest("api/components", "app").setParam("uuid", COMPONENT_UUID).execute();
.setLongName("src/main/java/org/sonar/api/Plugin.java")
.setPath("src/main/java/org/sonar/api/Plugin.java")
.setParentProjectId(5L);
- when(componentDao.getNullableByUuid(session, COMPONENT_UUID)).thenReturn(file);
- when(componentDao.getById(5L, session)).thenReturn(new ComponentDto().setId(5L).setLongName("SonarQube :: Plugin API").setKey(SUB_PROJECT_KEY));
- when(componentDao.getByUuid(session, project.uuid())).thenReturn(project);
+ when(componentDao.selectNullableByUuid(session, COMPONENT_UUID)).thenReturn(file);
+ when(componentDao.selectById(5L, session)).thenReturn(new ComponentDto().setId(5L).setLongName("SonarQube :: Plugin API").setKey(SUB_PROJECT_KEY));
+ when(componentDao.selectByUuid(session, project.uuid())).thenReturn(project);
return file;
}
when(componentDao.selectNullableByKey(session, key1)).thenReturn(file1);
when(componentDao.selectNullableByKey(session, key2)).thenReturn(file2);
- when(componentDao.getNullableById(5L, session)).thenReturn(
+ when(componentDao.selectNullableById(5L, session)).thenReturn(
new ComponentDto().setId(5L).setKey("org.codehaus.sonar:sonar-ws-client").setLongName("SonarQube :: Web Service Client"));
- when(componentDao.getNullableByUuid(session, project.uuid())).thenReturn(project);
+ when(componentDao.selectNullableByUuid(session, project.uuid())).thenReturn(project);
List<DuplicationsParser.Block> blocks = newArrayList();
blocks.add(new DuplicationsParser.Block(newArrayList(
verify(componentDao, times(2)).selectNullableByKey(eq(session), anyString());
// Verify call to dao is cached when searching for project / sub project
- verify(componentDao, times(1)).getNullableByUuid(eq(session), eq(project.uuid()));
- verify(componentDao, times(1)).getNullableById(eq(5L), eq(session));
+ verify(componentDao, times(1)).selectNullableByUuid(eq(session), eq(project.uuid()));
+ verify(componentDao, times(1)).selectNullableById(eq(5L), eq(session));
}
@Test
when(componentDao.selectNullableByKey(session, key1)).thenReturn(file1);
when(componentDao.selectNullableByKey(session, key2)).thenReturn(file2);
- when(componentDao.getNullableByUuid(session, project.uuid())).thenReturn(project);
+ when(componentDao.selectNullableByUuid(session, project.uuid())).thenReturn(project);
List<DuplicationsParser.Block> blocks = newArrayList();
blocks.add(new DuplicationsParser.Block(newArrayList(
ComponentDto file1 = ComponentTesting.newFileDto(project).setId(10L).setKey(key1).setLongName("PropertyDeleteQuery");
when(componentDao.selectNullableByKey(session, key1)).thenReturn(file1);
- when(componentDao.getNullableByUuid(session, project.uuid())).thenReturn(project);
+ when(componentDao.selectNullableByUuid(session, project.uuid())).thenReturn(project);
List<DuplicationsParser.Block> blocks = newArrayList();
String componentKey = "src/Foo.java";
userSessionRule.addComponentPermission(UserRole.CODEVIEWER, "org.codehaus.sonar:sonar", componentKey);
- when(componentDao.getByUuid(session, uuid)).thenReturn(new ComponentDto().setKey(componentKey));
+ when(componentDao.selectByUuid(session, uuid)).thenReturn(new ComponentDto().setKey(componentKey));
ComponentDto componentDto = new ComponentDto().setId(10L);
when(componentDao.selectNullableByKey(session, componentKey)).thenReturn(componentDto);
long copyResourceId = 42L;
ComponentDto technicalProject = new ComponentDto().setProjectUuid(devUuid).setCopyResourceId(copyResourceId);
- when(componentDao.getByUuids(isA(DbSession.class), anyCollection())).thenReturn(Arrays.asList(technicalProject));
+ when(componentDao.selectByUuids(isA(DbSession.class), anyCollection())).thenReturn(Arrays.asList(technicalProject));
when(componentService.getDistinctQualifiers(isA(DbSession.class), anyCollection())).thenReturn(Sets.newHashSet("DEV_PRJ"));
when(authorDao.selectScmAccountsByDeveloperUuids(isA(DbSession.class), anyCollection())).thenReturn(Lists.newArrayList(login1, login2));
ComponentDto actualProject = new ComponentDto().setUuid(projectUuid);
- when(componentDao.getByIds(isA(DbSession.class), anyCollection())).thenReturn(Arrays.asList(actualProject));
+ when(componentDao.selectByIds(isA(DbSession.class), anyCollection())).thenReturn(Arrays.asList(actualProject));
Map<String, Object> map = newHashMap();
map.put("componentUuids", newArrayList(copyProjectUuid));
.setLongName("project-long-name");
addIssueNTimes(newIssue1(), 5);
addIssueNTimes(newIssue2(), 3);
- when(dbClient.componentDao().getByUuid(any(DbSession.class), eq("file-uuid")).name()).thenReturn("file-name");
- when(dbClient.componentDao().getByUuid(any(DbSession.class), eq("directory-uuid")).name()).thenReturn("directory-name");
+ when(dbClient.componentDao().selectByUuid(any(DbSession.class), eq("file-uuid")).name()).thenReturn("file-name");
+ when(dbClient.componentDao().selectByUuid(any(DbSession.class), eq("directory-uuid")).name()).thenReturn("directory-name");
when(ruleIndex.getByKey(RuleKey.of("SonarQube", "rule-the-world"))).thenReturn(newRule("Rule the World", "Java"));
when(ruleIndex.getByKey(RuleKey.of("SonarQube", "rule-the-universe"))).thenReturn(newRule("Rule the Universe", "Clojure"));
.setKey("org.sonar.Sonar")
.setLongName("SonarQube")
.setName("SonarQube");
- when(componentDao.getByUuid(session, project.uuid())).thenReturn(project);
+ when(componentDao.selectByUuid(session, project.uuid())).thenReturn(project);
ComponentDto file = ComponentTesting.newFileDto(project)
.setId(10L)
.setName("SonarQube :: Issue Client")
.setQualifier("FIL")
.setParentProjectId(1L);
- when(componentDao.getByUuid(session, file.uuid())).thenReturn(file);
+ when(componentDao.selectByUuid(session, file.uuid())).thenReturn(file);
DefaultIssue issue = new DefaultIssue()
.setKey(issueKey)
.setId(1L)
.setKey("org.sonar.Sonar")
.setLongName("SonarQube");
- when(componentDao.getByUuid(session, project.uuid())).thenReturn(project);
+ when(componentDao.selectByUuid(session, project.uuid())).thenReturn(project);
// Module
ComponentDto module = ComponentTesting.newModuleDto(project)
.setLongName("SonarQube :: Server")
.setQualifier("BRC")
.setParentProjectId(1L);
- when(componentDao.getNullableById(module.getId(), session)).thenReturn(module);
+ when(componentDao.selectNullableById(module.getId(), session)).thenReturn(module);
// File
ComponentDto file = ComponentTesting.newFileDto(module)
.setLongName("SonarQube :: Issue Client")
.setQualifier("FIL")
.setParentProjectId(2L);
- when(componentDao.getByUuid(session, file.uuid())).thenReturn(file);
+ when(componentDao.selectByUuid(session, file.uuid())).thenReturn(file);
DefaultIssue issue = new DefaultIssue()
.setKey(issueKey)
.setKey("org.sonar.Sonar")
.setName("SonarQube")
.setLongName(null);
- when(componentDao.getByUuid(session, project.uuid())).thenReturn(project);
+ when(componentDao.selectByUuid(session, project.uuid())).thenReturn(project);
// Module
ComponentDto module = ComponentTesting.newModuleDto(project)
.setLongName(null)
.setQualifier("BRC")
.setParentProjectId(1L);
- when(componentDao.getNullableById(module.getId(), session)).thenReturn(module);
+ when(componentDao.selectNullableById(module.getId(), session)).thenReturn(module);
// File
ComponentDto file = ComponentTesting.newFileDto(module)
.setLongName("SonarQube :: Issue Client")
.setQualifier("FIL")
.setParentProjectId(2L);
- when(componentDao.getByUuid(session, file.uuid())).thenReturn(file);
+ when(componentDao.selectByUuid(session, file.uuid())).thenReturn(file);
DefaultIssue issue = new DefaultIssue()
.setKey(issueKey)
.setKey("org.sonar.Sonar")
.setLongName("SonarQube")
.setName("SonarQube");
- when(componentDao.getByUuid(session, project.uuid())).thenReturn(project);
+ when(componentDao.selectByUuid(session, project.uuid())).thenReturn(project);
ComponentDto file = ComponentTesting.newFileDto(project)
.setId(10L)
.setName("SonarQube :: Issue Client")
.setQualifier("FIL")
.setParentProjectId(1L);
- when(componentDao.getByUuid(session, file.uuid())).thenReturn(file);
+ when(componentDao.selectByUuid(session, file.uuid())).thenReturn(file);
DefaultIssue issue = createIssue()
.setComponentUuid(file.uuid())
.setKey("org.sonar.Sonar")
.setLongName("SonarQube")
.setName("SonarQube");
- when(componentDao.getByUuid(session, project.uuid())).thenReturn(project);
+ when(componentDao.selectByUuid(session, project.uuid())).thenReturn(project);
ComponentDto file = ComponentTesting.newFileDto(project)
.setId(10L)
.setName("SonarQube :: Issue Client")
.setQualifier("FIL")
.setParentProjectId(1L);
- when(componentDao.getByUuid(session, file.uuid())).thenReturn(file);
+ when(componentDao.selectByUuid(session, file.uuid())).thenReturn(file);
return createIssue()
.setComponentUuid(file.uuid())
@Before
public void initialize() {
- when(componentDao.getById(anyLong(), eq(session))).thenReturn(new ComponentDto().setId(1L).setKey(PROJECT_KEY));
+ when(componentDao.selectById(anyLong(), eq(session))).thenReturn(new ComponentDto().setId(1L).setKey(PROJECT_KEY));
when(myBatis.openSession(false)).thenReturn(session);
qGates = new QualityGates(dao, conditionDao, metricFinder, propertiesDao, componentDao, myBatis, userSessionRule);
new CoveredFileDoc().setFileUuid("bar-uuid").setCoveredLines(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)),
new CoveredFileDoc().setFileUuid("file-uuid").setCoveredLines(Arrays.asList(1, 2, 3))
));
- when(dbClient.componentDao().getByUuids(any(DbSession.class), anyList())).thenReturn(
+ when(dbClient.componentDao().selectByUuids(any(DbSession.class), anyList())).thenReturn(
Arrays.asList(
newFileDto(newProjectDto(), "bar-uuid").setKey("org.foo.Bar.java").setLongName("src/main/java/org/foo/Bar.java"),
newFileDto(newProjectDto(), "file-uuid").setKey("org.foo.File.java").setLongName("src/main/java/org/foo/File.java")));
enableSnapshot(1002);
try (SqlSession session = getMyBatis().openSession(false)) {
// FIXME selectByKey returns duplicates for libraries because of the join on snapshots table
- ComponentDto newLib = session.getMapper(ComponentMapper.class).findByKeys(Arrays.asList("junit:junit")).get(0);
+ ComponentDto newLib = session.getMapper(ComponentMapper.class).selectByKeys(Arrays.asList("junit:junit")).get(0);
assertThat(newLib.uuid()).isNotNull();
assertThat(newLib.projectUuid()).isEqualTo(newLib.uuid());
assertThat(newLib.moduleUuid()).isNull();
/**
* Return direct modules from a project/module
*/
- List<ComponentDto> findModulesByProject(@Param("projectKey") String projectKey);
+ List<ComponentDto> selectModulesByProject(@Param("projectKey") String projectKey);
/**
* Return sub project of component keys
*/
- List<ComponentDto> findSubProjectsByComponentUuids(@Param("uuids") Collection<String> uuids);
+ List<ComponentDto> selectSubProjectsByComponentUuids(@Param("uuids") Collection<String> uuids);
- List<ComponentDto> findByKeys(@Param("keys") Collection<String> keys);
+ List<ComponentDto> selectByKeys(@Param("keys") Collection<String> keys);
- List<ComponentDto> findByIds(@Param("ids") Collection<Long> ids);
+ List<ComponentDto> selectByIds(@Param("ids") Collection<Long> ids);
- List<ComponentDto> findByUuids(@Param("uuids") Collection<String> uuids);
+ List<ComponentDto> selectByUuids(@Param("uuids") Collection<String> uuids);
List<String> selectExistingUuids(@Param("uuids") Collection<String> uuids);
/**
* Return all project (PRJ/TRK) uuids
*/
- List<String> findProjectUuids();
+ List<String> selectProjectUuids();
/**
* Return all descendant modules (including itself) from a given component uuid and scope
</where>
</select>
- <select id="findModulesByProject" parameterType="String" resultType="Component">
+ <select id="selectModulesByProject" parameterType="String" resultType="Component">
SELECT <include refid="componentColumns"/>
FROM projects p
INNER JOIN snapshots s ON s.project_id=p.id AND s.islast=${_true}
</where>
</select>
- <select id="findByKeys" parameterType="String" resultType="Component">
+ <select id="selectByKeys" parameterType="String" resultType="Component">
select <include refid="componentColumns"/>
from projects p
<where>
</where>
</select>
- <select id="findByIds" parameterType="long" resultType="Component">
+ <select id="selectByIds" parameterType="long" resultType="Component">
select
<include refid="componentColumns"/>
from projects p
</where>
</select>
- <select id="findByUuids" parameterType="String" resultType="Component">
+ <select id="selectByUuids" parameterType="String" resultType="Component">
select <include refid="componentColumns"/>
from projects p
<where>
</where>
</select>
- <select id="findSubProjectsByComponentUuids" parameterType="String" resultType="Component">
+ <select id="selectSubProjectsByComponentUuids" parameterType="String" resultType="Component">
SELECT <include refid="componentColumns"/>
FROM projects p
INNER JOIN projects child ON child.root_id=p.id AND child.enabled=${_true}
<include refid="modulesTreeQuery"/>
</select>
- <select id="findProjectUuids" resultType="String">
+ <select id="selectProjectUuids" resultType="String">
SELECT p.uuid
FROM projects p
<where>