Example usage for com.liferay.portal.kernel.template TemplateVariableDefinition getClazz

List of usage examples for com.liferay.portal.kernel.template TemplateVariableDefinition getClazz

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.template TemplateVariableDefinition getClazz.

Prototype

public Class<?> getClazz() 

Source Link

Usage

From source file:com.liferay.dynamic.data.mapping.internal.util.DDMTemplateHelperImpl.java

License:Open Source License

@Override
public String getAutocompleteJSON(HttpServletRequest request, String language) throws Exception {

    JSONObject jsonObject = _jsonFactory.createJSONObject();

    JSONObject typesJSONObject = _jsonFactory.createJSONObject();
    JSONObject variablesJSONObject = _jsonFactory.createJSONObject();

    for (TemplateVariableDefinition templateVariableDefinition : getAutocompleteTemplateVariableDefinitions(
            request, language)) {/*from   w  ww .j av  a2 s. com*/

        Class<?> clazz = templateVariableDefinition.getClazz();

        if (clazz == null) {
            variablesJSONObject.put(templateVariableDefinition.getName(), StringPool.BLANK);
        } else {
            if (!typesJSONObject.has(clazz.getName())) {
                typesJSONObject.put(clazz.getName(), getAutocompleteClassJSONObject(clazz));
            }

            variablesJSONObject.put(templateVariableDefinition.getName(),
                    getAutocompleteVariableJSONObject(clazz));
        }
    }

    jsonObject.put("types", typesJSONObject);
    jsonObject.put("variables", variablesJSONObject);

    return jsonObject.toString();
}