diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2011-07-27 10:59:00 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2011-07-27 12:12:01 +0200 |
commit | 58a8a74c05def9176479b2cf951c49f398cb72f8 (patch) | |
tree | 336eabec56e974a6668c3547c1ee64c12dca5a66 /sonar-ws-client/src/main/java/org/sonar/wsclient | |
parent | ea0fb362a7dd6188973c0cb27291720ae71c29ca (diff) | |
download | sonarqube-58a8a74c05def9176479b2cf951c49f398cb72f8.tar.gz sonarqube-58a8a74c05def9176479b2cf951c49f398cb72f8.zip |
SONAR-2648 New web service /api/manual_measures
Diffstat (limited to 'sonar-ws-client/src/main/java/org/sonar/wsclient')
4 files changed, 243 insertions, 0 deletions
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ManualMeasure.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ManualMeasure.java new file mode 100644 index 00000000000..a755dfbf438 --- /dev/null +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ManualMeasure.java @@ -0,0 +1,133 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2008-2011 SonarSource + * mailto:contact AT sonarsource DOT com + * + * Sonar 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. + * + * Sonar 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 Sonar; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +package org.sonar.wsclient.services; + +import java.util.Date; + +/** + * @since 2.10 + */ +public class ManualMeasure extends Model { + + private long id; + private String metricKey; + private String resourceKey; + private Double value; + private String textValue; + private Date createdAt; + private Date updatedAt; + private String userLogin; + private String userName; + + public ManualMeasure() { + } + + public long getId() { + return id; + } + + public ManualMeasure setId(long id) { + this.id = id; + return this; + } + + public String getMetricKey() { + return metricKey; + } + + public ManualMeasure setMetricKey(String metricKey) { + this.metricKey = metricKey; + return this; + } + + public Double getValue() { + return value; + } + + public ManualMeasure setValue(Double value) { + this.value = value; + return this; + } + + public String getTextValue() { + return textValue; + } + + public ManualMeasure setTextValue(String textValue) { + this.textValue = textValue; + return this; + } + + public Date getCreatedAt() { + return createdAt; + } + + public ManualMeasure setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + return this; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public ManualMeasure setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public String getUserLogin() { + return userLogin; + } + + public ManualMeasure setUserLogin(String userLogin) { + this.userLogin = userLogin; + return this; + } + + public String getUserName() { + return userName; + } + + public ManualMeasure setUserName(String userName) { + this.userName = userName; + return this; + } + + public String getResourceKey() { + return resourceKey; + } + + public ManualMeasure setResourceKey(String resourceKey) { + this.resourceKey = resourceKey; + return this; + } + + @Override + public String toString() { + return new StringBuilder().append("Measure{") + .append("id='").append(id).append('\'') + .append("resourceKey='").append(resourceKey).append('\'') + .append("metricKey='").append(metricKey).append('\'') + .append(", value=").append(value) + .append(", textValue='").append(textValue).append('\'') + .append('}').toString(); + } +} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ManualMeasureQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ManualMeasureQuery.java new file mode 100644 index 00000000000..e2db6c2a192 --- /dev/null +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ManualMeasureQuery.java @@ -0,0 +1,64 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2008-2011 SonarSource + * mailto:contact AT sonarsource DOT com + * + * Sonar 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. + * + * Sonar 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 Sonar; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +package org.sonar.wsclient.services; + +/** + * @since 2.10 + */ +public final class ManualMeasureQuery extends Query<ManualMeasure> { + public static final String BASE_URL = "/api/manual_measures?"; + + private String resourceKey; + private String metricKey; + + private ManualMeasureQuery(String resourceKey) { + this.resourceKey = resourceKey; + } + + public String getResourceKey() { + return resourceKey; + } + + public String getMetricKey() { + return metricKey; + } + + public ManualMeasureQuery setMetricKey(String s) { + this.metricKey = s; + return this; + } + + @Override + public String getUrl() { + StringBuilder sb = new StringBuilder(BASE_URL); + appendUrlParameter(sb, "resource", resourceKey); + appendUrlParameter(sb, "metric", metricKey); + return sb.toString(); + } + + @Override + public Class<ManualMeasure> getModelClass() { + return ManualMeasure.class; + } + + public static ManualMeasureQuery create(String resourceKey) { + return new ManualMeasureQuery(resourceKey); + } +} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ManualMeasureUnmarshaller.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ManualMeasureUnmarshaller.java new file mode 100644 index 00000000000..f3b1a2d7bf8 --- /dev/null +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ManualMeasureUnmarshaller.java @@ -0,0 +1,45 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2008-2011 SonarSource + * mailto:contact AT sonarsource DOT com + * + * Sonar 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. + * + * Sonar 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 Sonar; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +package org.sonar.wsclient.unmarshallers; + +import org.sonar.wsclient.services.ManualMeasure; +import org.sonar.wsclient.services.WSUtils; + +/** + * @since 2.10 + */ +public class ManualMeasureUnmarshaller extends AbstractUnmarshaller<ManualMeasure> { + + @Override + protected ManualMeasure parse(Object json) { + WSUtils utils = WSUtils.getINSTANCE(); + return new ManualMeasure() + .setId(utils.getLong(json, "id")) + .setMetricKey(utils.getString(json, "metric")) + .setResourceKey(utils.getString(json, "resource")) + .setCreatedAt(utils.getDateTime(json, "created_at")) + .setUpdatedAt(utils.getDateTime(json, "updated_at")) + .setUserLogin(utils.getString(json, "login")) + .setUserName(utils.getString(json, "username")) + .setValue(utils.getDouble(json, "val")) + .setTextValue(utils.getString(json, "text")) + ; + } +} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/Unmarshallers.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/Unmarshallers.java index 71be7418dcf..5974603e3d4 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/Unmarshallers.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/Unmarshallers.java @@ -48,6 +48,7 @@ public final class Unmarshallers { unmarshallers.put(TimeMachine.class, new TimeMachineUnmarshaller()); unmarshallers.put(Profile.class, new ProfileUnmarshaller()); unmarshallers.put(Review.class, new ReviewUnmarshaller()); + unmarshallers.put(ManualMeasure.class, new ManualMeasureUnmarshaller()); } public static <MODEL extends Model> Unmarshaller<MODEL> forModel(Class<MODEL> modelClass) { |