]> source.dussan.org Git - sonarqube.git/commitdiff
* Add EventUnmarshaller to sonar-gwt-api
authorGodin <mandrikov@gmail.com>
Mon, 13 Dec 2010 14:56:54 +0000 (14:56 +0000)
committerGodin <mandrikov@gmail.com>
Mon, 13 Dec 2010 14:56:54 +0000 (14:56 +0000)
* Fix TimeMachineUnmarshaller

sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/EventUnmarshaller.java [new file with mode: 0644]
sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/TimeMachineUnmarshaller.java
sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/Unmarshallers.java

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 (file)
index 0000000..bd7ca08
--- /dev/null
@@ -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"));
+  }
+}
index 008e53b98f065bbc54a8312d8773289ac39adae7..68ffda4ed06573c7fc79b3cd7b667c4d8f962d9a 100644 (file)
@@ -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);
index 93a5dbf8110e203b31b6abd43f2efc936788f5b8..637af109357283642a9294258639d3615d16ec01 100644 (file)
@@ -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());
   }