use of com.google.gwt.json.client.JSONNumber in project perun by CESNET.
the class InsertExecService method addExecService.
/**
* Creates exec service in DB and associate it with service
*
* @param service service to associate with
* @param type type of exec service (SEND, GENERATE)
* @param enabled true if exec service is enabled
* @param delayNum default delay
* @param scriptPath path to propagation scripts
*/
public void addExecService(Service service, String type, Boolean enabled, int delayNum, String scriptPath) {
// TODO - test input
// test arguments
// if(!this.testArguments()){
// return;
//}
// reconstruct service
JSONObject serv = new JSONObject();
serv.put("id", new JSONNumber(service.getId()));
serv.put("name", new JSONString(service.getName()));
// reconstruct exec service
JSONObject exec = new JSONObject();
exec.put("execServiceType", new JSONString(type));
exec.put("enabled", JSONBoolean.getInstance(enabled));
exec.put("defaultDelay", new JSONNumber(delayNum));
// insert service into exec service
exec.put("service", serv);
exec.put("script", new JSONString(scriptPath));
// whole JSON query
JSONObject jsonQuery = new JSONObject();
jsonQuery.put("execService", exec);
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Adding of exec service failed.");
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Exec service successfully added!");
events.onFinished(jso);
}
;
public void onLoadingStart() {
events.onLoadingStart();
}
;
};
// sending data
JsonPostClient jspc = new JsonPostClient(newEvents);
jspc.sendData(JSON_URL, jsonQuery);
}
use of com.google.gwt.json.client.JSONNumber in project perun by CESNET.
the class RemoveHosts method prepareJSONObject.
/**
* Prepares a JSON object
*
* @return JSONObject the whole query
*/
private JSONObject prepareJSONObject() {
JSONNumber cluster = new JSONNumber(clusterId);
JSONNumber host = new JSONNumber(hostId);
JSONArray ids = new JSONArray();
ids.set(0, host);
// whole JSON query
JSONObject jsonQuery = new JSONObject();
jsonQuery.put("facility", cluster);
jsonQuery.put("hosts", ids);
return jsonQuery;
}
use of com.google.gwt.json.client.JSONNumber in project perun by CESNET.
the class CreateDependency method createDependancy.
/**
* Add dependency for exec service on another exec service
*
* @param execService add dependency for
* @param dependsOn add dependency on
*/
public void createDependancy(final int execService, final 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("Adding dependency failed.");
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Dependency successfully added!");
events.onFinished(jso);
}
;
public void onLoadingStart() {
events.onLoadingStart();
}
;
};
// sending data
JsonPostClient jspc = new JsonPostClient(newEvents);
jspc.sendData(JSON_URL, jsonQuery);
}
use of com.google.gwt.json.client.JSONNumber in project perun by CESNET.
the class AddHosts method prepareJSONObject.
/**
* Prepares a JSON object
*
* @return JSONObject the whole query
*/
private JSONObject prepareJSONObject() {
JSONNumber facility = new JSONNumber(facilityId);
JSONArray hostnames = new JSONArray();
// put names in array
for (int i = 0; i < hostNames.length; i++) {
// empty host names are excluded
if (hostNames[i] == "")
continue;
hostnames.set(i, new JSONString(hostNames[i]));
}
// whole JSON query
JSONObject jsonQuery = new JSONObject();
jsonQuery.put("facility", facility);
jsonQuery.put("hostnames", hostnames);
return jsonQuery;
}
use of com.google.gwt.json.client.JSONNumber in project perun by CESNET.
the class AddOwner method prepareJSONObject.
/**
* Prepares a JSON object
*
* @return JSONObject the whole query
*/
private JSONObject prepareJSONObject() {
// whole JSON query
JSONObject jsonQuery = new JSONObject();
jsonQuery.put("facility", new JSONNumber(facility));
jsonQuery.put("owner", new JSONNumber(owner));
return jsonQuery;
}
Aggregations