Example usage for com.liferay.portal.kernel.json JSONFactory createJSONObject

List of usage examples for com.liferay.portal.kernel.json JSONFactory createJSONObject

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.json JSONFactory createJSONObject.

Prototype

public JSONObject createJSONObject();

Source Link

Usage

From source file:com.liferay.dynamic.data.mapping.form.web.internal.display.context.DDMFormAdminFieldSetDisplayContext.java

License:Open Source License

@Override
public String getFormLocalizedDescription() throws PortalException {
    DDMStructure structure = getDDMStructure();

    JSONFactory jsonFactory = getJSONFactory();

    JSONObject jsonObject = jsonFactory.createJSONObject();

    if (structure == null) {
        jsonObject.put(getDefaultLanguageId(), "");
    } else {/*from  w  w  w  . j  a  v  a  2 s.c  o  m*/
        Map<Locale, String> descriptionMap = structure.getDescriptionMap();

        for (Map.Entry<Locale, String> entry : descriptionMap.entrySet()) {
            jsonObject.put(LocaleUtil.toLanguageId(entry.getKey()), entry.getValue());
        }
    }

    return jsonObject.toString();
}

From source file:com.liferay.dynamic.data.mapping.form.web.internal.display.context.DDMFormAdminFieldSetDisplayContext.java

License:Open Source License

@Override
public String getFormLocalizedName() throws PortalException {
    DDMStructure structure = getDDMStructure();

    JSONFactory jsonFactory = getJSONFactory();

    JSONObject jsonObject = jsonFactory.createJSONObject();

    if (structure == null) {
        jsonObject.put(getDefaultLanguageId(), "");
    } else {/*from  ww  w .  j a v  a 2s .  c om*/
        Map<Locale, String> nameMap = structure.getNameMap();

        for (Map.Entry<Locale, String> entry : nameMap.entrySet()) {
            jsonObject.put(LocaleUtil.toLanguageId(entry.getKey()), entry.getValue());
        }
    }

    return jsonObject.toString();
}

From source file:com.liferay.message.boards.internal.search.MBIndexerGetFullQueryTest.java

License:Open Source License

protected void setUpJSONFactoryUtil() {
    JSONFactoryUtil jsonFactoryUtil = new JSONFactoryUtil();

    JSONFactory jsonFactory = mock(JSONFactory.class);

    when(jsonFactory.createJSONObject()).thenReturn(mock(JSONObject.class));

    jsonFactoryUtil.setJSONFactory(jsonFactory);
}