}
});
}
+
+ public int countCustom(DbSession session) {
+ return mapper(session).countCustom();
+ }
}
+++ /dev/null
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-package org.sonar.server.metric.ws;
-
-import org.sonar.api.measures.Metric;
-import org.sonar.api.server.ws.Request;
-import org.sonar.api.server.ws.Response;
-import org.sonar.api.server.ws.WebService;
-import org.sonar.api.server.ws.WebService.Param;
-import org.sonar.api.utils.text.JsonWriter;
-import org.sonar.core.metric.db.MetricDto;
-import org.sonar.core.persistence.DbSession;
-import org.sonar.core.persistence.MyBatis;
-import org.sonar.server.db.DbClient;
-import org.sonar.server.es.SearchOptions;
-
-import javax.annotation.Nullable;
-
-import java.util.List;
-import java.util.Set;
-
-import static com.google.common.collect.Sets.newHashSet;
-
-public class ListAction implements MetricsWsAction {
-
- public static final String PARAM_IS_CUSTOM = "is_custom";
-
- public static final String FIELD_ID = "id";
- public static final String FIELD_KEY = "key";
- public static final String FIELD_NAME = "name";
- public static final String FIELD_DESCRIPTION = "description";
- public static final String FIELD_DOMAIN = "domain";
- public static final String FIELD_TYPE = "type";
- private static final Set<String> POSSIBLE_FIELDS = newHashSet(FIELD_ID, FIELD_KEY, FIELD_NAME, FIELD_DESCRIPTION, FIELD_DOMAIN, FIELD_TYPE);
-
- private final DbClient dbClient;
-
- public ListAction(DbClient dbClient) {
- this.dbClient = dbClient;
- }
-
- @Override
- public void define(WebService.NewController context) {
- WebService.NewAction action = context.createAction("list")
- .setSince("5.2")
- .setResponseExample(getClass().getResource("example-list.json"))
- .addPagingParams(100)
- .addFieldsParam(POSSIBLE_FIELDS)
- .setHandler(this);
-
- action.createParam(PARAM_IS_CUSTOM)
- .setExampleValue("true")
- .setDescription("Choose custom metrics following 3 cases:" +
- "<ul>" +
- "<li>true: only custom metrics are returned</li>" +
- "<li>false: only non custom metrics are returned</li>" +
- "<li>not specified: all metrics are returned</li>" +
- "</ul>");
- }
-
- @Override
- public void handle(Request request, Response response) throws Exception {
- SearchOptions searchOptions = new SearchOptions()
- .setPage(request.mandatoryParamAsInt(Param.PAGE),
- request.mandatoryParamAsInt(Param.PAGE_SIZE));
- Boolean isCustom = request.paramAsBoolean(PARAM_IS_CUSTOM);
- DbSession dbSession = dbClient.openSession(false);
- try {
- List<MetricDto> metrics = dbClient.metricDao().selectEnabled(dbSession, isCustom, searchOptions);
- JsonWriter json = response.newJsonWriter();
- json.beginObject();
- Set<String> desiredFields = desiredFields(request.paramAsStrings(Param.FIELDS));
- writeMetrics(json, metrics, desiredFields);
- json.endObject();
- json.close();
- } finally {
- MyBatis.closeQuietly(dbSession);
- }
- }
-
- private Set<String> desiredFields(@Nullable List<String> fields) {
- if (fields == null || fields.isEmpty()) {
- return POSSIBLE_FIELDS;
- }
-
- return newHashSet(fields);
- }
-
- private void writeMetrics(JsonWriter json, List<MetricDto> metrics, Set<String> desiredFields) {
- json.name("metrics");
- json.beginArray();
- for (MetricDto metric : metrics) {
- json.beginObject();
- json.prop(FIELD_ID, String.valueOf(metric.getId()));
- json.prop(FIELD_KEY, metric.getKey());
- writeIfDesired(json, FIELD_NAME, metric.getShortName(), desiredFields);
- writeIfDesired(json, FIELD_DESCRIPTION, metric.getDescription(), desiredFields);
- writeIfDesired(json, FIELD_DOMAIN, metric.getDomain(), desiredFields);
- writeIfDesired(json, FIELD_TYPE, Metric.ValueType.descriptionOf(metric.getValueType()), desiredFields);
- json.endObject();
- }
- json.endArray();
- }
-
- private void writeIfDesired(JsonWriter json, String field, String value, Set<String> desiredFields) {
- if (desiredFields.contains(field)) {
- json.prop(field, value);
- }
- }
-}
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.sonar.server.metric.ws;
+
+import java.util.List;
+import java.util.Set;
+import javax.annotation.Nullable;
+import org.sonar.api.measures.Metric;
+import org.sonar.api.server.ws.Request;
+import org.sonar.api.server.ws.Response;
+import org.sonar.api.server.ws.WebService;
+import org.sonar.api.server.ws.WebService.Param;
+import org.sonar.api.utils.text.JsonWriter;
+import org.sonar.core.metric.db.MetricDto;
+import org.sonar.core.persistence.DbSession;
+import org.sonar.core.persistence.MyBatis;
+import org.sonar.server.db.DbClient;
+import org.sonar.server.es.SearchOptions;
+
+import static com.google.common.collect.Sets.newHashSet;
+
+public class SearchAction implements MetricsWsAction {
+
+ private static final String ACTION = "search";
+
+ public static final String PARAM_IS_CUSTOM = "is_custom";
+
+ public static final String FIELD_ID = "id";
+ public static final String FIELD_KEY = "key";
+ public static final String FIELD_NAME = "name";
+ public static final String FIELD_DESCRIPTION = "description";
+ public static final String FIELD_DOMAIN = "domain";
+ public static final String FIELD_TYPE = "type";
+ private static final Set<String> OPTIONAL_FIELDS = newHashSet(FIELD_NAME, FIELD_DESCRIPTION, FIELD_DOMAIN, FIELD_TYPE);
+ private final Set<String> ALL_POSSIBLE_FIELDS;
+
+ private final DbClient dbClient;
+
+ public SearchAction(DbClient dbClient) {
+ this.dbClient = dbClient;
+ Set<String> possibleFields = newHashSet(FIELD_ID, FIELD_KEY);
+ possibleFields.addAll(OPTIONAL_FIELDS);
+ ALL_POSSIBLE_FIELDS = possibleFields;
+ }
+
+ @Override
+ public void define(WebService.NewController context) {
+ WebService.NewAction action = context.createAction(ACTION)
+ .setSince("5.2")
+ .setResponseExample(getClass().getResource("example-list.json"))
+ .addPagingParams(100)
+ .addFieldsParam(OPTIONAL_FIELDS)
+ .setHandler(this);
+
+ action.createParam(PARAM_IS_CUSTOM)
+ .setExampleValue("true")
+ .setDescription("Choose custom metrics following 3 cases:" +
+ "<ul>" +
+ "<li>true: only custom metrics are returned</li>" +
+ "<li>false: only non custom metrics are returned</li>" +
+ "<li>not specified: all metrics are returned</li>" +
+ "</ul>");
+ }
+
+ @Override
+ public void handle(Request request, Response response) throws Exception {
+ SearchOptions searchOptions = new SearchOptions()
+ .setPage(request.mandatoryParamAsInt(Param.PAGE),
+ request.mandatoryParamAsInt(Param.PAGE_SIZE));
+ Boolean isCustom = request.paramAsBoolean(PARAM_IS_CUSTOM);
+ DbSession dbSession = dbClient.openSession(false);
+ try {
+ List<MetricDto> metrics = dbClient.metricDao().selectEnabled(dbSession, isCustom, searchOptions);
+ int nbMetrics = dbClient.metricDao().countCustom(dbSession);
+ JsonWriter json = response.newJsonWriter();
+ json.beginObject();
+ Set<String> desiredFields = desiredFields(request.paramAsStrings(Param.FIELDS));
+ writeMetrics(json, metrics, desiredFields);
+ searchOptions.writeJson(json, nbMetrics);
+ json.endObject();
+ json.close();
+ } finally {
+ MyBatis.closeQuietly(dbSession);
+ }
+ }
+
+ private Set<String> desiredFields(@Nullable List<String> fields) {
+ if (fields == null || fields.isEmpty()) {
+ return ALL_POSSIBLE_FIELDS;
+ }
+
+ return newHashSet(fields);
+ }
+
+ private void writeMetrics(JsonWriter json, List<MetricDto> metrics, Set<String> desiredFields) {
+ json.name("metrics");
+ json.beginArray();
+ for (MetricDto metric : metrics) {
+ json.beginObject();
+ json.prop(FIELD_ID, String.valueOf(metric.getId()));
+ json.prop(FIELD_KEY, metric.getKey());
+ writeIfDesired(json, FIELD_NAME, metric.getShortName(), desiredFields);
+ writeIfDesired(json, FIELD_DESCRIPTION, metric.getDescription(), desiredFields);
+ writeIfDesired(json, FIELD_DOMAIN, metric.getDomain(), desiredFields);
+ writeIfDesired(json, FIELD_TYPE, Metric.ValueType.descriptionOf(metric.getValueType()), desiredFields);
+ json.endObject();
+ }
+ json.endArray();
+ }
+
+ private void writeIfDesired(JsonWriter json, String field, String value, Set<String> desiredFields) {
+ if (desiredFields.contains(field)) {
+ json.prop(field, value);
+ }
+ }
+}
import org.sonar.server.measure.ws.TimeMachineWs;
import org.sonar.server.metric.CoreCustomMetrics;
import org.sonar.server.metric.ws.MetricsWs;
+import org.sonar.server.metric.ws.SearchAction;
import org.sonar.server.notifications.NotificationCenter;
import org.sonar.server.notifications.NotificationService;
import org.sonar.server.permission.InternalPermissionService;
TimeMachineWs.class,
ManualMeasuresWs.class,
MetricsWs.class,
- org.sonar.server.metric.ws.ListAction.class,
+ SearchAction.class,
org.sonar.server.metric.ws.TypesAction.class,
org.sonar.server.metric.ws.DomainsAction.class,
org.sonar.server.metric.ws.DeleteAction.class,
+++ /dev/null
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-package org.sonar.server.metric.ws;
-
-import org.apache.commons.lang.StringUtils;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.sonar.api.server.ws.WebService.Param;
-import org.sonar.core.metric.db.MetricDto;
-import org.sonar.core.persistence.DbSession;
-import org.sonar.core.persistence.DbTester;
-import org.sonar.server.db.DbClient;
-import org.sonar.server.metric.persistence.MetricDao;
-import org.sonar.server.ws.WsTester;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.sonar.server.metric.ws.ListAction.PARAM_IS_CUSTOM;
-import static org.sonar.server.metric.ws.MetricTesting.newMetricDto;
-
-public class ListActionTest {
-
- @ClassRule
- public static DbTester db = new DbTester();
- DbClient dbClient;
- DbSession dbSession;
- WsTester ws;
-
- @Before
- public void setUp() {
- dbClient = new DbClient(db.database(), db.myBatis(), new MetricDao());
- dbSession = dbClient.openSession(false);
- ws = new WsTester(new MetricsWs(new ListAction(dbClient)));
- db.truncateTables();
- }
-
- @After
- public void tearDown() {
- dbSession.close();
- }
-
- @Test
- public void list_metrics_in_database() throws Exception {
- insertNewCustomMetric("1", "2", "3");
-
- WsTester.Result result = newRequest().execute();
-
- result.assertJson(getClass(), "list_metrics.json");
- }
-
- @Test
- public void list_metrics_ordered_by_name_case_insensitive() throws Exception {
- insertNewCustomMetric("3", "1", "2");
-
- String firstResult = newRequest().setParam(Param.PAGE, "1").setParam(Param.PAGE_SIZE, "1").execute().outputAsString();
- String secondResult = newRequest().setParam(Param.PAGE, "2").setParam(Param.PAGE_SIZE, "1").execute().outputAsString();
- String thirdResult = newRequest().setParam(Param.PAGE, "3").setParam(Param.PAGE_SIZE, "1").execute().outputAsString();
-
- assertThat(firstResult).contains("custom-key-1").doesNotContain("custom-key-2").doesNotContain("custom-key-3");
- assertThat(secondResult).contains("custom-key-2").doesNotContain("custom-key-1").doesNotContain("custom-key-3");
- assertThat(thirdResult).contains("custom-key-3").doesNotContain("custom-key-1").doesNotContain("custom-key-2");
- }
-
- @Test
- public void list_metrics_with_pagination() throws Exception {
- insertNewCustomMetric("1", "2", "3", "4", "5", "6", "7", "8", "9", "10");
-
- WsTester.Result result = newRequest()
- .setParam(Param.PAGE, "3")
- .setParam(Param.PAGE_SIZE, "4")
- .execute();
-
- assertThat(StringUtils.countMatches(result.outputAsString(), "custom-key")).isEqualTo(2);
- }
-
- @Test
- public void list_metric_with_is_custom_true() throws Exception {
- insertNewCustomMetric("1", "2");
- insertNewNonCustomMetric("3");
-
- String result = newRequest()
- .setParam(PARAM_IS_CUSTOM, "true").execute().outputAsString();
-
- assertThat(result).contains("custom-key-1", "custom-key-2")
- .doesNotContain("non-custom-key-3");
- }
-
- @Test
- public void list_metric_with_is_custom_false() throws Exception {
- insertNewCustomMetric("1", "2");
- insertNewNonCustomMetric("3");
-
- String result = newRequest()
- .setParam(PARAM_IS_CUSTOM, "false").execute().outputAsString();
-
- assertThat(result).doesNotContain("custom-key-1")
- .doesNotContain("custom-key-2")
- .contains("non-custom-key-3");
- }
-
- @Test
- public void list_metric_with_chosen_fields() throws Exception {
- insertNewCustomMetric("1");
-
- String result = newRequest().setParam(Param.FIELDS, "name").execute().outputAsString();
-
- assertThat(result).contains("id", "key", "name")
- .doesNotContain("domain")
- .doesNotContain("description")
- .doesNotContain("type");
- }
-
- private void insertNewNonCustomMetric(String... ids) {
- for (String id : ids) {
- dbClient.metricDao().insert(dbSession, newMetricDto()
- .setKey("non-custom-key-" + id)
- .setEnabled(true)
- .setUserManaged(false));
- }
- dbSession.commit();
- }
-
- private void insertNewCustomMetric(String... ids) {
- for (String id : ids) {
- dbClient.metricDao().insert(dbSession, newCustomMetric(id));
- }
- dbSession.commit();
- }
-
- private MetricDto newCustomMetric(String id) {
- return newMetricDto()
- .setKey("custom-key-" + id)
- .setShortName("custom-name-" + id)
- .setDomain("custom-domain-" + id)
- .setDescription("custom-description-" + id)
- .setValueType("INT")
- .setUserManaged(true)
- .setEnabled(true);
- }
-
- private WsTester.TestRequest newRequest() {
- return ws.newGetRequest("api/metrics", "list");
- }
-}
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.sonar.server.metric.ws;
+
+import org.apache.commons.lang.StringUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.sonar.api.server.ws.WebService.Param;
+import org.sonar.core.metric.db.MetricDto;
+import org.sonar.core.persistence.DbSession;
+import org.sonar.core.persistence.DbTester;
+import org.sonar.server.db.DbClient;
+import org.sonar.server.metric.persistence.MetricDao;
+import org.sonar.server.ws.WsTester;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.sonar.server.metric.ws.SearchAction.PARAM_IS_CUSTOM;
+import static org.sonar.server.metric.ws.MetricTesting.newMetricDto;
+
+public class SearchActionTest {
+
+ @ClassRule
+ public static DbTester db = new DbTester();
+ DbClient dbClient;
+ DbSession dbSession;
+ WsTester ws;
+
+ @Before
+ public void setUp() {
+ dbClient = new DbClient(db.database(), db.myBatis(), new MetricDao());
+ dbSession = dbClient.openSession(false);
+ ws = new WsTester(new MetricsWs(new SearchAction(dbClient)));
+ db.truncateTables();
+ }
+
+ @After
+ public void tearDown() {
+ dbSession.close();
+ }
+
+ @Test
+ public void search_metrics_in_database() throws Exception {
+ insertNewCustomMetric("1", "2", "3");
+
+ WsTester.Result result = newRequest().execute();
+
+ result.assertJson(getClass(), "search_metrics.json");
+ }
+
+ @Test
+ public void search_metrics_ordered_by_name_case_insensitive() throws Exception {
+ insertNewCustomMetric("3", "1", "2");
+
+ String firstResult = newRequest().setParam(Param.PAGE, "1").setParam(Param.PAGE_SIZE, "1").execute().outputAsString();
+ String secondResult = newRequest().setParam(Param.PAGE, "2").setParam(Param.PAGE_SIZE, "1").execute().outputAsString();
+ String thirdResult = newRequest().setParam(Param.PAGE, "3").setParam(Param.PAGE_SIZE, "1").execute().outputAsString();
+
+ assertThat(firstResult).contains("custom-key-1").doesNotContain("custom-key-2").doesNotContain("custom-key-3");
+ assertThat(secondResult).contains("custom-key-2").doesNotContain("custom-key-1").doesNotContain("custom-key-3");
+ assertThat(thirdResult).contains("custom-key-3").doesNotContain("custom-key-1").doesNotContain("custom-key-2");
+ }
+
+ @Test
+ public void search_metrics_with_pagination() throws Exception {
+ insertNewCustomMetric("1", "2", "3", "4", "5", "6", "7", "8", "9", "10");
+
+ WsTester.Result result = newRequest()
+ .setParam(Param.PAGE, "3")
+ .setParam(Param.PAGE_SIZE, "4")
+ .execute();
+
+ assertThat(StringUtils.countMatches(result.outputAsString(), "custom-key")).isEqualTo(2);
+ }
+
+ @Test
+ public void list_metric_with_is_custom_true() throws Exception {
+ insertNewCustomMetric("1", "2");
+ insertNewNonCustomMetric("3");
+
+ String result = newRequest()
+ .setParam(PARAM_IS_CUSTOM, "true").execute().outputAsString();
+
+ assertThat(result).contains("custom-key-1", "custom-key-2")
+ .doesNotContain("non-custom-key-3");
+ }
+
+ @Test
+ public void list_metric_with_is_custom_false() throws Exception {
+ insertNewCustomMetric("1", "2");
+ insertNewNonCustomMetric("3");
+
+ String result = newRequest()
+ .setParam(PARAM_IS_CUSTOM, "false").execute().outputAsString();
+
+ assertThat(result).doesNotContain("custom-key-1")
+ .doesNotContain("custom-key-2")
+ .contains("non-custom-key-3");
+ }
+
+ @Test
+ public void list_metric_with_chosen_fields() throws Exception {
+ insertNewCustomMetric("1");
+
+ String result = newRequest().setParam(Param.FIELDS, "name").execute().outputAsString();
+
+ assertThat(result).contains("id", "key", "name")
+ .doesNotContain("domain")
+ .doesNotContain("description")
+ .doesNotContain("type");
+ }
+
+ private void insertNewNonCustomMetric(String... ids) {
+ for (String id : ids) {
+ dbClient.metricDao().insert(dbSession, newMetricDto()
+ .setKey("non-custom-key-" + id)
+ .setEnabled(true)
+ .setUserManaged(false));
+ }
+ dbSession.commit();
+ }
+
+ private void insertNewCustomMetric(String... ids) {
+ for (String id : ids) {
+ dbClient.metricDao().insert(dbSession, newCustomMetric(id));
+ }
+ dbSession.commit();
+ }
+
+ private MetricDto newCustomMetric(String id) {
+ return newMetricDto()
+ .setKey("custom-key-" + id)
+ .setShortName("custom-name-" + id)
+ .setDomain("custom-domain-" + id)
+ .setDescription("custom-description-" + id)
+ .setValueType("INT")
+ .setUserManaged(true)
+ .setEnabled(true);
+ }
+
+ private WsTester.TestRequest newRequest() {
+ return ws.newGetRequest("api/metrics", "search");
+ }
+}
+++ /dev/null
-{
- "metrics":[
- {
- "key":"custom-key-1",
- "name":"custom-name-1",
- "type":"Integer",
- "domain":"custom-domain-1",
- "description":"custom-description-1"
- },
- {
- "key":"custom-key-2",
- "name":"custom-name-2",
- "type":"Integer",
- "domain":"custom-domain-2",
- "description":"custom-description-2"
- },
- {
- "key":"custom-key-3",
- "name":"custom-name-3",
- "type":"Integer",
- "domain":"custom-domain-3",
- "description":"custom-description-3"
- }
- ]
-}
--- /dev/null
+{
+ "metrics":[
+ {
+ "key":"custom-key-1",
+ "name":"custom-name-1",
+ "type":"Integer",
+ "domain":"custom-domain-1",
+ "description":"custom-description-1"
+ },
+ {
+ "key":"custom-key-2",
+ "name":"custom-name-2",
+ "type":"Integer",
+ "domain":"custom-domain-2",
+ "description":"custom-description-2"
+ },
+ {
+ "key":"custom-key-3",
+ "name":"custom-name-3",
+ "type":"Integer",
+ "domain":"custom-domain-3",
+ "description":"custom-description-3"
+ }
+ ],
+ "total":3,
+ "ps":100,
+ "p":1
+}
List<MetricDto> selectByKeys(@Param("keys") List<String> keys);
void disable(@Param("ids") List<Integer> ids);
+
+ int countCustom();
}
</where>
ORDER BY UPPER(m.short_name)
</select>
+ <select id="countCustom" resultType="Integer">
+ SELECT COUNT(*)
+ FROM metrics m
+ <where>
+ AND m.enabled=${_true}
+ AND m.user_managed=${_true}
+ </where>
+ </select>
<insert id="insert" parameterType="org.sonar.core.metric.db.MetricDto" useGeneratedKeys="true" keyColumn="id"
keyProperty="id">