Search in sources :

Example 91 with JSONNumber

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

the class InsertExecService method addExecService.

/**
	 * Creates exec service in DB and associate it with service
	 *
	 * @param service service to associate with
	 * @param type type of exec service (SEND, GENERATE)
	 * @param enabled true if exec service is enabled
	 * @param delayNum default delay
	 * @param scriptPath path to propagation scripts
	 */
public void addExecService(Service service, String type, Boolean enabled, int delayNum, String scriptPath) {
    // TODO - test input
    // test arguments
    // if(!this.testArguments()){
    //	return;
    //}
    // reconstruct service
    JSONObject serv = new JSONObject();
    serv.put("id", new JSONNumber(service.getId()));
    serv.put("name", new JSONString(service.getName()));
    // reconstruct exec service
    JSONObject exec = new JSONObject();
    exec.put("execServiceType", new JSONString(type));
    exec.put("enabled", JSONBoolean.getInstance(enabled));
    exec.put("defaultDelay", new JSONNumber(delayNum));
    // insert service into exec service
    exec.put("service", serv);
    exec.put("script", new JSONString(scriptPath));
    // whole JSON query
    JSONObject jsonQuery = new JSONObject();
    jsonQuery.put("execService", exec);
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Adding of exec service failed.");
            events.onError(error);
        }

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Exec service successfully added!");
            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) JSONString(com.google.gwt.json.client.JSONString)

Example 92 with JSONNumber

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

the class RemoveHosts method prepareJSONObject.

/**
	 * Prepares a JSON object
	 *
	 * @return JSONObject the whole query
	 */
private JSONObject prepareJSONObject() {
    JSONNumber cluster = new JSONNumber(clusterId);
    JSONNumber host = new JSONNumber(hostId);
    JSONArray ids = new JSONArray();
    ids.set(0, host);
    // whole JSON query
    JSONObject jsonQuery = new JSONObject();
    jsonQuery.put("facility", cluster);
    jsonQuery.put("hosts", ids);
    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 93 with JSONNumber

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

the class CreateDependency method createDependancy.

/**
	 * Add dependency for exec service on another exec service
	 *
	 * @param execService add dependency for
	 * @param dependsOn add dependency on
	 */
public void createDependancy(final int execService, final int dependsOn) {
    this.execService = execService;
    this.dependsOn = dependsOn;
    if (!this.testArguments()) {
        return;
    }
    JSONObject jsonQuery = new JSONObject();
    jsonQuery.put("execService", new JSONNumber(execService));
    jsonQuery.put("dependantExecService", new JSONNumber(dependsOn));
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

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

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Dependency successfully added!");
            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 94 with JSONNumber

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

the class AddHosts method prepareJSONObject.

/**
	 * Prepares a JSON object
	 *
	 * @return JSONObject the whole query
	 */
private JSONObject prepareJSONObject() {
    JSONNumber facility = new JSONNumber(facilityId);
    JSONArray hostnames = new JSONArray();
    // put names in array
    for (int i = 0; i < hostNames.length; i++) {
        // empty host names are excluded
        if (hostNames[i] == "")
            continue;
        hostnames.set(i, new JSONString(hostNames[i]));
    }
    // whole JSON query
    JSONObject jsonQuery = new JSONObject();
    jsonQuery.put("facility", facility);
    jsonQuery.put("hostnames", hostnames);
    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)

Example 95 with JSONNumber

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

the class AddOwner method prepareJSONObject.

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