use of org.sonar.db.ce.CeTaskCharacteristicDto in project sonarqube by SonarSource.
the class CeQueueImpl method loadTasks.
private List<CeTask> loadTasks(DbSession dbSession, List<CeQueueDto> dtos) {
// load components, if defined
Set<String> componentUuids = dtos.stream().flatMap(dto -> Stream.of(dto.getComponentUuid(), dto.getMainComponentUuid())).filter(Objects::nonNull).collect(Collectors.toSet());
Map<String, ComponentDto> componentsByUuid = dbClient.componentDao().selectByUuids(dbSession, componentUuids).stream().collect(uniqueIndex(ComponentDto::uuid));
// load characteristics
// TODO could be avoided, characteristics are already present in submissions
Set<String> taskUuids = dtos.stream().map(CeQueueDto::getUuid).collect(MoreCollectors.toSet(dtos.size()));
Multimap<String, CeTaskCharacteristicDto> characteristicsByTaskUuid = dbClient.ceTaskCharacteristicsDao().selectByTaskUuids(dbSession, taskUuids).stream().collect(MoreCollectors.index(CeTaskCharacteristicDto::getTaskUuid));
List<CeTask> result = new ArrayList<>();
for (CeQueueDto dto : dtos) {
ComponentDto component = ofNullable(dto.getComponentUuid()).map(componentsByUuid::get).orElse(null);
ComponentDto mainComponent = ofNullable(dto.getMainComponentUuid()).map(componentsByUuid::get).orElse(null);
Map<String, String> characteristics = characteristicsByTaskUuid.get(dto.getUuid()).stream().collect(uniqueIndex(CeTaskCharacteristicDto::getKey, CeTaskCharacteristicDto::getValue));
result.add(convertToTask(dbSession, dto, characteristics, component, mainComponent));
}
return result;
}
use of org.sonar.db.ce.CeTaskCharacteristicDto in project sonarqube by SonarSource.
the class CeQueueImpl method addToQueueInDb.
private CeQueueDto addToQueueInDb(DbSession dbSession, CeTaskSubmit submission) {
for (Map.Entry<String, String> characteristic : submission.getCharacteristics().entrySet()) {
CeTaskCharacteristicDto characteristicDto = new CeTaskCharacteristicDto();
characteristicDto.setUuid(uuidFactory.create());
characteristicDto.setTaskUuid(submission.getUuid());
characteristicDto.setKey(characteristic.getKey());
characteristicDto.setValue(characteristic.getValue());
dbClient.ceTaskCharacteristicsDao().insert(dbSession, characteristicDto);
}
CeQueueDto dto = new CeQueueDto();
dto.setUuid(submission.getUuid());
dto.setTaskType(submission.getType());
submission.getComponent().ifPresent(component -> dto.setComponentUuid(component.getUuid()).setMainComponentUuid(component.getMainComponentUuid()));
dto.setStatus(PENDING);
dto.setSubmitterUuid(submission.getSubmitterUuid());
dbClient.ceQueueDao().insert(dbSession, dto);
return dto;
}
use of org.sonar.db.ce.CeTaskCharacteristicDto in project sonarqube by SonarSource.
the class ComponentActionTest method insertCharacteristic.
private CeTaskCharacteristicDto insertCharacteristic(String taskUuid, String key, String value) {
CeTaskCharacteristicDto dto = new CeTaskCharacteristicDto().setUuid(Uuids.createFast()).setTaskUuid(taskUuid).setKey(key).setValue(value);
db.getDbClient().ceTaskCharacteristicsDao().insert(db.getSession(), Collections.singletonList(dto));
db.commit();
return dto;
}
use of org.sonar.db.ce.CeTaskCharacteristicDto in project sonarqube by SonarSource.
the class TaskActionTest method insertCharacteristic.
private CeTaskCharacteristicDto insertCharacteristic(String taskUuid, String key, String value) {
CeTaskCharacteristicDto dto = new CeTaskCharacteristicDto().setUuid(Uuids.createFast()).setTaskUuid(taskUuid).setKey(key).setValue(value);
db.getDbClient().ceTaskCharacteristicsDao().insert(db.getSession(), Collections.singletonList(dto));
db.commit();
return dto;
}
use of org.sonar.db.ce.CeTaskCharacteristicDto in project sonarqube by SonarSource.
the class ActivityActionTest method insertCharacteristic.
private CeTaskCharacteristicDto insertCharacteristic(String taskUuid, String key, String value) {
CeTaskCharacteristicDto dto = new CeTaskCharacteristicDto().setUuid(Uuids.createFast()).setTaskUuid(taskUuid).setKey(key).setValue(value);
db.getDbClient().ceTaskCharacteristicsDao().insert(db.getSession(), singletonList(dto));
db.commit();
return dto;
}
Aggregations