Revision 194492f7
Added by Cherian Mathew almost 9 years ago
- ID 194492f79bb2fb5eca5b4a2a5a3b39b849be8c51
- Parent 0312ac03
src/test/java/eu/etaxonomy/cdm/vaadin/jscomponent/D3CTree.java | ||
---|---|---|
10 | 10 |
package eu.etaxonomy.cdm.vaadin.jscomponent; |
11 | 11 |
|
12 | 12 |
import org.apache.log4j.Logger; |
13 |
import org.json.JSONArray; |
|
14 |
import org.json.JSONException; |
|
15 |
import org.json.JSONObject; |
|
16 | 13 |
|
14 |
import com.google.gwt.json.client.JSONException; |
|
17 | 15 |
import com.vaadin.annotations.JavaScript; |
18 | 16 |
import com.vaadin.annotations.StyleSheet; |
19 | 17 |
import com.vaadin.ui.AbstractJavaScriptComponent; |
20 | 18 |
import com.vaadin.ui.JavaScriptFunction; |
21 | 19 |
import com.vaadin.ui.Notification; |
22 | 20 |
|
21 |
import elemental.json.Json; |
|
22 |
import elemental.json.JsonArray; |
|
23 |
import elemental.json.JsonObject; |
|
24 |
|
|
23 | 25 |
/** |
24 | 26 |
* @author cmathew |
25 | 27 |
* @date 8 Apr 2015 |
... | ... | |
35 | 37 |
addFunction("select", new JavaScriptFunction() { |
36 | 38 |
|
37 | 39 |
@Override |
38 |
public void call(JSONArray arguments) throws JSONException {
|
|
40 |
public void call(elemental.json.JsonArray arguments) {
|
|
39 | 41 |
Notification.show("JS Rpc call : click on " + arguments.getString(0)); |
40 | 42 |
} |
41 | 43 |
}); |
42 | 44 |
|
43 | 45 |
try { |
44 |
JSONObject taxonFrom = new JSONObject();
|
|
46 |
JsonObject taxonFrom = Json.createObject();
|
|
45 | 47 |
taxonFrom.put("name", "taxon from"); |
46 | 48 |
|
47 | 49 |
|
48 |
JSONArray tfChildren = new JSONArray();
|
|
50 |
JsonArray tfChildren = Json.createArray();
|
|
49 | 51 |
taxonFrom.put("children", tfChildren); |
50 | 52 |
|
51 |
JSONObject conceptRelationship1 = new JSONObject();
|
|
53 |
JsonObject conceptRelationship1 = Json.createObject();
|
|
52 | 54 |
conceptRelationship1.put("name", "concept relationship 1"); |
53 | 55 |
|
54 |
JSONArray cr1Children = new JSONArray();
|
|
56 |
JsonArray cr1Children = Json.createArray();
|
|
55 | 57 |
conceptRelationship1.put("children", cr1Children); |
56 | 58 |
|
57 |
JSONObject conceptRelationship2 = new JSONObject();
|
|
59 |
JsonObject conceptRelationship2 = Json.createObject();
|
|
58 | 60 |
conceptRelationship2.put("name", "concept relationship 2"); |
59 | 61 |
|
60 |
JSONArray cr2Children = new JSONArray();
|
|
62 |
JsonArray cr2Children = Json.createArray();
|
|
61 | 63 |
conceptRelationship2.put("children", cr2Children); |
62 | 64 |
|
63 |
tfChildren.put(0, conceptRelationship1);
|
|
64 |
tfChildren.put(1, conceptRelationship2);
|
|
65 |
tfChildren.set(0, conceptRelationship1);
|
|
66 |
tfChildren.set(1, conceptRelationship2);
|
|
65 | 67 |
|
66 |
JSONObject taxonTo = new JSONObject();
|
|
68 |
JsonObject taxonTo = Json.createObject();
|
|
67 | 69 |
taxonTo.put("name", "taxon to"); |
68 | 70 |
|
69 |
cr1Children.put(0, taxonTo);
|
|
70 |
cr2Children.put(0, taxonTo);
|
|
71 |
cr1Children.set(0, taxonTo);
|
|
72 |
cr2Children.set(0, taxonTo);
|
|
71 | 73 |
//String conceptRelationshipTree = taxonFrom.toString(); |
72 | 74 |
String conceptRelationshipTree = "{\"direction\":\"right-left\",\"name\":\"Taxon d\",\"children\":[{\"name\":\"Congruent to\",\"children\":[{\"name\":\"Taxon e\",\"uuid\":\"84e99e24-f50a-4726-92d0-6088430c492a\",\"type\":\"taxon\"}],\"uuid\":\"511f504b-ae3b-4f04-b7b9-35c222f06e10\",\"type\":\"conceptr\"},{\"name\":\"Includes\",\"children\":[{\"name\":\"Taxon a\",\"uuid\":\"eaac797e-cac7-4649-97cf-c7b580076895\",\"type\":\"taxon\"}],\"uuid\":\"0e8b7922-974d-4389-b71e-af6fc9f98c56\",\"type\":\"conceptr\"},{\"name\":\"Includes\",\"children\":[{\"name\":\"Taxon b\",\"uuid\":\"5004a8e7-b907-4744-b67e-44ccb057ab3b\",\"type\":\"taxon\"}],\"uuid\":\"6fd9947e-21c3-4190-8748-57d9661e8659\",\"type\":\"conceptr\"},{\"name\":\"Excludes\",\"children\":[{\"name\":\"Taxon c\",\"uuid\":\"3d71c8b8-3bec-4f5f-ba23-6f9d55ef84e9\",\"type\":\"taxon\"}],\"uuid\":\"cc761030-38d2-4b5d-954d-32329c0ea106\",\"type\":\"conceptr\"}],\"uuid\":\"5f713f69-e03e-4a11-8a55-700fbbf44805\",\"type\":\"taxon\"}"; |
73 | 75 |
logger.warn("conceptRelationshipTree : " + conceptRelationshipTree); |
Also available in: Unified diff
updated version in pom file to 7.4.4 and replaced usage of org.json with elemental.json
Two issues seen (needs more investigation) :