Example usage for com.google.gwt.json.client JSONValue isObject

List of usage examples for com.google.gwt.json.client JSONValue isObject

Introduction

In this page you can find the example usage for com.google.gwt.json.client JSONValue isObject.

Prototype

public JSONObject isObject() 

Source Link

Document

Returns non-null if this JSONValue is really a JSONObject.

Usage

From source file:org.jboss.errai.jpa.client.local.ErraiManagedType.java

License:Apache License

protected <Y> void parseSingularJsonReference(X targetEntity, ErraiSingularAttribute<? super X, Y> attr,
        JSONValue attrJsonValue, ErraiEntityManager eem) {

    if (attrJsonValue == null || attrJsonValue.isNull() != null)
        return;/*from  w  w  w .  ja  v  a2  s. c om*/

    Key<Y, ?> key = (Key<Y, ?>) Key.fromJsonObject(eem, attrJsonValue.isObject(), true);
    logger.trace("   looking for " + key);
    Y value = eem.find(key, Collections.<String, Object>emptyMap());
    attr.set(targetEntity, value);
}

From source file:org.jbpm.console.ng.df.client.filter.json.DataSetLookupJSONMarshaller.java

License:Apache License

private DataSetGroup parseDataSetGroup(JSONObject dataSetGroupJson) {
    if (dataSetGroupJson == null)
        return null;

    DataSetGroup dataSetGroup = new DataSetGroup();

    dataSetGroup.setColumnGroup(null);/*w  w  w  . j a  v  a  2 s .  c  om*/
    JSONValue value = dataSetGroupJson.get(COLUMNGROUP);
    if (value != null)
        dataSetGroup.setColumnGroup(parseColumnGroup(value.isObject()));

    List<GroupFunction> groupFunctions = parseGroupFunctions(
            (value = dataSetGroupJson.get(GROUPFUNCTIONS)) != null ? value.isArray() : null);
    if (groupFunctions != null)
        dataSetGroup.getGroupFunctions().addAll(groupFunctions);

    dataSetGroup.setSelectedIntervalList(null);
    value = dataSetGroupJson.get(SELECTEDINTERVALS);
    if (value != null)
        dataSetGroup.setSelectedIntervalList(parseSelectedIntervals(value.isArray()));

    dataSetGroup.setJoin(false);
    value = dataSetGroupJson.get(JOIN);
    if (value != null)
        dataSetGroup.setJoin(Boolean.valueOf(value.isString().stringValue()));

    return dataSetGroup;
}

From source file:org.jbpm.console.ng.df.client.filter.json.DisplayerSettingsJSONMarshaller.java

License:Apache License

public DisplayerSettings fromJsonString(String jsonString) {
    DisplayerSettings ds = new DisplayerSettings();

    if (!StringUtils.isBlank(jsonString)) {

        JSONObject parseResult = JSONParser.parseStrict(jsonString).isObject();

        if (parseResult != null) {

            // UUID
            JSONValue uuidValue = parseResult.get(SETTINGS_UUID);
            ds.setUUID(uuidValue != null && uuidValue.isString() != null ? uuidValue.isString().stringValue()
                    : null);//from   w w  w .ja  va2  s  . c o m

            // First look if a dataset 'on-the-fly' has been specified
            JSONValue data = parseResult.get(DATASET_PREFIX);
            if (data != null) {
                DataSet dataSet = dataSetJSONMarshaller.fromJson(data.isObject());
                ds.setDataSet(dataSet);

                // Remove from the json input so that it doesn't end up in the settings map.
                parseResult.put(DATASET_PREFIX, null);

                // If none was found, look for a dataset lookup definition
            } else if ((data = parseResult.get(DATASET_LOOKUP_PREFIX)) != null) {
                DataSetLookup dataSetLookup = dataSetLookupJSONMarshaller.fromJson(data.isObject());
                ds.setDataSetLookup(dataSetLookup);

                // Remove from the json input so that it doesn't end up in the settings map.
                parseResult.put(DATASET_LOOKUP_PREFIX, null);
            } else {
                throw new RuntimeException(
                        FiltersConstants.INSTANCE.json_displayersettings_dataset_lookup_notspecified());
            }

            // Parse the columns settings
            JSONValue columns = parseResult.get(COLUMNS_PREFIX);
            if (columns != null) {
                List<ColumnSettings> columnSettingsList = parseColumnsFromJson(columns.isArray());
                ds.setColumnSettingsList(columnSettingsList);

                // Remove from the json input so that it doesn't end up in the settings map.
                parseResult.put(COLUMNS_PREFIX, null);
            }

            // Now parse all other settings
            ds.setSettingsFlatMap(parseSettingsFromJson(parseResult));
        }
    }
    return ds;
}

