use of cz.metacentrum.perun.webgui.json.JsonCallbackEvents in project perun by CESNET.
the class CreateMember method createMember.
/**
* Attempts to create member in VO from candidate
*
* @param voId vo where member should be created
* @param group where member should be created
* @param candidate candidate to be member
*/
public void createMember(final int voId, Group group, final Candidate candidate) {
this.voId = voId;
this.group = group;
this.candidate = candidate;
// test arguments
if (!this.testAdding()) {
return;
}
if (!session.isVoAdmin(voId)) {
// GROUP ADMIN HAVE OWN PROCESSING
createMemberAsGroupAdmin(voId, group, candidate);
return;
}
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Creating member: " + candidate.getDisplayName() + " failed.");
events.onError(error);
}
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Member " + candidate.getDisplayName() + " created !");
// call validation asynchronously
Member mem = jso.cast();
ValidateMemberAsync request = new ValidateMemberAsync();
request.validateMemberAsync(mem);
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.json.JsonCallbackEvents in project perun by CESNET.
the class DeleteMember method deleteMember.
/**
* Attempts to delete member in VO
*
* @param memberId ID of member which should be deleted
*/
public void deleteMember(final int memberId) {
this.memberId = memberId;
// test arguments
if (!this.testAdding()) {
return;
}
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Deleting member: " + memberId + " failed.");
events.onError(error);
}
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Member: " + memberId + " deleted!");
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.json.JsonCallbackEvents in project perun by CESNET.
the class CreateOwner method createOwner.
/**
* Attempts to create owner, it first tests the values and then submits them.
*
* @param ownerName name of future owner
* @param ownerContact owners contact (mail, phone, vo etc.)
* @param ownerType type of owner (administrative, technical)
*/
public void createOwner(final String ownerName, final String ownerContact, final String ownerType) {
this.ownerName = ownerName;
this.ownerContact = ownerContact;
this.ownerType = ownerType;
// test arguments
if (!this.testCreating()) {
return;
}
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Creating owner: " + ownerName + " failed.");
events.onError(error);
}
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Owner " + ownerName + " created.");
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.json.JsonCallbackEvents 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.json.JsonCallbackEvents 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);
}
Aggregations