use of cz.metacentrum.perun.webgui.model.PerunError in project perun by CESNET.
the class UpdatePublication method updatePublication.
/**
* Attempts to update a Publication, it first tests the values and then submits them.
*
* @param publication Publication
*/
public void updatePublication(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("Updating publication: " + publication.getId() + " failed.");
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
Publication pub = jso.cast();
session.getUiElements().setLogSuccessText("Publication with ID: " + pub.getId() + " updated.");
events.onFinished(jso);
}
;
public void onLoadingStart() {
events.onLoadingStart();
}
;
};
// create request
JsonPostClient request = new JsonPostClient(newEvents);
request.sendData(JSON_URL, jsonQuery);
}
use of cz.metacentrum.perun.webgui.model.PerunError in project perun by CESNET.
the class DeleteAuthorship method deleteAuthorship.
/**
* Attempts to delete Authorship, it first tests the values and then submits them.
*
* @param publicationId
* @param userId
*/
public void deleteAuthorship(final int publicationId, final int userId) {
this.publicationId = publicationId;
this.userId = userId;
// test arguments
if (!this.testDeleting()) {
return;
}
// json object
JSONObject jsonQuery = prepareJSONObject();
// local events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Removing author " + userId + " from publication: " + publicationId + " failed.");
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Author " + userId + " removed from publication: " + publicationId);
events.onFinished(jso);
}
;
public void onLoadingStart() {
events.onLoadingStart();
}
;
};
// create request
JsonPostClient request = new JsonPostClient(newEvents);
request.sendData(JSON_URL, jsonQuery);
}
use of cz.metacentrum.perun.webgui.model.PerunError in project perun by CESNET.
the class DeleteCategory method deleteCategory.
/**
* Attempts to delete a Category, it first tests the values and then submits them.
*
* @param categoryId ID of category to be deleted
*/
public void deleteCategory(final int categoryId) {
this.categoryId = categoryId;
// test arguments
if (!this.testDeleting()) {
return;
}
// json object
JSONObject jsonQuery = prepareJSONObject();
// local events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Deleting category " + categoryId + " failed.");
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Category " + categoryId + " deleted.");
events.onFinished(jso);
}
;
public void onLoadingStart() {
events.onLoadingStart();
}
;
};
// create request
JsonPostClient request = new JsonPostClient(newEvents);
request.sendData(JSON_URL, jsonQuery);
}
use of cz.metacentrum.perun.webgui.model.PerunError 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);
}
use of cz.metacentrum.perun.webgui.model.PerunError in project perun by CESNET.
the class RemoveExtSource method removeVoExtSource.
/**
* Attempts to remove external source from VO
*
* @param voId ID of VO, where we should remove ext source
* @param extSourceId ID of external source to be removed
*/
public void removeVoExtSource(final int voId, final int extSourceId) {
this.voId = voId;
this.extSourceId = extSourceId;
// test arguments
if (!this.testRemoving()) {
return;
}
// json object
JSONObject jsonQuery = prepareJSONObject();
// local events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Removing external source: " + extSourceId + " from VO: " + voId + " failed.");
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("External source: " + extSourceId + " successfully removed from VO: " + voId);
events.onFinished(jso);
}
;
public void onLoadingStart() {
events.onLoadingStart();
}
;
};
// create request
JsonPostClient request = new JsonPostClient(newEvents);
request.sendData(JSON_URL, jsonQuery);
}
Aggregations