Search in sources :

Example 86 with JSONObject

use of com.google.gwt.json.client.JSONObject in project perun by CESNET.

the class ValidateMemberAsync method prepareJSONObject.

/**
	 * Prepares a JSON object
	 *
	 * @return JSONObject the whole query
	 */
private JSONObject prepareJSONObject() {
    // create whole JSON query
    JSONObject jsonQuery = new JSONObject();
    jsonQuery.put("member", new JSONNumber(member.getId()));
    return jsonQuery;
}
Also used : JSONObject(com.google.gwt.json.client.JSONObject) JSONNumber(com.google.gwt.json.client.JSONNumber)

Example 87 with JSONObject

use of com.google.gwt.json.client.JSONObject in project perun by CESNET.

the class CreateOwner method prepareJSONObject.

/**
	 * Prepares a JSON object
	 *
	 * @return JSONObject the whole query
	 */
private JSONObject prepareJSONObject() {
    JSONObject owner = new JSONObject();
    owner.put("name", new JSONString(ownerName));
    owner.put("contact", new JSONString(ownerContact));
    owner.put("type", new JSONString(ownerType));
    JSONObject jsonQuery = new JSONObject();
    jsonQuery.put("owner", owner);
    return jsonQuery;
}
Also used : JSONObject(com.google.gwt.json.client.JSONObject) JSONString(com.google.gwt.json.client.JSONString)

Example 88 with JSONObject

use of com.google.gwt.json.client.JSONObject in project perun by CESNET.

the class DeleteOwner method prepareJSONObject.

/**
	 * Prepares a JSON object
	 *
	 * @return JSONObject the whole query
	 */
private JSONObject prepareJSONObject() {
    JSONObject jsonQuery = new JSONObject();
    jsonQuery.put("owner", new JSONNumber(ownerId));
    return jsonQuery;
}
Also used : JSONObject(com.google.gwt.json.client.JSONObject) JSONNumber(com.google.gwt.json.client.JSONNumber)

Example 89 with JSONObject

use of com.google.gwt.json.client.JSONObject in project perun by CESNET.

the class UpdateUser method updateUser.

/**
	 * Updates user details
	 * @param user User with updated details
	 */
public void updateUser(User user) {
    if (user == null) {
        UiElements.generateAlert("Parameter error", "User to update can't be null");
        return;
    }
    // OBJECT
    JSONObject oldUser = new JSONObject(user);
    // RECONSTRUCT OBJECT
    JSONObject newUser = new JSONObject();
    newUser.put("id", oldUser.get("id"));
    newUser.put("firstName", oldUser.get("firstName"));
    newUser.put("middleName", oldUser.get("middleName"));
    newUser.put("lastName", oldUser.get("lastName"));
    newUser.put("titleBefore", oldUser.get("titleBefore"));
    newUser.put("titleAfter", oldUser.get("titleAfter"));
    newUser.put("serviceUser", oldUser.get("serviceUser"));
    newUser.put("sponsoredUser", oldUser.get("sponsoredUser"));
    // whole JSON query
    JSONObject jsonQuery = new JSONObject();
    jsonQuery.put("user", newUser);
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Updating user failed.");
            events.onError(error);
        }

        ;

        public void onFinished(JavaScriptObject jso) {
            User u = jso.cast();
            session.getUiElements().setLogSuccessText("User " + u.getFullNameWithTitles() + " successfully updated!");
            events.onFinished(jso);
        }

        ;

        public void onLoadingStart() {
            events.onLoadingStart();
        }

        ;
    };
    // sending data
    JsonPostClient jspc = new JsonPostClient(newEvents);
    jspc.sendData(JSON_URL, jsonQuery);
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) User(cz.metacentrum.perun.webgui.model.User) JSONObject(com.google.gwt.json.client.JSONObject) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) JsonPostClient(cz.metacentrum.perun.webgui.json.JsonPostClient) PerunError(cz.metacentrum.perun.webgui.model.PerunError)

Example 90 with JSONObject

use of com.google.gwt.json.client.JSONObject in project perun by CESNET.

the class CreateVo method prepareJSONObject.

/**
	 * Prepares a JSON object.
	 * @return JSONObject - the whole query
	 */
private JSONObject prepareJSONObject() {
    // vo
    JSONObject vo = new JSONObject();
    vo.put("name", new JSONString(name));
    vo.put("shortName", new JSONString(shortName));
    // whole JSON query
    JSONObject jsonQuery = new JSONObject();
    jsonQuery.put("vo", vo);
    return jsonQuery;
}
Also used : JSONObject(com.google.gwt.json.client.JSONObject) JSONString(com.google.gwt.json.client.JSONString)

Aggregations

JSONObject (com.google.gwt.json.client.JSONObject)227 JSONNumber (com.google.gwt.json.client.JSONNumber)109 JSONString (com.google.gwt.json.client.JSONString)74 JSONArray (com.google.gwt.json.client.JSONArray)62 PerunError (cz.metacentrum.perun.webgui.model.PerunError)55 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)54 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)54 JsonPostClient (cz.metacentrum.perun.webgui.json.JsonPostClient)50 JSONValue (com.google.gwt.json.client.JSONValue)13 HashMap (java.util.HashMap)12 Map (java.util.Map)8 ArrayList (java.util.ArrayList)6 JsArrayString (com.google.gwt.core.client.JsArrayString)3 User (cz.metacentrum.perun.webgui.model.User)3 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)2 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)2 Command (com.google.gwt.user.client.Command)2 Contact (com.googlecode.gwtphonegap.client.contacts.Contact)2 ContactField (com.googlecode.gwtphonegap.client.contacts.ContactField)2 StringCallback (com.gwtmobile.phonegap.client.plugins.Bluetooth.StringCallback)2