use of com.google.gwt.json.client.JSONObject in project perun by CESNET.
the class CreateService method prepareJSONObject.
/**
* Prepares a JSON object
* @return JSONObject the whole query
*/
private JSONObject prepareJSONObject() {
// service
JSONObject service = new JSONObject();
// service name as object
service.put("name", new JSONString(serviceName));
// whole JSON query
JSONObject jsonQuery = new JSONObject();
// service object
jsonQuery.put("service", service);
return jsonQuery;
}
use of com.google.gwt.json.client.JSONObject in project perun by CESNET.
the class CreateServicePackage method prepareJSONObject.
/**
* Prepares a JSON object
* @return JSONObject the whole query
*/
private JSONObject prepareJSONObject() {
// service
JSONObject service = new JSONObject();
service.put("name", new JSONString(packageName));
service.put("description", new JSONString(packageDescription));
service.put("id", null);
// whole JSON query
JSONObject jsonQuery = new JSONObject();
jsonQuery.put("servicesPackage", service);
return jsonQuery;
}
use of com.google.gwt.json.client.JSONObject in project perun by CESNET.
the class SetLogin method prepareJSONObject.
/**
* Prepares a JSON object
*
* @return JSONObject the whole query
*/
private JSONObject prepareJSONObject() {
// create whole JSON query
JSONObject jsonQuery = new JSONObject();
jsonQuery.put("user", new JSONNumber(userId));
jsonQuery.put("login", new JSONString(login));
jsonQuery.put("namespace", new JSONString(namespace));
return jsonQuery;
}
use of com.google.gwt.json.client.JSONObject in project perun by CESNET.
the class UpdateNameTitles method updateUserTitles.
/**
* Updates user details
* @param user User with updated details
*/
public void updateUserTitles(User user) {
if (user == null) {
UiElements.generateAlert("Parameter error", "User to update can't be null");
return;
}
// OBJECT
JSONObject oldUser = new JSONObject(user);
// RECONSTRUCT OBJECT
JSONObject newUser = new JSONObject();
newUser.put("id", oldUser.get("id"));
newUser.put("firstName", oldUser.get("firstName"));
newUser.put("middleName", oldUser.get("middleName"));
newUser.put("lastName", oldUser.get("lastName"));
newUser.put("titleBefore", oldUser.get("titleBefore"));
newUser.put("titleAfter", oldUser.get("titleAfter"));
newUser.put("serviceUser", oldUser.get("serviceUser"));
// whole JSON query
JSONObject jsonQuery = new JSONObject();
jsonQuery.put("user", newUser);
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Updating user failed.");
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
User u = jso.cast();
session.getUiElements().setLogSuccessText("User " + u.getFullNameWithTitles() + " successfully updated!");
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.JSONObject in project perun by CESNET.
the class AddDestination method prepareJSONObject.
/**
* Prepares a JSON object
*
* @return JSONObject the whole query
*/
private JSONObject prepareJSONObject() {
// whole JSON query
JSONObject jsonQuery = new JSONObject();
jsonQuery.put("destination", new JSONString(destination));
jsonQuery.put("type", new JSONString(type));
jsonQuery.put("facility", new JSONNumber(facility.getId()));
JSONArray servs = new JSONArray();
for (int i = 0; i < services.size(); i++) {
// rebuild service object
JSONObject srv = new JSONObject();
srv.put("id", new JSONNumber(services.get(i).getId()));
srv.put("name", new JSONString(services.get(i).getName()));
servs.set(i, srv);
}
jsonQuery.put("services", servs);
return jsonQuery;
}
Aggregations