Search in sources :

Example 86 with JSONNumber

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

the class CreateGroup method createGroupInVo.

/**
	 * Create a new group in a VO
	 * @param voId VO ID
	 * @param name Group name
	 * @param description Group description
	 */
public void createGroupInVo(int voId, final String name, String description) {
    this.groupName = name;
    this.groupDescription = description;
    // test arguments
    if (!this.testCreating()) {
        return;
    }
    // GROUP OBJECT
    JSONObject group = new JSONObject();
    group.put("name", new JSONString(name));
    group.put("description", new JSONString(description));
    // whole JSON query
    JSONObject jsonQuery = new JSONObject();
    jsonQuery.put("vo", new JSONNumber(voId));
    jsonQuery.put("group", group);
    this.createGroup(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 87 with JSONNumber

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

the class CreateGroup method createGroupInGroup.

/**
	 * Creates a new subgroup in group
	 * @param groupId Parent group id
	 * @param name New group name
	 * @param description New group description
	 */
public void createGroupInGroup(final int groupId, final String name, String description) {
    this.groupName = name;
    this.groupDescription = description;
    // test arguments
    if (!this.testCreating()) {
        return;
    }
    // GROUP OBJECT
    JSONObject group = new JSONObject();
    group.put("name", new JSONString(name));
    group.put("description", new JSONString(description));
    // whole JSON query
    JSONObject jsonQuery = new JSONObject();
    jsonQuery.put("parentGroup", new JSONNumber(groupId));
    jsonQuery.put("group", group);
    this.createGroup(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 88 with JSONNumber

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

the class DeleteGroups method deleteGroups.

/**
	 * Delete (sub)groups of any group or VO.
	 *
	 * @param groups groups to be deleted
	 * @param force TRUE = forced delete (remove all members, remove from resources) / FALSE = not delete if group has members
	 */
public void deleteGroups(final ArrayList<? extends Group> groups, boolean force) {
    // whole JSON query
    JSONObject jsonQuery = new JSONObject();
    JSONArray grps = new JSONArray();
    for (int i = 0; i < groups.size(); i++) {
        grps.set(i, new JSONNumber(groups.get(i).getId()));
    }
    jsonQuery.put("groups", grps);
    jsonQuery.put("forceDelete", new JSONNumber((force) ? 1 : 0));
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

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

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Groups successfully deleted!");
            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) JSONObject(com.google.gwt.json.client.JSONObject) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) JsonPostClient(cz.metacentrum.perun.webgui.json.JsonPostClient) JSONArray(com.google.gwt.json.client.JSONArray) JSONNumber(com.google.gwt.json.client.JSONNumber) PerunError(cz.metacentrum.perun.webgui.model.PerunError)

Example 89 with JSONNumber

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

the class ForceServicePropagation method forcePropagation.

/**
	 * Starts Force service propagation for specified service and facility
	 *
	 * @param facilityId ID of facility to propagate service to
	 * @param serviceId ID of service to be propagated
	 */
public void forcePropagation(final int facilityId, final int serviceId) {
    this.facilityId = facilityId;
    this.serviceId = serviceId;
    // test arguments
    if (!this.testArguments()) {
        return;
    }
    // whole JSON query
    JSONObject jsonQuery = new JSONObject();
    jsonQuery.put("facility", new JSONNumber(facilityId));
    jsonQuery.put("service", new JSONNumber(serviceId));
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Propagation initialization of service: " + serviceId + " failed.");
            events.onError(error);
        }

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Propagation of service: " + serviceId + " initiated.");
            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) 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 90 with JSONNumber

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

the class FreeDenialOfExecServiceOnFacility method prepareJSONObject.

/**
	 * Prepares a JSON object
	 *
	 * @return JSONObject the whole query
	 */
private JSONObject prepareJSONObject() {
    JSONObject jsonQuery = new JSONObject();
    jsonQuery.put("facility", new JSONNumber(facilityId));
    jsonQuery.put("execService", new JSONNumber(execServiceId));
    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