Search in sources :

Example 56 with JSONObject

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

the class CreateService method prepareJSONObject.

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

Example 57 with JSONObject

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

the class CreateServicePackage method prepareJSONObject.

/**
	 * Prepares a JSON object
	 * @return JSONObject the whole query
	 */
private JSONObject prepareJSONObject() {
    // service
    JSONObject service = new JSONObject();
    service.put("name", new JSONString(packageName));
    service.put("description", new JSONString(packageDescription));
    service.put("id", null);
    // whole JSON query
    JSONObject jsonQuery = new JSONObject();
    jsonQuery.put("servicesPackage", service);
    return jsonQuery;
}
Also used : JSONObject(com.google.gwt.json.client.JSONObject) JSONString(com.google.gwt.json.client.JSONString)

Example 58 with JSONObject

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

the class SetLogin method prepareJSONObject.

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

Example 59 with JSONObject

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

the class UpdateNameTitles method updateUserTitles.

/**
	 * Updates user details
	 * @param user User with updated details
	 */
public void updateUserTitles(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"));
    // 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 60 with JSONObject

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

the class AddDestination method prepareJSONObject.

/**
	 * Prepares a JSON object
	 *
	 * @return JSONObject the whole query
	 */
private JSONObject prepareJSONObject() {
    // whole JSON query
    JSONObject jsonQuery = new JSONObject();
    jsonQuery.put("destination", new JSONString(destination));
    jsonQuery.put("type", new JSONString(type));
    jsonQuery.put("facility", new JSONNumber(facility.getId()));
    JSONArray servs = new JSONArray();
    for (int i = 0; i < services.size(); i++) {
        // rebuild service object
        JSONObject srv = new JSONObject();
        srv.put("id", new JSONNumber(services.get(i).getId()));
        srv.put("name", new JSONString(services.get(i).getName()));
        servs.set(i, srv);
    }
    jsonQuery.put("services", servs);
    return jsonQuery;
}
Also used : JSONObject(com.google.gwt.json.client.JSONObject) JSONArray(com.google.gwt.json.client.JSONArray) JSONNumber(com.google.gwt.json.client.JSONNumber) 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