Search in sources :

Example 96 with JsonPostClient

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

the class RemoveAdmin method removeFacilityAdminGroup.

/**
	 * Attempts to remove admin group from Facility, it first tests the values and then submits them.
	 *
	 * @param facility where we want to remove admin from
	 * @param group Group to be removed from admins
	 */
public void removeFacilityAdminGroup(final Facility facility, final Group group) {
    // store group id to user id to used unified check method
    this.userId = (group != null) ? group.getId() : 0;
    this.entityId = (facility != null) ? facility.getId() : 0;
    this.entity = PerunEntity.FACILITY;
    // test arguments
    if (!this.testRemoving()) {
        return;
    }
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Removing group " + group.getShortName() + " from managers failed.");
            // custom events
            events.onError(error);
        }

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Group " + group.getShortName() + " removed from managers of " + facility.getName());
            events.onFinished(jso);
        }

        ;

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

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

Example 97 with JsonPostClient

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

the class SetAttributeRights method setAttributeRights.

/**
	 * Attempts to set new value for some attributes
	 *
	 * @param rights List of attribute rights to set
	 */
public void setAttributeRights(final ArrayList<AttributeRights> rights) {
    this.rights = rights;
    // test arguments
    if (!this.testSetting()) {
        return;
    }
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Setting attribute rights failed.");
            events.onError(error);
        }

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Attribute rights are successfully updated.");
            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 98 with JsonPostClient

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

the class SetAttributes method setAttributes.

/**
	 * Attempts to set new value for some attributes
	 *
	 * @param ids defines which type of attribute will be set (member, user, member_resource, etc.)
	 * @param attributes list of attributes with a new value
	 */
public void setAttributes(final Map<String, Integer> ids, final ArrayList<Attribute> attributes) {
    this.ids = ids;
    this.attributes = attributes;
    // test arguments
    if (!this.testSetting()) {
        return;
    }
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Setting new values for attributes failed.");
            events.onError(error);
        }

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("New values for attributes successfully updated in DB !");
            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 99 with JsonPostClient

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

the class UpdateAttribute method updateAttribute.

/**
	 * Update attribute definition in DB (only description)
	 *
	 * @param a attribute definition to update to
	 */
public void updateAttribute(AttributeDefinition a) {
    this.attributeDefinition = a;
    // test arguments
    if (!this.testUpdating()) {
        return;
    }
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Updating attribute definition: " + attributeDefinition.getDisplayName() + " failed.");
            events.onError(error);
        }

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Attribute definition: " + attributeDefinition.getDisplayName() + " successfully updated.");
            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 100 with JsonPostClient

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

the class CreatePublication method createPublication.

/**
	 * Attempts to create a new Publication from EXTERNAL SOURCE, it first tests the values and then submits them.
	 *
	 * @param publication Publication
	 */
public void createPublication(final Publication publication) {
    this.publication = publication;
    // test arguments
    if (!this.testCreating()) {
        return;
    }
    // json object
    JSONObject jsonQuery = prepareJSONObject();
    // local events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Creating publicaton ext.ID: " + publication.getExternalId() + " failed.");
            events.onError(error);
        }

        ;

        public void onFinished(JavaScriptObject jso) {
            Publication pub = jso.cast();
            session.getUiElements().setLogSuccessText("Publication with ID: " + pub.getId() + " created.");
            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) Publication(cz.metacentrum.perun.webgui.model.Publication) PerunError(cz.metacentrum.perun.webgui.model.PerunError)

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