Search in sources :

Example 91 with JSONString

use of com.google.gwt.json.client.JSONString in project rstudio by rstudio.

the class RemoteServer method getRmdPublishDetails.

@Override
public void getRmdPublishDetails(String target, ServerRequestCallback<RmdPublishDetails> requestCallback) {
    JSONArray params = new JSONArray();
    params.set(0, new JSONString(target));
    sendRequest(RPC_SCOPE, GET_RMD_PUBLISH_DETAILS, params, requestCallback);
}
Also used : JSONArray(com.google.gwt.json.client.JSONArray) JSONString(com.google.gwt.json.client.JSONString)

Example 92 with JSONString

use of com.google.gwt.json.client.JSONString in project pentaho-platform by pentaho.

the class PermissionsPanel method saveSecuritySettings.

private void saveSecuritySettings() {
    JSONObject jsNewRoleAssignments = new JSONObject();
    JSONArray jsLogicalRoleAssignments = new JSONArray();
    int x = 0;
    for (Map.Entry<String, List<String>> roleAssignment : newRoleAssignments.entrySet()) {
        JSONArray jsLogicalRoles = new JSONArray();
        int y = 0;
        for (String logicalRoleName : roleAssignment.getValue()) {
            jsLogicalRoles.set(y++, new JSONString(logicalRoleName));
        }
        JSONObject jsRoleAssignment = new JSONObject();
        jsRoleAssignment.put("roleName", new JSONString(roleAssignment.getKey()));
        jsRoleAssignment.put("logicalRoles", jsLogicalRoles);
        jsLogicalRoleAssignments.set(x++, jsRoleAssignment);
    }
    jsNewRoleAssignments.put("assignments", jsLogicalRoleAssignments);
    RequestBuilder saveSettingRequestBuilder = new RequestBuilder(RequestBuilder.PUT, GWT.getHostPageBaseURL() + "api/userroledao/roleAssignments");
    saveSettingRequestBuilder.setHeader("Content-Type", "application/json");
    saveSettingRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
    try {
        saveSettingRequestBuilder.sendRequest(jsNewRoleAssignments.toString(), new RequestCallback() {

            public void onError(Request request, Throwable exception) {
            }

            public void onResponseReceived(Request request, Response response) {
                if (response.getStatusCode() == 200) {
                    masterRoleMap.putAll(newRoleAssignments);
                    newRoleAssignments.clear();
                }
            }
        });
    } catch (RequestException e) {
    // ignored
    }
}
Also used : RequestBuilder(com.google.gwt.http.client.RequestBuilder) JSONArray(com.google.gwt.json.client.JSONArray) Request(com.google.gwt.http.client.Request) JSONString(com.google.gwt.json.client.JSONString) JsArrayString(com.google.gwt.core.client.JsArrayString) RequestException(com.google.gwt.http.client.RequestException) Response(com.google.gwt.http.client.Response) JSONObject(com.google.gwt.json.client.JSONObject) RequestCallback(com.google.gwt.http.client.RequestCallback) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) JSONString(com.google.gwt.json.client.JSONString)

Example 93 with JSONString

use of com.google.gwt.json.client.JSONString in project pentaho-platform by pentaho.

the class GeneralPanel method setMetadataResponse.

/**
 * Accept metadata response object and parse for use in General panel
 *
 * @param response
 */