From source file:org.jbpm.console.ng.df.client.filter.json.DisplayerSettingsJSONMarshaller.java

License:Apache License

private void fillRecursive(String parentPath, JSONObject json, Map<String, String> settings) {
    String sb = StringUtils.isBlank(parentPath) ? "" : parentPath + ".";
    for (String key : json.keySet()) {
        String path = sb + key;/* ww w  .  j  a v  a  2 s  .  c o m*/
        JSONValue value = json.get(key);
        if (value.isObject() != null)
            fillRecursive(path, value.isObject(), settings);
        else if (value.isString() != null)
            settings.put(path, value.isString().stringValue());
    }
}

From source file:org.jbpm.console.ng.ht.forms.client.display.displayers.process.PlaceManagerStartProcessDisplayerImpl.java

License:Apache License

@Override
protected void initDisplayer() {
    JSONValue jsonValue = JSONParser.parseStrict(formContent);

    JSONObject jsonObject = jsonValue.isObject();

    if (jsonObject != null) {
        formContainer.setWidth("100%");
        formContainer.setHeight("400px");

        JSONValue jsonDestination = jsonObject.get("destination");

        if (jsonDestination == null)
            return;

        String destination = jsonDestination.isString().stringValue();

        JSONObject jsonParams = jsonObject.get("params").isObject();

        if (jsonParams == null)
            return;

        Map<String, String> params = jsniHelper.parseParams(jsonParams);

        placeManagerFormActivitySearcher.findFormActivityWidget(destination, formContainer);
        setFormParamsEvent.fire(new SetFormParamsEvent(params, false));
    }//w w  w  .ja  va 2s  . com
}

From source file:org.jbpm.console.ng.ht.forms.client.display.displayers.process.PlaceManagerStartProcessDisplayerImpl.java

License:Apache License

@Override
public boolean supportsContent(String content) {
    try {//from w  w w .j  av  a  2  s. co m
        JSONValue jsonValue = JSONParser.parseStrict(content);

        JSONObject jsonObject;

        if ((jsonObject = jsonValue.isObject()) == null)
            return false;

        jsonValue = jsonObject.get("handler");

        if (jsonValue.isString() == null)
            return false;

        return jsonValue.isString().stringValue().equals("handledByPlaceManagerFormProvider");
    } catch (Exception e) {
    }
    return false;
}

From source file:org.jbpm.console.ng.ht.forms.client.display.displayers.task.PlaceManagerTaskDisplayerImpl.java

License:Apache License

@Override
protected void initDisplayer() {
    JSONValue jsonValue = JSONParser.parseStrict(formContent);

    JSONObject jsonObject = jsonValue.isObject();

    if (jsonObject != null) {
        formContainer.setWidth("100%");
        formContainer.setHeight("400px");

        JSONValue jsonDestination = jsonObject.get("destination");

        if (jsonDestination == null)
            return;

        String destination = jsonDestination.isString().stringValue();

        JSONObject jsonParams = jsonObject.get("params").isObject();

        if (jsonParams == null)
            return;

        Map<String, String> params = jsniHelper.parseParams(jsonParams);

        String taskStatus = params.get("taskStatus");

        placeManagerFormActivitySearcher.findFormActivityWidget(destination, formContainer);

        if ("InProgress".equals(taskStatus)) {
            setFormParamsEvent.fire(new SetFormParamsEvent(params, false));
        } else {//  ww w  .  java 2s.  c om
            setFormParamsEvent.fire(new SetFormParamsEvent(params, true));
        }
    }
}

