Search in sources :

Example 26 with PropertyDto

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");
}
Also used : UserDto(org.sonar.db.user.UserDto) PropertyDto(org.sonar.db.property.PropertyDto) Test(org.junit.Test)

Example 27 with PropertyDto

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();
}
Also used : PropertyDto(org.sonar.db.property.PropertyDto)

Example 28 with PropertyDto

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;
}
Also used : PropertyDto(org.sonar.db.property.PropertyDto)

Example 29 with PropertyDto

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);
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) PropertyDto(org.sonar.db.property.PropertyDto)

Example 30 with PropertyDto

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;
}
Also used : PropertyDto(org.sonar.db.property.PropertyDto)

Aggregations

PropertyDto (org.sonar.db.property.PropertyDto)57 Test (org.junit.Test)25 ComponentDto (org.sonar.db.component.ComponentDto)23 OrganizationDto (org.sonar.db.organization.OrganizationDto)13 ProjectRepositories (org.sonar.scanner.protocol.input.ProjectRepositories)13 DbSession (org.sonar.db.DbSession)8 QualityGateDto (org.sonar.db.qualitygate.QualityGateDto)6 MapSettings (org.sonar.api.config.MapSettings)3 Settings (org.sonar.api.config.Settings)3 PropertyTesting.newComponentPropertyDto (org.sonar.db.property.PropertyTesting.newComponentPropertyDto)2 PropertyTesting.newGlobalPropertyDto (org.sonar.db.property.PropertyTesting.newGlobalPropertyDto)2 UserDto (org.sonar.db.user.UserDto)2 Date (java.util.Date)1 Matchers.anyString (org.mockito.Matchers.anyString)1 PropertyDefinition (org.sonar.api.config.PropertyDefinition)1 FilePathWithHashDto (org.sonar.db.component.FilePathWithHashDto)1 SnapshotDto (org.sonar.db.component.SnapshotDto)1 PropertyQuery (org.sonar.db.property.PropertyQuery)1 UserTesting.newUserDto (org.sonar.db.user.UserTesting.newUserDto)1 TestResponse (org.sonar.server.ws.TestResponse)1