protected void setMetadataResponse(Response response) {
    JSONObject json = (JSONObject) JSONParser.parseLenient(response.getText());
    if (json != null) {
        JSONArray arr = (JSONArray) json.get("stringKeyStringValueDto");
        for (int i = 0; i < arr.size(); i++) {
            JSONValue arrVal = arr.get(i);
            String key = arrVal.isObject().get("key").isString().stringValue();
            if (key != null && SolutionBrowserPanel.getInstance().isAdministrator()) {
                if (key.equals(org.pentaho.platform.api.repository2.unified.RepositoryFile.SCHEDULABLE_KEY) && !fileSummary.isFolder() || key.equals(org.pentaho.platform.api.repository2.unified.RepositoryFile.HIDDEN_KEY)) {
                    String value = arrVal.isObject().get("value").isString().stringValue();
                    if (key.startsWith(METADATA_PERM_PREFIX)) {
                        JSONObject nv = new JSONObject();
                        nv.put(key, new JSONString(value));
                        metadataPerms.add(nv);
                    }
                }
            }
        }
        for (final JSONObject nv : metadataPerms) {
            Set<String> keys = nv.keySet();
            for (final String key : keys) {
                if (key != null && SolutionBrowserPanel.getInstance().isAdministrator()) {
                    if (key.equals(org.pentaho.platform.api.repository2.unified.RepositoryFile.SCHEDULABLE_KEY) && !fileSummary.isFolder() || key.equals(org.pentaho.platform.api.repository2.unified.RepositoryFile.HIDDEN_KEY)) {
                        final CheckBox cb = new CheckBox(Messages.getString(key.substring(METADATA_PERM_PREFIX.length()).toLowerCase()));
                        cb.setWordWrap(false);
                        cb.setValue(Boolean.parseBoolean(nv.get(key).isString().stringValue()));
                        cb.addClickHandler(new ClickHandler() {

                            @Override
                            public void onClick(ClickEvent event) {
                                dirty = true;
                                nv.put(key, new JSONString(cb.getValue().toString()));
                            }
                        });
                        metadataPermsPanel.add(cb);
                    }
                }
            }
        }
    }
}
Also used : JSONValue(com.google.gwt.json.client.JSONValue) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JSONObject(com.google.gwt.json.client.JSONObject) CheckBox(com.google.gwt.user.client.ui.CheckBox) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) JSONArray(com.google.gwt.json.client.JSONArray) JSONString(com.google.gwt.json.client.JSONString) JSONString(com.google.gwt.json.client.JSONString)

Example 94 with JSONString

use of com.google.gwt.json.client.JSONString in project pentaho-platform by pentaho.

the class RunInBackgroundCommand method getJsonSimpleTrigger.

@SuppressWarnings("deprecation")
protected JSONObject getJsonSimpleTrigger(int repeatCount, int interval, Date startDate, Date endDate) {
    JSONObject trigger = new JSONObject();
    // $NON-NLS-1$
    trigger.put("repeatInterval", new JSONNumber(interval));
    // $NON-NLS-1$
    trigger.put("repeatCount", new JSONNumber(repeatCount));
    trigger.put("startTime", // $NON-NLS-1$
    startDate != null ? new JSONString(DateTimeFormat.getFormat(PredefinedFormat.ISO_8601).format(startDate)) : JSONNull.getInstance());
    if (endDate != null) {
        endDate.setHours(23);
        endDate.setMinutes(59);
        endDate.setSeconds(59);
    }
    trigger.put("endTime", // $NON-NLS-1$
    endDate == null ? JSONNull.getInstance() : new JSONString(DateTimeFormat.getFormat(PredefinedFormat.ISO_8601).format(endDate)));
    return trigger;
}
Also used : JSONObject(com.google.gwt.json.client.JSONObject) JSONNumber(com.google.gwt.json.client.JSONNumber) JSONString(com.google.gwt.json.client.JSONString)

Example 95 with JSONString

use of com.google.gwt.json.client.JSONString in project pentaho-platform by pentaho.

the class FavoritePickItem method toJson.

public JSONObject toJson() {
    JSONObject jso = new JSONObject();
    jso.put("fullPath", new JSONString(fullPath));
    if (lastUse != null) {
        jso.put("title", new JSONString(title));
        jso.put("lastUse", new JSONNumber(lastUse));
    }
    return jso;
}
Also used : JSONObject(com.google.gwt.json.client.JSONObject) JSONNumber(com.google.gwt.json.client.JSONNumber) JSONString(com.google.gwt.json.client.JSONString)

Aggregations

JSONString (com.google.gwt.json.client.JSONString)277 JSONArray (com.google.gwt.json.client.JSONArray)189 JSONObject (com.google.gwt.json.client.JSONObject)110 JSONNumber (com.google.gwt.json.client.JSONNumber)85 JSONValue (com.google.gwt.json.client.JSONValue)13 HashMap (java.util.HashMap)12 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)10 Map (java.util.Map)10 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)9 PerunError (cz.metacentrum.perun.webgui.model.PerunError)9 Material (org.cesiumjs.cs.scene.Material)9 MaterialOptions (org.cesiumjs.cs.scene.options.MaterialOptions)9 JsonPostClient (cz.metacentrum.perun.webgui.json.JsonPostClient)8 MetaData (com.ait.tooling.nativetools.client.collection.MetaData)7 ArrayList (java.util.ArrayList)7 JsArrayString (com.google.gwt.core.client.JsArrayString)6 RequestBuilder (com.google.gwt.http.client.RequestBuilder)6 Breakpoint (org.rstudio.studio.client.common.debugging.model.Breakpoint)6 Point (org.rstudio.studio.client.workbench.views.plots.model.Point)6 Request (com.google.gwt.http.client.Request)5