Search in sources :

Example 46 with JSONObject

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

the class AssignGroupToResources method prepareJSONObject.

/**
	 * Prepares a JSON object
	 *
	 * @return JSONObject the whole query
	 */
private JSONObject prepareJSONObject() {
    JSONObject jsonQuery = new JSONObject();
    JSONArray array = new JSONArray();
    for (int i = 0; i < resources.size(); i++) {
        array.set(i, new JSONNumber(resources.get(i).getId()));
    }
    jsonQuery.put("resources", array);
    jsonQuery.put("group", new JSONNumber(group.getId()));
    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)

Example 47 with JSONObject

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

the class GetUsers method retrieveData.

/**
	 * Retrieves data from RPC
	 */
public void retrieveData() {
    // empty
    if (this.attributesToSearchBy.size() == 0) {
        session.getUiElements().setLogText("No keywords.");
        return;
    }
    // ok, start
    loaderImage.loadingStart();
    // build request
    JSONObject attributesWithSearchingValues = new JSONObject();
    for (Map.Entry<String, String> entry : attributesToSearchBy.entrySet()) {
        String name = entry.getKey();
        String value = entry.getValue();
        attributesWithSearchingValues.put(name, new JSONString(value));
    }
    JSONObject req = new JSONObject();
    req.put("attributesWithSearchingValues", attributesWithSearchingValues);
    // send request
    JsonPostClient js = new JsonPostClient(new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Error while loading users.");
            loaderImage.loadingError(error);
            events.onError(error);
        }

        public void onLoadingStart() {
            loaderImage.loadingStart();
            session.getUiElements().setLogText("Loading users started.");
            events.onLoadingStart();
        }

        public void onFinished(JavaScriptObject jso) {
            loaderImage.loadingFinished();
            setList(JsonUtils.<User>jsoAsList(jso));
            sortTable();
            session.getUiElements().setLogText("Users loaded: " + list.size());
            events.onFinished(jso);
        }
    });
    js.sendData(JSON_URL, req);
    return;
}
Also used : User(cz.metacentrum.perun.webgui.model.User) JSONObject(com.google.gwt.json.client.JSONObject) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) JSONString(com.google.gwt.json.client.JSONString) PerunError(cz.metacentrum.perun.webgui.model.PerunError) HashMap(java.util.HashMap) Map(java.util.Map) JSONString(com.google.gwt.json.client.JSONString)

Example 48 with JSONObject

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

the class RemoveGroupsFromResource method prepareJSONObject.

/**
	 * Prepares a JSON object
	 *
	 * @return JSONObject the whole query
	 */
private JSONObject prepareJSONObject() {
    JSONObject jsonQuery = new JSONObject();
    JSONArray array = new JSONArray();
    for (int i = 0; i < groups.size(); i++) {
        array.set(i, new JSONNumber(groups.get(i).getId()));
    }
    jsonQuery.put("groups", array);
    jsonQuery.put("resource", new JSONNumber(resource.getId()));
    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)

Example 49 with JSONObject

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

the class CreatePassword method validateCallJSON.

/**
	 * Prepares a JSON object for validation request.
	 *
	 * @return JSONObject the whole query
	 */
private JSONObject validateCallJSON() {
    JSONObject jsonQuery = new JSONObject();
    jsonQuery.put("user", new JSONNumber(userId));
    jsonQuery.put("namespace", new JSONString(namespace));
    jsonQuery.put("login", new JSONString(login));
    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 50 with JSONObject

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

the class FindUsersByIdsNotInRpc method retrieveData.

/**
	 * Retrieves data from RPC
	 */
public void retrieveData() {
    String[] ids = searchString.split(",");
    if (ids.length == 0) {
        return;
    }
    idsCount = ids.length;
    onLoadingStart();
    for (String id : ids) {
        // trims the whitespace
        id = id.trim();
        try {
            int idint = Integer.parseInt(id);
            GetEntityById req = new GetEntityById(PerunEntity.USER, idint, new JsonCallbackEvents() {

                public void onFinished(JavaScriptObject jso) {
                    idsFound++;
                    // add to result
                    int i = result.size();
                    result.set(i, new JSONObject(jso));
                    isFinished();
                }

                public void onError(PerunError err) {
                    idsFound++;
                    isFinished();
                }
            });
            req.retrieveData();
        } catch (Exception e) {
        }
    }
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) JSONObject(com.google.gwt.json.client.JSONObject) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) GetEntityById(cz.metacentrum.perun.webgui.json.GetEntityById) PerunError(cz.metacentrum.perun.webgui.model.PerunError)

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