Example usage for com.liferay.portal.kernel.util MapUtil getBoolean

List of usage examples for com.liferay.portal.kernel.util MapUtil getBoolean

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util MapUtil getBoolean.

Prototype

public static boolean getBoolean(Map<String, ?> map, String key, boolean defaultValue) 

Source Link

Usage

From source file:com.liferay.dynamic.data.mapping.form.evaluator.DDMFormFieldEvaluationResult.java

License:Open Source License

public boolean isValid() {
    return MapUtil.getBoolean(_properties, "valid", true);
}

From source file:com.liferay.dynamic.data.mapping.form.evaluator.DDMFormFieldEvaluationResult.java

License:Open Source License

public boolean isVisible() {
    return MapUtil.getBoolean(_properties, "visible", true);
}

From source file:com.liferay.dynamic.data.mapping.model.DDMFormField.java

License:Open Source License

public boolean isShowLabel() {
    return MapUtil.getBoolean(_properties, "showLabel", true);
}

From source file:com.liferay.layout.internal.exportimport.data.handler.StagedLayoutSetStagedModelDataHandler.java

License:Open Source License

protected void deleteMissingLayouts(PortletDataContext portletDataContext, List<Element> layoutElements) {

    boolean deleteMissingLayouts = MapUtil.getBoolean(portletDataContext.getParameterMap(),
            PortletDataHandlerKeys.DELETE_MISSING_LAYOUTS, Boolean.TRUE.booleanValue());

    if (!deleteMissingLayouts) {
        return;/*from w  w w.  j a  v  a 2  s . c  o m*/
    }

    List<Layout> previousLayouts = _layoutLocalService.getLayouts(portletDataContext.getGroupId(),
            portletDataContext.isPrivateLayout());

    Stream<Element> layoutElementsStream = layoutElements.stream();

    List<String> sourceLayoutUuids = layoutElementsStream
            .map(layoutElement -> layoutElement.attributeValue("uuid")).collect(Collectors.toList());

    if (_log.isDebugEnabled() && !sourceLayoutUuids.isEmpty()) {
        _log.debug("Delete missing layouts");
    }

    Map<Long, Long> layoutPlids = (Map<Long, Long>) portletDataContext.getNewPrimaryKeysMap(Layout.class);
    ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();

    for (Layout layout : previousLayouts) {
        if (!sourceLayoutUuids.contains(layout.getUuid()) && !layoutPlids.containsValue(layout.getPlid())) {

            try {
                _layoutLocalService.deleteLayout(layout, false, serviceContext);
            } catch (Exception e) {
            }
        }
    }
}

From source file:com.liferay.samplelar.plugin.LARPlugin.java

License:Open Source License

@Override
public String exportData(PortletDataContext context, String portletId, PortletPreferences preferences)
        throws PortletDataException {

    Map parameterMap = context.getParameterMap();

    boolean exportData = MapUtil.getBoolean(parameterMap, "export-sample-lar-portlet-data",
            _enableExport.getDefaultState());

    if (_log.isDebugEnabled()) {
        if (exportData) {
            _log.debug("Exporting data is enabled");
        } else {//from w ww  . j a  va  2  s.c o m
            _log.debug("Exporting data is disabled");
        }
    }

    if (!exportData) {
        return null;
    }

    try {
        long exportDate = System.currentTimeMillis();

        if (_log.isInfoEnabled()) {
            _log.info("Exporting LAR on " + new Date(exportDate));
        }

        preferences.setValue("last-export-date", String.valueOf(exportDate));

        preferences.store();

        String data = "<data-file />";

        ZipWriter zipWriter = context.getZipWriter();

        if (zipWriter != null) {
            boolean createReadMe = MapUtil.getBoolean(parameterMap, "create-readme",
                    _createReadme.getDefaultState());

            if (createReadMe) {
                if (_log.isInfoEnabled()) {
                    _log.info("Writing to zip");
                }

                zipWriter.addEntry(portletId + "/README.txt", "Test writing to zip.");
            }

            String dataType = MapUtil.getString(parameterMap, "data-type", _dataType.getDefaultChoice());

            if (Validator.equals(dataType, "csv")) {
                StringBuilder csv = new StringBuilder();

                csv.append("data 1," + new Date() + "\n");
                csv.append("data 2," + new Date() + "\n");

                String filePath = portletId + "/data.csv";

                data = "<data-file>" + filePath + "</data-file>";

                zipWriter.addEntry(filePath, csv.toString());
            } else if (Validator.equals(dataType, "xml")) {
                StringBuilder xml = new StringBuilder();

                xml.append("<?xml version=\"1.0\"?>\n\n");
                xml.append("<records>\n");
                xml.append("\t<record>\n");
                xml.append("\t\t<field>data 1</field>\n");
                xml.append("\t\t<field>" + new Date() + "</field>\n");
                xml.append("\t</record>\n");
                xml.append("\t<record>\n");
                xml.append("\t\t<field>data 2</field>\n");
                xml.append("\t\t<field>" + new Date() + "</field>\n");
                xml.append("\t</record>\n");
                xml.append("</records>");

                String filePath = portletId + "/data.xml";

                data = "<data-file>" + filePath + "</data-file>";

                zipWriter.addEntry(filePath, xml.toString());
            }
        }

        return data;
    } catch (Exception e) {
        throw new PortletDataException(e);
    }
}

From source file:com.liferay.samplelar.plugin.LARPlugin.java

License:Open Source License

@Override
public PortletPreferences importData(PortletDataContext context, String portletId,
        PortletPreferences preferences, String data) throws PortletDataException {

    Map parameterMap = context.getParameterMap();

    boolean importData = MapUtil.getBoolean(parameterMap, "import-sample-lar-portlet-data",
            _enableImport.getDefaultState());

    if (_log.isDebugEnabled()) {
        if (importData) {
            _log.debug("Importing data is enabled");
        } else {/*from   www.j  a v  a 2s  . com*/
            _log.debug("Importing data is disabled");
        }
    }

    if (!importData) {
        return null;
    }

    try {
        long importDate = System.currentTimeMillis();

        preferences.setValue("last-import-date", String.valueOf(importDate));

        if (_log.isInfoEnabled()) {
            _log.info("Importing data " + data);
        }

        ZipReader zipReader = context.getZipReader();

        if (zipReader != null) {
            _log.info("From README file:\n\n" + zipReader.getEntryAsString(portletId + "/README.txt"));
        }

        return preferences;
    } catch (Exception e) {
        throw new PortletDataException(e);
    }
}