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);
}
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());
}
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);
}
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);
}
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);
}
Aggregations