use of org.sonar.db.metric.MetricDto in project sonarqube by SonarSource.
the class CreateAction method newMetricTemplate.
private static MetricDto newMetricTemplate(Request request) {
String key = checkMetricKeyFormat(request.mandatoryParam(PARAM_KEY));
String name = request.mandatoryParam(PARAM_NAME);
String type = Metric.ValueType.valueOf(request.mandatoryParam(PARAM_TYPE)).name();
String domain = request.param(PARAM_DOMAIN);
String description = request.param(PARAM_DESCRIPTION);
MetricDto metricTemplate = new MetricDto().setKey(key).setShortName(name).setValueType(type);
if (domain != null) {
metricTemplate.setDomain(domain);
}
if (description != null) {
metricTemplate.setDescription(description);
}
return metricTemplate;
}
use of org.sonar.db.metric.MetricDto in project sonarqube by SonarSource.
the class MetricJsonWriter method write.
public static void write(JsonWriter json, List<MetricDto> metrics, Set<String> fieldsToReturn) {
json.name("metrics");
json.beginArray();
for (MetricDto metric : metrics) {
write(json, metric, fieldsToReturn);
}
json.endArray();
}
use of org.sonar.db.metric.MetricDto in project sonarqube by SonarSource.
the class UpdateAction method checkNoOtherMetricWithTargetKey.
private void checkNoOtherMetricWithTargetKey(DbSession dbSession, MetricDto metricInDb, MetricDto template) {
String targetKey = template.getKey();
MetricDto metricWithTargetKey = dbClient.metricDao().selectByKey(dbSession, targetKey);
checkRequest(!isMetricFoundInDb(metricWithTargetKey) || metricInDb.getId().equals(metricWithTargetKey.getId()), "The key '%s' is already used by an existing metric.", targetKey);
}
use of org.sonar.db.metric.MetricDto in project sonarqube by SonarSource.
the class UpdateAction method newMetricTemplate.
private static MetricDto newMetricTemplate(Request request) {
int id = request.mandatoryParamAsInt(PARAM_ID);
String key = request.param(PARAM_KEY);
if (key != null) {
MetricKeyValidator.checkMetricKeyFormat(key);
}
String type = request.param(PARAM_TYPE);
String name = request.param(PARAM_NAME);
String domain = request.param(PARAM_DOMAIN);
String description = request.param(PARAM_DESCRIPTION);
MetricDto metricTemplate = new MetricDto().setId(id);
if (key != null) {
metricTemplate.setKey(key);
}
if (type != null) {
metricTemplate.setValueType(type);
}
if (name != null) {
metricTemplate.setShortName(name);
}
if (domain != null) {
metricTemplate.setDomain(domain);
}
if (description != null) {
metricTemplate.setDescription(description);
}
return metricTemplate;
}
use of org.sonar.db.metric.MetricDto in project sonarqube by SonarSource.
the class SearchMyProjectsDataLoader method load.
SearchMyProjectsData load(DbSession dbSession, SearchMyProjectsRequest request) {
SearchMyProjectsData.Builder data = builder();
ProjectsResult searchResult = searchProjects(dbSession, request);
List<ComponentDto> projects = searchResult.projects;
List<String> projectUuids = Lists.transform(projects, ComponentDto::projectUuid);
List<ComponentLinkDto> projectLinks = dbClient.componentLinkDao().selectByComponentUuids(dbSession, projectUuids);
List<SnapshotDto> snapshots = dbClient.snapshotDao().selectLastAnalysesByRootComponentUuids(dbSession, projectUuids);
MetricDto gateStatusMetric = dbClient.metricDao().selectOrFailByKey(dbSession, CoreMetrics.ALERT_STATUS_KEY);
MeasureQuery measureQuery = MeasureQuery.builder().setProjectUuids(projectUuids).setMetricId(gateStatusMetric.getId()).build();
List<MeasureDto> qualityGates = dbClient.measureDao().selectByQuery(dbSession, measureQuery);
data.setProjects(projects).setProjectLinks(projectLinks).setSnapshots(snapshots).setQualityGates(qualityGates).setTotalNbOfProjects(searchResult.total);
return data.build();
}
Aggregations