Search in sources :

Example 1 with ComponentNewValue

use of org.sonar.db.audit.model.ComponentNewValue in project sonarqube by SonarSource.

the class ComponentDao method setPrivateForRootComponentUuid.

public void setPrivateForRootComponentUuid(DbSession session, String projectUuid, boolean isPrivate, @Nullable String qualifier, String componentKey, String componentName) {
    ComponentNewValue componentNewValue = new ComponentNewValue(projectUuid, componentName, componentKey, isPrivate, qualifier);
    auditPersister.updateComponentVisibility(session, componentNewValue);
    mapper(session).setPrivateForRootComponentUuid(projectUuid, isPrivate);
}
Also used : ComponentNewValue(org.sonar.db.audit.model.ComponentNewValue)

Example 2 with ComponentNewValue

use of org.sonar.db.audit.model.ComponentNewValue in project sonarqube by SonarSource.

the class ComponentDao method update.

public void update(DbSession session, ComponentUpdateDto component, String qualifier) {
    auditPersister.updateComponent(session, new ComponentNewValue(component.getUuid(), component.getBName(), component.getBKey(), component.isBEnabled(), component.getBPath(), qualifier));
    mapper(session).update(component);
}
Also used : ComponentNewValue(org.sonar.db.audit.model.ComponentNewValue)

Example 3 with ComponentNewValue

use of org.sonar.db.audit.model.ComponentNewValue in project sonarqube by SonarSource.

the class ProjectDao method update.

public void update(DbSession session, ProjectDto project) {
    auditPersister.updateComponent(session, new ComponentNewValue(project));
    mapper(session).update(project);
}
Also used : ComponentNewValue(org.sonar.db.audit.model.ComponentNewValue)

Example 4 with ComponentNewValue

use of org.sonar.db.audit.model.ComponentNewValue in project sonarqube by SonarSource.

the class PurgeDao method deleteProject.

public void deleteProject(DbSession session, String uuid, String qualifier, String name, String key) {
    PurgeProfiler profiler = new PurgeProfiler();
    PurgeMapper purgeMapper = mapper(session);
    PurgeCommands purgeCommands = new PurgeCommands(session, profiler, system2);
    long start = System2.INSTANCE.now();
    List<String> branchUuids = session.getMapper(BranchMapper.class).selectByProjectUuid(uuid).stream().map(BranchDto::getUuid).filter(branchUuid -> !uuid.equals(branchUuid)).collect(Collectors.toList());
    branchUuids.forEach(id -> deleteRootComponent(id, purgeMapper, purgeCommands));
    deleteRootComponent(uuid, purgeMapper, purgeCommands);
    auditPersister.deleteComponent(session, new ComponentNewValue(uuid, name, key, qualifier));
    logProfiling(profiler, start);
}
Also used : BranchDto(org.sonar.db.component.BranchDto) Date(java.util.Date) DbSession(org.sonar.db.DbSession) TimeUtils(org.sonar.api.utils.TimeUtils) Loggers(org.sonar.api.utils.log.Loggers) DateUtils.dateToLong(org.sonar.api.utils.DateUtils.dateToLong) DateUtils(org.sonar.api.utils.DateUtils) MoreCollectors(org.sonar.core.util.stream.MoreCollectors) Nullable(javax.annotation.Nullable) Logger(org.sonar.api.utils.log.Logger) ImmutableSet(com.google.common.collect.ImmutableSet) Dao(org.sonar.db.Dao) System2(org.sonar.api.utils.System2) Predicate(java.util.function.Predicate) Collections.emptyList(java.util.Collections.emptyList) Optional.ofNullable(java.util.Optional.ofNullable) Collection(java.util.Collection) Set(java.util.Set) Collectors(java.util.stream.Collectors) ComponentNewValue(org.sonar.db.audit.model.ComponentNewValue) BranchMapper(org.sonar.db.component.BranchMapper) List(java.util.List) AuditPersister(org.sonar.db.audit.AuditPersister) ComponentDto(org.sonar.db.component.ComponentDto) DatabaseUtils.executeLargeInputs(org.sonar.db.DatabaseUtils.executeLargeInputs) Optional(java.util.Optional) BranchDto(org.sonar.db.component.BranchDto) ComponentNewValue(org.sonar.db.audit.model.ComponentNewValue) BranchMapper(org.sonar.db.component.BranchMapper)

Example 5 with ComponentNewValue

use of org.sonar.db.audit.model.ComponentNewValue in project sonarqube by SonarSource.

the class PurgeDaoWithAuditTest method delete_project_persist_audit_with_uuid_and_name.

@Test
public void delete_project_persist_audit_with_uuid_and_name() {
    ComponentDto project = db.components().insertPrivateProject();
    underTestWithPersister.deleteProject(dbSession, project.uuid(), project.qualifier(), project.name(), project.getKey());
    verify(auditPersister).deleteComponent(any(DbSession.class), newValueCaptor.capture());
    ComponentNewValue componentNewValue = newValueCaptor.getValue();
    assertThat(componentNewValue).extracting(ComponentNewValue::getComponentUuid, ComponentNewValue::getComponentName, ComponentNewValue::getComponentKey, ComponentNewValue::getQualifier).containsExactly(project.uuid(), project.name(), project.getKey(), "TRK");
}
Also used : DbSession(org.sonar.db.DbSession) ComponentDto(org.sonar.db.component.ComponentDto) ComponentNewValue(org.sonar.db.audit.model.ComponentNewValue) Test(org.junit.Test)

Aggregations

ComponentNewValue (org.sonar.db.audit.model.ComponentNewValue)5 DbSession (org.sonar.db.DbSession)2 ComponentDto (org.sonar.db.component.ComponentDto)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 Collection (java.util.Collection)1 Collections.emptyList (java.util.Collections.emptyList)1 Date (java.util.Date)1 List (java.util.List)1 Optional (java.util.Optional)1 Optional.ofNullable (java.util.Optional.ofNullable)1 Set (java.util.Set)1 Predicate (java.util.function.Predicate)1 Collectors (java.util.stream.Collectors)1 Nullable (javax.annotation.Nullable)1 Test (org.junit.Test)1 DateUtils (org.sonar.api.utils.DateUtils)1 DateUtils.dateToLong (org.sonar.api.utils.DateUtils.dateToLong)1 System2 (org.sonar.api.utils.System2)1 TimeUtils (org.sonar.api.utils.TimeUtils)1 Logger (org.sonar.api.utils.log.Logger)1