use of cz.metacentrum.perun.webgui.json.JsonCallbackEvents in project perun by CESNET.
the class GetResources method retrieveData.
/**
* Retrieves data from RPC
*/
public void retrieveData() {
// empty
if (this.attributesToSearchBy.size() == 0) {
session.getUiElements().setLogText("No keywords.");
return;
}
// ok, start
loaderImage.loadingStart();
// build request
JSONObject attributesWithSearchingValues = new JSONObject();
for (Map.Entry<String, String> entry : attributesToSearchBy.entrySet()) {
String name = entry.getKey();
String value = entry.getValue();
attributesWithSearchingValues.put(name, new JSONString(value));
}
JSONObject req = new JSONObject();
req.put("attributesWithSearchingValues", attributesWithSearchingValues);
// send request
JsonPostClient js = new JsonPostClient(new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Error while loading resources.");
loaderImage.loadingError(error);
events.onError(error);
}
public void onLoadingStart() {
loaderImage.loadingStart();
session.getUiElements().setLogText("Loading resources started.");
events.onLoadingStart();
}
public void onFinished(JavaScriptObject jso) {
loaderImage.loadingFinished();
setList(JsonUtils.<Resource>jsoAsList(jso));
sortTable();
session.getUiElements().setLogText("Resources loaded: " + list.size());
events.onFinished(jso);
}
});
js.sendData(JSON_URL, req);
return;
}
use of cz.metacentrum.perun.webgui.json.JsonCallbackEvents in project perun by CESNET.
the class DeleteSecurityTeam method deleteSecurityTeam.
/**
* Attempts to delete Security Team, it first tests the values and then submits them.
*
* @param securityTeamId ID of SecurityTeam to be deleted
* @param force true for force delete
*/
public void deleteSecurityTeam(final int securityTeamId, final boolean force) {
this.securityTeamId = securityTeamId;
this.force = force;
// test arguments
if (!this.testDeleting()) {
return;
}
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Deleting Security Team: " + securityTeamId + " failed.");
events.onError(error);
}
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Security Team " + securityTeamId + " 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 AssignServices method assignService.
/**
* Attempts to assign Services to Resource
*
* @param resourceId ID of resource where should be assigned
* @param services IDs of services to assign
*/
public void assignService(final int resourceId, final ArrayList<Service> services) {
this.resourceId = resourceId;
for (int i = 0; i < services.size(); i++) {
serviceIds[i] = services.get(i).getId();
}
// test arguments
if (!this.testAssigning()) {
return;
}
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Assigning services to resource: " + resourceId + " failed.");
events.onError(error);
}
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Services successfully assigned to resource: " + resourceId);
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 AssignServices method assignService.
/**
* Attempts to assign service to resource
*
* @param serviceId ID of service which should be assigned
* @param resourceId ID of resource where should be assigned
*/
public void assignService(final int serviceId, final int resourceId) {
this.resourceId = resourceId;
this.serviceIds[0] = serviceId;
// test arguments
if (!this.testAssigning()) {
return;
}
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Assigning service: " + serviceId + " to resource: " + resourceId + " failed.");
events.onError(error);
}
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Service: " + serviceId + " successfully assigned to resource: " + resourceId);
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 AssignResourceTag method assignResourceTag.
/**
* Attempts to assign resource tag to Resource, it first tests the values and then submits them
*
* @param tag ResourceTag to assign
*/
public void assignResourceTag(ResourceTag tag) {
this.resourceTag = tag;
// test arguments
if (!this.testAdding()) {
return;
}
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Assigning tag to resource failed.");
events.onError(error);
}
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Tag assigned to resource.");
events.onFinished(jso);
}
public void onLoadingStart() {
events.onLoadingStart();
}
};
// sending data
JsonPostClient jspc = new JsonPostClient(newEvents);
jspc.sendData(JSON_URL, prepareJSONObject());
}
Aggregations