summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkrasimir <krasimir@chalmers.se>2010-11-17 10:46:00 +0000
committerkrasimir <krasimir@chalmers.se>2010-11-17 10:46:00 +0000
commit7a2ab26f9f742f30b6068dc3cc95aa9965042a61 (patch)
tree3ee3f63b316cdd88cdfeda6c45e78f0feb1f07a5
parentcf8e1850bdd1a290305ec1a27fbcfd1d06a10f4b (diff)
forgot to add ContentService.java in the GF Editor
-rw-r--r--src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/ContentService.java77
1 files changed, 77 insertions, 0 deletions
diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/ContentService.java b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/ContentService.java
new file mode 100644
index 000000000..42ae897ba
--- /dev/null
+++ b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/ContentService.java
@@ -0,0 +1,77 @@
+package org.grammaticalframework.ui.gwt.client;
+
+import org.grammaticalframework.ui.gwt.client.JSONRequestBuilder.Arg;
+
+import java.util.*;
+import com.google.gwt.core.client.*;
+
+public class ContentService {
+ String contentBaseURL;
+
+ public ContentService(String contentBaseURL) {
+ this.contentBaseURL = contentBaseURL;
+ }
+
+ public String getBaseURL() {
+ return contentBaseURL;
+ }
+
+ public JSONRequest save(Object id, String content, SaveCallback callback) {
+ List<Arg> args = new ArrayList<Arg>();
+ if (id != null)
+ args.add(new Arg("id", id.toString()));
+ args.add(new Arg("command", "save"));
+ return JSONRequestBuilder.sendDataRequest(contentBaseURL, args, content, callback);
+ }
+
+ public interface SaveCallback extends JSONCallback<DocumentSignature> {}
+
+ public JSONRequest load(Object id, LoadCallback callback) {
+ List<Arg> args = new ArrayList<Arg>();
+ args.add(new Arg("command", "load"));
+ args.add(new Arg("id", id.toString()));
+ return JSONRequestBuilder.sendRequest(contentBaseURL, args, callback);
+ }
+
+ public interface LoadCallback extends JSONCallback<Document> {}
+
+ public JSONRequest search(String fullTextQuery, SearchCallback callback) {
+ List<Arg> args = new ArrayList<Arg>();
+ args.add(new Arg("command", "search"));
+ args.add(new Arg("query", fullTextQuery));
+ return JSONRequestBuilder.sendRequest(contentBaseURL, args, callback);
+ }
+
+ public interface SearchCallback extends JSONCallback<IterableJsArray<DocumentSignature>> {}
+
+ public static class DocumentSignature extends JavaScriptObject {
+ protected DocumentSignature() { }
+
+ public final native int getId() /*-{ return this.id; }-*/;
+ public final native String getTitle() /*-{ return this.title; }-*/;
+ public final native String getCreated() /*-{ return this.created; }-*/;
+ public final native String getModified() /*-{ return this.modified; }-*/;
+ }
+
+ public static class Document extends DocumentSignature {
+ protected Document() { }
+
+ public final native String getContent() /*-{ return this.content; }-*/;
+ }
+
+ public JSONRequest delete(List ids, DeleteCallback callback) {
+ List<Arg> args = new ArrayList<Arg>();
+ args.add(new Arg("command", "delete"));
+ for (Object id : ids) {
+ args.add(new Arg("id", id.toString()));
+ }
+ return JSONRequestBuilder.sendRequest(contentBaseURL, args, callback);
+ }
+
+ public interface DeleteCallback extends JSONCallback<DeleteResult> {}
+
+ public static class DeleteResult extends JavaScriptObject {
+ protected DeleteResult() { }
+ }
+
+}