Search in sources :

Example 51 with JSONNumber

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

the class DeleteThanks method prepareJSONObject.

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

Example 52 with JSONNumber

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

the class AddAdmin method prepareJSONObjectForGroup.

/**
	 * Prepares a JSON object
	 *
	 * @return JSONObject the whole query
	 */
private JSONObject prepareJSONObjectForGroup() {
    JSONObject jsonQuery = new JSONObject();
    if (entity.equals(PerunEntity.VIRTUAL_ORGANIZATION)) {
        jsonQuery.put("vo", new JSONNumber(entityId));
    } else if (entity.equals(PerunEntity.GROUP)) {
        jsonQuery.put("group", new JSONNumber(entityId));
    } else if (entity.equals(PerunEntity.FACILITY)) {
        jsonQuery.put("facility", new JSONNumber(entityId));
    } else if (entity.equals(PerunEntity.SECURITY_TEAM)) {
        jsonQuery.put("securityTeam", new JSONNumber(entityId));
    }
    jsonQuery.put("authorizedGroup", new JSONNumber(userId));
    return jsonQuery;
}
Also used : JSONObject(com.google.gwt.json.client.JSONObject) JSONNumber(com.google.gwt.json.client.JSONNumber)

Example 53 with JSONNumber

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

the class AddExtSource method addGroupExtSource.

/**
	 * Attempts to add external source to Group in DB - make RPC call
	 *
	 * @param groupId ID of Group, where should be ext source added
	 * @param extSourceId ID of external source to be added
	 */
public void addGroupExtSource(final int groupId, final int extSourceId) {
    this.extSourceId = extSourceId;
    // create whole JSON query
    JSONObject jsonQuery = new JSONObject();
    jsonQuery.put("source", new JSONNumber(extSourceId));
    jsonQuery.put("group", new JSONNumber(groupId));
    // local events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Adding external source: " + extSourceId + " to group: " + groupId + " failed.");
            events.onError(error);
        }

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("External source: " + extSourceId + " successfully added to group: " + groupId);
            events.onFinished(jso);
        }

        ;

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

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

Example 54 with JSONNumber

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

the class SetAttributes method prepareJSONObject.

/**
	 * Prepares a JSON object.
	 * @return JSONObject the whole query
	 */
private JSONObject prepareJSONObject() {
    // create whole JSON query
    JSONObject jsonQuery = new JSONObject();
    // create attrs field
    JSONArray array = new JSONArray();
    // create attributes
    for (int i = 0; i < attributes.size(); i++) {
        // skip attribute with empty or null value
        if (attributes.get(i).getValue() == null || attributes.get(i).getValue().equalsIgnoreCase("")) {
            continue;
        }
        // create Json object from attribute
        JSONObject attr = new JSONObject(attributes.get(i));
        // get only interested in properties
        JSONValue id = attr.get("id");
        JSONValue friendlyName = attr.get("friendlyName");
        JSONValue namespace = attr.get("namespace");
        JSONValue type = attr.get("type");
        JSONValue description = attr.get("description");
        JSONValue value = attr.get("value");
        JSONValue displayName = attr.get("displayName");
        // create new Attribute jsonObject
        JSONObject newAttr = new JSONObject();
        newAttr.put("value", value);
        newAttr.put("id", id);
        newAttr.put("type", type);
        newAttr.put("description", description);
        newAttr.put("namespace", namespace);
        newAttr.put("friendlyName", friendlyName);
        newAttr.put("displayName", displayName);
        // put attribute into array
        array.set(array.size(), newAttr);
    }
    for (Map.Entry<String, Integer> attrIds : this.ids.entrySet()) {
        jsonQuery.put(attrIds.getKey(), new JSONNumber(attrIds.getValue()));
    }
    jsonQuery.put("attributes", array);
    return jsonQuery;
}
Also used : JSONValue(com.google.gwt.json.client.JSONValue) JSONObject(com.google.gwt.json.client.JSONObject) JSONArray(com.google.gwt.json.client.JSONArray) JSONNumber(com.google.gwt.json.client.JSONNumber) HashMap(java.util.HashMap) Map(java.util.Map)

Example 55 with JSONNumber

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

the class RemoveAdmin method prepareJSONObjectForGroup.

/**
	 * Prepares a JSON object
	 *
	 * @return JSONObject the whole query
	 */
private JSONObject prepareJSONObjectForGroup() {
    // whole JSON query
    JSONObject jsonQuery = new JSONObject();
    if (entity.equals(PerunEntity.VIRTUAL_ORGANIZATION)) {
        jsonQuery.put("vo", new JSONNumber(entityId));
    } else if (entity.equals(PerunEntity.GROUP)) {
        jsonQuery.put("group", new JSONNumber(entityId));
    } else if (entity.equals(PerunEntity.FACILITY)) {
        jsonQuery.put("facility", new JSONNumber(entityId));
    } else if (entity.equals(PerunEntity.SECURITY_TEAM)) {
        jsonQuery.put("securityTeam", new JSONNumber(entityId));
    }
    jsonQuery.put("authorizedGroup", new JSONNumber(userId));
    return jsonQuery;
}
Also used : JSONObject(com.google.gwt.json.client.JSONObject) JSONNumber(com.google.gwt.json.client.JSONNumber)

Aggregations

JSONNumber (com.google.gwt.json.client.JSONNumber)164 JSONObject (com.google.gwt.json.client.JSONObject)109 JSONString (com.google.gwt.json.client.JSONString)72 JSONArray (com.google.gwt.json.client.JSONArray)69 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)19 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)18 JsonPostClient (cz.metacentrum.perun.webgui.json.JsonPostClient)18 PerunError (cz.metacentrum.perun.webgui.model.PerunError)17 HashMap (java.util.HashMap)4 Map (java.util.Map)4 JSONValue (com.google.gwt.json.client.JSONValue)3 ArrayList (java.util.ArrayList)3 Token (org.rstudio.core.client.Invalidation.Token)3 ServerError (org.rstudio.studio.client.server.ServerError)3 Breakpoint (org.rstudio.studio.client.common.debugging.model.Breakpoint)2 DiffResult (org.rstudio.studio.client.common.vcs.DiffResult)2 StatusAndPath (org.rstudio.studio.client.common.vcs.StatusAndPath)2 Point (org.rstudio.studio.client.workbench.views.plots.model.Point)2 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1