diff options
author | Godin <mandrikov@gmail.com> | 2010-12-13 14:56:54 +0000 |
---|---|---|
committer | Godin <mandrikov@gmail.com> | 2010-12-13 14:56:54 +0000 |
commit | 1147fd00b57d8b0d519315b04ffa0b8443a979cd (patch) | |
tree | 066484d3a1a10096ade61774db12b306c1e94269 /sonar-gwt-api | |
parent | 12b66215dca176a1ed3136abbbe24fb49f8b5cc9 (diff) | |
download | sonarqube-1147fd00b57d8b0d519315b04ffa0b8443a979cd.tar.gz sonarqube-1147fd00b57d8b0d519315b04ffa0b8443a979cd.zip |
* Add EventUnmarshaller to sonar-gwt-api
* Fix TimeMachineUnmarshaller
Diffstat (limited to 'sonar-gwt-api')
3 files changed, 45 insertions, 1 deletions
diff --git a/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/EventUnmarshaller.java b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/EventUnmarshaller.java new file mode 100644 index 00000000000..bd7ca08aa75 --- /dev/null +++ b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/EventUnmarshaller.java @@ -0,0 +1,38 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2009 SonarSource SA + * 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.gwt.unmarshallers; + +import com.google.gwt.json.client.JSONObject; +import org.sonar.gwt.JsonUtils; +import org.sonar.wsclient.services.Event; + +public class EventUnmarshaller extends AbstractUnmarshaller<Event> { + + protected Event parse(JSONObject json) { + return new Event() + .setId(JsonUtils.getString(json, "id")) + .setResourceKey(JsonUtils.getString(json, "rk")) + .setName(JsonUtils.getString(json, "n")) + .setCategory(JsonUtils.getString(json, "c")) + .setDate(JsonUtils.getDate(json, "dt")) + .setDescription(JsonUtils.getString(json, "ds")) + .setData(JsonUtils.getString(json, "data")); + } +} diff --git a/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/TimeMachineUnmarshaller.java b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/TimeMachineUnmarshaller.java index 008e53b98f0..68ffda4ed06 100644 --- a/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/TimeMachineUnmarshaller.java +++ b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/TimeMachineUnmarshaller.java @@ -18,7 +18,8 @@ public class TimeMachineUnmarshaller implements Unmarshaller<TimeMachineData> { JSONArray array = map.get(dateTimeStr).isArray(); List<String> measures = new ArrayList<String>(); for (int i = 0; i < JsonUtils.getArraySize(array); i++) { - JSONValue elem = JsonUtils.getArray(array, i); + // We can't use JsonUtils.getArray here, because it returns JSONObject instead of JSONValue + JSONValue elem = array.get(i); measures.add(JsonUtils.getAsString(elem)); } data.put(JsonUtils.parseDateTime(dateTimeStr), measures); diff --git a/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/Unmarshallers.java b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/Unmarshallers.java index 93a5dbf8110..637af109357 100644 --- a/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/Unmarshallers.java +++ b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/Unmarshallers.java @@ -41,6 +41,11 @@ public final class Unmarshallers { unmarshallers.put(Violation.class, new ViolationUnmarshaller()); unmarshallers.put(Server.class, new ServerUnmarshaller()); unmarshallers.put(DependencyTree.class, new DependencyTreeUnmarshaller()); + unmarshallers.put(Event.class, new EventUnmarshaller()); + // TODO + // FavouriteUnmarshaller + // PluginUnmarshaller + // RuleUnmarshaller unmarshallers.put(TimeMachineData.class, new TimeMachineUnmarshaller()); } |