From source file:org.jbpm.formapi.client.form.FormRepresentationDecoderClient.java

License:Apache License

@Override
public FormRepresentation decode(String code) throws FormEncodingException {
    FormRepresentation form = new FormRepresentation();
    JSONValue json = JSONParser.parseLenient(code);
    if (json.isObject() != null) {
        JSONObject jsonObj = json.isObject();
        if (jsonObj.get("action").isString() != null) {
            form.setAction(jsonObj.get("action").isString().stringValue());
        }/* ww w.j  a va 2 s  . c om*/
        if (jsonObj.get("documentation").isString() != null) {
            form.setDocumentation(jsonObj.get("documentation").isString().stringValue());
        }
        if (jsonObj.get("enctype").isString() != null) {
            form.setEnctype(jsonObj.get("enctype").isString().stringValue());
        }
        if (jsonObj.get("lastModified").isNumber() != null) {
            form.setLastModified(
                    Double.valueOf(jsonObj.get("lastModified").isNumber().doubleValue()).longValue());
        } else if (jsonObj.get("lastModified").isString() != null) {
            form.setLastModified(
                    Double.valueOf(jsonObj.get("lastModified").isString().stringValue()).longValue());
        }
        if (jsonObj.get("method").isString() != null) {
            form.setMethod(jsonObj.get("method").isString().stringValue());
        }
        if (jsonObj.get("name").isString() != null) {
            form.setName(jsonObj.get("name").isString().stringValue());
        }
        if (jsonObj.get("taskId").isString() != null) {
            form.setTaskId(jsonObj.get("taskId").isString().stringValue());
        }
        if (jsonObj.get("processName").isString() != null) {
            form.setProcessName(jsonObj.get("processName").isString().stringValue());
        }
        form.setFormItems(decodeItems(jsonObj.get("formItems")));
        form.setFormValidations(decodeValidations(jsonObj.get("formValidations")));
        form.setInputs(decodeInputs(jsonObj.get("inputs")));
        form.setOutputs(decodeOutputs(jsonObj.get("outputs")));
        form.setOnLoadScripts(decodeScripts(jsonObj.get("onLoadScripts")));
        form.setOnSubmitScripts(decodeScripts(jsonObj.get("onSubmitScripts")));
    }
    return form;
}

From source file:org.jbpm.formapi.client.form.FormRepresentationDecoderClient.java

License:Apache License

@Override
public FormItemRepresentation decodeItem(String json) throws FormEncodingException {
    JSONValue jsonValue = JSONParser.parseLenient(json);
    if (jsonValue.isObject() != null) {
        JSONObject jsonObj = jsonValue.isObject();
        Map<String, Object> dataMap = asMap(jsonObj);
        return (FormItemRepresentation) decode(dataMap);
    } else {/*from w w  w  . j  a va  2  s . c om*/
        throw new FormEncodingException("Expected JSON Object: " + jsonValue);
    }
}

From source file:org.jbpm.formapi.client.form.FormRepresentationDecoderClient.java

License:Apache License

public Map<String, InputData> decodeInputs(JSONValue json) throws FormEncodingException {
    Map<String, InputData> retval = new HashMap<String, InputData>();
    if (json != null && json.isObject() != null) {
        for (String key : json.isObject().keySet()) {
            JSONValue value = json.isObject().get(key);
            if (value.isObject() != null) {
                JSONObject jsonObj = value.isObject();
                retval.put(key, (InputData) decode(asMap(jsonObj)));
            }/*from  w  ww.  j  a  va  2  s .c o m*/
        }
    }
    return retval;
}