use of org.sonar.db.property.PropertyDto in project sonarqube by SonarSource.
the class ComponentActionTest method return_component_info_with_favourite.
@Test
public void return_component_info_with_favourite() throws Exception {
init();
UserDto user = dbTester.users().insertUser("obiwan");
componentDbTester.insertComponent(project);
propertyDbTester.insertProperty(new PropertyDto().setKey("favourite").setResourceId(project.getId()).setUserId(user.getId()));
userSession.logIn(user).addProjectUuidPermissions(UserRole.USER, project.uuid());
executeAndVerify(project.key(), "return_component_info_with_favourite.json");
}
use of org.sonar.db.property.PropertyDto in project sonarqube by SonarSource.
the class QualityGateDbTester method setDefaultQualityGate.
public void setDefaultQualityGate(QualityGateDto qualityGate) {
dbClient.propertiesDao().saveProperty(dbSession, new PropertyDto().setKey("sonar.qualitygate").setValue(String.valueOf(qualityGate.getId())));
db.commit();
}
use of org.sonar.db.property.PropertyDto in project sonarqube by SonarSource.
the class UserDaoTest method insertProperty.
private PropertyDto insertProperty(UserDto user) {
PropertyDto dto = new PropertyDto().setKey(randomAlphanumeric(100)).setUserId(user.getId());
dbClient.propertiesDao().saveProperty(session, dto);
return dto;
}
use of org.sonar.db.property.PropertyDto in project sonarqube by SonarSource.
the class AppAction method appendComponent.
private void appendComponent(JsonWriter json, ComponentDto component, UserSession userSession, DbSession session) {
List<PropertyDto> propertyDtos = dbClient.propertiesDao().selectByQuery(PropertyQuery.builder().setKey("favourite").setComponentId(component.getId()).setUserId(userSession.getUserId()).build(), session);
boolean isFavourite = propertyDtos.size() == 1;
json.prop("key", component.key());
json.prop("uuid", component.uuid());
json.prop("path", component.path());
json.prop("name", component.name());
json.prop("longName", component.longName());
json.prop("q", component.qualifier());
ComponentDto parentProject = retrieveRootIfNotCurrentComponent(component, session);
ComponentDto project = dbClient.componentDao().selectOrFailByUuid(session, component.projectUuid());
// Do not display parent project if parent project and project are the same
boolean displayParentProject = parentProject != null && !parentProject.uuid().equals(project.uuid());
json.prop("subProject", displayParentProject ? parentProject.key() : null);
json.prop("subProjectName", displayParentProject ? parentProject.longName() : null);
json.prop("project", project.key());
json.prop("projectName", project.longName());
json.prop("fav", isFavourite);
}
use of org.sonar.db.property.PropertyDto in project sonarqube by SonarSource.
the class ProjectDataLoader method getPropertiesMap.
private static Map<String, String> getPropertiesMap(List<PropertyDto> propertyDtos, boolean hasScanPerm) {
Map<String, String> properties = newHashMap();
for (PropertyDto propertyDto : propertyDtos) {
String key = propertyDto.getKey();
String value = propertyDto.getValue();
if (isPropertyAllowed(key, hasScanPerm)) {
properties.put(key, value);
}
}
return properties;
}
Aggregations