Search in sources :

Example 6 with JsonPostClient

use of cz.metacentrum.perun.webgui.json.JsonPostClient in project perun by CESNET.

the class DeleteExecService method deleteExecService.

/**
	 * Deletes Exec Service from DB
	 *
	 * @param serviceId id of exec service to be deleted
	 */
public void deleteExecService(final int serviceId) {
    this.execServiceId = serviceId;
    // test arguments
    if (!this.testArguments()) {
        return;
    }
    // whole JSON query
    JSONObject jsonQuery = new JSONObject();
    jsonQuery.put("execService", new JSONNumber(serviceId));
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Deleting of ExecService: " + execServiceId + " failed.");
            events.onError(error);
        }

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("ExecService: " + execServiceId + " deleted successfully.");
            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 7 with JsonPostClient

use of cz.metacentrum.perun.webgui.json.JsonPostClient in project perun by CESNET.

the class FreeDenialOfExecServiceOnFacility method freeDenialOfExecService.

/**
	 * Attempts to free denial of selected exec service on facility
	 *
	 * @param execServiceId
	 */
public void freeDenialOfExecService(final int execServiceId) {
    this.execServiceId = execServiceId;
    // test arguments
    if (!this.testCreating()) {
        return;
    }
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

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

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Exec service " + execServiceId + " allowed on facility.");
            events.onFinished(jso);
        }

        ;

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

        ;
    };
    // sending data
    JsonPostClient jspc = new JsonPostClient(newEvents);
    jspc.sendData(JSON_URL, prepareJSONObject());
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) JsonPostClient(cz.metacentrum.perun.webgui.json.JsonPostClient) PerunError(cz.metacentrum.perun.webgui.model.PerunError)

Example 8 with JsonPostClient

use of cz.metacentrum.perun.webgui.json.JsonPostClient in project perun by CESNET.

the class RemoveDependency method removeDependency.

/**
	 * Remove dependency for exec service on another exec service
	 *
	 * @param execService remove dependency for
	 * @param dependsOn remove dependency on
	 */
public void removeDependency(int execService, 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("Removing dependancy failed.");
            events.onError(error);
        }

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Dependancy sucesfully removed!");
            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 9 with JsonPostClient

use of cz.metacentrum.perun.webgui.json.JsonPostClient in project perun by CESNET.

the class AddGroupUnion method createGroupUnion.

public void createGroupUnion(final Group result, final Group operand) {
    // whole JSON query
    JSONObject jsonQuery = new JSONObject();
    jsonQuery.put("resultGroup", new JSONNumber(result.getId()));
    jsonQuery.put("operandGroup", new JSONNumber(operand.getId()));
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Creating group union with result group " + result.getId() + " and operand group " + operand.getId() + " failed.");
            events.onError(error);
        }

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Group union with result group " + result.getId() + " and operand group " + operand.getId() + " successfully created!");
            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 10 with JsonPostClient

use of cz.metacentrum.perun.webgui.json.JsonPostClient in project perun by CESNET.

the class AddMember method addMemberToGroup.

/**
	 * Attempts to add member to group
	 *
	 * @param group  group
	 * @param member member to be member of group
	 */
public void addMemberToGroup(final Group group, final RichMember member) {
    String errorMsg = "";
    if (((group != null) ? group.getId() : 0) == 0) {
        errorMsg += "Wrong parameter <strong>Group</strong>.</br>";
    }
    if (((member != null) ? member.getId() : 0) == 0) {
        errorMsg += "Wrong parameter <strong>Member</strong>.";
    }
    if (errorMsg.length() > 0) {
        UiElements.generateAlert("Parameter error", errorMsg);
    }
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        @Override
        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Adding member: " + member.getUser().getFullName() + " to group: " + group.getShortName() + " failed.");
            handleCommonExceptions(error, member, group);
            events.onError(error);
        }

        @Override
        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Member: " + member.getUser().getFullName() + " added to group: " + group.getShortName());
            events.onFinished(jso);
        }

        @Override
        public void onLoadingStart() {
            events.onLoadingStart();
        }
    };
    // sending data
    JsonPostClient jspc = new JsonPostClient(newEvents);
    // to allow own error handling for attributes errors.
    jspc.setHidden(true);
    // put data
    jspc.put("group", new JSONNumber(group.getId()));
    jspc.put("member", new JSONNumber(member.getId()));
    jspc.sendData(JSON_URL);
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) JsonPostClient(cz.metacentrum.perun.webgui.json.JsonPostClient) JSONNumber(com.google.gwt.json.client.JSONNumber)

Aggregations

JsonPostClient (cz.metacentrum.perun.webgui.json.JsonPostClient)150 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)149 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)149 PerunError (cz.metacentrum.perun.webgui.model.PerunError)126 JSONObject (com.google.gwt.json.client.JSONObject)50 JSONNumber (com.google.gwt.json.client.JSONNumber)18 JSONString (com.google.gwt.json.client.JSONString)6 HTML (com.google.gwt.user.client.ui.HTML)3 Publication (cz.metacentrum.perun.webgui.model.Publication)3 Confirm (cz.metacentrum.perun.webgui.widgets.Confirm)3 Group (cz.metacentrum.perun.webgui.model.Group)2 User (cz.metacentrum.perun.webgui.model.User)2 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1 JSONArray (com.google.gwt.json.client.JSONArray)1 FlexTable (com.google.gwt.user.client.ui.FlexTable)1 Image (com.google.gwt.user.client.ui.Image)1 Facility (cz.metacentrum.perun.webgui.model.Facility)1 Identity (cz.metacentrum.perun.webgui.model.Identity)1 Member (cz.metacentrum.perun.webgui.model.Member)1