use of cz.metacentrum.perun.webgui.model.PerunError in project perun by CESNET.
the class RemoveAttributes method removeAttributes.
/**
* Attempts to remove some attributes from entity
*
* @param ids defines which type of attribute will be removed (member, user, member_resource, etc.)
* @param attributes list of attributes to remove
*/
public void removeAttributes(final Map<String, Integer> ids, final ArrayList<Attribute> attributes) {
this.ids = ids;
this.attributes = attributes;
// test arguments
if (!this.testRemoving()) {
return;
}
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Removing attributes failed.");
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Attributes successfully removed !");
events.onFinished(jso);
}
;
public void onLoadingStart() {
events.onLoadingStart();
}
;
};
// sending data
JsonPostClient jspc = new JsonPostClient(newEvents);
jspc.sendData(JSON_URL, prepareJSONObject());
}
use of cz.metacentrum.perun.webgui.model.PerunError in project perun by CESNET.
the class SetAttribute method setAttribute.
/**
* Attempts to set new value for some attribute
*
* @param ids defines which type of attribute will be set (member, user, member_resource, etc.)
* @param attribute attribute object with a new value
*/
public void setAttribute(final Map<String, Integer> ids, final Attribute attribute) {
this.ids = ids;
this.attribute = attribute;
// test arguments
if (!this.testSetting()) {
return;
}
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Setting new value for attribute: " + attribute.getId() + " failed.");
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("New value for attribute: " + attribute.getId() + " successfully updated in DB !");
events.onFinished(jso);
}
;
public void onLoadingStart() {
events.onLoadingStart();
}
;
};
// sending data
JsonPostClient jspc = new JsonPostClient(newEvents);
jspc.sendData(JSON_URL, prepareJSONObject());
}
use of cz.metacentrum.perun.webgui.model.PerunError in project perun by CESNET.
the class CreateAuthorship method createAuthorship.
/**
* Attempts to create a new Authorship, it first tests the values and then submits them.
*
* @param pubId ID of publication
* @param userId ID of user
*/
public void createAuthorship(final int pubId, final int userId) {
this.userId = userId;
this.pubId = pubId;
// 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("Adding Author: " + userId + " for publication: " + pubId + " failed.");
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Author: " + userId + " successfully added for publication: " + pubId);
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 CreateCategory method createCategory.
/**
* Attempts to create a new Category, it first tests the values and then submits them.
*
* @param name Category name
* @param rank Category ranking
*/
public void createCategory(final String name, double rank) {
this.name = name;
this.rank = rank;
// 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 category " + name + " failed.");
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Category " + name + " created.");
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 HandleApplication method verifyApplication.
/**
* Verify application
*
* @param appId
*/
public void verifyApplication(int appId) {
this.appId = appId;
// test arguments
if (!this.testApplication()) {
return;
}
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
@Override
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Verifying application failed.");
events.onError(error);
}
;
@Override
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Application verified.");
events.onFinished(jso);
}
;
@Override
public void onLoadingStart() {
events.onLoadingStart();
}
;
};
// sending data
JsonPostClient jspc = new JsonPostClient(newEvents);
jspc.sendData(JSON_URL_VERIFY, prepareJSONObject());
}
Aggregations